@ncino/web-components 4.3.0-preview.9 → 5.0.0-preview.10
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.figma.js +10 -0
- package/dist/components/accordion/gator/base/accordion.gator.js +11 -9
- package/dist/components/accordion/gator/group/accordion-group.gator.figma.js +3 -0
- package/dist/components/accordion/gator/group/accordion-group.gator.js +2 -2
- package/dist/components/alert/gator/base/alert.gator.js +2 -2
- package/dist/components/alert/gator/subtitle/alert-subtitle.gator.js +2 -2
- package/dist/components/alert/gator/title/alert-title.gator.js +2 -2
- package/dist/components/avatar/gator/avatar.gator.js +5 -5
- package/dist/components/badge/gator/badge.gator.js +2 -2
- package/dist/components/banner/gator/banner.gator.figma.js +8 -0
- package/dist/components/banner/gator/banner.gator.js +6 -5
- package/dist/components/boolean/boolean.gator.figma.js +11 -0
- package/dist/components/boolean/boolean.gator.js +6 -6
- package/dist/components/breadcrumbs/gator/breadcrumb/breadcrumb.gator.figma.js +3 -0
- package/dist/components/breadcrumbs/gator/breadcrumb/breadcrumb.gator.js +2 -2
- package/dist/components/breadcrumbs/gator/container/breadcrumbs.gator.figma.js +5 -0
- 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/card/gator/footer/card-footer.gator.js +2 -2
- package/dist/components/card/gator/header/card-header.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/chip/chip.js +1 -1
- package/dist/components/chip/gator/chip.gator.js +15 -5
- 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/table/gator/table-bulk-controls/table-bulk-controls.gator.js +16 -0
- package/dist/components/table/gator/table.gator.js +55 -36
- package/dist/components/tabs/gator/tabset/tabset.gator.js +3 -3
- package/dist/components/text-detail/gator/text-detail.gator.figma.js +30 -0
- 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/toast/gator/base/toast.gator.js +8 -9
- package/dist/components/toast/gator/subtitle/toast-subtitle.gator.js +2 -2
- package/dist/components/toast/gator/title/toast-title.gator.js +2 -2
- package/dist/components/toast/toast.js +1 -1
- package/dist/components/toast-container/gator/toast-container.gator.js +18 -0
- package/dist/components/toast-container/index.js +1 -0
- package/dist/components/toaster/gator/toaster.gator.js +5 -0
- package/dist/components/toaster/index.js +1 -0
- package/dist/components/tooltip/tooltip.js +1 -1
- package/dist/index.gator.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.services.js +1 -0
- 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/@jridgewell_sourcemap-codec@1.5.4/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +1 -0
- 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 +12 -12
- 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/directive-helpers.js +2 -2
- 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/directives/repeat.js +5 -0
- package/dist/node_modules/.pnpm/lit-html@3.3.0/node_modules/lit-html/lit-html.js +3 -3
- package/dist/node_modules/.pnpm/magic-string@0.30.17/node_modules/magic-string/dist/magic-string.es.js +1 -1
- 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 +8 -0
- 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 +12 -0
- package/dist/packages/web-components/src/components/accordion/gator/base/accordion.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/accordion/gator/group/accordion-group.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/banner/gator/banner.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/button/gator/button.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/button-card/gator/button-card.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/card/gator/base/card.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/chip/gator/chip.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/table/gator/table-bulk-controls/table-bulk-controls.gator.scss.js +1 -0
- package/dist/packages/web-components/src/components/text-detail/gator/text-detail.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/toast/gator/base/toast.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/toast-container/gator/toast-container.gator.scss.js +1 -0
- package/dist/packages/web-components/src/components/toaster/gator/toaster.gator.scss.js +1 -0
- package/dist/packages/web-components/src/index.slds.scss.js +1 -1
- package/dist/services/toaster-service.js +1 -0
- package/dist/types/components/accordion/gator/base/accordion.gator.d.ts +13 -3
- package/dist/types/components/accordion/gator/base/accordion.gator.figma.d.ts +1 -0
- package/dist/types/components/accordion/gator/group/accordion-group.gator.d.ts +5 -0
- package/dist/types/components/accordion/gator/group/accordion-group.gator.figma.d.ts +1 -0
- package/dist/types/components/avatar/gator/avatar.gator.d.ts +1 -0
- package/dist/types/components/banner/gator/banner.gator.d.ts +5 -0
- package/dist/types/components/banner/gator/banner.gator.figma.d.ts +1 -0
- package/dist/types/components/boolean/boolean.gator.figma.d.ts +1 -0
- package/dist/types/components/breadcrumbs/gator/breadcrumb/breadcrumb.gator.figma.d.ts +1 -0
- package/dist/types/components/breadcrumbs/gator/container/breadcrumbs.gator.figma.d.ts +1 -0
- package/dist/types/components/chip/chip.d.ts +10 -0
- package/dist/types/components/chip/gator/chip.gator.d.ts +1 -0
- package/dist/types/components/modal/gator/modal.gator.d.ts +1 -1
- package/dist/types/components/table/gator/table-bulk-controls/table-bulk-controls.gator.d.ts +29 -0
- package/dist/types/components/table/gator/table-bulk-controls/table-bulk-controls.gator.test.d.ts +0 -0
- package/dist/types/components/table/gator/table.gator.d.ts +9 -0
- package/dist/types/components/text-detail/gator/text-detail.gator.d.ts +4 -2
- package/dist/types/components/text-detail/gator/text-detail.gator.figma.d.ts +1 -0
- package/dist/types/components/toast/toast.d.ts +14 -0
- package/dist/types/components/toast-container/gator/toast-container.gator.d.ts +15 -0
- package/dist/types/components/toast-container/gator/toast-container.gator.test.d.ts +0 -0
- package/dist/types/components/toast-container/index.d.ts +1 -0
- package/dist/types/components/toaster/gator/toaster.gator.d.ts +32 -0
- package/dist/types/components/toaster/gator/toaster.gator.test.d.ts +0 -0
- package/dist/types/components/toaster/index.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.gator.d.ts +2 -0
- package/dist/types/index.services.d.ts +1 -0
- package/dist/types/services/toaster-service.d.ts +117 -0
- package/dist/types/services/toaster-service.test.d.ts +1 -0
- 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 +16 -12
- package/web-types.json +293 -114
- package/dist/_virtual/sourcemap-codec.umd.js +0 -1
- package/dist/_virtual/sourcemap-codec.umd2.js +0 -1
- 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/@jridgewell_sourcemap-codec@1.5.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js +0 -1
- package/dist/node_modules/.pnpm/@vitest_browser@3.2.4_msw@2.7.3_@types_node@24.0.7_typescript@5.8.3__playwright@1.53.1__894c207534f0ba223b8299d9f5ff1049/node_modules/@vitest/browser/context.js +0 -1
- package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.7_@vitest_browser@3.2.4_@vitest_ui@3._93f645c93c51b497c065da8f21fff0a5/node_modules/vitest/dist/chunks/utils.XdZDrNZV.js +0 -8
- package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.7_@vitest_browser@3.2.4_@vitest_ui@3._93f645c93c51b497c065da8f21fff0a5/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js +0 -12
- package/dist/packages/web-components/src/components/accordion/gator/base/accordion.gator.tokens.scss.js +0 -1
- package/dist/packages/web-components/src/components/accordion/gator/group/accordion-group.gator.tokens.scss.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
- /package/dist/node_modules/.pnpm/{vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.7_@vitest_browser@3.2.4_@vitest_ui@3._93f645c93c51b497c065da8f21fff0a5 → 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/_commonjsHelpers.BFTU3MAI.js +0 -0
- /package/dist/node_modules/.pnpm/{vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.7_@vitest_browser@3.2.4_@vitest_ui@3._93f645c93c51b497c065da8f21fff0a5 → 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/date.Bq6ZW5rf.js +0 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import{Plugin as y,Command as A}from"../../../../../@ckeditor_ckeditor5-core@45.2.1/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{Widget as lo,WidgetToolbarRepository as Ue,toWidgetEditable as pt,isWidget as io,toWidget as so}from"../../../../../@ckeditor_ckeditor5-widget@45.2.1/node_modules/@ckeditor/ckeditor5-widget/dist/index.js";import{Collection as wt,first as We,getLocalizedArrowKeyCodeDirection as ro,DomEmitterMixin as ao,global as ie,Rect as se,toUnit as co,CKEditorError as $e,KeystrokeHandler as ge,FocusTracker as be}from"../../../../../@ckeditor_ckeditor5-utils@45.2.1/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{IconTable as Ge,IconTableColumn as uo,IconTableRow as ho,IconTableMergeCell as mo,IconCaption as go,IconTableCellProperties as bo,IconTableProperties as fo,IconCheck as Ct,IconCancel as Tt,IconObjectInlineRight as po,IconObjectCenter as wo,IconObjectInlineLeft as Co,IconAlignBottom as To,IconAlignMiddle as _o,IconAlignTop as yo,IconAlignJustify as vo,IconAlignRight as Ao,IconAlignCenter as So,IconAlignLeft as Ro}from"../../../../../@ckeditor_ckeditor5-icons@45.2.1/node_modules/@ckeditor/ckeditor5-icons/dist/index.js";import{createDropdown as te,MenuBarMenuView as Io,SwitchButtonView as xo,addListToDropdown as Le,ButtonView as V,ContextualBalloon as re,normalizeColorOptions as ae,getLocalizedColorOptions as ce,clickOutsideHandler as _t,SplitButtonView as ko,View as N,addKeyboardHandlingForGrid as Vo,ViewModel as yt,ViewCollection as Be,FocusCycler as De,FormHeaderView as vt,FormRowView as R,submitHandler as At,LabelView as E,LabeledFieldView as I,createLabeledDropdown as St,createLabeledInputText as F,ToolbarView as Te,BalloonPanelView as D,InputTextView as Po,ColorSelectorView as Eo}from"../../../../../@ckeditor_ckeditor5-ui@45.2.1/node_modules/@ckeditor/ckeditor5-ui/dist/index.js";import{ClipboardMarkersUtils as we,ClipboardPipeline as je}from"../../../../../@ckeditor_ckeditor5-clipboard@45.2.1/node_modules/@ckeditor/ckeditor5-clipboard/dist/index.js";import{enablePlaceholder as Wo,Element as Lo,addBorderRules as Rt,addPaddingRules as Bo,addBackgroundRules as It,DomEventObserver as Do,isColor as Fo,isLength as xt,isPercentage as No}from"../../../../../@ckeditor_ckeditor5-engine@45.2.1/node_modules/@ckeditor/ckeditor5-engine/dist/index.js";import{debounce as kt}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/function/debounce.js";import{isEqual as Ke}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/predicate/isEqual.js";import{throttle as Mo}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/function/throttle.js";import{isObject as Oo}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/predicate/isObject.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
|
|
4
|
+
*/function Fe(i,e){const{modelAttribute:t,styleName:o,viewElement:n,defaultValue:l,reduceBoxSides:s=!1,shouldUpcast:r=()=>!0}=e;i.for("upcast").attributeToAttribute({view:{name:n,styles:{[o]:/[\s\S]+/}},model:{key:t,value:(c,a,d)=>{if(!r(c))return;const u=W(l,"",d),h=c.getNormalizedStyle(o),m=s?ne(h):h;if(u!==m)return m}}})}function _e(i,e,t,o){i.for("upcast").add(n=>n.on("element:"+e,(l,s,r)=>{if(!s.modelRange)return;const c=["border-top-width","border-top-color","border-top-style","border-bottom-width","border-bottom-color","border-bottom-style","border-right-width","border-right-color","border-right-style","border-left-width","border-left-color","border-left-style"].filter(f=>s.viewItem.hasStyle(f));if(!c.length)return;const a={styles:c};if(!r.consumable.test(s.viewItem,a))return;const d=[...s.modelRange.getItems({shallow:!0})].pop(),u=d.findAncestor("table",{includeSelf:!0});let h=o;u&&u.getAttribute("tableType")=="layout"&&(h={style:"none",color:"",width:""}),r.consumable.consume(s.viewItem,a);const m={style:s.viewItem.getNormalizedStyle("border-style"),color:s.viewItem.getNormalizedStyle("border-color"),width:s.viewItem.getNormalizedStyle("border-width")},g={style:ne(m.style),color:ne(m.color),width:ne(m.width)};g.style!==h.style&&r.writer.setAttribute(t.style,g.style,d),g.color!==h.color&&r.writer.setAttribute(t.color,g.color,d),g.width!==h.width&&r.writer.setAttribute(t.width,g.width,d)}))}function j(i,e){const{modelElement:t,modelAttribute:o,styleName:n}=e;i.for("downcast").attributeToAttribute({model:{name:t,key:o},view:l=>({key:"style",value:{[n]:l}})})}function oe(i,e){const{modelAttribute:t,styleName:o}=e;i.for("downcast").add(n=>n.on(`attribute:${t}:table`,(l,s,r)=>{const{item:c,attributeNewValue:a}=s,{mapper:d,writer:u}=r;if(!r.consumable.consume(s.item,l.name))return;const h=[...d.toViewElement(c).getChildren()].find(m=>m.is("element","table"));a?u.setStyle(o,a,h):u.removeStyle(o,h)}))}function W(i,e,t){const o=t.modelRange&&We(t.modelRange.getItems({shallow:!0})),n=o&&o.is("element")&&o.findAncestor("table",{includeSelf:!0});return n&&n.getAttribute("tableType")==="layout"?e:i}function ne(i){if(!i)return;const e=["top","right","bottom","left"];if(!e.every(l=>i[l]))return i;const o=i.top;return e.every(l=>i[l]===o)?o:i}function _(i,e,t,o,n=1){e!=null&&n!==void 0&&n!==null&&e>n?o.setAttribute(i,e,t):o.removeAttribute(i,t)}function M(i,e,t={}){const o=i.createElement("tableCell",t);return i.insertElement("paragraph",o),i.insert(o,e),o}function ye(i,e){const t=e.parent.parent,o=parseInt(t.getAttribute("headingColumns")||"0"),{column:n}=i.getCellLocation(e);return!!o&&n<o}function le(i,e,t){const{modelAttribute:o}=t;i.extend("tableCell",{allowAttributes:[o]}),Fe(e,{viewElement:/^(td|th)$/,...t}),j(e,{modelElement:"tableCell",...t})}function L(i){const e=i.getSelectedElement();return e&&e.is("element","table")?e:i.getFirstPosition().findAncestor("table")}function zo(){return i=>{i.on("element:figure",(e,t,o)=>{if(!o.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const n=$o(t.viewItem);if(!n||!o.consumable.test(n,{name:!0}))return;o.consumable.consume(t.viewItem,{name:!0,classes:"table"});const l=o.convertItem(n,t.modelCursor),s=We(l.modelRange.getItems());if(!s){o.consumable.revert(t.viewItem,{name:!0,classes:"table"});return}o.convertChildren(t.viewItem,o.writer.createPositionAt(s,"end")),o.updateConversionResult(s,t)})}}function Ho(){return i=>{i.on("element:table",(e,t,o)=>{const n=t.viewItem;if(!o.consumable.test(n,{name:!0}))return;const{rows:l,headingRows:s,headingColumns:r}=Go(n),c={};r&&(c.headingColumns=r),s&&(c.headingRows=s);const a=o.writer.createElement("table",c);if(o.safeInsert(a,t.modelCursor)){if(o.consumable.consume(n,{name:!0}),l.forEach(d=>o.convertItem(d,o.writer.createPositionAt(a,"end"))),o.convertChildren(n,o.writer.createPositionAt(a,"end")),a.isEmpty){const d=o.writer.createElement("tableRow");o.writer.insert(d,o.writer.createPositionAt(a,"end")),M(o.writer,o.writer.createPositionAt(d,"end"))}o.updateConversionResult(a,t)}})}}function Uo(){return i=>{i.on("element:tr",(e,t)=>{t.viewItem.isEmpty&&t.modelCursor.index==0&&e.stop()},{priority:"high"})}}function qe(i){return e=>{e.on(`element:${i}`,(t,o,{writer:n})=>{if(!o.modelRange)return;const l=o.modelRange.start.nodeAfter,s=n.createPositionAt(l,0);if(o.viewItem.isEmpty){n.insertElement("paragraph",s);return}const r=Array.from(l.getChildren());if(r.every(c=>c.is("element","$marker"))){const c=n.createElement("paragraph");n.insert(c,n.createPositionAt(l,0));for(const a of r)n.move(n.createRangeOn(a),n.createPositionAt(c,"end"))}},{priority:"low"})}}function $o(i){for(const e of i.getChildren())if(e.is("element","table"))return e}function Go(i){let e=0,t;const o=[],n=[];let l;for(const s of Array.from(i.getChildren())){if(s.name!=="tbody"&&s.name!=="thead"&&s.name!=="tfoot")continue;s.name==="thead"&&!l&&(l=s);const r=Array.from(s.getChildren()).filter(a=>a.is("element","tr"));let c=null;for(const a of r){const d=Array.from(a.getChildren()).filter(u=>u.is("element","td")||u.is("element","th"));if(l&&s===l||s.name==="tbody"&&d.length>0&&(c===null||d.length===c)&&d.every(u=>u.is("element","th")))e++,o.push(a);else{n.push(a);const u=jo(a);(!t||u<t)&&(t=u)}c=Math.max(c||0,d.length)}}return{headingRows:e,headingColumns:t||0,rows:[...o,...n]}}function jo(i){let e=0,t=0;const o=Array.from(i.getChildren()).filter(n=>n.name==="th"||n.name==="td");for(;t<o.length&&o[t].name==="th";){const n=o[t],l=parseInt(n.getAttribute("colspan")||"1");e=e+l,t++}return e}/**
|
|
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
|
-
*/class T{constructor(t,e={}){g(this,"_table");g(this,"_startRow");g(this,"_endRow");g(this,"_startColumn");g(this,"_endColumn");g(this,"_includeAllSlots");g(this,"_skipRows");g(this,"_row");g(this,"_rowIndex");g(this,"_column");g(this,"_cellIndex");g(this,"_spannedCells");g(this,"_nextCellAtColumn");g(this,"_jumpedToStartRow",!1);this._table=t,this._startRow=e.row!==void 0?e.row:e.startRow||0,this._endRow=e.row!==void 0?e.row:e.endRow,this._startColumn=e.column!==void 0?e.column:e.startColumn||0,this._endColumn=e.column!==void 0?e.column:e.endColumn,this._includeAllSlots=!!e.includeAllSlots,this._skipRows=new Set,this._row=0,this._rowIndex=0,this._column=0,this._cellIndex=0,this._spannedCells=new Map,this._nextCellAtColumn=-1}[Symbol.iterator](){return this}next(){this._canJumpToStartRow()&&this._jumpToNonSpannedRowClosestToStartRow();const t=this._table.getChild(this._rowIndex);if(!t||this._isOverEndRow())return{done:!0,value:void 0};if(!t.is("element","tableRow"))return this._rowIndex++,this.next();if(this._isOverEndColumn())return this._advanceToNextRow();let e=null;const o=this._getSpanned();if(o)this._includeAllSlots&&!this._shouldSkipSlot()&&(e=this._formatOutValue(o.cell,o.row,o.column));else{const n=t.getChild(this._cellIndex);if(!n)return this._advanceToNextRow();const l=parseInt(n.getAttribute("colspan")||"1"),s=parseInt(n.getAttribute("rowspan")||"1");(l>1||s>1)&&this._recordSpans(n,s,l),this._shouldSkipSlot()||(e=this._formatOutValue(n)),this._nextCellAtColumn=this._column+l}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,e||this.next()}skipRow(t){this._skipRows.add(t)}_advanceToNextRow(){return this._row++,this._rowIndex++,this._column=0,this._cellIndex=0,this._nextCellAtColumn=-1,this.next()}_isOverEndRow(){return this._endRow!==void 0&&this._row>this._endRow}_isOverEndColumn(){return this._endColumn!==void 0&&this._column>this._endColumn}_formatOutValue(t,e=this._row,o=this._column){return{done:!1,value:new Yo(this,t,e,o)}}_shouldSkipSlot(){const t=this._skipRows.has(this._row),e=this._row<this._startRow,o=this._column<this._startColumn,n=this._endColumn!==void 0&&this._column>this._endColumn;return t||e||o||n}_getSpanned(){const t=this._spannedCells.get(this._row);return t&&t.get(this._column)||null}_recordSpans(t,e,o){const n={cell:t,row:this._row,column:this._column};for(let l=this._row;l<this._row+e;l++)for(let s=this._column;s<this._column+o;s++)(l!=this._row||s!=this._column)&&this._markSpannedCell(l,s,n)}_markSpannedCell(t,e,o){this._spannedCells.has(t)||this._spannedCells.set(t,new Map),this._spannedCells.get(t).set(e,o)}_canJumpToStartRow(){return!!this._startRow&&this._startRow>0&&!this._jumpedToStartRow}_jumpToNonSpannedRowClosestToStartRow(){const t=this._getRowLength(0);for(let e=this._startRow;!this._jumpedToStartRow;e--)t===this._getRowLength(e)&&(this._row=e,this._rowIndex=e,this._jumpedToStartRow=!0)}_getRowLength(t){return[...this._table.getChild(t).getChildren()].reduce((o,n)=>o+parseInt(n.getAttribute("colspan")||"1"),0)}}class Yo{constructor(t,e,o,n){g(this,"cell");g(this,"row");g(this,"column");g(this,"cellAnchorRow");g(this,"cellAnchorColumn");g(this,"_cellIndex");g(this,"_rowIndex");g(this,"_table");this.cell=e,this.row=t._row,this.column=t._column,this.cellAnchorRow=o,this.cellAnchorColumn=n,this._cellIndex=t._cellIndex,this._rowIndex=t._rowIndex,this._table=t._table}get isAnchor(){return this.row===this.cellAnchorRow&&this.column===this.cellAnchorColumn}get cellWidth(){return parseInt(this.cell.getAttribute("colspan")||"1")}get cellHeight(){return parseInt(this.cell.getAttribute("rowspan")||"1")}get rowIndex(){return this._rowIndex}getPositionBefore(){return this._table.root.document.model.createPositionAt(this._table.getChild(this.row),this._cellIndex)}}function Je(i,t){return(e,{writer:o})=>{const n=e.getAttribute("headingRows")||0,l=o.createContainerElement("table",null,[]),s=o.createContainerElement("figure",{class:"table"},l);n>0&&o.insert(o.createPositionAt(l,"end"),o.createContainerElement("thead",null,o.createSlot(r=>r.is("element","tableRow")&&r.index<n))),n<i.getRows(e)&&o.insert(o.createPositionAt(l,"end"),o.createContainerElement("tbody",null,o.createSlot(r=>r.is("element","tableRow")&&r.index>=n)));for(const{positionOffset:r,filter:a}of t.additionalSlots)o.insert(o.createPositionAt(l,r),o.createSlot(a));return o.insert(o.createPositionAt(l,"after"),o.createSlot(r=>r.is("element","tableRow")?!1:!t.additionalSlots.some(({filter:a})=>a(r)))),t.asWidget?Qo(s,o):s}}function Zo(){return(i,{writer:t})=>i.isEmpty?t.createEmptyElement("tr"):t.createContainerElement("tr")}function Ye(i={}){return(t,{writer:e})=>{const o=t.parent,n=o.parent,l=n.getChildIndex(o),s=new T(n,{row:l}),r=n.getAttribute("headingRows")||0,a=n.getAttribute("headingColumns")||0;let d=null;for(const c of s)if(c.cell==t){const h=c.row<r||c.column<a?"th":"td";d=i.asWidget?wt(e.createEditableElement(h),e,{withAriaRole:!1}):e.createContainerElement(h);break}return d}}function Ze(i={}){return(t,{writer:e})=>{if(!t.parent.is("element","tableCell")||!Pt(t))return null;if(i.asWidget)return e.createContainerElement("span",{class:"ck-table-bogus-paragraph"});{const o=e.createContainerElement("p");return e.setCustomProperty("dataPipeline:transparentRendering",!0,o),o}}}function Pt(i){return i.parent.childCount==1&&!en(i)}function Qo(i,t){return t.setCustomProperty("table",!0,i),uo(i,t,{hasSelectionHandle:!0})}function en(i){for(const t of i.getAttributeKeys())if(!(t.startsWith("selection:")||t=="htmlEmptyBlock"))return!0;return!1}class tn extends S{refresh(){const t=this.editor.model,e=t.document.selection,o=t.schema;this.isEnabled=on(e,o)}execute(t={}){const e=this.editor,o=e.model,n=e.plugins.get("TableUtils"),l=e.config.get("table.defaultHeadings.rows"),s=e.config.get("table.defaultHeadings.columns");t.headingRows===void 0&&l&&(t.headingRows=l),t.headingColumns===void 0&&s&&(t.headingColumns=s),o.change(r=>{const a=n.createTable(r,t);o.insertObject(a,null,null,{findOptimalPosition:"auto"}),r.setSelection(r.createPositionAt(a.getNodeByPath([0,0,0]),0))})}}function on(i,t){const e=i.getFirstPosition().parent,o=e===e.root?e:e.parent;return t.checkChild(o,"table")}class Qe extends S{constructor(e,o={}){super(e);g(this,"order");this.order=o.order||"below"}refresh(){const e=this.editor.model.document.selection,n=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=n}execute(){const e=this.editor,o=e.model.document.selection,n=e.plugins.get("TableUtils"),l=this.order==="above",s=n.getSelectionAffectedTableCells(o),r=n.getRowIndexes(s),a=l?r.first:r.last,d=s[0].findAncestor("table");n.insertRows(d,{at:l?a:a+1,copyStructureFromAbove:!l})}}class et extends S{constructor(e,o={}){super(e);g(this,"order");this.order=o.order||"right"}refresh(){const e=this.editor.model.document.selection,n=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=n}execute(){const e=this.editor,o=e.model.document.selection,n=e.plugins.get("TableUtils"),l=this.order==="left",s=n.getSelectionAffectedTableCells(o),r=n.getColumnIndexes(s),a=l?r.first:r.last,d=s[0].findAncestor("table");n.insertColumns(d,{columns:1,at:l?a:a+1})}}class tt extends S{constructor(e,o={}){super(e);g(this,"direction");this.direction=o.direction||"horizontally"}refresh(){const o=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=o.length===1}execute(){const e=this.editor.plugins.get("TableUtils"),o=e.getSelectionAffectedTableCells(this.editor.model.document.selection)[0];this.direction==="horizontally"?e.splitCellHorizontally(o,2):e.splitCellVertically(o,2)}}function Et(i,t,e){const{startRow:o,startColumn:n,endRow:l,endColumn:s}=t,r=e.createElement("table"),a=i.getAttribute("tableType");a&&e.setAttribute("tableType",a,r);const d=l-o+1;for(let u=0;u<d;u++)e.insertElement("tableRow",r,"end");const c=[...new T(i,{startRow:o,endRow:l,startColumn:n,endColumn:s,includeAllSlots:!0})];for(const{row:u,column:h,cell:m,isAnchor:p,cellAnchorRow:b,cellAnchorColumn:w}of c){const f=u-o,C=r.getChild(f);if(!p)(b<o||w<n)&&z(e,e.createPositionAt(C,"end"));else{const _=e.cloneElement(m);e.append(_,C),Ft(_,u,h,l,s,e)}}return nn(r,i,o,n,e),r}function Wt(i,t,e=0){const o=[],n=new T(i,{startRow:e,endRow:t-1});for(const l of n){const{row:s,cellHeight:r}=l,a=s+r-1;s<t&&t<=a&&o.push(l)}return o}function Lt(i,t,e){const o=i.parent,n=o.parent,l=o.index,s=parseInt(i.getAttribute("rowspan")),r=t-l,a={},d=s-r;d>1&&(a.rowspan=d);const c=parseInt(i.getAttribute("colspan")||"1");c>1&&(a.colspan=c);const u=l,h=u+r,m=[...new T(n,{startRow:u,endRow:h,includeAllSlots:!0})];let p=null,b;for(const w of m){const{row:f,column:C,cell:_}=w;_===i&&b===void 0&&(b=C),b!==void 0&&b===C&&f===h&&(p=z(e,w.getPositionBefore(),a))}return y("rowspan",r,i,e),p}function Bt(i,t){const e=[],o=new T(i);for(const n of o){const{column:l,cellWidth:s}=n,r=l+s-1;l<t&&t<=r&&e.push(n)}return e}function Dt(i,t,e,o){const n=parseInt(i.getAttribute("colspan")),l=e-t,s={},r=n-l;r>1&&(s.colspan=r);const a=parseInt(i.getAttribute("rowspan")||"1");a>1&&(s.rowspan=a);const d=z(o,o.createPositionAfter(i),s);return y("colspan",l,i,o),d}function Ft(i,t,e,o,n,l){const s=parseInt(i.getAttribute("colspan")||"1"),r=parseInt(i.getAttribute("rowspan")||"1");if(e+s-1>n){const c=n-e+1;y("colspan",c,i,l,1)}if(t+r-1>o){const c=o-t+1;y("rowspan",c,i,l,1)}}function nn(i,t,e,o,n){const l=parseInt(t.getAttribute("headingRows")||"0");if(l>0){const r=l-e;y("headingRows",r,i,n,0)}const s=parseInt(t.getAttribute("headingColumns")||"0");if(s>0){const r=s-o;y("headingColumns",r,i,n,0)}}function Ae(i,t){const e=t.getColumns(i),o=new Array(e).fill(0);for(const{column:l}of new T(i))o[l]++;const n=o.reduce((l,s,r)=>s?l:[...l,r],[]);if(n.length>0){const l=n[n.length-1];return t.removeColumns(i,{at:l}),!0}return!1}function Se(i,t){const e=[],o=t.getRows(i);for(let n=0;n<o;n++)i.getChild(n).isEmpty&&e.push(n);if(e.length>0){const n=e[e.length-1];return t.removeRows(i,{at:n}),!0}return!1}function Me(i,t){Ae(i,t)||Se(i,t)}function Nt(i,t){const e=Array.from(new T(i,{startColumn:t.firstColumn,endColumn:t.lastColumn,row:t.lastRow}));if(e.every(({cellHeight:l})=>l===1))return t.lastRow;const n=e[0].cellHeight-1;return t.lastRow+n}function Mt(i,t){const e=Array.from(new T(i,{startRow:t.firstRow,endRow:t.lastRow,column:t.lastColumn}));if(e.every(({cellWidth:l})=>l===1))return t.lastColumn;const n=e[0].cellWidth-1;return t.lastColumn+n}class Q extends S{constructor(e,o){super(e);g(this,"direction");g(this,"isHorizontal");this.direction=o.direction,this.isHorizontal=this.direction=="right"||this.direction=="left"}refresh(){const e=this._getMergeableCell();this.value=e,this.isEnabled=!!e}execute(){const e=this.editor.model,o=e.document,l=this.editor.plugins.get("TableUtils").getTableCellsContainingSelection(o.selection)[0],s=this.value,r=this.direction;e.change(a=>{const d=r=="right"||r=="down",c=d?l:s,u=d?s:l,h=u.parent;rn(u,c,a);const m=this.isHorizontal?"colspan":"rowspan",p=parseInt(l.getAttribute(m)||"1"),b=parseInt(s.getAttribute(m)||"1");a.setAttribute(m,p+b,c),a.setSelection(a.createRangeIn(c));const w=this.editor.plugins.get("TableUtils"),f=h.findAncestor("table");Me(f,w)})}_getMergeableCell(){const o=this.editor.model.document,n=this.editor.plugins.get("TableUtils"),l=n.getTableCellsContainingSelection(o.selection)[0];if(!l)return;const s=this.isHorizontal?ln(l,this.direction,n):sn(l,this.direction,n);if(!s)return;const r=this.isHorizontal?"rowspan":"colspan",a=parseInt(l.getAttribute(r)||"1");if(parseInt(s.getAttribute(r)||"1")===a)return s}}function ln(i,t,e){const n=i.parent.parent,l=t=="right"?i.nextSibling:i.previousSibling,s=(n.getAttribute("headingColumns")||0)>0;if(!l)return;const r=t=="right"?i:l,a=t=="right"?l:i,{column:d}=e.getCellLocation(r),{column:c}=e.getCellLocation(a),u=parseInt(r.getAttribute("colspan")||"1"),h=ve(e,r),m=ve(e,a);return s&&h!=m?void 0:d+u===c?l:void 0}function sn(i,t,e){const o=i.parent,n=o.parent,l=n.getChildIndex(o);if(t=="down"&&l===e.getRows(n)-1||t=="up"&&l===0)return null;const s=parseInt(i.getAttribute("rowspan")||"1"),r=n.getAttribute("headingRows")||0,a=t=="down"&&l+s===r,d=t=="up"&&l===r;if(r&&(a||d))return null;const c=parseInt(i.getAttribute("rowspan")||"1"),u=t=="down"?l+c:l,h=[...new T(n,{endRow:u})],p=h.find(w=>w.cell===i).column,b=h.find(({row:w,cellHeight:f,column:C})=>C!==p?!1:t=="down"?w===u:u===w+f);return b&&b.cell?b.cell:null}function rn(i,t,e){ot(i)||(ot(t)&&e.remove(e.createRangeIn(t)),e.move(e.createRangeIn(i),e.createPositionAt(t,"end"))),e.remove(i)}function ot(i){const t=i.getChild(0);return i.childCount==1&&t.is("element","paragraph")&&t.isEmpty}class an extends S{refresh(){const t=this.editor.plugins.get("TableUtils"),e=t.getSelectionAffectedTableCells(this.editor.model.document.selection),o=e[0];if(o){const n=o.findAncestor("table"),s=t.getRows(n)-1,r=t.getRowIndexes(e),a=r.first===0&&r.last===s;this.isEnabled=!a}else this.isEnabled=!1}execute(){const t=this.editor.model,e=this.editor.plugins.get("TableUtils"),o=e.getSelectionAffectedTableCells(t.document.selection),n=e.getRowIndexes(o),l=o[0],s=l.findAncestor("table"),r=e.getCellLocation(l).column;t.change(a=>{const d=n.last-n.first+1;e.removeRows(s,{at:n.first,rows:d});const c=cn(s,n.first,r,e.getRows(s));a.setSelection(a.createPositionAt(c,0))})}}function cn(i,t,e,o){const n=i.getChild(Math.min(t,o-1));let l=n.getChild(0),s=0;for(const r of n.getChildren()){if(s>e)return l;l=r,s+=parseInt(r.getAttribute("colspan")||"1")}return l}class dn extends S{refresh(){const t=this.editor.plugins.get("TableUtils"),e=t.getSelectionAffectedTableCells(this.editor.model.document.selection),o=e[0];if(o){const n=o.findAncestor("table"),l=t.getColumns(n),{first:s,last:r}=t.getColumnIndexes(e);this.isEnabled=r-s<l-1}else this.isEnabled=!1}execute(){const t=this.editor.plugins.get("TableUtils"),[e,o]=hn(this.editor.model.document.selection,t),n=e.parent.parent,l=[...new T(n)],s={first:l.find(a=>a.cell===e).column,last:l.find(a=>a.cell===o).column},r=un(l,e,o,s);this.editor.model.change(a=>{const d=s.last-s.first+1;t.removeColumns(n,{at:s.first,columns:d}),a.setSelection(a.createPositionAt(r,0))})}}function un(i,t,e,o){return parseInt(e.getAttribute("colspan")||"1")>1?e:t.previousSibling||e.nextSibling?e.nextSibling||t.previousSibling:o.first?i.reverse().find(({column:l})=>l<o.first).cell:i.reverse().find(({column:l})=>l>o.last).cell}function hn(i,t){const e=t.getSelectionAffectedTableCells(i),o=e[0],n=e.pop(),l=[o,n];return o.isBefore(n)?l:l.reverse()}class mn extends S{refresh(){const t=this.editor.plugins.get("TableUtils"),e=this.editor.model,o=t.getSelectionAffectedTableCells(e.document.selection);if(o.length===0){this.isEnabled=!1,this.value=!1;return}const n=o[0].findAncestor("table");this.isEnabled=e.schema.checkAttribute(n,"headingRows"),this.value=o.every(l=>this._isInHeading(l,l.parent.parent))}execute(t={}){if(t.forceValue===this.value)return;const e=this.editor.plugins.get("TableUtils"),o=this.editor.model,n=e.getSelectionAffectedTableCells(o.document.selection),l=n[0].findAncestor("table"),{first:s,last:r}=e.getRowIndexes(n),a=this.value?s:r+1,d=l.getAttribute("headingRows")||0;o.change(c=>{if(a){const u=a>d?d:0,h=Wt(l,a,u);for(const{cell:m}of h)Lt(m,a,c)}y("headingRows",a,l,c,0)})}_isInHeading(t,e){const o=parseInt(e.getAttribute("headingRows")||"0");return!!o&&t.parent.index<o}}class gn extends S{refresh(){const t=this.editor.plugins.get("TableUtils"),e=this.editor.model,o=t.getSelectionAffectedTableCells(e.document.selection);if(o.length===0){this.isEnabled=!1,this.value=!1;return}const n=o[0].findAncestor("table");this.isEnabled=e.schema.checkAttribute(n,"headingColumns"),this.value=o.every(l=>ve(t,l))}execute(t={}){if(t.forceValue===this.value)return;const e=this.editor.plugins.get("TableUtils"),o=this.editor.model,n=e.getSelectionAffectedTableCells(o.document.selection),l=n[0].findAncestor("table"),{first:s,last:r}=e.getColumnIndexes(n),a=this.value?s:r+1;o.change(d=>{if(a){const c=Bt(l,a);for(const{cell:u,column:h}of c)Dt(u,h,a,d)}y("headingColumns",a,l,d,0)})}}/**
|
|
7
|
+
*/class C{_table;_startRow;_endRow;_startColumn;_endColumn;_includeAllSlots;_skipRows;_row;_rowIndex;_column;_cellIndex;_spannedCells;_nextCellAtColumn;_jumpedToStartRow=!1;constructor(e,t={}){this._table=e,this._startRow=t.row!==void 0?t.row:t.startRow||0,this._endRow=t.row!==void 0?t.row:t.endRow,this._startColumn=t.column!==void 0?t.column:t.startColumn||0,this._endColumn=t.column!==void 0?t.column:t.endColumn,this._includeAllSlots=!!t.includeAllSlots,this._skipRows=new Set,this._row=0,this._rowIndex=0,this._column=0,this._cellIndex=0,this._spannedCells=new Map,this._nextCellAtColumn=-1}[Symbol.iterator](){return this}next(){this._canJumpToStartRow()&&this._jumpToNonSpannedRowClosestToStartRow();const e=this._table.getChild(this._rowIndex);if(!e||this._isOverEndRow())return{done:!0,value:void 0};if(!e.is("element","tableRow"))return this._rowIndex++,this.next();if(this._isOverEndColumn())return this._advanceToNextRow();let t=null;const o=this._getSpanned();if(o)this._includeAllSlots&&!this._shouldSkipSlot()&&(t=this._formatOutValue(o.cell,o.row,o.column));else{const n=e.getChild(this._cellIndex);if(!n)return this._advanceToNextRow();const l=parseInt(n.getAttribute("colspan")||"1"),s=parseInt(n.getAttribute("rowspan")||"1");(l>1||s>1)&&this._recordSpans(n,s,l),this._shouldSkipSlot()||(t=this._formatOutValue(n)),this._nextCellAtColumn=this._column+l}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,t||this.next()}skipRow(e){this._skipRows.add(e)}_advanceToNextRow(){return this._row++,this._rowIndex++,this._column=0,this._cellIndex=0,this._nextCellAtColumn=-1,this.next()}_isOverEndRow(){return this._endRow!==void 0&&this._row>this._endRow}_isOverEndColumn(){return this._endColumn!==void 0&&this._column>this._endColumn}_formatOutValue(e,t=this._row,o=this._column){return{done:!1,value:new Ko(this,e,t,o)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._row<this._startRow,o=this._column<this._startColumn,n=this._endColumn!==void 0&&this._column>this._endColumn;return e||t||o||n}_getSpanned(){const e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,o){const n={cell:e,row:this._row,column:this._column};for(let l=this._row;l<this._row+t;l++)for(let s=this._column;s<this._column+o;s++)(l!=this._row||s!=this._column)&&this._markSpannedCell(l,s,n)}_markSpannedCell(e,t,o){this._spannedCells.has(e)||this._spannedCells.set(e,new Map),this._spannedCells.get(e).set(t,o)}_canJumpToStartRow(){return!!this._startRow&&this._startRow>0&&!this._jumpedToStartRow}_jumpToNonSpannedRowClosestToStartRow(){const e=this._getRowLength(0);for(let t=this._startRow;!this._jumpedToStartRow;t--)e===this._getRowLength(t)&&(this._row=t,this._rowIndex=t,this._jumpedToStartRow=!0)}_getRowLength(e){return[...this._table.getChild(e).getChildren()].reduce((o,n)=>o+parseInt(n.getAttribute("colspan")||"1"),0)}}class Ko{cell;row;column;cellAnchorRow;cellAnchorColumn;_cellIndex;_rowIndex;_table;constructor(e,t,o,n){this.cell=t,this.row=e._row,this.column=e._column,this.cellAnchorRow=o,this.cellAnchorColumn=n,this._cellIndex=e._cellIndex,this._rowIndex=e._rowIndex,this._table=e._table}get isAnchor(){return this.row===this.cellAnchorRow&&this.column===this.cellAnchorColumn}get cellWidth(){return parseInt(this.cell.getAttribute("colspan")||"1")}get cellHeight(){return parseInt(this.cell.getAttribute("rowspan")||"1")}get rowIndex(){return this._rowIndex}getPositionBefore(){return this._table.root.document.model.createPositionAt(this._table.getChild(this.row),this._cellIndex)}}function Xe(i,e){return(t,{writer:o})=>{const n=t.getAttribute("headingRows")||0,l=o.createContainerElement("table",null,[]),s=o.createContainerElement("figure",{class:"table"},l);n>0&&o.insert(o.createPositionAt(l,"end"),o.createContainerElement("thead",null,o.createSlot(r=>r.is("element","tableRow")&&r.index<n))),n<i.getRows(t)&&o.insert(o.createPositionAt(l,"end"),o.createContainerElement("tbody",null,o.createSlot(r=>r.is("element","tableRow")&&r.index>=n)));for(const{positionOffset:r,filter:c}of e.additionalSlots)o.insert(o.createPositionAt(l,r),o.createSlot(c));return o.insert(o.createPositionAt(l,"after"),o.createSlot(r=>r.is("element","tableRow")?!1:!e.additionalSlots.some(({filter:c})=>c(r)))),e.asWidget?Xo(s,o):s}}function qo(){return(i,{writer:e})=>i.isEmpty?e.createEmptyElement("tr"):e.createContainerElement("tr")}function Je(i={}){return(e,{writer:t})=>{const o=e.parent,n=o.parent,l=n.getChildIndex(o),s=new C(n,{row:l}),r=n.getAttribute("headingRows")||0,c=n.getAttribute("headingColumns")||0;let a=null;for(const d of s)if(d.cell==e){const h=d.row<r||d.column<c?"th":"td";a=i.asWidget?pt(t.createEditableElement(h),t,{withAriaRole:!1}):t.createContainerElement(h);break}return a}}function Ye(i={}){return(e,{writer:t})=>{if(!e.parent.is("element","tableCell")||!Vt(e))return null;if(i.asWidget)return t.createContainerElement("span",{class:"ck-table-bogus-paragraph"});{const o=t.createContainerElement("p");return t.setCustomProperty("dataPipeline:transparentRendering",!0,o),o}}}function Vt(i){return i.parent.childCount==1&&!Jo(i)}function Xo(i,e){return e.setCustomProperty("table",!0,i),so(i,e,{hasSelectionHandle:!0})}function Jo(i){for(const e of i.getAttributeKeys())if(!(e.startsWith("selection:")||e=="htmlEmptyBlock"))return!0;return!1}class Yo extends A{refresh(){const e=this.editor.model,t=e.document.selection,o=e.schema;this.isEnabled=Zo(t,o)}execute(e={}){const t=this.editor,o=t.model,n=t.plugins.get("TableUtils"),l=t.config.get("table.defaultHeadings.rows"),s=t.config.get("table.defaultHeadings.columns");e.headingRows===void 0&&l&&(e.headingRows=l),e.headingColumns===void 0&&s&&(e.headingColumns=s),o.change(r=>{const c=n.createTable(r,e);o.insertObject(c,null,null,{findOptimalPosition:"auto"}),r.setSelection(r.createPositionAt(c.getNodeByPath([0,0,0]),0))})}}function Zo(i,e){const t=i.getFirstPosition().parent,o=t===t.root?t:t.parent;return e.checkChild(o,"table")}class Ze extends A{order;constructor(e,t={}){super(e),this.order=t.order||"below"}refresh(){const e=this.editor.model.document.selection,o=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=o}execute(){const e=this.editor,t=e.model.document.selection,o=e.plugins.get("TableUtils"),n=this.order==="above",l=o.getSelectionAffectedTableCells(t),s=o.getRowIndexes(l),r=n?s.first:s.last,c=l[0].findAncestor("table");o.insertRows(c,{at:n?r:r+1,copyStructureFromAbove:!n})}}class Qe extends A{order;constructor(e,t={}){super(e),this.order=t.order||"right"}refresh(){const e=this.editor.model.document.selection,o=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=o}execute(){const e=this.editor,t=e.model.document.selection,o=e.plugins.get("TableUtils"),n=this.order==="left",l=o.getSelectionAffectedTableCells(t),s=o.getColumnIndexes(l),r=n?s.first:s.last,c=l[0].findAncestor("table");o.insertColumns(c,{columns:1,at:n?r:r+1})}}class et extends A{direction;constructor(e,t={}){super(e),this.direction=t.direction||"horizontally"}refresh(){const t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=t.length===1}execute(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection)[0];this.direction==="horizontally"?e.splitCellHorizontally(t,2):e.splitCellVertically(t,2)}}function Pt(i,e,t){const{startRow:o,startColumn:n,endRow:l,endColumn:s}=e,r=t.createElement("table"),c=i.getAttribute("tableType");c&&t.setAttribute("tableType",c,r);const a=l-o+1;for(let u=0;u<a;u++)t.insertElement("tableRow",r,"end");const d=[...new C(i,{startRow:o,endRow:l,startColumn:n,endColumn:s,includeAllSlots:!0})];for(const{row:u,column:h,cell:m,isAnchor:g,cellAnchorRow:f,cellAnchorColumn:b}of d){const p=u-o,w=r.getChild(p);if(!g)(f<o||b<n)&&M(t,t.createPositionAt(w,"end"));else{const T=t.cloneElement(m);t.append(T,w),Dt(T,u,h,l,s,t)}}return Qo(r,i,o,n,t),r}function Et(i,e,t=0){const o=[],n=new C(i,{startRow:t,endRow:e-1});for(const l of n){const{row:s,cellHeight:r}=l,c=s+r-1;s<e&&e<=c&&o.push(l)}return o}function Wt(i,e,t){const o=i.parent,n=o.parent,l=o.index,s=parseInt(i.getAttribute("rowspan")),r=e-l,c={},a=s-r;a>1&&(c.rowspan=a);const d=parseInt(i.getAttribute("colspan")||"1");d>1&&(c.colspan=d);const u=l,h=u+r,m=[...new C(n,{startRow:u,endRow:h,includeAllSlots:!0})];let g=null,f;for(const b of m){const{row:p,column:w,cell:T}=b;T===i&&f===void 0&&(f=w),f!==void 0&&f===w&&p===h&&(g=M(t,b.getPositionBefore(),c))}return _("rowspan",r,i,t),g}function Lt(i,e){const t=[],o=new C(i);for(const n of o){const{column:l,cellWidth:s}=n,r=l+s-1;l<e&&e<=r&&t.push(n)}return t}function Bt(i,e,t,o){const n=parseInt(i.getAttribute("colspan")),l=t-e,s={},r=n-l;r>1&&(s.colspan=r);const c=parseInt(i.getAttribute("rowspan")||"1");c>1&&(s.rowspan=c);const a=M(o,o.createPositionAfter(i),s);return _("colspan",l,i,o),a}function Dt(i,e,t,o,n,l){const s=parseInt(i.getAttribute("colspan")||"1"),r=parseInt(i.getAttribute("rowspan")||"1");if(t+s-1>n){const d=n-t+1;_("colspan",d,i,l,1)}if(e+r-1>o){const d=o-e+1;_("rowspan",d,i,l,1)}}function Qo(i,e,t,o,n){const l=parseInt(e.getAttribute("headingRows")||"0");if(l>0){const r=l-t;_("headingRows",r,i,n,0)}const s=parseInt(e.getAttribute("headingColumns")||"0");if(s>0){const r=s-o;_("headingColumns",r,i,n,0)}}function ve(i,e){const t=e.getColumns(i),o=new Array(t).fill(0);for(const{column:l}of new C(i))o[l]++;const n=o.reduce((l,s,r)=>s?l:[...l,r],[]);if(n.length>0){const l=n[n.length-1];return e.removeColumns(i,{at:l}),!0}return!1}function Ae(i,e){const t=[],o=e.getRows(i);for(let n=0;n<o;n++)i.getChild(n).isEmpty&&t.push(n);if(t.length>0){const n=t[t.length-1];return e.removeRows(i,{at:n}),!0}return!1}function Ne(i,e){ve(i,e)||Ae(i,e)}function Ft(i,e){const t=Array.from(new C(i,{startColumn:e.firstColumn,endColumn:e.lastColumn,row:e.lastRow}));if(t.every(({cellHeight:l})=>l===1))return e.lastRow;const n=t[0].cellHeight-1;return e.lastRow+n}function Nt(i,e){const t=Array.from(new C(i,{startRow:e.firstRow,endRow:e.lastRow,column:e.lastColumn}));if(t.every(({cellWidth:l})=>l===1))return e.lastColumn;const n=t[0].cellWidth-1;return e.lastColumn+n}class Z extends A{direction;isHorizontal;constructor(e,t){super(e),this.direction=t.direction,this.isHorizontal=this.direction=="right"||this.direction=="left"}refresh(){const e=this._getMergeableCell();this.value=e,this.isEnabled=!!e}execute(){const e=this.editor.model,t=e.document,n=this.editor.plugins.get("TableUtils").getTableCellsContainingSelection(t.selection)[0],l=this.value,s=this.direction;e.change(r=>{const c=s=="right"||s=="down",a=c?n:l,d=c?l:n,u=d.parent;on(d,a,r);const h=this.isHorizontal?"colspan":"rowspan",m=parseInt(n.getAttribute(h)||"1"),g=parseInt(l.getAttribute(h)||"1");r.setAttribute(h,m+g,a),r.setSelection(r.createRangeIn(a));const f=this.editor.plugins.get("TableUtils"),b=u.findAncestor("table");Ne(b,f)})}_getMergeableCell(){const t=this.editor.model.document,o=this.editor.plugins.get("TableUtils"),n=o.getTableCellsContainingSelection(t.selection)[0];if(!n)return;const l=this.isHorizontal?en(n,this.direction,o):tn(n,this.direction,o);if(!l)return;const s=this.isHorizontal?"rowspan":"colspan",r=parseInt(n.getAttribute(s)||"1");if(parseInt(l.getAttribute(s)||"1")===r)return l}}function en(i,e,t){const n=i.parent.parent,l=e=="right"?i.nextSibling:i.previousSibling,s=(n.getAttribute("headingColumns")||0)>0;if(!l)return;const r=e=="right"?i:l,c=e=="right"?l:i,{column:a}=t.getCellLocation(r),{column:d}=t.getCellLocation(c),u=parseInt(r.getAttribute("colspan")||"1"),h=ye(t,r),m=ye(t,c);return s&&h!=m?void 0:a+u===d?l:void 0}function tn(i,e,t){const o=i.parent,n=o.parent,l=n.getChildIndex(o);if(e=="down"&&l===t.getRows(n)-1||e=="up"&&l===0)return null;const s=parseInt(i.getAttribute("rowspan")||"1"),r=n.getAttribute("headingRows")||0,c=e=="down"&&l+s===r,a=e=="up"&&l===r;if(r&&(c||a))return null;const d=parseInt(i.getAttribute("rowspan")||"1"),u=e=="down"?l+d:l,h=[...new C(n,{endRow:u})],g=h.find(b=>b.cell===i).column,f=h.find(({row:b,cellHeight:p,column:w})=>w!==g?!1:e=="down"?b===u:u===b+p);return f&&f.cell?f.cell:null}function on(i,e,t){tt(i)||(tt(e)&&t.remove(t.createRangeIn(e)),t.move(t.createRangeIn(i),t.createPositionAt(e,"end"))),t.remove(i)}function tt(i){const e=i.getChild(0);return i.childCount==1&&e.is("element","paragraph")&&e.isEmpty}class nn extends A{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),o=t[0];if(o){const n=o.findAncestor("table"),s=e.getRows(n)-1,r=e.getRowIndexes(t),c=r.first===0&&r.last===s;this.isEnabled=!c}else this.isEnabled=!1}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),o=t.getSelectionAffectedTableCells(e.document.selection),n=t.getRowIndexes(o),l=o[0],s=l.findAncestor("table"),r=t.getCellLocation(l).column;e.change(c=>{const a=n.last-n.first+1;t.removeRows(s,{at:n.first,rows:a});const d=ln(s,n.first,r,t.getRows(s));c.setSelection(c.createPositionAt(d,0))})}}function ln(i,e,t,o){const n=i.getChild(Math.min(e,o-1));let l=n.getChild(0),s=0;for(const r of n.getChildren()){if(s>t)return l;l=r,s+=parseInt(r.getAttribute("colspan")||"1")}return l}class sn extends A{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),o=t[0];if(o){const n=o.findAncestor("table"),l=e.getColumns(n),{first:s,last:r}=e.getColumnIndexes(t);this.isEnabled=r-s<l-1}else this.isEnabled=!1}execute(){const e=this.editor.plugins.get("TableUtils"),[t,o]=an(this.editor.model.document.selection,e),n=t.parent.parent,l=[...new C(n)],s={first:l.find(c=>c.cell===t).column,last:l.find(c=>c.cell===o).column},r=rn(l,t,o,s);this.editor.model.change(c=>{const a=s.last-s.first+1;e.removeColumns(n,{at:s.first,columns:a}),c.setSelection(c.createPositionAt(r,0))})}}function rn(i,e,t,o){return parseInt(t.getAttribute("colspan")||"1")>1?t:e.previousSibling||t.nextSibling?t.nextSibling||e.previousSibling:o.first?i.reverse().find(({column:l})=>l<o.first).cell:i.reverse().find(({column:l})=>l>o.last).cell}function an(i,e){const t=e.getSelectionAffectedTableCells(i),o=t[0],n=t.pop(),l=[o,n];return o.isBefore(n)?l:l.reverse()}class cn extends A{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,o=e.getSelectionAffectedTableCells(t.document.selection);if(o.length===0){this.isEnabled=!1,this.value=!1;return}const n=o[0].findAncestor("table");this.isEnabled=t.schema.checkAttribute(n,"headingRows"),this.value=o.every(l=>this._isInHeading(l,l.parent.parent))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),o=this.editor.model,n=t.getSelectionAffectedTableCells(o.document.selection),l=n[0].findAncestor("table"),{first:s,last:r}=t.getRowIndexes(n),c=this.value?s:r+1,a=l.getAttribute("headingRows")||0;o.change(d=>{if(c){const u=c>a?a:0,h=Et(l,c,u);for(const{cell:m}of h)Wt(m,c,d)}_("headingRows",c,l,d,0)})}_isInHeading(e,t){const o=parseInt(t.getAttribute("headingRows")||"0");return!!o&&e.parent.index<o}}class dn extends A{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,o=e.getSelectionAffectedTableCells(t.document.selection);if(o.length===0){this.isEnabled=!1,this.value=!1;return}const n=o[0].findAncestor("table");this.isEnabled=t.schema.checkAttribute(n,"headingColumns"),this.value=o.every(l=>ye(e,l))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),o=this.editor.model,n=t.getSelectionAffectedTableCells(o.document.selection),l=n[0].findAncestor("table"),{first:s,last:r}=t.getColumnIndexes(n),c=this.value?s:r+1;o.change(a=>{if(c){const d=Lt(l,c);for(const{cell:u,column:h}of d)Bt(u,h,c,a)}_("headingColumns",c,l,a,0)})}}/**
|
|
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
|
-
*/const bn=5,Re=40,fn=2,pn=3;function wn(i){const t=new Set;for(const e of i.document.differ.getChanges()){let o=null;switch(e.type){case"insert":o=["table","tableRow","tableCell"].includes(e.name)?e.position:null;break;case"remove":o=["tableRow","tableCell"].includes(e.name)?e.position:null;break;case"attribute":e.range.start.nodeAfter&&(o=["table","tableRow","tableCell"].includes(e.range.start.nodeAfter.name)?e.range.start:null);break}if(!o)continue;const n=o.nodeAfter&&o.nodeAfter.is("element","table")?o.nodeAfter:o.findAncestor("table");for(const l of i.createRangeOn(n).getItems())l.is("element","table")&&J(l)&&t.add(l)}return t}function Cn(i,t){return Re*100/Ot(i,t)}function Ot(i,t){const e=nt(i,"tbody",t)||nt(i,"thead",t),o=t.editing.view.domConverter.mapViewToDom(e);return Ie(o)}function nt(i,t,e){return[...[...e.editing.mapper.toViewElement(i).getChildren()].find(l=>l.is("element","table")).getChildren()].find(l=>l.is("element",t))}function Ie(i){const t=se.window.getComputedStyle(i);return t.boxSizing==="border-box"?parseFloat(t.width)-parseFloat(t.paddingLeft)-parseFloat(t.paddingRight)-parseFloat(t.borderLeftWidth)-parseFloat(t.borderRightWidth):parseFloat(t.width)}function Tn(i,t){const e=t.getCellLocation(i).column,o=i.getAttribute("colspan")||1;return{leftEdge:e,rightEdge:e+o-1}}function I(i){const t=Math.pow(10,fn),e=typeof i=="number"?i:parseFloat(i);return Math.round(e*t)/t}function _n(i,t,e){return i<=t?I(t):i>=e?I(e):I(i)}function yn(i,t){return Array(i).fill(t)}function X(i){return i.map(t=>typeof t=="number"?t:parseFloat(t)).filter(t=>!Number.isNaN(t)).reduce((t,e)=>t+e,0)}function Oe(i){const t=i.map(n=>n==="auto"?n:parseFloat(n.replace("%","")));let e=vn(t);const o=X(e);return o!==100&&(e=e.map(n=>I(n*100/o)).map((n,l,s)=>{if(!(l===s.length-1))return n;const a=X(s);return I(n+100-a)})),e.map(n=>n+"%")}function vn(i){const t=i.filter(n=>n==="auto").length;if(t===0)return i.map(n=>I(n));const e=X(i),o=Math.max((100-e)/t,bn);return i.map(n=>n==="auto"?o:n).map(n=>I(n))}function An(i){const t=se.window.getComputedStyle(i);return t.boxSizing==="border-box"?parseInt(t.width):parseFloat(t.width)+parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)+parseFloat(t.borderWidth)}function zt(i,t,e,o){for(let n=0;n<Math.max(e.length,i.length);n++){const l=i[n],s=e[n];s?l?o.setAttribute("columnWidth",s,l):o.appendElement("tableColumn",{columnWidth:s},t):o.remove(l)}}function J(i){if(i.is("element","tableColumnGroup"))return i;const t=i.getChildren();return Array.from(t).find(e=>e.is("element","tableColumnGroup"))}function Y(i){const t=J(i);return t?Array.from(t.getChildren()):[]}function Sn(i){return Y(i).map(t=>t.getAttribute("columnWidth"))}function Rn(i,t){return Y(i).reduce((o,n)=>{const l=n.getAttribute("columnWidth"),s=n.getAttribute("colSpan");if(!s)return o.push(l),o;for(let r=0;r<s;r++)o.push(l);return t.removeAttribute("colSpan",n),o},[])}class A extends v{static get pluginName(){return"TableUtils"}static get isOfficialPlugin(){return!0}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(t){const e=t.parent,o=e.parent,n=o.getChildIndex(e),l=new T(o,{row:n});for(const{cell:s,row:r,column:a}of l)if(s===t)return{row:r,column:a};/* istanbul ignore next -- @preserve */}createTable(t,e){const o=t.createElement("table"),n=e.rows||2,l=e.columns||2;return Te(t,o,0,n,l),e.headingRows&&y("headingRows",Math.min(e.headingRows,n),o,t,0),e.headingColumns&&y("headingColumns",Math.min(e.headingColumns,l),o,t,0),o}insertRows(t,e={}){const o=this.editor.model,n=e.at||0,l=e.rows||1,s=e.copyStructureFromAbove!==void 0,r=e.copyStructureFromAbove?n-1:n,a=this.getRows(t),d=this.getColumns(t);if(n>a)throw new Ge("tableutils-insertrows-insert-out-of-range",this,{options:e});o.change(c=>{const u=t.getAttribute("headingRows")||0;if(u>n&&y("headingRows",u+l,t,c,0),!s&&(n===0||n===a)){Te(c,t,n,l,d);return}const h=s?Math.max(n,r):n,m=new T(t,{endRow:h}),p=new Array(d).fill(1);for(const{row:b,column:w,cellHeight:f,cellWidth:C,cell:_}of m){const R=b+f-1,V=b<n&&n<=R,P=b<=r&&r<=R;V?(c.setAttribute("rowspan",f+l,_),p[w]=-C):s&&P&&(p[w]=C)}for(let b=0;b<l;b++){const w=c.createElement("tableRow");c.insert(w,t,n);for(let f=0;f<p.length;f++){const C=p[f],_=c.createPositionAt(w,"end");C>0&&z(c,_,C>1?{colspan:C}:void 0),f+=Math.abs(C)-1}}})}insertColumns(t,e={}){const o=this.editor.model,n=e.at||0,l=e.columns||1;o.change(s=>{const r=t.getAttribute("headingColumns");n<r&&s.setAttribute("headingColumns",r+l,t);const a=this.getColumns(t);if(n===0||a===n){for(const c of t.getChildren())c.is("element","tableRow")&&j(l,s,s.createPositionAt(c,n?"end":0));return}const d=new T(t,{column:n,includeAllSlots:!0});for(const c of d){const{row:u,cell:h,cellAnchorColumn:m,cellAnchorRow:p,cellWidth:b,cellHeight:w}=c;if(m<n){s.setAttribute("colspan",b+l,h);const f=p+w-1;for(let C=u;C<=f;C++)d.skipRow(C)}else j(l,s,c.getPositionBefore())}})}removeRows(t,e){const o=this.editor.model,n=e.rows||1,l=this.getRows(t),s=e.at,r=s+n-1;if(r>l-1)throw new Ge("tableutils-removerows-row-index-out-of-range",this,{table:t,options:e});o.change(a=>{const d={first:s,last:r},{cellsToMove:c,cellsToTrim:u}=kn(t,d);if(c.size){const h=r+1;Vn(t,h,c,a)}for(let h=r;h>=s;h--)a.remove(t.getChild(h));for(const{rowspan:h,cell:m}of u)y("rowspan",h,m,a);xn(t,d,a),Ae(t,this)||Se(t,this)})}removeColumns(t,e){const o=this.editor.model,n=e.at,l=e.columns||1,s=e.at+l-1;o.change(r=>{In(t,{first:n,last:s},r);const a=Y(t);for(let d=s;d>=n;d--){for(const{cell:c,column:u,cellWidth:h}of[...new T(t)])u<=d&&h>1&&u+h>d?y("colspan",h-1,c,r):u===d&&r.remove(c);if(a[d]){const c=d===0?a[1]:a[d-1],u=parseFloat(a[d].getAttribute("columnWidth")),h=parseFloat(c.getAttribute("columnWidth"));r.remove(a[d]),r.setAttribute("columnWidth",u+h+"%",c)}}Se(t,this)||Ae(t,this)})}splitCellVertically(t,e=2){const o=this.editor.model,l=t.parent.parent,s=parseInt(t.getAttribute("rowspan")||"1"),r=parseInt(t.getAttribute("colspan")||"1");o.change(a=>{if(r>1){const{newCellsSpan:d,updatedSpan:c}=lt(r,e);y("colspan",c,t,a);const u={};d>1&&(u.colspan=d),s>1&&(u.rowspan=s);const h=r>e?e-1:r-1;j(h,a,a.createPositionAfter(t),u)}if(r<e){const d=e-r,c=[...new T(l)],{column:u}=c.find(({cell:b})=>b===t),h=c.filter(({cell:b,cellWidth:w,column:f})=>{const C=b!==t&&f===u,_=f<u&&f+w>u;return C||_});for(const{cell:b,cellWidth:w}of h)a.setAttribute("colspan",w+d,b);const m={};s>1&&(m.rowspan=s),j(d,a,a.createPositionAfter(t),m);const p=l.getAttribute("headingColumns")||0;p>u&&y("headingColumns",p+d,l,a)}})}splitCellHorizontally(t,e=2){const o=this.editor.model,n=t.parent,l=n.parent,s=l.getChildIndex(n),r=parseInt(t.getAttribute("rowspan")||"1"),a=parseInt(t.getAttribute("colspan")||"1");o.change(d=>{if(r>1){const c=[...new T(l,{startRow:s,endRow:s+r-1,includeAllSlots:!0})],{newCellsSpan:u,updatedSpan:h}=lt(r,e);y("rowspan",h,t,d);const{column:m}=c.find(({cell:w})=>w===t),p={};u>1&&(p.rowspan=u),a>1&&(p.colspan=a);let b=0;for(const w of c){const{column:f,row:C}=w,_=C>=s+h,R=f===m;b>=u&&R&&(b=0),_&&R&&(b||j(1,d,w.getPositionBefore(),p),b++)}}if(r<e){const c=e-r,u=[...new T(l,{startRow:0,endRow:s})];for(const{cell:p,cellHeight:b,row:w}of u)if(p!==t&&w+b>s){const f=b+c;d.setAttribute("rowspan",f,p)}const h={};a>1&&(h.colspan=a),Te(d,l,s+1,c,1,h);const m=l.getAttribute("headingRows")||0;m>s&&y("headingRows",m+c,l,d)}})}getColumns(t){return[...t.getChild(0).getChildren()].filter(o=>o.is("element","tableCell")).reduce((o,n)=>{const l=parseInt(n.getAttribute("colspan")||"1");return o+l},0)}getRows(t){return Array.from(t.getChildren()).reduce((e,o)=>o.is("element","tableRow")?e+1:e,0)}createTableWalker(t,e={}){return new T(t,e)}getSelectedTableCells(t){const e=[];for(const o of this.sortRanges(t.getRanges())){const n=o.getContainedElement();n&&n.is("element","tableCell")&&e.push(n)}return e}getTableCellsContainingSelection(t){const e=[];for(const o of t.getRanges()){const n=o.start.findAncestor("tableCell");n&&e.push(n)}return e}getSelectionAffectedTableCells(t){const e=this.getSelectedTableCells(t);return e.length?e:this.getTableCellsContainingSelection(t)}getRowIndexes(t){const e=t.map(o=>o.parent.index);return this._getFirstLastIndexesObject(e)}getColumnIndexes(t){const e=t[0].findAncestor("table"),n=[...new T(e)].filter(l=>t.includes(l.cell)).map(l=>l.column);return this._getFirstLastIndexesObject(n)}isSelectionRectangular(t){if(t.length<2||!this._areCellInTheSameTableSection(t))return!1;const e=new Set,o=new Set;let n=0;for(const s of t){const{row:r,column:a}=this.getCellLocation(s),d=parseInt(s.getAttribute("rowspan"))||1,c=parseInt(s.getAttribute("colspan"))||1;e.add(r),o.add(a),d>1&&e.add(r+d-1),c>1&&o.add(a+c-1),n+=d*c}return En(e,o)==n}sortRanges(t){return Array.from(t).sort(Pn)}_getFirstLastIndexesObject(t){const e=t.sort((l,s)=>l-s),o=e[0],n=e[e.length-1];return{first:o,last:n}}_areCellInTheSameTableSection(t){const e=t[0].findAncestor("table"),o=this.getRowIndexes(t),n=parseInt(e.getAttribute("headingRows"))||0;if(!this._areIndexesInSameSection(o,n))return!1;const l=this.getColumnIndexes(t),s=parseInt(e.getAttribute("headingColumns"))||0;return this._areIndexesInSameSection(l,s)}_areIndexesInSameSection({first:t,last:e},o){const n=t<o,l=e<o;return n===l}}function Te(i,t,e,o,n,l={}){for(let s=0;s<o;s++){const r=i.createElement("tableRow");i.insert(r,t,e),j(n,i,i.createPositionAt(r,"end"),l)}}function j(i,t,e,o={}){for(let n=0;n<i;n++)z(t,e,o)}function lt(i,t){if(i<t)return{newCellsSpan:1,updatedSpan:1};const e=Math.floor(i/t),o=i-e*t+e;return{newCellsSpan:e,updatedSpan:o}}function In(i,t,e){const o=i.getAttribute("headingColumns")||0;if(o&&t.first<o){const n=Math.min(o-1,t.last)-t.first+1;e.setAttribute("headingColumns",o-n,i)}}function xn(i,{first:t,last:e},o){const n=i.getAttribute("headingRows")||0;if(t<n){const l=e<n?n-(e-t+1):t;y("headingRows",l,i,o,0)}}function kn(i,{first:t,last:e}){const o=new Map,n=[];for(const{row:l,column:s,cellHeight:r,cell:a}of new T(i,{endRow:e})){const d=l+r-1;if(l>=t&&l<=e&&d>e){const h=e-l+1,m=r-h;o.set(s,{cell:a,rowspan:m})}if(l<t&&d>=t){let h;d>=e?h=e-t+1:h=d-t+1,n.push({cell:a,rowspan:r-h})}}return{cellsToMove:o,cellsToTrim:n}}function Vn(i,t,e,o){const l=[...new T(i,{includeAllSlots:!0,row:t})],s=i.getChild(t);let r;for(const{column:a,cell:d,isAnchor:c}of l)if(e.has(a)){const{cell:u,rowspan:h}=e.get(a),m=r?o.createPositionAfter(r):o.createPositionAt(s,0);o.move(o.createRangeOn(u),m),y("rowspan",h,u,o),r=u}else c&&(r=d)}function Pn(i,t){const e=i.start,o=t.start;return e.isBefore(o)?-1:1}function En(i,t){const e=Array.from(i.values()),o=Array.from(t.values()),n=Math.max(...e),l=Math.min(...e),s=Math.max(...o),r=Math.min(...o);return(n-l+1)*(s-r+1)}class Wn extends S{refresh(){const t=this.editor.plugins.get(A),e=t.getSelectedTableCells(this.editor.model.document.selection);this.isEnabled=t.isSelectionRectangular(e)}execute(){const t=this.editor.model,e=this.editor.plugins.get(A);t.change(o=>{const n=e.getSelectedTableCells(t.document.selection),l=n.shift(),{mergeWidth:s,mergeHeight:r}=Bn(l,n,e);y("colspan",s,l,o),y("rowspan",r,l,o);for(const d of n)Ln(d,l,o);const a=l.findAncestor("table");Me(a,e),o.setSelection(l,"in")})}}function Ln(i,t,e){it(i)||(it(t)&&e.remove(e.createRangeIn(t)),e.move(e.createRangeIn(i),e.createPositionAt(t,"end"))),e.remove(i)}function it(i){const t=i.getChild(0);return i.childCount==1&&t.is("element","paragraph")&&t.isEmpty}function Bn(i,t,e){let o=0,n=0;for(const d of t){const{row:c,column:u}=e.getCellLocation(d);o=st(d,u,o,"colspan"),n=st(d,c,n,"rowspan")}const{row:l,column:s}=e.getCellLocation(i),r=o-s,a=n-l;return{mergeWidth:r,mergeHeight:a}}function st(i,t,e,o){const n=parseInt(i.getAttribute(o)||"1");return Math.max(e,t+n)}class Dn extends S{constructor(t){super(t),this.affectsData=!1}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const t=this.editor.model,e=this.editor.plugins.get("TableUtils"),o=e.getSelectionAffectedTableCells(t.document.selection),n=e.getRowIndexes(o),l=o[0].findAncestor("table"),s=[];for(let r=n.first;r<=n.last;r++)for(const a of l.getChild(r).getChildren())s.push(t.createRangeOn(a));t.change(r=>{r.setSelection(s)})}}class Fn extends S{constructor(t){super(t),this.affectsData=!1}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const t=this.editor.plugins.get("TableUtils"),e=this.editor.model,o=t.getSelectionAffectedTableCells(e.document.selection),n=o[0],l=o.pop(),s=n.findAncestor("table"),r=t.getCellLocation(n),a=t.getCellLocation(l),d=Math.min(r.column,a.column),c=Math.max(r.column,a.column),u=[];for(const h of new T(s,{startColumn:d,endColumn:c}))u.push(e.createRangeOn(h.cell));e.change(h=>{h.setSelection(u)})}}function Nn(i){i.document.registerPostFixer(t=>Mn(t,i))}function Mn(i,t){const e=t.document.differ.getChanges();let o=!1;const n=new Set;for(const l of e){let s=null;l.type=="insert"&&l.name=="table"&&(s=l.position.nodeAfter),(l.type=="insert"||l.type=="remove")&&(l.name=="tableRow"||l.name=="tableCell")&&(s=l.position.findAncestor("table")),$n(l)&&(s=l.range.start.findAncestor("table")),s&&!n.has(s)&&(o=On(s,i)||o,o=zn(s,i)||o,n.add(s))}return o}function On(i,t){let e=!1;const o=Hn(i);if(o.length){e=!0;for(const n of o)y("rowspan",n.rowspan,n.cell,t,1)}return e}function zn(i,t){let e=!1;const o=Un(i),n=[];for(const[a,d]of o.entries())!d&&i.getChild(a).is("element","tableRow")&&n.push(a);if(n.length){e=!0;for(const a of n.reverse())t.remove(i.getChild(a)),o.splice(a,1)}const l=o.filter((a,d)=>i.getChild(d).is("element","tableRow")),s=l[0];if(!l.every(a=>a===s)){const a=l.reduce((d,c)=>c>d?c:d,0);for(const[d,c]of l.entries()){const u=a-c;if(u){for(let h=0;h<u;h++)z(t,t.createPositionAt(i.getChild(d),"end"));e=!0}}}return e}function Hn(i){const t=parseInt(i.getAttribute("headingRows")||"0"),e=Array.from(i.getChildren()).reduce((n,l)=>l.is("element","tableRow")?n+1:n,0),o=[];for(const{row:n,cell:l,cellHeight:s}of new T(i)){if(s<2)continue;const a=n<t?t:e;if(n+s>a){const d=a-n;o.push({cell:l,rowspan:d})}}return o}function Un(i){const t=new Array(i.childCount).fill(0);for(const{rowIndex:e}of new T(i,{includeAllSlots:!0}))t[e]++;return t}function $n(i){if(i.type!=="attribute")return!1;const t=i.attributeKey;return t==="headingRows"||t==="colspan"||t==="rowspan"}/**
|
|
10
|
+
*/const un=5,Se=40,hn=2,mn=3;function gn(i){const e=new Set;for(const t of i.document.differ.getChanges()){let o=null;switch(t.type){case"insert":o=["table","tableRow","tableCell"].includes(t.name)?t.position:null;break;case"remove":o=["tableRow","tableCell"].includes(t.name)?t.position:null;break;case"attribute":t.range.start.nodeAfter&&(o=["table","tableRow","tableCell"].includes(t.range.start.nodeAfter.name)?t.range.start:null);break}if(!o)continue;const n=o.nodeAfter&&o.nodeAfter.is("element","table")?o.nodeAfter:o.findAncestor("table");for(const l of i.createRangeOn(n).getItems())l.is("element","table")&&X(l)&&e.add(l)}return e}function bn(i,e){return Se*100/Mt(i,e)}function Mt(i,e){const t=ot(i,"tbody",e)||ot(i,"thead",e),o=e.editing.view.domConverter.mapViewToDom(t);return Re(o)}function ot(i,e,t){return[...[...t.editing.mapper.toViewElement(i).getChildren()].find(l=>l.is("element","table")).getChildren()].find(l=>l.is("element",e))}function Re(i){const e=ie.window.getComputedStyle(i);return e.boxSizing==="border-box"?parseFloat(e.width)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth):parseFloat(e.width)}function fn(i,e){const t=e.getCellLocation(i).column,o=i.getAttribute("colspan")||1;return{leftEdge:t,rightEdge:t+o-1}}function S(i){const e=Math.pow(10,hn),t=typeof i=="number"?i:parseFloat(i);return Math.round(t*e)/e}function pn(i,e,t){return i<=e?S(e):i>=t?S(t):S(i)}function wn(i,e){return Array(i).fill(e)}function q(i){return i.map(e=>typeof e=="number"?e:parseFloat(e)).filter(e=>!Number.isNaN(e)).reduce((e,t)=>e+t,0)}function Me(i){const e=i.map(n=>n==="auto"?n:parseFloat(n.replace("%","")));let t=Cn(e);const o=q(t);return o!==100&&(t=t.map(n=>S(n*100/o)).map((n,l,s)=>{if(!(l===s.length-1))return n;const c=q(s);return S(n+100-c)})),t.map(n=>n+"%")}function Cn(i){const e=i.filter(n=>n==="auto").length;if(e===0)return i.map(n=>S(n));const t=q(i),o=Math.max((100-t)/e,un);return i.map(n=>n==="auto"?o:n).map(n=>S(n))}function Tn(i){const e=ie.window.getComputedStyle(i);return e.boxSizing==="border-box"?parseInt(e.width):parseFloat(e.width)+parseFloat(e.paddingLeft)+parseFloat(e.paddingRight)+parseFloat(e.borderWidth)}function Ot(i,e,t,o){for(let n=0;n<Math.max(t.length,i.length);n++){const l=i[n],s=t[n];s?l?o.setAttribute("columnWidth",s,l):o.appendElement("tableColumn",{columnWidth:s},e):o.remove(l)}}function X(i){if(i.is("element","tableColumnGroup"))return i;const e=i.getChildren();return Array.from(e).find(t=>t.is("element","tableColumnGroup"))}function J(i){const e=X(i);return e?Array.from(e.getChildren()):[]}function _n(i){return J(i).map(e=>e.getAttribute("columnWidth"))}function yn(i,e){return J(i).reduce((o,n)=>{const l=n.getAttribute("columnWidth"),s=n.getAttribute("colSpan");if(!s)return o.push(l),o;for(let r=0;r<s;r++)o.push(l);return e.removeAttribute("colSpan",n),o},[])}class v extends y{static get pluginName(){return"TableUtils"}static get isOfficialPlugin(){return!0}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,o=t.parent,n=o.getChildIndex(t),l=new C(o,{row:n});for(const{cell:s,row:r,column:c}of l)if(s===e)return{row:r,column:c};/* istanbul ignore next -- @preserve */}createTable(e,t){const o=e.createElement("table"),n=t.rows||2,l=t.columns||2;return Ce(e,o,0,n,l),t.headingRows&&_("headingRows",Math.min(t.headingRows,n),o,e,0),t.headingColumns&&_("headingColumns",Math.min(t.headingColumns,l),o,e,0),o}insertRows(e,t={}){const o=this.editor.model,n=t.at||0,l=t.rows||1,s=t.copyStructureFromAbove!==void 0,r=t.copyStructureFromAbove?n-1:n,c=this.getRows(e),a=this.getColumns(e);if(n>c)throw new $e("tableutils-insertrows-insert-out-of-range",this,{options:t});o.change(d=>{const u=e.getAttribute("headingRows")||0;if(u>n&&_("headingRows",u+l,e,d,0),!s&&(n===0||n===c)){Ce(d,e,n,l,a);return}const h=s?Math.max(n,r):n,m=new C(e,{endRow:h}),g=new Array(a).fill(1);for(const{row:f,column:b,cellHeight:p,cellWidth:w,cell:T}of m){const x=f+p-1,k=f<n&&n<=x,G=f<=r&&r<=x;k?(d.setAttribute("rowspan",p+l,T),g[b]=-w):s&&G&&(g[b]=w)}for(let f=0;f<l;f++){const b=d.createElement("tableRow");d.insert(b,e,n);for(let p=0;p<g.length;p++){const w=g[p],T=d.createPositionAt(b,"end");w>0&&M(d,T,w>1?{colspan:w}:void 0),p+=Math.abs(w)-1}}})}insertColumns(e,t={}){const o=this.editor.model,n=t.at||0,l=t.columns||1;o.change(s=>{const r=e.getAttribute("headingColumns");n<r&&s.setAttribute("headingColumns",r+l,e);const c=this.getColumns(e);if(n===0||c===n){for(const d of e.getChildren())d.is("element","tableRow")&&$(l,s,s.createPositionAt(d,n?"end":0));return}const a=new C(e,{column:n,includeAllSlots:!0});for(const d of a){const{row:u,cell:h,cellAnchorColumn:m,cellAnchorRow:g,cellWidth:f,cellHeight:b}=d;if(m<n){s.setAttribute("colspan",f+l,h);const p=g+b-1;for(let w=u;w<=p;w++)a.skipRow(w)}else $(l,s,d.getPositionBefore())}})}removeRows(e,t){const o=this.editor.model,n=t.rows||1,l=this.getRows(e),s=t.at,r=s+n-1;if(r>l-1)throw new $e("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});o.change(c=>{const a={first:s,last:r},{cellsToMove:d,cellsToTrim:u}=Sn(e,a);if(d.size){const h=r+1;Rn(e,h,d,c)}for(let h=r;h>=s;h--)c.remove(e.getChild(h));for(const{rowspan:h,cell:m}of u)_("rowspan",h,m,c);An(e,a,c),ve(e,this)||Ae(e,this)})}removeColumns(e,t){const o=this.editor.model,n=t.at,l=t.columns||1,s=t.at+l-1;o.change(r=>{vn(e,{first:n,last:s},r);const c=J(e);for(let a=s;a>=n;a--){for(const{cell:d,column:u,cellWidth:h}of[...new C(e)])u<=a&&h>1&&u+h>a?_("colspan",h-1,d,r):u===a&&r.remove(d);if(c[a]){const d=a===0?c[1]:c[a-1],u=parseFloat(c[a].getAttribute("columnWidth")),h=parseFloat(d.getAttribute("columnWidth"));r.remove(c[a]),r.setAttribute("columnWidth",u+h+"%",d)}}Ae(e,this)||ve(e,this)})}splitCellVertically(e,t=2){const o=this.editor.model,l=e.parent.parent,s=parseInt(e.getAttribute("rowspan")||"1"),r=parseInt(e.getAttribute("colspan")||"1");o.change(c=>{if(r>1){const{newCellsSpan:a,updatedSpan:d}=nt(r,t);_("colspan",d,e,c);const u={};a>1&&(u.colspan=a),s>1&&(u.rowspan=s);const h=r>t?t-1:r-1;$(h,c,c.createPositionAfter(e),u)}if(r<t){const a=t-r,d=[...new C(l)],{column:u}=d.find(({cell:f})=>f===e),h=d.filter(({cell:f,cellWidth:b,column:p})=>{const w=f!==e&&p===u,T=p<u&&p+b>u;return w||T});for(const{cell:f,cellWidth:b}of h)c.setAttribute("colspan",b+a,f);const m={};s>1&&(m.rowspan=s),$(a,c,c.createPositionAfter(e),m);const g=l.getAttribute("headingColumns")||0;g>u&&_("headingColumns",g+a,l,c)}})}splitCellHorizontally(e,t=2){const o=this.editor.model,n=e.parent,l=n.parent,s=l.getChildIndex(n),r=parseInt(e.getAttribute("rowspan")||"1"),c=parseInt(e.getAttribute("colspan")||"1");o.change(a=>{if(r>1){const d=[...new C(l,{startRow:s,endRow:s+r-1,includeAllSlots:!0})],{newCellsSpan:u,updatedSpan:h}=nt(r,t);_("rowspan",h,e,a);const{column:m}=d.find(({cell:b})=>b===e),g={};u>1&&(g.rowspan=u),c>1&&(g.colspan=c);let f=0;for(const b of d){const{column:p,row:w}=b,T=w>=s+h,x=p===m;f>=u&&x&&(f=0),T&&x&&(f||$(1,a,b.getPositionBefore(),g),f++)}}if(r<t){const d=t-r,u=[...new C(l,{startRow:0,endRow:s})];for(const{cell:g,cellHeight:f,row:b}of u)if(g!==e&&b+f>s){const p=f+d;a.setAttribute("rowspan",p,g)}const h={};c>1&&(h.colspan=c),Ce(a,l,s+1,d,1,h);const m=l.getAttribute("headingRows")||0;m>s&&_("headingRows",m+d,l,a)}})}getColumns(e){return[...e.getChild(0).getChildren()].filter(o=>o.is("element","tableCell")).reduce((o,n)=>{const l=parseInt(n.getAttribute("colspan")||"1");return o+l},0)}getRows(e){return Array.from(e.getChildren()).reduce((t,o)=>o.is("element","tableRow")?t+1:t,0)}createTableWalker(e,t={}){return new C(e,t)}getSelectedTableCells(e){const t=[];for(const o of this.sortRanges(e.getRanges())){const n=o.getContainedElement();n&&n.is("element","tableCell")&&t.push(n)}return t}getTableCellsContainingSelection(e){const t=[];for(const o of e.getRanges()){const n=o.start.findAncestor("tableCell");n&&t.push(n)}return t}getSelectionAffectedTableCells(e){const t=this.getSelectedTableCells(e);return t.length?t:this.getTableCellsContainingSelection(e)}getRowIndexes(e){const t=e.map(o=>o.parent.index);return this._getFirstLastIndexesObject(t)}getColumnIndexes(e){const t=e[0].findAncestor("table"),n=[...new C(t)].filter(l=>e.includes(l.cell)).map(l=>l.column);return this._getFirstLastIndexesObject(n)}isSelectionRectangular(e){if(e.length<2||!this._areCellInTheSameTableSection(e))return!1;const t=new Set,o=new Set;let n=0;for(const s of e){const{row:r,column:c}=this.getCellLocation(s),a=parseInt(s.getAttribute("rowspan"))||1,d=parseInt(s.getAttribute("colspan"))||1;t.add(r),o.add(c),a>1&&t.add(r+a-1),d>1&&o.add(c+d-1),n+=a*d}return xn(t,o)==n}sortRanges(e){return Array.from(e).sort(In)}_getFirstLastIndexesObject(e){const t=e.sort((l,s)=>l-s),o=t[0],n=t[t.length-1];return{first:o,last:n}}_areCellInTheSameTableSection(e){const t=e[0].findAncestor("table"),o=this.getRowIndexes(e),n=parseInt(t.getAttribute("headingRows"))||0;if(!this._areIndexesInSameSection(o,n))return!1;const l=this.getColumnIndexes(e),s=parseInt(t.getAttribute("headingColumns"))||0;return this._areIndexesInSameSection(l,s)}_areIndexesInSameSection({first:e,last:t},o){const n=e<o,l=t<o;return n===l}}function Ce(i,e,t,o,n,l={}){for(let s=0;s<o;s++){const r=i.createElement("tableRow");i.insert(r,e,t),$(n,i,i.createPositionAt(r,"end"),l)}}function $(i,e,t,o={}){for(let n=0;n<i;n++)M(e,t,o)}function nt(i,e){if(i<e)return{newCellsSpan:1,updatedSpan:1};const t=Math.floor(i/e),o=i-t*e+t;return{newCellsSpan:t,updatedSpan:o}}function vn(i,e,t){const o=i.getAttribute("headingColumns")||0;if(o&&e.first<o){const n=Math.min(o-1,e.last)-e.first+1;t.setAttribute("headingColumns",o-n,i)}}function An(i,{first:e,last:t},o){const n=i.getAttribute("headingRows")||0;if(e<n){const l=t<n?n-(t-e+1):e;_("headingRows",l,i,o,0)}}function Sn(i,{first:e,last:t}){const o=new Map,n=[];for(const{row:l,column:s,cellHeight:r,cell:c}of new C(i,{endRow:t})){const a=l+r-1;if(l>=e&&l<=t&&a>t){const h=t-l+1,m=r-h;o.set(s,{cell:c,rowspan:m})}if(l<e&&a>=e){let h;a>=t?h=t-e+1:h=a-e+1,n.push({cell:c,rowspan:r-h})}}return{cellsToMove:o,cellsToTrim:n}}function Rn(i,e,t,o){const l=[...new C(i,{includeAllSlots:!0,row:e})],s=i.getChild(e);let r;for(const{column:c,cell:a,isAnchor:d}of l)if(t.has(c)){const{cell:u,rowspan:h}=t.get(c),m=r?o.createPositionAfter(r):o.createPositionAt(s,0);o.move(o.createRangeOn(u),m),_("rowspan",h,u,o),r=u}else d&&(r=a)}function In(i,e){const t=i.start,o=e.start;return t.isBefore(o)?-1:1}function xn(i,e){const t=Array.from(i.values()),o=Array.from(e.values()),n=Math.max(...t),l=Math.min(...t),s=Math.max(...o),r=Math.min(...o);return(n-l+1)*(s-r+1)}class kn extends A{refresh(){const e=this.editor.plugins.get(v),t=e.getSelectedTableCells(this.editor.model.document.selection);this.isEnabled=e.isSelectionRectangular(t)}execute(){const e=this.editor.model,t=this.editor.plugins.get(v);e.change(o=>{const n=t.getSelectedTableCells(e.document.selection),l=n.shift(),{mergeWidth:s,mergeHeight:r}=Pn(l,n,t);_("colspan",s,l,o),_("rowspan",r,l,o);for(const a of n)Vn(a,l,o);const c=l.findAncestor("table");Ne(c,t),o.setSelection(l,"in")})}}function Vn(i,e,t){lt(i)||(lt(e)&&t.remove(t.createRangeIn(e)),t.move(t.createRangeIn(i),t.createPositionAt(e,"end"))),t.remove(i)}function lt(i){const e=i.getChild(0);return i.childCount==1&&e.is("element","paragraph")&&e.isEmpty}function Pn(i,e,t){let o=0,n=0;for(const a of e){const{row:d,column:u}=t.getCellLocation(a);o=it(a,u,o,"colspan"),n=it(a,d,n,"rowspan")}const{row:l,column:s}=t.getCellLocation(i),r=o-s,c=n-l;return{mergeWidth:r,mergeHeight:c}}function it(i,e,t,o){const n=parseInt(i.getAttribute(o)||"1");return Math.max(t,e+n)}class En extends A{constructor(e){super(e),this.affectsData=!1}refresh(){const t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=t.length>0}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),o=t.getSelectionAffectedTableCells(e.document.selection),n=t.getRowIndexes(o),l=o[0].findAncestor("table"),s=[];for(let r=n.first;r<=n.last;r++)for(const c of l.getChild(r).getChildren())s.push(e.createRangeOn(c));e.change(r=>{r.setSelection(s)})}}class Wn extends A{constructor(e){super(e),this.affectsData=!1}refresh(){const t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=t.length>0}execute(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,o=e.getSelectionAffectedTableCells(t.document.selection),n=o[0],l=o.pop(),s=n.findAncestor("table"),r=e.getCellLocation(n),c=e.getCellLocation(l),a=Math.min(r.column,c.column),d=Math.max(r.column,c.column),u=[];for(const h of new C(s,{startColumn:a,endColumn:d}))u.push(t.createRangeOn(h.cell));t.change(h=>{h.setSelection(u)})}}function Ln(i){i.document.registerPostFixer(e=>Bn(e,i))}function Bn(i,e){const t=e.document.differ.getChanges();let o=!1;const n=new Set;for(const l of t){let s=null;l.type=="insert"&&l.name=="table"&&(s=l.position.nodeAfter),(l.type=="insert"||l.type=="remove")&&(l.name=="tableRow"||l.name=="tableCell")&&(s=l.position.findAncestor("table")),On(l)&&(s=l.range.start.findAncestor("table")),s&&!n.has(s)&&(o=Dn(s,i)||o,o=Fn(s,i)||o,n.add(s))}return o}function Dn(i,e){let t=!1;const o=Nn(i);if(o.length){t=!0;for(const n of o)_("rowspan",n.rowspan,n.cell,e,1)}return t}function Fn(i,e){let t=!1;const o=Mn(i),n=[];for(const[c,a]of o.entries())!a&&i.getChild(c).is("element","tableRow")&&n.push(c);if(n.length){t=!0;for(const c of n.reverse())e.remove(i.getChild(c)),o.splice(c,1)}const l=o.filter((c,a)=>i.getChild(a).is("element","tableRow")),s=l[0];if(!l.every(c=>c===s)){const c=l.reduce((a,d)=>d>a?d:a,0);for(const[a,d]of l.entries()){const u=c-d;if(u){for(let h=0;h<u;h++)M(e,e.createPositionAt(i.getChild(a),"end"));t=!0}}}return t}function Nn(i){const e=parseInt(i.getAttribute("headingRows")||"0"),t=Array.from(i.getChildren()).reduce((n,l)=>l.is("element","tableRow")?n+1:n,0),o=[];for(const{row:n,cell:l,cellHeight:s}of new C(i)){if(s<2)continue;const c=n<e?e:t;if(n+s>c){const a=c-n;o.push({cell:l,rowspan:a})}}return o}function Mn(i){const e=new Array(i.childCount).fill(0);for(const{rowIndex:t}of new C(i,{includeAllSlots:!0}))e[t]++;return e}function On(i){if(i.type!=="attribute")return!1;const e=i.attributeKey;return e==="headingRows"||e==="colspan"||e==="rowspan"}/**
|
|
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
|
-
*/function Gn(i){i.document.registerPostFixer(t=>jn(t,i))}function jn(i,t){const e=t.document.differ.getChanges();let o=!1;for(const n of e)n.type=="insert"&&n.name=="table"&&(o=Kn(n.position.nodeAfter,i)||o),n.type=="insert"&&n.name=="tableRow"&&(o=Ht(n.position.nodeAfter,i)||o),n.type=="insert"&&n.name=="tableCell"&&(o=xe(n.position.nodeAfter,i)||o),(n.type=="remove"||n.type=="insert")&&qn(n)&&(o=xe(n.position.parent,i)||o);return o}function Kn(i,t){let e=!1;for(const o of i.getChildren())o.is("element","tableRow")&&(e=Ht(o,t)||e);return e}function Ht(i,t){let e=!1;for(const o of i.getChildren())e=xe(o,t)||e;return e}function xe(i,t){if(i.childCount==0)return t.insertElement("paragraph",i),!0;const e=Array.from(i.getChildren()).filter(o=>o.is("$text"));for(const o of e)t.wrap(t.createRangeOn(o),"paragraph");return!!e.length}function qn(i){return i.position.parent.is("element","tableCell")?i.type=="insert"&&i.name=="$text"||i.type=="remove":!1}function Xn(i,t){const e=i.document.differ;for(const o of e.getChanges()){let n,l=!1;if(o.type=="attribute"){const d=o.range.start.nodeAfter;if(!d||!d.is("element","table")||o.attributeKey!="headingRows"&&o.attributeKey!="headingColumns")continue;n=d,l=o.attributeKey=="headingRows"}else(o.name=="tableRow"||o.name=="tableCell")&&(n=o.position.findAncestor("table"),l=o.name=="tableRow");if(!n)continue;const s=n.getAttribute("headingRows")||0,r=n.getAttribute("headingColumns")||0,a=new T(n);for(const d of a){const u=d.row<s||d.column<r?"th":"td",h=t.mapper.toViewElement(d.cell);h&&h.is("element")&&h.name!=u&&t.reconvertItem(l?d.cell.parent:d.cell)}}}function Jn(i,t){const e=i.document.differ,o=new Set;for(const n of e.getChanges()){const l=n.type=="attribute"?n.range.start.parent:n.position.parent;l.is("element","tableCell")&&o.add(l)}for(const n of o.values()){const l=Array.from(n.getChildren()).filter(s=>Yn(s,t.mapper));for(const s of l)t.reconvertItem(s)}}function Yn(i,t){if(!i.is("element","paragraph"))return!1;const e=t.toViewElement(i);return e?Pt(i)!==e.is("element","span"):!1}class Z extends v{constructor(e){super(e);g(this,"_additionalSlots");this._additionalSlots=[]}static get pluginName(){return"TableEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[A]}init(){const e=this.editor,o=e.model,n=o.schema,l=e.conversion,s=e.plugins.get(A);n.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]}),n.register("tableRow",{allowIn:"table",isLimit:!0}),n.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),l.for("upcast").add(Go()),l.for("upcast").add(jo()),l.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Je(s,{asWidget:!0,additionalSlots:this._additionalSlots})}),l.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Je(s,{additionalSlots:this._additionalSlots})}),l.for("upcast").elementToElement({model:"tableRow",view:"tr"}),l.for("upcast").add(Ko()),l.for("downcast").elementToElement({model:"tableRow",view:Zo()}),l.for("upcast").elementToElement({model:"tableCell",view:"td"}),l.for("upcast").elementToElement({model:"tableCell",view:"th"}),l.for("upcast").add(Xe("td")),l.for("upcast").add(Xe("th")),l.for("editingDowncast").elementToElement({model:"tableCell",view:Ye({asWidget:!0})}),l.for("dataDowncast").elementToElement({model:"tableCell",view:Ye()}),l.for("editingDowncast").elementToElement({model:"paragraph",view:Ze({asWidget:!0}),converterPriority:"high"}),l.for("dataDowncast").elementToElement({model:"paragraph",view:Ze(),converterPriority:"high"}),l.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),l.for("upcast").attributeToAttribute({model:{key:"colspan",value:rt("colspan")},view:"colspan"}),l.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),l.for("upcast").attributeToAttribute({model:{key:"rowspan",value:rt("rowspan")},view:"rowspan"}),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.commands.add("insertTable",new tn(e)),e.commands.add("insertTableRowAbove",new Qe(e,{order:"above"})),e.commands.add("insertTableRowBelow",new Qe(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new et(e,{order:"left"})),e.commands.add("insertTableColumnRight",new et(e,{order:"right"})),e.commands.add("removeTableRow",new an(e)),e.commands.add("removeTableColumn",new dn(e)),e.commands.add("splitTableCellVertically",new tt(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new tt(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new Wn(e)),e.commands.add("mergeTableCellRight",new Q(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new Q(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new Q(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new Q(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new gn(e)),e.commands.add("setTableRowHeader",new mn(e)),e.commands.add("selectTableRow",new Dn(e)),e.commands.add("selectTableColumn",new Fn(e)),Nn(o),Gn(o),this.listenTo(o.document,"change:data",()=>{Xn(o,e.editing),Jn(o,e.editing)})}registerAdditionalSlot(e){this._additionalSlots.push(e)}}function rt(i){return t=>{const e=parseInt(t.getAttribute(i));return Number.isNaN(e)||e<=0?null:e}}class at extends O{constructor(e){super(e);g(this,"items");g(this,"keystrokes");g(this,"focusTracker");const o=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new be,this.focusTracker=new fe,this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",(n,l)=>`${l} × ${n}`),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"mouseover@.ck-insert-table-dropdown-grid-box":o.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck","ck-insert-table-dropdown__label"],"aria-hidden":!0},children:[{text:o.to("label")}]}],on:{mousedown:o.to(n=>{n.preventDefault()}),click:o.to(()=>{this.fire("execute")})}}),this.on("boxover",(n,l)=>{const{row:s,column:r}=l.target.dataset;this.items.get((parseInt(s,10)-1)*10+(parseInt(r,10)-1)).focus()}),this.focusTracker.on("change:focusedElement",(n,l,s)=>{if(!s)return;const{row:r,column:a}=s.dataset;this.set({rows:parseInt(r),columns:parseInt(a)})}),this.on("change:columns",()=>this._highlightGridBoxes()),this.on("change:rows",()=>this._highlightGridBoxes())}render(){super.render(),Lo({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:10,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection});for(const e of this.items)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element)}reset(){this.set({rows:1,columns:1})}focus(){this.items.get(0).focus()}focusLast(){this.items.get(0).focus()}_highlightGridBoxes(){const e=this.rows,o=this.columns;this.items.map((n,l)=>{const s=Math.floor(l/10),r=l%10,a=s<e&&r<o;n.set("isOn",a)})}_createGridButton(e,o,n,l){const s=new E(e);return s.set({label:l,class:"ck-insert-table-dropdown-grid-box"}),s.extendTemplate({attributes:{"data-row":o,"data-column":n}}),s}_createGridCollection(){const e=[];for(let o=0;o<100;o++){const n=Math.floor(o/10),l=o%10,s=`${n+1} × ${l+1}`;e.push(this._createGridButton(this.locale,n+1,l+1,s))}return this.createCollection(e)}}class Zn extends v{static get pluginName(){return"TableUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=this.editor.t,n=t.locale.contentLanguageDirection==="ltr";t.ui.componentFactory.add("insertTable",l=>{const s=t.commands.get("insertTable"),r=oe(l);r.bind("isEnabled").to(s),r.buttonView.set({icon:je,label:e("Insert table"),tooltip:!0});let a;return r.on("change:isOpen",()=>{a||(a=new at(l),r.panelView.children.add(a),a.delegate("execute").to(r),r.on("execute",()=>{t.execute("insertTable",{rows:a.rows,columns:a.columns}),t.editing.view.focus()}))}),r}),t.ui.componentFactory.add("menuBar:insertTable",l=>{const s=t.commands.get("insertTable"),r=new Po(l),a=new at(l);return a.delegate("execute").to(r),r.on("change:isOpen",(d,c,u)=>{u||a.reset()}),a.on("execute",()=>{t.execute("insertTable",{rows:a.rows,columns:a.columns}),t.editing.view.focus()}),r.buttonView.set({label:e("Table"),icon:je}),r.panelView.children.add(a),r.bind("isEnabled").to(s),r}),t.ui.componentFactory.add("tableColumn",l=>{const s=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:e("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:n?"insertTableColumnLeft":"insertTableColumnRight",label:e("Insert column left")}},{type:"button",model:{commandName:n?"insertTableColumnRight":"insertTableColumnLeft",label:e("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:e("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:e("Select column")}}];return this._prepareDropdown(e("Column"),bo,s,l)}),t.ui.componentFactory.add("tableRow",l=>{const s=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:e("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:e("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:e("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:e("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:e("Select row")}}];return this._prepareDropdown(e("Row"),fo,s,l)}),t.ui.componentFactory.add("mergeTableCells",l=>{const s=[{type:"button",model:{commandName:"mergeTableCellUp",label:e("Merge cell up")}},{type:"button",model:{commandName:n?"mergeTableCellRight":"mergeTableCellLeft",label:e("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:e("Merge cell down")}},{type:"button",model:{commandName:n?"mergeTableCellLeft":"mergeTableCellRight",label:e("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:e("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:e("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(e("Merge cells"),po,s,l)})}_prepareDropdown(t,e,o,n){const l=this.editor,s=oe(n),r=this._fillDropdownWithListOptions(s,o);return s.buttonView.set({label:t,icon:e,tooltip:!0}),s.bind("isEnabled").toMany(r,"isEnabled",(...a)=>a.some(d=>d)),this.listenTo(s,"execute",a=>{l.execute(a.source.commandName),a.source instanceof Eo||l.editing.view.focus()}),s}_prepareMergeSplitButtonDropdown(t,e,o,n){const l=this.editor,s=oe(n,Wo),r="mergeTableCells",a=l.commands.get(r),d=this._fillDropdownWithListOptions(s,o);return s.buttonView.set({label:t,icon:e,tooltip:!0,isEnabled:!0}),s.bind("isEnabled").toMany([a,...d],"isEnabled",(...c)=>c.some(u=>u)),this.listenTo(s.buttonView,"execute",()=>{l.execute(r),l.editing.view.focus()}),this.listenTo(s,"execute",c=>{l.execute(c.source.commandName),l.editing.view.focus()}),s}_fillDropdownWithListOptions(t,e){const o=this.editor,n=[],l=new Ct;for(const s of e)Qn(s,o,n,l);return Be(t,l),n}}function Qn(i,t,e,o){if(i.type==="button"||i.type==="switchbutton"){const n=i.model=new vt(i.model),{commandName:l,bindIsOn:s}=i.model,r=t.commands.get(l);e.push(r),n.set({commandName:l}),n.bind("isEnabled").to(r),s&&n.bind("isOn").to(r,"value"),n.set({withText:!0})}o.add(i)}class F extends v{static get pluginName(){return"TableSelection"}static get isOfficialPlugin(){return!0}static get requires(){return[A,A]}init(){const t=this.editor,e=t.model,o=t.editing.view;this.listenTo(e,"deleteContent",(n,l)=>this._handleDeleteContent(n,l),{priority:"high"}),this.listenTo(o.document,"insertText",(n,l)=>this._handleInsertTextEvent(n,l),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const t=this.editor.plugins.get(A),e=this.editor.model.document.selection,o=t.getSelectedTableCells(e);return o.length==0?null:o}getSelectionAsFragment(){const t=this.editor.plugins.get(A),e=this.getSelectedTableCells();return e?this.editor.model.change(o=>{const n=o.createDocumentFragment(),{first:l,last:s}=t.getColumnIndexes(e),{first:r,last:a}=t.getRowIndexes(e),d=e[0].findAncestor("table");let c=a,u=s;if(t.isSelectionRectangular(e)){const p={firstColumn:l,lastColumn:s,firstRow:r,lastRow:a};c=Nt(d,p),u=Mt(d,p)}const m=Et(d,{startRow:r,startColumn:l,endRow:c,endColumn:u},o);return o.insert(m,n,0),n}):null}setCellSelection(t,e){const o=this._getCellsToSelect(t,e);this.editor.model.change(n=>{n.setSelection(o.cells.map(l=>n.createRangeOn(l)),{backward:o.backward})})}getFocusCell(){const o=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return o&&o.is("element","tableCell")?o:null}getAnchorCell(){const t=this.editor.model.document.selection,o=Le(t.getRanges()).getContainedElement();return o&&o.is("element","tableCell")?o:null}_defineSelectionConverter(){const t=this.editor,e=new Set;t.conversion.for("editingDowncast").add(n=>n.on("selection",(l,s,r)=>{const a=r.writer;o(a);const d=this.getSelectedTableCells();if(!d)return;for(const u of d){const h=r.mapper.toViewElement(u);a.addClass("ck-editor__editable_selected",h),e.add(h)}const c=r.mapper.toViewElement(d[d.length-1]);a.setSelection(c,0)},{priority:"lowest"}));function o(n){for(const l of e)n.removeClass("ck-editor__editable_selected",l);e.clear()}}_enablePluginDisabling(){const t=this.editor;this.on("change:isEnabled",()=>{if(!this.isEnabled){const e=this.getSelectedTableCells();if(!e)return;t.model.change(o=>{const n=o.createPositionAt(e[0],0),l=t.model.schema.getNearestSelectionRange(n);o.setSelection(l)})}})}_handleDeleteContent(t,e){const o=this.editor.plugins.get(A),n=e[0],l=e[1],s=this.editor.model,r=!l||l.direction=="backward",a=o.getSelectedTableCells(n);a.length&&(t.stop(),s.change(d=>{const c=a[r?a.length-1:0];s.change(h=>{for(const m of a)s.deleteContent(h.createSelection(m,"in"))});const u=s.schema.getNearestSelectionRange(d.createPositionAt(c,0));n.is("documentSelection")?d.setSelection(u):n.setTo(u)}))}_handleInsertTextEvent(t,e){const o=this.editor,n=this.getSelectedTableCells();if(!n)return;const l=o.editing.view,s=o.editing.mapper,r=n.map(a=>l.createRangeOn(s.toViewElement(a)));e.selection=l.createSelection(r),e.preventDefault()}_getCellsToSelect(t,e){const o=this.editor.plugins.get("TableUtils"),n=o.getCellLocation(t),l=o.getCellLocation(e),s=Math.min(n.row,l.row),r=Math.max(n.row,l.row),a=Math.min(n.column,l.column),d=parseInt(e.getAttribute("colspan")||"1")-1,c=Math.max(n.column,l.column+d),u=new Array(r-s+1).fill(null).map(()=>[]),h={startRow:s,endRow:r,startColumn:a,endColumn:c};for(const{row:b,cell:w}of new T(t.findAncestor("table"),h))u[b-s].push(w);const m=l.row<n.row,p=l.column<n.column;return m&&u.reverse(),p&&u.forEach(b=>b.reverse()),{cells:u.flat(),backward:m||p}}}class el extends v{static get pluginName(){return"TableClipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[Ce,Ke,F,A]}init(){const e=this.editor.editing.view.document;this.listenTo(e,"copy",(o,n)=>this._onCopyCut(o,n)),this.listenTo(e,"cut",(o,n)=>this._onCopyCut(o,n)),this._listenToContentInsertion(),this.decorate("_replaceTableSlotCell")}_listenToContentInsertion(){const{editor:t}=this,e=t.plugins.get(Ke),o=t.plugins.get(F);let n=!1;e.on("contentInsertion",(l,s)=>{n=s.method==="paste"}),this.listenTo(t.model,"insertContent",(l,[s,r])=>{(n||o.getSelectedTableCells()!==null)&&this._onInsertContent(l,s,r)},{priority:"high"}),e.on("contentInsertion",()=>{n=!1},{priority:"lowest"})}_onCopyCut(t,e){const o=this.editor.editing.view,n=this.editor.plugins.get(F),l=this.editor.plugins.get(Ce);n.getSelectedTableCells()&&(t.name=="cut"&&!this.editor.model.canEditAt(this.editor.model.document.selection)||(e.preventDefault(),t.stop(),this.editor.model.enqueueChange({isUndoable:t.name==="cut"},()=>{const s=l._copySelectedFragmentWithMarkers(t.name,this.editor.model.document.selection,()=>n.getSelectionAsFragment());o.document.fire("clipboardOutput",{dataTransfer:e.dataTransfer,content:this.editor.data.toView(s),method:t.name})})))}_onInsertContent(t,e,o){if(o&&!o.is("documentSelection"))return;const n=this.editor.model,l=this.editor.plugins.get(A),s=this.editor.plugins.get(Ce),r=this.getTableIfOnlyTableInContent(e,n);if(!r)return;const a=l.getSelectionAffectedTableCells(n.document.selection);if(!a.length){Me(r,l);return}t.stop(),e.is("documentFragment")?s._pasteMarkersIntoTransformedElement(e.markers,d=>this._replaceSelectedCells(r,a,d)):this.editor.model.change(d=>{this._replaceSelectedCells(r,a,d)})}_replaceSelectedCells(t,e,o){const n=this.editor.plugins.get(A),l={width:n.getColumns(t),height:n.getRows(t)},s=tl(e,l,o,n),r=s.lastRow-s.firstRow+1,a=s.lastColumn-s.firstColumn+1,d={startRow:0,startColumn:0,endRow:Math.min(r,l.height)-1,endColumn:Math.min(a,l.width)-1};t=Et(t,d,o);const c=e[0].findAncestor("table"),u=this._replaceSelectedCellsWithPasted(t,l,c,s,o);if(this.editor.plugins.get("TableSelection").isEnabled){const h=n.sortRanges(u.map(m=>o.createRangeOn(m)));o.setSelection(h)}else o.setSelection(u[0],0);return c}_replaceSelectedCellsWithPasted(t,e,o,n,l){const{width:s,height:r}=e,a=nl(t,s,r),d=[...new T(o,{startRow:n.firstRow,endRow:n.lastRow,startColumn:n.firstColumn,endColumn:n.lastColumn,includeAllSlots:!0})],c=[];let u;for(const w of d){const{row:f,column:C}=w;C===n.firstColumn&&(u=w.getPositionBefore());const _=f-n.firstRow,R=C-n.firstColumn,V=a[_%r][R%s],P=V?l.cloneElement(V):null,G=this._replaceTableSlotCell(w,P,u,l);G&&(Ft(G,f,C,n.lastRow,n.lastColumn,l),c.push(G),u=l.createPositionAfter(G))}const h=parseInt(o.getAttribute("headingRows")||"0"),m=parseInt(o.getAttribute("headingColumns")||"0"),p=n.firstRow<h&&h<=n.lastRow,b=n.firstColumn<m&&m<=n.lastColumn;if(p){const w={first:n.firstColumn,last:n.lastColumn},f=ke(o,h,w,l,n.firstRow);c.push(...f)}if(b){const w={first:n.firstRow,last:n.lastRow},f=Ve(o,m,w,l);c.push(...f)}return c}_replaceTableSlotCell(t,e,o,n){const{cell:l,isAnchor:s}=t;return s&&n.remove(l),e?(n.insert(e,o),e):null}getTableIfOnlyTableInContent(t,e){if(!t.is("documentFragment")&&!t.is("element"))return null;if(t.is("element","table"))return t;if(t.childCount==1&&t.getChild(0).is("element","table"))return t.getChild(0);const o=e.createRangeIn(t);for(const n of o.getItems())if(n.is("element","table")){const l=e.createRange(o.start,e.createPositionBefore(n));if(e.hasContent(l,{ignoreWhitespaces:!0}))return null;const s=e.createRange(e.createPositionAfter(n),o.end);return e.hasContent(s,{ignoreWhitespaces:!0})?null:n}return null}}function tl(i,t,e,o){const n=i[0].findAncestor("table"),l=o.getColumnIndexes(i),s=o.getRowIndexes(i),r={firstColumn:l.first,lastColumn:l.last,firstRow:s.first,lastRow:s.last},a=i.length===1;return a&&(r.lastRow+=t.height-1,r.lastColumn+=t.width-1,ol(n,r.lastRow+1,r.lastColumn+1,o)),a||!o.isSelectionRectangular(i)?ll(n,r,e):(r.lastRow=Nt(n,r),r.lastColumn=Mt(n,r)),r}function ol(i,t,e,o){const n=o.getColumns(i),l=o.getRows(i);e>n&&o.insertColumns(i,{at:n,columns:e-n}),t>l&&o.insertRows(i,{at:l,rows:t-l})}function nl(i,t,e){const o=new Array(e).fill(null).map(()=>new Array(t).fill(null));for(const{column:n,row:l,cell:s}of new T(i))o[l][n]=s;return o}function ll(i,t,e){const{firstRow:o,lastRow:n,firstColumn:l,lastColumn:s}=t,r={first:o,last:n},a={first:l,last:s};Ve(i,l,r,e),Ve(i,s+1,r,e),ke(i,o,a,e),ke(i,n+1,a,e,o)}function ke(i,t,e,o,n=0){return t<1?void 0:Wt(i,t,n).filter(({column:r,cellWidth:a})=>Ut(r,a,e)).map(({cell:r})=>Lt(r,t,o))}function Ve(i,t,e,o){return t<1?void 0:Bt(i,t).filter(({row:s,cellHeight:r})=>Ut(s,r,e)).map(({cell:s,column:r})=>Dt(s,r,t,o))}function Ut(i,t,e){const o=i+t-1,{first:n,last:l}=e,s=i>=n&&i<=l,r=i<n&&o>=n;return s||r}class il extends v{static get pluginName(){return"TableKeyboard"}static get isOfficialPlugin(){return!0}static get requires(){return[F,A]}init(){const t=this.editor,o=t.editing.view.document,n=t.t;this.listenTo(o,"arrowKey",(...l)=>this._onArrowKey(...l),{context:"table"}),this.listenTo(o,"tab",(...l)=>this._handleTabOnSelectedTable(...l),{context:"figure"}),this.listenTo(o,"tab",(...l)=>this._handleTab(...l),{context:["th","td"]}),t.accessibility.addKeystrokeInfoGroup({id:"table",label:n("Keystrokes that can be used in a table cell"),keystrokes:[{label:n("Move the selection to the next cell"),keystroke:"Tab"},{label:n("Move the selection to the previous cell"),keystroke:"Shift+Tab"},{label:n("Insert a new table row (when in the last cell of a table)"),keystroke:"Tab"},{label:n("Navigate through the table"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]}]})}_handleTabOnSelectedTable(t,e){const o=this.editor,l=o.model.document.selection.getSelectedElement();!l||!l.is("element","table")||(e.preventDefault(),e.stopPropagation(),t.stop(),o.model.change(s=>{s.setSelection(s.createRangeIn(l.getChild(0).getChild(0)))}))}_handleTab(t,e){const o=this.editor,n=this.editor.plugins.get(A),l=this.editor.plugins.get("TableSelection"),s=o.model.document.selection,r=!e.shiftKey;let a=n.getTableCellsContainingSelection(s)[0];if(a||(a=l.getFocusCell()),!a)return;e.preventDefault(),e.stopPropagation(),t.stop();const d=a.parent,c=d.parent,u=c.getChildIndex(d),h=d.getChildIndex(a),m=h===0;if(!r&&m&&u===0){o.model.change(f=>{f.setSelection(f.createRangeOn(c))});return}const p=h===d.childCount-1,b=u===n.getRows(c)-1;if(r&&b&&p&&(o.execute("insertTableRowBelow"),u===n.getRows(c)-1)){o.model.change(f=>{f.setSelection(f.createRangeOn(c))});return}let w;if(r&&p)w=c.getChild(u+1).getChild(0);else if(!r&&m){const f=c.getChild(u-1);w=f.getChild(f.childCount-1)}else w=d.getChild(h+(r?1:-1));o.model.change(f=>{f.setSelection(f.createRangeIn(w))})}_onArrowKey(t,e){const o=this.editor,n=e.keyCode,l=ho(n,o.locale.contentLanguageDirection);this._handleArrowKeys(l,e.shiftKey)&&(e.preventDefault(),e.stopPropagation(),t.stop())}_handleArrowKeys(t,e){const o=this.editor.plugins.get(A),n=this.editor.plugins.get("TableSelection"),l=this.editor.model,s=l.document.selection,r=["right","down"].includes(t),a=o.getSelectedTableCells(s);if(a.length){let c;return e?c=n.getFocusCell():c=r?a[a.length-1]:a[0],this._navigateFromCellInDirection(c,t,e),!0}const d=s.focus.findAncestor("tableCell");/* istanbul ignore if: paranoid check -- @preserve */if(!d)return!1;if(!s.isCollapsed)if(e){if(s.isBackward==r&&!s.containsEntireContent(d))return!1}else{const c=s.getSelectedElement();if(!c||!l.schema.isObject(c))return!1}return this._isSelectionAtCellEdge(s,d,r)?(this._navigateFromCellInDirection(d,t,e),!0):!1}_isSelectionAtCellEdge(t,e,o){const n=this.editor.model,l=this.editor.model.schema,s=o?t.getLastPosition():t.getFirstPosition();if(!l.getLimitElement(s).is("element","tableCell"))return n.createPositionAt(e,o?"end":0).isTouching(s);const r=n.createSelection(s);return n.modifySelection(r,{direction:o?"forward":"backward"}),s.isEqual(r.focus)}_navigateFromCellInDirection(t,e,o=!1){const n=this.editor.model,l=t.findAncestor("table"),s=[...new T(l,{includeAllSlots:!0})],{row:r,column:a}=s[s.length-1],d=s.find(({cell:C})=>C==t);let{row:c,column:u}=d;switch(e){case"left":u--;break;case"up":c--;break;case"right":u+=d.cellWidth;break;case"down":c+=d.cellHeight;break}const h=c<0||c>r,m=u<0&&c<=0,p=u>a&&c>=r;if(h||m||p){n.change(C=>{C.setSelection(C.createRangeOn(l))});return}u<0?(u=o?0:a,c--):u>a&&(u=o?a:0,c++);const b=s.find(C=>C.row==c&&C.column==u).cell,w=["right","down"].includes(e),f=this.editor.plugins.get("TableSelection");if(o&&f.isEnabled){const C=f.getAnchorCell()||t;f.setCellSelection(C,b)}else{const C=n.createPositionAt(b,w?0:"end");n.change(_=>{_.setSelection(C)})}}}class $t extends Oo{constructor(){super(...arguments);g(this,"domEventType",["mousemove","mouseleave"])}onDomEvent(e){this.fire(e.type,e)}}class sl extends v{static get pluginName(){return"TableMouse"}static get isOfficialPlugin(){return!0}static get requires(){return[F,A]}init(){this.editor.editing.view.addObserver($t),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const t=this.editor,e=t.plugins.get(A);let o=!1;const n=t.plugins.get(F);this.listenTo(t.editing.view.document,"mousedown",(l,s)=>{const r=t.model.document.selection;if(!this.isEnabled||!n.isEnabled||!s.domEvent.shiftKey)return;const a=n.getAnchorCell()||e.getTableCellsContainingSelection(r)[0];if(!a)return;const d=this._getModelTableCellFromDomEvent(s);d&&ct(a,d)&&(o=!0,n.setCellSelection(a,d),s.preventDefault())}),this.listenTo(t.editing.view.document,"mouseup",()=>{o=!1}),this.listenTo(t.editing.view.document,"selectionChange",l=>{o&&l.stop()},{priority:"highest"})}_enableMouseDragSelection(){const t=this.editor;let e,o,n=!1,l=!1;const s=t.plugins.get(F);this.listenTo(t.editing.view.document,"mousedown",(r,a)=>{!this.isEnabled||!s.isEnabled||a.domEvent.shiftKey||a.domEvent.ctrlKey||a.domEvent.altKey||(e=this._getModelTableCellFromDomEvent(a))}),this.listenTo(t.editing.view.document,"mousemove",(r,a)=>{if(!a.domEvent.buttons||!e)return;const d=this._getModelTableCellFromDomEvent(a);d&&ct(e,d)&&(o=d,!n&&o!=e&&(n=!0)),n&&(l=!0,s.setCellSelection(e,o),a.preventDefault())}),this.listenTo(t.editing.view.document,"mouseup",()=>{n=!1,l=!1,e=null,o=null}),this.listenTo(t.editing.view.document,"selectionChange",r=>{l&&r.stop()},{priority:"highest"})}_getModelTableCellFromDomEvent(t){const e=t.target,o=this.editor.editing.view.createPositionAt(e,0);return this.editor.editing.mapper.toModelPosition(o).parent.findAncestor("tableCell",{includeSelf:!0})}}function ct(i,t){return i.parent.parent==t.parent.parent}class ui extends v{static get requires(){return[Z,Zn,F,sl,il,el,ao]}static get pluginName(){return"Table"}static get isOfficialPlugin(){return!0}}function ue(i){const t=Gt(i);return t||pe(i)}function Gt(i){const t=i.getSelectedElement();return t&&jt(t)?t:null}function pe(i){const t=i.getFirstPosition();if(!t)return null;let e=t.parent;for(;e;){if(e.is("element")&&jt(e))return e;e=e.parent}return null}function jt(i){return!!i.getCustomProperty("table")&&co(i)}class hi extends v{static get requires(){return[$e]}static get pluginName(){return"TableToolbar"}static get isOfficialPlugin(){return!0}afterInit(){const t=this.editor,e=t.t,o=t.plugins.get($e),n=t.config.get("table.contentToolbar"),l=t.config.get("table.tableToolbar");n&&o.register("tableContent",{ariaLabel:e("Table toolbar"),items:n,getRelatedElement:pe}),l&&o.register("table",{ariaLabel:e("Table toolbar"),items:l,getRelatedElement:Gt})}}class rl extends O{constructor(e,o){super(e);g(this,"options");g(this,"focusTracker");g(this,"focusCycler");g(this,"_focusables");g(this,"dropdownView");g(this,"inputView");g(this,"keystrokes");g(this,"_stillTyping");this.set("value",""),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.options=o,this.focusTracker=new fe,this._focusables=new De,this.dropdownView=this._createDropdownView(),this.inputView=this._createInputTextView(),this.keystrokes=new be,this._stillTyping=!1,this.focusCycler=new Fe({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color"]},children:[this.dropdownView,this.inputView]}),this.on("change:value",(n,l,s)=>this._setInputValue(s))}render(){super.render(),[this.inputView,this.dropdownView.buttonView].forEach(e=>{this.focusTracker.add(e.element),this._focusables.add(e)}),this.keystrokes.listenTo(this.element)}focus(e){e===-1?this.focusCycler.focusLast():this.focusCycler.focusFirst()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createDropdownView(){const e=this.locale,o=e.t,n=this.bindTemplate,l=this._createColorSelector(e),s=oe(e),r=new O;return r.setTemplate({tag:"span",attributes:{class:["ck","ck-input-color__button__preview"],style:{backgroundColor:n.to("value")}},children:[{tag:"span",attributes:{class:["ck","ck-input-color__button__preview__no-color-indicator",n.if("value","ck-hidden",a=>a!="")]}}]}),s.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),s.buttonView.children.add(r),s.buttonView.label=o("Color picker"),s.buttonView.tooltip=!0,s.panelPosition=e.uiLanguageDirection==="rtl"?"se":"sw",s.panelView.children.add(l),s.bind("isEnabled").to(this,"isReadOnly",a=>!a),s.on("change:isOpen",(a,d,c)=>{c&&(l.updateSelectedColors(),l.showColorGridsFragment())}),s}_createInputTextView(){const e=this.locale,o=new Bo(e);return o.extendTemplate({on:{blur:o.bindTemplate.to("blur")}}),o.value=this.value,o.bind("isReadOnly","hasError").to(this),this.bind("isFocused","isEmpty").to(o),o.on("input",()=>{const n=o.element.value,l=this.options.colorDefinitions.find(s=>n===s.label);this._stillTyping=!0,this.value=l&&l.color||n}),o.on("blur",()=>{this._stillTyping=!1,this._setInputValue(o.element.value)}),o.delegate("input").to(this),o}_createColorSelector(e){const o=e.t,n=this.options.defaultColorValue||"",l=o(n?"Restore default":"Remove color"),s=new Do(e,{colors:this.options.colorDefinitions,columns:this.options.columns,removeButtonLabel:l,colorPickerLabel:o("Color picker"),colorPickerViewConfig:this.options.colorPickerConfig===!1?!1:{...this.options.colorPickerConfig,hideInput:!0}});s.appendUI(),s.on("execute",(a,d)=>{if(d.source==="colorPickerSaveButton"){this.dropdownView.isOpen=!1;return}this.value=d.value||n,this.fire("input"),d.source!=="colorPicker"&&(this.dropdownView.isOpen=!1)});let r=this.value;return s.on("colorPicker:cancel",()=>{this.value=r,this.fire("input"),this.dropdownView.isOpen=!1}),s.colorGridsFragmentView.colorPickerButtonView.on("execute",()=>{r=this.value}),s.bind("selectedColor").to(this,"value"),s}_setInputValue(e){if(!this._stillTyping){const o=dt(e),n=this.options.colorDefinitions.find(l=>o===dt(l.color));n?this.inputView.value=n.label:this.inputView.value=e||""}}}function dt(i){return i.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")}const ze=i=>i==="";function He(i){return{none:i("None"),solid:i("Solid"),dotted:i("Dotted"),dashed:i("Dashed"),double:i("Double"),groove:i("Groove"),ridge:i("Ridge"),inset:i("Inset"),outset:i("Outset")}}function Kt(i){return i('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function qt(i){return i('The value is invalid. Try "10px" or "2em" or simply "2".')}function he(i){return i=i.trim().toLowerCase(),ze(i)||zo(i)}function q(i){return i=i.trim(),ze(i)||Yt(i)||kt(i)||Ho(i)}function Xt(i){return i=i.trim(),ze(i)||Yt(i)||kt(i)}function Jt(i,t){const e=new Ct,o=He(i.t);for(const n in o){const l={type:"button",model:new vt({_borderStyleValue:n,label:o[n],role:"menuitemradio",withText:!0})};n==="none"?l.model.bind("isOn").to(i,"borderStyle",s=>t==="none"?!s:s===n):l.model.bind("isOn").to(i,"borderStyle",s=>s===n),e.add(l)}return e}function Pe(i){const{view:t,icons:e,toolbar:o,labels:n,propertyName:l,nameToValue:s,defaultValue:r}=i;for(const a in n){const d=new E(t.locale);d.set({role:"radio",isToggleable:!0,label:n[a],icon:e[a],tooltip:n[a]});const c=s?s(a):a;d.bind("isOn").to(t,l,u=>{let h=u;return u===""&&r&&(h=r),c===h}),d.on("execute",()=>{!r&&c&&t[l]===c?t[l]=void 0:t[l]=c}),o.items.add(d)}}const me=[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}];function ge(i){return(t,e,o)=>{const n=new rl(t.locale,{colorDefinitions:al(i.colorConfig),columns:i.columns,defaultColorValue:i.defaultColorValue,colorPickerConfig:i.colorPickerConfig});return n.inputView.set({id:e,ariaDescribedById:o}),n.bind("isReadOnly").to(t,"isEnabled",l=>!l),n.bind("hasError").to(t,"errorText",l=>!!l),n.on("input",()=>{t.errorText=null}),t.bind("isEmpty","isFocused").to(n),n}}function Yt(i){const t=parseFloat(i);return!Number.isNaN(t)&&i===String(t)}function al(i){return i.map(t=>({color:t.model,label:t.label,options:{hasBorder:t.hasBorder}}))}class cl extends O{constructor(e,o){super(e);g(this,"options");g(this,"focusTracker");g(this,"keystrokes");g(this,"children");g(this,"borderStyleDropdown");g(this,"borderWidthInput");g(this,"borderColorInput");g(this,"backgroundInput");g(this,"paddingInput");g(this,"widthInput");g(this,"heightInput");g(this,"horizontalAlignmentToolbar");g(this,"verticalAlignmentToolbar");g(this,"saveButtonView");g(this,"cancelButtonView");g(this,"_focusables");g(this,"_focusCycler");this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:""}),this.options=o;const{borderStyleDropdown:n,borderWidthInput:l,borderColorInput:s,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:a,backgroundInput:d}=this._createBackgroundFields(),{widthInput:c,operatorLabel:u,heightInput:h,dimensionsLabel:m}=this._createDimensionFields(),{horizontalAlignmentToolbar:p,verticalAlignmentToolbar:b,alignmentLabel:w}=this._createAlignmentFields();this.focusTracker=new fe,this.keystrokes=new be,this.children=this.createCollection(),this.borderStyleDropdown=n,this.borderWidthInput=l,this.borderColorInput=s,this.backgroundInput=d,this.paddingInput=this._createPaddingField(),this.widthInput=c,this.heightInput=h,this.horizontalAlignmentToolbar=p,this.verticalAlignmentToolbar=b;const{saveButtonView:f,cancelButtonView:C}=this._createActionButtons();this.saveButtonView=f,this.cancelButtonView=C,this._focusables=new De,this._focusCycler=new Fe({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new At(e,{label:this.t("Cell properties")})),this.children.add(new x(e,{labelView:r,children:[r,n,s,l],class:"ck-table-form__border-row"})),this.children.add(new x(e,{labelView:a,children:[a,d],class:"ck-table-form__background-row"})),this.children.add(new x(e,{children:[new x(e,{labelView:m,children:[m,c,u,h],class:"ck-table-form__dimensions-row"}),new x(e,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new x(e,{labelView:w,children:[w,p,b],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new x(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-cell-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),St({view:this}),[this.borderColorInput,this.backgroundInput].forEach(e=>{this._focusCycler.chain(e.fieldView.focusCycler)}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.paddingInput,this.horizontalAlignmentToolbar,this.verticalAlignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableCellProperties,o={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},n=ge({colorConfig:this.options.borderColors,columns:5,defaultColorValue:o.color,colorPickerConfig:this.options.colorPickerConfig}),l=this.locale,s=this.t,r=s("Style"),a=new L(l);a.text=s("Border");const d=He(s),c=new k(l,Rt);c.set({label:r,class:"ck-table-form__border-style"}),c.fieldView.buttonView.set({ariaLabel:r,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:r}),c.fieldView.buttonView.bind("label").to(this,"borderStyle",m=>d[m||"none"]),c.fieldView.on("execute",m=>{this.borderStyle=m.source._borderStyleValue}),c.bind("isEmpty").to(this,"borderStyle",m=>!m),Be(c.fieldView,Jt(this,o.style),{role:"menu",ariaLabel:r});const u=new k(l,M);u.set({label:s("Width"),class:"ck-table-form__border-width"}),u.fieldView.bind("value").to(this,"borderWidth"),u.bind("isEnabled").to(this,"borderStyle",ee),u.fieldView.on("input",()=>{this.borderWidth=u.fieldView.element.value});const h=new k(l,n);return h.set({label:s("Color"),class:"ck-table-form__border-color"}),h.fieldView.bind("value").to(this,"borderColor"),h.bind("isEnabled").to(this,"borderStyle",ee),h.fieldView.on("input",()=>{this.borderColor=h.fieldView.value}),this.on("change:borderStyle",(m,p,b,w)=>{ee(b)||(this.borderColor="",this.borderWidth=""),ee(w)||(this.borderColor=o.color,this.borderWidth=o.width)}),{borderRowLabel:a,borderStyleDropdown:c,borderColorInput:h,borderWidthInput:u}}_createBackgroundFields(){const e=this.locale,o=this.t,n=new L(e);n.text=o("Background");const l=ge({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),s=new k(e,l);return s.set({label:o("Color"),class:"ck-table-cell-properties-form__background"}),s.fieldView.bind("value").to(this,"backgroundColor"),s.fieldView.on("input",()=>{this.backgroundColor=s.fieldView.value}),{backgroundRowLabel:n,backgroundInput:s}}_createDimensionFields(){const e=this.locale,o=this.t,n=new L(e);n.text=o("Dimensions");const l=new k(e,M);l.set({label:o("Width"),class:"ck-table-form__dimensions-row__width"}),l.fieldView.bind("value").to(this,"width"),l.fieldView.on("input",()=>{this.width=l.fieldView.element.value});const s=new O(e);s.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new k(e,M);return r.set({label:o("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",()=>{this.height=r.fieldView.element.value}),{dimensionsLabel:n,widthInput:l,operatorLabel:s,heightInput:r}}_createPaddingField(){const e=this.locale,o=this.t,n=new k(e,M);return n.set({label:o("Padding"),class:"ck-table-cell-properties-form__padding"}),n.fieldView.bind("value").to(this,"padding"),n.fieldView.on("input",()=>{this.padding=n.fieldView.element.value}),n}_createAlignmentFields(){const e=this.locale,o=this.t,n=new L(e),l={left:Vo,center:ko,right:xo,justify:Io,top:Ro,middle:So,bottom:Ao};n.text=o("Table cell text alignment");const s=new _e(e),r=e.contentLanguageDirection==="rtl";s.set({isCompact:!0,role:"radiogroup",ariaLabel:o("Horizontal text alignment toolbar")}),Pe({view:this,icons:l,toolbar:s,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:d=>{if(r){if(d==="left")return"right";if(d==="right")return"left"}return d},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});const a=new _e(e);return a.set({isCompact:!0,role:"radiogroup",ariaLabel:o("Vertical text alignment toolbar")}),Pe({view:this,icons:l,toolbar:a,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:s,verticalAlignmentToolbar:a,alignmentLabel:n}}_createActionButtons(){const e=this.locale,o=this.t,n=new E(e),l=new E(e),s=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return n.set({label:o("Save"),icon:Tt,class:"ck-button-save",type:"submit",withText:!0}),n.bind("isEnabled").toMany(s,"errorText",(...r)=>r.every(a=>!a)),l.set({label:o("Cancel"),icon:_t,class:"ck-button-cancel",withText:!0}),l.delegate("execute").to(this,"cancel"),{saveButtonView:n,cancelButtonView:l}}get _horizontalAlignmentLabels(){const e=this.locale,o=this.t,n=o("Align cell text to the left"),l=o("Align cell text to the center"),s=o("Align cell text to the right"),r=o("Justify cell text");return e.uiLanguageDirection==="rtl"?{right:s,center:l,left:n,justify:r}:{left:n,center:l,right:s,justify:r}}get _verticalAlignmentLabels(){const e=this.t;return{top:e("Align cell text to the top"),middle:e("Align cell text to the middle"),bottom:e("Align cell text to the bottom")}}}function ee(i){return i!=="none"}const Ee=[N.defaultPositions.northArrowSouth,N.defaultPositions.northArrowSouthWest,N.defaultPositions.northArrowSouthEast,N.defaultPositions.southArrowNorth,N.defaultPositions.southArrowNorthWest,N.defaultPositions.southArrowNorthEast,N.defaultPositions.viewportStickyNorth];function Zt(i,t){const e=i.plugins.get("ContextualBalloon"),o=i.editing.view.document.selection;let n;t==="cell"?pe(o)&&(n=eo(i)):ue(o)&&(n=Qt(i)),n&&e.updatePosition(n)}function Qt(i){const t=i.model.document.selection,e=D(t),o=i.editing.mapper.toViewElement(e);return{target:i.editing.view.domConverter.mapViewToDom(o),positions:Ee}}function eo(i){const t=i.editing.mapper,e=i.editing.view.domConverter,o=i.model.document.selection;if(o.rangeCount>1)return{target:()=>dl(o.getRanges(),i),positions:Ee};const n=to(o.getFirstPosition()),l=t.toViewElement(n);return{target:e.mapViewToDom(l),positions:Ee}}function to(i){return i.nodeAfter&&i.nodeAfter.is("element","tableCell")?i.nodeAfter:i.findAncestor("tableCell")}function dl(i,t){const e=t.editing.mapper,o=t.editing.view.domConverter,n=Array.from(i).map(l=>{const s=to(l.start),r=e.toViewElement(s);return new re(o.mapViewToDom(r))});return re.getBoundingRect(n)}function H(i){if(!i||!$o(i))return i;const{top:t,right:e,bottom:o,left:n}=i;if(t==e&&e==o&&o==n)return t}function U(i,t){const e=parseFloat(i);return Number.isNaN(e)||String(e)!==String(i)?i:`${e}${t}`}function we(i,t={}){const e={borderStyle:"none",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",...i};return t.includeAlignmentProperty&&!e.alignment&&(e.alignment="center"),t.includePaddingProperty&&!e.padding&&(e.padding=""),t.includeVerticalAlignmentProperty&&!e.verticalAlignment&&(e.verticalAlignment="middle"),t.includeHorizontalAlignmentProperty&&!e.horizontalAlignment&&(e.horizontalAlignment=t.isRightToLeftContent?"right":"left"),e}function oo(i,t){return we({borderStyle:"double",borderColor:"hsl(0, 0%, 70%)",borderWidth:"1px",...i},t)}function Ue(i,t){return we({borderStyle:"solid",borderColor:"hsl(0, 0%, 75%)",borderWidth:"1px",...i},t)}const ul=500,ut={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",height:"tableCellHeight",width:"tableCellWidth",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment"};class hl extends v{constructor(e){super(e);g(this,"_defaultContentTableCellProperties");g(this,"_defaultLayoutTableCellProperties");g(this,"_balloon");g(this,"view");g(this,"_viewWithContentTableDefaults");g(this,"_viewWithLayoutTableDefaults");g(this,"_undoStepBatch");g(this,"_isReady");e.config.define("table.tableCellProperties",{borderColors:me,backgroundColors:me})}static get requires(){return[ae]}static get pluginName(){return"TableCellPropertiesUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,o=e.t;this._defaultContentTableCellProperties=Ue(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:e.locale.contentLanguageDirection==="rtl"}),this._defaultLayoutTableCellProperties=we(void 0,{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,isRightToLeftContent:e.locale.contentLanguageDirection==="rtl"}),this._balloon=e.plugins.get(ae),this.view=null,this._isReady=!1,e.ui.componentFactory.add("tableCellProperties",n=>{const l=new E(n);l.set({label:o("Cell properties"),icon:Co,tooltip:!0}),this.listenTo(l,"execute",()=>this._showView());const s=Object.values(ut).map(r=>e.commands.get(r));return l.bind("isEnabled").toMany(s,"isEnabled",(...r)=>r.some(a=>a)),l})}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){const o=this.editor,n=o.config.get("table.tableCellProperties"),l=ce(n.borderColors),s=de(o.locale,l),r=ce(n.backgroundColors),a=de(o.locale,r),d=n.colorPicker!==!1,c=new cl(o.locale,{borderColors:s,backgroundColors:a,defaultTableCellProperties:e,colorPickerConfig:d?n.colorPicker||{}:!1}),u=o.t;c.render(),this.listenTo(c,"submit",()=>{this._hideView()}),this.listenTo(c,"cancel",()=>{this._undoStepBatch.operations.length&&o.execute("undo",this._undoStepBatch),this._hideView()}),c.keystrokes.set("Esc",(p,b)=>{this._hideView(),b()}),yt({emitter:c,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const h=Kt(u),m=qt(u);return c.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle")),c.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:c.borderColorInput,commandName:"tableCellBorderColor",errorText:h,validator:he})),c.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:c.borderWidthInput,commandName:"tableCellBorderWidth",errorText:m,validator:Xt})),c.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:c.paddingInput,commandName:"tableCellPadding",errorText:m,validator:q})),c.on("change:width",this._getValidatedPropertyChangeCallback({viewField:c.widthInput,commandName:"tableCellWidth",errorText:m,validator:q})),c.on("change:height",this._getValidatedPropertyChangeCallback({viewField:c.heightInput,commandName:"tableCellHeight",errorText:m,validator:q})),c.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:c.backgroundInput,commandName:"tableCellBackgroundColor",errorText:h,validator:he})),c.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment")),c.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment")),c}_fillViewFormFromCommandValues(){const e=this.editor.commands,o=e.get("tableCellBorderStyle");Object.entries(ut).map(([n,l])=>{const s=n,r=this.view===this._viewWithContentTableDefaults?this._defaultContentTableCellProperties[s]||"":this._defaultLayoutTableCellProperties[s]||"";return[n,e.get(l).value||r]}).forEach(([n,l])=>{(n==="borderColor"||n==="borderWidth")&&o.value==="none"||this.view.set(n,l)}),this._isReady=!0}_showView(){const e=this.editor,o=ue(e.editing.view.document.selection),n=o&&e.editing.mapper.toModelElement(o),l=!n||n.getAttribute("tableType")!=="layout";l&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableCellProperties):!l&&!this._viewWithLayoutTableDefaults&&(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableCellProperties)),this.view=l?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:eo(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor,o=e.editing.view.document;pe(o.selection)?this._isViewVisible&&Zt(e,"cell"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(o,n,l)=>{this._isReady&&this.editor.execute(e,{value:l,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:o,viewField:n,validator:l,errorText:s}=e,r=Vt(()=>{n.errorText=s},ul);return(a,d,c)=>{r.cancel(),this._isReady&&(l(c)?(this.editor.execute(o,{value:c,batch:this._undoStepBatch}),n.errorText=null):r())}}}class W extends S{constructor(e,o,n){super(e);g(this,"attributeName");g(this,"_defaultValue");g(this,"_defaultContentTableValue");g(this,"_defaultLayoutTableValue");switch(this.attributeName=o,this._defaultContentTableValue=n,o){case"tableCellBorderStyle":this._defaultLayoutTableValue="none";break;case"tableCellHorizontalAlignment":this._defaultLayoutTableValue="left";break;case"tableCellVerticalAlignment":this._defaultLayoutTableValue="middle";break;default:this._defaultLayoutTableValue=void 0}}refresh(){const o=this.editor.model.document.selection,l=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(o),s=D(o);this._defaultValue=!s||s.getAttribute("tableType")!=="layout"?this._defaultContentTableValue:this._defaultLayoutTableValue,this.isEnabled=!!l.length,this.value=this._getSingleValue(l)}execute(e={}){const{value:o,batch:n}=e,l=this.editor.model,r=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(l.document.selection),a=this._getValueToSet(o);l.enqueueChange(n,d=>{a?r.forEach(c=>d.setAttribute(this.attributeName,a,c)):r.forEach(c=>d.removeAttribute(this.attributeName,c))})}_getAttribute(e){if(!e)return;const o=e.getAttribute(this.attributeName);if(o!==this._defaultValue)return o}_getValueToSet(e){if(e!==this._defaultValue)return e}_getSingleValue(e){const o=this._getAttribute(e[0]);return e.every(l=>this._getAttribute(l)===o)?o:void 0}}class ml extends W{constructor(t,e){super(t,"tableCellWidth",e)}_getValueToSet(t){if(t=U(t,"px"),t!==this._defaultValue)return t}}class no extends v{static get pluginName(){return"TableCellWidthEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Z]}init(){const t=this.editor,e=Ue(t.config.get("table.tableCellProperties.defaultProperties"));ie(t.model.schema,t.conversion,{modelAttribute:"tableCellWidth",styleName:"width",defaultValue:e.width}),t.commands.add("tableCellWidth",new ml(t,e.width))}}class gl extends W{constructor(t,e){super(t,"tableCellPadding",e)}_getAttribute(t){if(!t)return;const e=H(t.getAttribute(this.attributeName));if(e!==this._defaultValue)return e}_getValueToSet(t){const e=U(t,"px");if(e!==this._defaultValue)return e}}class bl extends W{constructor(t,e){super(t,"tableCellHeight",e)}_getValueToSet(t){const e=U(t,"px");if(e!==this._defaultValue)return e}}class fl extends W{constructor(t,e){super(t,"tableCellBackgroundColor",e)}}class pl extends W{constructor(t,e){super(t,"tableCellVerticalAlignment",e)}}class wl extends W{constructor(t,e){super(t,"tableCellHorizontalAlignment",e)}}class Cl extends W{constructor(t,e){super(t,"tableCellBorderStyle",e)}_getAttribute(t){if(!t)return;const e=H(t.getAttribute(this.attributeName));if(e!==this._defaultValue)return e}}class Tl extends W{constructor(t,e){super(t,"tableCellBorderColor",e)}_getAttribute(t){if(!t)return;const e=H(t.getAttribute(this.attributeName));if(e!==this._defaultValue)return e}}class _l extends W{constructor(t,e){super(t,"tableCellBorderWidth",e)}_getAttribute(t){if(!t)return;const e=H(t.getAttribute(this.attributeName));if(e!==this._defaultValue)return e}_getValueToSet(t){const e=U(t,"px");if(e!==this._defaultValue)return e}}const ht=/^(top|middle|bottom)$/,mt=/^(left|center|right|justify)$/;class yl extends v{static get pluginName(){return"TableCellPropertiesEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Z,no]}init(){const t=this.editor,e=t.model.schema,o=t.conversion;t.config.define("table.tableCellProperties.defaultProperties",{});const n=Ue(t.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:t.locale.contentLanguageDirection==="rtl"});t.data.addStyleProcessorRules(It),vl(e,o,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),t.commands.add("tableCellBorderStyle",new Cl(t,n.borderStyle)),t.commands.add("tableCellBorderColor",new Tl(t,n.borderColor)),t.commands.add("tableCellBorderWidth",new _l(t,n.borderWidth)),ie(e,o,{modelAttribute:"tableCellHeight",styleName:"height",defaultValue:n.height}),t.commands.add("tableCellHeight",new bl(t,n.height)),t.data.addStyleProcessorRules(Mo),ie(e,o,{modelAttribute:"tableCellPadding",styleName:"padding",reduceBoxSides:!0,defaultValue:n.padding}),t.commands.add("tableCellPadding",new gl(t,n.padding)),t.data.addStyleProcessorRules(xt),ie(e,o,{modelAttribute:"tableCellBackgroundColor",styleName:"background-color",defaultValue:n.backgroundColor}),t.commands.add("tableCellBackgroundColor",new fl(t,n.backgroundColor)),Al(e,o,n.horizontalAlignment),t.commands.add("tableCellHorizontalAlignment",new wl(t,n.horizontalAlignment)),Sl(e,o,n.verticalAlignment),t.commands.add("tableCellVerticalAlignment",new pl(t,n.verticalAlignment))}}function vl(i,t,e){const o={width:"tableCellBorderWidth",color:"tableCellBorderColor",style:"tableCellBorderStyle"};i.extend("tableCell",{allowAttributes:Object.values(o)}),ye(t,"td",o,e),ye(t,"th",o,e),K(t,{modelElement:"tableCell",modelAttribute:o.style,styleName:"border-style"}),K(t,{modelElement:"tableCell",modelAttribute:o.color,styleName:"border-color"}),K(t,{modelElement:"tableCell",modelAttribute:o.width,styleName:"border-width"})}function Al(i,t,e){i.extend("tableCell",{allowAttributes:["tableCellHorizontalAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellHorizontalAlignment"},view:o=>({key:"style",value:{"text-align":o}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"text-align":mt}},model:{key:"tableCellHorizontalAlignment",value:(o,n,l)=>{const s=B(e,"left",l),r=o.getStyle("text-align");return r===s?null:r}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{align:mt}},model:{key:"tableCellHorizontalAlignment",value:(o,n,l)=>{const s=B(e,"left",l),r=o.getAttribute("align");return r===s?null:r}}})}function Sl(i,t,e){i.extend("tableCell",{allowAttributes:["tableCellVerticalAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellVerticalAlignment"},view:o=>({key:"style",value:{"vertical-align":o}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"vertical-align":ht}},model:{key:"tableCellVerticalAlignment",value:(o,n,l)=>{const s=B(e,"middle",l),r=o.getStyle("vertical-align");return r===s?null:r}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{valign:ht}},model:{key:"tableCellVerticalAlignment",value:(o,n,l)=>{const s=B(e,"middle",l),r=o.getAttribute("valign");return r===s?null:r}}})}class mi extends v{static get pluginName(){return"TableCellProperties"}static get isOfficialPlugin(){return!0}static get requires(){return[yl,hl]}}class Rl extends S{refresh(){this.isEnabled=!0}execute(t={}){const{model:e,plugins:o}=this.editor;let{table:n=e.document.selection.getSelectedElement(),columnWidths:l,tableWidth:s}=t;l&&(l=Array.isArray(l)?l:l.split(",")),e.change(r=>{s?r.setAttribute("tableWidth",s,n):r.removeAttribute("tableWidth",n);const a=o.get("TableColumnResizeEditing").getColumnGroupElement(n);if(!l&&!a)return;if(!l)return r.remove(a);const d=Oe(l);if(a)Array.from(a.getChildren()).forEach((c,u)=>r.setAttribute("columnWidth",d[u],c));else{const c=r.createElement("tableColumnGroup");d.forEach(u=>r.appendElement("tableColumn",{columnWidth:u},c)),r.append(c,n)}})}}function Il(i){return t=>t.on("element:colgroup",(e,o,n)=>{const l=o.modelCursor.findAncestor("table"),s=J(l);if(!s)return;const r=Y(s),a=i.getColumns(l);let d=Rn(s,n.writer);d=Array.from({length:a},(c,u)=>d[u]||"auto"),(d.length!=r.length||d.includes("auto"))&&zt(r,s,Oe(d),n.writer)},{priority:"low"})}function xl(){return i=>i.on("insert:table",(t,e,o)=>{const n=o.writer,l=e.item,s=o.mapper.toViewElement(l),r=s.is("element","table")?s:Array.from(s.getChildren()).find(d=>d.is("element","table"));J(l)?n.addClass("ck-table-resized",r):n.removeClass("ck-table-resized",r)},{priority:"low"})}const gt=go("px");class kl extends v{constructor(e){super(e);g(this,"_isResizingActive");g(this,"_resizingData");g(this,"_domEmitter");g(this,"_tableUtilsPlugin");g(this,"_initialMouseEventData",null);this._isResizingActive=!1,this.set("_isResizingAllowed",!0),this._resizingData=null,this._domEmitter=new(mo()),this._tableUtilsPlugin=e.plugins.get("TableUtils"),this.on("change:_isResizingAllowed",(o,n,l)=>{const s=l?"removeClass":"addClass";e.editing.view.change(r=>{for(const a of e.editing.view.document.roots)r[s]("ck-column-resize_disabled",e.editing.view.document.getRoot(a.rootName))})})}static get requires(){return[Z,A]}static get pluginName(){return"TableColumnResizeEditing"}static get isOfficialPlugin(){return!0}init(){this._extendSchema(),this._registerPostFixer(),this._registerConverters(),this._registerResizingListeners(),this._registerResizerInserter();const e=this.editor,o=e.plugins.get("TableColumnResize");e.plugins.get("TableEditing").registerAdditionalSlot({filter:s=>s.is("element","tableColumnGroup"),positionOffset:0});const l=new Rl(e);e.commands.add("resizeTableWidth",l),e.commands.add("resizeColumnWidths",l),this.bind("_isResizingAllowed").to(e,"isReadOnly",o,"isEnabled",l,"isEnabled",(s,r,a)=>!s&&r&&a)}destroy(){this._domEmitter.stopListening(),super.destroy()}getColumnGroupElement(e){return J(e)}getTableColumnElements(e){return Y(e)}getTableColumnsWidths(e){return Sn(e)}_extendSchema(){this.editor.model.schema.extend("table",{allowAttributes:["tableWidth"]}),this.editor.model.schema.register("tableColumnGroup",{allowIn:"table",isLimit:!0}),this.editor.model.schema.register("tableColumn",{allowIn:"tableColumnGroup",allowAttributes:["columnWidth","colSpan"],isLimit:!0})}_registerPostFixer(){const o=this.editor.model;o.document.registerPostFixer(s=>{let r=!1;for(const a of wn(o)){const d=this.getColumnGroupElement(a),c=this.getTableColumnElements(d),u=this.getTableColumnsWidths(d);let h=Oe(u);h=n(h,a,this),!qe(u,h)&&(zt(c,d,h,s),r=!0)}return r});function n(s,r,a){const d=a._tableUtilsPlugin.getColumns(r);if(d-s.length===0)return s;const u=s.map(m=>Number(m.replace("%",""))),h=l(a.editor.model.document.differ,r);for(const m of h){const p=d-u.length;if(p===0)continue;const b=p>0,w=a._tableUtilsPlugin.getCellLocation(m).column;if(b){const f=Cn(r,a.editor),C=yn(p,f);u.splice(w,0,...C)}else{const f=u.splice(w,Math.abs(p));u[w]+=X(f)}}return u.map(m=>m+"%")}function l(s,r){const a=new Set;for(const d of s.getChanges())if(d.type=="insert"&&d.position.nodeAfter&&d.position.nodeAfter.name=="tableCell"&&d.position.nodeAfter.getAncestors().includes(r))a.add(d.position.nodeAfter);else if(d.type=="remove"){const c=d.position.nodeBefore||d.position.nodeAfter;c.name=="tableCell"&&c.getAncestors().includes(r)&&a.add(c)}return a}}_registerConverters(){const o=this.editor.conversion;o.for("upcast").attributeToAttribute({view:{name:/^(figure|table)$/,styles:{width:/[\s\S]+/}},model:{name:"table",key:"tableWidth",value:n=>{if(!n.parent.is("element","figure"))return n.getStyle("width")}}}),o.for("downcast").attributeToAttribute({model:{name:"table",key:"tableWidth"},view:n=>({name:"figure",key:"style",value:{width:n}})}),o.elementToElement({model:"tableColumnGroup",view:"colgroup"}),o.elementToElement({model:"tableColumn",view:"col"}),o.for("downcast").add(xl()),o.for("upcast").add(Il(this._tableUtilsPlugin)),o.for("upcast").attributeToAttribute({view:{name:"col",styles:{width:/.*/}},model:{key:"columnWidth",value:n=>{const l=n.getStyle("width");return!l||!l.endsWith("%")&&!l.endsWith("pt")?"auto":l}}}),o.for("upcast").attributeToAttribute({view:{name:"col",key:"span"},model:"colSpan"}),o.for("downcast").attributeToAttribute({model:{name:"tableColumn",key:"columnWidth"},view:n=>({key:"style",value:{width:n}})})}_registerResizingListeners(){const e=this.editor.editing.view;e.addObserver($t),e.document.on("mouseover",this._onMouseOverHandler.bind(this),{priority:"high"}),e.document.on("mousedown",this._onMouseDownHandler.bind(this),{priority:"high"}),e.document.on("mouseout",this._onMouseOutHandler.bind(this),{priority:"high"}),this._domEmitter.listenTo(se.window.document,"mousemove",Uo(this._onMouseMoveHandler.bind(this),50)),this._domEmitter.listenTo(se.window.document,"mouseup",this._onMouseUpHandler.bind(this))}_recalculateResizerElement(e){const o=this.editor,n=o.editing.view.domConverter,l=n.mapViewToDom(e.findAncestor("table")),s=n.mapViewToDom(e.findAncestor(u=>["td","th"].includes(u.name))),r=new re(l),a=new re(s),d=gt(Number((r.top-a.top).toFixed(4))),c=gt(Number((a.bottom-r.bottom).toFixed(4)));o.editing.view.change(u=>{u.setStyle("top",d,e),u.setStyle("bottom",c,e)})}_resetResizerStyles(e){this.editor.editing.view.change(o=>{o.removeStyle("top",e),o.removeStyle("bottom",e)})}_onMouseOverHandler(e,o){const n=o.target;n.hasClass("ck-table-column-resizer")&&this._isResizingAllowed&&this._recalculateResizerElement(n)}_onMouseOutHandler(e,o){const n=o.target;n.hasClass("ck-table-column-resizer")&&this._isResizingAllowed&&(this._isResizingActive||this._resetResizerStyles(n))}_onMouseDownHandler(e,o){const n=o.target;if(!n.hasClass("ck-table-column-resizer")||!this._isResizingAllowed)return;const l=this.editor,s=l.editing.mapper.toModelElement(n.findAncestor("figure"));l.model.canEditAt(s)&&(o.preventDefault(),e.stop(),this._initialMouseEventData=o)}_startResizingAfterThreshold(){const e=this._initialMouseEventData,{target:o}=e,n=this.editor.editing.mapper.toModelElement(o.findAncestor("figure")),l=o.findAncestor("table"),s=r(n,this._tableUtilsPlugin,this.editor);Array.from(l.getChildren()).find(c=>c.is("element","colgroup"))||this.editor.editing.view.change(c=>{a(c,s,l)}),this._isResizingActive=!0,this._resizingData=this._getResizingData(e,s),this.editor.editing.view.change(c=>d(c,l,this._resizingData));function r(c,u,h){const m=Array(u.getColumns(c)),p=new T(c);for(const b of p){const w=h.editing.mapper.toViewElement(b.cell),f=h.editing.view.domConverter.mapViewToDom(w),C=An(f);(!m[b.column]||C<m[b.column])&&(m[b.column]=I(C))}return m}function a(c,u,h){const m=c.createContainerElement("colgroup");for(let p=0;p<u.length;p++){const b=c.createEmptyElement("col"),w=`${I(u[p]/X(u)*100)}%`;c.setStyle("width",w,b),c.insert(c.createPositionAt(m,"end"),b)}c.insert(c.createPositionAt(h,0),m)}function d(c,u,h){const m=h.widths.viewFigureWidth/h.widths.viewFigureParentWidth;c.addClass("ck-table-resized",u),c.addClass("ck-table-column-resizer__active",h.elements.viewResizer),c.setStyle("width",`${I(m*100)}%`,u.findAncestor("figure"))}}_onMouseMoveHandler(e,o){if(this._initialMouseEventData){const R=this._initialMouseEventData.domEvent;if(Math.abs(o.clientX-R.clientX)>=pn)this._startResizingAfterThreshold(),this._initialMouseEventData=null;else return}if(!this._isResizingActive)return;if(!this._isResizingAllowed){this._onMouseUpHandler();return}const{columnPosition:n,flags:{isRightEdge:l,isTableCentered:s,isLtrContent:r},elements:{viewFigure:a,viewLeftColumn:d,viewRightColumn:c,viewResizer:u},widths:{viewFigureParentWidth:h,tableWidth:m,leftColumnWidth:p,rightColumnWidth:b}}=this._resizingData,w=-p+Re,f=l?h-m:b-Re,C=(r?1:-1)*(l&&s?2:1),_=_n((o.clientX-n)*C,Math.min(w,0),Math.max(f,0));_!==0&&(this.editor.editing.view.change(R=>{const V=I((p+_)*100/m);if(R.setStyle("width",`${V}%`,d),l){const P=I((m+_)*100/h);R.setStyle("width",`${P}%`,a)}else{const P=I((b-_)*100/m);R.setStyle("width",`${P}%`,c)}}),this._recalculateResizerElement(u))}_onMouseUpHandler(){if(this._initialMouseEventData=null,!this._isResizingActive)return;const{viewResizer:e,modelTable:o,viewFigure:n,viewColgroup:l}=this._resizingData.elements,s=this.editor,r=s.editing.view,a=this.getColumnGroupElement(o),d=Array.from(l.getChildren()).filter(f=>f.is("view:element")),c=a?this.getTableColumnsWidths(a):null,u=d.map(f=>f.getStyle("width")),h=!qe(c,u),m=o.getAttribute("tableWidth"),p=n.getStyle("width"),b=m!==p;(h||b)&&(this._isResizingAllowed?s.execute("resizeTableWidth",{table:o,tableWidth:`${I(p)}%`,columnWidths:u}):r.change(f=>{if(c)for(const C of d)f.setStyle("width",c.shift(),C);else f.remove(l);b&&(m?f.setStyle("width",m,n):f.removeStyle("width",n)),!c&&!m&&f.removeClass("ck-table-resized",[...n.getChildren()].find(C=>C.name==="table"))})),r.change(f=>{f.removeClass("ck-table-column-resizer__active",e)}),r.domConverter.mapViewToDom(e).matches(":hover")||this._resetResizerStyles(e),this._isResizingActive=!1,this._resizingData=null}_getResizingData(e,o){const n=this.editor,l=e.domEvent.clientX,s=e.target,r=s.findAncestor("td")||s.findAncestor("th"),a=n.editing.mapper.toModelElement(r),d=a.findAncestor("table"),c=Tn(a,this._tableUtilsPlugin).rightEdge,u=this._tableUtilsPlugin.getColumns(d)-1,h=c===u,m=!d.hasAttribute("tableAlignment"),p=n.locale.contentLanguageDirection!=="rtl",b=r.findAncestor("table"),w=b.findAncestor("figure"),f=[...b.getChildren()].find(io=>io.is("element","colgroup")),C=f.getChild(c),_=h?void 0:f.getChild(c+1),R=Ie(n.editing.view.domConverter.mapViewToDom(w.parent)),V=Ie(n.editing.view.domConverter.mapViewToDom(w)),P=Ot(d,n),G=o[c],lo=h?void 0:o[c+1];return{columnPosition:l,flags:{isRightEdge:h,isTableCentered:m,isLtrContent:p},elements:{viewResizer:s,modelTable:d,viewFigure:w,viewColgroup:f,viewLeftColumn:C,viewRightColumn:_},widths:{viewFigureParentWidth:R,viewFigureWidth:V,tableWidth:P,leftColumnWidth:G,rightColumnWidth:lo}}}_registerResizerInserter(){this.editor.conversion.for("editingDowncast").add(e=>{e.on("insert:tableCell",(o,n,l)=>{const s=n.item,r=l.mapper.toViewElement(s),a=l.writer;a.insert(a.createPositionAt(r,"end"),a.createUIElement("div",{class:"ck-table-column-resizer"}))},{priority:"lowest"})})}}class gi extends v{static get requires(){return[kl,no]}static get pluginName(){return"TableColumnResize"}static get isOfficialPlugin(){return!0}}class $ extends S{constructor(e,o,n){super(e);g(this,"attributeName");g(this,"_defaultValue");g(this,"_defaultContentTableValue");g(this,"_defaultLayoutTableValue");this.attributeName=o,this._defaultContentTableValue=n,this._defaultLayoutTableValue=o==="tableBorderStyle"?"none":void 0}refresh(){const o=this.editor.model.document.selection,n=D(o);this._defaultValue=!n||n.getAttribute("tableType")!=="layout"?this._defaultContentTableValue:this._defaultLayoutTableValue,this.isEnabled=!!n,this.value=this._getValue(n)}execute(e={}){const o=this.editor.model,n=o.document.selection,{value:l,batch:s}=e,r=D(n),a=this._getValueToSet(l);o.enqueueChange(s,d=>{a?d.setAttribute(this.attributeName,a,r):d.removeAttribute(this.attributeName,r)})}_getValue(e){if(!e)return;const o=e.getAttribute(this.attributeName);if(o!==this._defaultValue)return o}_getValueToSet(e){if(e!==this._defaultValue)return e}}class Vl extends ${constructor(t,e){super(t,"tableBackgroundColor",e)}}class Pl extends ${constructor(t,e){super(t,"tableBorderColor",e)}_getValue(t){if(!t)return;const e=H(t.getAttribute(this.attributeName));if(e!==this._defaultValue)return e}}class El extends ${constructor(t,e){super(t,"tableBorderStyle",e)}_getValue(t){if(!t)return;const e=H(t.getAttribute(this.attributeName));if(e!==this._defaultValue)return e}}class Wl extends ${constructor(t,e){super(t,"tableBorderWidth",e)}_getValue(t){if(!t)return;const e=H(t.getAttribute(this.attributeName));if(e!==this._defaultValue)return e}_getValueToSet(t){const e=U(t,"px");if(e!==this._defaultValue)return e}}class Ll extends ${constructor(t,e){super(t,"tableWidth",e)}_getValueToSet(t){if(t=U(t,"px"),t!==this._defaultValue)return t}}class Bl extends ${constructor(t,e){super(t,"tableHeight",e)}_getValueToSet(t){if(t=U(t,"px"),t!==this._defaultValue)return t}}class Dl extends ${constructor(t,e){super(t,"tableAlignment",e)}}const Fl=/^(left|center|right)$/,Nl=/^(left|none|right)$/;class Ml extends v{static get pluginName(){return"TablePropertiesEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Z]}init(){const t=this.editor,e=t.model.schema,o=t.conversion;t.config.define("table.tableProperties.defaultProperties",{});const n=oo(t.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0});t.data.addStyleProcessorRules(It),Ol(e,o,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),t.commands.add("tableBorderColor",new Pl(t,n.borderColor)),t.commands.add("tableBorderStyle",new El(t,n.borderStyle)),t.commands.add("tableBorderWidth",new Wl(t,n.borderWidth)),zl(e,o,n.alignment),t.commands.add("tableAlignment",new Dl(t,n.alignment)),bt(e,o,{modelAttribute:"tableWidth",styleName:"width",defaultValue:n.width}),t.commands.add("tableWidth",new Ll(t,n.width)),bt(e,o,{modelAttribute:"tableHeight",styleName:"height",defaultValue:n.height}),t.commands.add("tableHeight",new Bl(t,n.height)),t.data.addStyleProcessorRules(xt),Hl(e,o,{modelAttribute:"tableBackgroundColor",styleName:"background-color",defaultValue:n.backgroundColor}),t.commands.add("tableBackgroundColor",new Vl(t,n.backgroundColor))}}function Ol(i,t,e){const o={width:"tableBorderWidth",color:"tableBorderColor",style:"tableBorderStyle"};i.extend("table",{allowAttributes:Object.values(o)}),ye(t,"table",o,e),ne(t,{modelAttribute:o.color,styleName:"border-color"}),ne(t,{modelAttribute:o.style,styleName:"border-style"}),ne(t,{modelAttribute:o.width,styleName:"border-width"})}function zl(i,t,e){i.extend("table",{allowAttributes:["tableAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment",values:["left","center","right"]},view:{left:{key:"style",value:{float:"left"}},right:{key:"style",value:{float:"right"}},center:(o,n,l)=>({key:"style",value:l.item.getAttribute("tableType")!=="layout"?{float:"none"}:{"margin-left":"auto","margin-right":"auto"}})},converterPriority:"high"}),t.for("upcast").attributeToAttribute({view:{name:/^(table|figure)$/,styles:{float:Nl}},model:{key:"tableAlignment",value:(o,n,l)=>{const s=B(e,"",l);let r=o.getStyle("float");return r==="none"&&(r="center"),r===s?null:r}}}).attributeToAttribute({view:{name:/^(table|figure)$/,styles:{"margin-left":"auto","margin-right":"auto"}},model:{key:"tableAlignment",value:(o,n,l)=>{const s=B(e,"",l),r="center";return r===s?null:r}}}).attributeToAttribute({view:{attributes:{align:Fl}},model:{name:"table",key:"tableAlignment",value:(o,n,l)=>{const s=B(e,"",l),r=o.getAttribute("align");return r===s?null:r}}})}function Hl(i,t,e){const{modelAttribute:o}=e;i.extend("table",{allowAttributes:[o]}),Ne(t,{viewElement:"table",...e}),ne(t,e)}function bt(i,t,e){const{modelAttribute:o}=e;i.extend("table",{allowAttributes:[o]}),Ne(t,{viewElement:/^(table|figure)$/,shouldUpcast:n=>!(n.name=="table"&&n.parent.name=="figure"),...e}),K(t,{modelElement:"table",...e})}class Ul extends O{constructor(e,o){super(e);g(this,"options");g(this,"focusTracker");g(this,"keystrokes");g(this,"children");g(this,"borderStyleDropdown");g(this,"borderWidthInput");g(this,"borderColorInput");g(this,"backgroundInput");g(this,"widthInput");g(this,"heightInput");g(this,"alignmentToolbar");g(this,"saveButtonView");g(this,"cancelButtonView");g(this,"_focusables");g(this,"_focusCycler");this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=o;const{borderStyleDropdown:n,borderWidthInput:l,borderColorInput:s,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:a,backgroundInput:d}=this._createBackgroundFields(),{widthInput:c,operatorLabel:u,heightInput:h,dimensionsLabel:m}=this._createDimensionFields(),{alignmentToolbar:p,alignmentLabel:b}=this._createAlignmentFields();this.focusTracker=new fe,this.keystrokes=new be,this.children=this.createCollection(),this.borderStyleDropdown=n,this.borderWidthInput=l,this.borderColorInput=s,this.backgroundInput=d,this.widthInput=c,this.heightInput=h,this.alignmentToolbar=p;const{saveButtonView:w,cancelButtonView:f}=this._createActionButtons();this.saveButtonView=w,this.cancelButtonView=f,this._focusables=new De,this._focusCycler=new Fe({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new At(e,{label:this.t("Table properties")})),this.children.add(new x(e,{labelView:r,children:[r,n,s,l],class:"ck-table-form__border-row"})),this.children.add(new x(e,{labelView:a,children:[a,d],class:"ck-table-form__background-row"})),this.children.add(new x(e,{children:[new x(e,{labelView:m,children:[m,c,u,h],class:"ck-table-form__dimensions-row"}),new x(e,{labelView:b,children:[b,p],class:"ck-table-properties-form__alignment-row"})]})),this.children.add(new x(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),St({view:this}),[this.borderColorInput,this.backgroundInput].forEach(e=>{this._focusCycler.chain(e.fieldView.focusCycler)}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.alignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableProperties,o={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},n=ge({colorConfig:this.options.borderColors,columns:5,defaultColorValue:o.color,colorPickerConfig:this.options.colorPickerConfig}),l=this.locale,s=this.t,r=s("Style"),a=new L(l);a.text=s("Border");const d=He(s),c=new k(l,Rt);c.set({label:r,class:"ck-table-form__border-style"}),c.fieldView.buttonView.set({ariaLabel:r,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:r}),c.fieldView.buttonView.bind("label").to(this,"borderStyle",m=>d[m||"none"]),c.fieldView.on("execute",m=>{this.borderStyle=m.source._borderStyleValue}),c.bind("isEmpty").to(this,"borderStyle",m=>!m),Be(c.fieldView,Jt(this,o.style),{role:"menu",ariaLabel:r});const u=new k(l,M);u.set({label:s("Width"),class:"ck-table-form__border-width"}),u.fieldView.bind("value").to(this,"borderWidth"),u.bind("isEnabled").to(this,"borderStyle",te),u.fieldView.on("input",()=>{this.borderWidth=u.fieldView.element.value});const h=new k(l,n);return h.set({label:s("Color"),class:"ck-table-form__border-color"}),h.fieldView.bind("value").to(this,"borderColor"),h.bind("isEnabled").to(this,"borderStyle",te),h.fieldView.on("input",()=>{this.borderColor=h.fieldView.value}),this.on("change:borderStyle",(m,p,b,w)=>{te(b)||(this.borderColor="",this.borderWidth=""),te(w)||(this.borderColor=o.color,this.borderWidth=o.width)}),{borderRowLabel:a,borderStyleDropdown:c,borderColorInput:h,borderWidthInput:u}}_createBackgroundFields(){const e=this.locale,o=this.t,n=new L(e);n.text=o("Background");const l=ge({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),s=new k(e,l);return s.set({label:o("Color"),class:"ck-table-properties-form__background"}),s.fieldView.bind("value").to(this,"backgroundColor"),s.fieldView.on("input",()=>{this.backgroundColor=s.fieldView.value}),{backgroundRowLabel:n,backgroundInput:s}}_createDimensionFields(){const e=this.locale,o=this.t,n=new L(e);n.text=o("Dimensions");const l=new k(e,M);l.set({label:o("Width"),class:"ck-table-form__dimensions-row__width"}),l.fieldView.bind("value").to(this,"width"),l.fieldView.on("input",()=>{this.width=l.fieldView.element.value});const s=new O(e);s.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new k(e,M);return r.set({label:o("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",()=>{this.height=r.fieldView.element.value}),{dimensionsLabel:n,widthInput:l,operatorLabel:s,heightInput:r}}_createAlignmentFields(){const e=this.locale,o=this.t,n=new L(e);n.text=o("Alignment");const l=new _e(e);return l.set({role:"radiogroup",isCompact:!0,ariaLabel:o("Table alignment toolbar")}),Pe({view:this,icons:{left:vo,center:yo,right:_o},toolbar:l,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:n,alignmentToolbar:l}}_createActionButtons(){const e=this.locale,o=this.t,n=new E(e),l=new E(e),s=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return n.set({label:o("Save"),icon:Tt,class:"ck-button-save",type:"submit",withText:!0}),n.bind("isEnabled").toMany(s,"errorText",(...r)=>r.every(a=>!a)),l.set({label:o("Cancel"),icon:_t,class:"ck-button-cancel",withText:!0}),l.delegate("execute").to(this,"cancel"),{saveButtonView:n,cancelButtonView:l}}get _alignmentLabels(){const e=this.locale,o=this.t,n=o("Align table to the left"),l=o("Center table"),s=o("Align table to the right");return e.uiLanguageDirection==="rtl"?{right:s,center:l,left:n}:{left:n,center:l,right:s}}}function te(i){return i!=="none"}const $l=500,ft={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class Gl extends v{constructor(e){super(e);g(this,"_defaultContentTableProperties");g(this,"_defaultLayoutTableProperties");g(this,"_balloon");g(this,"view",null);g(this,"_viewWithContentTableDefaults",null);g(this,"_viewWithLayoutTableDefaults",null);g(this,"_undoStepBatch");g(this,"_isReady");e.config.define("table.tableProperties",{borderColors:me,backgroundColors:me})}static get requires(){return[ae]}static get pluginName(){return"TablePropertiesUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;this._defaultContentTableProperties=oo(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._defaultLayoutTableProperties=we(),this._balloon=e.plugins.get(ae),e.ui.componentFactory.add("tableProperties",()=>this._createTablePropertiesButton())}_createTablePropertiesButton(){const e=this.editor,o=e.t,n=new E(e.locale);n.set({label:o("Table properties"),icon:To,tooltip:!0}),this.listenTo(n,"execute",()=>this._showView());const l=Object.values(ft).map(s=>e.commands.get(s));return n.bind("isEnabled").toMany(l,"isEnabled",(...s)=>s.some(r=>r)),n}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){const o=this.editor,n=o.config.get("table.tableProperties"),l=ce(n.borderColors),s=de(o.locale,l),r=ce(n.backgroundColors),a=de(o.locale,r),d=n.colorPicker!==!1,c=new Ul(o.locale,{borderColors:s,backgroundColors:a,defaultTableProperties:e,colorPickerConfig:d?n.colorPicker||{}:!1}),u=o.t;c.render(),this.listenTo(c,"submit",()=>{this._hideView()}),this.listenTo(c,"cancel",()=>{this._undoStepBatch.operations.length&&o.execute("undo",this._undoStepBatch),this._hideView()}),c.keystrokes.set("Esc",(p,b)=>{this._hideView(),b()}),yt({emitter:c,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const h=Kt(u),m=qt(u);return c.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle")),c.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:c.borderColorInput,commandName:"tableBorderColor",errorText:h,validator:he})),c.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:c.borderWidthInput,commandName:"tableBorderWidth",errorText:m,validator:Xt})),c.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:c.backgroundInput,commandName:"tableBackgroundColor",errorText:h,validator:he})),c.on("change:width",this._getValidatedPropertyChangeCallback({viewField:c.widthInput,commandName:"tableWidth",errorText:m,validator:q})),c.on("change:height",this._getValidatedPropertyChangeCallback({viewField:c.heightInput,commandName:"tableHeight",errorText:m,validator:q})),c.on("change:alignment",this._getPropertyChangeCallback("tableAlignment")),c}_fillViewFormFromCommandValues(){const e=this.editor.commands,o=e.get("tableBorderStyle");Object.entries(ft).map(([n,l])=>{const s=n,r=this.view===this._viewWithContentTableDefaults?this._defaultContentTableProperties[s]||"":this._defaultLayoutTableProperties[s]||"";return[s,e.get(l).value||r]}).forEach(([n,l])=>{(n==="borderColor"||n==="borderWidth")&&o.value==="none"||this.view.set(n,l)}),this._isReady=!0}_showView(){const e=this.editor,o=ue(e.editing.view.document.selection),n=o&&e.editing.mapper.toModelElement(o),l=!n||n.getAttribute("tableType")!=="layout";l&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableProperties):!l&&!this._viewWithLayoutTableDefaults&&(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableProperties)),this.view=l?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:Qt(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor,o=e.editing.view.document;ue(o.selection)?this._isViewVisible&&Zt(e,"table"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(o,n,l)=>{this._isReady&&this.editor.execute(e,{value:l,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:o,viewField:n,validator:l,errorText:s}=e,r=Vt(()=>{n.errorText=s},$l);return(a,d,c)=>{r.cancel(),this._isReady&&(l(c)?(this.editor.execute(o,{value:c,batch:this._undoStepBatch}),n.errorText=null):r())}}}class bi extends v{static get pluginName(){return"TableProperties"}static get isOfficialPlugin(){return!0}static get requires(){return[Ml,Gl]}}/**
|
|
13
|
+
*/function zn(i){i.document.registerPostFixer(e=>Hn(e,i))}function Hn(i,e){const t=e.document.differ.getChanges();let o=!1;for(const n of t)n.type=="insert"&&n.name=="table"&&(o=Un(n.position.nodeAfter,i)||o),n.type=="insert"&&n.name=="tableRow"&&(o=zt(n.position.nodeAfter,i)||o),n.type=="insert"&&n.name=="tableCell"&&(o=Ie(n.position.nodeAfter,i)||o),(n.type=="remove"||n.type=="insert")&&$n(n)&&(o=Ie(n.position.parent,i)||o);return o}function Un(i,e){let t=!1;for(const o of i.getChildren())o.is("element","tableRow")&&(t=zt(o,e)||t);return t}function zt(i,e){let t=!1;for(const o of i.getChildren())t=Ie(o,e)||t;return t}function Ie(i,e){if(i.childCount==0)return e.insertElement("paragraph",i),!0;const t=Array.from(i.getChildren()).filter(o=>o.is("$text"));for(const o of t)e.wrap(e.createRangeOn(o),"paragraph");return!!t.length}function $n(i){return i.position.parent.is("element","tableCell")?i.type=="insert"&&i.name=="$text"||i.type=="remove":!1}function Gn(i,e){const t=i.document.differ;for(const o of t.getChanges()){let n,l=!1;if(o.type=="attribute"){const a=o.range.start.nodeAfter;if(!a||!a.is("element","table")||o.attributeKey!="headingRows"&&o.attributeKey!="headingColumns")continue;n=a,l=o.attributeKey=="headingRows"}else(o.name=="tableRow"||o.name=="tableCell")&&(n=o.position.findAncestor("table"),l=o.name=="tableRow");if(!n)continue;const s=n.getAttribute("headingRows")||0,r=n.getAttribute("headingColumns")||0,c=new C(n);for(const a of c){const u=a.row<s||a.column<r?"th":"td",h=e.mapper.toViewElement(a.cell);h&&h.is("element")&&h.name!=u&&e.reconvertItem(l?a.cell.parent:a.cell)}}}function jn(i,e){const t=i.document.differ,o=new Set;for(const n of t.getChanges()){const l=n.type=="attribute"?n.range.start.parent:n.position.parent;l.is("element","tableCell")&&o.add(l)}for(const n of o.values()){const l=Array.from(n.getChildren()).filter(s=>Kn(s,e.mapper));for(const s of l)e.reconvertItem(s)}}function Kn(i,e){if(!i.is("element","paragraph"))return!1;const t=e.toViewElement(i);return t?Vt(i)!==t.is("element","span"):!1}class Y extends y{_additionalSlots;static get pluginName(){return"TableEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[v]}constructor(e){super(e),this._additionalSlots=[]}init(){const e=this.editor,t=e.model,o=t.schema,n=e.conversion,l=e.plugins.get(v);o.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]}),o.register("tableRow",{allowIn:"table",isLimit:!0}),o.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),n.for("upcast").add(zo()),n.for("upcast").add(Ho()),n.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Xe(l,{asWidget:!0,additionalSlots:this._additionalSlots})}),n.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Xe(l,{additionalSlots:this._additionalSlots})}),n.for("upcast").elementToElement({model:"tableRow",view:"tr"}),n.for("upcast").add(Uo()),n.for("downcast").elementToElement({model:"tableRow",view:qo()}),n.for("upcast").elementToElement({model:"tableCell",view:"td"}),n.for("upcast").elementToElement({model:"tableCell",view:"th"}),n.for("upcast").add(qe("td")),n.for("upcast").add(qe("th")),n.for("editingDowncast").elementToElement({model:"tableCell",view:Je({asWidget:!0})}),n.for("dataDowncast").elementToElement({model:"tableCell",view:Je()}),n.for("editingDowncast").elementToElement({model:"paragraph",view:Ye({asWidget:!0}),converterPriority:"high"}),n.for("dataDowncast").elementToElement({model:"paragraph",view:Ye(),converterPriority:"high"}),n.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),n.for("upcast").attributeToAttribute({model:{key:"colspan",value:st("colspan")},view:"colspan"}),n.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),n.for("upcast").attributeToAttribute({model:{key:"rowspan",value:st("rowspan")},view:"rowspan"}),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.commands.add("insertTable",new Yo(e)),e.commands.add("insertTableRowAbove",new Ze(e,{order:"above"})),e.commands.add("insertTableRowBelow",new Ze(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new Qe(e,{order:"left"})),e.commands.add("insertTableColumnRight",new Qe(e,{order:"right"})),e.commands.add("removeTableRow",new nn(e)),e.commands.add("removeTableColumn",new sn(e)),e.commands.add("splitTableCellVertically",new et(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new et(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new kn(e)),e.commands.add("mergeTableCellRight",new Z(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new Z(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new Z(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new Z(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new dn(e)),e.commands.add("setTableRowHeader",new cn(e)),e.commands.add("selectTableRow",new En(e)),e.commands.add("selectTableColumn",new Wn(e)),Ln(t),zn(t),this.listenTo(t.document,"change:data",()=>{Gn(t,e.editing),jn(t,e.editing)})}registerAdditionalSlot(e){this._additionalSlots.push(e)}}function st(i){return e=>{const t=parseInt(e.getAttribute(i));return Number.isNaN(t)||t<=0?null:t}}class rt extends N{items;keystrokes;focusTracker;constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new ge,this.focusTracker=new be,this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",(o,n)=>`${n} × ${o}`),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"mouseover@.ck-insert-table-dropdown-grid-box":t.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck","ck-insert-table-dropdown__label"],"aria-hidden":!0},children:[{text:t.to("label")}]}],on:{mousedown:t.to(o=>{o.preventDefault()}),click:t.to(()=>{this.fire("execute")})}}),this.on("boxover",(o,n)=>{const{row:l,column:s}=n.target.dataset;this.items.get((parseInt(l,10)-1)*10+(parseInt(s,10)-1)).focus()}),this.focusTracker.on("change:focusedElement",(o,n,l)=>{if(!l)return;const{row:s,column:r}=l.dataset;this.set({rows:parseInt(s),columns:parseInt(r)})}),this.on("change:columns",()=>this._highlightGridBoxes()),this.on("change:rows",()=>this._highlightGridBoxes())}render(){super.render(),Vo({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:10,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection});for(const e of this.items)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element)}reset(){this.set({rows:1,columns:1})}focus(){this.items.get(0).focus()}focusLast(){this.items.get(0).focus()}_highlightGridBoxes(){const e=this.rows,t=this.columns;this.items.map((o,n)=>{const l=Math.floor(n/10),s=n%10,r=l<e&&s<t;o.set("isOn",r)})}_createGridButton(e,t,o,n){const l=new V(e);return l.set({label:n,class:"ck-insert-table-dropdown-grid-box"}),l.extendTemplate({attributes:{"data-row":t,"data-column":o}}),l}_createGridCollection(){const e=[];for(let t=0;t<100;t++){const o=Math.floor(t/10),n=t%10,l=`${o+1} × ${n+1}`;e.push(this._createGridButton(this.locale,o+1,n+1,l))}return this.createCollection(e)}}class qn extends y{static get pluginName(){return"TableUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t,n=e.locale.contentLanguageDirection==="ltr";e.ui.componentFactory.add("insertTable",l=>{const s=e.commands.get("insertTable"),r=te(l);r.bind("isEnabled").to(s),r.buttonView.set({icon:Ge,label:t("Insert table"),tooltip:!0});let c;return r.on("change:isOpen",()=>{c||(c=new rt(l),r.panelView.children.add(c),c.delegate("execute").to(r),r.on("execute",()=>{e.execute("insertTable",{rows:c.rows,columns:c.columns}),e.editing.view.focus()}))}),r}),e.ui.componentFactory.add("menuBar:insertTable",l=>{const s=e.commands.get("insertTable"),r=new Io(l),c=new rt(l);return c.delegate("execute").to(r),r.on("change:isOpen",(a,d,u)=>{u||c.reset()}),c.on("execute",()=>{e.execute("insertTable",{rows:c.rows,columns:c.columns}),e.editing.view.focus()}),r.buttonView.set({label:t("Table"),icon:Ge}),r.panelView.children.add(c),r.bind("isEnabled").to(s),r}),e.ui.componentFactory.add("tableColumn",l=>{const s=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:t("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:n?"insertTableColumnLeft":"insertTableColumnRight",label:t("Insert column left")}},{type:"button",model:{commandName:n?"insertTableColumnRight":"insertTableColumnLeft",label:t("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:t("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:t("Select column")}}];return this._prepareDropdown(t("Column"),uo,s,l)}),e.ui.componentFactory.add("tableRow",l=>{const s=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:t("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:t("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:t("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:t("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:t("Select row")}}];return this._prepareDropdown(t("Row"),ho,s,l)}),e.ui.componentFactory.add("mergeTableCells",l=>{const s=[{type:"button",model:{commandName:"mergeTableCellUp",label:t("Merge cell up")}},{type:"button",model:{commandName:n?"mergeTableCellRight":"mergeTableCellLeft",label:t("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:t("Merge cell down")}},{type:"button",model:{commandName:n?"mergeTableCellLeft":"mergeTableCellRight",label:t("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:t("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:t("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(t("Merge cells"),mo,s,l)})}_prepareDropdown(e,t,o,n){const l=this.editor,s=te(n),r=this._fillDropdownWithListOptions(s,o);return s.buttonView.set({label:e,icon:t,tooltip:!0}),s.bind("isEnabled").toMany(r,"isEnabled",(...c)=>c.some(a=>a)),this.listenTo(s,"execute",c=>{l.execute(c.source.commandName),c.source instanceof xo||l.editing.view.focus()}),s}_prepareMergeSplitButtonDropdown(e,t,o,n){const l=this.editor,s=te(n,ko),r="mergeTableCells",c=l.commands.get(r),a=this._fillDropdownWithListOptions(s,o);return s.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),s.bind("isEnabled").toMany([c,...a],"isEnabled",(...d)=>d.some(u=>u)),this.listenTo(s.buttonView,"execute",()=>{l.execute(r),l.editing.view.focus()}),this.listenTo(s,"execute",d=>{l.execute(d.source.commandName),l.editing.view.focus()}),s}_fillDropdownWithListOptions(e,t){const o=this.editor,n=[],l=new wt;for(const s of t)Xn(s,o,n,l);return Le(e,l),n}}function Xn(i,e,t,o){if(i.type==="button"||i.type==="switchbutton"){const n=i.model=new yt(i.model),{commandName:l,bindIsOn:s}=i.model,r=e.commands.get(l);t.push(r),n.set({commandName:l}),n.bind("isEnabled").to(r),s&&n.bind("isOn").to(r,"value"),n.set({withText:!0})}o.add(i)}class B extends y{static get pluginName(){return"TableSelection"}static get isOfficialPlugin(){return!0}static get requires(){return[v,v]}init(){const e=this.editor,t=e.model,o=e.editing.view;this.listenTo(t,"deleteContent",(n,l)=>this._handleDeleteContent(n,l),{priority:"high"}),this.listenTo(o.document,"insertText",(n,l)=>this._handleInsertTextEvent(n,l),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=this.editor.plugins.get(v),t=this.editor.model.document.selection,o=e.getSelectedTableCells(t);return o.length==0?null:o}getSelectionAsFragment(){const e=this.editor.plugins.get(v),t=this.getSelectedTableCells();return t?this.editor.model.change(o=>{const n=o.createDocumentFragment(),{first:l,last:s}=e.getColumnIndexes(t),{first:r,last:c}=e.getRowIndexes(t),a=t[0].findAncestor("table");let d=c,u=s;if(e.isSelectionRectangular(t)){const g={firstColumn:l,lastColumn:s,firstRow:r,lastRow:c};d=Ft(a,g),u=Nt(a,g)}const m=Pt(a,{startRow:r,startColumn:l,endRow:d,endColumn:u},o);return o.insert(m,n,0),n}):null}setCellSelection(e,t){const o=this._getCellsToSelect(e,t);this.editor.model.change(n=>{n.setSelection(o.cells.map(l=>n.createRangeOn(l)),{backward:o.backward})})}getFocusCell(){const o=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return o&&o.is("element","tableCell")?o:null}getAnchorCell(){const e=this.editor.model.document.selection,o=We(e.getRanges()).getContainedElement();return o&&o.is("element","tableCell")?o:null}_defineSelectionConverter(){const e=this.editor,t=new Set;e.conversion.for("editingDowncast").add(n=>n.on("selection",(l,s,r)=>{const c=r.writer;o(c);const a=this.getSelectedTableCells();if(!a)return;for(const u of a){const h=r.mapper.toViewElement(u);c.addClass("ck-editor__editable_selected",h),t.add(h)}const d=r.mapper.toViewElement(a[a.length-1]);c.setSelection(d,0)},{priority:"lowest"}));function o(n){for(const l of t)n.removeClass("ck-editor__editable_selected",l);t.clear()}}_enablePluginDisabling(){const e=this.editor;this.on("change:isEnabled",()=>{if(!this.isEnabled){const t=this.getSelectedTableCells();if(!t)return;e.model.change(o=>{const n=o.createPositionAt(t[0],0),l=e.model.schema.getNearestSelectionRange(n);o.setSelection(l)})}})}_handleDeleteContent(e,t){const o=this.editor.plugins.get(v),n=t[0],l=t[1],s=this.editor.model,r=!l||l.direction=="backward",c=o.getSelectedTableCells(n);c.length&&(e.stop(),s.change(a=>{const d=c[r?c.length-1:0];s.change(h=>{for(const m of c)s.deleteContent(h.createSelection(m,"in"))});const u=s.schema.getNearestSelectionRange(a.createPositionAt(d,0));n.is("documentSelection")?a.setSelection(u):n.setTo(u)}))}_handleInsertTextEvent(e,t){const o=this.editor,n=this.getSelectedTableCells();if(!n)return;const l=o.editing.view,s=o.editing.mapper,r=n.map(c=>l.createRangeOn(s.toViewElement(c)));t.selection=l.createSelection(r),t.preventDefault()}_getCellsToSelect(e,t){const o=this.editor.plugins.get("TableUtils"),n=o.getCellLocation(e),l=o.getCellLocation(t),s=Math.min(n.row,l.row),r=Math.max(n.row,l.row),c=Math.min(n.column,l.column),a=parseInt(t.getAttribute("colspan")||"1")-1,d=Math.max(n.column,l.column+a),u=new Array(r-s+1).fill(null).map(()=>[]),h={startRow:s,endRow:r,startColumn:c,endColumn:d};for(const{row:f,cell:b}of new C(e.findAncestor("table"),h))u[f-s].push(b);const m=l.row<n.row,g=l.column<n.column;return m&&u.reverse(),g&&u.forEach(f=>f.reverse()),{cells:u.flat(),backward:m||g}}}class Jn extends y{static get pluginName(){return"TableClipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[we,je,B,v]}init(){const t=this.editor.editing.view.document;this.listenTo(t,"copy",(o,n)=>this._onCopyCut(o,n)),this.listenTo(t,"cut",(o,n)=>this._onCopyCut(o,n)),this._listenToContentInsertion(),this.decorate("_replaceTableSlotCell")}_listenToContentInsertion(){const{editor:e}=this,t=e.plugins.get(je),o=e.plugins.get(B);let n=!1;t.on("contentInsertion",(l,s)=>{n=s.method==="paste"}),this.listenTo(e.model,"insertContent",(l,[s,r])=>{(n||o.getSelectedTableCells()!==null)&&this._onInsertContent(l,s,r)},{priority:"high"}),t.on("contentInsertion",()=>{n=!1},{priority:"lowest"})}_onCopyCut(e,t){const o=this.editor.editing.view,n=this.editor.plugins.get(B),l=this.editor.plugins.get(we);n.getSelectedTableCells()&&(e.name=="cut"&&!this.editor.model.canEditAt(this.editor.model.document.selection)||(t.preventDefault(),e.stop(),this.editor.model.enqueueChange({isUndoable:e.name==="cut"},()=>{const s=l._copySelectedFragmentWithMarkers(e.name,this.editor.model.document.selection,()=>n.getSelectionAsFragment());o.document.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:this.editor.data.toView(s),method:e.name})})))}_onInsertContent(e,t,o){if(o&&!o.is("documentSelection"))return;const n=this.editor.model,l=this.editor.plugins.get(v),s=this.editor.plugins.get(we),r=this.getTableIfOnlyTableInContent(t,n);if(!r)return;const c=l.getSelectionAffectedTableCells(n.document.selection);if(!c.length){Ne(r,l);return}e.stop(),t.is("documentFragment")?s._pasteMarkersIntoTransformedElement(t.markers,a=>this._replaceSelectedCells(r,c,a)):this.editor.model.change(a=>{this._replaceSelectedCells(r,c,a)})}_replaceSelectedCells(e,t,o){const n=this.editor.plugins.get(v),l={width:n.getColumns(e),height:n.getRows(e)},s=Yn(t,l,o,n),r=s.lastRow-s.firstRow+1,c=s.lastColumn-s.firstColumn+1,a={startRow:0,startColumn:0,endRow:Math.min(r,l.height)-1,endColumn:Math.min(c,l.width)-1};e=Pt(e,a,o);const d=t[0].findAncestor("table"),u=this._replaceSelectedCellsWithPasted(e,l,d,s,o);if(this.editor.plugins.get("TableSelection").isEnabled){const h=n.sortRanges(u.map(m=>o.createRangeOn(m)));o.setSelection(h)}else o.setSelection(u[0],0);return d}_replaceSelectedCellsWithPasted(e,t,o,n,l){const{width:s,height:r}=t,c=Qn(e,s,r),a=[...new C(o,{startRow:n.firstRow,endRow:n.lastRow,startColumn:n.firstColumn,endColumn:n.lastColumn,includeAllSlots:!0})],d=[];let u;for(const b of a){const{row:p,column:w}=b;w===n.firstColumn&&(u=b.getPositionBefore());const T=p-n.firstRow,x=w-n.firstColumn,k=c[T%r][x%s],G=k?l.cloneElement(k):null,U=this._replaceTableSlotCell(b,G,u,l);U&&(Dt(U,p,w,n.lastRow,n.lastColumn,l),d.push(U),u=l.createPositionAfter(U))}const h=parseInt(o.getAttribute("headingRows")||"0"),m=parseInt(o.getAttribute("headingColumns")||"0"),g=n.firstRow<h&&h<=n.lastRow,f=n.firstColumn<m&&m<=n.lastColumn;if(g){const b={first:n.firstColumn,last:n.lastColumn},p=xe(o,h,b,l,n.firstRow);d.push(...p)}if(f){const b={first:n.firstRow,last:n.lastRow},p=ke(o,m,b,l);d.push(...p)}return d}_replaceTableSlotCell(e,t,o,n){const{cell:l,isAnchor:s}=e;return s&&n.remove(l),t?(n.insert(t,o),t):null}getTableIfOnlyTableInContent(e,t){if(!e.is("documentFragment")&&!e.is("element"))return null;if(e.is("element","table"))return e;if(e.childCount==1&&e.getChild(0).is("element","table"))return e.getChild(0);const o=t.createRangeIn(e);for(const n of o.getItems())if(n.is("element","table")){const l=t.createRange(o.start,t.createPositionBefore(n));if(t.hasContent(l,{ignoreWhitespaces:!0}))return null;const s=t.createRange(t.createPositionAfter(n),o.end);return t.hasContent(s,{ignoreWhitespaces:!0})?null:n}return null}}function Yn(i,e,t,o){const n=i[0].findAncestor("table"),l=o.getColumnIndexes(i),s=o.getRowIndexes(i),r={firstColumn:l.first,lastColumn:l.last,firstRow:s.first,lastRow:s.last},c=i.length===1;return c&&(r.lastRow+=e.height-1,r.lastColumn+=e.width-1,Zn(n,r.lastRow+1,r.lastColumn+1,o)),c||!o.isSelectionRectangular(i)?el(n,r,t):(r.lastRow=Ft(n,r),r.lastColumn=Nt(n,r)),r}function Zn(i,e,t,o){const n=o.getColumns(i),l=o.getRows(i);t>n&&o.insertColumns(i,{at:n,columns:t-n}),e>l&&o.insertRows(i,{at:l,rows:e-l})}function Qn(i,e,t){const o=new Array(t).fill(null).map(()=>new Array(e).fill(null));for(const{column:n,row:l,cell:s}of new C(i))o[l][n]=s;return o}function el(i,e,t){const{firstRow:o,lastRow:n,firstColumn:l,lastColumn:s}=e,r={first:o,last:n},c={first:l,last:s};ke(i,l,r,t),ke(i,s+1,r,t),xe(i,o,c,t),xe(i,n+1,c,t,o)}function xe(i,e,t,o,n=0){return e<1?void 0:Et(i,e,n).filter(({column:r,cellWidth:c})=>Ht(r,c,t)).map(({cell:r})=>Wt(r,e,o))}function ke(i,e,t,o){return e<1?void 0:Lt(i,e).filter(({row:s,cellHeight:r})=>Ht(s,r,t)).map(({cell:s,column:r})=>Bt(s,r,e,o))}function Ht(i,e,t){const o=i+e-1,{first:n,last:l}=t,s=i>=n&&i<=l,r=i<n&&o>=n;return s||r}class tl extends y{static get pluginName(){return"TableKeyboard"}static get isOfficialPlugin(){return!0}static get requires(){return[B,v]}init(){const e=this.editor,o=e.editing.view.document,n=e.t;this.listenTo(o,"arrowKey",(...l)=>this._onArrowKey(...l),{context:"table"}),this.listenTo(o,"tab",(...l)=>this._handleTabOnSelectedTable(...l),{context:"figure"}),this.listenTo(o,"tab",(...l)=>this._handleTab(...l),{context:["th","td"]}),e.accessibility.addKeystrokeInfoGroup({id:"table",label:n("Keystrokes that can be used in a table cell"),keystrokes:[{label:n("Move the selection to the next cell"),keystroke:"Tab"},{label:n("Move the selection to the previous cell"),keystroke:"Shift+Tab"},{label:n("Insert a new table row (when in the last cell of a table)"),keystroke:"Tab"},{label:n("Navigate through the table"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]}]})}_handleTabOnSelectedTable(e,t){const o=this.editor,l=o.model.document.selection.getSelectedElement();!l||!l.is("element","table")||(t.preventDefault(),t.stopPropagation(),e.stop(),o.model.change(s=>{s.setSelection(s.createRangeIn(l.getChild(0).getChild(0)))}))}_handleTab(e,t){const o=this.editor,n=this.editor.plugins.get(v),l=this.editor.plugins.get("TableSelection"),s=o.model.document.selection,r=!t.shiftKey;let c=n.getTableCellsContainingSelection(s)[0];if(c||(c=l.getFocusCell()),!c)return;t.preventDefault(),t.stopPropagation(),e.stop();const a=c.parent,d=a.parent,u=d.getChildIndex(a),h=a.getChildIndex(c),m=h===0;if(!r&&m&&u===0){o.model.change(p=>{p.setSelection(p.createRangeOn(d))});return}const g=h===a.childCount-1,f=u===n.getRows(d)-1;if(r&&f&&g&&(o.execute("insertTableRowBelow"),u===n.getRows(d)-1)){o.model.change(p=>{p.setSelection(p.createRangeOn(d))});return}let b;if(r&&g)b=d.getChild(u+1).getChild(0);else if(!r&&m){const p=d.getChild(u-1);b=p.getChild(p.childCount-1)}else b=a.getChild(h+(r?1:-1));o.model.change(p=>{p.setSelection(p.createRangeIn(b))})}_onArrowKey(e,t){const o=this.editor,n=t.keyCode,l=ro(n,o.locale.contentLanguageDirection);this._handleArrowKeys(l,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const o=this.editor.plugins.get(v),n=this.editor.plugins.get("TableSelection"),l=this.editor.model,s=l.document.selection,r=["right","down"].includes(e),c=o.getSelectedTableCells(s);if(c.length){let d;return t?d=n.getFocusCell():d=r?c[c.length-1]:c[0],this._navigateFromCellInDirection(d,e,t),!0}const a=s.focus.findAncestor("tableCell");/* istanbul ignore if: paranoid check -- @preserve */if(!a)return!1;if(!s.isCollapsed)if(t){if(s.isBackward==r&&!s.containsEntireContent(a))return!1}else{const d=s.getSelectedElement();if(!d||!l.schema.isObject(d))return!1}return this._isSelectionAtCellEdge(s,a,r)?(this._navigateFromCellInDirection(a,e,t),!0):!1}_isSelectionAtCellEdge(e,t,o){const n=this.editor.model,l=this.editor.model.schema,s=o?e.getLastPosition():e.getFirstPosition();if(!l.getLimitElement(s).is("element","tableCell"))return n.createPositionAt(t,o?"end":0).isTouching(s);const r=n.createSelection(s);return n.modifySelection(r,{direction:o?"forward":"backward"}),s.isEqual(r.focus)}_navigateFromCellInDirection(e,t,o=!1){const n=this.editor.model,l=e.findAncestor("table"),s=[...new C(l,{includeAllSlots:!0})],{row:r,column:c}=s[s.length-1],a=s.find(({cell:w})=>w==e);let{row:d,column:u}=a;switch(t){case"left":u--;break;case"up":d--;break;case"right":u+=a.cellWidth;break;case"down":d+=a.cellHeight;break}const h=d<0||d>r,m=u<0&&d<=0,g=u>c&&d>=r;if(h||m||g){n.change(w=>{w.setSelection(w.createRangeOn(l))});return}u<0?(u=o?0:c,d--):u>c&&(u=o?c:0,d++);const f=s.find(w=>w.row==d&&w.column==u).cell,b=["right","down"].includes(t),p=this.editor.plugins.get("TableSelection");if(o&&p.isEnabled){const w=p.getAnchorCell()||e;p.setCellSelection(w,f)}else{const w=n.createPositionAt(f,b?0:"end");n.change(T=>{T.setSelection(w)})}}}class Ut extends Do{domEventType=["mousemove","mouseleave"];onDomEvent(e){this.fire(e.type,e)}}class ol extends y{static get pluginName(){return"TableMouse"}static get isOfficialPlugin(){return!0}static get requires(){return[B,v]}init(){this.editor.editing.view.addObserver(Ut),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor,t=e.plugins.get(v);let o=!1;const n=e.plugins.get(B);this.listenTo(e.editing.view.document,"mousedown",(l,s)=>{const r=e.model.document.selection;if(!this.isEnabled||!n.isEnabled||!s.domEvent.shiftKey)return;const c=n.getAnchorCell()||t.getTableCellsContainingSelection(r)[0];if(!c)return;const a=this._getModelTableCellFromDomEvent(s);a&&at(c,a)&&(o=!0,n.setCellSelection(c,a),s.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{o=!1}),this.listenTo(e.editing.view.document,"selectionChange",l=>{o&&l.stop()},{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,o,n=!1,l=!1;const s=e.plugins.get(B);this.listenTo(e.editing.view.document,"mousedown",(r,c)=>{!this.isEnabled||!s.isEnabled||c.domEvent.shiftKey||c.domEvent.ctrlKey||c.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(c))}),this.listenTo(e.editing.view.document,"mousemove",(r,c)=>{if(!c.domEvent.buttons||!t)return;const a=this._getModelTableCellFromDomEvent(c);a&&at(t,a)&&(o=a,!n&&o!=t&&(n=!0)),n&&(l=!0,s.setCellSelection(t,o),c.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{n=!1,l=!1,t=null,o=null}),this.listenTo(e.editing.view.document,"selectionChange",r=>{l&&r.stop()},{priority:"highest"})}_getModelTableCellFromDomEvent(e){const t=e.target,o=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(o).parent.findAncestor("tableCell",{includeSelf:!0})}}function at(i,e){return i.parent.parent==e.parent.parent}class si extends y{static get requires(){return[Y,qn,B,ol,tl,Jn,lo]}static get pluginName(){return"Table"}static get isOfficialPlugin(){return!0}}function de(i){const e=$t(i);return e||fe(i)}function $t(i){const e=i.getSelectedElement();return e&&Gt(e)?e:null}function fe(i){const e=i.getFirstPosition();if(!e)return null;let t=e.parent;for(;t;){if(t.is("element")&&Gt(t))return t;t=t.parent}return null}function Gt(i){return!!i.getCustomProperty("table")&&io(i)}class ri extends y{static get requires(){return[Ue]}static get pluginName(){return"TableToolbar"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=e.t,o=e.plugins.get(Ue),n=e.config.get("table.contentToolbar"),l=e.config.get("table.tableToolbar");n&&o.register("tableContent",{ariaLabel:t("Table toolbar"),items:n,getRelatedElement:fe}),l&&o.register("table",{ariaLabel:t("Table toolbar"),items:l,getRelatedElement:$t})}}class nl extends N{options;focusTracker;focusCycler;_focusables;dropdownView;inputView;keystrokes;_stillTyping;constructor(e,t){super(e),this.set("value",""),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.options=t,this.focusTracker=new be,this._focusables=new Be,this.dropdownView=this._createDropdownView(),this.inputView=this._createInputTextView(),this.keystrokes=new ge,this._stillTyping=!1,this.focusCycler=new De({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color"]},children:[this.dropdownView,this.inputView]}),this.on("change:value",(o,n,l)=>this._setInputValue(l))}render(){super.render(),[this.inputView,this.dropdownView.buttonView].forEach(e=>{this.focusTracker.add(e.element),this._focusables.add(e)}),this.keystrokes.listenTo(this.element)}focus(e){e===-1?this.focusCycler.focusLast():this.focusCycler.focusFirst()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createDropdownView(){const e=this.locale,t=e.t,o=this.bindTemplate,n=this._createColorSelector(e),l=te(e),s=new N;return s.setTemplate({tag:"span",attributes:{class:["ck","ck-input-color__button__preview"],style:{backgroundColor:o.to("value")}},children:[{tag:"span",attributes:{class:["ck","ck-input-color__button__preview__no-color-indicator",o.if("value","ck-hidden",r=>r!="")]}}]}),l.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),l.buttonView.children.add(s),l.buttonView.label=t("Color picker"),l.buttonView.tooltip=!0,l.panelPosition=e.uiLanguageDirection==="rtl"?"se":"sw",l.panelView.children.add(n),l.bind("isEnabled").to(this,"isReadOnly",r=>!r),l.on("change:isOpen",(r,c,a)=>{a&&(n.updateSelectedColors(),n.showColorGridsFragment())}),l}_createInputTextView(){const e=this.locale,t=new Po(e);return t.extendTemplate({on:{blur:t.bindTemplate.to("blur")}}),t.value=this.value,t.bind("isReadOnly","hasError").to(this),this.bind("isFocused","isEmpty").to(t),t.on("input",()=>{const o=t.element.value,n=this.options.colorDefinitions.find(l=>o===l.label);this._stillTyping=!0,this.value=n&&n.color||o}),t.on("blur",()=>{this._stillTyping=!1,this._setInputValue(t.element.value)}),t.delegate("input").to(this),t}_createColorSelector(e){const t=e.t,o=this.options.defaultColorValue||"",n=t(o?"Restore default":"Remove color"),l=new Eo(e,{colors:this.options.colorDefinitions,columns:this.options.columns,removeButtonLabel:n,colorPickerLabel:t("Color picker"),colorPickerViewConfig:this.options.colorPickerConfig===!1?!1:{...this.options.colorPickerConfig,hideInput:!0}});l.appendUI(),l.on("execute",(r,c)=>{if(c.source==="colorPickerSaveButton"){this.dropdownView.isOpen=!1;return}this.value=c.value||o,this.fire("input"),c.source!=="colorPicker"&&(this.dropdownView.isOpen=!1)});let s=this.value;return l.on("colorPicker:cancel",()=>{this.value=s,this.fire("input"),this.dropdownView.isOpen=!1}),l.colorGridsFragmentView.colorPickerButtonView.on("execute",()=>{s=this.value}),l.bind("selectedColor").to(this,"value"),l}_setInputValue(e){if(!this._stillTyping){const t=ct(e),o=this.options.colorDefinitions.find(n=>t===ct(n.color));o?this.inputView.value=o.label:this.inputView.value=e||""}}}function ct(i){return i.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")}const Oe=i=>i==="";function ze(i){return{none:i("None"),solid:i("Solid"),dotted:i("Dotted"),dashed:i("Dashed"),double:i("Double"),groove:i("Groove"),ridge:i("Ridge"),inset:i("Inset"),outset:i("Outset")}}function jt(i){return i('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function Kt(i){return i('The value is invalid. Try "10px" or "2em" or simply "2".')}function ue(i){return i=i.trim().toLowerCase(),Oe(i)||Fo(i)}function K(i){return i=i.trim(),Oe(i)||Jt(i)||xt(i)||No(i)}function qt(i){return i=i.trim(),Oe(i)||Jt(i)||xt(i)}function Xt(i,e){const t=new wt,o=ze(i.t);for(const n in o){const l={type:"button",model:new yt({_borderStyleValue:n,label:o[n],role:"menuitemradio",withText:!0})};n==="none"?l.model.bind("isOn").to(i,"borderStyle",s=>e==="none"?!s:s===n):l.model.bind("isOn").to(i,"borderStyle",s=>s===n),t.add(l)}return t}function Ve(i){const{view:e,icons:t,toolbar:o,labels:n,propertyName:l,nameToValue:s,defaultValue:r}=i;for(const c in n){const a=new V(e.locale);a.set({role:"radio",isToggleable:!0,label:n[c],icon:t[c],tooltip:n[c]});const d=s?s(c):c;a.bind("isOn").to(e,l,u=>{let h=u;return u===""&&r&&(h=r),d===h}),a.on("execute",()=>{!r&&d&&e[l]===d?e[l]=void 0:e[l]=d}),o.items.add(a)}}const he=[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}];function me(i){return(e,t,o)=>{const n=new nl(e.locale,{colorDefinitions:ll(i.colorConfig),columns:i.columns,defaultColorValue:i.defaultColorValue,colorPickerConfig:i.colorPickerConfig});return n.inputView.set({id:t,ariaDescribedById:o}),n.bind("isReadOnly").to(e,"isEnabled",l=>!l),n.bind("hasError").to(e,"errorText",l=>!!l),n.on("input",()=>{e.errorText=null}),e.bind("isEmpty","isFocused").to(n),n}}function Jt(i){const e=parseFloat(i);return!Number.isNaN(e)&&i===String(e)}function ll(i){return i.map(e=>({color:e.model,label:e.label,options:{hasBorder:e.hasBorder}}))}class il extends N{options;focusTracker;keystrokes;children;borderStyleDropdown;borderWidthInput;borderColorInput;backgroundInput;paddingInput;widthInput;heightInput;horizontalAlignmentToolbar;verticalAlignmentToolbar;saveButtonView;cancelButtonView;_focusables;_focusCycler;constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:""}),this.options=t;const{borderStyleDropdown:o,borderWidthInput:n,borderColorInput:l,borderRowLabel:s}=this._createBorderFields(),{backgroundRowLabel:r,backgroundInput:c}=this._createBackgroundFields(),{widthInput:a,operatorLabel:d,heightInput:u,dimensionsLabel:h}=this._createDimensionFields(),{horizontalAlignmentToolbar:m,verticalAlignmentToolbar:g,alignmentLabel:f}=this._createAlignmentFields();this.focusTracker=new be,this.keystrokes=new ge,this.children=this.createCollection(),this.borderStyleDropdown=o,this.borderWidthInput=n,this.borderColorInput=l,this.backgroundInput=c,this.paddingInput=this._createPaddingField(),this.widthInput=a,this.heightInput=u,this.horizontalAlignmentToolbar=m,this.verticalAlignmentToolbar=g;const{saveButtonView:b,cancelButtonView:p}=this._createActionButtons();this.saveButtonView=b,this.cancelButtonView=p,this._focusables=new Be,this._focusCycler=new De({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new vt(e,{label:this.t("Cell properties")})),this.children.add(new R(e,{labelView:s,children:[s,o,l,n],class:"ck-table-form__border-row"})),this.children.add(new R(e,{labelView:r,children:[r,c],class:"ck-table-form__background-row"})),this.children.add(new R(e,{children:[new R(e,{labelView:h,children:[h,a,d,u],class:"ck-table-form__dimensions-row"}),new R(e,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new R(e,{labelView:f,children:[f,m,g],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new R(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-cell-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),At({view:this}),[this.borderColorInput,this.backgroundInput].forEach(e=>{this._focusCycler.chain(e.fieldView.focusCycler)}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.paddingInput,this.horizontalAlignmentToolbar,this.verticalAlignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableCellProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},o=me({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),n=this.locale,l=this.t,s=l("Style"),r=new E(n);r.text=l("Border");const c=ze(l),a=new I(n,St);a.set({label:s,class:"ck-table-form__border-style"}),a.fieldView.buttonView.set({ariaLabel:s,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:s}),a.fieldView.buttonView.bind("label").to(this,"borderStyle",h=>c[h||"none"]),a.fieldView.on("execute",h=>{this.borderStyle=h.source._borderStyleValue}),a.bind("isEmpty").to(this,"borderStyle",h=>!h),Le(a.fieldView,Xt(this,t.style),{role:"menu",ariaLabel:s});const d=new I(n,F);d.set({label:l("Width"),class:"ck-table-form__border-width"}),d.fieldView.bind("value").to(this,"borderWidth"),d.bind("isEnabled").to(this,"borderStyle",Q),d.fieldView.on("input",()=>{this.borderWidth=d.fieldView.element.value});const u=new I(n,o);return u.set({label:l("Color"),class:"ck-table-form__border-color"}),u.fieldView.bind("value").to(this,"borderColor"),u.bind("isEnabled").to(this,"borderStyle",Q),u.fieldView.on("input",()=>{this.borderColor=u.fieldView.value}),this.on("change:borderStyle",(h,m,g,f)=>{Q(g)||(this.borderColor="",this.borderWidth=""),Q(f)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:r,borderStyleDropdown:a,borderColorInput:u,borderWidthInput:d}}_createBackgroundFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Background");const n=me({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),l=new I(e,n);return l.set({label:t("Color"),class:"ck-table-cell-properties-form__background"}),l.fieldView.bind("value").to(this,"backgroundColor"),l.fieldView.on("input",()=>{this.backgroundColor=l.fieldView.value}),{backgroundRowLabel:o,backgroundInput:l}}_createDimensionFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Dimensions");const n=new I(e,F);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",()=>{this.width=n.fieldView.element.value});const l=new N(e);l.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const s=new I(e,F);return s.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),s.fieldView.bind("value").to(this,"height"),s.fieldView.on("input",()=>{this.height=s.fieldView.element.value}),{dimensionsLabel:o,widthInput:n,operatorLabel:l,heightInput:s}}_createPaddingField(){const e=this.locale,t=this.t,o=new I(e,F);return o.set({label:t("Padding"),class:"ck-table-cell-properties-form__padding"}),o.fieldView.bind("value").to(this,"padding"),o.fieldView.on("input",()=>{this.padding=o.fieldView.element.value}),o}_createAlignmentFields(){const e=this.locale,t=this.t,o=new E(e),n={left:Ro,center:So,right:Ao,justify:vo,top:yo,middle:_o,bottom:To};o.text=t("Table cell text alignment");const l=new Te(e),s=e.contentLanguageDirection==="rtl";l.set({isCompact:!0,role:"radiogroup",ariaLabel:t("Horizontal text alignment toolbar")}),Ve({view:this,icons:n,toolbar:l,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:c=>{if(s){if(c==="left")return"right";if(c==="right")return"left"}return c},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});const r=new Te(e);return r.set({isCompact:!0,role:"radiogroup",ariaLabel:t("Vertical text alignment toolbar")}),Ve({view:this,icons:n,toolbar:r,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:l,verticalAlignmentToolbar:r,alignmentLabel:o}}_createActionButtons(){const e=this.locale,t=this.t,o=new V(e),n=new V(e),l=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return o.set({label:t("Save"),icon:Ct,class:"ck-button-save",type:"submit",withText:!0}),o.bind("isEnabled").toMany(l,"errorText",(...s)=>s.every(r=>!r)),n.set({label:t("Cancel"),icon:Tt,class:"ck-button-cancel",withText:!0}),n.delegate("execute").to(this,"cancel"),{saveButtonView:o,cancelButtonView:n}}get _horizontalAlignmentLabels(){const e=this.locale,t=this.t,o=t("Align cell text to the left"),n=t("Align cell text to the center"),l=t("Align cell text to the right"),s=t("Justify cell text");return e.uiLanguageDirection==="rtl"?{right:l,center:n,left:o,justify:s}:{left:o,center:n,right:l,justify:s}}get _verticalAlignmentLabels(){const e=this.t;return{top:e("Align cell text to the top"),middle:e("Align cell text to the middle"),bottom:e("Align cell text to the bottom")}}}function Q(i){return i!=="none"}const Pe=[D.defaultPositions.northArrowSouth,D.defaultPositions.northArrowSouthWest,D.defaultPositions.northArrowSouthEast,D.defaultPositions.southArrowNorth,D.defaultPositions.southArrowNorthWest,D.defaultPositions.southArrowNorthEast,D.defaultPositions.viewportStickyNorth];function Yt(i,e){const t=i.plugins.get("ContextualBalloon"),o=i.editing.view.document.selection;let n;e==="cell"?fe(o)&&(n=Qt(i)):de(o)&&(n=Zt(i)),n&&t.updatePosition(n)}function Zt(i){const e=i.model.document.selection,t=L(e),o=i.editing.mapper.toViewElement(t);return{target:i.editing.view.domConverter.mapViewToDom(o),positions:Pe}}function Qt(i){const e=i.editing.mapper,t=i.editing.view.domConverter,o=i.model.document.selection;if(o.rangeCount>1)return{target:()=>sl(o.getRanges(),i),positions:Pe};const n=eo(o.getFirstPosition()),l=e.toViewElement(n);return{target:t.mapViewToDom(l),positions:Pe}}function eo(i){return i.nodeAfter&&i.nodeAfter.is("element","tableCell")?i.nodeAfter:i.findAncestor("tableCell")}function sl(i,e){const t=e.editing.mapper,o=e.editing.view.domConverter,n=Array.from(i).map(l=>{const s=eo(l.start),r=t.toViewElement(s);return new se(o.mapViewToDom(r))});return se.getBoundingRect(n)}function O(i){if(!i||!Oo(i))return i;const{top:e,right:t,bottom:o,left:n}=i;if(e==t&&t==o&&o==n)return e}function z(i,e){const t=parseFloat(i);return Number.isNaN(t)||String(t)!==String(i)?i:`${t}${e}`}function pe(i,e={}){const t={borderStyle:"none",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",...i};return e.includeAlignmentProperty&&!t.alignment&&(t.alignment="center"),e.includePaddingProperty&&!t.padding&&(t.padding=""),e.includeVerticalAlignmentProperty&&!t.verticalAlignment&&(t.verticalAlignment="middle"),e.includeHorizontalAlignmentProperty&&!t.horizontalAlignment&&(t.horizontalAlignment=e.isRightToLeftContent?"right":"left"),t}function to(i,e){return pe({borderStyle:"double",borderColor:"hsl(0, 0%, 70%)",borderWidth:"1px",...i},e)}function He(i,e){return pe({borderStyle:"solid",borderColor:"hsl(0, 0%, 75%)",borderWidth:"1px",...i},e)}const rl=500,dt={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",height:"tableCellHeight",width:"tableCellWidth",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment"};class al extends y{_defaultContentTableCellProperties;_defaultLayoutTableCellProperties;_balloon;view;_viewWithContentTableDefaults;_viewWithLayoutTableDefaults;_undoStepBatch;_isReady;static get requires(){return[re]}static get pluginName(){return"TableCellPropertiesUI"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("table.tableCellProperties",{borderColors:he,backgroundColors:he})}init(){const e=this.editor,t=e.t;this._defaultContentTableCellProperties=He(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:e.locale.contentLanguageDirection==="rtl"}),this._defaultLayoutTableCellProperties=pe(void 0,{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,isRightToLeftContent:e.locale.contentLanguageDirection==="rtl"}),this._balloon=e.plugins.get(re),this.view=null,this._isReady=!1,e.ui.componentFactory.add("tableCellProperties",o=>{const n=new V(o);n.set({label:t("Cell properties"),icon:bo,tooltip:!0}),this.listenTo(n,"execute",()=>this._showView());const l=Object.values(dt).map(s=>e.commands.get(s));return n.bind("isEnabled").toMany(l,"isEnabled",(...s)=>s.some(r=>r)),n})}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){const t=this.editor,o=t.config.get("table.tableCellProperties"),n=ae(o.borderColors),l=ce(t.locale,n),s=ae(o.backgroundColors),r=ce(t.locale,s),c=o.colorPicker!==!1,a=new il(t.locale,{borderColors:l,backgroundColors:r,defaultTableCellProperties:e,colorPickerConfig:c?o.colorPicker||{}:!1}),d=t.t;a.render(),this.listenTo(a,"submit",()=>{this._hideView()}),this.listenTo(a,"cancel",()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._undoStepBatch),this._hideView()}),a.keystrokes.set("Esc",(m,g)=>{this._hideView(),g()}),_t({emitter:a,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const u=jt(d),h=Kt(d);return a.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle")),a.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:a.borderColorInput,commandName:"tableCellBorderColor",errorText:u,validator:ue})),a.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:a.borderWidthInput,commandName:"tableCellBorderWidth",errorText:h,validator:qt})),a.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:a.paddingInput,commandName:"tableCellPadding",errorText:h,validator:K})),a.on("change:width",this._getValidatedPropertyChangeCallback({viewField:a.widthInput,commandName:"tableCellWidth",errorText:h,validator:K})),a.on("change:height",this._getValidatedPropertyChangeCallback({viewField:a.heightInput,commandName:"tableCellHeight",errorText:h,validator:K})),a.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:a.backgroundInput,commandName:"tableCellBackgroundColor",errorText:u,validator:ue})),a.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment")),a.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment")),a}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableCellBorderStyle");Object.entries(dt).map(([o,n])=>{const l=o,s=this.view===this._viewWithContentTableDefaults?this._defaultContentTableCellProperties[l]||"":this._defaultLayoutTableCellProperties[l]||"";return[o,e.get(n).value||s]}).forEach(([o,n])=>{(o==="borderColor"||o==="borderWidth")&&t.value==="none"||this.view.set(o,n)}),this._isReady=!0}_showView(){const e=this.editor,t=de(e.editing.view.document.selection),o=t&&e.editing.mapper.toModelElement(t),n=!o||o.getAttribute("tableType")!=="layout";n&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableCellProperties):!n&&!this._viewWithLayoutTableDefaults&&(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableCellProperties)),this.view=n?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:Qt(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor,t=e.editing.view.document;fe(t.selection)?this._isViewVisible&&Yt(e,"cell"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,o,n)=>{this._isReady&&this.editor.execute(e,{value:n,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:o,validator:n,errorText:l}=e,s=kt(()=>{o.errorText=l},rl);return(r,c,a)=>{s.cancel(),this._isReady&&(n(a)?(this.editor.execute(t,{value:a,batch:this._undoStepBatch}),o.errorText=null):s())}}}class P extends A{attributeName;_defaultValue;_defaultContentTableValue;_defaultLayoutTableValue;constructor(e,t,o){switch(super(e),this.attributeName=t,this._defaultContentTableValue=o,t){case"tableCellBorderStyle":this._defaultLayoutTableValue="none";break;case"tableCellHorizontalAlignment":this._defaultLayoutTableValue="left";break;case"tableCellVerticalAlignment":this._defaultLayoutTableValue="middle";break;default:this._defaultLayoutTableValue=void 0}}refresh(){const t=this.editor.model.document.selection,n=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(t),l=L(t);this._defaultValue=!l||l.getAttribute("tableType")!=="layout"?this._defaultContentTableValue:this._defaultLayoutTableValue,this.isEnabled=!!n.length,this.value=this._getSingleValue(n)}execute(e={}){const{value:t,batch:o}=e,n=this.editor.model,s=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(n.document.selection),r=this._getValueToSet(t);n.enqueueChange(o,c=>{r?s.forEach(a=>c.setAttribute(this.attributeName,r,a)):s.forEach(a=>c.removeAttribute(this.attributeName,a))})}_getAttribute(e){if(!e)return;const t=e.getAttribute(this.attributeName);if(t!==this._defaultValue)return t}_getValueToSet(e){if(e!==this._defaultValue)return e}_getSingleValue(e){const t=this._getAttribute(e[0]);return e.every(n=>this._getAttribute(n)===t)?t:void 0}}class cl extends P{constructor(e,t){super(e,"tableCellWidth",t)}_getValueToSet(e){if(e=z(e,"px"),e!==this._defaultValue)return e}}class oo extends y{static get pluginName(){return"TableCellWidthEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Y]}init(){const e=this.editor,t=He(e.config.get("table.tableCellProperties.defaultProperties"));le(e.model.schema,e.conversion,{modelAttribute:"tableCellWidth",styleName:"width",defaultValue:t.width}),e.commands.add("tableCellWidth",new cl(e,t.width))}}class dl extends P{constructor(e,t){super(e,"tableCellPadding",t)}_getAttribute(e){if(!e)return;const t=O(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}_getValueToSet(e){const t=z(e,"px");if(t!==this._defaultValue)return t}}class ul extends P{constructor(e,t){super(e,"tableCellHeight",t)}_getValueToSet(e){const t=z(e,"px");if(t!==this._defaultValue)return t}}class hl extends P{constructor(e,t){super(e,"tableCellBackgroundColor",t)}}class ml extends P{constructor(e,t){super(e,"tableCellVerticalAlignment",t)}}class gl extends P{constructor(e,t){super(e,"tableCellHorizontalAlignment",t)}}class bl extends P{constructor(e,t){super(e,"tableCellBorderStyle",t)}_getAttribute(e){if(!e)return;const t=O(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class fl extends P{constructor(e,t){super(e,"tableCellBorderColor",t)}_getAttribute(e){if(!e)return;const t=O(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class pl extends P{constructor(e,t){super(e,"tableCellBorderWidth",t)}_getAttribute(e){if(!e)return;const t=O(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}_getValueToSet(e){const t=z(e,"px");if(t!==this._defaultValue)return t}}const ut=/^(top|middle|bottom)$/,ht=/^(left|center|right|justify)$/;class wl extends y{static get pluginName(){return"TableCellPropertiesEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Y,oo]}init(){const e=this.editor,t=e.model.schema,o=e.conversion;e.config.define("table.tableCellProperties.defaultProperties",{});const n=He(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:e.locale.contentLanguageDirection==="rtl"});e.data.addStyleProcessorRules(Rt),Cl(t,o,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableCellBorderStyle",new bl(e,n.borderStyle)),e.commands.add("tableCellBorderColor",new fl(e,n.borderColor)),e.commands.add("tableCellBorderWidth",new pl(e,n.borderWidth)),le(t,o,{modelAttribute:"tableCellHeight",styleName:"height",defaultValue:n.height}),e.commands.add("tableCellHeight",new ul(e,n.height)),e.data.addStyleProcessorRules(Bo),le(t,o,{modelAttribute:"tableCellPadding",styleName:"padding",reduceBoxSides:!0,defaultValue:n.padding}),e.commands.add("tableCellPadding",new dl(e,n.padding)),e.data.addStyleProcessorRules(It),le(t,o,{modelAttribute:"tableCellBackgroundColor",styleName:"background-color",defaultValue:n.backgroundColor}),e.commands.add("tableCellBackgroundColor",new hl(e,n.backgroundColor)),Tl(t,o,n.horizontalAlignment),e.commands.add("tableCellHorizontalAlignment",new gl(e,n.horizontalAlignment)),_l(t,o,n.verticalAlignment),e.commands.add("tableCellVerticalAlignment",new ml(e,n.verticalAlignment))}}function Cl(i,e,t){const o={width:"tableCellBorderWidth",color:"tableCellBorderColor",style:"tableCellBorderStyle"};i.extend("tableCell",{allowAttributes:Object.values(o)}),_e(e,"td",o,t),_e(e,"th",o,t),j(e,{modelElement:"tableCell",modelAttribute:o.style,styleName:"border-style"}),j(e,{modelElement:"tableCell",modelAttribute:o.color,styleName:"border-color"}),j(e,{modelElement:"tableCell",modelAttribute:o.width,styleName:"border-width"})}function Tl(i,e,t){i.extend("tableCell",{allowAttributes:["tableCellHorizontalAlignment"]}),e.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellHorizontalAlignment"},view:o=>({key:"style",value:{"text-align":o}})}),e.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"text-align":ht}},model:{key:"tableCellHorizontalAlignment",value:(o,n,l)=>{const s=W(t,"left",l),r=o.getStyle("text-align");return r===s?null:r}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{align:ht}},model:{key:"tableCellHorizontalAlignment",value:(o,n,l)=>{const s=W(t,"left",l),r=o.getAttribute("align");return r===s?null:r}}})}function _l(i,e,t){i.extend("tableCell",{allowAttributes:["tableCellVerticalAlignment"]}),e.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellVerticalAlignment"},view:o=>({key:"style",value:{"vertical-align":o}})}),e.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"vertical-align":ut}},model:{key:"tableCellVerticalAlignment",value:(o,n,l)=>{const s=W(t,"middle",l),r=o.getStyle("vertical-align");return r===s?null:r}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{valign:ut}},model:{key:"tableCellVerticalAlignment",value:(o,n,l)=>{const s=W(t,"middle",l),r=o.getAttribute("valign");return r===s?null:r}}})}class ai extends y{static get pluginName(){return"TableCellProperties"}static get isOfficialPlugin(){return!0}static get requires(){return[wl,al]}}class yl extends A{refresh(){this.isEnabled=!0}execute(e={}){const{model:t,plugins:o}=this.editor;let{table:n=t.document.selection.getSelectedElement(),columnWidths:l,tableWidth:s}=e;l&&(l=Array.isArray(l)?l:l.split(",")),t.change(r=>{s?r.setAttribute("tableWidth",s,n):r.removeAttribute("tableWidth",n);const c=o.get("TableColumnResizeEditing").getColumnGroupElement(n);if(!l&&!c)return;if(!l)return r.remove(c);const a=Me(l);if(c)Array.from(c.getChildren()).forEach((d,u)=>r.setAttribute("columnWidth",a[u],d));else{const d=r.createElement("tableColumnGroup");a.forEach(u=>r.appendElement("tableColumn",{columnWidth:u},d)),r.append(d,n)}})}}function vl(i){return e=>e.on("element:colgroup",(t,o,n)=>{const l=o.modelCursor.findAncestor("table"),s=X(l);if(!s)return;const r=J(s),c=i.getColumns(l);let a=yn(s,n.writer);a=Array.from({length:c},(d,u)=>a[u]||"auto"),(a.length!=r.length||a.includes("auto"))&&Ot(r,s,Me(a),n.writer)},{priority:"low"})}function Al(){return i=>i.on("insert:table",(e,t,o)=>{const n=o.writer,l=t.item,s=o.mapper.toViewElement(l),r=s.is("element","table")?s:Array.from(s.getChildren()).find(a=>a.is("element","table"));X(l)?n.addClass("ck-table-resized",r):n.removeClass("ck-table-resized",r)},{priority:"low"})}const mt=co("px");class Sl extends y{_isResizingActive;_resizingData;_domEmitter;_tableUtilsPlugin;_initialMouseEventData=null;static get requires(){return[Y,v]}static get pluginName(){return"TableColumnResizeEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),this._isResizingActive=!1,this.set("_isResizingAllowed",!0),this._resizingData=null,this._domEmitter=new(ao()),this._tableUtilsPlugin=e.plugins.get("TableUtils"),this.on("change:_isResizingAllowed",(t,o,n)=>{const l=n?"removeClass":"addClass";e.editing.view.change(s=>{for(const r of e.editing.view.document.roots)s[l]("ck-column-resize_disabled",e.editing.view.document.getRoot(r.rootName))})})}init(){this._extendSchema(),this._registerPostFixer(),this._registerConverters(),this._registerResizingListeners(),this._registerResizerInserter();const e=this.editor,t=e.plugins.get("TableColumnResize");e.plugins.get("TableEditing").registerAdditionalSlot({filter:l=>l.is("element","tableColumnGroup"),positionOffset:0});const n=new yl(e);e.commands.add("resizeTableWidth",n),e.commands.add("resizeColumnWidths",n),this.bind("_isResizingAllowed").to(e,"isReadOnly",t,"isEnabled",n,"isEnabled",(l,s,r)=>!l&&s&&r)}destroy(){this._domEmitter.stopListening(),super.destroy()}getColumnGroupElement(e){return X(e)}getTableColumnElements(e){return J(e)}getTableColumnsWidths(e){return _n(e)}_extendSchema(){this.editor.model.schema.extend("table",{allowAttributes:["tableWidth"]}),this.editor.model.schema.register("tableColumnGroup",{allowIn:"table",isLimit:!0}),this.editor.model.schema.register("tableColumn",{allowIn:"tableColumnGroup",allowAttributes:["columnWidth","colSpan"],isLimit:!0})}_registerPostFixer(){const t=this.editor.model;t.document.registerPostFixer(l=>{let s=!1;for(const r of gn(t)){const c=this.getColumnGroupElement(r),a=this.getTableColumnElements(c),d=this.getTableColumnsWidths(c);let u=Me(d);u=o(u,r,this),!Ke(d,u)&&(Ot(a,c,u,l),s=!0)}return s});function o(l,s,r){const c=r._tableUtilsPlugin.getColumns(s);if(c-l.length===0)return l;const d=l.map(h=>Number(h.replace("%",""))),u=n(r.editor.model.document.differ,s);for(const h of u){const m=c-d.length;if(m===0)continue;const g=m>0,f=r._tableUtilsPlugin.getCellLocation(h).column;if(g){const b=bn(s,r.editor),p=wn(m,b);d.splice(f,0,...p)}else{const b=d.splice(f,Math.abs(m));d[f]+=q(b)}}return d.map(h=>h+"%")}function n(l,s){const r=new Set;for(const c of l.getChanges())if(c.type=="insert"&&c.position.nodeAfter&&c.position.nodeAfter.name=="tableCell"&&c.position.nodeAfter.getAncestors().includes(s))r.add(c.position.nodeAfter);else if(c.type=="remove"){const a=c.position.nodeBefore||c.position.nodeAfter;a.name=="tableCell"&&a.getAncestors().includes(s)&&r.add(a)}return r}}_registerConverters(){const t=this.editor.conversion;t.for("upcast").attributeToAttribute({view:{name:/^(figure|table)$/,styles:{width:/[\s\S]+/}},model:{name:"table",key:"tableWidth",value:o=>{if(!o.parent.is("element","figure"))return o.getStyle("width")}}}),t.for("downcast").attributeToAttribute({model:{name:"table",key:"tableWidth"},view:o=>({name:"figure",key:"style",value:{width:o}})}),t.elementToElement({model:"tableColumnGroup",view:"colgroup"}),t.elementToElement({model:"tableColumn",view:"col"}),t.for("downcast").add(Al()),t.for("upcast").add(vl(this._tableUtilsPlugin)),t.for("upcast").attributeToAttribute({view:{name:"col",styles:{width:/.*/}},model:{key:"columnWidth",value:o=>{const n=o.getStyle("width");return!n||!n.endsWith("%")&&!n.endsWith("pt")?"auto":n}}}),t.for("upcast").attributeToAttribute({view:{name:"col",key:"span"},model:"colSpan"}),t.for("downcast").attributeToAttribute({model:{name:"tableColumn",key:"columnWidth"},view:o=>({key:"style",value:{width:o}})})}_registerResizingListeners(){const e=this.editor.editing.view;e.addObserver(Ut),e.document.on("mouseover",this._onMouseOverHandler.bind(this),{priority:"high"}),e.document.on("mousedown",this._onMouseDownHandler.bind(this),{priority:"high"}),e.document.on("mouseout",this._onMouseOutHandler.bind(this),{priority:"high"}),this._domEmitter.listenTo(ie.window.document,"mousemove",Mo(this._onMouseMoveHandler.bind(this),50)),this._domEmitter.listenTo(ie.window.document,"mouseup",this._onMouseUpHandler.bind(this))}_recalculateResizerElement(e){const t=this.editor,o=t.editing.view.domConverter,n=o.mapViewToDom(e.findAncestor("table")),l=o.mapViewToDom(e.findAncestor(d=>["td","th"].includes(d.name))),s=new se(n),r=new se(l),c=mt(Number((s.top-r.top).toFixed(4))),a=mt(Number((r.bottom-s.bottom).toFixed(4)));t.editing.view.change(d=>{d.setStyle("top",c,e),d.setStyle("bottom",a,e)})}_resetResizerStyles(e){this.editor.editing.view.change(t=>{t.removeStyle("top",e),t.removeStyle("bottom",e)})}_onMouseOverHandler(e,t){const o=t.target;o.hasClass("ck-table-column-resizer")&&this._isResizingAllowed&&this._recalculateResizerElement(o)}_onMouseOutHandler(e,t){const o=t.target;o.hasClass("ck-table-column-resizer")&&this._isResizingAllowed&&(this._isResizingActive||this._resetResizerStyles(o))}_onMouseDownHandler(e,t){const o=t.target;if(!o.hasClass("ck-table-column-resizer")||!this._isResizingAllowed)return;const n=this.editor,l=n.editing.mapper.toModelElement(o.findAncestor("figure"));n.model.canEditAt(l)&&(t.preventDefault(),e.stop(),this._initialMouseEventData=t)}_startResizingAfterThreshold(){const e=this._initialMouseEventData,{target:t}=e,o=this.editor.editing.mapper.toModelElement(t.findAncestor("figure")),n=t.findAncestor("table"),l=s(o,this._tableUtilsPlugin,this.editor);Array.from(n.getChildren()).find(a=>a.is("element","colgroup"))||this.editor.editing.view.change(a=>{r(a,l,n)}),this._isResizingActive=!0,this._resizingData=this._getResizingData(e,l),this.editor.editing.view.change(a=>c(a,n,this._resizingData));function s(a,d,u){const h=Array(d.getColumns(a)),m=new C(a);for(const g of m){const f=u.editing.mapper.toViewElement(g.cell),b=u.editing.view.domConverter.mapViewToDom(f),p=Tn(b);(!h[g.column]||p<h[g.column])&&(h[g.column]=S(p))}return h}function r(a,d,u){const h=a.createContainerElement("colgroup");for(let m=0;m<d.length;m++){const g=a.createEmptyElement("col"),f=`${S(d[m]/q(d)*100)}%`;a.setStyle("width",f,g),a.insert(a.createPositionAt(h,"end"),g)}a.insert(a.createPositionAt(u,0),h)}function c(a,d,u){const h=u.widths.viewFigureWidth/u.widths.viewFigureParentWidth;a.addClass("ck-table-resized",d),a.addClass("ck-table-column-resizer__active",u.elements.viewResizer),a.setStyle("width",`${S(h*100)}%`,d.findAncestor("figure"))}}_onMouseMoveHandler(e,t){if(this._initialMouseEventData){const T=this._initialMouseEventData.domEvent;if(Math.abs(t.clientX-T.clientX)>=mn)this._startResizingAfterThreshold(),this._initialMouseEventData=null;else return}if(!this._isResizingActive)return;if(!this._isResizingAllowed){this._onMouseUpHandler();return}const{columnPosition:o,flags:{isRightEdge:n,isTableCentered:l,isLtrContent:s},elements:{viewFigure:r,viewLeftColumn:c,viewRightColumn:a,viewResizer:d},widths:{viewFigureParentWidth:u,tableWidth:h,leftColumnWidth:m,rightColumnWidth:g}}=this._resizingData,f=-m+Se,b=n?u-h:g-Se,p=(s?1:-1)*(n&&l?2:1),w=pn((t.clientX-o)*p,Math.min(f,0),Math.max(b,0));w!==0&&(this.editor.editing.view.change(T=>{const x=S((m+w)*100/h);if(T.setStyle("width",`${x}%`,c),n){const k=S((h+w)*100/u);T.setStyle("width",`${k}%`,r)}else{const k=S((g-w)*100/h);T.setStyle("width",`${k}%`,a)}}),this._recalculateResizerElement(d))}_onMouseUpHandler(){if(this._initialMouseEventData=null,!this._isResizingActive)return;const{viewResizer:e,modelTable:t,viewFigure:o,viewColgroup:n}=this._resizingData.elements,l=this.editor,s=l.editing.view,r=this.getColumnGroupElement(t),c=Array.from(n.getChildren()).filter(b=>b.is("view:element")),a=r?this.getTableColumnsWidths(r):null,d=c.map(b=>b.getStyle("width")),u=!Ke(a,d),h=t.getAttribute("tableWidth"),m=o.getStyle("width"),g=h!==m;(u||g)&&(this._isResizingAllowed?l.execute("resizeTableWidth",{table:t,tableWidth:`${S(m)}%`,columnWidths:d}):s.change(b=>{if(a)for(const p of c)b.setStyle("width",a.shift(),p);else b.remove(n);g&&(h?b.setStyle("width",h,o):b.removeStyle("width",o)),!a&&!h&&b.removeClass("ck-table-resized",[...o.getChildren()].find(p=>p.name==="table"))})),s.change(b=>{b.removeClass("ck-table-column-resizer__active",e)}),s.domConverter.mapViewToDom(e).matches(":hover")||this._resetResizerStyles(e),this._isResizingActive=!1,this._resizingData=null}_getResizingData(e,t){const o=this.editor,n=e.domEvent.clientX,l=e.target,s=l.findAncestor("td")||l.findAncestor("th"),r=o.editing.mapper.toModelElement(s),c=r.findAncestor("table"),a=fn(r,this._tableUtilsPlugin).rightEdge,d=this._tableUtilsPlugin.getColumns(c)-1,u=a===d,h=!c.hasAttribute("tableAlignment"),m=o.locale.contentLanguageDirection!=="rtl",g=s.findAncestor("table"),f=g.findAncestor("figure"),b=[...g.getChildren()].find(no=>no.is("element","colgroup")),p=b.getChild(a),w=u?void 0:b.getChild(a+1),T=Re(o.editing.view.domConverter.mapViewToDom(f.parent)),x=Re(o.editing.view.domConverter.mapViewToDom(f)),k=Mt(c,o),G=t[a],U=u?void 0:t[a+1];return{columnPosition:n,flags:{isRightEdge:u,isTableCentered:h,isLtrContent:m},elements:{viewResizer:l,modelTable:c,viewFigure:f,viewColgroup:b,viewLeftColumn:p,viewRightColumn:w},widths:{viewFigureParentWidth:T,viewFigureWidth:x,tableWidth:k,leftColumnWidth:G,rightColumnWidth:U}}}_registerResizerInserter(){this.editor.conversion.for("editingDowncast").add(e=>{e.on("insert:tableCell",(t,o,n)=>{const l=o.item,s=n.mapper.toViewElement(l),r=n.writer;r.insert(r.createPositionAt(s,"end"),r.createUIElement("div",{class:"ck-table-column-resizer"}))},{priority:"lowest"})})}}class ci extends y{static get requires(){return[Sl,oo]}static get pluginName(){return"TableColumnResize"}static get isOfficialPlugin(){return!0}}class H extends A{attributeName;_defaultValue;_defaultContentTableValue;_defaultLayoutTableValue;constructor(e,t,o){super(e),this.attributeName=t,this._defaultContentTableValue=o,this._defaultLayoutTableValue=t==="tableBorderStyle"?"none":void 0}refresh(){const t=this.editor.model.document.selection,o=L(t);this._defaultValue=!o||o.getAttribute("tableType")!=="layout"?this._defaultContentTableValue:this._defaultLayoutTableValue,this.isEnabled=!!o,this.value=this._getValue(o)}execute(e={}){const t=this.editor.model,o=t.document.selection,{value:n,batch:l}=e,s=L(o),r=this._getValueToSet(n);t.enqueueChange(l,c=>{r?c.setAttribute(this.attributeName,r,s):c.removeAttribute(this.attributeName,s)})}_getValue(e){if(!e)return;const t=e.getAttribute(this.attributeName);if(t!==this._defaultValue)return t}_getValueToSet(e){if(e!==this._defaultValue)return e}}class Rl extends H{constructor(e,t){super(e,"tableBackgroundColor",t)}}class Il extends H{constructor(e,t){super(e,"tableBorderColor",t)}_getValue(e){if(!e)return;const t=O(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class xl extends H{constructor(e,t){super(e,"tableBorderStyle",t)}_getValue(e){if(!e)return;const t=O(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class kl extends H{constructor(e,t){super(e,"tableBorderWidth",t)}_getValue(e){if(!e)return;const t=O(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}_getValueToSet(e){const t=z(e,"px");if(t!==this._defaultValue)return t}}class Vl extends H{constructor(e,t){super(e,"tableWidth",t)}_getValueToSet(e){if(e=z(e,"px"),e!==this._defaultValue)return e}}class Pl extends H{constructor(e,t){super(e,"tableHeight",t)}_getValueToSet(e){if(e=z(e,"px"),e!==this._defaultValue)return e}}class El extends H{constructor(e,t){super(e,"tableAlignment",t)}}const Wl=/^(left|center|right)$/,Ll=/^(left|none|right)$/;class Bl extends y{static get pluginName(){return"TablePropertiesEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Y]}init(){const e=this.editor,t=e.model.schema,o=e.conversion;e.config.define("table.tableProperties.defaultProperties",{});const n=to(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0});e.data.addStyleProcessorRules(Rt),Dl(t,o,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableBorderColor",new Il(e,n.borderColor)),e.commands.add("tableBorderStyle",new xl(e,n.borderStyle)),e.commands.add("tableBorderWidth",new kl(e,n.borderWidth)),Fl(t,o,n.alignment),e.commands.add("tableAlignment",new El(e,n.alignment)),gt(t,o,{modelAttribute:"tableWidth",styleName:"width",defaultValue:n.width}),e.commands.add("tableWidth",new Vl(e,n.width)),gt(t,o,{modelAttribute:"tableHeight",styleName:"height",defaultValue:n.height}),e.commands.add("tableHeight",new Pl(e,n.height)),e.data.addStyleProcessorRules(It),Nl(t,o,{modelAttribute:"tableBackgroundColor",styleName:"background-color",defaultValue:n.backgroundColor}),e.commands.add("tableBackgroundColor",new Rl(e,n.backgroundColor))}}function Dl(i,e,t){const o={width:"tableBorderWidth",color:"tableBorderColor",style:"tableBorderStyle"};i.extend("table",{allowAttributes:Object.values(o)}),_e(e,"table",o,t),oe(e,{modelAttribute:o.color,styleName:"border-color"}),oe(e,{modelAttribute:o.style,styleName:"border-style"}),oe(e,{modelAttribute:o.width,styleName:"border-width"})}function Fl(i,e,t){i.extend("table",{allowAttributes:["tableAlignment"]}),e.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment",values:["left","center","right"]},view:{left:{key:"style",value:{float:"left"}},right:{key:"style",value:{float:"right"}},center:(o,n,l)=>({key:"style",value:l.item.getAttribute("tableType")!=="layout"?{float:"none"}:{"margin-left":"auto","margin-right":"auto"}})},converterPriority:"high"}),e.for("upcast").attributeToAttribute({view:{name:/^(table|figure)$/,styles:{float:Ll}},model:{key:"tableAlignment",value:(o,n,l)=>{const s=W(t,"",l);let r=o.getStyle("float");return r==="none"&&(r="center"),r===s?null:r}}}).attributeToAttribute({view:{name:/^(table|figure)$/,styles:{"margin-left":"auto","margin-right":"auto"}},model:{key:"tableAlignment",value:(o,n,l)=>{const s=W(t,"",l),r="center";return r===s?null:r}}}).attributeToAttribute({view:{attributes:{align:Wl}},model:{name:"table",key:"tableAlignment",value:(o,n,l)=>{const s=W(t,"",l),r=o.getAttribute("align");return r===s?null:r}}})}function Nl(i,e,t){const{modelAttribute:o}=t;i.extend("table",{allowAttributes:[o]}),Fe(e,{viewElement:"table",...t}),oe(e,t)}function gt(i,e,t){const{modelAttribute:o}=t;i.extend("table",{allowAttributes:[o]}),Fe(e,{viewElement:/^(table|figure)$/,shouldUpcast:n=>!(n.name=="table"&&n.parent.name=="figure"),...t}),j(e,{modelElement:"table",...t})}class Ml extends N{options;focusTracker;keystrokes;children;borderStyleDropdown;borderWidthInput;borderColorInput;backgroundInput;widthInput;heightInput;alignmentToolbar;saveButtonView;cancelButtonView;_focusables;_focusCycler;constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=t;const{borderStyleDropdown:o,borderWidthInput:n,borderColorInput:l,borderRowLabel:s}=this._createBorderFields(),{backgroundRowLabel:r,backgroundInput:c}=this._createBackgroundFields(),{widthInput:a,operatorLabel:d,heightInput:u,dimensionsLabel:h}=this._createDimensionFields(),{alignmentToolbar:m,alignmentLabel:g}=this._createAlignmentFields();this.focusTracker=new be,this.keystrokes=new ge,this.children=this.createCollection(),this.borderStyleDropdown=o,this.borderWidthInput=n,this.borderColorInput=l,this.backgroundInput=c,this.widthInput=a,this.heightInput=u,this.alignmentToolbar=m;const{saveButtonView:f,cancelButtonView:b}=this._createActionButtons();this.saveButtonView=f,this.cancelButtonView=b,this._focusables=new Be,this._focusCycler=new De({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new vt(e,{label:this.t("Table properties")})),this.children.add(new R(e,{labelView:s,children:[s,o,l,n],class:"ck-table-form__border-row"})),this.children.add(new R(e,{labelView:r,children:[r,c],class:"ck-table-form__background-row"})),this.children.add(new R(e,{children:[new R(e,{labelView:h,children:[h,a,d,u],class:"ck-table-form__dimensions-row"}),new R(e,{labelView:g,children:[g,m],class:"ck-table-properties-form__alignment-row"})]})),this.children.add(new R(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),At({view:this}),[this.borderColorInput,this.backgroundInput].forEach(e=>{this._focusCycler.chain(e.fieldView.focusCycler)}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.alignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},o=me({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),n=this.locale,l=this.t,s=l("Style"),r=new E(n);r.text=l("Border");const c=ze(l),a=new I(n,St);a.set({label:s,class:"ck-table-form__border-style"}),a.fieldView.buttonView.set({ariaLabel:s,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:s}),a.fieldView.buttonView.bind("label").to(this,"borderStyle",h=>c[h||"none"]),a.fieldView.on("execute",h=>{this.borderStyle=h.source._borderStyleValue}),a.bind("isEmpty").to(this,"borderStyle",h=>!h),Le(a.fieldView,Xt(this,t.style),{role:"menu",ariaLabel:s});const d=new I(n,F);d.set({label:l("Width"),class:"ck-table-form__border-width"}),d.fieldView.bind("value").to(this,"borderWidth"),d.bind("isEnabled").to(this,"borderStyle",ee),d.fieldView.on("input",()=>{this.borderWidth=d.fieldView.element.value});const u=new I(n,o);return u.set({label:l("Color"),class:"ck-table-form__border-color"}),u.fieldView.bind("value").to(this,"borderColor"),u.bind("isEnabled").to(this,"borderStyle",ee),u.fieldView.on("input",()=>{this.borderColor=u.fieldView.value}),this.on("change:borderStyle",(h,m,g,f)=>{ee(g)||(this.borderColor="",this.borderWidth=""),ee(f)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:r,borderStyleDropdown:a,borderColorInput:u,borderWidthInput:d}}_createBackgroundFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Background");const n=me({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),l=new I(e,n);return l.set({label:t("Color"),class:"ck-table-properties-form__background"}),l.fieldView.bind("value").to(this,"backgroundColor"),l.fieldView.on("input",()=>{this.backgroundColor=l.fieldView.value}),{backgroundRowLabel:o,backgroundInput:l}}_createDimensionFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Dimensions");const n=new I(e,F);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",()=>{this.width=n.fieldView.element.value});const l=new N(e);l.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const s=new I(e,F);return s.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),s.fieldView.bind("value").to(this,"height"),s.fieldView.on("input",()=>{this.height=s.fieldView.element.value}),{dimensionsLabel:o,widthInput:n,operatorLabel:l,heightInput:s}}_createAlignmentFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Alignment");const n=new Te(e);return n.set({role:"radiogroup",isCompact:!0,ariaLabel:t("Table alignment toolbar")}),Ve({view:this,icons:{left:Co,center:wo,right:po},toolbar:n,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:o,alignmentToolbar:n}}_createActionButtons(){const e=this.locale,t=this.t,o=new V(e),n=new V(e),l=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return o.set({label:t("Save"),icon:Ct,class:"ck-button-save",type:"submit",withText:!0}),o.bind("isEnabled").toMany(l,"errorText",(...s)=>s.every(r=>!r)),n.set({label:t("Cancel"),icon:Tt,class:"ck-button-cancel",withText:!0}),n.delegate("execute").to(this,"cancel"),{saveButtonView:o,cancelButtonView:n}}get _alignmentLabels(){const e=this.locale,t=this.t,o=t("Align table to the left"),n=t("Center table"),l=t("Align table to the right");return e.uiLanguageDirection==="rtl"?{right:l,center:n,left:o}:{left:o,center:n,right:l}}}function ee(i){return i!=="none"}const Ol=500,bt={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class zl extends y{_defaultContentTableProperties;_defaultLayoutTableProperties;_balloon;view=null;_viewWithContentTableDefaults=null;_viewWithLayoutTableDefaults=null;_undoStepBatch;_isReady;static get requires(){return[re]}static get pluginName(){return"TablePropertiesUI"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("table.tableProperties",{borderColors:he,backgroundColors:he})}init(){const e=this.editor;this._defaultContentTableProperties=to(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._defaultLayoutTableProperties=pe(),this._balloon=e.plugins.get(re),e.ui.componentFactory.add("tableProperties",()=>this._createTablePropertiesButton())}_createTablePropertiesButton(){const e=this.editor,t=e.t,o=new V(e.locale);o.set({label:t("Table properties"),icon:fo,tooltip:!0}),this.listenTo(o,"execute",()=>this._showView());const n=Object.values(bt).map(l=>e.commands.get(l));return o.bind("isEnabled").toMany(n,"isEnabled",(...l)=>l.some(s=>s)),o}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){const t=this.editor,o=t.config.get("table.tableProperties"),n=ae(o.borderColors),l=ce(t.locale,n),s=ae(o.backgroundColors),r=ce(t.locale,s),c=o.colorPicker!==!1,a=new Ml(t.locale,{borderColors:l,backgroundColors:r,defaultTableProperties:e,colorPickerConfig:c?o.colorPicker||{}:!1}),d=t.t;a.render(),this.listenTo(a,"submit",()=>{this._hideView()}),this.listenTo(a,"cancel",()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._undoStepBatch),this._hideView()}),a.keystrokes.set("Esc",(m,g)=>{this._hideView(),g()}),_t({emitter:a,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const u=jt(d),h=Kt(d);return a.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle")),a.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:a.borderColorInput,commandName:"tableBorderColor",errorText:u,validator:ue})),a.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:a.borderWidthInput,commandName:"tableBorderWidth",errorText:h,validator:qt})),a.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:a.backgroundInput,commandName:"tableBackgroundColor",errorText:u,validator:ue})),a.on("change:width",this._getValidatedPropertyChangeCallback({viewField:a.widthInput,commandName:"tableWidth",errorText:h,validator:K})),a.on("change:height",this._getValidatedPropertyChangeCallback({viewField:a.heightInput,commandName:"tableHeight",errorText:h,validator:K})),a.on("change:alignment",this._getPropertyChangeCallback("tableAlignment")),a}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableBorderStyle");Object.entries(bt).map(([o,n])=>{const l=o,s=this.view===this._viewWithContentTableDefaults?this._defaultContentTableProperties[l]||"":this._defaultLayoutTableProperties[l]||"";return[l,e.get(n).value||s]}).forEach(([o,n])=>{(o==="borderColor"||o==="borderWidth")&&t.value==="none"||this.view.set(o,n)}),this._isReady=!0}_showView(){const e=this.editor,t=de(e.editing.view.document.selection),o=t&&e.editing.mapper.toModelElement(t),n=!o||o.getAttribute("tableType")!=="layout";n&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableProperties):!n&&!this._viewWithLayoutTableDefaults&&(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableProperties)),this.view=n?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:Zt(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor,t=e.editing.view.document;de(t.selection)?this._isViewVisible&&Yt(e,"table"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,o,n)=>{this._isReady&&this.editor.execute(e,{value:n,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:o,validator:n,errorText:l}=e,s=kt(()=>{o.errorText=l},Ol);return(r,c,a)=>{s.cancel(),this._isReady&&(n(a)?(this.editor.execute(t,{value:a,batch:this._undoStepBatch}),o.errorText=null):s())}}}class di extends y{static get pluginName(){return"TableProperties"}static get isOfficialPlugin(){return!0}static get requires(){return[Bl,zl]}}/**
|
|
14
14
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
15
15
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
16
|
-
*/function
|
|
16
|
+
*/function Hl(i){i.document.registerPostFixer(e=>Ul(e,i))}function Ul(i,e){const t=e.document.differ.getChanges();let o=!1;for(const n of t){if(n.type!="insert")continue;const l=n.position.parent;if(l.is("element","table")||n.name=="table"){const s=n.name=="table"?n.position.nodeAfter:l,r=Array.from(s.getChildren()).filter(a=>a.is("element","caption")),c=r.shift();if(!c)continue;for(const a of r)i.move(i.createRangeIn(a),c,"end"),i.remove(a);c.nextSibling&&(i.move(i.createRangeOn(c),s,"end"),o=!0),o=!!r.length||o}}return o}function ft(i){return!!i&&i.is("element","table")}function Ee(i){for(const e of i.getChildren())if(e.is("element","caption"))return e;return null}function $l(i){const e=L(i);return e?Ee(e):null}function Gl(i){const e=i.parent;return i.name=="figcaption"&&e&&e.is("element","figure")&&e.hasClass("table")?{name:!0}:i.name=="caption"&&e&&e.is("element","table")?{name:!0}:null}class jl extends A{refresh(){const e=this.editor,t=L(e.model.document.selection);this.isEnabled=!!t&&e.model.schema.checkChild(t,"caption"),this.isEnabled?this.value=!!Ee(t):this.value=!1}execute({focusCaptionOnShow:e=!1}={}){this.editor.model.change(t=>{this.value?this._hideTableCaption(t):this._showTableCaption(t,e)})}_showTableCaption(e,t){const o=this.editor.model,n=L(o.document.selection),r=this.editor.plugins.get("TableCaptionEditing")._getSavedCaption(n)||e.createElement("caption");o.insertContent(r,n,"end"),t&&e.setSelection(r,"in")}_hideTableCaption(e){const t=this.editor.model,o=L(t.document.selection),n=this.editor.plugins.get("TableCaptionEditing"),l=Ee(o);n._saveCaption(o,l),t.deleteContent(e.createSelection(l,"on"))}}class Kl extends y{_savedCaptionsMap;static get pluginName(){return"TableCaptionEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),this._savedCaptionsMap=new WeakMap}init(){const e=this.editor,t=e.model.schema,o=e.editing.view,n=e.t;t.isRegistered("caption")?t.extend("caption",{allowIn:"table"}):t.register("caption",{allowIn:"table",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleTableCaption",new jl(this.editor)),e.conversion.for("upcast").elementToElement({view:Gl,model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(l,{writer:s})=>ft(l.parent)?s.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(l,{writer:s})=>{if(!ft(l.parent))return null;const r=s.createEditableElement("figcaption");return s.setCustomProperty("tableCaption",!0,r),r.placeholder=n("Enter table caption"),Wo({view:o,element:r,keepOnFocus:!0}),pt(r,s)}}),Hl(e.model)}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?Lo.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}}class ql extends y{static get pluginName(){return"TableCaptionUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,o=e.t;e.ui.componentFactory.add("toggleTableCaption",n=>{const l=e.commands.get("toggleTableCaption"),s=new V(n);return s.set({icon:go,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(l,"value","isEnabled"),s.bind("label").to(l,"value",r=>o(r?"Toggle caption off":"Toggle caption on")),this.listenTo(s,"execute",()=>{if(e.execute("toggleTableCaption",{focusCaptionOnShow:!0}),l.value){const r=$l(e.model.document.selection),c=e.editing.mapper.toViewElement(r);if(!c)return;t.scrollToTheSelection(),t.change(a=>{a.addClass("table__caption_highlighted",c)})}e.editing.view.focus()}),s})}}class ui extends y{static get pluginName(){return"TableCaption"}static get isOfficialPlugin(){return!0}static get requires(){return[Kl,ql]}}export{si as Table,ui as TableCaption,Kl as TableCaptionEditing,ql as TableCaptionUI,ai as TableCellProperties,wl as TableCellPropertiesEditing,al as TableCellPropertiesUI,oo as TableCellWidthEditing,Jn as TableClipboard,ci as TableColumnResize,Sl as TableColumnResizeEditing,Y as TableEditing,tl as TableKeyboard,ol as TableMouse,di as TableProperties,Bl as TablePropertiesEditing,zl as TablePropertiesUI,B as TableSelection,ri as TableToolbar,qn as TableUI,v as TableUtils};
|