@ncino/web-components 5.0.0-preview.2 → 5.0.0-preview.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_commonjsHelpers.js +1 -1
- package/dist/_virtual/index_html.js +1 -1
- package/dist/_virtual/index_react.js +1 -1
- package/dist/_virtual/preload-helper.js +1 -1
- package/dist/assets/node_modules/.pnpm/ckeditor5@45.2.1/node_modules/ckeditor5/dist/ckeditor5.css +1 -1
- package/dist/components/accordion/gator/base/accordion.gator.js +6 -6
- package/dist/components/avatar/gator/avatar.gator.js +2 -2
- package/dist/components/badge/gator/badge.gator.js +2 -2
- package/dist/components/boolean/boolean.gator.js +6 -6
- package/dist/components/breadcrumbs/gator/breadcrumb/breadcrumb.gator.js +2 -2
- package/dist/components/button/gator/button.gator.js +4 -4
- package/dist/components/button-group/gator/button-group.gator.js +2 -2
- package/dist/components/checkbox/checkbox.gator.js +5 -5
- package/dist/components/checkbox-group/checkbox-group.gator.js +8 -8
- package/dist/components/combobox/base/combobox.js +1 -1
- package/dist/components/combobox/base/combobox.slds.js +13 -13
- package/dist/components/date-picker/base/gator/datepicker.gator.js +18 -18
- package/dist/components/date-picker/year-month-selector/year-month-selector.gator.js +2 -2
- package/dist/components/headline-card/gator/headline-card.gator.js +2 -2
- package/dist/components/icon/gator/icon.gator.js +2 -2
- package/dist/components/illustration/gator/illustration.gator.js +2 -2
- package/dist/components/input/base/input-base.gator.js +1 -1
- package/dist/components/input/gator/dropdown/input-dropdown.gator.js +11 -11
- package/dist/components/input/gator/input-currency/input-currency.gator.js +2 -2
- package/dist/components/input/gator/input-date/input-date.gator.js +15 -15
- package/dist/components/input/gator/input-file/input-file.gator.js +3 -3
- package/dist/components/input/gator/input-masked/input-masked.gator.js +1 -1
- package/dist/components/input/gator/input-phone/input-phone.gator.js +2 -2
- package/dist/components/input/gator/input-search/input-search.gator.js +2 -2
- package/dist/components/input/gator/input-text/input-text.gator.js +1 -1
- package/dist/components/input/gator/input-time/input-time.gator.js +2 -2
- package/dist/components/list/gator/list/list.gator.js +2 -2
- package/dist/components/list/gator/list-item/list-item.gator.js +6 -6
- package/dist/components/menu/base/gator/menu.gator.js +3 -3
- package/dist/components/menu/base/slds/menu.slds.js +2 -2
- package/dist/components/menu/menu-item/gator/menu-item.gator.js +2 -2
- package/dist/components/menu/menu-submenu/menu-submenu.js +1 -1
- package/dist/components/modal/gator/modal.gator.js +38 -39
- package/dist/components/page-header/gator/page-header.gator.js +2 -2
- package/dist/components/panel/gator/panel.gator.js +13 -13
- package/dist/components/panel/gator/panel.storybook-test.js +1 -1
- package/dist/components/pill/pill.slds.js +3 -3
- package/dist/components/popover/gator/popover.gator.js +10 -10
- package/dist/components/popover/popover.js +1 -1
- package/dist/components/radio/radio.gator.js +2 -2
- package/dist/components/radio-group/radio-group.gator.js +2 -2
- package/dist/components/selection-box-group/selection-box-group.gator.js +5 -5
- package/dist/components/selector/gator/selector.gator.js +2 -2
- package/dist/components/switch/gator/switch.gator.js +2 -2
- package/dist/components/tabs/gator/tabset/tabset.gator.js +3 -3
- package/dist/components/text-detail/gator/text-detail.gator.js +17 -18
- package/dist/components/time-picker/gator/time-picker.gator.js +19 -19
- package/dist/components/tooltip/tooltip.js +1 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-autosave@45.2.1/node_modules/@ckeditor/ckeditor5-autosave/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-basic-styles@45.2.1/node_modules/@ckeditor/ckeditor5-basic-styles/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-clipboard@45.2.1/node_modules/@ckeditor/ckeditor5-clipboard/dist/index.js +10 -10
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-cloud-services@45.2.1/node_modules/@ckeditor/ckeditor5-cloud-services/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-code-block@45.2.1/node_modules/@ckeditor/ckeditor5-code-block/dist/index.js +5 -5
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-core@45.2.1/node_modules/@ckeditor/ckeditor5-core/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-editor-classic@45.2.1/node_modules/@ckeditor/ckeditor5-editor-classic/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-engine@45.2.1/node_modules/@ckeditor/ckeditor5-engine/dist/index.js +12 -12
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-find-and-replace@45.2.1/node_modules/@ckeditor/ckeditor5-find-and-replace/dist/index.js +3 -3
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-font@45.2.1/node_modules/@ckeditor/ckeditor5-font/dist/index.js +3 -3
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-heading@45.2.1/node_modules/@ckeditor/ckeditor5-heading/dist/index.js +3 -3
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-html-embed@45.2.1/node_modules/@ckeditor/ckeditor5-html-embed/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-html-support@45.2.1/node_modules/@ckeditor/ckeditor5-html-support/dist/index.js +6 -6
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-image@45.2.1/node_modules/@ckeditor/ckeditor5-image/dist/index.js +4 -4
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-indent@45.2.1/node_modules/@ckeditor/ckeditor5-indent/dist/index.js +4 -4
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-link@45.2.1/node_modules/@ckeditor/ckeditor5-link/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-list@45.2.1/node_modules/@ckeditor/ckeditor5-list/dist/index.js +5 -5
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-markdown-gfm@45.2.1/node_modules/@ckeditor/ckeditor5-markdown-gfm/dist/index.js +4 -4
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-media-embed@45.2.1/node_modules/@ckeditor/ckeditor5-media-embed/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-paragraph@45.2.1/node_modules/@ckeditor/ckeditor5-paragraph/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-paste-from-office@45.2.1/node_modules/@ckeditor/ckeditor5-paste-from-office/dist/index.js +9 -9
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-source-editing@45.2.1/node_modules/@ckeditor/ckeditor5-source-editing/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-special-characters@45.2.1/node_modules/@ckeditor/ckeditor5-special-characters/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-style@45.2.1/node_modules/@ckeditor/ckeditor5-style/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-table@45.2.1/node_modules/@ckeditor/ckeditor5-table/dist/index.js +6 -6
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-typing@45.2.1/node_modules/@ckeditor/ckeditor5-typing/dist/index.js +4 -4
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-ui@45.2.1/node_modules/@ckeditor/ckeditor5-ui/dist/index.js +10 -10
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-undo@45.2.1/node_modules/@ckeditor/ckeditor5-undo/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-upload@45.2.1/node_modules/@ckeditor/ckeditor5-upload/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-utils@45.2.1/node_modules/@ckeditor/ckeditor5-utils/dist/index.js +38 -38
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-watchdog@45.2.1/node_modules/@ckeditor/ckeditor5-watchdog/dist/index.js +3 -3
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-widget@45.2.1/node_modules/@ckeditor/ckeditor5-widget/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@deltablot_dropzone@7.3.1/node_modules/@deltablot/dropzone/dist/dropzone.js +1 -1
- package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/lib/main.js +1 -1
- package/dist/node_modules/.pnpm/@figma_code-connect@1.3.4/node_modules/@figma/code-connect/dist/common/fetch.js +1 -0
- package/dist/node_modules/.pnpm/@figma_code-connect@1.3.4/node_modules/@figma/code-connect/dist/connect/figma_rest_api.js +1 -0
- package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/connect/helpers.js +1 -1
- package/dist/node_modules/.pnpm/@figma_code-connect@1.3.4/node_modules/@figma/code-connect/package.json.js +1 -0
- package/dist/node_modules/.pnpm/@floating-ui_dom@1.7.2/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +1 -1
- package/dist/node_modules/.pnpm/@lit_reactive-element@2.1.0/node_modules/@lit/reactive-element/reactive-element.js +2 -2
- package/dist/node_modules/.pnpm/@storybook_core@8.6.14_prettier@3.6.2_storybook@8.6.14_prettier@3.6.2_/node_modules/@storybook/core/dist/channels/index.js +9 -9
- package/dist/node_modules/.pnpm/@storybook_core@8.6.14_prettier@3.6.2_storybook@8.6.14_prettier@3.6.2_/node_modules/@storybook/core/dist/csf/index.js +1 -1
- package/dist/node_modules/.pnpm/@storybook_core@8.6.14_prettier@3.6.2_storybook@8.6.14_prettier@3.6.2_/node_modules/@storybook/core/dist/preview-api/index.js +22 -22
- package/dist/node_modules/.pnpm/@storybook_instrumenter@8.6.14_storybook@8.6.14_prettier@3.6.2_/node_modules/@storybook/instrumenter/dist/index.js +36 -36
- package/dist/node_modules/.pnpm/@storybook_test@8.6.14_storybook@8.6.14_prettier@3.6.2_/node_modules/@storybook/test/dist/index.js +111 -111
- package/dist/node_modules/.pnpm/@vitest_browser@3.2.4_msw@2.7.3_@types_node@24.0.10_typescript@5.8.3__playwright@1.53.2_77c47ac19cbe97978028e1e5ac862536/node_modules/@vitest/browser/context.js +1 -0
- package/dist/node_modules/.pnpm/@vitest_expect@3.2.4/node_modules/@vitest/expect/dist/index.js +8 -8
- package/dist/node_modules/.pnpm/@vitest_pretty-format@3.2.4/node_modules/@vitest/pretty-format/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js +5 -5
- package/dist/node_modules/.pnpm/@vitest_snapshot@3.2.4/node_modules/@vitest/snapshot/dist/index.js +11 -11
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/diff.js +21 -21
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/error.js +2 -2
- package/dist/node_modules/.pnpm/axe-core@4.10.3/node_modules/axe-core/axe.js +4 -4
- package/dist/node_modules/.pnpm/chai@5.2.0/node_modules/chai/chai.js +3 -3
- package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/_internal/isPrototype.js +1 -1
- package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.js +1 -1
- package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/get.js +1 -1
- package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/unset.js +1 -1
- package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.js +1 -1
- package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/function/debounce.js +1 -1
- package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/object/cloneDeepWith.js +1 -1
- package/dist/node_modules/.pnpm/lit-element@4.2.0/node_modules/lit-element/lit-element.js +2 -2
- package/dist/node_modules/.pnpm/lit-html@3.3.0/node_modules/lit-html/async-directive.js +1 -1
- package/dist/node_modules/.pnpm/lit-html@3.3.0/node_modules/lit-html/directives/class-map.js +2 -2
- package/dist/node_modules/.pnpm/lit-html@3.3.0/node_modules/lit-html/directives/ref.js +2 -2
- package/dist/node_modules/.pnpm/lit-html@3.3.0/node_modules/lit-html/lit-html.js +3 -3
- package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cache/cache.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cache/cachestorage.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cookies/parse.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/constants.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/headers.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/index.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/request.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/response.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/util.js +2 -2
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/webidl.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/connection.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/events.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/frame.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/receiver.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/util.js +1 -1
- package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/websocket.js +1 -1
- package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.10_@vitest_browser@3.2.4_@vitest_ui@3_8c34ee540b1f52c214debce201d1e515/node_modules/vitest/dist/chunks/utils.XdZDrNZV.js +1 -1
- package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.10_@vitest_browser@3.2.4_@vitest_ui@3_8c34ee540b1f52c214debce201d1e515/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js +8 -8
- package/dist/packages/web-components/src/components/button/gator/button.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/modal/gator/modal.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/switch/gator/switch.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/text-detail/gator/text-detail.gator.scss.js +1 -1
- package/dist/packages/web-components/src/index.slds.scss.js +1 -1
- package/dist/types/components/modal/gator/modal.gator.d.ts +1 -1
- package/dist/types/components/text-detail/gator/text-detail.gator.d.ts +4 -2
- package/dist/utils/accessibility-utils.js +1 -1
- package/dist/utils/datatestid-utils.js +1 -1
- package/dist/utils/lightdom-utils.js +1 -1
- package/dist/utils/vitest-a11y-utils.js +1 -1
- package/dist/utils/vitest-utils.js +1 -1
- package/package.json +10 -10
- package/web-types.json +2 -3
- package/dist/node_modules/.pnpm/@figma_code-connect@1.3.3/node_modules/@figma/code-connect/dist/common/fetch.js +0 -1
- package/dist/node_modules/.pnpm/@figma_code-connect@1.3.3/node_modules/@figma/code-connect/dist/connect/figma_rest_api.js +0 -1
- package/dist/node_modules/.pnpm/@figma_code-connect@1.3.3/node_modules/@figma/code-connect/package.json.js +0 -1
- package/dist/node_modules/.pnpm/@vitest_browser@3.2.4_msw@2.7.3_@types_node@24.0.10_typescript@5.8.3__playwright@1.53.1_5fd2997ee9a97429a51e07bc2023c338/node_modules/@vitest/browser/context.js +0 -1
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/client/external.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/client/figma_client.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/common/logging.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/common/updates.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/connect/external_types.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/connect/index_common.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/html/external.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/html/index_html.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/html/template_literal.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/react/external.js +0 -0
- /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/react/index_react.js +0 -0
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import{Plugin as b}from"../../../../../@ckeditor_ckeditor5-core@45.2.1/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{EventInfo as q,uid as z,delay as j,DomEmitterMixin as A,env as f,global as m,createElement as x,Rect as _,getRangeFromMouseEvent as ee,ResizeObserver as te,toUnit as re}from"../../../../../@ckeditor_ckeditor5-utils@45.2.1/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{MouseObserver as ne,LiveRange as T,DomEventObserver as ie,DataTransfer as oe,Range as se}from"../../../../../@ckeditor_ckeditor5-engine@45.2.1/node_modules/@ckeditor/ckeditor5-engine/dist/index.js";import{Widget as ae,isWidget as k}from"../../../../../@ckeditor_ckeditor5-widget@45.2.1/node_modules/@ckeditor/ckeditor5-widget/dist/index.js";import{View as le}from"../../../../../@ckeditor_ckeditor5-ui@45.2.1/node_modules/@ckeditor/ckeditor5-ui/dist/index.js";import{mapValues as ce}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/mapValues.js";import{throttle as V}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/function/throttle.js";/**
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/class
|
|
4
|
+
*/class v extends ie{domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"];constructor(e){super(e);const t=this.document;this.listenTo(t,"paste",r("clipboardInput"),{priority:"low"}),this.listenTo(t,"drop",r("clipboardInput"),{priority:"low"}),this.listenTo(t,"dragover",r("dragging"),{priority:"low"});function r(n){return(s,o)=>{o.preventDefault();const i=o.dropRange?[o.dropRange]:null,l=new q(t,n);t.fire(l,{dataTransfer:o.dataTransfer,method:s.name,targetRanges:i,target:o.target,domEvent:o.domEvent}),l.stop.called&&o.stopPropagation()}}}onDomEvent(e){const t="clipboardData"in e?e.clipboardData:e.dataTransfer,r=e.type=="drop"||e.type=="paste",n={dataTransfer:new oe(t,{cacheFiles:r})};if(e.type=="drop"||e.type=="dragover"){const s=ee(e);n.dropRange=s&&this.view.domConverter.domRangeToView(s)}this.fire(e.type,e,n)}}/**
|
|
5
5
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
6
6
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
7
|
-
*/function
|
|
7
|
+
*/function de(a){return a=a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\r?\n\r?\n/g,"</p><p>").replace(/\r?\n/g,"<br>").replace(/\t/g," ").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," "),(a.includes("</p><p>")||a.includes("<br>"))&&(a=`<p>${a}</p>`),a}/**
|
|
8
8
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
9
9
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
10
|
-
*/function
|
|
10
|
+
*/function ge(a){return a.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g,(e,t)=>t.length==1?" ":t).replace(/<!--[\s\S]*?-->/g,"")}/**
|
|
11
11
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
12
12
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
13
|
-
*/const
|
|
14
|
-
`;let
|
|
15
|
-
`;for(const
|
|
13
|
+
*/const B=["figcaption","li"],L=["ol","ul"];function H(a,e){if(e.is("$text")||e.is("$textProxy"))return e.data;if(e.is("element","img")&&e.hasAttribute("alt"))return e.getAttribute("alt");if(e.is("element","br"))return`
|
|
14
|
+
`;let t="",r=null;for(const n of e.getChildren())t+=pe(n,r)+H(a,n),r=n;if(e.is("rawElement")){const n=document.createElement("div");e.render(n,a),t+=K(n)}return t}function K(a){let e="";if(a.nodeType===Node.TEXT_NODE)return a.textContent;if(a.tagName==="BR")return`
|
|
15
|
+
`;for(const t of a.childNodes)e+=K(t);return e}function pe(a,e){return e?a.is("element","li")&&!a.isEmpty&&a.getChild(0).is("containerElement")||L.includes(a.name)&&L.includes(e.name)?`
|
|
16
16
|
|
|
17
|
-
`:!
|
|
18
|
-
`:
|
|
17
|
+
`:!a.is("containerElement")&&!e.is("containerElement")?"":B.includes(a.name)||B.includes(e.name)?`
|
|
18
|
+
`:a.is("element")&&a.getCustomProperty("dataPipeline:transparentRendering")||e.is("element")&&e.getCustomProperty("dataPipeline:transparentRendering")?"":`
|
|
19
19
|
|
|
20
|
-
`:""}class Y extends _{constructor(){super(...arguments);m(this,"_markersToCopy",new Map)}static get pluginName(){return"ClipboardMarkersUtils"}static get isOfficialPlugin(){return!0}_registerMarkerToCopy(e,n){this._markersToCopy.set(e,n)}_copySelectedFragmentWithMarkers(e,n,t=i=>i.model.getSelectedContent(i.model.document.selection)){return this.editor.model.change(i=>{const o=i.model.document.selection;i.setSelection(n);const r=this._insertFakeMarkersIntoSelection(i,i.model.document.selection,e),s=t(i),c=this._removeFakeMarkersInsideElement(i,s);for(const[d,g]of Object.entries(r)){c[d]||(c[d]=i.createRangeIn(s));for(const p of g)i.remove(p)}s.markers.clear();for(const[d,g]of Object.entries(c))s.markers.set(d,g);return i.setSelection(o),s})}_pasteMarkersIntoTransformedElement(e,n){const t=this._getPasteMarkersFromRangeMap(e);return this.editor.model.change(i=>{const o=this._insertFakeMarkersElements(i,t),r=n(i),s=this._removeFakeMarkersInsideElement(i,r);for(const c of Object.values(o).flat())i.remove(c);for(const[c,d]of Object.entries(s))i.model.markers.has(c)||i.addMarker(c,{usingOperation:!0,affectsData:!0,range:d});return r})}_pasteFragmentWithMarkers(e){const n=this._getPasteMarkersFromRangeMap(e.markers);e.markers.clear();for(const t of n)e.markers.set(t.name,t.range);return this.editor.model.insertContent(e)}_forceMarkersCopy(e,n,t={allowedActions:"all",copyPartiallySelected:!0,duplicateOnPaste:!0}){const i=this._markersToCopy.get(e);this._markersToCopy.set(e,t),n(),i?this._markersToCopy.set(e,i):this._markersToCopy.delete(e)}_isMarkerCopyable(e,n){const t=this._getMarkerClipboardConfig(e);if(!t)return!1;if(!n)return!0;const{allowedActions:i}=t;return i==="all"||i.includes(n)}_hasMarkerConfiguration(e){return!!this._getMarkerClipboardConfig(e)}_getMarkerClipboardConfig(e){const[n]=e.split(":");return this._markersToCopy.get(n)||null}_insertFakeMarkersIntoSelection(e,n,t){const i=this._getCopyableMarkersFromSelection(e,n,t);return this._insertFakeMarkersElements(e,i)}_getCopyableMarkersFromSelection(e,n,t){const i=Array.from(n.getRanges()),o=new Set(i.flatMap(s=>Array.from(e.model.markers.getMarkersIntersectingRange(s)))),r=s=>{if(!this._isMarkerCopyable(s.name,t))return!1;const{copyPartiallySelected:d}=this._getMarkerClipboardConfig(s.name);if(!d){const g=s.getRange();return i.some(p=>p.containsRange(g,!0))}return!0};return Array.from(o).filter(r).map(s=>({name:t==="dragstart"?this._getUniqueMarkerName(s.name):s.name,range:s.getRange()}))}_getPasteMarkersFromRangeMap(e,n=null){const{model:t}=this.editor;return(e instanceof Map?Array.from(e.entries()):Object.entries(e)).flatMap(([o,r])=>{if(!this._hasMarkerConfiguration(o))return[{name:o,range:r}];if(this._isMarkerCopyable(o,n)){const s=this._getMarkerClipboardConfig(o),c=t.markers.has(o)&&t.markers.get(o).getRange().root.rootName==="$graveyard";return(s.duplicateOnPaste||c)&&(o=this._getUniqueMarkerName(o)),[{name:o,range:r}]}return[]})}_insertFakeMarkersElements(e,n){const t={},i=n.flatMap(o=>{const{start:r,end:s}=o.range;return[{position:r,marker:o,type:"start"},{position:s,marker:o,type:"end"}]}).sort(({position:o},{position:r})=>o.isBefore(r)?1:-1);for(const{position:o,marker:r,type:s}of i){const c=e.createElement("$marker",{"data-name":r.name,"data-type":s});t[r.name]||(t[r.name]=[]),t[r.name].push(c),e.insert(c,o)}return t}_removeFakeMarkersInsideElement(e,n){const i=this._getAllFakeMarkersFromElement(e,n).reduce((o,r)=>{const s=r.markerElement&&e.createPositionBefore(r.markerElement);let c=o[r.name],d=!1;return c!=null&&c.start&&(c!=null&&c.end)&&(this._getMarkerClipboardConfig(r.name).duplicateOnPaste?o[this._getUniqueMarkerName(r.name)]=o[r.name]:d=!0,c=null),d||(o[r.name]={...c,[r.type]:s}),r.markerElement&&e.remove(r.markerElement),o},{});return me(i,o=>new de(o.start||e.createPositionFromPath(n,[0]),o.end||e.createPositionAt(n,"end")))}_getAllFakeMarkersFromElement(e,n){const t=Array.from(e.createRangeIn(n)).flatMap(({item:r})=>{if(!r.is("element","$marker"))return[];const s=r.getAttribute("data-name"),c=r.getAttribute("data-type");return[{markerElement:r,name:s,type:c}]}),i=[],o=[];for(const r of t)r.type==="end"&&(t.some(c=>c.name===r.name&&c.type==="start")||i.push({markerElement:null,name:r.name,type:"start"})),r.type==="start"&&(t.some(c=>c.name===r.name&&c.type==="end")||o.unshift({markerElement:null,name:r.name,type:"end"}));return[...i,...t,...o]}_getUniqueMarkerName(e){const n=e.split(":"),t=H().substring(1,6);return n.length===3?`${n.slice(0,2).join(":")}:${t}`:`${n.join(":")}:${t}`}}class T extends _{static get pluginName(){return"ClipboardPipeline"}static get isOfficialPlugin(){return!0}static get requires(){return[Y]}init(){this.editor.editing.view.addObserver(D),this._setupPasteDrop(),this._setupCopyCut()}_fireOutputTransformationEvent(a,e,n){const t=this.editor.plugins.get("ClipboardMarkersUtils");this.editor.model.enqueueChange({isUndoable:n==="cut"},()=>{const i=t._copySelectedFragmentWithMarkers(n,e);this.fire("outputTransformation",{dataTransfer:a,content:i,method:n})})}_setupPasteDrop(){const a=this.editor,e=a.model,n=a.editing.view,t=n.document,i=this.editor.plugins.get("ClipboardMarkersUtils");this.listenTo(t,"clipboardInput",(o,r)=>{r.method=="paste"&&!a.model.canEditAt(a.model.document.selection)&&o.stop()},{priority:"highest"}),this.listenTo(t,"clipboardInput",(o,r)=>{const s=r.dataTransfer;let c;if(r.content)c=r.content;else{let p="";s.getData("text/html")?p=he(s.getData("text/html")):s.getData("text/plain")&&(p=ue(s.getData("text/plain"))),c=this.editor.data.htmlProcessor.toView(p)}const d=new j(this,"inputTransformation"),g=s.getData("application/ckeditor5-editor-id")||null;this.fire(d,{content:c,dataTransfer:s,sourceEditorId:g,targetRanges:r.targetRanges,method:r.method}),d.stop.called&&o.stop(),n.scrollToTheSelection()},{priority:"low"}),this.listenTo(this,"inputTransformation",(o,r)=>{if(r.content.isEmpty)return;const c=this.editor.data.toModel(r.content,"$clipboardHolder");c.childCount!=0&&(o.stop(),e.change(()=>{this.fire("contentInsertion",{content:c,method:r.method,sourceEditorId:r.sourceEditorId,dataTransfer:r.dataTransfer,targetRanges:r.targetRanges})}))},{priority:"low"}),this.listenTo(this,"contentInsertion",(o,r)=>{r.resultRange=i._pasteFragmentWithMarkers(r.content)},{priority:"low"})}_setupCopyCut(){const a=this.editor,e=a.model.document,t=a.editing.view.document,i=(o,r)=>{const s=r.dataTransfer;r.preventDefault(),this._fireOutputTransformationEvent(s,e.selection,o.name)};this.listenTo(t,"copy",i,{priority:"low"}),this.listenTo(t,"cut",(o,r)=>{a.model.canEditAt(a.model.document.selection)?i(o,r):r.preventDefault()},{priority:"low"}),this.listenTo(this,"outputTransformation",(o,r)=>{const s=a.data.toView(r.content,{isClipboardPipeline:!0});t.fire("clipboardOutput",{dataTransfer:r.dataTransfer,content:s,method:r.method})},{priority:"low"}),this.listenTo(t,"clipboardOutput",(o,r)=>{r.content.isEmpty||(r.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(r.content)),r.dataTransfer.setData("text/plain",G(a.data.htmlProcessor.domConverter,r.content)),r.dataTransfer.setData("application/ckeditor5-editor-id",this.editor.id)),r.method=="cut"&&a.model.deleteContent(e.selection)},{priority:"low"})}}const A=se("px");class be extends pe{constructor(){super();const a=this.bindTemplate;this.set({isVisible:!1,left:null,top:null,width:null}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-clipboard-drop-target-line",a.if("isVisible","ck-hidden",e=>!e)],style:{left:a.to("left",e=>A(e)),top:a.to("top",e=>A(e)),width:a.to("width",e=>A(e))}}})}}class C extends _{constructor(){super(...arguments);m(this,"removeDropMarkerDelayed",K(()=>this.removeDropMarker(),40));m(this,"_updateDropMarkerThrottled",L(e=>this._updateDropMarker(e),40));m(this,"_reconvertMarkerThrottled",L(()=>{this.editor.model.markers.has("drop-target")&&this.editor.editing.reconvertMarker("drop-target")},0));m(this,"_dropTargetLineView",new be);m(this,"_domEmitter",new(S()));m(this,"_scrollables",new Map)}static get pluginName(){return"DragDropTarget"}static get isOfficialPlugin(){return!0}init(){this._setupDropMarker()}destroy(){this._domEmitter.stopListening();for(const{resizeObserver:e}of this._scrollables.values())e.destroy();return this._updateDropMarkerThrottled.cancel(),this.removeDropMarkerDelayed.cancel(),this._reconvertMarkerThrottled.cancel(),super.destroy()}updateDropMarker(e,n,t,i,o,r){this.removeDropMarkerDelayed.cancel();const s=N(this.editor,e,n,t,i,o,r);/* istanbul ignore next -- @preserve */if(s){if(r&&r.containsRange(s))return this.removeDropMarker();this._updateDropMarkerThrottled(s)}}getFinalDropRange(e,n,t,i,o,r){const s=N(this.editor,e,n,t,i,o,r);return this.removeDropMarker(),s}removeDropMarker(){const e=this.editor.model;this.removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),this._dropTargetLineView.isVisible=!1,e.markers.has("drop-target")&&e.change(n=>{n.removeMarker("drop-target")})}_setupDropMarker(){const e=this.editor;e.ui.view.body.add(this._dropTargetLineView),e.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),e.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(n,{writer:t})=>{if(e.model.schema.checkChild(n.markerRange.start,"$text"))return this._dropTargetLineView.isVisible=!1,this._createDropTargetPosition(t);n.markerRange.isCollapsed?this._updateDropTargetLine(n.markerRange):this._dropTargetLineView.isVisible=!1}})}_updateDropMarker(e){const n=this.editor,t=n.model.markers;n.model.change(i=>{t.has("drop-target")?t.get("drop-target").getRange().isEqual(e)||i.updateMarker("drop-target",{range:e}):i.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})})}_createDropTargetPosition(e){return e.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},function(n){const t=this.toDomElement(n);return t.append("",n.createElement("span"),""),t})}_updateDropTargetLine(e){const n=this.editor.editing,t=e.start.nodeBefore,i=e.start.nodeAfter,o=e.start.parent,r=t?n.mapper.toViewElement(t):null,s=r?n.view.domConverter.mapViewToDom(r):null,c=i?n.mapper.toViewElement(i):null,d=c?n.view.domConverter.mapViewToDom(c):null,g=n.mapper.toViewElement(o);if(!g)return;const p=n.view.domConverter.mapViewToDom(g),h=this._getScrollableRect(g),{scrollX:u,scrollY:v}=f.window,O=s?new k(s):null,I=d?new k(d):null,E=new k(p).excludeScrollbarsAndBorders(),F=O?O.bottom:E.top,R=I?I.top:E.bottom,x=f.window.getComputedStyle(p),P=F<=R?(F+R)/2:R;if(h.top<P&&P<h.bottom){const Z=E.left+parseFloat(x.paddingLeft),ee=E.right-parseFloat(x.paddingRight),V=Math.max(Z+u,h.left),te=Math.min(ee+u,h.right);this._dropTargetLineView.set({isVisible:!0,left:V,top:P+v,width:te-V})}else this._dropTargetLineView.isVisible=!1}_getScrollableRect(e){const n=e.root.rootName;let t;if(this._scrollables.has(n))t=this._scrollables.get(n).domElement;else{const i=this.editor.editing.view.domConverter.mapViewToDom(e);t=ke(i),this._domEmitter.listenTo(t,"scroll",this._reconvertMarkerThrottled,{usePassive:!0});const o=new oe(t,this._reconvertMarkerThrottled);this._scrollables.set(n,{domElement:t,resizeObserver:o})}return new k(t).excludeScrollbarsAndBorders()}}function N(l,a,e,n,t,i,o){const r=l.model,s=l.editing.mapper;let d=W(l,a);for(;d;){if(!i){if(r.schema.checkChild(d,"$text")){if(e){const g=e[0].start,p=s.toModelPosition(g);if(!o||Array.from(o.getItems({shallow:!0})).every(u=>r.schema.checkChild(p,u))){if(r.schema.checkChild(p,"$text"))return r.createRange(p);if(g)return M(l,W(l,g.parent),n,t)}}}else if(r.schema.isInline(d))return M(l,d,n,t)}if(r.schema.isBlock(d))return M(l,d,n,t);if(r.schema.checkChild(d,"$block")){const g=Array.from(d.getChildren()).filter(u=>u.is("element")&&!_e(l,u));let p=0,h=g.length;if(h==0)return r.createRange(r.createPositionAt(d,"end"));for(;p<h-1;){const u=Math.floor((p+h)/2);J(l,g[u],n,t)=="before"?h=u:p=u}return M(l,g[p],n,t)}d=d.parent}return null}function _e(l,a){const e=l.editing.mapper,n=l.editing.view.domConverter,t=e.toViewElement(a);if(!t)return!0;const i=n.mapViewToDom(t);return f.window.getComputedStyle(i).float!="none"}function M(l,a,e,n){const t=l.model;return t.createRange(t.createPositionAt(a,J(l,a,e,n)))}function J(l,a,e,n){const t=l.editing.mapper,i=l.editing.view.domConverter,o=t.toViewElement(a),r=i.mapViewToDom(o),s=new k(r);return l.model.schema.isInline(a)?e<(s.left+s.right)/2?"before":"after":n<(s.top+s.bottom)/2?"before":"after"}function W(l,a){const e=l.editing.mapper,n=l.editing.view,t=e.toModelElement(a);if(t)return t;const i=n.createPositionBefore(a),o=e.findMappedViewAncestor(i);return e.toModelElement(o)}function ke(l){let a=l;do{a=a.parentElement;const e=f.window.getComputedStyle(a).overflowY;if(e=="auto"||e=="scroll")break}while(a.tagName!="BODY");return a}class ve extends _{constructor(){super(...arguments);m(this,"_isBlockDragging",!1);m(this,"_domEmitter",new(S()))}static get pluginName(){return"DragDropBlockToolbar"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(this.listenTo(e,"change:isReadOnly",(n,t,i)=>{i?(this.forceDisabled("readOnlyMode"),this._isBlockDragging=!1):this.clearForceDisabled("readOnlyMode")}),b.isAndroid&&this.forceDisabled("noAndroidSupport"),e.plugins.has("BlockToolbar")){const t=e.plugins.get("BlockToolbar").buttonView.element;this._domEmitter.listenTo(t,"dragstart",(i,o)=>this._handleBlockDragStart(o)),this._domEmitter.listenTo(f.document,"dragover",(i,o)=>this._handleBlockDragging(o)),this._domEmitter.listenTo(f.document,"drop",(i,o)=>this._handleBlockDragging(o)),this._domEmitter.listenTo(f.document,"dragend",()=>this._handleBlockDragEnd(),{useCapture:!0}),this.isEnabled&&t.setAttribute("draggable","true"),this.on("change:isEnabled",(i,o,r)=>{t.setAttribute("draggable",r?"true":"false")})}}destroy(){return this._domEmitter.stopListening(),super.destroy()}_handleBlockDragStart(e){if(!this.isEnabled)return;const n=this.editor.model,t=n.document.selection,i=this.editor.editing.view,o=Array.from(t.getSelectedBlocks()),r=n.createRange(n.createPositionBefore(o[0]),n.createPositionAfter(o[o.length-1]));n.change(s=>s.setSelection(r)),this._isBlockDragging=!0,i.focus(),i.getObserver(D).onDomEvent(e)}_handleBlockDragging(e){if(!this.isEnabled||!this._isBlockDragging)return;const n=e.clientX+(this.editor.locale.contentLanguageDirection=="ltr"?100:-100),t=e.clientY,i=document.elementFromPoint(n,t),o=this.editor.editing.view;!i||!i.closest(".ck-editor__editable")||o.getObserver(D).onDomEvent({...e,type:e.type,dataTransfer:e.dataTransfer,target:i,clientX:n,clientY:t,preventDefault:()=>e.preventDefault(),stopPropagation:()=>e.stopPropagation()})}_handleBlockDragEnd(){this._isBlockDragging=!1}}class ye extends _{constructor(){super(...arguments);m(this,"_draggedRange");m(this,"_draggingUid");m(this,"_draggableElement");m(this,"_clearDraggableAttributesDelayed",K(()=>this._clearDraggableAttributes(),40));m(this,"_blockMode",!1);m(this,"_domEmitter",new(S()));m(this,"_previewContainer")}static get pluginName(){return"DragDrop"}static get isOfficialPlugin(){return!0}static get requires(){return[T,ge,C,ve]}init(){const e=this.editor,n=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,n.addObserver(D),n.addObserver(ae),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",(t,i,o)=>{o?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")}),this.on("change:isEnabled",(t,i,o)=>{o||this._finalizeDragging(!1)}),b.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._previewContainer&&this._previewContainer.remove(),this._domEmitter.stopListening(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,n=e.model,t=e.editing.view,i=t.document,o=e.plugins.get(C);this.listenTo(i,"dragstart",(r,s)=>{var v;if((v=s.target)!=null&&v.is("editableElement")){s.preventDefault();return}if(this._prepareDraggedRange(s.target),!this._draggedRange){s.preventDefault();return}this._draggingUid=H(),s.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",s.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const c=n.createSelection(this._draggedRange.toRange());this.editor.plugins.get("ClipboardPipeline")._fireOutputTransformationEvent(s.dataTransfer,c,"dragstart");const{dataTransfer:g,domTarget:p,domEvent:h}=s,{clientX:u}=h;this._updatePreview({dataTransfer:g,domTarget:p,clientX:u}),s.stopPropagation(),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")},{priority:"low"}),this.listenTo(i,"dragend",(r,s)=>{this._finalizeDragging(!s.dataTransfer.isCanceled&&s.dataTransfer.dropEffect=="move")},{priority:"low"}),this._domEmitter.listenTo(f.document,"dragend",()=>{this._blockMode=!1},{useCapture:!0}),this.listenTo(i,"dragenter",()=>{this.isEnabled&&t.focus()}),this.listenTo(i,"dragleave",()=>{o.removeDropMarkerDelayed()}),this.listenTo(i,"dragging",(r,s)=>{if(!this.isEnabled){s.dataTransfer.dropEffect="none";return}const{clientX:c,clientY:d}=s.domEvent;o.updateDropMarker(s.target,s.targetRanges,c,d,this._blockMode,this._draggedRange),this._draggedRange||(s.dataTransfer.dropEffect="copy"),b.isGecko||(s.dataTransfer.effectAllowed=="copy"?s.dataTransfer.dropEffect="copy":["all","copyMove"].includes(s.dataTransfer.effectAllowed)&&(s.dataTransfer.dropEffect="move")),r.stop()},{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get(C);this.listenTo(t,"clipboardInput",(o,r)=>{if(r.method!="drop")return;const{clientX:s,clientY:c}=r.domEvent,d=i.getFinalDropRange(r.target,r.targetRanges,s,c,this._blockMode,this._draggedRange);if(!d){this._finalizeDragging(!1),o.stop();return}if(this._draggedRange&&this._draggingUid!=r.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid=""),q(r.dataTransfer)=="move"&&this._draggedRange&&this._draggedRange.containsRange(d,!0)){this._finalizeDragging(!1),o.stop();return}r.targetRanges=[e.editing.mapper.toViewRange(d)]},{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(T);e.on("contentInsertion",(n,t)=>{if(!this.isEnabled||t.method!=="drop")return;const i=t.targetRanges.map(o=>this.editor.editing.mapper.toModelRange(o));this.editor.model.change(o=>o.setSelection(i))},{priority:"high"}),e.on("contentInsertion",(n,t)=>{if(!this.isEnabled||t.method!=="drop")return;const i=q(t.dataTransfer)=="move",o=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(o&&i)},{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,n=e.editing.view,t=n.document;this.listenTo(t,"mousedown",(i,o)=>{if(b.isAndroid||!o)return;this._clearDraggableAttributesDelayed.cancel();let r=z(o.target);if(b.isBlink&&!e.isReadOnly&&!r&&!t.selection.isCollapsed){const s=t.selection.getSelectedElement();(!s||!y(s))&&(r=t.selection.editableElement)}r&&(n.change(s=>{s.setAttribute("draggable","true",r)}),this._draggableElement=e.editing.mapper.toModelElement(r))}),this.listenTo(t,"mouseup",()=>{b.isAndroid||this._clearDraggableAttributesDelayed()})}_clearDraggableAttributes(){const e=this.editor.editing;e.view.change(n=>{this._draggableElement&&this._draggableElement.root.rootName!="$graveyard"&&n.removeAttribute("draggable",e.mapper.toViewElement(this._draggableElement)),this._draggableElement=null})}_finalizeDragging(e){const n=this.editor,t=n.model;n.plugins.get(C).removeDropMarker(),this._clearDraggableAttributes(),n.plugins.has("WidgetToolbarRepository")&&n.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._previewContainer&&(this._previewContainer.remove(),this._previewContainer=void 0),this._draggedRange&&(e&&this.isEnabled&&t.change(o=>{const r=t.createSelection(this._draggedRange);t.deleteContent(r,{doNotAutoparagraph:!0});const s=r.getFirstPosition().parent;s.isEmpty&&!t.schema.checkChild(s,"$text")&&t.schema.checkChild(s,"paragraph")&&o.insertElement("paragraph",s,0)}),this._draggedRange.detach(),this._draggedRange=null)}_prepareDraggedRange(e){const n=this.editor,t=n.model,i=t.document.selection,o=e?z(e):null;if(o){const d=n.editing.mapper.toModelElement(o);this._draggedRange=w.fromRange(t.createRangeOn(d)),this._blockMode=t.schema.isBlock(d),n.plugins.has("WidgetToolbarRepository")&&n.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop");return}if(i.isCollapsed&&!i.getFirstPosition().parent.isEmpty)return;const r=Array.from(i.getSelectedBlocks()),s=i.getFirstRange();if(r.length==0){this._draggedRange=w.fromRange(s);return}const c=Q(t,r);if(r.length>1)this._draggedRange=w.fromRange(c),this._blockMode=!0;else if(r.length==1){const d=s.start.isTouching(c.start)&&s.end.isTouching(c.end);this._draggedRange=w.fromRange(d?c:s),this._blockMode=d}t.change(d=>d.setSelection(this._draggedRange.toRange()))}_updatePreview({dataTransfer:e,domTarget:n,clientX:t}){const i=this.editor.editing.view,o=i.document.selection.editableElement,r=i.domConverter.mapViewToDom(o),s=f.window.getComputedStyle(r);this._previewContainer?this._previewContainer.firstElementChild&&this._previewContainer.removeChild(this._previewContainer.firstElementChild):(this._previewContainer=B(f.document,"div",{style:"position: fixed; left: -999999px;"}),f.document.body.appendChild(this._previewContainer));const c=new k(r);if(r.contains(n))return;const d=parseFloat(s.paddingLeft),g=B(f.document,"div");g.className="ck ck-content",g.style.width=s.width,g.style.paddingLeft=`${c.left-t+d}px`,b.isiOS&&(g.style.backgroundColor="white"),i.domConverter.setContentOf(g,e.getData("text/html")),e.setDragImage(g,0,0),this._previewContainer.appendChild(g)}}function q(l){return b.isGecko?l.dropEffect:["all","copyMove"].includes(l.effectAllowed)?"move":"copy"}function z(l){if(l.is("editableElement"))return null;if(l.hasClass("ck-widget__selection-handle"))return l.findAncestor(y);if(y(l))return l;const a=l.findAncestor(e=>y(e)||e.is("editableElement"));return y(a)?a:null}function Q(l,a){const e=a[0],n=a[a.length-1],t=e.getCommonAncestor(n),i=l.createPositionBefore(e),o=l.createPositionAfter(n);if(t&&t.is("element")&&!l.schema.isLimit(t)){const r=l.createRangeOn(t),s=i.isTouching(r.start),c=o.isTouching(r.end);if(s&&c)return Q(l,[t])}return l.createRange(i,o)}class De extends _{static get pluginName(){return"PastePlainText"}static get isOfficialPlugin(){return!0}static get requires(){return[T]}init(){const a=this.editor,e=a.model,n=a.editing.view,t=e.document.selection;n.addObserver(D),a.plugins.get(T).on("contentInsertion",(i,o)=>{Te(o.content,e)&&e.change(r=>{const s=Array.from(t.getAttributes()).filter(([d])=>e.schema.getAttributeProperties(d).isFormatting);t.isCollapsed||e.deleteContent(t,{doNotAutoparagraph:!0}),s.push(...t.getAttributes());const c=r.createRangeIn(o.content);for(const d of c.getItems())for(const g of s)e.schema.checkAttribute(d,g[0])&&r.setAttribute(g[0],g[1],d)})})}}function Te(l,a){let e=a.createRangeIn(l);if(l.childCount==1){const n=l.getChild(0);n.is("element")&&a.schema.isBlock(n)&&!a.schema.isObject(n)&&!a.schema.isLimit(n)&&(e=a.createRangeIn(n))}for(const n of e.getItems())if(!a.schema.isInline(n)||Array.from(n.getAttributeKeys()).find(i=>a.schema.getAttributeProperties(i).isFormatting))return!1;return!0}class Oe extends _{static get pluginName(){return"Clipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[Y,T,ye,De]}init(){const a=this.editor,e=this.editor.t;a.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Copy selected content"),keystroke:"CTRL+C"},{label:e("Paste content"),keystroke:"CTRL+V"},{label:e("Paste content as plain text"),keystroke:"CTRL+SHIFT+V"}]})}}export{Oe as Clipboard,Y as ClipboardMarkersUtils,D as ClipboardObserver,T as ClipboardPipeline,ye as DragDrop,ve as DragDropBlockToolbar,C as DragDropTarget,De as PastePlainText,ue as plainTextToHtml,G as viewToPlainText};
|
|
20
|
+
`:""}class G extends b{_markersToCopy=new Map;static get pluginName(){return"ClipboardMarkersUtils"}static get isOfficialPlugin(){return!0}_registerMarkerToCopy(e,t){this._markersToCopy.set(e,t)}_copySelectedFragmentWithMarkers(e,t,r=n=>n.model.getSelectedContent(n.model.document.selection)){return this.editor.model.change(n=>{const s=n.model.document.selection;n.setSelection(t);const o=this._insertFakeMarkersIntoSelection(n,n.model.document.selection,e),i=r(n),l=this._removeFakeMarkersInsideElement(n,i);for(const[c,d]of Object.entries(o)){l[c]||=n.createRangeIn(i);for(const g of d)n.remove(g)}i.markers.clear();for(const[c,d]of Object.entries(l))i.markers.set(c,d);return n.setSelection(s),i})}_pasteMarkersIntoTransformedElement(e,t){const r=this._getPasteMarkersFromRangeMap(e);return this.editor.model.change(n=>{const s=this._insertFakeMarkersElements(n,r),o=t(n),i=this._removeFakeMarkersInsideElement(n,o);for(const l of Object.values(s).flat())n.remove(l);for(const[l,c]of Object.entries(i))n.model.markers.has(l)||n.addMarker(l,{usingOperation:!0,affectsData:!0,range:c});return o})}_pasteFragmentWithMarkers(e){const t=this._getPasteMarkersFromRangeMap(e.markers);e.markers.clear();for(const r of t)e.markers.set(r.name,r.range);return this.editor.model.insertContent(e)}_forceMarkersCopy(e,t,r={allowedActions:"all",copyPartiallySelected:!0,duplicateOnPaste:!0}){const n=this._markersToCopy.get(e);this._markersToCopy.set(e,r),t(),n?this._markersToCopy.set(e,n):this._markersToCopy.delete(e)}_isMarkerCopyable(e,t){const r=this._getMarkerClipboardConfig(e);if(!r)return!1;if(!t)return!0;const{allowedActions:n}=r;return n==="all"||n.includes(t)}_hasMarkerConfiguration(e){return!!this._getMarkerClipboardConfig(e)}_getMarkerClipboardConfig(e){const[t]=e.split(":");return this._markersToCopy.get(t)||null}_insertFakeMarkersIntoSelection(e,t,r){const n=this._getCopyableMarkersFromSelection(e,t,r);return this._insertFakeMarkersElements(e,n)}_getCopyableMarkersFromSelection(e,t,r){const n=Array.from(t.getRanges()),s=new Set(n.flatMap(i=>Array.from(e.model.markers.getMarkersIntersectingRange(i)))),o=i=>{if(!this._isMarkerCopyable(i.name,r))return!1;const{copyPartiallySelected:c}=this._getMarkerClipboardConfig(i.name);if(!c){const d=i.getRange();return n.some(g=>g.containsRange(d,!0))}return!0};return Array.from(s).filter(o).map(i=>({name:r==="dragstart"?this._getUniqueMarkerName(i.name):i.name,range:i.getRange()}))}_getPasteMarkersFromRangeMap(e,t=null){const{model:r}=this.editor;return(e instanceof Map?Array.from(e.entries()):Object.entries(e)).flatMap(([s,o])=>{if(!this._hasMarkerConfiguration(s))return[{name:s,range:o}];if(this._isMarkerCopyable(s,t)){const i=this._getMarkerClipboardConfig(s),l=r.markers.has(s)&&r.markers.get(s).getRange().root.rootName==="$graveyard";return(i.duplicateOnPaste||l)&&(s=this._getUniqueMarkerName(s)),[{name:s,range:o}]}return[]})}_insertFakeMarkersElements(e,t){const r={},n=t.flatMap(s=>{const{start:o,end:i}=s.range;return[{position:o,marker:s,type:"start"},{position:i,marker:s,type:"end"}]}).sort(({position:s},{position:o})=>s.isBefore(o)?1:-1);for(const{position:s,marker:o,type:i}of n){const l=e.createElement("$marker",{"data-name":o.name,"data-type":i});r[o.name]||(r[o.name]=[]),r[o.name].push(l),e.insert(l,s)}return r}_removeFakeMarkersInsideElement(e,t){const n=this._getAllFakeMarkersFromElement(e,t).reduce((s,o)=>{const i=o.markerElement&&e.createPositionBefore(o.markerElement);let l=s[o.name],c=!1;return l?.start&&l?.end&&(this._getMarkerClipboardConfig(o.name).duplicateOnPaste?s[this._getUniqueMarkerName(o.name)]=s[o.name]:c=!0,l=null),c||(s[o.name]={...l,[o.type]:i}),o.markerElement&&e.remove(o.markerElement),s},{});return ce(n,s=>new se(s.start||e.createPositionFromPath(t,[0]),s.end||e.createPositionAt(t,"end")))}_getAllFakeMarkersFromElement(e,t){const r=Array.from(e.createRangeIn(t)).flatMap(({item:o})=>{if(!o.is("element","$marker"))return[];const i=o.getAttribute("data-name"),l=o.getAttribute("data-type");return[{markerElement:o,name:i,type:l}]}),n=[],s=[];for(const o of r)o.type==="end"&&(r.some(l=>l.name===o.name&&l.type==="start")||n.push({markerElement:null,name:o.name,type:"start"})),o.type==="start"&&(r.some(l=>l.name===o.name&&l.type==="end")||s.unshift({markerElement:null,name:o.name,type:"end"}));return[...n,...r,...s]}_getUniqueMarkerName(e){const t=e.split(":"),r=z().substring(1,6);return t.length===3?`${t.slice(0,2).join(":")}:${r}`:`${t.join(":")}:${r}`}}class y extends b{static get pluginName(){return"ClipboardPipeline"}static get isOfficialPlugin(){return!0}static get requires(){return[G]}init(){this.editor.editing.view.addObserver(v),this._setupPasteDrop(),this._setupCopyCut()}_fireOutputTransformationEvent(e,t,r){const n=this.editor.plugins.get("ClipboardMarkersUtils");this.editor.model.enqueueChange({isUndoable:r==="cut"},()=>{const s=n._copySelectedFragmentWithMarkers(r,t);this.fire("outputTransformation",{dataTransfer:e,content:s,method:r})})}_setupPasteDrop(){const e=this.editor,t=e.model,r=e.editing.view,n=r.document,s=this.editor.plugins.get("ClipboardMarkersUtils");this.listenTo(n,"clipboardInput",(o,i)=>{i.method=="paste"&&!e.model.canEditAt(e.model.document.selection)&&o.stop()},{priority:"highest"}),this.listenTo(n,"clipboardInput",(o,i)=>{const l=i.dataTransfer;let c;if(i.content)c=i.content;else{let p="";l.getData("text/html")?p=ge(l.getData("text/html")):l.getData("text/plain")&&(p=de(l.getData("text/plain"))),c=this.editor.data.htmlProcessor.toView(p)}const d=new q(this,"inputTransformation"),g=l.getData("application/ckeditor5-editor-id")||null;this.fire(d,{content:c,dataTransfer:l,sourceEditorId:g,targetRanges:i.targetRanges,method:i.method}),d.stop.called&&o.stop(),r.scrollToTheSelection()},{priority:"low"}),this.listenTo(this,"inputTransformation",(o,i)=>{if(i.content.isEmpty)return;const c=this.editor.data.toModel(i.content,"$clipboardHolder");c.childCount!=0&&(o.stop(),t.change(()=>{this.fire("contentInsertion",{content:c,method:i.method,sourceEditorId:i.sourceEditorId,dataTransfer:i.dataTransfer,targetRanges:i.targetRanges})}))},{priority:"low"}),this.listenTo(this,"contentInsertion",(o,i)=>{i.resultRange=s._pasteFragmentWithMarkers(i.content)},{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,n=e.editing.view.document,s=(o,i)=>{const l=i.dataTransfer;i.preventDefault(),this._fireOutputTransformationEvent(l,t.selection,o.name)};this.listenTo(n,"copy",s,{priority:"low"}),this.listenTo(n,"cut",(o,i)=>{e.model.canEditAt(e.model.document.selection)?s(o,i):i.preventDefault()},{priority:"low"}),this.listenTo(this,"outputTransformation",(o,i)=>{const l=e.data.toView(i.content,{isClipboardPipeline:!0});n.fire("clipboardOutput",{dataTransfer:i.dataTransfer,content:l,method:i.method})},{priority:"low"}),this.listenTo(n,"clipboardOutput",(o,i)=>{i.content.isEmpty||(i.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(i.content)),i.dataTransfer.setData("text/plain",H(e.data.htmlProcessor.domConverter,i.content)),i.dataTransfer.setData("application/ckeditor5-editor-id",this.editor.id)),i.method=="cut"&&e.model.deleteContent(t.selection)},{priority:"low"})}}const P=re("px");class me extends le{constructor(){super();const e=this.bindTemplate;this.set({isVisible:!1,left:null,top:null,width:null}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-clipboard-drop-target-line",e.if("isVisible","ck-hidden",t=>!t)],style:{left:e.to("left",t=>P(t)),top:e.to("top",t=>P(t)),width:e.to("width",t=>P(t))}}})}}class E extends b{removeDropMarkerDelayed=j(()=>this.removeDropMarker(),40);_updateDropMarkerThrottled=V(e=>this._updateDropMarker(e),40);_reconvertMarkerThrottled=V(()=>{this.editor.model.markers.has("drop-target")&&this.editor.editing.reconvertMarker("drop-target")},0);_dropTargetLineView=new me;_domEmitter=new(A());_scrollables=new Map;static get pluginName(){return"DragDropTarget"}static get isOfficialPlugin(){return!0}init(){this._setupDropMarker()}destroy(){this._domEmitter.stopListening();for(const{resizeObserver:e}of this._scrollables.values())e.destroy();return this._updateDropMarkerThrottled.cancel(),this.removeDropMarkerDelayed.cancel(),this._reconvertMarkerThrottled.cancel(),super.destroy()}updateDropMarker(e,t,r,n,s,o){this.removeDropMarkerDelayed.cancel();const i=U(this.editor,e,t,r,n,s,o);/* istanbul ignore next -- @preserve */if(i){if(o&&o.containsRange(i))return this.removeDropMarker();this._updateDropMarkerThrottled(i)}}getFinalDropRange(e,t,r,n,s,o){const i=U(this.editor,e,t,r,n,s,o);return this.removeDropMarker(),i}removeDropMarker(){const e=this.editor.model;this.removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),this._dropTargetLineView.isVisible=!1,e.markers.has("drop-target")&&e.change(t=>{t.removeMarker("drop-target")})}_setupDropMarker(){const e=this.editor;e.ui.view.body.add(this._dropTargetLineView),e.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),e.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(t,{writer:r})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return this._dropTargetLineView.isVisible=!1,this._createDropTargetPosition(r);t.markerRange.isCollapsed?this._updateDropTargetLine(t.markerRange):this._dropTargetLineView.isVisible=!1}})}_updateDropMarker(e){const t=this.editor,r=t.model.markers;t.model.change(n=>{r.has("drop-target")?r.get("drop-target").getRange().isEqual(e)||n.updateMarker("drop-target",{range:e}):n.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})})}_createDropTargetPosition(e){return e.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},function(t){const r=this.toDomElement(t);return r.append("",t.createElement("span"),""),r})}_updateDropTargetLine(e){const t=this.editor.editing,r=e.start.nodeBefore,n=e.start.nodeAfter,s=e.start.parent,o=r?t.mapper.toViewElement(r):null,i=o?t.view.domConverter.mapViewToDom(o):null,l=n?t.mapper.toViewElement(n):null,c=l?t.view.domConverter.mapViewToDom(l):null,d=t.mapper.toViewElement(s);if(!d)return;const g=t.view.domConverter.mapViewToDom(d),p=this._getScrollableRect(d),{scrollX:u,scrollY:h}=m.window,M=i?new _(i):null,S=c?new _(c):null,D=new _(g).excludeScrollbarsAndBorders(),O=M?M.bottom:D.top,C=S?S.top:D.bottom,I=m.window.getComputedStyle(g),R=O<=C?(O+C)/2:C;if(p.top<R&&R<p.bottom){const J=D.left+parseFloat(I.paddingLeft),Q=D.right-parseFloat(I.paddingRight),F=Math.max(J+u,p.left),Z=Math.min(Q+u,p.right);this._dropTargetLineView.set({isVisible:!0,left:F,top:R+h,width:Z-F})}else this._dropTargetLineView.isVisible=!1}_getScrollableRect(e){const t=e.root.rootName;let r;if(this._scrollables.has(t))r=this._scrollables.get(t).domElement;else{const n=this.editor.editing.view.domConverter.mapViewToDom(e);r=he(n),this._domEmitter.listenTo(r,"scroll",this._reconvertMarkerThrottled,{usePassive:!0});const s=new te(r,this._reconvertMarkerThrottled);this._scrollables.set(t,{domElement:r,resizeObserver:s})}return new _(r).excludeScrollbarsAndBorders()}}function U(a,e,t,r,n,s,o){const i=a.model,l=a.editing.mapper;let d=$(a,e);for(;d;){if(!s){if(i.schema.checkChild(d,"$text")){if(t){const g=t[0].start,p=l.toModelPosition(g);if(!o||Array.from(o.getItems({shallow:!0})).every(h=>i.schema.checkChild(p,h))){if(i.schema.checkChild(p,"$text"))return i.createRange(p);if(g)return w(a,$(a,g.parent),r,n)}}}else if(i.schema.isInline(d))return w(a,d,r,n)}if(i.schema.isBlock(d))return w(a,d,r,n);if(i.schema.checkChild(d,"$block")){const g=Array.from(d.getChildren()).filter(h=>h.is("element")&&!ue(a,h));let p=0,u=g.length;if(u==0)return i.createRange(i.createPositionAt(d,"end"));for(;p<u-1;){const h=Math.floor((p+u)/2);X(a,g[h],r,n)=="before"?u=h:p=h}return w(a,g[p],r,n)}d=d.parent}return null}function ue(a,e){const t=a.editing.mapper,r=a.editing.view.domConverter,n=t.toViewElement(e);if(!n)return!0;const s=r.mapViewToDom(n);return m.window.getComputedStyle(s).float!="none"}function w(a,e,t,r){const n=a.model;return n.createRange(n.createPositionAt(e,X(a,e,t,r)))}function X(a,e,t,r){const n=a.editing.mapper,s=a.editing.view.domConverter,o=n.toViewElement(e),i=s.mapViewToDom(o),l=new _(i);return a.model.schema.isInline(e)?t<(l.left+l.right)/2?"before":"after":r<(l.top+l.bottom)/2?"before":"after"}function $(a,e){const t=a.editing.mapper,r=a.editing.view,n=t.toModelElement(e);if(n)return n;const s=r.createPositionBefore(e),o=t.findMappedViewAncestor(s);return t.toModelElement(o)}function he(a){let e=a;do{e=e.parentElement;const t=m.window.getComputedStyle(e).overflowY;if(t=="auto"||t=="scroll")break}while(e.tagName!="BODY");return e}class fe extends b{_isBlockDragging=!1;_domEmitter=new(A());static get pluginName(){return"DragDropBlockToolbar"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(this.listenTo(e,"change:isReadOnly",(t,r,n)=>{n?(this.forceDisabled("readOnlyMode"),this._isBlockDragging=!1):this.clearForceDisabled("readOnlyMode")}),f.isAndroid&&this.forceDisabled("noAndroidSupport"),e.plugins.has("BlockToolbar")){const r=e.plugins.get("BlockToolbar").buttonView.element;this._domEmitter.listenTo(r,"dragstart",(n,s)=>this._handleBlockDragStart(s)),this._domEmitter.listenTo(m.document,"dragover",(n,s)=>this._handleBlockDragging(s)),this._domEmitter.listenTo(m.document,"drop",(n,s)=>this._handleBlockDragging(s)),this._domEmitter.listenTo(m.document,"dragend",()=>this._handleBlockDragEnd(),{useCapture:!0}),this.isEnabled&&r.setAttribute("draggable","true"),this.on("change:isEnabled",(n,s,o)=>{r.setAttribute("draggable",o?"true":"false")})}}destroy(){return this._domEmitter.stopListening(),super.destroy()}_handleBlockDragStart(e){if(!this.isEnabled)return;const t=this.editor.model,r=t.document.selection,n=this.editor.editing.view,s=Array.from(r.getSelectedBlocks()),o=t.createRange(t.createPositionBefore(s[0]),t.createPositionAfter(s[s.length-1]));t.change(i=>i.setSelection(o)),this._isBlockDragging=!0,n.focus(),n.getObserver(v).onDomEvent(e)}_handleBlockDragging(e){if(!this.isEnabled||!this._isBlockDragging)return;const t=e.clientX+(this.editor.locale.contentLanguageDirection=="ltr"?100:-100),r=e.clientY,n=document.elementFromPoint(t,r),s=this.editor.editing.view;!n||!n.closest(".ck-editor__editable")||s.getObserver(v).onDomEvent({...e,type:e.type,dataTransfer:e.dataTransfer,target:n,clientX:t,clientY:r,preventDefault:()=>e.preventDefault(),stopPropagation:()=>e.stopPropagation()})}_handleBlockDragEnd(){this._isBlockDragging=!1}}class be extends b{_draggedRange;_draggingUid;_draggableElement;_clearDraggableAttributesDelayed=j(()=>this._clearDraggableAttributes(),40);_blockMode=!1;_domEmitter=new(A());_previewContainer;static get pluginName(){return"DragDrop"}static get isOfficialPlugin(){return!0}static get requires(){return[y,ae,E,fe]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,t.addObserver(v),t.addObserver(ne),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",(r,n,s)=>{s?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")}),this.on("change:isEnabled",(r,n,s)=>{s||this._finalizeDragging(!1)}),f.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._previewContainer&&this._previewContainer.remove(),this._domEmitter.stopListening(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,t=e.model,r=e.editing.view,n=r.document,s=e.plugins.get(E);this.listenTo(n,"dragstart",(o,i)=>{if(i.target?.is("editableElement")){i.preventDefault();return}if(this._prepareDraggedRange(i.target),!this._draggedRange){i.preventDefault();return}this._draggingUid=z(),i.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",i.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const l=t.createSelection(this._draggedRange.toRange());this.editor.plugins.get("ClipboardPipeline")._fireOutputTransformationEvent(i.dataTransfer,l,"dragstart");const{dataTransfer:d,domTarget:g,domEvent:p}=i,{clientX:u}=p;this._updatePreview({dataTransfer:d,domTarget:g,clientX:u}),i.stopPropagation(),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")},{priority:"low"}),this.listenTo(n,"dragend",(o,i)=>{this._finalizeDragging(!i.dataTransfer.isCanceled&&i.dataTransfer.dropEffect=="move")},{priority:"low"}),this._domEmitter.listenTo(m.document,"dragend",()=>{this._blockMode=!1},{useCapture:!0}),this.listenTo(n,"dragenter",()=>{this.isEnabled&&r.focus()}),this.listenTo(n,"dragleave",()=>{s.removeDropMarkerDelayed()}),this.listenTo(n,"dragging",(o,i)=>{if(!this.isEnabled){i.dataTransfer.dropEffect="none";return}const{clientX:l,clientY:c}=i.domEvent;s.updateDropMarker(i.target,i.targetRanges,l,c,this._blockMode,this._draggedRange),this._draggedRange||(i.dataTransfer.dropEffect="copy"),f.isGecko||(i.dataTransfer.effectAllowed=="copy"?i.dataTransfer.dropEffect="copy":["all","copyMove"].includes(i.dataTransfer.effectAllowed)&&(i.dataTransfer.dropEffect="move")),o.stop()},{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,r=e.editing.view.document,n=e.plugins.get(E);this.listenTo(r,"clipboardInput",(s,o)=>{if(o.method!="drop")return;const{clientX:i,clientY:l}=o.domEvent,c=n.getFinalDropRange(o.target,o.targetRanges,i,l,this._blockMode,this._draggedRange);if(!c){this._finalizeDragging(!1),s.stop();return}if(this._draggedRange&&this._draggingUid!=o.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid=""),N(o.dataTransfer)=="move"&&this._draggedRange&&this._draggedRange.containsRange(c,!0)){this._finalizeDragging(!1),s.stop();return}o.targetRanges=[e.editing.mapper.toViewRange(c)]},{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(y);e.on("contentInsertion",(t,r)=>{if(!this.isEnabled||r.method!=="drop")return;const n=r.targetRanges.map(s=>this.editor.editing.mapper.toModelRange(s));this.editor.model.change(s=>s.setSelection(n))},{priority:"high"}),e.on("contentInsertion",(t,r)=>{if(!this.isEnabled||r.method!=="drop")return;const n=N(r.dataTransfer)=="move",s=!r.resultRange||!r.resultRange.isCollapsed;this._finalizeDragging(s&&n)},{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,r=t.document;this.listenTo(r,"mousedown",(n,s)=>{if(f.isAndroid||!s)return;this._clearDraggableAttributesDelayed.cancel();let o=W(s.target);if(f.isBlink&&!e.isReadOnly&&!o&&!r.selection.isCollapsed){const i=r.selection.getSelectedElement();(!i||!k(i))&&(o=r.selection.editableElement)}o&&(t.change(i=>{i.setAttribute("draggable","true",o)}),this._draggableElement=e.editing.mapper.toModelElement(o))}),this.listenTo(r,"mouseup",()=>{f.isAndroid||this._clearDraggableAttributesDelayed()})}_clearDraggableAttributes(){const e=this.editor.editing;e.view.change(t=>{this._draggableElement&&this._draggableElement.root.rootName!="$graveyard"&&t.removeAttribute("draggable",e.mapper.toViewElement(this._draggableElement)),this._draggableElement=null})}_finalizeDragging(e){const t=this.editor,r=t.model;t.plugins.get(E).removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._previewContainer&&(this._previewContainer.remove(),this._previewContainer=void 0),this._draggedRange&&(e&&this.isEnabled&&r.change(s=>{const o=r.createSelection(this._draggedRange);r.deleteContent(o,{doNotAutoparagraph:!0});const i=o.getFirstPosition().parent;i.isEmpty&&!r.schema.checkChild(i,"$text")&&r.schema.checkChild(i,"paragraph")&&s.insertElement("paragraph",i,0)}),this._draggedRange.detach(),this._draggedRange=null)}_prepareDraggedRange(e){const t=this.editor,r=t.model,n=r.document.selection,s=e?W(e):null;if(s){const c=t.editing.mapper.toModelElement(s);this._draggedRange=T.fromRange(r.createRangeOn(c)),this._blockMode=r.schema.isBlock(c),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop");return}if(n.isCollapsed&&!n.getFirstPosition().parent.isEmpty)return;const o=Array.from(n.getSelectedBlocks()),i=n.getFirstRange();if(o.length==0){this._draggedRange=T.fromRange(i);return}const l=Y(r,o);if(o.length>1)this._draggedRange=T.fromRange(l),this._blockMode=!0;else if(o.length==1){const c=i.start.isTouching(l.start)&&i.end.isTouching(l.end);this._draggedRange=T.fromRange(c?l:i),this._blockMode=c}r.change(c=>c.setSelection(this._draggedRange.toRange()))}_updatePreview({dataTransfer:e,domTarget:t,clientX:r}){const n=this.editor.editing.view,s=n.document.selection.editableElement,o=n.domConverter.mapViewToDom(s),i=m.window.getComputedStyle(o);this._previewContainer?this._previewContainer.firstElementChild&&this._previewContainer.removeChild(this._previewContainer.firstElementChild):(this._previewContainer=x(m.document,"div",{style:"position: fixed; left: -999999px;"}),m.document.body.appendChild(this._previewContainer));const l=new _(o);if(o.contains(t))return;const c=parseFloat(i.paddingLeft),d=x(m.document,"div");d.className="ck ck-content",d.style.width=i.width,d.style.paddingLeft=`${l.left-r+c}px`,f.isiOS&&(d.style.backgroundColor="white"),n.domConverter.setContentOf(d,e.getData("text/html")),e.setDragImage(d,0,0),this._previewContainer.appendChild(d)}}function N(a){return f.isGecko?a.dropEffect:["all","copyMove"].includes(a.effectAllowed)?"move":"copy"}function W(a){if(a.is("editableElement"))return null;if(a.hasClass("ck-widget__selection-handle"))return a.findAncestor(k);if(k(a))return a;const e=a.findAncestor(t=>k(t)||t.is("editableElement"));return k(e)?e:null}function Y(a,e){const t=e[0],r=e[e.length-1],n=t.getCommonAncestor(r),s=a.createPositionBefore(t),o=a.createPositionAfter(r);if(n&&n.is("element")&&!a.schema.isLimit(n)){const i=a.createRangeOn(n),l=s.isTouching(i.start),c=o.isTouching(i.end);if(l&&c)return Y(a,[n])}return a.createRange(s,o)}class _e extends b{static get pluginName(){return"PastePlainText"}static get isOfficialPlugin(){return!0}static get requires(){return[y]}init(){const e=this.editor,t=e.model,r=e.editing.view,n=t.document.selection;r.addObserver(v),e.plugins.get(y).on("contentInsertion",(s,o)=>{ke(o.content,t)&&t.change(i=>{const l=Array.from(n.getAttributes()).filter(([d])=>t.schema.getAttributeProperties(d).isFormatting);n.isCollapsed||t.deleteContent(n,{doNotAutoparagraph:!0}),l.push(...n.getAttributes());const c=i.createRangeIn(o.content);for(const d of c.getItems())for(const g of l)t.schema.checkAttribute(d,g[0])&&i.setAttribute(g[0],g[1],d)})})}}function ke(a,e){let t=e.createRangeIn(a);if(a.childCount==1){const r=a.getChild(0);r.is("element")&&e.schema.isBlock(r)&&!e.schema.isObject(r)&&!e.schema.isLimit(r)&&(t=e.createRangeIn(r))}for(const r of t.getItems())if(!e.schema.isInline(r)||Array.from(r.getAttributeKeys()).find(s=>e.schema.getAttributeProperties(s).isFormatting))return!1;return!0}class Ce extends b{static get pluginName(){return"Clipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[G,y,be,_e]}init(){const e=this.editor,t=this.editor.t;e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Copy selected content"),keystroke:"CTRL+C"},{label:t("Paste content"),keystroke:"CTRL+V"},{label:t("Paste content as plain text"),keystroke:"CTRL+SHIFT+V"}]})}}export{Ce as Clipboard,G as ClipboardMarkersUtils,v as ClipboardObserver,y as ClipboardPipeline,be as DragDrop,fe as DragDropBlockToolbar,E as DragDropTarget,_e as PastePlainText,de as plainTextToHtml,H as viewToPlainText};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{ContextPlugin as f}from"../../../../../@ckeditor_ckeditor5-core@45.2.1/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{CKEditorError as i,ObservableMixin as p,logWarning as _,EmitterMixin as g}from"../../../../../@ckeditor_ckeditor5-utils@45.2.1/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";/**
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/const
|
|
4
|
+
*/const T={autoRefresh:!0},d=36e5,k=5e3;class l extends p(){_refresh;_options;_tokenRefreshTimeout;_isDestroyed=!1;constructor(e,t={}){if(super(),!e)throw new i("token-missing-token-url",this);t.initValue&&this._validateTokenValue(t.initValue),this.set("value",t.initValue),typeof e=="function"?this._refresh=e:this._refresh=()=>w(e),this._options={...T,...t}}init(){return new Promise((e,t)=>{if(!this.value){this.refreshToken().then(e).catch(t);return}this._options.autoRefresh&&this._registerRefreshTokenTimeout(),e(this)})}refreshToken(){const e=this._options.autoRefresh;return this._refresh().then(t=>(this._validateTokenValue(t),this.set("value",t),e&&this._registerRefreshTokenTimeout(),this)).catch(t=>{throw _("token-refresh-failed",{autoRefresh:e}),e&&this._registerRefreshTokenTimeout(k),t})}destroy(){this._isDestroyed=!0,clearTimeout(this._tokenRefreshTimeout)}_validateTokenValue(e){const t=typeof e=="string",r=!/^".*"$/.test(e),s=t&&e.split(".").length===3;if(!(r&&s))throw new i("token-not-in-jwt-format",this)}_registerRefreshTokenTimeout(e){if(clearTimeout(this._tokenRefreshTimeout),this._isDestroyed)return;const t=e||this._getTokenRefreshTimeoutTime();this._tokenRefreshTimeout=setTimeout(()=>{this.refreshToken()},t)}_getTokenRefreshTimeoutTime(){try{const[,e]=this.value.split("."),{exp:t}=JSON.parse(atob(e));return t?Math.floor((t*1e3-Date.now())/2):d}catch{return d}}static create(e,t={}){return new l(e,t).init()}}function w(n){return new Promise((e,t)=>{const r=new XMLHttpRequest;r.open("GET",n),r.addEventListener("load",()=>{const s=r.status,o=r.response;return s<200||s>299?t(new i("token-cannot-download-new-token",null)):e(o)}),r.addEventListener("error",()=>t(new Error("Network Error"))),r.addEventListener("abort",()=>t(new Error("Abort"))),r.send()})}const h=/^data:(\S*?);base64,/;class m extends g(){file;xhr;_token;_apiAddress;constructor(e,t,r){if(super(),!e)throw new i("fileuploader-missing-file",null);if(!t)throw new i("fileuploader-missing-token",null);if(!r)throw new i("fileuploader-missing-api-address",null);this.file=R(e)?E(e):e,this._token=t,this._apiAddress=r}onProgress(e){return this.on("progress",(t,r)=>e(r)),this}onError(e){return this.once("error",(t,r)=>e(r)),this}abort(){this.xhr.abort()}send(){return this._prepareRequest(),this._attachXHRListeners(),this._sendRequest()}_prepareRequest(){const e=new XMLHttpRequest;e.open("POST",this._apiAddress),e.setRequestHeader("Authorization",this._token.value),e.responseType="json",this.xhr=e}_attachXHRListeners(){const e=this.xhr,t=r=>()=>this.fire("error",r);e.addEventListener("error",t("Network Error")),e.addEventListener("abort",t("Abort"));/* istanbul ignore else -- @preserve */e.upload&&e.upload.addEventListener("progress",r=>{r.lengthComputable&&this.fire("progress",{total:r.total,uploaded:r.loaded})}),e.addEventListener("load",()=>{const r=e.status,s=e.response;if(r<200||r>299)return this.fire("error",s.message||s.error)})}_sendRequest(){const e=new FormData,t=this.xhr;return e.append("file",this.file),new Promise((r,s)=>{t.addEventListener("load",()=>{const o=t.status,a=t.response;return o<200||o>299?a.message?s(new i("fileuploader-uploading-data-failed",this,{message:a.message})):s(a.error):r(a)}),t.addEventListener("error",()=>s(new Error("Network Error"))),t.addEventListener("abort",()=>s(new Error("Abort"))),t.send(e)})}}function E(n,e=512){try{const t=n.match(h)[1],r=atob(n.replace(h,"")),s=[];for(let o=0;o<r.length;o+=e){const a=r.slice(o,o+e),c=new Array(a.length);for(let u=0;u<a.length;u++)c[u]=a.charCodeAt(u);s.push(new Uint8Array(c))}return new Blob(s,{type:t})}catch{throw new i("fileuploader-decoding-image-data-error",null)}}function R(n){return typeof n!="string"?!1:!!n.match(h)?.length}class v{_token;_apiAddress;constructor(e,t){if(!e)throw new i("uploadgateway-missing-token",null);if(!t)throw new i("uploadgateway-missing-api-address",null);this._token=e,this._apiAddress=t}upload(e){return new m(e,this._token,this._apiAddress)}}class y extends f{static get pluginName(){return"CloudServicesCore"}static get isOfficialPlugin(){return!0}createToken(e,t){return new l(e,t)}createUploadGateway(e,t){return new v(e,t)}}class C extends f{tokenUrl;uploadUrl;webSocketUrl;bundleVersion;token=null;_tokens=new Map;static get pluginName(){return"CloudServices"}static get isOfficialPlugin(){return!0}static get requires(){return[y]}async init(){const t=this.context.config.get("cloudServices")||{};for(const[o,a]of Object.entries(t))this[o]=a;if(!this.tokenUrl){this.token=null;return}const s=this.context.plugins.get("CloudServicesCore").createToken(this.tokenUrl);try{this.token=await s.init(),this._tokens.set(this.tokenUrl,this.token)}catch(o){throw s.destroy(),o}}async registerTokenUrl(e){if(this._tokens.has(e))return this.getTokenFor(e);const r=await this.context.plugins.get("CloudServicesCore").createToken(e).init();return this._tokens.set(e,r),r}getTokenFor(e){const t=this._tokens.get(e);if(!t)throw new i("cloudservices-token-not-registered",this);return t}destroy(){super.destroy();for(const e of this._tokens.values())e.destroy()}}export{C as CloudServices,y as CloudServicesCore,l as Token};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import{Plugin as C,Command as S}from"../../../../../@ckeditor_ckeditor5-core@45.2.1/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{ShiftEnter as y}from"../../../../../@ckeditor_ckeditor5-enter@45.2.1/node_modules/@ckeditor/ckeditor5-enter/dist/index.js";import{UpcastWriter as O}from"../../../../../@ckeditor_ckeditor5-engine@45.2.1/node_modules/@ckeditor/ckeditor5-engine/dist/index.js";import{ClipboardPipeline as R}from"../../../../../@ckeditor_ckeditor5-clipboard@45.2.1/node_modules/@ckeditor/ckeditor5-clipboard/dist/index.js";import{Collection as M,first as B}from"../../../../../@ckeditor_ckeditor5-utils@45.2.1/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{createDropdown as N,addListToDropdown as q,MenuBarMenuView as F,MenuBarMenuListView as $,MenuBarMenuListItemView as z,MenuBarMenuListItemButtonView as W,ViewModel as j,SplitButtonView as U}from"../../../../../@ckeditor_ckeditor5-ui@45.2.1/node_modules/@ckeditor/ckeditor5-ui/dist/index.js";import{IconCodeBlock as w}from"../../../../../@ckeditor_ckeditor5-icons@45.2.1/node_modules/@ckeditor/ckeditor5-icons/dist/index.js";/**
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/function
|
|
5
|
-
`),
|
|
6
|
-
`))}}function
|
|
7
|
-
`).map(
|
|
4
|
+
*/function h(i){const e=i.t,n=i.config.get("codeBlock.languages");for(const o of n)o.label==="Plain text"&&(o.label=e("Plain text")),o.class===void 0&&(o.class=`language-${o.language}`);return n}function k(i,e,n){const o={};for(const c of i)if(e==="class"){const s=c[e].split(" ").shift();o[s]=c[n]}else o[c[e]]=c[n];return o}function x(i){return i.data.match(/^(\s*)/)[0]}function H(i,e){const n=i.createDocumentFragment(),o=e.split(`
|
|
5
|
+
`),c=o.reduce((s,t,r)=>(s.push(t),r<o.length-1&&s.push(i.createElement("br")),s),[]);return i.appendChild(c,n),n}function v(i){const e=i.document.selection,n=[];if(e.isCollapsed)return[e.anchor];const o=e.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:c}of o){let s=c.is("$textProxy")?c.textNode:c;const t=s.parent;if(!t.is("element","codeBlock")||s.is("element","softBreak"))continue;for(;s.previousSibling&&!s.previousSibling.is("element","softBreak");)s=s.previousSibling;const r=s.is("$text")?s.startOffset+x(s).length:s.startOffset,a=i.createPositionAt(t,r);n.every(l=>!l.isEqual(a))&&n.push(a)}return n}function _(i){const e=B(i.getSelectedBlocks());return!!e&&e.is("element","codeBlock")}function A(i,e){return e.is("rootElement")||i.isLimit(e)?!1:i.checkChild(e.parent,"codeBlock")}function P(i,e,n,o){const c=k(e,"language","label"),s=n.getAttribute("language");if(s in c){const t=c[s];return i(o==="enter"?"Entering %0 code snippet":"Leaving %0 code snippet",t)}return i(o==="enter"?"Entering code snippet":"Leaving code snippet")}function D(i,e){for(i.textNode&&(i=e.createPositionBefore(i.textNode));i.nodeBefore&&!i.nodeBefore.is("element","softBreak");)i=e.createPositionBefore(i.nodeBefore);const n=i.nodeAfter;return n&&n.is("$text")?n:null}class J extends S{_lastLanguage;constructor(e){super(e),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const n=this.editor,o=n.model,c=o.document.selection,t=h(n)[0],r=Array.from(c.getSelectedBlocks()),a=e.forceValue==null?!this.value:e.forceValue,l=K(e,this._lastLanguage,t.language);o.change(u=>{a?this._applyCodeBlock(u,r,l):this._removeCodeBlock(u,r)})}_getValue(){const e=this.editor.model.document.selection,n=B(e.getSelectedBlocks());return!!n?.is("element","codeBlock")?n.getAttribute("language"):!1}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,n=this.editor.model.schema,o=B(e.getSelectedBlocks());return o?A(n,o):!1}_applyCodeBlock(e,n,o){this._lastLanguage=o;const c=this.editor.model.schema,s=n.filter(t=>A(c,t));for(const t of s)e.rename(t,"codeBlock"),e.setAttribute("language",o,t),c.removeDisallowedAttributes([t],e),Array.from(t.getChildren()).filter(r=>!c.checkChild(t,r)).forEach(r=>e.remove(r));s.reverse().forEach((t,r)=>{const a=s[r+1];t.previousSibling===a&&(e.appendElement("softBreak",a),e.merge(e.createPositionBefore(t)))})}_removeCodeBlock(e,n){const o=n.filter(c=>c.is("element","codeBlock"));for(const c of o){const s=e.createRangeOn(c);for(const t of Array.from(s.getItems()).reverse())if(t.is("element","softBreak")&&t.parent.is("element","codeBlock")){const{position:r}=e.split(e.createPositionBefore(t)),a=r.nodeAfter;e.rename(a,"paragraph"),e.removeAttribute("language",a),e.remove(t)}e.rename(c,"paragraph"),e.removeAttribute("language",c)}}}function K(i,e,n){return i.language?i.language:i.usePreviousLanguageChoice&&e?e:n}class G extends S{_indentSequence;constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const n=this.editor.model;n.change(o=>{const c=v(n);for(const s of c){const t=o.createText(this._indentSequence);n.insertContent(t,s)}})}_checkEnabled(){return this._indentSequence?_(this.editor.model.document.selection):!1}}class X extends S{_indentSequence;constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const n=this.editor.model;n.change(()=>{const o=v(n);for(const c of o){const s=E(n,c,this._indentSequence);s&&n.deleteContent(n.createSelection(s))}})}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return _(e.document.selection)?v(e).some(n=>E(e,n,this._indentSequence)):!1}}function E(i,e,n){const o=D(e,i);if(!o)return null;const c=x(o),s=c.lastIndexOf(n);if(s+n.length!==c.length||s===-1)return null;const{parent:t,startOffset:r}=o;return i.createRange(i.createPositionAt(t,r+s),i.createPositionAt(t,r+s+n.length))}function T(i,e,n=!1){const o=k(e,"language","class"),c=k(e,"language","label");return(s,t,r)=>{const{writer:a,mapper:l,consumable:u}=r;if(!u.consume(t.item,"insert"))return;const d=t.item.getAttribute("language"),g=l.toViewPosition(i.createPositionBefore(t.item)),m={};n&&(m["data-language"]=c[d],m.spellcheck="false");const p=o[d]?{class:o[d]}:void 0,L=a.createContainerElement("code",p),V=a.createContainerElement("pre",m,L);a.insert(g,V),l.bindElements(t.item,L)}}function Q(i){return(e,n,o)=>{if(n.item.parent.name!=="codeBlock")return;const{writer:c,mapper:s,consumable:t}=o;if(!t.consume(n.item,"insert"))return;const r=s.toViewPosition(i.createPositionBefore(n.item));c.insert(r,c.createText(`
|
|
6
|
+
`))}}function Y(i,e){const n=k(e,"class","language"),o=e[0].language;return(c,s,t)=>{const r=s.viewItem,a=r.parent;if(!a||!a.is("element","pre")||s.modelCursor.findAncestor("codeBlock"))return;const{consumable:l,writer:u}=t;if(!l.test(r,{name:!0}))return;const d=u.createElement("codeBlock"),g=[...r.getClassNames()];g.length||g.push("");for(const m of g){const p=n[m];if(p){u.setAttribute("language",p,d);break}}d.hasAttribute("language")||u.setAttribute("language",o,d),t.convertChildren(r,d),t.safeInsert(d,s.modelCursor)&&(l.consume(r,{name:!0}),t.updateConversionResult(d,s))}}function Z(){return(i,e,{consumable:n,writer:o})=>{let c=e.modelCursor;if(!n.test(e.viewItem)||!c.findAncestor("codeBlock"))return;n.consume(e.viewItem);const t=e.viewItem.data.split(`
|
|
7
|
+
`).map(a=>o.createText(a)),r=t[t.length-1];for(const a of t)if(o.insert(a,c),c=c.getShiftedBy(a.offsetSize),a!==r){const l=o.createElement("softBreak");o.insert(l,c),c=o.createPositionAfter(l)}e.modelRange=o.createRange(e.modelCursor,c),e.modelCursor=c}}function ee(){return(i,e,{consumable:n})=>{const o=e.viewItem;if(o.findAncestor("pre"))return;const c=Array.from(o.getChildren()),s=c.find(t=>t.is("element","code"));if(s)for(const t of c)t===s||!t.is("$text")||n.consume(t,{name:!0})}}const I="paragraph";class te extends C{static get pluginName(){return"CodeBlockEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[y]}constructor(e){super(e),e.config.define("codeBlock",{languages:[{language:"plaintext",label:"Plain text"},{language:"c",label:"C"},{language:"cs",label:"C#"},{language:"cpp",label:"C++"},{language:"css",label:"CSS"},{language:"diff",label:"Diff"},{language:"go",label:"Go"},{language:"html",label:"HTML"},{language:"java",label:"Java"},{language:"javascript",label:"JavaScript"},{language:"php",label:"PHP"},{language:"python",label:"Python"},{language:"ruby",label:"Ruby"},{language:"typescript",label:"TypeScript"},{language:"xml",label:"XML"}],indentSequence:" "})}init(){const e=this.editor,n=e.model.schema,o=e.model,c=e.editing.view,s=h(e);e.commands.add("codeBlock",new J(e)),e.commands.add("indentCodeBlock",new G(e)),e.commands.add("outdentCodeBlock",new X(e)),this.listenTo(c.document,"tab",(t,r)=>{const a=r.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(a).isEnabled&&(e.execute(a),r.stopPropagation(),r.preventDefault(),t.stop())},{context:"pre"}),n.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",disallowChildren:"$inlineObject",allowAttributes:["language"],allowAttributesOf:"$listItem",isBlock:!0}),n.addAttributeCheck((t,r)=>{const a=t.getItem(t.length-2);if(n.getAttributeProperties(r).isFormatting&&a&&a.name=="codeBlock")return!1}),e.editing.downcastDispatcher.on("insert:codeBlock",T(o,s,!0)),e.data.downcastDispatcher.on("insert:codeBlock",T(o,s)),e.data.downcastDispatcher.on("insert:softBreak",Q(o),{priority:"high"}),e.data.upcastDispatcher.on("element:code",Y(c,s)),e.data.upcastDispatcher.on("text",Z()),e.data.upcastDispatcher.on("element:pre",ee(),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",(t,r)=>{let a=o.createRange(o.document.selection.anchor);if(r.targetRanges&&(a=e.editing.mapper.toModelRange(r.targetRanges[0])),!a.start.parent.is("element","codeBlock"))return;const l=r.dataTransfer.getData("text/plain"),u=new O(e.editing.view.document);r.content=H(u,l)}),e.plugins.has("ClipboardPipeline")&&e.plugins.get(R).on("contentInsertion",(t,r)=>{const a=e.model,l=a.document.selection;l.anchor.parent.is("element","codeBlock")&&a.change(u=>{const d=u.createRangeIn(r.content);for(const g of[...d.getItems()])g.is("node")&&!n.checkChild(l.anchor,g)&&u.remove(g)})}),this.listenTo(o,"getSelectedContent",(t,[r])=>{const a=r.anchor;r.isCollapsed||!a.parent.is("element","codeBlock")||!a.hasSameParentAs(r.focus)||o.change(l=>{const u=t.return;if(a.parent.is("element")&&(u.childCount>1||r.containsEntireContent(a.parent))){const g=l.createElement("codeBlock",a.parent.getAttributes());l.append(u,g);const m=l.createDocumentFragment();l.append(g,m),t.return=m;return}const d=u.getChild(0);n.checkAttribute(d,"code")&&l.setAttribute("code",!0,d)})})}afterInit(){const e=this.editor,n=e.commands,o=n.get("indent"),c=n.get("outdent");o&&o.registerChildCommand(n.get("indentCodeBlock"),{priority:"highest"}),c&&c.registerChildCommand(n.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",(s,t)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(!oe(e,t.isSoft)&&!ie(e,t.isSoft)&&ne(e),t.preventDefault(),s.stop())},{context:"pre"}),this._initAriaAnnouncements()}_initAriaAnnouncements(){const{model:e,ui:n,t:o}=this.editor,c=h(this.editor);let s=null;e.document.selection.on("change:range",()=>{const t=e.document.selection.focus.parent;!n||s===t||!t.is("element")||(s&&s.is("element","codeBlock")&&n.ariaLiveAnnouncer.announce(P(o,c,s,"leave")),t.is("element","codeBlock")&&n.ariaLiveAnnouncer.announce(P(o,c,t,"enter")),s=t)})}}function ne(i){const e=i.model,n=e.document,o=n.selection.getLastPosition();let c;const s=D(o,e);s&&s.is("$text")&&(c=x(s)),i.model.change(t=>{i.execute("shiftEnter"),c&&t.insertText(c,n.selection.anchor)})}function oe(i,e){const o=i.model.document,c=i.editing.view,s=o.selection.getLastPosition(),t=s.nodeAfter;return e||!o.selection.isCollapsed||!s.isAtStart||!f(t)?!1:(i.model.change(r=>{i.execute("enter");const a=o.selection.anchor.parent.previousSibling;r.rename(a,I),r.setSelection(a,"in"),i.model.schema.removeDisallowedAttributes([a],r),r.remove(t)}),c.scrollToTheSelection(),!0)}function ie(i,e){const n=i.model,o=n.document,c=i.editing.view,s=o.selection.getLastPosition(),t=s.nodeBefore;let r;if(e||!o.selection.isCollapsed||!s.isAtEnd||!t||!t.previousSibling)return!1;if(f(t)&&f(t.previousSibling))r=n.createRange(n.createPositionBefore(t.previousSibling),n.createPositionAfter(t));else if(b(t)&&f(t.previousSibling)&&f(t.previousSibling.previousSibling))r=n.createRange(n.createPositionBefore(t.previousSibling.previousSibling),n.createPositionAfter(t));else if(b(t)&&f(t.previousSibling)&&b(t.previousSibling.previousSibling)&&t.previousSibling.previousSibling&&f(t.previousSibling.previousSibling.previousSibling))r=n.createRange(n.createPositionBefore(t.previousSibling.previousSibling.previousSibling),n.createPositionAfter(t));else return!1;return i.model.change(a=>{a.remove(r),i.execute("enter");const l=o.selection.anchor.parent;a.rename(l,I),i.model.schema.removeDisallowedAttributes([l],a)}),c.scrollToTheSelection(),!0}function b(i){return i&&i.is("$text")&&!i.data.match(/\S/)}function f(i){return i&&i.is("element","softBreak")}class se extends C{static get pluginName(){return"CodeBlockUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,n=e.t,o=e.ui.componentFactory,c=h(e),s=this._getLanguageListItemDefinitions(c),t=e.commands.get("codeBlock");o.add("codeBlock",r=>{const a=N(r,U),l=a.buttonView,u=n("Insert code block");return l.set({label:u,tooltip:!0,icon:w,isToggleable:!0}),l.bind("isOn").to(t,"value",d=>!!d),l.on("execute",()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()}),a.on("execute",d=>{e.execute("codeBlock",{language:d.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()}),a.class="ck-code-block-dropdown",a.bind("isEnabled").to(t),q(a,s,{role:"menu",ariaLabel:u}),a}),o.add("menuBar:codeBlock",r=>{const a=new F(r);a.buttonView.set({role:"menuitem",label:n("Code block"),icon:w}),a.bind("isEnabled").to(t);const l=new $(r);l.set({ariaLabel:n("Insert code block")});for(const u of s){const d=new z(r,a),g=new W(r);g.bind(...Object.keys(u.model)).to(u.model),g.set({isToggleable:!0,role:"menuitemcheckbox"}),g.delegate("execute").to(a),g.on("execute",()=>{e.execute("codeBlock",{language:u.model._codeBlockLanguage,forceValue:t.value!=u.model._codeBlockLanguage}),e.editing.view.focus()}),d.children.add(g),l.items.add(d)}return a.panelView.children.add(l),a})}_getLanguageListItemDefinitions(e){const o=this.editor.commands.get("codeBlock"),c=new M;for(const s of e){const t={type:"button",model:new j({_codeBlockLanguage:s.language,label:s.label,role:"menuitemradio",withText:!0})};t.model.bind("isOn").to(o,"value",r=>r===t.model._codeBlockLanguage),c.add(t)}return c}}class me extends C{static get requires(){return[te,se]}static get pluginName(){return"CodeBlock"}static get isOfficialPlugin(){return!0}}export{me as CodeBlock,te as CodeBlockEditing,se as CodeBlockUI};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{ObservableMixin as P,Collection as W,CKEditorError as l,insertToPriorityArray as V,setDataInElement as q,Config as j,parseBase64EncodedObject as Y,toArray as J,crc32 as Q,releaseDate as X,uid as A,logError as Z,Locale as ee,EmitterMixin as te,KeystrokeHandler as ie,global as T,env as _}from"../../../../../@ckeditor_ckeditor5-utils@45.2.1/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{Model as ne,DataController as se,StylesProcessor as oe,EditingController as re,Conversion as ae}from"../../../../../@ckeditor_ckeditor5-engine@45.2.1/node_modules/@ckeditor/ckeditor5-engine/dist/index.js";import{EditorWatchdog as le,ContextWatchdog as ce}from"../../../../../@ckeditor_ckeditor5-watchdog@45.2.1/node_modules/@ckeditor/ckeditor5-watchdog/dist/index.js";import{isFunction as M}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/predicate/isFunction.js";import{get as ue}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/get.js";import{set as de}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/set.js";/**
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/class Me extends v(){constructor(e){super();c(this,"editor");c(this,"_disableStack",new Set);this.editor=e,this.set("isEnabled",!0)}forceDisabled(e){this._disableStack.add(e),this._disableStack.size==1&&(this.on("set:isEnabled",B,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),this._disableStack.size==0&&(this.off("set:isEnabled",B),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}}function B(n){n.return=!1,n.stop()}class pe extends v(){constructor(e){super();c(this,"editor");c(this,"_isEnabledBasedOnSelection");c(this,"_affectsData");c(this,"_disableStack");this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this._affectsData=!0,this._isEnabledBasedOnSelection=!0,this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",()=>{this.refresh()}),this.listenTo(e,"change:isReadOnly",()=>{this.refresh()}),this.on("set:isEnabled",t=>{if(!this.affectsData)return;const o=e.model.document.selection,h=!(o.getFirstPosition().root.rootName=="$graveyard")&&e.model.canEditAt(o);(e.isReadOnly||this._isEnabledBasedOnSelection&&!h)&&(t.return=!1,t.stop())},{priority:"highest"}),this.on("execute",t=>{this.isEnabled||t.stop()},{priority:"high"})}get affectsData(){return this._affectsData}set affectsData(e){this._affectsData=e}refresh(){this.isEnabled=!0}forceDisabled(e){this._disableStack.add(e),this._disableStack.size==1&&(this.on("set:isEnabled",W,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),this._disableStack.size==0&&(this.off("set:isEnabled",W),this.refresh())}execute(...e){}destroy(){this.stopListening()}}function W(n){n.return=!1,n.stop()}class Ue extends pe{constructor(){super(...arguments);c(this,"_childCommandsDefinitions",[])}refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={}){Z(this._childCommandsDefinitions,{command:e,priority:t.priority||"normal"}),e.on("change:isEnabled",()=>this._checkEnabled()),this._checkEnabled()}_checkEnabled(){this.isEnabled=!!this._getFirstEnabledCommand()}_getFirstEnabledCommand(){const e=this._childCommandsDefinitions.find(({command:t})=>t.isEnabled);return e&&e.command}}class Y extends re(){constructor(e,t=[],o=[]){super();c(this,"_context");c(this,"_plugins",new Map);c(this,"_availablePlugins");c(this,"_contextPlugins");this._context=e,this._availablePlugins=new Map;for(const a of t)a.pluginName&&this._availablePlugins.set(a.pluginName,a);this._contextPlugins=new Map;for(const[a,h]of o)this._contextPlugins.set(a,h),this._contextPlugins.set(h,a),a.pluginName&&this._availablePlugins.set(a.pluginName,a)}*[Symbol.iterator](){for(const e of this._plugins)typeof e[0]=="function"&&(yield e)}get(e){const t=this._plugins.get(e);if(!t){let o=e;throw typeof e=="function"&&(o=e.pluginName||e.name),new u("plugincollection-plugin-not-loaded",this._context,{plugin:o})}return t}has(e){return this._plugins.has(e)}init(e,t=[],o=[]){const a=this,h=this._context;b(e),p(e);const y=e.filter(s=>!C(s,t)),S=[...P(y)];I(S,o);const k=A(S);return D(k,"init").then(()=>D(k,"afterInit")).then(()=>k);function _(s){return typeof s=="function"}function O(s){return _(s)&&!!s.isContextPlugin}function C(s,d){return d.some(r=>r===s||m(s)===r||m(r)===s)}function m(s){return _(s)?s.pluginName||s.name:s}function b(s,d=new Set){s.forEach(r=>{_(r)&&(d.has(r)||(d.add(r),r.pluginName&&!a._availablePlugins.has(r.pluginName)&&a._availablePlugins.set(r.pluginName,r),r.requires&&b(r.requires,d)))})}function P(s,d=new Set){return s.map(r=>_(r)?r:a._availablePlugins.get(r)).reduce((r,l)=>d.has(l)?r:(d.add(l),l.requires&&(p(l.requires,l),P(l.requires,d).forEach(f=>r.add(f))),r.add(l)),new Set)}function p(s,d=null){s.map(r=>_(r)?r:a._availablePlugins.get(r)||r).forEach(r=>{T(r,d),N(r,d),R(r,d)})}function T(s,d){if(!_(s))throw d?new u("plugincollection-soft-required",h,{missingPlugin:s,requiredBy:m(d)}):new u("plugincollection-plugin-not-found",h,{plugin:s})}function N(s,d){if(O(d)&&!O(s))throw new u("plugincollection-context-required",h,{plugin:m(s),requiredBy:m(d)})}function R(s,d){if(d&&C(s,t))throw new u("plugincollection-required",h,{plugin:m(s),requiredBy:m(d)})}function A(s){return s.map(d=>{let r=a._contextPlugins.get(d);return r=r||new d(h),a._add(d,r),r})}function D(s,d){return s.reduce((r,l)=>!l[d]||a._contextPlugins.has(l)?r:r.then(l[d].bind(l)),Promise.resolve())}function I(s,d){for(const r of d){if(typeof r!="function")throw new u("plugincollection-replace-plugin-invalid-type",null,{pluginItem:r});const l=r.pluginName;if(!l)throw new u("plugincollection-replace-plugin-missing-name",null,{pluginItem:r});if(r.requires&&r.requires.length)throw new u("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:l});const f=a._availablePlugins.get(l);if(!f)throw new u("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:l});const w=s.indexOf(f);if(w===-1){if(a._contextPlugins.has(f))return;throw new u("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:l})}if(f.requires&&f.requires.length)throw new u("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:l});s.splice(w,1,r),a._availablePlugins.set(l,r)}}}destroy(){const e=[];for(const[,t]of this)typeof t.destroy=="function"&&!this._contextPlugins.has(t)&&e.push(t.destroy());return Promise.all(e)}_add(e,t){this._plugins.set(e,t);const o=e.pluginName;if(o){if(this._plugins.has(o))throw new u("plugincollection-plugin-name-conflict",null,{pluginName:o,plugin1:this._plugins.get(o).constructor,plugin2:e});this._plugins.set(o,t)}}}class L{constructor(i){c(this,"config");c(this,"plugins");c(this,"locale");c(this,"t");c(this,"editors");c(this,"_contextOwner",null);const{translations:e,...t}=i||{};this.config=new V(t,this.constructor.defaultConfig);const o=this.constructor.builtinPlugins;this.config.define("plugins",o),this.plugins=new Y(this,o);const a=this.config.get("language")||{};this.locale=new oe({uiLanguage:typeof a=="string"?a:a.ui,contentLanguage:this.config.get("language.content"),translations:e}),this.t=this.locale.t,this.editors=new $}initPlugins(){const i=this.config.get("plugins")||[],e=this.config.get("substitutePlugins")||[];for(const t of i.concat(e)){if(typeof t!="function")throw new u("context-initplugins-constructor-only",null,{Plugin:t});if(t.isContextPlugin!==!0)throw new u("context-initplugins-invalid-plugin",null,{Plugin:t})}return this.plugins.init(i,[],e)}destroy(){return Promise.all(Array.from(this.editors,i=>i.destroy())).then(()=>this.plugins.destroy())}_addEditor(i,e){if(this._contextOwner)throw new u("context-addeditor-private-context");this.editors.add(i),e&&(this._contextOwner=i)}_removeEditor(i){return this.editors.has(i)&&this.editors.remove(i),this._contextOwner===i?this.destroy():Promise.resolve()}_getEditorConfig(){const i={};for(const e of this.config.names())["plugins","removePlugins","extraPlugins"].includes(e)||(i[e]=this.config.get(e));return i}static create(i){return new Promise(e=>{const t=new this(i);e(t.initPlugins().then(()=>t))})}}c(L,"defaultConfig"),c(L,"builtinPlugins");class we extends v(){constructor(e){super();c(this,"context");this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}}class be{constructor(){c(this,"_commands");this._commands=new Map}add(i,e){this._commands.set(i,e)}get(i){return this._commands.get(i)}execute(i,...e){const t=this.get(i);if(!t)throw new u("commandcollection-command-not-found",this,{commandName:i});return t.execute(...e)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const i of this.commands())i.destroy()}}class _e extends ae{constructor(e){super();c(this,"editor");this.editor=e}set(e,t,o={}){if(typeof t=="string"){const a=t;t=(h,y)=>{this.editor.execute(a),y()}}super.set(e,t,o)}}const q="contentEditing",j="common";class Ee{constructor(i){c(this,"keystrokeInfos",new Map);c(this,"_editor");this._editor=i;const e=i.config.get("menuBar.isVisible"),t=i.locale.t;this.addKeystrokeInfoCategory({id:q,label:t("Content editing keystrokes"),description:t("These keyboard shortcuts allow for quick access to content editing features.")});const o=[{label:t("Close contextual balloons, dropdowns, and dialogs"),keystroke:"Esc"},{label:t("Open the accessibility help dialog"),keystroke:"Alt+0"},{label:t("Move focus between form fields (inputs, buttons, etc.)"),keystroke:[["Tab"],["Shift+Tab"]]},{label:t("Move focus to the toolbar, navigate between toolbars"),keystroke:"Alt+F10",mayRequireFn:!0},{label:t("Navigate through the toolbar or menu bar"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]},{label:t("Execute the currently focused button. Executing buttons that interact with the editor content moves the focus back to the content."),keystroke:[["Enter"],["Space"]]}];e&&o.push({label:t("Move focus to the menu bar, navigate between menu bars"),keystroke:"Alt+F9",mayRequireFn:!0}),this.addKeystrokeInfoCategory({id:"navigation",label:t("User interface and content navigation keystrokes"),description:t("Use the following keystrokes for more efficient navigation in the CKEditor 5 user interface."),groups:[{id:"common",keystrokes:o}]})}addKeystrokeInfoCategory({id:i,label:e,description:t,groups:o}){this.keystrokeInfos.set(i,{id:i,label:e,description:t,groups:new Map}),this.addKeystrokeInfoGroup({categoryId:i,id:j}),o&&o.forEach(a=>{this.addKeystrokeInfoGroup({categoryId:i,...a})})}addKeystrokeInfoGroup({categoryId:i=q,id:e,label:t,keystrokes:o}){const a=this.keystrokeInfos.get(i);if(!a)throw new u("accessibility-unknown-keystroke-info-category",this._editor,{groupId:e,categoryId:i});a.groups.set(e,{id:e,label:t,keystrokes:o||[]})}addKeystrokeInfos({categoryId:i=q,groupId:e=j,keystrokes:t}){if(!this.keystrokeInfos.has(i))throw new u("accessibility-unknown-keystroke-info-category",this._editor,{categoryId:i,keystrokes:t});const o=this.keystrokeInfos.get(i);if(!o.groups.has(e))throw new u("accessibility-unknown-keystroke-info-group",this._editor,{groupId:e,categoryId:i,keystrokes:t});o.groups.get(e).keystrokes.push(...t)}}function ke(n){return{sessionId:Oe(),pageSessionId:Ce(),hostname:window.location.hostname,version:globalThis.CKEDITOR_VERSION,type:Pe(n),plugins:xe(n.plugins),distribution:ve(),env:Se(),integration:Object.create(null),menuBar:{isVisible:!!n.config.get("menuBar.isVisible")},language:{ui:n.locale.uiLanguage,content:n.locale.contentLanguage},toolbar:{main:M(n.config.get("toolbar")),block:M(n.config.get("blockToolbar")),balloon:M(n.config.get("balloonToolbar"))}}}function Pe(n){return Object.getPrototypeOf(n).constructor.editorName}function xe(n){return Array.from(n).filter(([i])=>!!i.pluginName).map(([i])=>{const{pluginName:e,isContextPlugin:t,isOfficialPlugin:o,isPremiumPlugin:a}=i;return{isContext:!!t,isOfficial:!!o,isPremium:!!a,name:e}})}function M(n){if(!n)return;const i=Array.isArray(n)?{items:n}:n,e=a(i.items||[]);return{isMultiline:e.includes("-"),shouldNotGroupWhenFull:!!i.shouldNotGroupWhenFull,items:o(e)};function o(h){return h.filter(y=>y!=="|"&&y!=="-")}function a(h){return h.flatMap(y=>typeof y=="string"?[y]:a(y.items))}}function ve(){return{channel:window[Symbol.for("cke distribution")]||"sh"}}function Se(){let n="unknown",i="unknown";return E.isMac?n="mac":E.isWindows?n="windows":E.isiOS?n="ios":E.isAndroid&&(n="android"),E.isGecko?i="gecko":E.isBlink?i="blink":E.isSafari&&(i="safari"),{os:n,browser:i}}function Oe(){return localStorage.getItem("__ckeditor-session-id")||localStorage.setItem("__ckeditor-session-id",U()),localStorage.getItem("__ckeditor-session-id")}function Ce(){return K.window.CKEDITOR_PAGE_SESSION_ID=K.window.CKEDITOR_PAGE_SESSION_ID||U(),K.window.CKEDITOR_PAGE_SESSION_ID}class x extends v(){constructor(e={}){super();c(this,"accessibility");c(this,"commands");c(this,"config");c(this,"conversion");c(this,"data");c(this,"editing");c(this,"locale");c(this,"model");c(this,"plugins");c(this,"keystrokes");c(this,"t");c(this,"_context");c(this,"_readOnlyLocks");if("sanitizeHtml"in e)throw new u("editor-config-sanitizehtml-not-supported");const t=this.constructor,{translations:o,...a}=t.defaultConfig||{},{translations:h=o,...y}=e,S=e.language||a.language;this._context=e.context||new L({language:S,translations:h}),this._context._addEditor(this,!e.context);const k=Array.from(t.builtinPlugins||[]);this.config=new V(y,a),this.config.define("plugins",k),this.config.define(this._context._getEditorConfig()),O(this.config),this.plugins=new Y(this,k,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new be,this.set("state","initializing"),this.once("ready",()=>this.state="ready",{priority:"high"}),this.once("destroy",()=>this.state="destroyed",{priority:"high"}),this.model=new le,this.on("change:isReadOnly",()=>{this.model.document.isReadOnly=this.isReadOnly});const _=new ue;this.data=new ce(this.model,_),this.editing=new de(this.model,_),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new he([this.editing.downcastDispatcher,this.data.downcastDispatcher],this.data.upcastDispatcher),this.conversion.addAlias("dataDowncast",this.data.downcastDispatcher),this.conversion.addAlias("editingDowncast",this.editing.downcastDispatcher),this.keystrokes=new _e(this),this.keystrokes.listenTo(this.editing.view.document),this.accessibility=new Ee(this),C(this);function O(m){let b=m.get("licenseKey");if(!b&&window.CKEDITOR_GLOBAL_LICENSE_KEY&&(b=window.CKEDITOR_GLOBAL_LICENSE_KEY,m.set("licenseKey",b)),!b)throw new u("license-key-missing")}function C(m){const b=m.config.get("licenseKey"),P=window[Symbol.for("cke distribution")]||"sh";function p(l){m.enableReadOnlyMode(Symbol("invalidLicense")),m._showLicenseError(l)}function T(l){const f=l.split(".");return f.length!=3?null:f[1]}function N(l){return["exp","jti","vc"].every(w=>w in l)}function R(l){return Object.getOwnPropertyNames(l).sort().filter(g=>g!="vc"&&l[g]!=null).map(g=>l[g])}function A(l){const{hostname:f}=new URL(window.location.href);if(l.includes(f))return!0;const w=f.split(".");return l.filter(g=>g.includes("*")).map(g=>g.split(".")).filter(g=>g.length<=w.length).map(g=>Array(w.length-g.length).fill(g[0]==="*"?"*":"").concat(g)).some(g=>w.every((J,F)=>g[F]===J||g[F]==="*"))}function D(l){const f=l[0].toUpperCase()+l.slice(1),w=l==="evaluation"?"an":"a";console.info(`%cCKEditor 5 ${f} License`,"color: #ffffff; background: #743CCD; font-size: 14px; padding: 4px 8px; border-radius: 4px;"),console.warn(`⚠️ You are using ${w} ${l} license of CKEditor 5${l==="trial"?" which is for evaluation purposes only":""}. For production usage, please obtain a production license at https://portal.ckeditor.com/`)}if(b=="GPL"){P=="cloud"&&p("distributionChannel");return}const I=T(b);if(!I){p("invalid");return}const s=ee(I);if(!s){p("invalid");return}if(!N(s)){p("invalid");return}if(s.distributionChannel&&!te(s.distributionChannel).includes(P)){p("distributionChannel");return}if(ie(R(s))!=s.vc.toLowerCase()){p("invalid");return}if(new Date(s.exp*1e3)<ne){p("expired");return}const r=s.licensedHosts;if(r&&r.length>0&&!A(r)){p("domainLimit");return}if(["evaluation","trial"].includes(s.licenseType)&&s.exp*1e3<Date.now()){p("expired");return}if(["development","evaluation","trial"].includes(s.licenseType)){const{licenseType:l}=s;window.CKEDITOR_WARNING_SUPPRESSIONS=window.CKEDITOR_WARNING_SUPPRESSIONS||{},window.CKEDITOR_WARNING_SUPPRESSIONS[l]||(D(l),window.CKEDITOR_WARNING_SUPPRESSIONS[l]=!0)}if(["evaluation","trial"].includes(s.licenseType)){const l=s.licenseType,f=setTimeout(()=>{p(`${l}Limit`)},6e5);m.on("destroy",()=>{clearTimeout(f)})}s.usageEndpoint&&m.once("ready",()=>{const l={requestId:U(),requestTime:Math.round(Date.now()/1e3),license:b,editor:De(m)};m._sendUsageRequest(s.usageEndpoint,l).then(f=>{const{status:w,message:g}=f;g&&console.warn(g),w!="ok"&&p("usageLimit")},()=>{se("license-key-validation-endpoint-not-reachable",{url:s.usageEndpoint})})},{priority:"high"})}}static get editorName(){return"Editor"}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new u("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if(typeof e!="string"&&typeof e!="symbol")throw new u("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)||(this._readOnlyLocks.add(e),this._readOnlyLocks.size===1&&this.fire("change:isReadOnly","isReadOnly",!0,!1))}disableReadOnlyMode(e){if(typeof e!="string"&&typeof e!="symbol")throw new u("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)&&(this._readOnlyLocks.delete(e),this._readOnlyLocks.size===0&&this.fire("change:isReadOnly","isReadOnly",!1,!0))}setData(e){this.data.set(e)}getData(e){return this.data.get(e)}initPlugins(){const e=this.config,t=e.get("plugins"),o=e.get("removePlugins")||[],a=e.get("extraPlugins")||[],h=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(a),o,h)}destroy(){let e=Promise.resolve();return this.state=="initializing"&&(e=new Promise(t=>this.once("ready",t))),e.then(()=>{this.fire("destroy"),this.stopListening(),this.commands.destroy()}).then(()=>this.plugins.destroy()).then(()=>{this.model.destroy(),this.data.destroy(),this.editing.destroy(),this.keystrokes.destroy()}).then(()=>this._context._removeEditor(this))}execute(e,...t){try{return this.commands.execute(e,...t)}catch(o){/* istanbul ignore next -- @preserve */u.rethrowUnexpectedError(o,this)}}focus(){this.editing.view.focus()}static create(...e){throw new Error("This is an abstract method.")}_showLicenseError(e,t){setTimeout(()=>{if(e=="invalid")throw new u("invalid-license-key");if(e=="expired")throw new u("license-key-expired");if(e=="domainLimit")throw new u("license-key-domain-limit");if(e=="featureNotAllowed")throw new u("license-key-plugin-not-allowed",null,{pluginName:t});if(e=="evaluationLimit")throw new u("license-key-evaluation-limit");if(e=="trialLimit")throw new u("license-key-trial-limit");if(e=="developmentLimit")throw new u("license-key-development-limit");if(e=="usageLimit")throw new u("license-key-usage-limit");if(e=="distributionChannel")throw new u("license-key-invalid-distribution-channel")},0),this._showLicenseError=()=>{}}async _sendUsageRequest(e,t){const o=new Headers({"Content-Type":"application/json"}),a=await fetch(new URL(e),{method:"POST",headers:o,body:JSON.stringify(t)});if(!a.ok)throw new Error(`HTTP Response: ${a.status}`);return a.json()}}c(x,"defaultConfig"),c(x,"builtinPlugins"),c(x,"Context",L),c(x,"EditorWatchdog",fe),c(x,"ContextWatchdog",ge);function De(n){const i=ke(n);function e(t,o){if(me(i,t)!==void 0)throw new u("editor-usage-data-path-already-set",{path:t});ye(i,t,o)}return n.fire("collectUsageData",{setUsageData:e}),i}function Fe(n){if(!z(n.updateSourceElement))throw new u("attachtoform-missing-elementapi-interface",n);const i=n.sourceElement;if(Ie(i)&&i.form){let e;const t=i.form,o=()=>n.updateSourceElement();z(t.submit)&&(e=t.submit,t.submit=()=>{o(),e.apply(t)}),t.addEventListener("submit",o),n.on("destroy",()=>{t.removeEventListener("submit",o),e&&(t.submit=e)})}}function Ie(n){return!!n&&n.tagName.toLowerCase()==="textarea"}function H(n){class i extends n{constructor(){super(...arguments);c(this,"sourceElement")}updateSourceElement(o){if(!this.sourceElement)throw new u("editor-missing-sourceelement",this);const a=this.config.get("updateSourceElementOnDestroy"),h=this.sourceElement instanceof HTMLTextAreaElement;if(!a&&!h){G(this.sourceElement,"");return}const y=typeof o=="string"?o:this.data.get();G(this.sourceElement,y)}}return i}H.updateSourceElement=H(Object).prototype.updateSourceElement;class Ge extends we{constructor(){super(...arguments);c(this,"_actions")}static get pluginName(){return"PendingActions"}static get isOfficialPlugin(){return!0}init(){this.set("hasAny",!1),this._actions=new $({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if(typeof e!="string")throw new u("pendingactions-add-invalid-message",this);const t=new(v());return t.set("message",e),this._actions.add(t),this.hasAny=!0,t}remove(e){this._actions.remove(e),this.hasAny=!!this._actions.length}get first(){return this._actions.get(0)}[Symbol.iterator](){return this._actions[Symbol.iterator]()}}export{pe as Command,L as Context,we as ContextPlugin,x as Editor,H as ElementApiMixin,Ue as MultiCommand,Ge as PendingActions,Me as Plugin,Fe as attachToForm};
|
|
4
|
+
*/class Te extends P(){editor;_disableStack=new Set;constructor(e){super(),this.editor=e,this.set("isEnabled",!0)}forceDisabled(e){this._disableStack.add(e),this._disableStack.size==1&&(this.on("set:isEnabled",U,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),this._disableStack.size==0&&(this.off("set:isEnabled",U),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}}function U(o){o.return=!1,o.stop()}class he extends P(){editor;_isEnabledBasedOnSelection;_affectsData;_disableStack;constructor(e){super(),this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this._affectsData=!0,this._isEnabledBasedOnSelection=!0,this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",()=>{this.refresh()}),this.listenTo(e,"change:isReadOnly",()=>{this.refresh()}),this.on("set:isEnabled",t=>{if(!this.affectsData)return;const i=e.model.document.selection,u=!(i.getFirstPosition().root.rootName=="$graveyard")&&e.model.canEditAt(i);(e.isReadOnly||this._isEnabledBasedOnSelection&&!u)&&(t.return=!1,t.stop())},{priority:"highest"}),this.on("execute",t=>{this.isEnabled||t.stop()},{priority:"high"})}get affectsData(){return this._affectsData}set affectsData(e){this._affectsData=e}refresh(){this.isEnabled=!0}forceDisabled(e){this._disableStack.add(e),this._disableStack.size==1&&(this.on("set:isEnabled",F,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),this._disableStack.size==0&&(this.off("set:isEnabled",F),this.refresh())}execute(...e){}destroy(){this.stopListening()}}function F(o){o.return=!1,o.stop()}class Ne extends he{_childCommandsDefinitions=[];refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={}){V(this._childCommandsDefinitions,{command:e,priority:t.priority||"normal"}),e.on("change:isEnabled",()=>this._checkEnabled()),this._checkEnabled()}_checkEnabled(){this.isEnabled=!!this._getFirstEnabledCommand()}_getFirstEnabledCommand(){const e=this._childCommandsDefinitions.find(({command:t})=>t.isEnabled);return e&&e.command}}class H extends te(){_context;_plugins=new Map;_availablePlugins;_contextPlugins;constructor(e,t=[],i=[]){super(),this._context=e,this._availablePlugins=new Map;for(const n of t)n.pluginName&&this._availablePlugins.set(n.pluginName,n);this._contextPlugins=new Map;for(const[n,u]of i)this._contextPlugins.set(n,u),this._contextPlugins.set(u,n),n.pluginName&&this._availablePlugins.set(n.pluginName,n)}*[Symbol.iterator](){for(const e of this._plugins)typeof e[0]=="function"&&(yield e)}get(e){const t=this._plugins.get(e);if(!t){let i=e;throw typeof e=="function"&&(i=e.pluginName||e.name),new l("plugincollection-plugin-not-loaded",this._context,{plugin:i})}return t}has(e){return this._plugins.has(e)}init(e,t=[],i=[]){const n=this,u=this._context;w(e),g(e);const y=e.filter(s=>!v(s,t)),p=[...k(y)];C(p,i);const E=L(p);return S(E,"init").then(()=>S(E,"afterInit")).then(()=>E);function b(s){return typeof s=="function"}function x(s){return b(s)&&!!s.isContextPlugin}function v(s,c){return c.some(r=>r===s||f(s)===r||f(r)===s)}function f(s){return b(s)?s.pluginName||s.name:s}function w(s,c=new Set){s.forEach(r=>{b(r)&&(c.has(r)||(c.add(r),r.pluginName&&!n._availablePlugins.has(r.pluginName)&&n._availablePlugins.set(r.pluginName,r),r.requires&&w(r.requires,c)))})}function k(s,c=new Set){return s.map(r=>b(r)?r:n._availablePlugins.get(r)).reduce((r,a)=>c.has(a)?r:(c.add(a),a.requires&&(g(a.requires,a),k(a.requires,c).forEach(d=>r.add(d))),r.add(a)),new Set)}function g(s,c=null){s.map(r=>b(r)?r:n._availablePlugins.get(r)||r).forEach(r=>{O(r,c),D(r,c),I(r,c)})}function O(s,c){if(!b(s))throw c?new l("plugincollection-soft-required",u,{missingPlugin:s,requiredBy:f(c)}):new l("plugincollection-plugin-not-found",u,{plugin:s})}function D(s,c){if(x(c)&&!x(s))throw new l("plugincollection-context-required",u,{plugin:f(s),requiredBy:f(c)})}function I(s,c){if(c&&v(s,t))throw new l("plugincollection-required",u,{plugin:f(s),requiredBy:f(c)})}function L(s){return s.map(c=>{let r=n._contextPlugins.get(c);return r=r||new c(u),n._add(c,r),r})}function S(s,c){return s.reduce((r,a)=>!a[c]||n._contextPlugins.has(a)?r:r.then(a[c].bind(a)),Promise.resolve())}function C(s,c){for(const r of c){if(typeof r!="function")throw new l("plugincollection-replace-plugin-invalid-type",null,{pluginItem:r});const a=r.pluginName;if(!a)throw new l("plugincollection-replace-plugin-missing-name",null,{pluginItem:r});if(r.requires&&r.requires.length)throw new l("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:a});const d=n._availablePlugins.get(a);if(!d)throw new l("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:a});const m=s.indexOf(d);if(m===-1){if(n._contextPlugins.has(d))return;throw new l("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:a})}if(d.requires&&d.requires.length)throw new l("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:a});s.splice(m,1,r),n._availablePlugins.set(a,r)}}}destroy(){const e=[];for(const[,t]of this)typeof t.destroy=="function"&&!this._contextPlugins.has(t)&&e.push(t.destroy());return Promise.all(e)}_add(e,t){this._plugins.set(e,t);const i=e.pluginName;if(i){if(this._plugins.has(i))throw new l("plugincollection-plugin-name-conflict",null,{pluginName:i,plugin1:this._plugins.get(i).constructor,plugin2:e});this._plugins.set(i,t)}}}class G{config;plugins;locale;t;editors;static defaultConfig;static builtinPlugins;_contextOwner=null;constructor(e){const{translations:t,...i}=e||{};this.config=new j(i,this.constructor.defaultConfig);const n=this.constructor.builtinPlugins;this.config.define("plugins",n),this.plugins=new H(this,n);const u=this.config.get("language")||{};this.locale=new ee({uiLanguage:typeof u=="string"?u:u.ui,contentLanguage:this.config.get("language.content"),translations:t}),this.t=this.locale.t,this.editors=new W}initPlugins(){const e=this.config.get("plugins")||[],t=this.config.get("substitutePlugins")||[];for(const i of e.concat(t)){if(typeof i!="function")throw new l("context-initplugins-constructor-only",null,{Plugin:i});if(i.isContextPlugin!==!0)throw new l("context-initplugins-invalid-plugin",null,{Plugin:i})}return this.plugins.init(e,[],t)}destroy(){return Promise.all(Array.from(this.editors,e=>e.destroy())).then(()=>this.plugins.destroy())}_addEditor(e,t){if(this._contextOwner)throw new l("context-addeditor-private-context");this.editors.add(e),t&&(this._contextOwner=e)}_removeEditor(e){return this.editors.has(e)&&this.editors.remove(e),this._contextOwner===e?this.destroy():Promise.resolve()}_getEditorConfig(){const e={};for(const t of this.config.names())["plugins","removePlugins","extraPlugins"].includes(t)||(e[t]=this.config.get(t));return e}static create(e){return new Promise(t=>{const i=new this(e);t(i.initPlugins().then(()=>i))})}}class fe extends P(){context;constructor(e){super(),this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}}class ge{_commands;constructor(){this._commands=new Map}add(e,t){this._commands.set(e,t)}get(e){return this._commands.get(e)}execute(e,...t){const i=this.get(e);if(!i)throw new l("commandcollection-command-not-found",this,{commandName:e});return i.execute(...t)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const e of this.commands())e.destroy()}}class me extends ie{editor;constructor(e){super(),this.editor=e}set(e,t,i={}){if(typeof t=="string"){const n=t;t=(u,y)=>{this.editor.execute(n),y()}}super.set(e,t,i)}}const N="contentEditing",z="common";class ye{keystrokeInfos=new Map;_editor;constructor(e){this._editor=e;const t=e.config.get("menuBar.isVisible"),i=e.locale.t;this.addKeystrokeInfoCategory({id:N,label:i("Content editing keystrokes"),description:i("These keyboard shortcuts allow for quick access to content editing features.")});const n=[{label:i("Close contextual balloons, dropdowns, and dialogs"),keystroke:"Esc"},{label:i("Open the accessibility help dialog"),keystroke:"Alt+0"},{label:i("Move focus between form fields (inputs, buttons, etc.)"),keystroke:[["Tab"],["Shift+Tab"]]},{label:i("Move focus to the toolbar, navigate between toolbars"),keystroke:"Alt+F10",mayRequireFn:!0},{label:i("Navigate through the toolbar or menu bar"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]},{label:i("Execute the currently focused button. Executing buttons that interact with the editor content moves the focus back to the content."),keystroke:[["Enter"],["Space"]]}];t&&n.push({label:i("Move focus to the menu bar, navigate between menu bars"),keystroke:"Alt+F9",mayRequireFn:!0}),this.addKeystrokeInfoCategory({id:"navigation",label:i("User interface and content navigation keystrokes"),description:i("Use the following keystrokes for more efficient navigation in the CKEditor 5 user interface."),groups:[{id:"common",keystrokes:n}]})}addKeystrokeInfoCategory({id:e,label:t,description:i,groups:n}){this.keystrokeInfos.set(e,{id:e,label:t,description:i,groups:new Map}),this.addKeystrokeInfoGroup({categoryId:e,id:z}),n&&n.forEach(u=>{this.addKeystrokeInfoGroup({categoryId:e,...u})})}addKeystrokeInfoGroup({categoryId:e=N,id:t,label:i,keystrokes:n}){const u=this.keystrokeInfos.get(e);if(!u)throw new l("accessibility-unknown-keystroke-info-category",this._editor,{groupId:t,categoryId:e});u.groups.set(t,{id:t,label:i,keystrokes:n||[]})}addKeystrokeInfos({categoryId:e=N,groupId:t=z,keystrokes:i}){if(!this.keystrokeInfos.has(e))throw new l("accessibility-unknown-keystroke-info-category",this._editor,{categoryId:e,keystrokes:i});const n=this.keystrokeInfos.get(e);if(!n.groups.has(t))throw new l("accessibility-unknown-keystroke-info-group",this._editor,{groupId:t,categoryId:e,keystrokes:i});n.groups.get(t).keystrokes.push(...i)}}function pe(o){return{sessionId:ke(),pageSessionId:Pe(),hostname:window.location.hostname,version:globalThis.CKEDITOR_VERSION,type:we(o),plugins:be(o.plugins),distribution:_e(),env:Ee(),integration:Object.create(null),menuBar:{isVisible:!!o.config.get("menuBar.isVisible")},language:{ui:o.locale.uiLanguage,content:o.locale.contentLanguage},toolbar:{main:R(o.config.get("toolbar")),block:R(o.config.get("blockToolbar")),balloon:R(o.config.get("balloonToolbar"))}}}function we(o){return Object.getPrototypeOf(o).constructor.editorName}function be(o){return Array.from(o).filter(([e])=>!!e.pluginName).map(([e])=>{const{pluginName:t,isContextPlugin:i,isOfficialPlugin:n,isPremiumPlugin:u}=e;return{isContext:!!i,isOfficial:!!n,isPremium:!!u,name:t}})}function R(o){if(!o)return;const e=Array.isArray(o)?{items:o}:o,t=u(e.items||[]);return{isMultiline:t.includes("-"),shouldNotGroupWhenFull:!!e.shouldNotGroupWhenFull,items:n(t)};function n(y){return y.filter(p=>p!=="|"&&p!=="-")}function u(y){return y.flatMap(p=>typeof p=="string"?[p]:u(p.items))}}function _e(){return{channel:window[Symbol.for("cke distribution")]||"sh"}}function Ee(){let o="unknown",e="unknown";return _.isMac?o="mac":_.isWindows?o="windows":_.isiOS?o="ios":_.isAndroid&&(o="android"),_.isGecko?e="gecko":_.isBlink?e="blink":_.isSafari&&(e="safari"),{os:o,browser:e}}function ke(){return localStorage.getItem("__ckeditor-session-id")||localStorage.setItem("__ckeditor-session-id",A()),localStorage.getItem("__ckeditor-session-id")}function Pe(){return T.window.CKEDITOR_PAGE_SESSION_ID=T.window.CKEDITOR_PAGE_SESSION_ID||A(),T.window.CKEDITOR_PAGE_SESSION_ID}class Re extends P(){static get editorName(){return"Editor"}accessibility;commands;config;conversion;data;editing;locale;model;plugins;keystrokes;t;static defaultConfig;static builtinPlugins;_context;_readOnlyLocks;constructor(e={}){if(super(),"sanitizeHtml"in e)throw new l("editor-config-sanitizehtml-not-supported");const t=this.constructor,{translations:i,...n}=t.defaultConfig||{},{translations:u=i,...y}=e,p=e.language||n.language;this._context=e.context||new G({language:p,translations:u}),this._context._addEditor(this,!e.context);const E=Array.from(t.builtinPlugins||[]);this.config=new j(y,n),this.config.define("plugins",E),this.config.define(this._context._getEditorConfig()),x(this.config),this.plugins=new H(this,E,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new ge,this.set("state","initializing"),this.once("ready",()=>this.state="ready",{priority:"high"}),this.once("destroy",()=>this.state="destroyed",{priority:"high"}),this.model=new ne,this.on("change:isReadOnly",()=>{this.model.document.isReadOnly=this.isReadOnly});const b=new oe;this.data=new se(this.model,b),this.editing=new re(this.model,b),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new ae([this.editing.downcastDispatcher,this.data.downcastDispatcher],this.data.upcastDispatcher),this.conversion.addAlias("dataDowncast",this.data.downcastDispatcher),this.conversion.addAlias("editingDowncast",this.editing.downcastDispatcher),this.keystrokes=new me(this),this.keystrokes.listenTo(this.editing.view.document),this.accessibility=new ye(this),v(this);function x(f){let w=f.get("licenseKey");if(!w&&window.CKEDITOR_GLOBAL_LICENSE_KEY&&(w=window.CKEDITOR_GLOBAL_LICENSE_KEY,f.set("licenseKey",w)),!w)throw new l("license-key-missing")}function v(f){const w=f.config.get("licenseKey"),k=window[Symbol.for("cke distribution")]||"sh";function g(a){f.enableReadOnlyMode(Symbol("invalidLicense")),f._showLicenseError(a)}function O(a){const d=a.split(".");return d.length!=3?null:d[1]}function D(a){return["exp","jti","vc"].every(m=>m in a)}function I(a){return Object.getOwnPropertyNames(a).sort().filter(h=>h!="vc"&&a[h]!=null).map(h=>a[h])}function L(a){const{hostname:d}=new URL(window.location.href);if(a.includes(d))return!0;const m=d.split(".");return a.filter(h=>h.includes("*")).map(h=>h.split(".")).filter(h=>h.length<=m.length).map(h=>Array(m.length-h.length).fill(h[0]==="*"?"*":"").concat(h)).some(h=>m.every(($,K)=>h[K]===$||h[K]==="*"))}function S(a){const d=a[0].toUpperCase()+a.slice(1),m=a==="evaluation"?"an":"a";console.info(`%cCKEditor 5 ${d} License`,"color: #ffffff; background: #743CCD; font-size: 14px; padding: 4px 8px; border-radius: 4px;"),console.warn(`⚠️ You are using ${m} ${a} license of CKEditor 5${a==="trial"?" which is for evaluation purposes only":""}. For production usage, please obtain a production license at https://portal.ckeditor.com/`)}if(w=="GPL"){k=="cloud"&&g("distributionChannel");return}const C=O(w);if(!C){g("invalid");return}const s=Y(C);if(!s){g("invalid");return}if(!D(s)){g("invalid");return}if(s.distributionChannel&&!J(s.distributionChannel).includes(k)){g("distributionChannel");return}if(Q(I(s))!=s.vc.toLowerCase()){g("invalid");return}if(new Date(s.exp*1e3)<X){g("expired");return}const r=s.licensedHosts;if(r&&r.length>0&&!L(r)){g("domainLimit");return}if(["evaluation","trial"].includes(s.licenseType)&&s.exp*1e3<Date.now()){g("expired");return}if(["development","evaluation","trial"].includes(s.licenseType)){const{licenseType:a}=s;window.CKEDITOR_WARNING_SUPPRESSIONS=window.CKEDITOR_WARNING_SUPPRESSIONS||{},window.CKEDITOR_WARNING_SUPPRESSIONS[a]||(S(a),window.CKEDITOR_WARNING_SUPPRESSIONS[a]=!0)}if(["evaluation","trial"].includes(s.licenseType)){const a=s.licenseType,d=setTimeout(()=>{g(`${a}Limit`)},6e5);f.on("destroy",()=>{clearTimeout(d)})}s.usageEndpoint&&f.once("ready",()=>{const a={requestId:A(),requestTime:Math.round(Date.now()/1e3),license:w,editor:xe(f)};f._sendUsageRequest(s.usageEndpoint,a).then(d=>{const{status:m,message:h}=d;h&&console.warn(h),m!="ok"&&g("usageLimit")},()=>{Z("license-key-validation-endpoint-not-reachable",{url:s.usageEndpoint})})},{priority:"high"})}}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new l("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if(typeof e!="string"&&typeof e!="symbol")throw new l("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)||(this._readOnlyLocks.add(e),this._readOnlyLocks.size===1&&this.fire("change:isReadOnly","isReadOnly",!0,!1))}disableReadOnlyMode(e){if(typeof e!="string"&&typeof e!="symbol")throw new l("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)&&(this._readOnlyLocks.delete(e),this._readOnlyLocks.size===0&&this.fire("change:isReadOnly","isReadOnly",!1,!0))}setData(e){this.data.set(e)}getData(e){return this.data.get(e)}initPlugins(){const e=this.config,t=e.get("plugins"),i=e.get("removePlugins")||[],n=e.get("extraPlugins")||[],u=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(n),i,u)}destroy(){let e=Promise.resolve();return this.state=="initializing"&&(e=new Promise(t=>this.once("ready",t))),e.then(()=>{this.fire("destroy"),this.stopListening(),this.commands.destroy()}).then(()=>this.plugins.destroy()).then(()=>{this.model.destroy(),this.data.destroy(),this.editing.destroy(),this.keystrokes.destroy()}).then(()=>this._context._removeEditor(this))}execute(e,...t){try{return this.commands.execute(e,...t)}catch(i){/* istanbul ignore next -- @preserve */l.rethrowUnexpectedError(i,this)}}focus(){this.editing.view.focus()}static create(...e){throw new Error("This is an abstract method.")}static Context=G;static EditorWatchdog=le;static ContextWatchdog=ce;_showLicenseError(e,t){setTimeout(()=>{if(e=="invalid")throw new l("invalid-license-key");if(e=="expired")throw new l("license-key-expired");if(e=="domainLimit")throw new l("license-key-domain-limit");if(e=="featureNotAllowed")throw new l("license-key-plugin-not-allowed",null,{pluginName:t});if(e=="evaluationLimit")throw new l("license-key-evaluation-limit");if(e=="trialLimit")throw new l("license-key-trial-limit");if(e=="developmentLimit")throw new l("license-key-development-limit");if(e=="usageLimit")throw new l("license-key-usage-limit");if(e=="distributionChannel")throw new l("license-key-invalid-distribution-channel")},0),this._showLicenseError=()=>{}}async _sendUsageRequest(e,t){const i=new Headers({"Content-Type":"application/json"}),n=await fetch(new URL(e),{method:"POST",headers:i,body:JSON.stringify(t)});if(!n.ok)throw new Error(`HTTP Response: ${n.status}`);return n.json()}}function xe(o){const e=pe(o);function t(i,n){if(ue(e,i)!==void 0)throw new l("editor-usage-data-path-already-set",{path:i});de(e,i,n)}return o.fire("collectUsageData",{setUsageData:t}),e}function Ae(o){if(!M(o.updateSourceElement))throw new l("attachtoform-missing-elementapi-interface",o);const e=o.sourceElement;if(ve(e)&&e.form){let t;const i=e.form,n=()=>o.updateSourceElement();M(i.submit)&&(t=i.submit,i.submit=()=>{n(),t.apply(i)}),i.addEventListener("submit",n),o.on("destroy",()=>{i.removeEventListener("submit",n),t&&(i.submit=t)})}}function ve(o){return!!o&&o.tagName.toLowerCase()==="textarea"}function B(o){class e extends o{sourceElement;updateSourceElement(i){if(!this.sourceElement)throw new l("editor-missing-sourceelement",this);const n=this.config.get("updateSourceElementOnDestroy"),u=this.sourceElement instanceof HTMLTextAreaElement;if(!n&&!u){q(this.sourceElement,"");return}const y=typeof i=="string"?i:this.data.get();q(this.sourceElement,y)}}return e}B.updateSourceElement=B(Object).prototype.updateSourceElement;class Ke extends fe{_actions;static get pluginName(){return"PendingActions"}static get isOfficialPlugin(){return!0}init(){this.set("hasAny",!1),this._actions=new W({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if(typeof e!="string")throw new l("pendingactions-add-invalid-message",this);const t=new(P());return t.set("message",e),this._actions.add(t),this.hasAny=!0,t}remove(e){this._actions.remove(e),this.hasAny=!!this._actions.length}get first(){return this._actions.get(0)}[Symbol.iterator](){return this._actions[Symbol.iterator]()}}export{he as Command,G as Context,fe as ContextPlugin,Re as Editor,B as ElementApiMixin,Ne as MultiCommand,Ke as PendingActions,Te as Plugin,Ae as attachToForm};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{BoxedEditorUIView as f,StickyPanelView as w,ToolbarView as m,MenuBarView as p,InlineEditableUIView as b,EditorUI as y,normalizeToolbarConfig as v,DialogView as u}from"../../../../../@ckeditor_ckeditor5-ui@45.2.1/node_modules/@ckeditor/ckeditor5-ui/dist/index.js";import{enablePlaceholder as P}from"../../../../../@ckeditor_ckeditor5-engine@45.2.1/node_modules/@ckeditor/ckeditor5-engine/dist/index.js";import{CKEditorError as k,getDataFromElement as T,ElementReplacer as V,Rect as a}from"../../../../../@ckeditor_ckeditor5-utils@45.2.1/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{ElementApiMixin as C,attachToForm as B,Editor as E}from"../../../../../@ckeditor_ckeditor5-core@45.2.1/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{isElement as S}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/predicate/isElement.js";/**
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/class
|
|
4
|
+
*/class _ extends y{view;_toolbarConfig;_elementReplacer;constructor(t,i){super(t),this.view=i,this._toolbarConfig=v(t.config.get("toolbar")),this._elementReplacer=new V,this.listenTo(t.editing.view,"scrollToTheSelection",this._handleScrollToTheSelectionWithStickyPanel.bind(this))}get element(){return this.view.element}init(t){const i=this.editor,o=this.view,n=i.editing.view,e=o.editable,s=n.document.getRoot();e.name=s.rootName,o.render();const r=e.element;this.setEditableElement(e.name,r),o.editable.bind("isFocused").to(this.focusTracker),n.attachDomRoot(r),t&&this._elementReplacer.replace(t,this.element),this._initPlaceholder(),this._initToolbar(),o.menuBarView&&this.initMenuBar(o.menuBarView),this._initDialogPluginIntegration(),this._initContextualBalloonIntegration(),this.fire("ready")}destroy(){super.destroy();const t=this.view,i=this.editor.editing.view;this._elementReplacer.restore(),i.getDomRoot(t.editable.name)&&i.detachDomRoot(t.editable.name),t.destroy()}_initToolbar(){const t=this.view;t.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),t.stickyPanel.limiterElement=t.element,t.stickyPanel.bind("viewportTopOffset").to(this,"viewportOffset",({visualTop:i})=>i||0),t.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(t.toolbar)}_initPlaceholder(){const t=this.editor,i=t.editing.view,o=i.document.getRoot(),n=t.sourceElement;let e;const s=t.config.get("placeholder");s&&(e=typeof s=="string"?s:s[this.view.editable.name]),!e&&n&&n.tagName.toLowerCase()==="textarea"&&(e=n.getAttribute("placeholder")),e&&(o.placeholder=e),P({view:i,element:o,isDirectHost:!1,keepOnFocus:!0})}_initContextualBalloonIntegration(){if(!this.editor.plugins.has("ContextualBalloon"))return;const{stickyPanel:t}=this.view,i=this.editor.plugins.get("ContextualBalloon");i.on("getPositionOptions",n=>{const e=n.return;if(!e||!t.isSticky||!t.element)return;const s=new a(t.element).height,r=typeof e.target=="function"?e.target():e.target,h=typeof e.limiter=="function"?e.limiter():e.limiter;if(r&&h&&new a(r).height>=new a(h).height-s)return;const d={...e.viewportOffsetConfig},g=(d.top||0)+s;n.return={...e,viewportOffsetConfig:{...d,top:g}}},{priority:"low"});const o=()=>{i.visibleView&&i.updatePosition()};this.listenTo(t,"change:isSticky",o),this.listenTo(this.editor.ui,"change:viewportOffset",o)}_handleScrollToTheSelectionWithStickyPanel(t,i,o){const n=this.view.stickyPanel;if(n.isSticky){const e=new a(n.element).height;i.viewportOffset.top+=e}else{const e=()=>{this.editor.editing.view.scrollToTheSelection(o)};this.listenTo(n,"change:isSticky",e),setTimeout(()=>{this.stopListening(n,"change:isSticky",e)},20)}}_initDialogPluginIntegration(){if(!this.editor.plugins.has("Dialog"))return;const t=this.view.stickyPanel,i=this.editor.plugins.get("Dialog");i.on("show",()=>{const o=i.view;o.on("moveTo",(n,e)=>{if(!t.isSticky||o.wasMoved||o.isModal)return;const s=new a(t.contentPanelElement);e[1]<s.bottom+u.defaultOffset&&(e[1]=s.bottom+u.defaultOffset)},{priority:"high"})},{priority:"low"})}}class R extends f{stickyPanel;toolbar;editable;constructor(t,i,o={}){super(t),this.stickyPanel=new w(t),this.toolbar=new m(t,{shouldGroupWhenFull:o.shouldToolbarGroupWhenFull}),o.useMenuBar&&(this.menuBarView=new p(t)),this.editable=new b(t,i,void 0,{label:o.label})}render(){super.render(),this.menuBarView?this.stickyPanel.content.addMany([this.menuBarView,this.toolbar]):this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}}class W extends C(E){static get editorName(){return"ClassicEditor"}ui;constructor(t,i={}){if(!c(t)&&i.initialData!==void 0)throw new k("editor-create-initial-data",null);super(i),this.config.define("menuBar.isVisible",!1),this.config.get("initialData")===void 0&&this.config.set("initialData",x(t)),c(t)&&(this.sourceElement=t),this.model.document.createRoot();const o=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=this.config.get("menuBar"),e=new R(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:o,useMenuBar:n.isVisible,label:this.config.get("label")});this.ui=new _(this,e),B(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(t,i={}){return new Promise(o=>{const n=new this(t,i);o(n.initPlugins().then(()=>n.ui.init(c(t)?t:null)).then(()=>n.data.init(n.config.get("initialData"))).then(()=>n.fire("ready")).then(()=>n))})}}function x(l){return c(l)?T(l):l}function c(l){return S(l)}export{W as ClassicEditor,R as ClassicEditorUIView};
|