-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
c89c723
commit 5e8048b
Showing
12 changed files
with
2,879 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
/// <reference types="react" /> | ||
import * as PropTypes from 'prop-types'; | ||
import { CKEditorProps, CKEditorType } from './types'; | ||
/** | ||
* `CKEditor` component is a convenient wrapper around low-level hooks. | ||
* It's useful for simpler use cases. For advanced usage see `useCKEditor` hook. | ||
*/ | ||
declare function CKEditor<EventHandlerProp>({ config, debug, editorUrl, initData, name, readOnly, style, type, | ||
/** | ||
* `handlers` object must contain event handlers props only! | ||
*/ | ||
...handlers }: CKEditorProps<EventHandlerProp>): JSX.Element; | ||
declare namespace CKEditor { | ||
var propTypes: { | ||
onPaste: PropTypes.Requireable<(...args: any[]) => any>; | ||
onFocus: PropTypes.Requireable<(...args: any[]) => any>; | ||
onBlur: PropTypes.Requireable<(...args: any[]) => any>; | ||
onChange: PropTypes.Requireable<(...args: any[]) => any>; | ||
onResize: PropTypes.Requireable<(...args: any[]) => any>; | ||
onDrop: PropTypes.Requireable<(...args: any[]) => any>; | ||
onBeforeLoad: PropTypes.Requireable<(...args: any[]) => any>; | ||
onNamespaceLoaded: PropTypes.Requireable<(...args: any[]) => any>; | ||
onActiveEnterModeChange: PropTypes.Requireable<(...args: any[]) => any>; | ||
onActiveFilterChange: PropTypes.Requireable<(...args: any[]) => any>; | ||
onAfterCommandExec: PropTypes.Requireable<(...args: any[]) => any>; | ||
onAfterInsertHtml: PropTypes.Requireable<(...args: any[]) => any>; | ||
onAfterPaste: PropTypes.Requireable<(...args: any[]) => any>; | ||
onAfterPasteFromWord: PropTypes.Requireable<(...args: any[]) => any>; | ||
onAfterSetData: PropTypes.Requireable<(...args: any[]) => any>; | ||
onAfterUndoImage: PropTypes.Requireable<(...args: any[]) => any>; | ||
onAriaEditorHelpLabel: PropTypes.Requireable<(...args: any[]) => any>; | ||
onAriaWidget: PropTypes.Requireable<(...args: any[]) => any>; | ||
onAutogrow: PropTypes.Requireable<(...args: any[]) => any>; | ||
onBeforeCommandExec: PropTypes.Requireable<(...args: any[]) => any>; | ||
onBeforeDestroy: PropTypes.Requireable<(...args: any[]) => any>; | ||
onBeforeGetData: PropTypes.Requireable<(...args: any[]) => any>; | ||
onBeforeModeUnload: PropTypes.Requireable<(...args: any[]) => any>; | ||
onBeforeSetMode: PropTypes.Requireable<(...args: any[]) => any>; | ||
onBeforeUndoImage: PropTypes.Requireable<(...args: any[]) => any>; | ||
onConfigLoaded: PropTypes.Requireable<(...args: any[]) => any>; | ||
onContentDirChanged: PropTypes.Requireable<(...args: any[]) => any>; | ||
onContentDom: PropTypes.Requireable<(...args: any[]) => any>; | ||
onContentDomInvalidated: PropTypes.Requireable<(...args: any[]) => any>; | ||
onContentDomUnload: PropTypes.Requireable<(...args: any[]) => any>; | ||
onContentPreview: PropTypes.Requireable<(...args: any[]) => any>; | ||
onCustomConfigLoaded: PropTypes.Requireable<(...args: any[]) => any>; | ||
onDataFiltered: PropTypes.Requireable<(...args: any[]) => any>; | ||
onDataReady: PropTypes.Requireable<(...args: any[]) => any>; | ||
onDestroy: PropTypes.Requireable<(...args: any[]) => any>; | ||
onDialogHide: PropTypes.Requireable<(...args: any[]) => any>; | ||
onDialogShow: PropTypes.Requireable<(...args: any[]) => any>; | ||
onDirChanged: PropTypes.Requireable<(...args: any[]) => any>; | ||
onDoubleclick: PropTypes.Requireable<(...args: any[]) => any>; | ||
onDragend: PropTypes.Requireable<(...args: any[]) => any>; | ||
onDragstart: PropTypes.Requireable<(...args: any[]) => any>; | ||
onElementsPathUpdate: PropTypes.Requireable<(...args: any[]) => any>; | ||
onExportPdf: PropTypes.Requireable<(...args: any[]) => any>; | ||
onFileUploadRequest: PropTypes.Requireable<(...args: any[]) => any>; | ||
onFileUploadResponse: PropTypes.Requireable<(...args: any[]) => any>; | ||
onFloatingSpaceLayout: PropTypes.Requireable<(...args: any[]) => any>; | ||
onGetData: PropTypes.Requireable<(...args: any[]) => any>; | ||
onGetSnapshot: PropTypes.Requireable<(...args: any[]) => any>; | ||
onInsertElement: PropTypes.Requireable<(...args: any[]) => any>; | ||
onInsertHtml: PropTypes.Requireable<(...args: any[]) => any>; | ||
onInsertText: PropTypes.Requireable<(...args: any[]) => any>; | ||
onInstanceReady: PropTypes.Requireable<(...args: any[]) => any>; | ||
onKey: PropTypes.Requireable<(...args: any[]) => any>; | ||
onLangLoaded: PropTypes.Requireable<(...args: any[]) => any>; | ||
onLoadSnapshot: PropTypes.Requireable<(...args: any[]) => any>; | ||
onLoaded: PropTypes.Requireable<(...args: any[]) => any>; | ||
onLockSnapshot: PropTypes.Requireable<(...args: any[]) => any>; | ||
onMaximize: PropTypes.Requireable<(...args: any[]) => any>; | ||
onMenuShow: PropTypes.Requireable<(...args: any[]) => any>; | ||
onMode: PropTypes.Requireable<(...args: any[]) => any>; | ||
onNotificationHide: PropTypes.Requireable<(...args: any[]) => any>; | ||
onNotificationShow: PropTypes.Requireable<(...args: any[]) => any>; | ||
onNotificationUpdate: PropTypes.Requireable<(...args: any[]) => any>; | ||
onPasteFromWord: PropTypes.Requireable<(...args: any[]) => any>; | ||
onPluginsLoaded: PropTypes.Requireable<(...args: any[]) => any>; | ||
onReadOnly: PropTypes.Requireable<(...args: any[]) => any>; | ||
onRemoveFormatCleanup: PropTypes.Requireable<(...args: any[]) => any>; | ||
onRequired: PropTypes.Requireable<(...args: any[]) => any>; | ||
onSave: PropTypes.Requireable<(...args: any[]) => any>; | ||
onSaveSnapshot: PropTypes.Requireable<(...args: any[]) => any>; | ||
onSelectionChange: PropTypes.Requireable<(...args: any[]) => any>; | ||
onSetData: PropTypes.Requireable<(...args: any[]) => any>; | ||
onStylesRemove: PropTypes.Requireable<(...args: any[]) => any>; | ||
onStylesSet: PropTypes.Requireable<(...args: any[]) => any>; | ||
onTemplate: PropTypes.Requireable<(...args: any[]) => any>; | ||
onToDataFormat: PropTypes.Requireable<(...args: any[]) => any>; | ||
onToHtml: PropTypes.Requireable<(...args: any[]) => any>; | ||
onUiSpace: PropTypes.Requireable<(...args: any[]) => any>; | ||
onUnlockSnapshot: PropTypes.Requireable<(...args: any[]) => any>; | ||
onUpdateSnapshot: PropTypes.Requireable<(...args: any[]) => any>; | ||
onWidgetDefinition: PropTypes.Requireable<(...args: any[]) => any>; | ||
/** | ||
* Config object passed to editor's constructor. | ||
* | ||
* A new instance of editor will be created everytime a new instance of `config` is provided. | ||
* If this is not expected behavior then ensure referential equality of `config` between renders. | ||
* | ||
* See: https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html | ||
*/ | ||
config: PropTypes.Requireable<object>; | ||
/** | ||
* Toggles debugging. Logs info related to editor lifecycle events. | ||
*/ | ||
debug: PropTypes.Requireable<boolean>; | ||
/** | ||
* Url with editor's source code. Uses newest version from https://cdn.ckeditor.com domain by default. | ||
*/ | ||
editorUrl: PropTypes.Requireable<string>; | ||
/** | ||
* Initial data will be set only once during editor instance's lifecycle. | ||
*/ | ||
initData: PropTypes.Requireable<PropTypes.ReactNodeLike>; | ||
/** | ||
* A unique identifier of editor instance. | ||
* | ||
* See: https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#property-name | ||
*/ | ||
name: PropTypes.Requireable<string>; | ||
/** | ||
* This prop has two-fold effect: | ||
* | ||
* - Serves as a convenience prop to start editor in read-only mode. | ||
* It's an equivalent of passing `{ readOnly: true }` in `config` but takes precedence over it. | ||
* | ||
* - Allows to toggle editor's `read-only` mode on runtime. | ||
* | ||
* See: https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-readOnly | ||
*/ | ||
readOnly: PropTypes.Requireable<boolean>; | ||
/** | ||
* Styles passed to the root element. | ||
*/ | ||
style: PropTypes.Requireable<object>; | ||
/** | ||
* Setups editor in either `classic` or `inline` mode. | ||
* | ||
* A new instance of editor will be created everytime a new value of `type` is provided. | ||
* If this is not expected behavior then ensure stable value of `type` between renders. | ||
* | ||
* See: | ||
* - https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.html#method-replace | ||
* - https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.html#method-inline | ||
*/ | ||
type: PropTypes.Requireable<CKEditorType>; | ||
}; | ||
} | ||
export default CKEditor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
import { CKEditorAction } from './types'; | ||
/** | ||
* Two types of events are discerned: | ||
* | ||
* - `editor` events are associated with native editor events. In addition, custom events can be specified. | ||
* - `namespace` events are additional events provided by React integration. | ||
*/ | ||
/** | ||
* Available `editor` events. | ||
* | ||
* See: https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html | ||
*/ | ||
export declare const events: readonly ["activeEnterModeChange", "activeFilterChange", "afterCommandExec", "afterInsertHtml", "afterPaste", "afterPasteFromWord", "afterSetData", "afterUndoImage", "ariaEditorHelpLabel", "ariaWidget", "autogrow", "beforeCommandExec", "beforeDestroy", "beforeGetData", "beforeModeUnload", "beforeSetMode", "beforeUndoImage", "blur", "change", "configLoaded", "contentDirChanged", "contentDom", "contentDomInvalidated", "contentDomUnload", "contentPreview", "customConfigLoaded", "dataFiltered", "dataReady", "destroy", "dialogHide", "dialogShow", "dirChanged", "doubleclick", "dragend", "dragstart", "drop", "elementsPathUpdate", "exportPdf", "fileUploadRequest", "fileUploadResponse", "floatingSpaceLayout", "focus", "getData", "getSnapshot", "insertElement", "insertHtml", "insertText", "instanceReady", "key", "langLoaded", "loadSnapshot", "loaded", "lockSnapshot", "maximize", "menuShow", "mode", "notificationHide", "notificationShow", "notificationUpdate", "paste", "pasteFromWord", "pluginsLoaded", "readOnly", "removeFormatCleanup", "required", "resize", "save", "saveSnapshot", "selectionChange", "setData", "stylesRemove", "stylesSet", "template", "toDataFormat", "toHtml", "uiSpace", "unlockSnapshot", "updateSnapshot", "widgetDefinition"]; | ||
/** | ||
* Available `namespace` events. | ||
* | ||
* - `beforeLoad`: fired before an editor instance is created | ||
* - `namespaceLoaded`: fired after CKEDITOR namespace is created; fired only once regardless of number of editor instances | ||
*/ | ||
export declare const namespaceEvents: readonly ["beforeLoad", "namespaceLoaded"]; | ||
/** | ||
* Combines `editor` and `namespace` events. | ||
*/ | ||
export declare const defaultEvents: ("required" | "key" | "loaded" | "resize" | "template" | "paste" | "blur" | "change" | "dragend" | "dragstart" | "drop" | "focus" | "mode" | "readOnly" | "activeEnterModeChange" | "activeFilterChange" | "afterCommandExec" | "afterInsertHtml" | "afterPaste" | "afterPasteFromWord" | "afterSetData" | "afterUndoImage" | "ariaEditorHelpLabel" | "ariaWidget" | "autogrow" | "beforeCommandExec" | "beforeDestroy" | "beforeGetData" | "beforeModeUnload" | "beforeSetMode" | "beforeUndoImage" | "configLoaded" | "contentDirChanged" | "contentDom" | "contentDomInvalidated" | "contentDomUnload" | "contentPreview" | "customConfigLoaded" | "dataFiltered" | "dataReady" | "destroy" | "dialogHide" | "dialogShow" | "dirChanged" | "doubleclick" | "elementsPathUpdate" | "exportPdf" | "fileUploadRequest" | "fileUploadResponse" | "floatingSpaceLayout" | "getData" | "getSnapshot" | "insertElement" | "insertHtml" | "insertText" | "instanceReady" | "langLoaded" | "loadSnapshot" | "lockSnapshot" | "maximize" | "menuShow" | "notificationHide" | "notificationShow" | "notificationUpdate" | "pasteFromWord" | "pluginsLoaded" | "removeFormatCleanup" | "save" | "saveSnapshot" | "selectionChange" | "setData" | "stylesRemove" | "stylesSet" | "toDataFormat" | "toHtml" | "uiSpace" | "unlockSnapshot" | "updateSnapshot" | "widgetDefinition" | "beforeLoad" | "namespaceLoaded")[]; | ||
/** | ||
* Events as action types should be prefixed to allow easier consumption by downstream reducers. | ||
*/ | ||
export declare const EVENT_PREFIX = "__CKE__"; | ||
/** | ||
* Prefixes event name: `instanceReady` -> `__CKE__instanceReady`. | ||
* | ||
* @param evtName event name | ||
* @returns prefixed event name | ||
*/ | ||
export declare function prefixEventName(evtName: string): string; | ||
/** | ||
* Strips prefix from event name. `__CKE__instanceReady` -> `instanceReady`. | ||
* | ||
* @param evtName prefixed event name | ||
* @returns event name | ||
*/ | ||
export declare function stripPrefix(prefixedEventName: string): string; | ||
/** | ||
* Transforms prefixed event name to a handler name, e.g. `instanceReady` -> `onInstanceReady`. | ||
* | ||
* @param evtName event name | ||
* @returns handler name | ||
*/ | ||
export declare function eventNameToHandlerName(evtName: string): string; | ||
/** | ||
* Transforms handler name to event name, e.g. `onInstanceReady` -> `instanceReady`. | ||
* | ||
* @param evtName event name | ||
* @returns handler name | ||
*/ | ||
export declare function handlerNameToEventName(handlerName: string): string; | ||
/** | ||
* Provides an object with event names as keys and prefixed names as values, e.g. `{ instanceReady: __CKE__instanceReady }`. | ||
* This allows to easily mix editor event actions and own actions in downstream reducers. | ||
*/ | ||
export declare const CKEditorEventAction: CKEditorAction; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
export * from './types'; | ||
export { prefixEventName, stripPrefix, CKEditorEventAction } from './events'; | ||
export * from './registerEditorEventHandler'; | ||
export { default as registerEditorEventHandler } from './registerEditorEventHandler'; | ||
export * from './useCKEditor'; | ||
export { default as useCKEditor } from './useCKEditor'; | ||
export * from './CKEditor'; | ||
export { default as CKEditor } from './CKEditor'; |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
import { CKEditorDefaultEvent, CKEditorRegisterEventArgs } from './types'; | ||
/** | ||
* Registers editor event. Allows to toggle debugging mode. | ||
* | ||
* @param editor instance of editor | ||
* @param debug toggles debugger | ||
*/ | ||
declare function registerEditorEventHandler<EditorEvent>({ debug, editor, evtName, handler, listenerData, priority }: CKEditorRegisterEventArgs<EditorEvent | CKEditorDefaultEvent>): () => void; | ||
export default registerEditorEventHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,380 @@ | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
import * as React from 'react'; | ||
import * as PropTypes from 'prop-types'; | ||
import CKEditor from './CKEditor'; | ||
import { events, namespaceEvents } from './events'; | ||
/** | ||
* Event names associated with `editor` events. | ||
*/ | ||
export type CKEditorEditorEventName = typeof events[number]; | ||
/** | ||
* Event names associated with `namespace` events. | ||
*/ | ||
export type CKEditorNamespaceEventName = typeof namespaceEvents[number]; | ||
/** | ||
* Combined `editor` and `namespace` events. | ||
*/ | ||
export type CKEditorDefaultEvent = CKEditorEditorEventName | CKEditorNamespaceEventName; | ||
/** | ||
* Payload passed to `editor` event handlers. | ||
*/ | ||
export interface CKEditorEventPayload<EventName> { | ||
/** | ||
* Additional event data. | ||
*/ | ||
data?: Record<string, unknown> | null; | ||
/** | ||
* Editor instance that holds the event sender. | ||
*/ | ||
editor?: CKEditorInstance | null; | ||
/** | ||
* Extra data appended during listener registration. | ||
*/ | ||
listenerData?: any; | ||
/** | ||
* Event name. | ||
*/ | ||
name: EventName; | ||
/** | ||
* Object that publishes event. | ||
*/ | ||
sender: Record<string, unknown>; | ||
/** | ||
* Cancels event (if cancelable). | ||
*/ | ||
cancel?: () => void | null; | ||
/** | ||
* Removes current listener. | ||
*/ | ||
removeListener?: () => void | null; | ||
/** | ||
* No listeners will be called afterwards. | ||
*/ | ||
stop?: () => void | null; | ||
} | ||
/** | ||
* Signature of `editor` event handler. | ||
*/ | ||
export type CKEditorEventHandler<EventName> = (evt: CKEditorEventPayload<EventName>) => void; | ||
/** | ||
* Signature of `namespace` event handler. | ||
*/ | ||
export type CKEditorNamespaceHandler = (CKEDITOR: CKEditorNamespace) => void; | ||
/** | ||
* Editor instance. | ||
*/ | ||
export type CKEditorInstance = any; | ||
/** | ||
* Editor configuration object. | ||
*/ | ||
export type CKEditorConfig = Record<string, any>; | ||
/** | ||
* Namespace object. | ||
*/ | ||
export type CKEditorNamespace = any; | ||
/** | ||
* `useCKEditor` hook arguments. | ||
*/ | ||
export interface CKEditorHookProps<EventName extends string> { | ||
/** | ||
* Config object passed to editor's constructor. | ||
* | ||
* A new instance of editor will be created everytime a new instance of `config` is provided. | ||
* If this is not expected behavior then ensure referential equality of `config` between renders. | ||
* | ||
* See: https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html | ||
*/ | ||
config?: CKEditorConfig | null; | ||
/** | ||
* Toggles debugging. Logs info related to editor lifecycle events. | ||
*/ | ||
debug?: boolean | null; | ||
/** | ||
* Dispatches `editor` / `namespace` events. | ||
*/ | ||
dispatchEvent?: CKEditorEventDispatcher; | ||
/** | ||
* List of editor events that will be dispatched. Omit if all events are to be dispatched. | ||
*/ | ||
subscribeTo?: ReadonlyArray<EventName>; | ||
/** | ||
* Url with editor's source code. Uses https://cdn.ckeditor.com domain by default. | ||
*/ | ||
editorUrl?: string | null; | ||
/** | ||
* DOM element to which editor will be bound. | ||
*/ | ||
element: HTMLElement | null; | ||
/** | ||
* Initial editor content. Only `string` values are accepted. | ||
*/ | ||
initContent?: string | null; | ||
/** | ||
* Initializes editor in either `classic` or `inline` mode. | ||
* | ||
* See: | ||
* - https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.html#method-inline | ||
* - https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.html#method-replace | ||
*/ | ||
type?: CKEditorType | null; | ||
} | ||
/** | ||
* Arguments passed to event registeration helper. | ||
*/ | ||
export interface CKEditorRegisterEventArgs<EventName> { | ||
/** | ||
* Toggles debugging. Logs info related to editor lifecycle events. | ||
*/ | ||
debug?: boolean | null; | ||
/** | ||
* Editor instance. | ||
*/ | ||
editor: CKEditorInstance; | ||
/** | ||
* Event handler to register. | ||
*/ | ||
handler: CKEditorEventHandler<EventName>; | ||
/** | ||
* Editor's event name. | ||
*/ | ||
evtName: EventName; | ||
/** | ||
* Custom data passed to listener. | ||
*/ | ||
listenerData?: any; | ||
/** | ||
* Sets handler's priority. | ||
*/ | ||
priority?: number; | ||
} | ||
export interface CKEditorHookResult { | ||
/** | ||
* Instance of editor. | ||
*/ | ||
editor?: CKEditorInstance; | ||
/** | ||
* Status of editor's instance. Equivalent of `editor.status`. | ||
*/ | ||
status?: CKEditorStatus; | ||
/** | ||
* Indicates if an error occurred. This is a non-recoverable state. Hook must be remounted. | ||
*/ | ||
error?: boolean; | ||
/** | ||
* Indicates if loading of CKEditor is in progress. | ||
*/ | ||
loading?: boolean; | ||
} | ||
/** | ||
* Dispatcher of editor events. | ||
*/ | ||
export type CKEditorEventDispatcher = ({ type, payload }: { | ||
type: string; | ||
payload: any; | ||
}) => void; | ||
/** | ||
* Possible types of editor. | ||
*/ | ||
export type CKEditorType = 'classic' | 'inline'; | ||
/** | ||
* Editor status. | ||
* | ||
* See: https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#property-status | ||
*/ | ||
export type CKEditorStatus = 'unloaded' | 'loaded' | 'ready' | 'destroyed'; | ||
/** | ||
* Props of `CKEditor` component. | ||
* | ||
* Some prop types are overriden to provide better typings than `PropTypes.InferProps` has to offer. | ||
*/ | ||
export type CKEditorProps<EventHandlerProp> = PropTypes.InferProps<Omit<typeof CKEditor.propTypes, 'config' | 'style' | keyof CKEditorEventHandlerProp>> & { | ||
config?: CKEditorConfig | null; | ||
style?: React.CSSProperties | null; | ||
} & Partial<CKEditorEventHandlerProp> & EventHandlerProp; | ||
/** | ||
* Event handler props. | ||
*/ | ||
export interface CKEditorEventHandlerProp { | ||
/** | ||
* Namespace events. | ||
*/ | ||
onBeforeLoad: CKEditorNamespaceHandler; | ||
onNamespaceLoaded: CKEditorNamespaceHandler; | ||
/** | ||
* Editor events. | ||
*/ | ||
onActiveEnterModeChange: CKEditorEventHandler<'activeEnterModeChange'>; | ||
onActiveFilterChange: CKEditorEventHandler<'activeFilterChange'>; | ||
onAfterCommandExec: CKEditorEventHandler<'afterCommandExec'>; | ||
onAfterInsertHtml: CKEditorEventHandler<'afterInsertHtml'>; | ||
onAfterPaste: CKEditorEventHandler<'afterPaste'>; | ||
onAfterPasteFromWord: CKEditorEventHandler<'afterPasteFromWord'>; | ||
onAfterSetData: CKEditorEventHandler<'afterSetData'>; | ||
onAfterUndoImage: CKEditorEventHandler<'afterUndoImage'>; | ||
onAriaEditorHelpLabel: CKEditorEventHandler<'ariaEditorHelpLabel'>; | ||
onAriaWidget: CKEditorEventHandler<'ariaWidget'>; | ||
onAutogrow: CKEditorEventHandler<'autogrow'>; | ||
onBeforeCommandExec: CKEditorEventHandler<'beforeCommandExec'>; | ||
onBeforeDestroy: CKEditorEventHandler<'beforeDestroy'>; | ||
onBeforeGetData: CKEditorEventHandler<'beforeGetData'>; | ||
onBeforeModeUnload: CKEditorEventHandler<'beforeModeUnload'>; | ||
onBeforeSetMode: CKEditorEventHandler<'beforeSetMode'>; | ||
onBeforeUndoImage: CKEditorEventHandler<'beforeUndoImage'>; | ||
onBlur: CKEditorEventHandler<'blur'>; | ||
onChange: CKEditorEventHandler<'change'>; | ||
onConfigLoaded: CKEditorEventHandler<'configLoaded'>; | ||
onContentDirChanged: CKEditorEventHandler<'contentDirChanged'>; | ||
onContentDom: CKEditorEventHandler<'contentDom'>; | ||
onContentDomInvalidated: CKEditorEventHandler<'contentDomInvalidated'>; | ||
onContentDomUnload: CKEditorEventHandler<'contentDomUnload'>; | ||
onContentPreview: CKEditorEventHandler<'contentPreview'>; | ||
onCustomConfigLoaded: CKEditorEventHandler<'customConfigLoaded'>; | ||
onDataFiltered: CKEditorEventHandler<'dataFiltered'>; | ||
onDataReady: CKEditorEventHandler<'dataReady'>; | ||
onDestroy: CKEditorEventHandler<'destroy'>; | ||
onDialogHide: CKEditorEventHandler<'dialogHide'>; | ||
onDialogShow: CKEditorEventHandler<'dialogShow'>; | ||
onDirChanged: CKEditorEventHandler<'dirChanged'>; | ||
onDoubleclick: CKEditorEventHandler<'doubleclick'>; | ||
onDragend: CKEditorEventHandler<'dragend'>; | ||
onDragstart: CKEditorEventHandler<'dragstart'>; | ||
onDrop: CKEditorEventHandler<'drop'>; | ||
onElementsPathUpdate: CKEditorEventHandler<'elementsPathUpdate'>; | ||
onExportPdf: CKEditorEventHandler<'exportPdf'>; | ||
onFileUploadRequest: CKEditorEventHandler<'fileUploadRequest'>; | ||
onFileUploadResponse: CKEditorEventHandler<'fileUploadResponse'>; | ||
onFloatingSpaceLayout: CKEditorEventHandler<'floatingSpaceLayout'>; | ||
onFocus: CKEditorEventHandler<'focus'>; | ||
onGetData: CKEditorEventHandler<'getData'>; | ||
onGetSnapshot: CKEditorEventHandler<'getSnapshot'>; | ||
onInsertElement: CKEditorEventHandler<'insertElement'>; | ||
onInsertHtml: CKEditorEventHandler<'insertHtml'>; | ||
onInsertText: CKEditorEventHandler<'insertText'>; | ||
onInstanceReady: CKEditorEventHandler<'instanceReady'>; | ||
onKey: CKEditorEventHandler<'key'>; | ||
onLangLoaded: CKEditorEventHandler<'langLoaded'>; | ||
onLoadSnapshot: CKEditorEventHandler<'loadSnapshot'>; | ||
onLoaded: CKEditorEventHandler<'loaded'>; | ||
onLockSnapshot: CKEditorEventHandler<'lockSnapshot'>; | ||
onMaximize: CKEditorEventHandler<'maximize'>; | ||
onMenuShow: CKEditorEventHandler<'menuShow'>; | ||
onMode: CKEditorEventHandler<'mode'>; | ||
onNotificationHide: CKEditorEventHandler<'notificationHide'>; | ||
onNotificationShow: CKEditorEventHandler<'notificationShow'>; | ||
onNotificationUpdate: CKEditorEventHandler<'notificationUpdate'>; | ||
onPaste: CKEditorEventHandler<'paste'>; | ||
onPasteFromWord: CKEditorEventHandler<'pasteFromWord'>; | ||
onPluginsLoaded: CKEditorEventHandler<'pluginsLoaded'>; | ||
onReadOnly: CKEditorEventHandler<'readOnly'>; | ||
onRemoveFormatCleanup: CKEditorEventHandler<'removeFormatCleanup'>; | ||
onRequired: CKEditorEventHandler<'required'>; | ||
onResize: CKEditorEventHandler<'resize'>; | ||
onSave: CKEditorEventHandler<'save'>; | ||
onSaveSnapshot: CKEditorEventHandler<'saveSnapshot'>; | ||
onSelectionChange: CKEditorEventHandler<'selectionChange'>; | ||
onSetData: CKEditorEventHandler<'setData'>; | ||
onStylesRemove: CKEditorEventHandler<'stylesRemove'>; | ||
onStylesSet: CKEditorEventHandler<'stylesSet'>; | ||
onTemplate: CKEditorEventHandler<'template'>; | ||
onToDataFormat: CKEditorEventHandler<'toDataFormat'>; | ||
onToHtml: CKEditorEventHandler<'toHtml'>; | ||
onUiSpace: CKEditorEventHandler<'uiSpace'>; | ||
onUnlockSnapshot: CKEditorEventHandler<'unlockSnapshot'>; | ||
onUpdateSnapshot: CKEditorEventHandler<'updateSnapshot'>; | ||
onWidgetDefinition: CKEditorEventHandler<'widgetDefinition'>; | ||
} | ||
/** | ||
* Event action types. | ||
*/ | ||
export interface CKEditorAction { | ||
/** | ||
* Namespace events. | ||
*/ | ||
beforeLoad: '__CKE__beforeLoad'; | ||
namespaceLoaded: '__CKE__namespaceLoaded'; | ||
/** | ||
* Editor events. | ||
*/ | ||
activeEnterModeChange: '__CKE__activeEnterModeChange'; | ||
activeFilterChange: '__CKE__activeFilterChange'; | ||
afterCommandExec: '__CKE__afterCommandExec'; | ||
afterInsertHtml: '__CKE__afterInsertHtml'; | ||
afterPaste: '__CKE__afterPaste'; | ||
afterPasteFromWord: '__CKE__afterPasteFromWord'; | ||
afterSetData: '__CKE__afterSetData'; | ||
afterUndoImage: '__CKE__afterUndoImage'; | ||
ariaEditorHelpLabel: '__CKE__ariaEditorHelpLabel'; | ||
ariaWidget: '__CKE__ariaWidget'; | ||
autogrow: '__CKE__autogrow'; | ||
beforeCommandExec: '__CKE__beforeCommandExec'; | ||
beforeDestroy: '__CKE__beforeDestroy'; | ||
beforeGetData: '__CKE__beforeGetData'; | ||
beforeModeUnload: '__CKE__beforeModeUnload'; | ||
beforeSetMode: '__CKE__beforeSetMode'; | ||
beforeUndoImage: '__CKE__beforeUndoImage'; | ||
blur: '__CKE__blur'; | ||
change: '__CKE__change'; | ||
configLoaded: '__CKE__configLoaded'; | ||
contentDirChanged: '__CKE__contentDirChanged'; | ||
contentDom: '__CKE__contentDom'; | ||
contentDomInvalidated: '__CKE__contentDomInvalidated'; | ||
contentDomUnload: '__CKE__contentDomUnload'; | ||
contentPreview: '__CKE__contentPreview'; | ||
customConfigLoaded: '__CKE__customConfigLoaded'; | ||
dataFiltered: '__CKE__dataFiltered'; | ||
dataReady: '__CKE__dataReady'; | ||
destroy: '__CKE__destroy'; | ||
dialogHide: '__CKE__dialogHide'; | ||
dialogShow: '__CKE__dialogShow'; | ||
dirChanged: '__CKE__dirChanged'; | ||
doubleclick: '__CKE__doubleclick'; | ||
dragend: '__CKE__dragend'; | ||
dragstart: '__CKE__dragstart'; | ||
drop: '__CKE__drop'; | ||
elementsPathUpdate: '__CKE__elementsPathUpdate'; | ||
exportPdf: '__CKE__exportPdf'; | ||
fileUploadRequest: '__CKE__fileUploadRequest'; | ||
fileUploadResponse: '__CKE__fileUploadResponse'; | ||
floatingSpaceLayout: '__CKE__floatingSpaceLayout'; | ||
focus: '__CKE__focus'; | ||
getData: '__CKE__getData'; | ||
getSnapshot: '__CKE__getSnapshot'; | ||
insertElement: '__CKE__insertElement'; | ||
insertHtml: '__CKE__insertHtml'; | ||
insertText: '__CKE__insertText'; | ||
instanceReady: '__CKE__instanceReady'; | ||
key: '__CKE__key'; | ||
langLoaded: '__CKE__langLoaded'; | ||
loadSnapshot: '__CKE__loadSnapshot'; | ||
loaded: '__CKE__loaded'; | ||
lockSnapshot: '__CKE__lockSnapshot'; | ||
maximize: '__CKE__maximize'; | ||
menuShow: '__CKE__menuShow'; | ||
mode: '__CKE__mode'; | ||
notificationHide: '__CKE__notificationHide'; | ||
notificationShow: '__CKE__notificationShow'; | ||
notificationUpdate: '__CKE__notificationUpdate'; | ||
paste: '__CKE__paste'; | ||
pasteFromWord: '__CKE__pasteFromWord'; | ||
pluginsLoaded: '__CKE__pluginsLoaded'; | ||
readOnly: '__CKE__readOnly'; | ||
removeFormatCleanup: '__CKE__removeFormatCleanup'; | ||
required: '__CKE__required'; | ||
resize: '__CKE__resize'; | ||
save: '__CKE__save'; | ||
saveSnapshot: '__CKE__saveSnapshot'; | ||
selectionChange: '__CKE__selectionChange'; | ||
setData: '__CKE__setData'; | ||
stylesRemove: '__CKE__stylesRemove'; | ||
stylesSet: '__CKE__stylesSet'; | ||
template: '__CKE__template'; | ||
toDataFormat: '__CKE__toDataFormat'; | ||
toHtml: '__CKE__toHtml'; | ||
uiSpace: '__CKE__uiSpace'; | ||
unlockSnapshot: '__CKE__unlockSnapshot'; | ||
updateSnapshot: '__CKE__updateSnapshot'; | ||
widgetDefinition: '__CKE__widgetDefinition'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
import { CKEditorDefaultEvent, CKEditorHookProps, CKEditorHookResult } from './types'; | ||
/** | ||
* `useCKEditor` is a low-level hook that holds core logic for editor lifecycle. | ||
* It is responsible for initializing and destroying editor instance. | ||
*/ | ||
declare function useCKEditor<EditorEvent extends string>({ config, debug, dispatchEvent, subscribeTo, editorUrl, element, initContent, type }: CKEditorHookProps<EditorEvent | CKEditorDefaultEvent>): CKEditorHookResult; | ||
export default useCKEditor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
import * as React from 'react'; | ||
import { CKEditorStatus, CKEditorType } from './types'; | ||
/** | ||
* Transforms `camelCaseValue` into `kebab-case-value`. | ||
* | ||
* @param str string to transform | ||
* @returns transformed string | ||
*/ | ||
export declare function camelToKebab(str: string): string; | ||
/** | ||
* Generates reasonably unique value of five lower-case letters. | ||
* | ||
* @returns unique value | ||
*/ | ||
export declare function uniqueName(): string; | ||
/** | ||
* Returns style for the root element. | ||
* | ||
* @param type editor type | ||
* @param status editor status | ||
* @param style custom style | ||
* @returns style | ||
*/ | ||
export declare function getStyle(type: CKEditorType, status?: CKEditorStatus, style?: React.CSSProperties | null): React.CSSProperties | { | ||
readonly display: "none"; | ||
readonly visibility: "hidden"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters