2023-03-01 12:25:48 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Editor groups a collection of contents in tabs.
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/editor/)
|
|
|
|
*
|
|
|
|
* @module editor
|
|
|
|
*
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
import { VNode } from 'vue';
|
2023-07-06 11:17:08 +00:00
|
|
|
import { ComponentHooks } from '../basecomponent';
|
2023-09-05 08:50:46 +00:00
|
|
|
import { PassThroughOptions } from '../passthrough';
|
2023-09-05 11:28:04 +00:00
|
|
|
import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
|
2023-09-05 08:50:46 +00:00
|
|
|
|
2023-07-11 22:42:43 +00:00
|
|
|
export declare type EditorPassThroughOptionType = EditorPassThroughAttributes | ((options: EditorPassThroughMethodOptions) => EditorPassThroughAttributes | string) | string | null | undefined;
|
2023-05-05 10:15:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) option method.
|
|
|
|
*/
|
|
|
|
export interface EditorPassThroughMethodOptions {
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines instance.
|
|
|
|
*/
|
2023-07-06 12:01:33 +00:00
|
|
|
instance: any;
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines valid properties.
|
|
|
|
*/
|
2023-05-05 10:15:25 +00:00
|
|
|
props: EditorProps;
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines current inline state.
|
|
|
|
*/
|
2023-05-05 10:15:25 +00:00
|
|
|
state: EditorState;
|
2023-09-05 08:50:46 +00:00
|
|
|
/**
|
|
|
|
* Defines passthrough(pt) options in global config.
|
|
|
|
*/
|
|
|
|
global: object | undefined;
|
2023-05-05 10:15:25 +00:00
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2023-03-01 12:25:48 +00:00
|
|
|
/**
|
|
|
|
* Custom text change event.
|
2023-03-06 20:35:39 +00:00
|
|
|
* @see {@link EditorEmits['text-change']}
|
2023-03-01 12:25:48 +00:00
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface EditorTextChangeEvent {
|
|
|
|
/**
|
|
|
|
* Current value as html.
|
|
|
|
*/
|
|
|
|
htmlValue: string;
|
|
|
|
/**
|
|
|
|
* Current value as text.
|
|
|
|
*/
|
|
|
|
textValue: any;
|
|
|
|
/**
|
|
|
|
* Representation of the change.
|
|
|
|
*/
|
|
|
|
delta: any;
|
|
|
|
/**
|
|
|
|
* Source of change. Will be either 'user' or 'api'.
|
|
|
|
*/
|
|
|
|
source: string;
|
|
|
|
/**
|
|
|
|
* Text editor instance.
|
|
|
|
*/
|
|
|
|
instance: any;
|
|
|
|
}
|
2023-03-01 12:25:48 +00:00
|
|
|
/**
|
|
|
|
* Custom selection change event.
|
2023-03-06 20:35:39 +00:00
|
|
|
* @see {@link EditorEmits['selection-change']}
|
2023-03-01 12:25:48 +00:00
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface EditorSelectionChangeEvent {
|
|
|
|
/**
|
|
|
|
* Current value as html.
|
|
|
|
*/
|
|
|
|
htmlValue: string;
|
|
|
|
/**
|
|
|
|
* Current value as text.
|
|
|
|
*/
|
|
|
|
textValue: any;
|
|
|
|
/**
|
|
|
|
* Representation of the selection boundaries.
|
|
|
|
*/
|
|
|
|
range: any;
|
|
|
|
/**
|
|
|
|
* Representation of the previous selection boundaries.
|
|
|
|
*/
|
|
|
|
oldRange: any;
|
|
|
|
/**
|
|
|
|
* Source of change. Will be either 'user' or 'api'.
|
|
|
|
*/
|
|
|
|
source: string;
|
|
|
|
/**
|
|
|
|
* Text editor instance.
|
|
|
|
*/
|
|
|
|
instance: any;
|
|
|
|
}
|
2023-03-01 12:25:48 +00:00
|
|
|
/**
|
|
|
|
* Custom load event.
|
2023-03-06 20:35:39 +00:00
|
|
|
* @see {@link EditorEmits.load}
|
2023-03-01 12:25:48 +00:00
|
|
|
*/
|
2022-09-14 11:26:01 +00:00
|
|
|
export interface EditorLoadEvent {
|
|
|
|
/**
|
|
|
|
* Text editor instance.
|
|
|
|
*/
|
|
|
|
instance: any;
|
|
|
|
}
|
|
|
|
|
2023-05-05 10:15:25 +00:00
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) options.
|
|
|
|
* @see {@link EditorProps.pt}
|
|
|
|
*/
|
|
|
|
export interface EditorPassThroughOptions {
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the root's DOM element.
|
2023-05-05 10:15:25 +00:00
|
|
|
*/
|
|
|
|
root?: EditorPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the toolbar's DOM element.
|
2023-05-05 10:15:25 +00:00
|
|
|
*/
|
|
|
|
toolbar?: EditorPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the formats' DOM element.
|
2023-05-05 10:15:25 +00:00
|
|
|
*/
|
|
|
|
formats?: EditorPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the header's DOM element.
|
2023-05-05 10:15:25 +00:00
|
|
|
*/
|
2023-05-25 14:18:27 +00:00
|
|
|
header?: EditorPassThroughOptionType;
|
2023-05-05 10:15:25 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the option's DOM element.
|
2023-05-05 10:15:25 +00:00
|
|
|
*/
|
|
|
|
option?: EditorPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the bold's DOM element.
|
2023-05-25 14:18:27 +00:00
|
|
|
*/
|
|
|
|
bold?: EditorPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the italic's DOM element.
|
2023-05-25 14:18:27 +00:00
|
|
|
*/
|
|
|
|
italic?: EditorPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the underline's DOM element.
|
2023-05-25 14:18:27 +00:00
|
|
|
*/
|
|
|
|
underline?: EditorPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the color's DOM element.
|
2023-05-25 14:18:27 +00:00
|
|
|
*/
|
|
|
|
color?: EditorPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the background's DOM element.
|
2023-05-05 10:15:25 +00:00
|
|
|
*/
|
2023-05-25 14:18:27 +00:00
|
|
|
background?: EditorPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the list's DOM element.
|
2023-05-25 14:18:27 +00:00
|
|
|
*/
|
|
|
|
list?: EditorPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the select's DOM element.
|
2023-05-25 14:18:27 +00:00
|
|
|
*/
|
|
|
|
select?: EditorPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the link's DOM element.
|
2023-05-25 14:18:27 +00:00
|
|
|
*/
|
|
|
|
link?: EditorPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the image's DOM element.
|
2023-05-25 14:18:27 +00:00
|
|
|
*/
|
|
|
|
image?: EditorPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the code block's DOM element.
|
2023-05-25 14:18:27 +00:00
|
|
|
*/
|
|
|
|
codeBlock?: EditorPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the clean's DOM element.
|
2023-05-25 14:18:27 +00:00
|
|
|
*/
|
|
|
|
clean?: EditorPassThroughOptionType;
|
2023-05-05 10:15:25 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the content's DOM element.
|
2023-05-05 10:15:25 +00:00
|
|
|
*/
|
|
|
|
content?: EditorPassThroughOptionType;
|
2023-07-06 11:09:01 +00:00
|
|
|
/**
|
2023-11-07 06:16:39 +00:00
|
|
|
* Used to manage all lifecycle hooks.
|
2023-07-06 11:09:01 +00:00
|
|
|
* @see {@link BaseComponent.ComponentHooks}
|
|
|
|
*/
|
|
|
|
hooks?: ComponentHooks;
|
2023-05-05 10:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough attributes for each DOM elements
|
|
|
|
*/
|
|
|
|
export interface EditorPassThroughAttributes {
|
|
|
|
[key: string]: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines current inline state in Editor component.
|
|
|
|
*/
|
|
|
|
export interface EditorState {
|
|
|
|
/**
|
|
|
|
* Current rerendered color key as a number.
|
|
|
|
* @defaultValue 0
|
|
|
|
*/
|
|
|
|
reRenderColorKey: number;
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:25:48 +00:00
|
|
|
/**
|
|
|
|
* Defines valid properties in Editor component.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface EditorProps {
|
|
|
|
/**
|
|
|
|
* Value of the content.
|
|
|
|
*/
|
|
|
|
modelValue?: string | undefined;
|
|
|
|
/**
|
|
|
|
* Placeholder text to show when editor is empty.
|
|
|
|
*/
|
|
|
|
placeholder?: string | undefined;
|
|
|
|
/**
|
|
|
|
* Whether to instantiate the editor to readonly mode.
|
2023-03-10 14:00:58 +00:00
|
|
|
* @defaultValue false
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
readonly?: boolean | undefined;
|
|
|
|
/**
|
2023-10-11 08:45:10 +00:00
|
|
|
* Whitelist of formats to display, see [here](https://quilljs.com/docs/formats/) for available options.
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
formats?: any[];
|
|
|
|
/**
|
|
|
|
* Inline style of the container.
|
|
|
|
*/
|
|
|
|
editorStyle?: any;
|
2022-09-14 11:26:01 +00:00
|
|
|
/**
|
2023-10-11 08:45:10 +00:00
|
|
|
* Modules configuration, see [here](https://quilljs.com/docs/modules/) for available options.
|
2022-09-14 11:26:01 +00:00
|
|
|
*/
|
|
|
|
modules?: any;
|
2023-05-05 10:15:25 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to DOM elements inside the component.
|
2023-05-05 10:15:25 +00:00
|
|
|
* @type {EditorPassThroughOptions}
|
|
|
|
*/
|
2023-09-05 11:28:04 +00:00
|
|
|
pt?: PassThrough<EditorPassThroughOptions>;
|
2023-09-05 08:50:46 +00:00
|
|
|
/**
|
|
|
|
* Used to configure passthrough(pt) options of the component.
|
|
|
|
* @type {PassThroughOptions}
|
|
|
|
*/
|
|
|
|
ptOptions?: PassThroughOptions;
|
2023-05-25 14:18:27 +00:00
|
|
|
/**
|
|
|
|
* When enabled, it removes component related styles in the core.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
unstyled?: boolean;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 12:25:48 +00:00
|
|
|
/**
|
|
|
|
* Defines valid slots in Editor slots.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface EditorSlots {
|
|
|
|
/**
|
|
|
|
* Custom toolbar template.
|
|
|
|
*/
|
|
|
|
toolbar: () => VNode[];
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:25:48 +00:00
|
|
|
/**
|
|
|
|
* Defines valid emits in Editor component.
|
|
|
|
*/
|
|
|
|
export interface EditorEmits {
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Emitted when the value changes.
|
|
|
|
* @param {string} value - New value.
|
|
|
|
*/
|
2023-03-01 12:25:48 +00:00
|
|
|
'update:modelValue'(value: string): void;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when text of editor changes.
|
|
|
|
* @param {EditorTextChangeEvent} event - Custom text change event.
|
|
|
|
*/
|
2023-03-01 12:25:48 +00:00
|
|
|
'text-change'(event: EditorTextChangeEvent): void;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when selection of the text changes.
|
|
|
|
* @param {EditorSelectionChangeEvent} event - Custom selection change event.
|
|
|
|
*/
|
2023-03-01 12:25:48 +00:00
|
|
|
'selection-change'(event: EditorSelectionChangeEvent): void;
|
2022-09-14 11:26:01 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when the quill modules are loaded.
|
|
|
|
* @param {EditorLoadEvent} event - Custom load event.
|
|
|
|
*/
|
2023-03-01 12:25:48 +00:00
|
|
|
load(event: EditorLoadEvent): void;
|
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2023-03-01 12:25:48 +00:00
|
|
|
/**
|
|
|
|
* **PrimeVue - Editor**
|
|
|
|
*
|
|
|
|
* _Editor groups a collection of contents in tabs._
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/editor/)
|
|
|
|
* --- ---
|
2023-03-03 10:55:20 +00:00
|
|
|
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
|
2023-03-01 12:25:48 +00:00
|
|
|
*
|
|
|
|
* @group Component
|
|
|
|
*
|
|
|
|
*/
|
2022-09-14 11:26:01 +00:00
|
|
|
declare class Editor extends ClassComponent<EditorProps, EditorSlots, EditorEmits> {}
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
declare module '@vue/runtime-core' {
|
|
|
|
interface GlobalComponents {
|
2022-09-14 11:26:01 +00:00
|
|
|
Editor: GlobalComponentConstructor<Editor>;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Editor;
|