From 6ff03b75fc07a7369f7ddbab7912aef456260ab4 Mon Sep 17 00:00:00 2001 From: Jacek Bogdanski Date: Fri, 25 Aug 2023 18:00:25 +0200 Subject: [PATCH] Clean after release [ci skip] --- dist/CKEditor.d.ts | 155 --- dist/events.d.ts | 65 -- dist/index.cjs.js | 448 --------- dist/index.d.ts | 12 - dist/index.esm.js | 418 -------- dist/index.umd.development.js | 1340 -------------------------- dist/index.umd.production.min.js | 5 - dist/registerEditorEventHandler.d.ts | 13 - dist/types.d.ts | 380 -------- dist/useCKEditor.d.ts | 11 - dist/utils.d.ts | 31 - 11 files changed, 2878 deletions(-) delete mode 100644 dist/CKEditor.d.ts delete mode 100644 dist/events.d.ts delete mode 100644 dist/index.cjs.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.esm.js delete mode 100644 dist/index.umd.development.js delete mode 100644 dist/index.umd.production.min.js delete mode 100644 dist/registerEditorEventHandler.d.ts delete mode 100644 dist/types.d.ts delete mode 100644 dist/useCKEditor.d.ts delete mode 100644 dist/utils.d.ts diff --git a/dist/CKEditor.d.ts b/dist/CKEditor.d.ts deleted file mode 100644 index f2a703d..0000000 --- a/dist/CKEditor.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/** - * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. - * For licensing, see LICENSE.md. - */ -/// -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({ config, debug, editorUrl, initData, name, readOnly, style, type, -/** - * `handlers` object must contain event handlers props only! - */ -...handlers }: CKEditorProps): 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; - /** - * Toggles debugging. Logs info related to editor lifecycle events. - */ - debug: PropTypes.Requireable; - /** - * Url with editor's source code. Uses newest version from https://cdn.ckeditor.com domain by default. - */ - editorUrl: PropTypes.Requireable; - /** - * Initial data will be set only once during editor instance's lifecycle. - */ - initData: PropTypes.Requireable; - /** - * A unique identifier of editor instance. - * - * See: https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#property-name - */ - name: PropTypes.Requireable; - /** - * 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; - /** - * Styles passed to the root element. - */ - style: PropTypes.Requireable; - /** - * 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; - }; -} -export default CKEditor; diff --git a/dist/events.d.ts b/dist/events.d.ts deleted file mode 100644 index 5ec9fed..0000000 --- a/dist/events.d.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @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; diff --git a/dist/index.cjs.js b/dist/index.cjs.js deleted file mode 100644 index 97a9dcd..0000000 --- a/dist/index.cjs.js +++ /dev/null @@ -1,448 +0,0 @@ -/** - * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. - * For licensing, see LICENSE.md. - */ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var React = require('react'); -var ckeditor4IntegrationsCommon = require('ckeditor4-integrations-common'); -var PropTypes = require('prop-types'); - -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { return e[k]; } - }); - } - }); - } - n["default"] = e; - return Object.freeze(n); -} - -var React__namespace = /*#__PURE__*/_interopNamespace(React); -var PropTypes__namespace = /*#__PURE__*/_interopNamespace(PropTypes); - -var __assign = function() { - __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -function __rest(s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; -} -function __spreadArray(to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -} - -var events = [ - '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' -]; -var namespaceEvents = ['beforeLoad', 'namespaceLoaded']; -var defaultEvents = __spreadArray(__spreadArray([], events, true), namespaceEvents, true); -var EVENT_PREFIX = '__CKE__'; -function prefixEventName(evtName) { - return "".concat(EVENT_PREFIX).concat(evtName); -} -function stripPrefix(prefixedEventName) { - return prefixedEventName.substr(EVENT_PREFIX.length); -} -function eventNameToHandlerName(evtName) { - var cap = evtName.substr(0, 1).toUpperCase() + evtName.substr(1); - return "on".concat(cap); -} -function handlerNameToEventName(handlerName) { - return handlerName.substr(2, 1).toLowerCase() + handlerName.substr(3); -} -var CKEditorEventAction = __spreadArray(__spreadArray([], events, true), namespaceEvents, true).reduce(function (acc, evtName) { - var _a; - return __assign(__assign({}, acc), (_a = {}, _a[evtName] = prefixEventName(evtName), _a)); -}, {}); - -function camelToKebab(str) { - return str - .split(/(?=[A-Z])/) - .join('-') - .toLowerCase(); -} -function uniqueName() { - return Math.random() - .toString(36) - .replace(/[^a-z]+/g, '') - .substr(0, 5); -} -function getStyle(type, status, style) { - var hidden = { display: 'none', visibility: 'hidden' }; - if (type === 'classic') { - return hidden; - } - return status === 'ready' ? style !== null && style !== void 0 ? style : undefined : hidden; -} - -function registerEditorEventHandler(_a) { - var debug = _a.debug, editor = _a.editor, evtName = _a.evtName, handler = _a.handler, listenerData = _a.listenerData, priority = _a.priority; - var handlerId = debug && uniqueName(); - var _handler = handler; - if (debug) { - _handler = function (args) { - console.log({ - operation: 'invoke', - editor: editor.name, - evtName: evtName, - handlerId: handlerId, - data: args.data, - listenerData: args.listenerData - }); - handler(args); - }; - } - if (debug) { - console.log({ - operation: 'register', - editor: editor.name, - evtName: evtName, - handlerId: handlerId - }); - } - editor.on(evtName, _handler, null, listenerData, priority); - return function () { - if (debug) { - console.log({ - operation: 'unregister', - editor: editor.name, - evtName: evtName, - handlerId: handlerId - }); - } - editor.removeListener(evtName, _handler); - }; -} - -var useEffect$1 = React__namespace.useEffect, useReducer = React__namespace.useReducer, useRef$1 = React__namespace.useRef; -var defEditorUrl = 'https://cdn.ckeditor.com/4.23.0-lts/standard-all/ckeditor.js'; -var defConfig = {}; -function useCKEditor(_a) { - var config = _a.config, debug = _a.debug, dispatchEvent = _a.dispatchEvent, _b = _a.subscribeTo, subscribeTo = _b === void 0 ? defaultEvents : _b, editorUrl = _a.editorUrl, element = _a.element, initContent = _a.initContent, _c = _a.type, type = _c === void 0 ? 'classic' : _c; - var editorUrlRef = useRef$1(editorUrl || defEditorUrl); - var subscribeToRef = useRef$1(subscribeTo !== null && subscribeTo !== void 0 ? subscribeTo : defaultEvents); - var debugRef = useRef$1(debug); - var dispatchEventRef = useRef$1(dispatchEvent); - var initContentRef = useRef$1(initContent); - var configRef = useRef$1(config || defConfig); - var typeRef = useRef$1(type); - var _d = useReducer(reducer, { - editor: undefined, - hookStatus: 'init' - }), _e = _d[0], editor = _e.editor, hookStatus = _e.hookStatus, dispatch = _d[1]; - useEffect$1(function () { - if (element && !editor) { - dispatch({ type: 'loading' }); - var onNamespaceLoaded = function (CKEDITOR) { - var _a; - if (subscribeToRef.current.indexOf('namespaceLoaded') !== -1) { - (_a = dispatchEventRef.current) === null || _a === void 0 ? void 0 : _a.call(dispatchEventRef, { - type: CKEditorEventAction.namespaceLoaded, - payload: CKEDITOR - }); - } - }; - var initEditor = function (CKEDITOR) { - var _a; - var isInline = typeRef.current === 'inline'; - var isReadOnly = configRef.current.readOnly; - if (subscribeToRef.current.indexOf('beforeLoad') !== -1) { - (_a = dispatchEventRef.current) === null || _a === void 0 ? void 0 : _a.call(dispatchEventRef, { - type: CKEditorEventAction.beforeLoad, - payload: CKEDITOR - }); - } - var editor = CKEDITOR[isInline ? 'inline' : 'replace'](element, configRef.current); - var subscribedEditorEvents = subscribeToRef.current.filter(function (evtName) { return namespaceEvents.indexOf(evtName) === -1; }); - subscribedEditorEvents.forEach(function (evtName) { - registerEditorEventHandler({ - debug: debugRef.current, - editor: editor, - evtName: evtName, - handler: function (payload) { - var _a; - (_a = dispatchEventRef.current) === null || _a === void 0 ? void 0 : _a.call(dispatchEventRef, { - type: "".concat(EVENT_PREFIX).concat(evtName), - payload: payload - }); - } - }); - }); - registerEditorEventHandler({ - debug: debugRef.current, - editor: editor, - evtName: 'loaded', - handler: function () { - dispatch({ type: 'loaded' }); - }, - priority: -1 - }); - registerEditorEventHandler({ - debug: debugRef.current, - editor: editor, - evtName: 'instanceReady', - handler: function (_a) { - var editor = _a.editor; - dispatch({ type: 'ready' }); - if (isInline && !isReadOnly) { - editor.setReadOnly(false); - } - if (initContentRef.current) { - editor.setData(initContentRef.current, { - noSnapshot: true, - callback: function () { - editor.resetUndo(); - } - }); - } - }, - priority: -1 - }); - registerEditorEventHandler({ - debug: debugRef.current, - editor: editor, - evtName: 'destroy', - handler: function () { - dispatch({ type: 'destroyed' }); - }, - priority: -1 - }); - dispatch({ - type: 'unloaded', - payload: editor - }); - }; - ckeditor4IntegrationsCommon.getEditorNamespace(editorUrlRef.current, onNamespaceLoaded) - .then(initEditor) - .catch(function (error) { - if (process.env.NODE_ENV !== 'test') { - console.error(error); - } - dispatch({ type: 'error' }); - }); - } - return function () { - if (editor) { - editor.destroy(); - } - }; - }, [editor, element]); - return { - editor: editor, - status: editor === null || editor === void 0 ? void 0 : editor.status, - error: hookStatus === 'error', - loading: hookStatus === 'loading' - }; -} -function reducer(state, action) { - switch (action.type) { - case 'init': - return __assign(__assign({}, state), { hookStatus: 'init' }); - case 'loading': - return __assign(__assign({}, state), { hookStatus: 'loading' }); - case 'unloaded': - return { - editor: action.payload, - hookStatus: 'unloaded' - }; - case 'loaded': - return __assign(__assign({}, state), { hookStatus: 'loaded' }); - case 'ready': - return __assign(__assign({}, state), { hookStatus: 'ready' }); - case 'destroyed': - return { - editor: undefined, - hookStatus: 'destroyed' - }; - case 'error': - return { - editor: undefined, - hookStatus: 'error' - }; - default: - return state; - } -} - -var useEffect = React__namespace.useEffect, useRef = React__namespace.useRef, useState = React__namespace.useState; -function CKEditor(_a) { - var _b = _a.config, config = _b === void 0 ? {} : _b, debug = _a.debug, editorUrl = _a.editorUrl, initData = _a.initData, name = _a.name, readOnly = _a.readOnly, style = _a.style, type = _a.type, - handlers = __rest(_a, ["config", "debug", "editorUrl", "initData", "name", "readOnly", "style", "type"]); - var _c = useState(null), element = _c[0], setElement = _c[1]; - var refs = useRef(handlers); - var dispatchEvent = function (_a) { - var type = _a.type, payload = _a.payload; - var handlerName = eventNameToHandlerName(stripPrefix(type)); - var handler = refs.current[handlerName]; - if (handler) { - handler(payload); - } - }; - if (config && typeof readOnly === 'boolean') { - config.readOnly = readOnly; - } - var _d = useCKEditor({ - config: config, - dispatchEvent: dispatchEvent, - debug: debug, - editorUrl: editorUrl, - element: element, - initContent: typeof initData === 'string' ? initData : undefined, - subscribeTo: Object.keys(handlers) - .filter(function (key) { return key.indexOf('on') === 0; }) - .map(handlerNameToEventName), - type: type - }), editor = _d.editor, status = _d.status; - useEffect(function () { - var canSetStyles = type !== 'inline' && - editor && - (status === 'loaded' || status === 'ready'); - if (style && canSetStyles) { - editor.container.setStyles(style); - } - return function () { - if (style && canSetStyles) { - Object.keys(style) - .map(camelToKebab) - .forEach(function (styleName) { - editor.container.removeStyle(styleName); - }); - } - }; - }, [editor, status, style, type]); - useEffect(function () { - if (editor && status === 'ready' && typeof readOnly === 'boolean') { - editor.setReadOnly(readOnly); - } - }, [editor, status, readOnly]); - return (React__namespace.createElement("div", { id: name !== null && name !== void 0 ? name : undefined, ref: setElement, style: getStyle(type !== null && type !== void 0 ? type : 'classic', status, style) }, typeof initData === 'string' ? null : initData)); -} -var propTypes = __assign({ - config: PropTypes__namespace.object, - debug: PropTypes__namespace.bool, - editorUrl: PropTypes__namespace.string, - initData: PropTypes__namespace.node, - name: PropTypes__namespace.string, - readOnly: PropTypes__namespace.bool, - style: PropTypes__namespace.object, - type: PropTypes__namespace.oneOf(['classic', 'inline']) }, defaultEvents.reduce(function (acc, key) { - var _a; - return __assign(__assign({}, acc), (_a = {}, _a[eventNameToHandlerName(key)] = PropTypes__namespace.func, _a)); -}, {})); -CKEditor.propTypes = propTypes; - -exports.CKEditor = CKEditor; -exports.CKEditorEventAction = CKEditorEventAction; -exports.prefixEventName = prefixEventName; -exports.registerEditorEventHandler = registerEditorEventHandler; -exports.stripPrefix = stripPrefix; -exports.useCKEditor = useCKEditor; diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 70638a1..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * @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'; diff --git a/dist/index.esm.js b/dist/index.esm.js deleted file mode 100644 index 2b9513f..0000000 --- a/dist/index.esm.js +++ /dev/null @@ -1,418 +0,0 @@ -/** - * @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 { getEditorNamespace } from 'ckeditor4-integrations-common'; -import * as PropTypes from 'prop-types'; - -var __assign = function() { - __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -function __rest(s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; -} -function __spreadArray(to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -} - -var events = [ - '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' -]; -var namespaceEvents = ['beforeLoad', 'namespaceLoaded']; -var defaultEvents = __spreadArray(__spreadArray([], events, true), namespaceEvents, true); -var EVENT_PREFIX = '__CKE__'; -function prefixEventName(evtName) { - return "".concat(EVENT_PREFIX).concat(evtName); -} -function stripPrefix(prefixedEventName) { - return prefixedEventName.substr(EVENT_PREFIX.length); -} -function eventNameToHandlerName(evtName) { - var cap = evtName.substr(0, 1).toUpperCase() + evtName.substr(1); - return "on".concat(cap); -} -function handlerNameToEventName(handlerName) { - return handlerName.substr(2, 1).toLowerCase() + handlerName.substr(3); -} -var CKEditorEventAction = __spreadArray(__spreadArray([], events, true), namespaceEvents, true).reduce(function (acc, evtName) { - var _a; - return __assign(__assign({}, acc), (_a = {}, _a[evtName] = prefixEventName(evtName), _a)); -}, {}); - -function camelToKebab(str) { - return str - .split(/(?=[A-Z])/) - .join('-') - .toLowerCase(); -} -function uniqueName() { - return Math.random() - .toString(36) - .replace(/[^a-z]+/g, '') - .substr(0, 5); -} -function getStyle(type, status, style) { - var hidden = { display: 'none', visibility: 'hidden' }; - if (type === 'classic') { - return hidden; - } - return status === 'ready' ? style !== null && style !== void 0 ? style : undefined : hidden; -} - -function registerEditorEventHandler(_a) { - var debug = _a.debug, editor = _a.editor, evtName = _a.evtName, handler = _a.handler, listenerData = _a.listenerData, priority = _a.priority; - var handlerId = debug && uniqueName(); - var _handler = handler; - if (debug) { - _handler = function (args) { - console.log({ - operation: 'invoke', - editor: editor.name, - evtName: evtName, - handlerId: handlerId, - data: args.data, - listenerData: args.listenerData - }); - handler(args); - }; - } - if (debug) { - console.log({ - operation: 'register', - editor: editor.name, - evtName: evtName, - handlerId: handlerId - }); - } - editor.on(evtName, _handler, null, listenerData, priority); - return function () { - if (debug) { - console.log({ - operation: 'unregister', - editor: editor.name, - evtName: evtName, - handlerId: handlerId - }); - } - editor.removeListener(evtName, _handler); - }; -} - -var useEffect$1 = React.useEffect, useReducer = React.useReducer, useRef$1 = React.useRef; -var defEditorUrl = 'https://cdn.ckeditor.com/4.23.0-lts/standard-all/ckeditor.js'; -var defConfig = {}; -function useCKEditor(_a) { - var config = _a.config, debug = _a.debug, dispatchEvent = _a.dispatchEvent, _b = _a.subscribeTo, subscribeTo = _b === void 0 ? defaultEvents : _b, editorUrl = _a.editorUrl, element = _a.element, initContent = _a.initContent, _c = _a.type, type = _c === void 0 ? 'classic' : _c; - var editorUrlRef = useRef$1(editorUrl || defEditorUrl); - var subscribeToRef = useRef$1(subscribeTo !== null && subscribeTo !== void 0 ? subscribeTo : defaultEvents); - var debugRef = useRef$1(debug); - var dispatchEventRef = useRef$1(dispatchEvent); - var initContentRef = useRef$1(initContent); - var configRef = useRef$1(config || defConfig); - var typeRef = useRef$1(type); - var _d = useReducer(reducer, { - editor: undefined, - hookStatus: 'init' - }), _e = _d[0], editor = _e.editor, hookStatus = _e.hookStatus, dispatch = _d[1]; - useEffect$1(function () { - if (element && !editor) { - dispatch({ type: 'loading' }); - var onNamespaceLoaded = function (CKEDITOR) { - var _a; - if (subscribeToRef.current.indexOf('namespaceLoaded') !== -1) { - (_a = dispatchEventRef.current) === null || _a === void 0 ? void 0 : _a.call(dispatchEventRef, { - type: CKEditorEventAction.namespaceLoaded, - payload: CKEDITOR - }); - } - }; - var initEditor = function (CKEDITOR) { - var _a; - var isInline = typeRef.current === 'inline'; - var isReadOnly = configRef.current.readOnly; - if (subscribeToRef.current.indexOf('beforeLoad') !== -1) { - (_a = dispatchEventRef.current) === null || _a === void 0 ? void 0 : _a.call(dispatchEventRef, { - type: CKEditorEventAction.beforeLoad, - payload: CKEDITOR - }); - } - var editor = CKEDITOR[isInline ? 'inline' : 'replace'](element, configRef.current); - var subscribedEditorEvents = subscribeToRef.current.filter(function (evtName) { return namespaceEvents.indexOf(evtName) === -1; }); - subscribedEditorEvents.forEach(function (evtName) { - registerEditorEventHandler({ - debug: debugRef.current, - editor: editor, - evtName: evtName, - handler: function (payload) { - var _a; - (_a = dispatchEventRef.current) === null || _a === void 0 ? void 0 : _a.call(dispatchEventRef, { - type: "".concat(EVENT_PREFIX).concat(evtName), - payload: payload - }); - } - }); - }); - registerEditorEventHandler({ - debug: debugRef.current, - editor: editor, - evtName: 'loaded', - handler: function () { - dispatch({ type: 'loaded' }); - }, - priority: -1 - }); - registerEditorEventHandler({ - debug: debugRef.current, - editor: editor, - evtName: 'instanceReady', - handler: function (_a) { - var editor = _a.editor; - dispatch({ type: 'ready' }); - if (isInline && !isReadOnly) { - editor.setReadOnly(false); - } - if (initContentRef.current) { - editor.setData(initContentRef.current, { - noSnapshot: true, - callback: function () { - editor.resetUndo(); - } - }); - } - }, - priority: -1 - }); - registerEditorEventHandler({ - debug: debugRef.current, - editor: editor, - evtName: 'destroy', - handler: function () { - dispatch({ type: 'destroyed' }); - }, - priority: -1 - }); - dispatch({ - type: 'unloaded', - payload: editor - }); - }; - getEditorNamespace(editorUrlRef.current, onNamespaceLoaded) - .then(initEditor) - .catch(function (error) { - if (process.env.NODE_ENV !== 'test') { - console.error(error); - } - dispatch({ type: 'error' }); - }); - } - return function () { - if (editor) { - editor.destroy(); - } - }; - }, [editor, element]); - return { - editor: editor, - status: editor === null || editor === void 0 ? void 0 : editor.status, - error: hookStatus === 'error', - loading: hookStatus === 'loading' - }; -} -function reducer(state, action) { - switch (action.type) { - case 'init': - return __assign(__assign({}, state), { hookStatus: 'init' }); - case 'loading': - return __assign(__assign({}, state), { hookStatus: 'loading' }); - case 'unloaded': - return { - editor: action.payload, - hookStatus: 'unloaded' - }; - case 'loaded': - return __assign(__assign({}, state), { hookStatus: 'loaded' }); - case 'ready': - return __assign(__assign({}, state), { hookStatus: 'ready' }); - case 'destroyed': - return { - editor: undefined, - hookStatus: 'destroyed' - }; - case 'error': - return { - editor: undefined, - hookStatus: 'error' - }; - default: - return state; - } -} - -var useEffect = React.useEffect, useRef = React.useRef, useState = React.useState; -function CKEditor(_a) { - var _b = _a.config, config = _b === void 0 ? {} : _b, debug = _a.debug, editorUrl = _a.editorUrl, initData = _a.initData, name = _a.name, readOnly = _a.readOnly, style = _a.style, type = _a.type, - handlers = __rest(_a, ["config", "debug", "editorUrl", "initData", "name", "readOnly", "style", "type"]); - var _c = useState(null), element = _c[0], setElement = _c[1]; - var refs = useRef(handlers); - var dispatchEvent = function (_a) { - var type = _a.type, payload = _a.payload; - var handlerName = eventNameToHandlerName(stripPrefix(type)); - var handler = refs.current[handlerName]; - if (handler) { - handler(payload); - } - }; - if (config && typeof readOnly === 'boolean') { - config.readOnly = readOnly; - } - var _d = useCKEditor({ - config: config, - dispatchEvent: dispatchEvent, - debug: debug, - editorUrl: editorUrl, - element: element, - initContent: typeof initData === 'string' ? initData : undefined, - subscribeTo: Object.keys(handlers) - .filter(function (key) { return key.indexOf('on') === 0; }) - .map(handlerNameToEventName), - type: type - }), editor = _d.editor, status = _d.status; - useEffect(function () { - var canSetStyles = type !== 'inline' && - editor && - (status === 'loaded' || status === 'ready'); - if (style && canSetStyles) { - editor.container.setStyles(style); - } - return function () { - if (style && canSetStyles) { - Object.keys(style) - .map(camelToKebab) - .forEach(function (styleName) { - editor.container.removeStyle(styleName); - }); - } - }; - }, [editor, status, style, type]); - useEffect(function () { - if (editor && status === 'ready' && typeof readOnly === 'boolean') { - editor.setReadOnly(readOnly); - } - }, [editor, status, readOnly]); - return (React.createElement("div", { id: name !== null && name !== void 0 ? name : undefined, ref: setElement, style: getStyle(type !== null && type !== void 0 ? type : 'classic', status, style) }, typeof initData === 'string' ? null : initData)); -} -var propTypes = __assign({ - config: PropTypes.object, - debug: PropTypes.bool, - editorUrl: PropTypes.string, - initData: PropTypes.node, - name: PropTypes.string, - readOnly: PropTypes.bool, - style: PropTypes.object, - type: PropTypes.oneOf(['classic', 'inline']) }, defaultEvents.reduce(function (acc, key) { - var _a; - return __assign(__assign({}, acc), (_a = {}, _a[eventNameToHandlerName(key)] = PropTypes.func, _a)); -}, {})); -CKEditor.propTypes = propTypes; - -export { CKEditor, CKEditorEventAction, prefixEventName, registerEditorEventHandler, stripPrefix, useCKEditor }; diff --git a/dist/index.umd.development.js b/dist/index.umd.development.js deleted file mode 100644 index 3c13586..0000000 --- a/dist/index.umd.development.js +++ /dev/null @@ -1,1340 +0,0 @@ -/** - * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. - * For licensing, see LICENSE.md. - */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) : - typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CKEditor4React = {}, global.React)); -})(this, (function (exports, React) { 'use strict'; - - function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { return e[k]; } - }); - } - }); - } - n["default"] = e; - return Object.freeze(n); - } - - var React__namespace = /*#__PURE__*/_interopNamespace(React); - - var __assign = function() { - __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); - }; - function __rest(s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; - } - function __spreadArray(to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); - } - - var events = [ - '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' - ]; - var namespaceEvents = ['beforeLoad', 'namespaceLoaded']; - var defaultEvents = __spreadArray(__spreadArray([], events, true), namespaceEvents, true); - var EVENT_PREFIX = '__CKE__'; - function prefixEventName(evtName) { - return "".concat(EVENT_PREFIX).concat(evtName); - } - function stripPrefix(prefixedEventName) { - return prefixedEventName.substr(EVENT_PREFIX.length); - } - function eventNameToHandlerName(evtName) { - var cap = evtName.substr(0, 1).toUpperCase() + evtName.substr(1); - return "on".concat(cap); - } - function handlerNameToEventName(handlerName) { - return handlerName.substr(2, 1).toLowerCase() + handlerName.substr(3); - } - var CKEditorEventAction = __spreadArray(__spreadArray([], events, true), namespaceEvents, true).reduce(function (acc, evtName) { - var _a; - return __assign(__assign({}, acc), (_a = {}, _a[evtName] = prefixEventName(evtName), _a)); - }, {}); - - function camelToKebab(str) { - return str - .split(/(?=[A-Z])/) - .join('-') - .toLowerCase(); - } - function uniqueName() { - return Math.random() - .toString(36) - .replace(/[^a-z]+/g, '') - .substr(0, 5); - } - function getStyle(type, status, style) { - var hidden = { display: 'none', visibility: 'hidden' }; - if (type === 'classic') { - return hidden; - } - return status === 'ready' ? style !== null && style !== void 0 ? style : undefined : hidden; - } - - function registerEditorEventHandler(_a) { - var debug = _a.debug, editor = _a.editor, evtName = _a.evtName, handler = _a.handler, listenerData = _a.listenerData, priority = _a.priority; - var handlerId = debug && uniqueName(); - var _handler = handler; - if (debug) { - _handler = function (args) { - console.log({ - operation: 'invoke', - editor: editor.name, - evtName: evtName, - handlerId: handlerId, - data: args.data, - listenerData: args.listenerData - }); - handler(args); - }; - } - if (debug) { - console.log({ - operation: 'register', - editor: editor.name, - evtName: evtName, - handlerId: handlerId - }); - } - editor.on(evtName, _handler, null, listenerData, priority); - return function () { - if (debug) { - console.log({ - operation: 'unregister', - editor: editor.name, - evtName: evtName, - handlerId: handlerId - }); - } - editor.removeListener(evtName, _handler); - }; - } - - var index_cjs = {}; - - Object.defineProperty(index_cjs, '__esModule', { value: true }); - function loadScript (src, opts, cb) { - var head = document.head || document.getElementsByTagName('head')[0]; - var script = document.createElement('script'); - if (typeof opts === 'function') { - cb = opts; - opts = {}; - } - opts = opts || {}; - cb = cb || function () {}; - script.type = opts.type || 'text/javascript'; - script.charset = opts.charset || 'utf8'; - script.async = 'async' in opts ? !!opts.async : true; - script.src = src; - if (opts.attrs) { - setAttributes(script, opts.attrs); - } - if (opts.text) { - script.text = String(opts.text); - } - var onend = 'onload' in script ? stdOnEnd : ieOnEnd; - onend(script, cb); - if (!script.onload) { - stdOnEnd(script, cb); - } - head.appendChild(script); - } - function setAttributes(script, attrs) { - for (var attr in attrs) { - script.setAttribute(attr, attrs[attr]); - } - } - function stdOnEnd(script, cb) { - script.onload = function () { - this.onerror = this.onload = null; - cb(null, script); - }; - script.onerror = function () { - this.onerror = this.onload = null; - cb(new Error('Failed to load ' + this.src), script); - }; - } - function ieOnEnd(script, cb) { - script.onreadystatechange = function () { - if (this.readyState != 'complete' && this.readyState != 'loaded') { - return; - } - this.onreadystatechange = null; - cb(null, script); - }; - } - var promise; - function getEditorNamespace(editorURL, onNamespaceLoaded) { - if ('CKEDITOR' in window) { - return Promise.resolve(CKEDITOR); - } - if (typeof editorURL !== 'string' || editorURL.length < 1) { - return Promise.reject(new TypeError('CKEditor URL must be a non-empty string.')); - } - if (!promise) { - promise = getEditorNamespace.scriptLoader(editorURL).then(function (res) { - if (onNamespaceLoaded) { - onNamespaceLoaded(res); - } - return res; - }); - } - return promise; - } - getEditorNamespace.scriptLoader = function (editorURL) { - return new Promise(function (scriptResolve, scriptReject) { - loadScript(editorURL, function (err) { - promise = undefined; - if (err) { - return scriptReject(err); - } else if (!window.CKEDITOR) { - return scriptReject(new Error('Script loaded from editorUrl doesn\'t provide CKEDITOR namespace.')); - } - scriptResolve(CKEDITOR); - }); - }); - }; - function debounce(fn, delay) { - var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - var cancel; - return function () { - clearTimeout(cancel); - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - cancel = setTimeout(fn.bind.apply(fn, [context].concat(args)), delay); - }; - } - index_cjs.debounce = debounce; - var getEditorNamespace_1 = index_cjs.getEditorNamespace = getEditorNamespace; - - var useEffect$1 = React__namespace.useEffect, useReducer = React__namespace.useReducer, useRef$1 = React__namespace.useRef; - var defEditorUrl = 'https://cdn.ckeditor.com/4.23.0-lts/standard-all/ckeditor.js'; - var defConfig = {}; - function useCKEditor(_a) { - var config = _a.config, debug = _a.debug, dispatchEvent = _a.dispatchEvent, _b = _a.subscribeTo, subscribeTo = _b === void 0 ? defaultEvents : _b, editorUrl = _a.editorUrl, element = _a.element, initContent = _a.initContent, _c = _a.type, type = _c === void 0 ? 'classic' : _c; - var editorUrlRef = useRef$1(editorUrl || defEditorUrl); - var subscribeToRef = useRef$1(subscribeTo !== null && subscribeTo !== void 0 ? subscribeTo : defaultEvents); - var debugRef = useRef$1(debug); - var dispatchEventRef = useRef$1(dispatchEvent); - var initContentRef = useRef$1(initContent); - var configRef = useRef$1(config || defConfig); - var typeRef = useRef$1(type); - var _d = useReducer(reducer, { - editor: undefined, - hookStatus: 'init' - }), _e = _d[0], editor = _e.editor, hookStatus = _e.hookStatus, dispatch = _d[1]; - useEffect$1(function () { - if (element && !editor) { - dispatch({ type: 'loading' }); - var onNamespaceLoaded = function (CKEDITOR) { - var _a; - if (subscribeToRef.current.indexOf('namespaceLoaded') !== -1) { - (_a = dispatchEventRef.current) === null || _a === void 0 ? void 0 : _a.call(dispatchEventRef, { - type: CKEditorEventAction.namespaceLoaded, - payload: CKEDITOR - }); - } - }; - var initEditor = function (CKEDITOR) { - var _a; - var isInline = typeRef.current === 'inline'; - var isReadOnly = configRef.current.readOnly; - if (subscribeToRef.current.indexOf('beforeLoad') !== -1) { - (_a = dispatchEventRef.current) === null || _a === void 0 ? void 0 : _a.call(dispatchEventRef, { - type: CKEditorEventAction.beforeLoad, - payload: CKEDITOR - }); - } - var editor = CKEDITOR[isInline ? 'inline' : 'replace'](element, configRef.current); - var subscribedEditorEvents = subscribeToRef.current.filter(function (evtName) { return namespaceEvents.indexOf(evtName) === -1; }); - subscribedEditorEvents.forEach(function (evtName) { - registerEditorEventHandler({ - debug: debugRef.current, - editor: editor, - evtName: evtName, - handler: function (payload) { - var _a; - (_a = dispatchEventRef.current) === null || _a === void 0 ? void 0 : _a.call(dispatchEventRef, { - type: "".concat(EVENT_PREFIX).concat(evtName), - payload: payload - }); - } - }); - }); - registerEditorEventHandler({ - debug: debugRef.current, - editor: editor, - evtName: 'loaded', - handler: function () { - dispatch({ type: 'loaded' }); - }, - priority: -1 - }); - registerEditorEventHandler({ - debug: debugRef.current, - editor: editor, - evtName: 'instanceReady', - handler: function (_a) { - var editor = _a.editor; - dispatch({ type: 'ready' }); - if (isInline && !isReadOnly) { - editor.setReadOnly(false); - } - if (initContentRef.current) { - editor.setData(initContentRef.current, { - noSnapshot: true, - callback: function () { - editor.resetUndo(); - } - }); - } - }, - priority: -1 - }); - registerEditorEventHandler({ - debug: debugRef.current, - editor: editor, - evtName: 'destroy', - handler: function () { - dispatch({ type: 'destroyed' }); - }, - priority: -1 - }); - dispatch({ - type: 'unloaded', - payload: editor - }); - }; - getEditorNamespace_1(editorUrlRef.current, onNamespaceLoaded) - .then(initEditor) - .catch(function (error) { - { - console.error(error); - } - dispatch({ type: 'error' }); - }); - } - return function () { - if (editor) { - editor.destroy(); - } - }; - }, [editor, element]); - return { - editor: editor, - status: editor === null || editor === void 0 ? void 0 : editor.status, - error: hookStatus === 'error', - loading: hookStatus === 'loading' - }; - } - function reducer(state, action) { - switch (action.type) { - case 'init': - return __assign(__assign({}, state), { hookStatus: 'init' }); - case 'loading': - return __assign(__assign({}, state), { hookStatus: 'loading' }); - case 'unloaded': - return { - editor: action.payload, - hookStatus: 'unloaded' - }; - case 'loaded': - return __assign(__assign({}, state), { hookStatus: 'loaded' }); - case 'ready': - return __assign(__assign({}, state), { hookStatus: 'ready' }); - case 'destroyed': - return { - editor: undefined, - hookStatus: 'destroyed' - }; - case 'error': - return { - editor: undefined, - hookStatus: 'error' - }; - default: - return state; - } - } - - var propTypes$1 = {exports: {}}; - - var reactIs = {exports: {}}; - - var reactIs_development = {}; - - var hasRequiredReactIs_development; - function requireReactIs_development () { - if (hasRequiredReactIs_development) return reactIs_development; - hasRequiredReactIs_development = 1; - { - (function() { - var hasSymbol = typeof Symbol === 'function' && Symbol.for; - var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; - var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; - var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; - var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; - var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; - var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; - var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; - var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf; - var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; - var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; - var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; - var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; - var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; - var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; - var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; - var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; - var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; - var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; - function isValidElementType(type) { - return typeof type === 'string' || typeof type === 'function' || - type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE); - } - function typeOf(object) { - if (typeof object === 'object' && object !== null) { - var $$typeof = object.$$typeof; - switch ($$typeof) { - case REACT_ELEMENT_TYPE: - var type = object.type; - switch (type) { - case REACT_ASYNC_MODE_TYPE: - case REACT_CONCURRENT_MODE_TYPE: - case REACT_FRAGMENT_TYPE: - case REACT_PROFILER_TYPE: - case REACT_STRICT_MODE_TYPE: - case REACT_SUSPENSE_TYPE: - return type; - default: - var $$typeofType = type && type.$$typeof; - switch ($$typeofType) { - case REACT_CONTEXT_TYPE: - case REACT_FORWARD_REF_TYPE: - case REACT_LAZY_TYPE: - case REACT_MEMO_TYPE: - case REACT_PROVIDER_TYPE: - return $$typeofType; - default: - return $$typeof; - } - } - case REACT_PORTAL_TYPE: - return $$typeof; - } - } - return undefined; - } - var AsyncMode = REACT_ASYNC_MODE_TYPE; - var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; - var ContextConsumer = REACT_CONTEXT_TYPE; - var ContextProvider = REACT_PROVIDER_TYPE; - var Element = REACT_ELEMENT_TYPE; - var ForwardRef = REACT_FORWARD_REF_TYPE; - var Fragment = REACT_FRAGMENT_TYPE; - var Lazy = REACT_LAZY_TYPE; - var Memo = REACT_MEMO_TYPE; - var Portal = REACT_PORTAL_TYPE; - var Profiler = REACT_PROFILER_TYPE; - var StrictMode = REACT_STRICT_MODE_TYPE; - var Suspense = REACT_SUSPENSE_TYPE; - var hasWarnedAboutDeprecatedIsAsyncMode = false; - function isAsyncMode(object) { - { - if (!hasWarnedAboutDeprecatedIsAsyncMode) { - hasWarnedAboutDeprecatedIsAsyncMode = true; - console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.'); - } - } - return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE; - } - function isConcurrentMode(object) { - return typeOf(object) === REACT_CONCURRENT_MODE_TYPE; - } - function isContextConsumer(object) { - return typeOf(object) === REACT_CONTEXT_TYPE; - } - function isContextProvider(object) { - return typeOf(object) === REACT_PROVIDER_TYPE; - } - function isElement(object) { - return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; - } - function isForwardRef(object) { - return typeOf(object) === REACT_FORWARD_REF_TYPE; - } - function isFragment(object) { - return typeOf(object) === REACT_FRAGMENT_TYPE; - } - function isLazy(object) { - return typeOf(object) === REACT_LAZY_TYPE; - } - function isMemo(object) { - return typeOf(object) === REACT_MEMO_TYPE; - } - function isPortal(object) { - return typeOf(object) === REACT_PORTAL_TYPE; - } - function isProfiler(object) { - return typeOf(object) === REACT_PROFILER_TYPE; - } - function isStrictMode(object) { - return typeOf(object) === REACT_STRICT_MODE_TYPE; - } - function isSuspense(object) { - return typeOf(object) === REACT_SUSPENSE_TYPE; - } - reactIs_development.AsyncMode = AsyncMode; - reactIs_development.ConcurrentMode = ConcurrentMode; - reactIs_development.ContextConsumer = ContextConsumer; - reactIs_development.ContextProvider = ContextProvider; - reactIs_development.Element = Element; - reactIs_development.ForwardRef = ForwardRef; - reactIs_development.Fragment = Fragment; - reactIs_development.Lazy = Lazy; - reactIs_development.Memo = Memo; - reactIs_development.Portal = Portal; - reactIs_development.Profiler = Profiler; - reactIs_development.StrictMode = StrictMode; - reactIs_development.Suspense = Suspense; - reactIs_development.isAsyncMode = isAsyncMode; - reactIs_development.isConcurrentMode = isConcurrentMode; - reactIs_development.isContextConsumer = isContextConsumer; - reactIs_development.isContextProvider = isContextProvider; - reactIs_development.isElement = isElement; - reactIs_development.isForwardRef = isForwardRef; - reactIs_development.isFragment = isFragment; - reactIs_development.isLazy = isLazy; - reactIs_development.isMemo = isMemo; - reactIs_development.isPortal = isPortal; - reactIs_development.isProfiler = isProfiler; - reactIs_development.isStrictMode = isStrictMode; - reactIs_development.isSuspense = isSuspense; - reactIs_development.isValidElementType = isValidElementType; - reactIs_development.typeOf = typeOf; - })(); - } - return reactIs_development; - } - - var hasRequiredReactIs; - function requireReactIs () { - if (hasRequiredReactIs) return reactIs.exports; - hasRequiredReactIs = 1; - (function (module) { - { - module.exports = requireReactIs_development(); - } - } (reactIs)); - return reactIs.exports; - } - - var objectAssign; - var hasRequiredObjectAssign; - function requireObjectAssign () { - if (hasRequiredObjectAssign) return objectAssign; - hasRequiredObjectAssign = 1; - var getOwnPropertySymbols = Object.getOwnPropertySymbols; - var hasOwnProperty = Object.prototype.hasOwnProperty; - var propIsEnumerable = Object.prototype.propertyIsEnumerable; - function toObject(val) { - if (val === null || val === undefined) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } - return Object(val); - } - function shouldUseNative() { - try { - if (!Object.assign) { - return false; - } - var test1 = new String('abc'); - test1[5] = 'de'; - if (Object.getOwnPropertyNames(test1)[0] === '5') { - return false; - } - var test2 = {}; - for (var i = 0; i < 10; i++) { - test2['_' + String.fromCharCode(i)] = i; - } - var order2 = Object.getOwnPropertyNames(test2).map(function (n) { - return test2[n]; - }); - if (order2.join('') !== '0123456789') { - return false; - } - var test3 = {}; - 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { - test3[letter] = letter; - }); - if (Object.keys(Object.assign({}, test3)).join('') !== - 'abcdefghijklmnopqrst') { - return false; - } - return true; - } catch (err) { - return false; - } - } - objectAssign = shouldUseNative() ? Object.assign : function (target, source) { - var from; - var to = toObject(target); - var symbols; - for (var s = 1; s < arguments.length; s++) { - from = Object(arguments[s]); - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } - if (getOwnPropertySymbols) { - symbols = getOwnPropertySymbols(from); - for (var i = 0; i < symbols.length; i++) { - if (propIsEnumerable.call(from, symbols[i])) { - to[symbols[i]] = from[symbols[i]]; - } - } - } - } - return to; - }; - return objectAssign; - } - - var ReactPropTypesSecret_1; - var hasRequiredReactPropTypesSecret; - function requireReactPropTypesSecret () { - if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1; - hasRequiredReactPropTypesSecret = 1; - var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; - ReactPropTypesSecret_1 = ReactPropTypesSecret; - return ReactPropTypesSecret_1; - } - - var has; - var hasRequiredHas; - function requireHas () { - if (hasRequiredHas) return has; - hasRequiredHas = 1; - has = Function.call.bind(Object.prototype.hasOwnProperty); - return has; - } - - var checkPropTypes_1; - var hasRequiredCheckPropTypes; - function requireCheckPropTypes () { - if (hasRequiredCheckPropTypes) return checkPropTypes_1; - hasRequiredCheckPropTypes = 1; - var printWarning = function() {}; - { - var ReactPropTypesSecret = requireReactPropTypesSecret(); - var loggedTypeFailures = {}; - var has = requireHas(); - printWarning = function(text) { - var message = 'Warning: ' + text; - if (typeof console !== 'undefined') { - console.error(message); - } - try { - throw new Error(message); - } catch (x) { } - }; - } - function checkPropTypes(typeSpecs, values, location, componentName, getStack) { - { - for (var typeSpecName in typeSpecs) { - if (has(typeSpecs, typeSpecName)) { - var error; - try { - if (typeof typeSpecs[typeSpecName] !== 'function') { - var err = Error( - (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + - 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + - 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.' - ); - err.name = 'Invariant Violation'; - throw err; - } - error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); - } catch (ex) { - error = ex; - } - if (error && !(error instanceof Error)) { - printWarning( - (componentName || 'React class') + ': type specification of ' + - location + ' `' + typeSpecName + '` is invalid; the type checker ' + - 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + - 'You may have forgotten to pass an argument to the type checker ' + - 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + - 'shape all require an argument).' - ); - } - if (error instanceof Error && !(error.message in loggedTypeFailures)) { - loggedTypeFailures[error.message] = true; - var stack = getStack ? getStack() : ''; - printWarning( - 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') - ); - } - } - } - } - } - checkPropTypes.resetWarningCache = function() { - { - loggedTypeFailures = {}; - } - }; - checkPropTypes_1 = checkPropTypes; - return checkPropTypes_1; - } - - var factoryWithTypeCheckers; - var hasRequiredFactoryWithTypeCheckers; - function requireFactoryWithTypeCheckers () { - if (hasRequiredFactoryWithTypeCheckers) return factoryWithTypeCheckers; - hasRequiredFactoryWithTypeCheckers = 1; - var ReactIs = requireReactIs(); - var assign = requireObjectAssign(); - var ReactPropTypesSecret = requireReactPropTypesSecret(); - var has = requireHas(); - var checkPropTypes = requireCheckPropTypes(); - var printWarning = function() {}; - { - printWarning = function(text) { - var message = 'Warning: ' + text; - if (typeof console !== 'undefined') { - console.error(message); - } - try { - throw new Error(message); - } catch (x) {} - }; - } - function emptyFunctionThatReturnsNull() { - return null; - } - factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) { - var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; - var FAUX_ITERATOR_SYMBOL = '@@iterator'; - function getIteratorFn(maybeIterable) { - var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); - if (typeof iteratorFn === 'function') { - return iteratorFn; - } - } - var ANONYMOUS = '<>'; - var ReactPropTypes = { - array: createPrimitiveTypeChecker('array'), - bigint: createPrimitiveTypeChecker('bigint'), - bool: createPrimitiveTypeChecker('boolean'), - func: createPrimitiveTypeChecker('function'), - number: createPrimitiveTypeChecker('number'), - object: createPrimitiveTypeChecker('object'), - string: createPrimitiveTypeChecker('string'), - symbol: createPrimitiveTypeChecker('symbol'), - any: createAnyTypeChecker(), - arrayOf: createArrayOfTypeChecker, - element: createElementTypeChecker(), - elementType: createElementTypeTypeChecker(), - instanceOf: createInstanceTypeChecker, - node: createNodeChecker(), - objectOf: createObjectOfTypeChecker, - oneOf: createEnumTypeChecker, - oneOfType: createUnionTypeChecker, - shape: createShapeTypeChecker, - exact: createStrictShapeTypeChecker, - }; - function is(x, y) { - if (x === y) { - return x !== 0 || 1 / x === 1 / y; - } else { - return x !== x && y !== y; - } - } - function PropTypeError(message, data) { - this.message = message; - this.data = data && typeof data === 'object' ? data: {}; - this.stack = ''; - } - PropTypeError.prototype = Error.prototype; - function createChainableTypeChecker(validate) { - { - var manualPropTypeCallCache = {}; - var manualPropTypeWarningCount = 0; - } - function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { - componentName = componentName || ANONYMOUS; - propFullName = propFullName || propName; - if (secret !== ReactPropTypesSecret) { - if (throwOnDirectAccess) { - var err = new Error( - 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + - 'Use `PropTypes.checkPropTypes()` to call them. ' + - 'Read more at http://fb.me/use-check-prop-types' - ); - err.name = 'Invariant Violation'; - throw err; - } else if (typeof console !== 'undefined') { - var cacheKey = componentName + ':' + propName; - if ( - !manualPropTypeCallCache[cacheKey] && - manualPropTypeWarningCount < 3 - ) { - printWarning( - 'You are manually calling a React.PropTypes validation ' + - 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' + - 'and will throw in the standalone `prop-types` package. ' + - 'You may be seeing this warning due to a third-party PropTypes ' + - 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.' - ); - manualPropTypeCallCache[cacheKey] = true; - manualPropTypeWarningCount++; - } - } - } - if (props[propName] == null) { - if (isRequired) { - if (props[propName] === null) { - return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); - } - return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); - } - return null; - } else { - return validate(props, propName, componentName, location, propFullName); - } - } - var chainedCheckType = checkType.bind(null, false); - chainedCheckType.isRequired = checkType.bind(null, true); - return chainedCheckType; - } - function createPrimitiveTypeChecker(expectedType) { - function validate(props, propName, componentName, location, propFullName, secret) { - var propValue = props[propName]; - var propType = getPropType(propValue); - if (propType !== expectedType) { - var preciseType = getPreciseType(propValue); - return new PropTypeError( - 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'), - {expectedType: expectedType} - ); - } - return null; - } - return createChainableTypeChecker(validate); - } - function createAnyTypeChecker() { - return createChainableTypeChecker(emptyFunctionThatReturnsNull); - } - function createArrayOfTypeChecker(typeChecker) { - function validate(props, propName, componentName, location, propFullName) { - if (typeof typeChecker !== 'function') { - return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); - } - var propValue = props[propName]; - if (!Array.isArray(propValue)) { - var propType = getPropType(propValue); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); - } - for (var i = 0; i < propValue.length; i++) { - var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret); - if (error instanceof Error) { - return error; - } - } - return null; - } - return createChainableTypeChecker(validate); - } - function createElementTypeChecker() { - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - if (!isValidElement(propValue)) { - var propType = getPropType(propValue); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); - } - return null; - } - return createChainableTypeChecker(validate); - } - function createElementTypeTypeChecker() { - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - if (!ReactIs.isValidElementType(propValue)) { - var propType = getPropType(propValue); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.')); - } - return null; - } - return createChainableTypeChecker(validate); - } - function createInstanceTypeChecker(expectedClass) { - function validate(props, propName, componentName, location, propFullName) { - if (!(props[propName] instanceof expectedClass)) { - var expectedClassName = expectedClass.name || ANONYMOUS; - var actualClassName = getClassName(props[propName]); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); - } - return null; - } - return createChainableTypeChecker(validate); - } - function createEnumTypeChecker(expectedValues) { - if (!Array.isArray(expectedValues)) { - { - if (arguments.length > 1) { - printWarning( - 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' + - 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).' - ); - } else { - printWarning('Invalid argument supplied to oneOf, expected an array.'); - } - } - return emptyFunctionThatReturnsNull; - } - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - for (var i = 0; i < expectedValues.length; i++) { - if (is(propValue, expectedValues[i])) { - return null; - } - } - var valuesString = JSON.stringify(expectedValues, function replacer(key, value) { - var type = getPreciseType(value); - if (type === 'symbol') { - return String(value); - } - return value; - }); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); - } - return createChainableTypeChecker(validate); - } - function createObjectOfTypeChecker(typeChecker) { - function validate(props, propName, componentName, location, propFullName) { - if (typeof typeChecker !== 'function') { - return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); - } - var propValue = props[propName]; - var propType = getPropType(propValue); - if (propType !== 'object') { - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); - } - for (var key in propValue) { - if (has(propValue, key)) { - var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); - if (error instanceof Error) { - return error; - } - } - } - return null; - } - return createChainableTypeChecker(validate); - } - function createUnionTypeChecker(arrayOfTypeCheckers) { - if (!Array.isArray(arrayOfTypeCheckers)) { - printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') ; - return emptyFunctionThatReturnsNull; - } - for (var i = 0; i < arrayOfTypeCheckers.length; i++) { - var checker = arrayOfTypeCheckers[i]; - if (typeof checker !== 'function') { - printWarning( - 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + - 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.' - ); - return emptyFunctionThatReturnsNull; - } - } - function validate(props, propName, componentName, location, propFullName) { - var expectedTypes = []; - for (var i = 0; i < arrayOfTypeCheckers.length; i++) { - var checker = arrayOfTypeCheckers[i]; - var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret); - if (checkerResult == null) { - return null; - } - if (checkerResult.data && has(checkerResult.data, 'expectedType')) { - expectedTypes.push(checkerResult.data.expectedType); - } - } - var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': ''; - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.')); - } - return createChainableTypeChecker(validate); - } - function createNodeChecker() { - function validate(props, propName, componentName, location, propFullName) { - if (!isNode(props[propName])) { - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); - } - return null; - } - return createChainableTypeChecker(validate); - } - function invalidValidatorError(componentName, location, propFullName, key, type) { - return new PropTypeError( - (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' + - 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.' - ); - } - function createShapeTypeChecker(shapeTypes) { - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - var propType = getPropType(propValue); - if (propType !== 'object') { - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); - } - for (var key in shapeTypes) { - var checker = shapeTypes[key]; - if (typeof checker !== 'function') { - return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); - } - var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); - if (error) { - return error; - } - } - return null; - } - return createChainableTypeChecker(validate); - } - function createStrictShapeTypeChecker(shapeTypes) { - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - var propType = getPropType(propValue); - if (propType !== 'object') { - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); - } - var allKeys = assign({}, props[propName], shapeTypes); - for (var key in allKeys) { - var checker = shapeTypes[key]; - if (has(shapeTypes, key) && typeof checker !== 'function') { - return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); - } - if (!checker) { - return new PropTypeError( - 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + - '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + - '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') - ); - } - var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); - if (error) { - return error; - } - } - return null; - } - return createChainableTypeChecker(validate); - } - function isNode(propValue) { - switch (typeof propValue) { - case 'number': - case 'string': - case 'undefined': - return true; - case 'boolean': - return !propValue; - case 'object': - if (Array.isArray(propValue)) { - return propValue.every(isNode); - } - if (propValue === null || isValidElement(propValue)) { - return true; - } - var iteratorFn = getIteratorFn(propValue); - if (iteratorFn) { - var iterator = iteratorFn.call(propValue); - var step; - if (iteratorFn !== propValue.entries) { - while (!(step = iterator.next()).done) { - if (!isNode(step.value)) { - return false; - } - } - } else { - while (!(step = iterator.next()).done) { - var entry = step.value; - if (entry) { - if (!isNode(entry[1])) { - return false; - } - } - } - } - } else { - return false; - } - return true; - default: - return false; - } - } - function isSymbol(propType, propValue) { - if (propType === 'symbol') { - return true; - } - if (!propValue) { - return false; - } - if (propValue['@@toStringTag'] === 'Symbol') { - return true; - } - if (typeof Symbol === 'function' && propValue instanceof Symbol) { - return true; - } - return false; - } - function getPropType(propValue) { - var propType = typeof propValue; - if (Array.isArray(propValue)) { - return 'array'; - } - if (propValue instanceof RegExp) { - return 'object'; - } - if (isSymbol(propType, propValue)) { - return 'symbol'; - } - return propType; - } - function getPreciseType(propValue) { - if (typeof propValue === 'undefined' || propValue === null) { - return '' + propValue; - } - var propType = getPropType(propValue); - if (propType === 'object') { - if (propValue instanceof Date) { - return 'date'; - } else if (propValue instanceof RegExp) { - return 'regexp'; - } - } - return propType; - } - function getPostfixForTypeWarning(value) { - var type = getPreciseType(value); - switch (type) { - case 'array': - case 'object': - return 'an ' + type; - case 'boolean': - case 'date': - case 'regexp': - return 'a ' + type; - default: - return type; - } - } - function getClassName(propValue) { - if (!propValue.constructor || !propValue.constructor.name) { - return ANONYMOUS; - } - return propValue.constructor.name; - } - ReactPropTypes.checkPropTypes = checkPropTypes; - ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache; - ReactPropTypes.PropTypes = ReactPropTypes; - return ReactPropTypes; - }; - return factoryWithTypeCheckers; - } - - { - var ReactIs = requireReactIs(); - var throwOnDirectAccess = true; - propTypes$1.exports = requireFactoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess); - } - - var useEffect = React__namespace.useEffect, useRef = React__namespace.useRef, useState = React__namespace.useState; - function CKEditor(_a) { - var _b = _a.config, config = _b === void 0 ? {} : _b, debug = _a.debug, editorUrl = _a.editorUrl, initData = _a.initData, name = _a.name, readOnly = _a.readOnly, style = _a.style, type = _a.type, - handlers = __rest(_a, ["config", "debug", "editorUrl", "initData", "name", "readOnly", "style", "type"]); - var _c = useState(null), element = _c[0], setElement = _c[1]; - var refs = useRef(handlers); - var dispatchEvent = function (_a) { - var type = _a.type, payload = _a.payload; - var handlerName = eventNameToHandlerName(stripPrefix(type)); - var handler = refs.current[handlerName]; - if (handler) { - handler(payload); - } - }; - if (config && typeof readOnly === 'boolean') { - config.readOnly = readOnly; - } - var _d = useCKEditor({ - config: config, - dispatchEvent: dispatchEvent, - debug: debug, - editorUrl: editorUrl, - element: element, - initContent: typeof initData === 'string' ? initData : undefined, - subscribeTo: Object.keys(handlers) - .filter(function (key) { return key.indexOf('on') === 0; }) - .map(handlerNameToEventName), - type: type - }), editor = _d.editor, status = _d.status; - useEffect(function () { - var canSetStyles = type !== 'inline' && - editor && - (status === 'loaded' || status === 'ready'); - if (style && canSetStyles) { - editor.container.setStyles(style); - } - return function () { - if (style && canSetStyles) { - Object.keys(style) - .map(camelToKebab) - .forEach(function (styleName) { - editor.container.removeStyle(styleName); - }); - } - }; - }, [editor, status, style, type]); - useEffect(function () { - if (editor && status === 'ready' && typeof readOnly === 'boolean') { - editor.setReadOnly(readOnly); - } - }, [editor, status, readOnly]); - return (React__namespace.createElement("div", { id: name !== null && name !== void 0 ? name : undefined, ref: setElement, style: getStyle(type !== null && type !== void 0 ? type : 'classic', status, style) }, typeof initData === 'string' ? null : initData)); - } - var propTypes = __assign({ - config: propTypes$1.exports.object, - debug: propTypes$1.exports.bool, - editorUrl: propTypes$1.exports.string, - initData: propTypes$1.exports.node, - name: propTypes$1.exports.string, - readOnly: propTypes$1.exports.bool, - style: propTypes$1.exports.object, - type: propTypes$1.exports.oneOf(['classic', 'inline']) }, defaultEvents.reduce(function (acc, key) { - var _a; - return __assign(__assign({}, acc), (_a = {}, _a[eventNameToHandlerName(key)] = propTypes$1.exports.func, _a)); - }, {})); - CKEditor.propTypes = propTypes; - - exports.CKEditor = CKEditor; - exports.CKEditorEventAction = CKEditorEventAction; - exports.prefixEventName = prefixEventName; - exports.registerEditorEventHandler = registerEditorEventHandler; - exports.stripPrefix = stripPrefix; - exports.useCKEditor = useCKEditor; - - Object.defineProperty(exports, '__esModule', { value: true }); - -})); diff --git a/dist/index.umd.production.min.js b/dist/index.umd.production.min.js deleted file mode 100644 index ae1f401..0000000 --- a/dist/index.umd.production.min.js +++ /dev/null @@ -1,5 +0,0 @@ -/** - * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. - * For licensing, see LICENSE.md. - */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CKEditor4React={},e.React)}(this,(function(e,t){"use strict";function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var r=n(t),o=function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n2&&void 0!==arguments[2]?arguments[2]:{};return function(){clearTimeout(n);for(var o=arguments.length,a=new Array(o),i=0;i({ debug, editor, evtName, handler, listenerData, priority }: CKEditorRegisterEventArgs): () => void; -export default registerEditorEventHandler; diff --git a/dist/types.d.ts b/dist/types.d.ts deleted file mode 100644 index 1e18e99..0000000 --- a/dist/types.d.ts +++ /dev/null @@ -1,380 +0,0 @@ -/** - * @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 { - /** - * Additional event data. - */ - data?: Record | 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; - /** - * 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 = (evt: CKEditorEventPayload) => 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; -/** - * Namespace object. - */ -export type CKEditorNamespace = any; -/** - * `useCKEditor` hook arguments. - */ -export interface CKEditorHookProps { - /** - * 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; - /** - * 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 { - /** - * Toggles debugging. Logs info related to editor lifecycle events. - */ - debug?: boolean | null; - /** - * Editor instance. - */ - editor: CKEditorInstance; - /** - * Event handler to register. - */ - handler: CKEditorEventHandler; - /** - * 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 = PropTypes.InferProps> & { - config?: CKEditorConfig | null; - style?: React.CSSProperties | null; -} & Partial & 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'; -} diff --git a/dist/useCKEditor.d.ts b/dist/useCKEditor.d.ts deleted file mode 100644 index 3d8ef29..0000000 --- a/dist/useCKEditor.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @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({ config, debug, dispatchEvent, subscribeTo, editorUrl, element, initContent, type }: CKEditorHookProps): CKEditorHookResult; -export default useCKEditor; diff --git a/dist/utils.d.ts b/dist/utils.d.ts deleted file mode 100644 index 4b71a15..0000000 --- a/dist/utils.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @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"; -};