@syncfusion/ej2-richtexteditor 29.2.4-738301 → 29.2.4-760237
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/.eslintrc.json +262 -260
- package/aceconfig.js +17 -0
- package/blazorGlobalSrc/common/config.d.ts +63 -0
- package/blazorGlobalSrc/common/config.js +123 -0
- package/blazorGlobalSrc/common/constant.d.ts +117 -0
- package/blazorGlobalSrc/common/constant.js +23 -0
- package/blazorGlobalSrc/common/editor-styles.d.ts +1 -0
- package/blazorGlobalSrc/common/editor-styles.js +5 -0
- package/blazorGlobalSrc/common/index.d.ts +7 -0
- package/blazorGlobalSrc/common/index.js +9 -0
- package/blazorGlobalSrc/common/interface.d.ts +119 -0
- package/blazorGlobalSrc/common/interface.js +4 -0
- package/blazorGlobalSrc/common/types.d.ts +25 -0
- package/blazorGlobalSrc/common/types.js +4 -0
- package/blazorGlobalSrc/common/user-agent.d.ts +41 -0
- package/blazorGlobalSrc/common/user-agent.js +71 -0
- package/blazorGlobalSrc/common/util.d.ts +70 -0
- package/blazorGlobalSrc/common/util.js +222 -0
- package/blazorGlobalSrc/components.d.ts +8 -0
- package/blazorGlobalSrc/components.js +12 -0
- package/blazorGlobalSrc/editor-manager/base/classes.d.ts +31 -0
- package/blazorGlobalSrc/editor-manager/base/classes.js +28 -0
- package/blazorGlobalSrc/editor-manager/base/constant.d.ts +97 -0
- package/blazorGlobalSrc/editor-manager/base/constant.js +41 -0
- package/blazorGlobalSrc/editor-manager/base/editor-manager.d.ts +95 -0
- package/blazorGlobalSrc/editor-manager/base/editor-manager.js +339 -0
- package/blazorGlobalSrc/editor-manager/base/enum.d.ts +17 -0
- package/blazorGlobalSrc/editor-manager/base/enum.js +4 -0
- package/blazorGlobalSrc/editor-manager/base/interface.d.ts +263 -0
- package/blazorGlobalSrc/editor-manager/base/interface.js +4 -0
- package/blazorGlobalSrc/editor-manager/base/types.d.ts +7 -0
- package/blazorGlobalSrc/editor-manager/base/types.js +4 -0
- package/blazorGlobalSrc/editor-manager/base.d.ts +8 -0
- package/blazorGlobalSrc/editor-manager/base.js +10 -0
- package/blazorGlobalSrc/editor-manager/index.d.ts +5 -0
- package/blazorGlobalSrc/editor-manager/index.js +9 -0
- package/blazorGlobalSrc/editor-manager/plugin/alignments.d.ts +26 -0
- package/blazorGlobalSrc/editor-manager/plugin/alignments.js +105 -0
- package/blazorGlobalSrc/editor-manager/plugin/audio.d.ts +34 -0
- package/blazorGlobalSrc/editor-manager/plugin/audio.js +145 -0
- package/blazorGlobalSrc/editor-manager/plugin/clearformat-exec.d.ts +24 -0
- package/blazorGlobalSrc/editor-manager/plugin/clearformat-exec.js +47 -0
- package/blazorGlobalSrc/editor-manager/plugin/clearformat.d.ts +29 -0
- package/blazorGlobalSrc/editor-manager/plugin/clearformat.js +249 -0
- package/blazorGlobalSrc/editor-manager/plugin/dom-node.d.ts +351 -0
- package/blazorGlobalSrc/editor-manager/plugin/dom-node.js +737 -0
- package/blazorGlobalSrc/editor-manager/plugin/dom-tree.d.ts +84 -0
- package/blazorGlobalSrc/editor-manager/plugin/dom-tree.js +164 -0
- package/blazorGlobalSrc/editor-manager/plugin/emoji-picker-action.d.ts +10 -0
- package/blazorGlobalSrc/editor-manager/plugin/emoji-picker-action.js +86 -0
- package/blazorGlobalSrc/editor-manager/plugin/format-painter-actions.d.ts +47 -0
- package/blazorGlobalSrc/editor-manager/plugin/format-painter-actions.js +622 -0
- package/blazorGlobalSrc/editor-manager/plugin/formats.d.ts +43 -0
- package/blazorGlobalSrc/editor-manager/plugin/formats.js +597 -0
- package/blazorGlobalSrc/editor-manager/plugin/image.d.ts +48 -0
- package/blazorGlobalSrc/editor-manager/plugin/image.js +399 -0
- package/blazorGlobalSrc/editor-manager/plugin/indents.d.ts +24 -0
- package/blazorGlobalSrc/editor-manager/plugin/indents.js +106 -0
- package/blazorGlobalSrc/editor-manager/plugin/insert-methods.d.ts +48 -0
- package/blazorGlobalSrc/editor-manager/plugin/insert-methods.js +37 -0
- package/blazorGlobalSrc/editor-manager/plugin/insert-text.d.ts +22 -0
- package/blazorGlobalSrc/editor-manager/plugin/insert-text.js +36 -0
- package/blazorGlobalSrc/editor-manager/plugin/inserthtml-exec.d.ts +22 -0
- package/blazorGlobalSrc/editor-manager/plugin/inserthtml-exec.js +49 -0
- package/blazorGlobalSrc/editor-manager/plugin/inserthtml.d.ts +51 -0
- package/blazorGlobalSrc/editor-manager/plugin/inserthtml.js +985 -0
- package/blazorGlobalSrc/editor-manager/plugin/isformatted.d.ts +89 -0
- package/blazorGlobalSrc/editor-manager/plugin/isformatted.js +199 -0
- package/blazorGlobalSrc/editor-manager/plugin/link.d.ts +41 -0
- package/blazorGlobalSrc/editor-manager/plugin/link.js +550 -0
- package/blazorGlobalSrc/editor-manager/plugin/lists.d.ts +74 -0
- package/blazorGlobalSrc/editor-manager/plugin/lists.js +1503 -0
- package/blazorGlobalSrc/editor-manager/plugin/ms-word-clean-up.d.ts +61 -0
- package/blazorGlobalSrc/editor-manager/plugin/ms-word-clean-up.js +1136 -0
- package/blazorGlobalSrc/editor-manager/plugin/nodecutter.d.ts +64 -0
- package/blazorGlobalSrc/editor-manager/plugin/nodecutter.js +167 -0
- package/blazorGlobalSrc/editor-manager/plugin/selection-commands.d.ts +41 -0
- package/blazorGlobalSrc/editor-manager/plugin/selection-commands.js +1069 -0
- package/blazorGlobalSrc/editor-manager/plugin/selection-exec.d.ts +24 -0
- package/blazorGlobalSrc/editor-manager/plugin/selection-exec.js +49 -0
- package/blazorGlobalSrc/editor-manager/plugin/table-selection.d.ts +26 -0
- package/blazorGlobalSrc/editor-manager/plugin/table-selection.js +210 -0
- package/blazorGlobalSrc/editor-manager/plugin/table.d.ts +56 -0
- package/blazorGlobalSrc/editor-manager/plugin/table.js +1100 -0
- package/blazorGlobalSrc/editor-manager/plugin/toolbar-status.d.ts +39 -0
- package/blazorGlobalSrc/editor-manager/plugin/toolbar-status.js +384 -0
- package/blazorGlobalSrc/editor-manager/plugin/undo.d.ts +85 -0
- package/blazorGlobalSrc/editor-manager/plugin/undo.js +216 -0
- package/blazorGlobalSrc/editor-manager/plugin/video.d.ts +38 -0
- package/blazorGlobalSrc/editor-manager/plugin/video.js +311 -0
- package/blazorGlobalSrc/editor-manager/plugin.d.ts +27 -0
- package/blazorGlobalSrc/editor-manager/plugin.js +31 -0
- package/blazorGlobalSrc/global.d.ts +1 -0
- package/blazorGlobalSrc/global.js +3 -0
- package/blazorGlobalSrc/index.d.ts +8 -0
- package/blazorGlobalSrc/index.js +12 -0
- package/blazorGlobalSrc/markdown-parser/base/constant.d.ts +39 -0
- package/blazorGlobalSrc/markdown-parser/base/constant.js +10 -0
- package/blazorGlobalSrc/markdown-parser/base/interface.d.ts +169 -0
- package/blazorGlobalSrc/markdown-parser/base/interface.js +4 -0
- package/blazorGlobalSrc/markdown-parser/base/markdown-parser.d.ts +69 -0
- package/blazorGlobalSrc/markdown-parser/base/markdown-parser.js +87 -0
- package/blazorGlobalSrc/markdown-parser/base/types.d.ts +7 -0
- package/blazorGlobalSrc/markdown-parser/base/types.js +4 -0
- package/blazorGlobalSrc/markdown-parser/base.d.ts +7 -0
- package/blazorGlobalSrc/markdown-parser/base.js +9 -0
- package/blazorGlobalSrc/markdown-parser/index.d.ts +5 -0
- package/blazorGlobalSrc/markdown-parser/index.js +9 -0
- package/blazorGlobalSrc/markdown-parser/plugin/clearformat.d.ts +28 -0
- package/blazorGlobalSrc/markdown-parser/plugin/clearformat.js +110 -0
- package/blazorGlobalSrc/markdown-parser/plugin/formats.d.ts +32 -0
- package/blazorGlobalSrc/markdown-parser/plugin/formats.js +225 -0
- package/blazorGlobalSrc/markdown-parser/plugin/insert-text.d.ts +24 -0
- package/blazorGlobalSrc/markdown-parser/plugin/insert-text.js +49 -0
- package/blazorGlobalSrc/markdown-parser/plugin/link.d.ts +24 -0
- package/blazorGlobalSrc/markdown-parser/plugin/link.js +50 -0
- package/blazorGlobalSrc/markdown-parser/plugin/lists.d.ts +39 -0
- package/blazorGlobalSrc/markdown-parser/plugin/lists.js +462 -0
- package/blazorGlobalSrc/markdown-parser/plugin/markdown-selection.d.ts +140 -0
- package/blazorGlobalSrc/markdown-parser/plugin/markdown-selection.js +104 -0
- package/blazorGlobalSrc/markdown-parser/plugin/md-selection-formats.d.ts +31 -0
- package/blazorGlobalSrc/markdown-parser/plugin/md-selection-formats.js +335 -0
- package/blazorGlobalSrc/markdown-parser/plugin/table.d.ts +52 -0
- package/blazorGlobalSrc/markdown-parser/plugin/table.js +216 -0
- package/blazorGlobalSrc/markdown-parser/plugin/undo.d.ts +83 -0
- package/blazorGlobalSrc/markdown-parser/plugin/undo.js +147 -0
- package/blazorGlobalSrc/markdown-parser/plugin.d.ts +11 -0
- package/blazorGlobalSrc/markdown-parser/plugin.js +15 -0
- package/blazorGlobalSrc/rich-text-editor/actions/base-quick-toolbar.d.ts +114 -0
- package/blazorGlobalSrc/rich-text-editor/actions/base-quick-toolbar.js +465 -0
- package/blazorGlobalSrc/rich-text-editor/actions/base-toolbar.d.ts +58 -0
- package/blazorGlobalSrc/rich-text-editor/actions/base-toolbar.js +216 -0
- package/blazorGlobalSrc/rich-text-editor/actions/color-picker.d.ts +52 -0
- package/blazorGlobalSrc/rich-text-editor/actions/color-picker.js +241 -0
- package/blazorGlobalSrc/rich-text-editor/actions/count.d.ts +55 -0
- package/blazorGlobalSrc/rich-text-editor/actions/count.js +117 -0
- package/blazorGlobalSrc/rich-text-editor/actions/dropdown-buttons.d.ts +72 -0
- package/blazorGlobalSrc/rich-text-editor/actions/dropdown-buttons.js +552 -0
- package/blazorGlobalSrc/rich-text-editor/actions/emoji-picker.d.ts +51 -0
- package/blazorGlobalSrc/rich-text-editor/actions/emoji-picker.js +853 -0
- package/blazorGlobalSrc/rich-text-editor/actions/enter-key.d.ts +28 -0
- package/blazorGlobalSrc/rich-text-editor/actions/enter-key.js +821 -0
- package/blazorGlobalSrc/rich-text-editor/actions/execute-command-callback.d.ts +11 -0
- package/blazorGlobalSrc/rich-text-editor/actions/execute-command-callback.js +28 -0
- package/blazorGlobalSrc/rich-text-editor/actions/file-manager.d.ts +45 -0
- package/blazorGlobalSrc/rich-text-editor/actions/file-manager.js +249 -0
- package/blazorGlobalSrc/rich-text-editor/actions/format-painter.d.ts +25 -0
- package/blazorGlobalSrc/rich-text-editor/actions/format-painter.js +156 -0
- package/blazorGlobalSrc/rich-text-editor/actions/full-screen.d.ts +40 -0
- package/blazorGlobalSrc/rich-text-editor/actions/full-screen.js +148 -0
- package/blazorGlobalSrc/rich-text-editor/actions/html-attributes.d.ts +15 -0
- package/blazorGlobalSrc/rich-text-editor/actions/html-attributes.js +50 -0
- package/blazorGlobalSrc/rich-text-editor/actions/html-editor.d.ts +120 -0
- package/blazorGlobalSrc/rich-text-editor/actions/html-editor.js +1244 -0
- package/blazorGlobalSrc/rich-text-editor/actions/html-toolbar-status.d.ts +14 -0
- package/blazorGlobalSrc/rich-text-editor/actions/html-toolbar-status.js +47 -0
- package/blazorGlobalSrc/rich-text-editor/actions/import-export.d.ts +21 -0
- package/blazorGlobalSrc/rich-text-editor/actions/import-export.js +117 -0
- package/blazorGlobalSrc/rich-text-editor/actions/keyboard-model.d.ts +30 -0
- package/blazorGlobalSrc/rich-text-editor/actions/keyboard.d.ts +110 -0
- package/blazorGlobalSrc/rich-text-editor/actions/keyboard.js +163 -0
- package/blazorGlobalSrc/rich-text-editor/actions/markdown-editor.d.ts +66 -0
- package/blazorGlobalSrc/rich-text-editor/actions/markdown-editor.js +142 -0
- package/blazorGlobalSrc/rich-text-editor/actions/markdown-toolbar-status.d.ts +23 -0
- package/blazorGlobalSrc/rich-text-editor/actions/markdown-toolbar-status.js +124 -0
- package/blazorGlobalSrc/rich-text-editor/actions/paste-clean-up.d.ts +86 -0
- package/blazorGlobalSrc/rich-text-editor/actions/paste-clean-up.js +1071 -0
- package/blazorGlobalSrc/rich-text-editor/actions/quick-toolbar.d.ts +151 -0
- package/blazorGlobalSrc/rich-text-editor/actions/quick-toolbar.js +548 -0
- package/blazorGlobalSrc/rich-text-editor/actions/resize.d.ts +37 -0
- package/blazorGlobalSrc/rich-text-editor/actions/resize.js +188 -0
- package/blazorGlobalSrc/rich-text-editor/actions/sanitize-helper.d.ts +11 -0
- package/blazorGlobalSrc/rich-text-editor/actions/sanitize-helper.js +168 -0
- package/blazorGlobalSrc/rich-text-editor/actions/toolbar-action.d.ts +18 -0
- package/blazorGlobalSrc/rich-text-editor/actions/toolbar-action.js +76 -0
- package/blazorGlobalSrc/rich-text-editor/actions/toolbar.d.ts +185 -0
- package/blazorGlobalSrc/rich-text-editor/actions/toolbar.js +512 -0
- package/blazorGlobalSrc/rich-text-editor/actions/xhtml-validation.d.ts +25 -0
- package/blazorGlobalSrc/rich-text-editor/actions/xhtml-validation.js +166 -0
- package/blazorGlobalSrc/rich-text-editor/actions.d.ts +26 -0
- package/blazorGlobalSrc/rich-text-editor/actions.js +30 -0
- package/blazorGlobalSrc/rich-text-editor/audio.d.ts +4 -0
- package/blazorGlobalSrc/rich-text-editor/audio.js +8 -0
- package/blazorGlobalSrc/rich-text-editor/base/classes.d.ts +628 -0
- package/blazorGlobalSrc/rich-text-editor/base/classes.js +129 -0
- package/blazorGlobalSrc/rich-text-editor/base/constant.d.ts +808 -0
- package/blazorGlobalSrc/rich-text-editor/base/constant.js +334 -0
- package/blazorGlobalSrc/rich-text-editor/base/enum.d.ts +81 -0
- package/blazorGlobalSrc/rich-text-editor/base/enum.js +37 -0
- package/blazorGlobalSrc/rich-text-editor/base/interface.d.ts +1577 -0
- package/blazorGlobalSrc/rich-text-editor/base/interface.js +194 -0
- package/blazorGlobalSrc/rich-text-editor/base/rich-text-editor-model.d.ts +1032 -0
- package/blazorGlobalSrc/rich-text-editor/base/rich-text-editor.d.ts +1699 -0
- package/blazorGlobalSrc/rich-text-editor/base/rich-text-editor.js +2645 -0
- package/blazorGlobalSrc/rich-text-editor/base/util.d.ts +212 -0
- package/blazorGlobalSrc/rich-text-editor/base/util.js +610 -0
- package/blazorGlobalSrc/rich-text-editor/base.d.ts +10 -0
- package/blazorGlobalSrc/rich-text-editor/base.js +13 -0
- package/blazorGlobalSrc/rich-text-editor/formatter/formatter.d.ts +87 -0
- package/blazorGlobalSrc/rich-text-editor/formatter/formatter.js +223 -0
- package/blazorGlobalSrc/rich-text-editor/formatter/html-formatter.d.ts +34 -0
- package/blazorGlobalSrc/rich-text-editor/formatter/html-formatter.js +44 -0
- package/blazorGlobalSrc/rich-text-editor/formatter/markdown-formatter.d.ts +39 -0
- package/blazorGlobalSrc/rich-text-editor/formatter/markdown-formatter.js +48 -0
- package/blazorGlobalSrc/rich-text-editor/formatter.d.ts +6 -0
- package/blazorGlobalSrc/rich-text-editor/formatter.js +10 -0
- package/blazorGlobalSrc/rich-text-editor/html-editor.d.ts +4 -0
- package/blazorGlobalSrc/rich-text-editor/html-editor.js +8 -0
- package/blazorGlobalSrc/rich-text-editor/image.d.ts +4 -0
- package/blazorGlobalSrc/rich-text-editor/image.js +8 -0
- package/blazorGlobalSrc/rich-text-editor/index.d.ts +9 -0
- package/blazorGlobalSrc/rich-text-editor/index.js +12 -0
- package/blazorGlobalSrc/rich-text-editor/link.d.ts +4 -0
- package/blazorGlobalSrc/rich-text-editor/link.js +8 -0
- package/blazorGlobalSrc/rich-text-editor/markdown-editor.d.ts +4 -0
- package/blazorGlobalSrc/rich-text-editor/markdown-editor.js +8 -0
- package/blazorGlobalSrc/rich-text-editor/models/default-locale.d.ts +25 -0
- package/blazorGlobalSrc/rich-text-editor/models/default-locale.js +391 -0
- package/blazorGlobalSrc/rich-text-editor/models/iframe-settings-model.d.ts +68 -0
- package/blazorGlobalSrc/rich-text-editor/models/iframe-settings.d.ts +61 -0
- package/blazorGlobalSrc/rich-text-editor/models/iframe-settings.js +60 -0
- package/blazorGlobalSrc/rich-text-editor/models/inline-mode-model.d.ts +24 -0
- package/blazorGlobalSrc/rich-text-editor/models/inline-mode.d.ts +20 -0
- package/blazorGlobalSrc/rich-text-editor/models/inline-mode.js +37 -0
- package/blazorGlobalSrc/rich-text-editor/models/items.d.ts +36 -0
- package/blazorGlobalSrc/rich-text-editor/models/items.js +1011 -0
- package/blazorGlobalSrc/rich-text-editor/models/models.d.ts +7 -0
- package/blazorGlobalSrc/rich-text-editor/models/models.js +4 -0
- package/blazorGlobalSrc/rich-text-editor/models/slash-menu-settings-model.d.ts +40 -0
- package/blazorGlobalSrc/rich-text-editor/models/slash-menu-settings.d.ts +50 -0
- package/blazorGlobalSrc/rich-text-editor/models/slash-menu-settings.js +143 -0
- package/blazorGlobalSrc/rich-text-editor/models/toolbar-settings-model.d.ts +1130 -0
- package/blazorGlobalSrc/rich-text-editor/models/toolbar-settings.d.ts +992 -0
- package/blazorGlobalSrc/rich-text-editor/models/toolbar-settings.js +510 -0
- package/blazorGlobalSrc/rich-text-editor/models.d.ts +4 -0
- package/blazorGlobalSrc/rich-text-editor/models.js +4 -0
- package/blazorGlobalSrc/rich-text-editor/quick-toolbar.d.ts +4 -0
- package/blazorGlobalSrc/rich-text-editor/quick-toolbar.js +8 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/audio-module.d.ts +82 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/audio-module.js +886 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/content-renderer.d.ts +65 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/content-renderer.js +49 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/dialog-renderer.d.ts +39 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/dialog-renderer.js +111 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/iframe-content-renderer.d.ts +33 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/iframe-content-renderer.js +101 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/image-module.d.ts +199 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/image-module.js +2494 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/link-module.d.ts +63 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/link-module.js +596 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/markdown-renderer.d.ts +65 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/markdown-renderer.js +38 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/popup-renderer.d.ts +54 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/popup-renderer.js +35 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/render.d.ts +46 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/render.js +70 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/slash-menu.d.ts +20 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/slash-menu.js +224 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/table-module.d.ts +155 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/table-module.js +2206 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/toolbar-renderer.d.ts +131 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/toolbar-renderer.js +747 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/video-module.d.ts +120 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/video-module.js +1507 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/view-source.d.ts +74 -0
- package/blazorGlobalSrc/rich-text-editor/renderer/view-source.js +225 -0
- package/blazorGlobalSrc/rich-text-editor/renderer.d.ts +17 -0
- package/blazorGlobalSrc/rich-text-editor/renderer.js +21 -0
- package/blazorGlobalSrc/rich-text-editor/services/renderer-factory.d.ts +33 -0
- package/blazorGlobalSrc/rich-text-editor/services/renderer-factory.js +29 -0
- package/blazorGlobalSrc/rich-text-editor/services/service-locator.d.ts +29 -0
- package/blazorGlobalSrc/rich-text-editor/services/service-locator.js +25 -0
- package/blazorGlobalSrc/rich-text-editor/services.d.ts +5 -0
- package/blazorGlobalSrc/rich-text-editor/services.js +9 -0
- package/blazorGlobalSrc/rich-text-editor/toolbar.d.ts +4 -0
- package/blazorGlobalSrc/rich-text-editor/toolbar.js +8 -0
- package/blazorGlobalSrc/rich-text-editor/video.d.ts +4 -0
- package/blazorGlobalSrc/rich-text-editor/video.js +8 -0
- package/blazorGlobalSrc/rich-text-editor.d.ts +4 -0
- package/blazorGlobalSrc/rich-text-editor.js +8 -0
- package/blazorGlobalSrc/selection/index.d.ts +4 -0
- package/blazorGlobalSrc/selection/index.js +8 -0
- package/blazorGlobalSrc/selection/selection.d.ts +244 -0
- package/blazorGlobalSrc/selection/selection.js +309 -0
- package/dist/ej2-richtexteditor.umd.min.js +1 -1
- package/dist/ej2-richtexteditor.umd.min.js.map +1 -1
- package/dist/es6/ej2-richtexteditor.es2015.js +6 -4
- package/dist/es6/ej2-richtexteditor.es2015.js.map +1 -1
- package/dist/es6/ej2-richtexteditor.es5.js +6 -4
- package/dist/es6/ej2-richtexteditor.es5.js.map +1 -1
- package/helpers/e2e/index.d.ts +1 -0
- package/helpers/e2e/index.js +8 -0
- package/helpers/e2e/rte-helper.d.ts +79 -0
- package/helpers/e2e/rte-helper.js +81 -0
- package/package.json +1 -1
- package/src/editor-manager/plugin/dom-tree.js +6 -4
- package/src/global.d.ts +1 -0
- package/styles/bds-lite.css +7 -17
- package/styles/bds.css +11 -22
- package/styles/bootstrap-dark-lite.css +3 -13
- package/styles/bootstrap-dark.css +3 -14
- package/styles/bootstrap-lite.css +3 -13
- package/styles/bootstrap.css +3 -14
- package/styles/bootstrap4-lite.css +3 -13
- package/styles/bootstrap4.css +3 -14
- package/styles/bootstrap5-dark-lite.css +3 -13
- package/styles/bootstrap5-dark.css +3 -14
- package/styles/bootstrap5-lite.css +3 -13
- package/styles/bootstrap5.3-lite.css +3 -13
- package/styles/bootstrap5.3.css +3 -14
- package/styles/bootstrap5.css +3 -14
- package/styles/fabric-dark-lite.css +3 -13
- package/styles/fabric-dark.css +3 -14
- package/styles/fabric-lite.css +3 -13
- package/styles/fabric.css +3 -14
- package/styles/fluent-dark-lite.css +3 -13
- package/styles/fluent-dark.css +3 -14
- package/styles/fluent-lite.css +3 -13
- package/styles/fluent.css +3 -14
- package/styles/fluent2-lite.css +3 -13
- package/styles/fluent2.css +3 -14
- package/styles/highcontrast-light-lite.css +3 -13
- package/styles/highcontrast-light.css +3 -14
- package/styles/highcontrast-lite.css +3 -13
- package/styles/highcontrast.css +3 -14
- package/styles/material-dark-lite.css +3 -13
- package/styles/material-dark.css +3 -14
- package/styles/material-lite.css +3 -13
- package/styles/material.css +3 -14
- package/styles/material3-dark-lite.css +3 -13
- package/styles/material3-dark.css +3 -14
- package/styles/material3-lite.css +3 -13
- package/styles/material3.css +3 -14
- package/styles/rich-text-editor/_bds-definition.scss +2 -2
- package/styles/rich-text-editor/_bigger.scss +0 -1
- package/styles/rich-text-editor/_layout.scss +0 -9
- package/styles/rich-text-editor/_theme.scss +3 -0
- package/styles/rich-text-editor/bds.css +11 -22
- package/styles/rich-text-editor/bootstrap-dark.css +3 -14
- package/styles/rich-text-editor/bootstrap.css +3 -14
- package/styles/rich-text-editor/bootstrap4.css +3 -14
- package/styles/rich-text-editor/bootstrap5-dark.css +3 -14
- package/styles/rich-text-editor/bootstrap5.3.css +3 -14
- package/styles/rich-text-editor/bootstrap5.css +3 -14
- package/styles/rich-text-editor/fabric-dark.css +3 -14
- package/styles/rich-text-editor/fabric.css +3 -14
- package/styles/rich-text-editor/fluent-dark.css +3 -14
- package/styles/rich-text-editor/fluent.css +3 -14
- package/styles/rich-text-editor/fluent2.css +3 -14
- package/styles/rich-text-editor/highcontrast-light.css +3 -14
- package/styles/rich-text-editor/highcontrast.css +3 -14
- package/styles/rich-text-editor/material-dark.css +3 -14
- package/styles/rich-text-editor/material.css +3 -14
- package/styles/rich-text-editor/material3-dark.css +3 -14
- package/styles/rich-text-editor/material3.css +3 -14
- package/styles/rich-text-editor/tailwind-dark.css +3 -14
- package/styles/rich-text-editor/tailwind.css +3 -14
- package/styles/rich-text-editor/tailwind3.css +3 -14
- package/styles/tailwind-dark-lite.css +3 -13
- package/styles/tailwind-dark.css +3 -14
- package/styles/tailwind-lite.css +3 -13
- package/styles/tailwind.css +3 -14
- package/styles/tailwind3-lite.css +3 -13
- package/styles/tailwind3.css +3 -14
- package/tslint.json +111 -0
|
@@ -0,0 +1,2206 @@
|
|
|
1
|
+
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "@syncfusion/ej2-popups", "@syncfusion/ej2-buttons", "../base/constant", "../base/enum", "@syncfusion/ej2-inputs", "../base/classes", "../base/util", "../../common/util"], function (require, exports, ej2_base_1, ej2_base_2, ej2_popups_1, ej2_buttons_1, events, enum_1, ej2_inputs_1, classes, util_1, util_2) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
var Table = (function () {
|
|
5
|
+
function Table(parent, serviceLocator) {
|
|
6
|
+
this.ensureInsideTableList = true;
|
|
7
|
+
this.pageX = null;
|
|
8
|
+
this.pageY = null;
|
|
9
|
+
this.moveEle = null;
|
|
10
|
+
this.currentColumnResize = '';
|
|
11
|
+
this.resizeEndTime = 0;
|
|
12
|
+
this.isTableMoveActive = false;
|
|
13
|
+
this.isResizeBind = true;
|
|
14
|
+
this.parent = parent;
|
|
15
|
+
this.rteID = parent.element.id;
|
|
16
|
+
this.l10n = serviceLocator.getService('rteLocale');
|
|
17
|
+
this.rendererFactory = serviceLocator.getService('rendererFactory');
|
|
18
|
+
this.dialogRenderObj = serviceLocator.getService('dialogRenderObject');
|
|
19
|
+
this.addEventListener();
|
|
20
|
+
this.isDestroyed = false;
|
|
21
|
+
}
|
|
22
|
+
Table.prototype.addEventListener = function () {
|
|
23
|
+
if (this.parent.isDestroyed) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.parent.on(events.createTable, this.renderDlgContent, this);
|
|
27
|
+
this.parent.on(events.initialEnd, this.afterRender, this);
|
|
28
|
+
this.parent.on(events.dynamicModule, this.afterRender, this);
|
|
29
|
+
this.parent.on(events.showTableDialog, this.showDialog, this);
|
|
30
|
+
this.parent.on(events.closeTableDialog, this.closeDialog, this);
|
|
31
|
+
this.parent.on(events.docClick, this.docClick, this);
|
|
32
|
+
this.parent.on(events.iframeMouseDown, this.onIframeMouseDown, this);
|
|
33
|
+
this.parent.on(events.editAreaClick, this.editAreaClickHandler, this);
|
|
34
|
+
this.parent.on(events.clearDialogObj, this.clearDialogObj, this);
|
|
35
|
+
this.parent.on(events.tableToolbarAction, this.onToolbarAction, this);
|
|
36
|
+
this.parent.on(events.dropDownSelect, this.dropdownSelect, this);
|
|
37
|
+
this.parent.on(events.keyDown, this.keyDown, this);
|
|
38
|
+
this.parent.on(events.tableModulekeyUp, this.tableModulekeyUp, this);
|
|
39
|
+
this.parent.on(events.bindCssClass, this.setCssClass, this);
|
|
40
|
+
this.parent.on(events.destroy, this.destroy, this);
|
|
41
|
+
this.parent.on(events.afterKeyDown, this.afterKeyDown, this);
|
|
42
|
+
this.parent.on(events.hideTableQuickToolbar, this.hideTableQuickToolbar, this);
|
|
43
|
+
};
|
|
44
|
+
Table.prototype.removeEventListener = function () {
|
|
45
|
+
this.parent.off(events.createTable, this.renderDlgContent);
|
|
46
|
+
this.parent.off(events.initialEnd, this.afterRender);
|
|
47
|
+
this.parent.off(events.dynamicModule, this.afterRender);
|
|
48
|
+
this.parent.off(events.docClick, this.docClick);
|
|
49
|
+
this.parent.off(events.iframeMouseDown, this.onIframeMouseDown);
|
|
50
|
+
this.parent.off(events.showTableDialog, this.showDialog);
|
|
51
|
+
this.parent.off(events.closeTableDialog, this.closeDialog);
|
|
52
|
+
this.parent.off(events.editAreaClick, this.editAreaClickHandler);
|
|
53
|
+
this.parent.off(events.clearDialogObj, this.clearDialogObj);
|
|
54
|
+
this.parent.off(events.tableToolbarAction, this.onToolbarAction);
|
|
55
|
+
this.parent.off(events.dropDownSelect, this.dropdownSelect);
|
|
56
|
+
this.parent.off(events.mouseDown, this.cellSelect);
|
|
57
|
+
this.parent.off(events.hideTableQuickToolbar, this.hideTableQuickToolbar);
|
|
58
|
+
this.parent.off(events.keyDown, this.keyDown);
|
|
59
|
+
this.parent.off(events.tableModulekeyUp, this.tableModulekeyUp);
|
|
60
|
+
this.parent.off(events.bindCssClass, this.setCssClass);
|
|
61
|
+
this.parent.off(events.destroy, this.destroy);
|
|
62
|
+
this.parent.off(events.afterKeyDown, this.afterKeyDown);
|
|
63
|
+
if (!ej2_base_1.Browser.isDevice && this.parent.tableSettings.resize) {
|
|
64
|
+
ej2_base_2.EventHandler.remove(this.contentModule.getEditPanel(), 'mouseover', this.resizeHelper);
|
|
65
|
+
ej2_base_2.EventHandler.remove(this.contentModule.getEditPanel(), ej2_base_1.Browser.touchStartEvent, this.resizeStart);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
Table.prototype.updateCss = function (currentObj, e) {
|
|
69
|
+
if (currentObj && e.cssClass) {
|
|
70
|
+
if (ej2_base_2.isNullOrUndefined(e.oldCssClass)) {
|
|
71
|
+
currentObj.setProperties({ cssClass: (currentObj.cssClass + ' ' + e.cssClass).trim() });
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
currentObj.setProperties({ cssClass: (currentObj.cssClass.replace(e.oldCssClass, '').trim() + ' ' + e.cssClass).trim() });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
Table.prototype.setCssClass = function (e) {
|
|
79
|
+
if (this.popupObj && e.cssClass) {
|
|
80
|
+
if (ej2_base_2.isNullOrUndefined(e.oldCssClass)) {
|
|
81
|
+
ej2_base_2.addClass([this.popupObj.element], e.cssClass);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
util_2.removeClassWithAttr([this.popupObj.element], e.oldCssClass);
|
|
85
|
+
ej2_base_2.addClass([this.popupObj.element], e.cssClass);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
this.updateCss(this.createTableButton, e);
|
|
89
|
+
this.updateCss(this.editdlgObj, e);
|
|
90
|
+
var numericTextBoxObj = [
|
|
91
|
+
this.columnTextBox, this.rowTextBox, this.tableWidthNum, this.tableCellPadding, this.tableCellSpacing
|
|
92
|
+
];
|
|
93
|
+
for (var i = 0; i < numericTextBoxObj.length; i++) {
|
|
94
|
+
this.updateCss(numericTextBoxObj[i], e);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
Table.prototype.afterRender = function () {
|
|
98
|
+
if (ej2_base_2.isNullOrUndefined(this.contentModule)) {
|
|
99
|
+
this.contentModule = this.rendererFactory.getRenderer(enum_1.RenderType.Content);
|
|
100
|
+
this.parent.on(events.mouseDown, this.cellSelect, this);
|
|
101
|
+
if (this.parent.tableSettings.resize) {
|
|
102
|
+
ej2_base_2.EventHandler.add(this.parent.contentModule.getEditPanel(), ej2_base_1.Browser.touchStartEvent, this.resizeStart, this);
|
|
103
|
+
}
|
|
104
|
+
if (!ej2_base_1.Browser.isDevice && this.parent.tableSettings.resize) {
|
|
105
|
+
ej2_base_2.EventHandler.add(this.contentModule.getEditPanel(), 'mouseover', this.resizeHelper, this);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
Table.prototype.dropdownSelect = function (e) {
|
|
110
|
+
var item = e.item;
|
|
111
|
+
if (!document.body.contains(document.body.querySelector('.e-rte-quick-toolbar')) || item.command !== 'Table') {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
|
|
115
|
+
var args = {
|
|
116
|
+
args: e,
|
|
117
|
+
selection: this.parent.formatter.editorManager.nodeSelection.save(range, this.contentModule.getDocument()),
|
|
118
|
+
selectParent: this.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range)
|
|
119
|
+
};
|
|
120
|
+
switch (item.subCommand) {
|
|
121
|
+
case 'InsertRowBefore':
|
|
122
|
+
case 'InsertRowAfter':
|
|
123
|
+
this.addRow(args.selection, e);
|
|
124
|
+
break;
|
|
125
|
+
case 'InsertColumnLeft':
|
|
126
|
+
case 'InsertColumnRight':
|
|
127
|
+
this.addColumn(args.selection, e);
|
|
128
|
+
break;
|
|
129
|
+
case 'DeleteColumn':
|
|
130
|
+
case 'DeleteRow':
|
|
131
|
+
this.removeRowColumn(args.selection, e);
|
|
132
|
+
break;
|
|
133
|
+
case 'AlignTop':
|
|
134
|
+
case 'AlignMiddle':
|
|
135
|
+
case 'AlignBottom':
|
|
136
|
+
this.verticalAlign(args, e);
|
|
137
|
+
break;
|
|
138
|
+
case 'Dashed':
|
|
139
|
+
case 'Alternate':
|
|
140
|
+
case 'Custom':
|
|
141
|
+
this.tableStyles(args, e);
|
|
142
|
+
break;
|
|
143
|
+
case 'Merge':
|
|
144
|
+
case 'VerticalSplit':
|
|
145
|
+
case 'HorizontalSplit':
|
|
146
|
+
this.UpdateCells(args.selection, e);
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
Table.prototype.UpdateCells = function (selectCell, e) {
|
|
151
|
+
this.parent.formatter.process(this.parent, e, e, { selection: selectCell, subCommand: e.item.subCommand });
|
|
152
|
+
this.hideTableQuickToolbar();
|
|
153
|
+
};
|
|
154
|
+
Table.prototype.keyDown = function (e) {
|
|
155
|
+
var event = e.args;
|
|
156
|
+
var proxy = this;
|
|
157
|
+
switch (event.action) {
|
|
158
|
+
case 'escape':
|
|
159
|
+
break;
|
|
160
|
+
case 'insert-table':
|
|
161
|
+
if (this.parent.editorMode === 'HTML') {
|
|
162
|
+
this.openDialog(true, e);
|
|
163
|
+
}
|
|
164
|
+
else if (this.parent.editorMode === 'Markdown') {
|
|
165
|
+
this.parent.formatter.process(this.parent, null, event);
|
|
166
|
+
}
|
|
167
|
+
event.preventDefault();
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
if (!ej2_base_2.isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection) && this.contentModule
|
|
171
|
+
&& event.code !== 'KeyK') {
|
|
172
|
+
var selection = void 0;
|
|
173
|
+
var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
|
|
174
|
+
var ele = this.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range)[0];
|
|
175
|
+
ele = (ele && ele.tagName !== 'TD' && ele.tagName !== 'TH') ? ele.parentElement : ele;
|
|
176
|
+
if ((event.keyCode === 8 || event.keyCode === 46) ||
|
|
177
|
+
(event.ctrlKey && event.keyCode === 88)) {
|
|
178
|
+
if (ele && ele.tagName === 'TBODY') {
|
|
179
|
+
if (!ej2_base_2.isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection) && this.contentModule) {
|
|
180
|
+
selection = this.parent.formatter.editorManager.nodeSelection.save(range, this.contentModule.getDocument());
|
|
181
|
+
}
|
|
182
|
+
event.preventDefault();
|
|
183
|
+
proxy.removeTable(selection, event, true);
|
|
184
|
+
}
|
|
185
|
+
else if (ele && ele.querySelectorAll('table').length > 0) {
|
|
186
|
+
this.removeResizeElement();
|
|
187
|
+
this.hideTableQuickToolbar();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (ele && ele.tagName !== 'TD' && ele.tagName !== 'TH') {
|
|
191
|
+
var closestTd = ej2_base_1.closest(ele, 'td');
|
|
192
|
+
ele = !ej2_base_2.isNullOrUndefined(closestTd) && this.parent.inputElement.contains(closestTd) ? closestTd : ele;
|
|
193
|
+
}
|
|
194
|
+
if (ele && (ele.tagName === 'TD' || ele.tagName === 'TH')) {
|
|
195
|
+
var selectedEndCell = this.contentModule.getEditPanel().querySelectorAll('.e-cell-select-end');
|
|
196
|
+
if ((ej2_base_1.isNullOrUndefined(this.activeCell) || this.activeCell !== ele) && !ej2_base_1.isNullOrUndefined(selectedEndCell) && selectedEndCell.length === 0) {
|
|
197
|
+
this.activeCell = ele;
|
|
198
|
+
}
|
|
199
|
+
if (!ej2_base_1.isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection) && this.contentModule) {
|
|
200
|
+
selection = this.parent.formatter.editorManager.nodeSelection.save(range, this.contentModule.getDocument());
|
|
201
|
+
}
|
|
202
|
+
if (!event.shiftKey ||
|
|
203
|
+
(event.shiftKey && event.keyCode === 9)) {
|
|
204
|
+
switch (event.keyCode) {
|
|
205
|
+
case 9:
|
|
206
|
+
case 37:
|
|
207
|
+
case 39:
|
|
208
|
+
proxy.tabSelection(event, selection, ele);
|
|
209
|
+
break;
|
|
210
|
+
case 40:
|
|
211
|
+
case 38:
|
|
212
|
+
proxy.tableArrowNavigation(event, selection, ele);
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (this.parent.editorMode === 'HTML' && event.shiftKey && (event.keyCode === 39 ||
|
|
219
|
+
event.keyCode === 37
|
|
220
|
+
|| event.keyCode === 38 || event.keyCode === 40)) {
|
|
221
|
+
this.keyDownEventInstance = event;
|
|
222
|
+
ej2_base_2.EventHandler.add(this.parent.contentModule.getDocument(), 'selectionchange', this.tableCellsKeyboardSelection, this);
|
|
223
|
+
}
|
|
224
|
+
if (event.ctrlKey && event.key === 'a') {
|
|
225
|
+
this.handleSelectAll();
|
|
226
|
+
}
|
|
227
|
+
if (((event.code === 'Delete' && event.which === 46) || (event.code === 'Backspace' && event.which === 8)) && this.parent.editorMode === 'HTML') {
|
|
228
|
+
var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
|
|
229
|
+
if (range.startContainer.nodeType === Node.ELEMENT_NODE && range.startContainer.nodeName === 'DIV' && range.startContainer.classList.contains('e-table-fake-selection')) {
|
|
230
|
+
this.deleteTable();
|
|
231
|
+
event.preventDefault();
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
var table = (event.code === 'Delete' && event.which === 46) ? this.getAdjacentTableElement(range, true) : this.getAdjacentTableElement(range, false);
|
|
235
|
+
if (table) {
|
|
236
|
+
this.updateTableSelection(table);
|
|
237
|
+
event.preventDefault();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
var isShiftEnter = event.shiftKey && event.key === 'Enter';
|
|
243
|
+
var isActionKey = classes.ALLOWED_ACTIONKEYS.indexOf(event.key) !== -1;
|
|
244
|
+
if (isShiftEnter || isActionKey || (event.key && event.key.length === 1)) {
|
|
245
|
+
var table = this.parent.contentModule.getEditPanel().querySelector('table.e-cell-select');
|
|
246
|
+
if (table) {
|
|
247
|
+
if (event.keyCode === 39 || event.keyCode === 37) {
|
|
248
|
+
this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.contentModule.getDocument(), table, 0);
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
var firstTd = table.querySelector('tr').cells[0];
|
|
252
|
+
this.parent.formatter.editorManager.nodeSelection.setSelectionText(this.contentModule.getDocument(), firstTd, firstTd, 0, 0);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
this.removeTableSelection();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
Table.prototype.tableCellsKeyboardSelection = function (e) {
|
|
260
|
+
ej2_base_2.EventHandler.remove(this.parent.contentModule.getDocument(), 'selectionchange', this.tableCellsKeyboardSelection);
|
|
261
|
+
var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
|
|
262
|
+
var event = this.keyDownEventInstance;
|
|
263
|
+
var isMultiSelect = !ej2_base_2.isNullOrUndefined(range) && !ej2_base_2.isNullOrUndefined(range.commonAncestorContainer) &&
|
|
264
|
+
range.commonAncestorContainer.nodeType === Node.ELEMENT_NODE
|
|
265
|
+
&& (range.commonAncestorContainer.tagName === 'TR'
|
|
266
|
+
|| range.commonAncestorContainer.tagName === 'TBODY') && !ej2_base_2.isNullOrUndefined(this.activeCell);
|
|
267
|
+
var selectedEndCell = this.contentModule.getEditPanel().querySelectorAll('.e-cell-select-end');
|
|
268
|
+
if (!ej2_base_2.isNullOrUndefined(selectedEndCell) && selectedEndCell.length > 0) {
|
|
269
|
+
this.parent.formatter.editorManager.nodeSelection.Clear(this.parent.contentModule.getDocument());
|
|
270
|
+
this.parent.formatter.editorManager.nodeSelection.setSelectionText(this.parent.contentModule.getDocument(), selectedEndCell[0], selectedEndCell[0], 0, 0);
|
|
271
|
+
this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), selectedEndCell[0], 0);
|
|
272
|
+
}
|
|
273
|
+
if (isMultiSelect || (!ej2_base_2.isNullOrUndefined(selectedEndCell) && selectedEndCell.length > 0)) {
|
|
274
|
+
var cells = this.getCorrespondingColumns();
|
|
275
|
+
var cell = !ej2_base_2.isNullOrUndefined(selectedEndCell)
|
|
276
|
+
&& selectedEndCell.length > 0 ? selectedEndCell[0] : this.activeCell;
|
|
277
|
+
var activeIndexes = this.getCorrespondingIndex(cell, cells);
|
|
278
|
+
var activeCellRowIndex = activeIndexes[0];
|
|
279
|
+
var activeCellColIndex = activeIndexes[1];
|
|
280
|
+
var target = void 0;
|
|
281
|
+
if (event.keyCode === 39) {
|
|
282
|
+
if (activeCellColIndex < cells[0].length - 1) {
|
|
283
|
+
target = cells[activeCellRowIndex][(activeCellColIndex + 1)];
|
|
284
|
+
}
|
|
285
|
+
else if (activeCellRowIndex < cells.length - 1) {
|
|
286
|
+
target = cells[(activeCellRowIndex + 1)][activeCellColIndex];
|
|
287
|
+
if (selectedEndCell.length === 0 && activeCellRowIndex < cells.length - 1) {
|
|
288
|
+
this.activeCell = cells[activeCellRowIndex][0];
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
this.resetTableSelection();
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
else if (event.keyCode === 37) {
|
|
296
|
+
if (0 < activeCellColIndex) {
|
|
297
|
+
target = cells[activeCellRowIndex][(activeCellColIndex - 1)];
|
|
298
|
+
}
|
|
299
|
+
else if (0 < activeCellRowIndex) {
|
|
300
|
+
target = cells[(activeCellRowIndex - 1)][activeCellColIndex];
|
|
301
|
+
if (selectedEndCell.length === 0 && 0 < activeCellRowIndex) {
|
|
302
|
+
this.activeCell = cells[activeCellRowIndex][(cells[activeCellRowIndex].length - 1)];
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
this.resetTableSelection();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
else if (event.keyCode === 38) {
|
|
310
|
+
if (0 < activeCellRowIndex) {
|
|
311
|
+
target = cells[(activeCellRowIndex - 1)][activeCellColIndex];
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
this.resetTableSelection();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
else if (event.keyCode === 40) {
|
|
318
|
+
if (activeCellRowIndex < cells.length - 1) {
|
|
319
|
+
target = cells[(activeCellRowIndex + 1)][activeCellColIndex];
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
this.resetTableSelection();
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (target) {
|
|
326
|
+
this.parent.formatter.editorManager.observer.notify('TABLE_MOVE', {
|
|
327
|
+
event: { target: target },
|
|
328
|
+
selectNode: [this.activeCell]
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (selectedEndCell.length > 0) {
|
|
333
|
+
event.preventDefault();
|
|
334
|
+
e.preventDefault();
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
Table.prototype.resetTableSelection = function () {
|
|
338
|
+
var selectedEndCell = this.contentModule.getEditPanel().querySelectorAll('.e-cell-select-end');
|
|
339
|
+
if (!ej2_base_2.isNullOrUndefined(selectedEndCell) && selectedEndCell.length > 0) {
|
|
340
|
+
this.parent.formatter.editorManager.nodeSelection.setSelectionNode(this.parent.contentModule.getDocument(), this.curTable);
|
|
341
|
+
}
|
|
342
|
+
this.activeCell = null;
|
|
343
|
+
this.removeCellSelectClasses();
|
|
344
|
+
this.removeTableSelection();
|
|
345
|
+
};
|
|
346
|
+
Table.prototype.getCorrespondingColumns = function () {
|
|
347
|
+
var elementArray = [];
|
|
348
|
+
var colspan = 0;
|
|
349
|
+
var allRows = this.curTable.rows;
|
|
350
|
+
for (var i = 0; i <= allRows.length - 1; i++) {
|
|
351
|
+
var ele = allRows[i];
|
|
352
|
+
var index = 0;
|
|
353
|
+
for (var j = 0; j <= ele.children.length - 1; j++) {
|
|
354
|
+
var colEle = ele.children[j];
|
|
355
|
+
for (var ele_1 = colEle, colspan_1 = parseInt(ele_1.getAttribute('colspan'), 10) || 1, rowSpan = parseInt(ele_1.getAttribute('rowspan'), 10) || 1, rowIndex = i; rowIndex < i + rowSpan; rowIndex++) {
|
|
356
|
+
for (var colIndex = index; colIndex < index + colspan_1; colIndex++) {
|
|
357
|
+
if (!elementArray[rowIndex]) {
|
|
358
|
+
elementArray[rowIndex] = [];
|
|
359
|
+
}
|
|
360
|
+
if (elementArray[rowIndex][colIndex]) {
|
|
361
|
+
index++;
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
elementArray[rowIndex][colIndex] = colEle;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
index += colspan;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return elementArray;
|
|
372
|
+
};
|
|
373
|
+
Table.prototype.getCorrespondingIndex = function (cell, allCells) {
|
|
374
|
+
for (var i = 0; i < allCells.length; i++) {
|
|
375
|
+
for (var j = 0; j < allCells[i].length; j++) {
|
|
376
|
+
if (allCells[i][j] === cell) {
|
|
377
|
+
return [i, j];
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return [];
|
|
382
|
+
};
|
|
383
|
+
Table.prototype.getAdjacentTableElement = function (range, isdelKey) {
|
|
384
|
+
if (!range.collapsed || (!isdelKey && this.quickToolObj && this.quickToolObj.tableQTBar
|
|
385
|
+
&& document.body.contains(this.quickToolObj.tableQTBar.element))) {
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
var nodeCollection = this.getNodeCollection(range);
|
|
389
|
+
var startContainer = (range.collapsed && this.parent.contentModule.getEditPanel() === range.startContainer
|
|
390
|
+
&& nodeCollection && nodeCollection.length > 0 && nodeCollection[0] ?
|
|
391
|
+
nodeCollection[0] : range.startContainer);
|
|
392
|
+
var adjacentElement = this.getSelectedTableEle(nodeCollection);
|
|
393
|
+
var isBrEle = this.getBrElement(range, nodeCollection);
|
|
394
|
+
if (startContainer && startContainer.nodeType === Node.ELEMENT_NODE) {
|
|
395
|
+
if (startContainer.tagName === 'IMG' || startContainer.querySelector('img') || startContainer.tagName === 'AUDIO'
|
|
396
|
+
|| startContainer.querySelector('audio') || startContainer.tagName === 'VIDEO' || startContainer.querySelector('video')
|
|
397
|
+
|| startContainer.querySelector('.e-video-clickelem')) {
|
|
398
|
+
var compareRange = this.contentModule.getDocument().createRange();
|
|
399
|
+
compareRange.collapse(true);
|
|
400
|
+
compareRange.selectNodeContents(startContainer);
|
|
401
|
+
var nodeIndex = this.parent.formatter.editorManager.nodeSelection.getIndex(startContainer);
|
|
402
|
+
if ((isdelKey && compareRange.startOffset >= range.startOffset) ||
|
|
403
|
+
(!isdelKey && (startContainer.tagName !== 'IMG' && compareRange.startOffset !== range.startOffset
|
|
404
|
+
|| startContainer.tagName === 'IMG' && nodeIndex !== range.startOffset))) {
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (startContainer && startContainer.nodeType === Node.TEXT_NODE) {
|
|
410
|
+
if (isdelKey) {
|
|
411
|
+
if (range.endOffset !== range.endContainer.textContent.length) {
|
|
412
|
+
if (range.endOffset !== range.endContainer.textContent.trim().length) {
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
else if (range.startOffset !== 0) {
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
if (startContainer && startContainer.nodeType === Node.ELEMENT_NODE && startContainer.tagName === 'TABLE') {
|
|
422
|
+
adjacentElement = startContainer;
|
|
423
|
+
}
|
|
424
|
+
if (adjacentElement) {
|
|
425
|
+
var currentEleIndex = this.parent.formatter.editorManager.nodeSelection.getIndex(adjacentElement);
|
|
426
|
+
if (!((range.startOffset === currentEleIndex && isdelKey) || (range.startOffset !== currentEleIndex && !isdelKey))) {
|
|
427
|
+
adjacentElement = null;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
if (!adjacentElement && startContainer) {
|
|
431
|
+
adjacentElement = this.getAdjacentElementFromDom(startContainer, isBrEle, isdelKey);
|
|
432
|
+
}
|
|
433
|
+
if (adjacentElement && adjacentElement.nodeType === Node.ELEMENT_NODE && adjacentElement.tagName === 'TABLE') {
|
|
434
|
+
this.setSelection(adjacentElement, isBrEle);
|
|
435
|
+
return adjacentElement;
|
|
436
|
+
}
|
|
437
|
+
return null;
|
|
438
|
+
};
|
|
439
|
+
Table.prototype.getAdjacentElementFromDom = function (startContainer, isBrEle, isdelKey) {
|
|
440
|
+
var adjacentElement;
|
|
441
|
+
var parentElement = (isBrEle ? isBrEle : startContainer.parentNode);
|
|
442
|
+
var currentElement = startContainer;
|
|
443
|
+
while (parentElement && !adjacentElement && parentElement.parentNode) {
|
|
444
|
+
var childNodes = Array.from(parentElement.childNodes);
|
|
445
|
+
var startContainerIndex = childNodes.indexOf(currentElement);
|
|
446
|
+
if (startContainerIndex !== -1 && ((isdelKey && startContainerIndex < childNodes.length - 1)
|
|
447
|
+
|| (!isdelKey && startContainerIndex > 0))) {
|
|
448
|
+
adjacentElement = (childNodes[isdelKey ? startContainerIndex + 1 : startContainerIndex - 1]);
|
|
449
|
+
}
|
|
450
|
+
else {
|
|
451
|
+
adjacentElement = (isdelKey ? parentElement.nextSibling : parentElement.previousSibling);
|
|
452
|
+
currentElement = parentElement;
|
|
453
|
+
}
|
|
454
|
+
if (!isBrEle && startContainer.nodeType === Node.TEXT_NODE && adjacentElement && adjacentElement.tagName && adjacentElement.tagName.toUpperCase() === 'BR') {
|
|
455
|
+
isBrEle = currentElement = parentElement = adjacentElement;
|
|
456
|
+
adjacentElement = null;
|
|
457
|
+
}
|
|
458
|
+
if (!isBrEle && adjacentElement && !(adjacentElement.nodeType === Node.ELEMENT_NODE && adjacentElement.tagName === 'TABLE') && !ej2_base_2.isNullOrUndefined(adjacentElement.textContent) && !adjacentElement.textContent.trim()) {
|
|
459
|
+
currentElement = parentElement = adjacentElement.parentNode;
|
|
460
|
+
adjacentElement = null;
|
|
461
|
+
}
|
|
462
|
+
if (adjacentElement && adjacentElement.tagName && ['UL', 'OL', 'LI'].indexOf(adjacentElement.tagName.toUpperCase()) !== -1) {
|
|
463
|
+
adjacentElement = this.getAdjacentElementFromList(adjacentElement, isdelKey);
|
|
464
|
+
if (!adjacentElement) {
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
if (parentElement && parentElement.tagName && parentElement.tagName.toUpperCase() === 'LI' && !isdelKey) {
|
|
469
|
+
adjacentElement = parentElement;
|
|
470
|
+
}
|
|
471
|
+
parentElement = parentElement.parentNode;
|
|
472
|
+
}
|
|
473
|
+
return adjacentElement;
|
|
474
|
+
};
|
|
475
|
+
Table.prototype.getAdjacentElementFromList = function (adjacentElement, isdelKey) {
|
|
476
|
+
while (adjacentElement) {
|
|
477
|
+
if (adjacentElement.tagName && ['UL', 'OL', 'LI'].indexOf(adjacentElement.tagName.toUpperCase()) === -1) {
|
|
478
|
+
if (!(adjacentElement.nodeType === Node.ELEMENT_NODE && adjacentElement.tagName === 'TABLE')) {
|
|
479
|
+
adjacentElement = (isdelKey ? adjacentElement.firstChild : adjacentElement.lastChild);
|
|
480
|
+
}
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
adjacentElement = (isdelKey ? adjacentElement.firstChild : adjacentElement.lastChild);
|
|
484
|
+
}
|
|
485
|
+
return adjacentElement;
|
|
486
|
+
};
|
|
487
|
+
Table.prototype.getNodeCollection = function (range) {
|
|
488
|
+
var nodes = [];
|
|
489
|
+
if (range.collapsed && this.parent.contentModule.getEditPanel() === range.startContainer
|
|
490
|
+
&& range.startContainer.childNodes.length > 0) {
|
|
491
|
+
var index = Math.max(0, Math.min(range.startContainer.childNodes.length - 1, range.endOffset - 1));
|
|
492
|
+
nodes.push(range.startContainer.childNodes[index]);
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
nodes = this.parent.formatter.editorManager.nodeSelection.getNodeCollection(range);
|
|
496
|
+
}
|
|
497
|
+
return nodes;
|
|
498
|
+
};
|
|
499
|
+
Table.prototype.getSelectedTableEle = function (nodeCollection) {
|
|
500
|
+
if (nodeCollection && nodeCollection.length > 0) {
|
|
501
|
+
for (var _i = 0, _a = Array.from(nodeCollection); _i < _a.length; _i++) {
|
|
502
|
+
var element = _a[_i];
|
|
503
|
+
if (element && element.tagName === 'TABLE') {
|
|
504
|
+
return element;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
return null;
|
|
509
|
+
};
|
|
510
|
+
Table.prototype.getBrElement = function (range, nodeCollection) {
|
|
511
|
+
if (range.endContainer.tagName === 'BR') {
|
|
512
|
+
return range.endContainer;
|
|
513
|
+
}
|
|
514
|
+
if (nodeCollection.length === 1 && nodeCollection[0]
|
|
515
|
+
&& nodeCollection[0].tagName === 'BR') {
|
|
516
|
+
return nodeCollection[0];
|
|
517
|
+
}
|
|
518
|
+
return null;
|
|
519
|
+
};
|
|
520
|
+
Table.prototype.setSelection = function (nextElement, isBrEle) {
|
|
521
|
+
if (!nextElement.classList.contains('e-cell-select')) {
|
|
522
|
+
this.parent.formatter.editorManager.nodeSelection.Clear(this.contentModule.getDocument());
|
|
523
|
+
if (isBrEle) {
|
|
524
|
+
if (isBrEle.parentNode && isBrEle.parentNode.childNodes.length === 1 && isBrEle.parentNode.firstChild.nodeName === 'BR') {
|
|
525
|
+
ej2_base_1.detach(isBrEle.parentNode);
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
ej2_base_1.detach(isBrEle);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
var fakeSelectionEle = this.parent.createElement('div', { className: 'e-table-fake-selection' });
|
|
532
|
+
fakeSelectionEle.setAttribute('contenteditable', 'false');
|
|
533
|
+
this.contentModule.getEditPanel().appendChild(fakeSelectionEle);
|
|
534
|
+
this.parent.formatter.editorManager.nodeSelection.setSelectionNode(this.contentModule.getDocument(), fakeSelectionEle);
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
Table.prototype.removeAllFakeSelectionEles = function () {
|
|
538
|
+
var fakeSelectionEles = this.parent.contentModule.getEditPanel().querySelectorAll('.e-table-fake-selection');
|
|
539
|
+
if (fakeSelectionEles && fakeSelectionEles.length > 0) {
|
|
540
|
+
fakeSelectionEles.forEach(function (element) {
|
|
541
|
+
ej2_base_1.detach(element);
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
Table.prototype.deleteTable = function () {
|
|
546
|
+
var table = this.parent.contentModule.getEditPanel().querySelector('table.e-cell-select');
|
|
547
|
+
this.removeResizeElement();
|
|
548
|
+
if (table) {
|
|
549
|
+
var brElement = document.createElement('br');
|
|
550
|
+
var containerEle = brElement;
|
|
551
|
+
if (this.parent.enterKey === 'DIV') {
|
|
552
|
+
containerEle = document.createElement('div');
|
|
553
|
+
containerEle.appendChild(brElement);
|
|
554
|
+
}
|
|
555
|
+
else if (this.parent.enterKey === 'P') {
|
|
556
|
+
containerEle = document.createElement('p');
|
|
557
|
+
containerEle.appendChild(brElement);
|
|
558
|
+
}
|
|
559
|
+
table.parentNode.replaceChild(containerEle, table);
|
|
560
|
+
this.parent.formatter.editorManager.nodeSelection.setSelectionText(this.contentModule.getDocument(), containerEle, containerEle, 0, 0);
|
|
561
|
+
this.removeTableSelection();
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
Table.prototype.removeTableSelection = function () {
|
|
565
|
+
var table = this.parent.contentModule.getEditPanel().querySelector('table.e-cell-select');
|
|
566
|
+
if (table) {
|
|
567
|
+
util_2.removeClassWithAttr([table], classes.CLS_TABLE_SEL);
|
|
568
|
+
}
|
|
569
|
+
this.removeAllFakeSelectionEles();
|
|
570
|
+
};
|
|
571
|
+
Table.prototype.updateTableSelection = function (table) {
|
|
572
|
+
ej2_base_2.addClass([table], 'e-cell-select');
|
|
573
|
+
};
|
|
574
|
+
Table.prototype.handleSelectAll = function () {
|
|
575
|
+
this.cancelResizeAction();
|
|
576
|
+
var selectedCells = this.parent.inputElement.querySelectorAll('.' + classes.CLS_TABLE_SEL);
|
|
577
|
+
util_2.removeClassWithAttr(selectedCells, classes.CLS_TABLE_SEL);
|
|
578
|
+
this.removeTableSelection();
|
|
579
|
+
};
|
|
580
|
+
Table.prototype.tableModulekeyUp = function (e) {
|
|
581
|
+
if (!ej2_base_2.isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection) && this.contentModule) {
|
|
582
|
+
var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
|
|
583
|
+
var ele = this.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range)[0];
|
|
584
|
+
ele = (ele && ele.tagName !== 'TD' && ele.tagName !== 'TH') ? ele.parentElement : ele;
|
|
585
|
+
if (ele && ele.tagName !== 'TD' && ele.tagName !== 'TH') {
|
|
586
|
+
var closestTd = ej2_base_1.closest(ele, 'td');
|
|
587
|
+
ele = !ej2_base_2.isNullOrUndefined(closestTd) && this.parent.inputElement.contains(closestTd) ? closestTd : ele;
|
|
588
|
+
}
|
|
589
|
+
if ((ele && ele.tagName === 'TD' || ele.tagName === 'TH') && !ele.classList.contains(classes.CLS_TABLE_SEL)) {
|
|
590
|
+
ele.classList.add(classes.CLS_TABLE_SEL);
|
|
591
|
+
}
|
|
592
|
+
var eventArgs = e.args;
|
|
593
|
+
if (this.previousTableElement !== ele && !ej2_base_2.isNullOrUndefined(this.previousTableElement)
|
|
594
|
+
&& !eventArgs.shiftKey && (eventArgs.keyCode === 39 || eventArgs.keyCode === 37 ||
|
|
595
|
+
eventArgs.keyCode === 38 || eventArgs.keyCode === 40)) {
|
|
596
|
+
util_2.removeClassWithAttr([this.previousTableElement], classes.CLS_TABLE_SEL);
|
|
597
|
+
this.removeTableSelection();
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
Table.prototype.openDialog = function (isInternal, e) {
|
|
602
|
+
if (!isInternal) {
|
|
603
|
+
this.parent.contentModule.getEditPanel().focus();
|
|
604
|
+
}
|
|
605
|
+
if (this.parent.editorMode === 'HTML') {
|
|
606
|
+
var docElement = this.parent.contentModule.getDocument();
|
|
607
|
+
var range = this.parent.formatter.editorManager.nodeSelection.getRange(docElement);
|
|
608
|
+
var selection = this.parent.formatter.editorManager.nodeSelection.save(range, docElement);
|
|
609
|
+
var args = {
|
|
610
|
+
originalEvent: e ? e.args : { action: 'insert-table' },
|
|
611
|
+
item: {
|
|
612
|
+
command: 'Table',
|
|
613
|
+
subCommand: 'CreateTable'
|
|
614
|
+
},
|
|
615
|
+
name: !isInternal ? 'showDialog' : null
|
|
616
|
+
};
|
|
617
|
+
this.insertTableDialog({ self: this, args: args, selection: selection });
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
Table.prototype.showDialog = function () {
|
|
621
|
+
this.openDialog(false);
|
|
622
|
+
this.setCssClass({ cssClass: this.parent.getCssClass() });
|
|
623
|
+
};
|
|
624
|
+
Table.prototype.closeDialog = function () {
|
|
625
|
+
if (this.editdlgObj) {
|
|
626
|
+
this.editdlgObj.hide({ returnValue: true });
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
Table.prototype.onToolbarAction = function (args) {
|
|
630
|
+
var item = args.args.item;
|
|
631
|
+
switch (item.subCommand) {
|
|
632
|
+
case 'TableHeader':
|
|
633
|
+
this.tableHeader(args.selection, args.args);
|
|
634
|
+
break;
|
|
635
|
+
case 'TableRemove':
|
|
636
|
+
this.removeTable(args.selection, args.args);
|
|
637
|
+
break;
|
|
638
|
+
case 'TableEditProperties':
|
|
639
|
+
this.editTable(args);
|
|
640
|
+
break;
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
Table.prototype.verticalAlign = function (args, e) {
|
|
644
|
+
var tdEle = ej2_base_1.closest(args.selectParent[0], 'th') || ej2_base_1.closest(args.selectParent[0], 'td');
|
|
645
|
+
if (tdEle) {
|
|
646
|
+
this.parent.formatter.process(this.parent, e, e, { tableCell: tdEle, subCommand: e.item.subCommand });
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
Table.prototype.tableStyles = function (args, e) {
|
|
650
|
+
var command = e.item.subCommand;
|
|
651
|
+
var table = ej2_base_1.closest(args.selectParent[0], 'table');
|
|
652
|
+
if (command === 'Dashed') {
|
|
653
|
+
(this.parent.element.classList.contains(classes.CLS_TB_DASH_BOR)) ?
|
|
654
|
+
util_2.removeClassWithAttr([this.parent.element], classes.CLS_TB_DASH_BOR) : this.parent.element.classList.add(classes.CLS_TB_DASH_BOR);
|
|
655
|
+
(table.classList.contains(classes.CLS_TB_DASH_BOR)) ? util_2.removeClassWithAttr([table], classes.CLS_TB_DASH_BOR) :
|
|
656
|
+
table.classList.add(classes.CLS_TB_DASH_BOR);
|
|
657
|
+
}
|
|
658
|
+
if (command === 'Alternate') {
|
|
659
|
+
(this.parent.element.classList.contains(classes.CLS_TB_ALT_BOR)) ?
|
|
660
|
+
util_2.removeClassWithAttr([this.parent.element], classes.CLS_TB_ALT_BOR) : this.parent.element.classList.add(classes.CLS_TB_ALT_BOR);
|
|
661
|
+
(table.classList.contains(classes.CLS_TB_ALT_BOR)) ? util_2.removeClassWithAttr([table], classes.CLS_TB_ALT_BOR) :
|
|
662
|
+
table.classList.add(classes.CLS_TB_ALT_BOR);
|
|
663
|
+
}
|
|
664
|
+
if (args.args && args.args.item.cssClass) {
|
|
665
|
+
var classList = args.args.item.cssClass.split(' ');
|
|
666
|
+
for (var i = 0; i < classList.length; i++) {
|
|
667
|
+
if (table.classList.contains(classList[i])) {
|
|
668
|
+
util_2.removeClassWithAttr([table], (classList[i]));
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
table.classList.add(classList[i]);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
this.parent.formatter.process(this.parent, e, e, { subCommand: e.item.subCommand });
|
|
676
|
+
this.parent.formatter.saveData();
|
|
677
|
+
this.hideTableQuickToolbar();
|
|
678
|
+
this.parent.formatter.editorManager.nodeSelection.restore();
|
|
679
|
+
};
|
|
680
|
+
Table.prototype.insideList = function (range) {
|
|
681
|
+
var blockNodes = this.getBlockNodesInSelection(range);
|
|
682
|
+
var nodes = [];
|
|
683
|
+
for (var i = 0; i < blockNodes.length; i++) {
|
|
684
|
+
if (blockNodes[i].parentNode.tagName === 'LI') {
|
|
685
|
+
nodes.push(blockNodes[i].parentNode);
|
|
686
|
+
}
|
|
687
|
+
else if (blockNodes[i].tagName === 'LI' && blockNodes[i].childNodes[0].tagName !== 'P' &&
|
|
688
|
+
(blockNodes[i].childNodes[0].tagName !== 'OL' &&
|
|
689
|
+
blockNodes[i].childNodes[0].tagName !== 'UL')) {
|
|
690
|
+
nodes.push(blockNodes[i]);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
if (nodes.length > 1 || nodes.length && ((range.startOffset === 0 && range.endOffset === 0))) {
|
|
694
|
+
this.ensureInsideTableList = true;
|
|
695
|
+
return true;
|
|
696
|
+
}
|
|
697
|
+
else {
|
|
698
|
+
this.ensureInsideTableList = false;
|
|
699
|
+
return false;
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
Table.prototype.getBlockNodesInSelection = function (range) {
|
|
703
|
+
var blockTags = [
|
|
704
|
+
'DIV', 'SECTION', 'HEADER', 'FOOTER', 'ARTICLE', 'NAV',
|
|
705
|
+
'P', 'H1', 'H2', 'H3', 'BLOCKQUOTE', 'LI', 'PRE',
|
|
706
|
+
'TD', 'TH', 'FORM', 'FIELDSET', 'LEGEND', 'LABEL', 'TEXTAREA'
|
|
707
|
+
];
|
|
708
|
+
var blockNodes = new Set();
|
|
709
|
+
var treeWalker = this.contentModule.getDocument().createTreeWalker(range.commonAncestorContainer, NodeFilter.SHOW_TEXT, {
|
|
710
|
+
acceptNode: function (node) { return (range.intersectsNode(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT); }
|
|
711
|
+
});
|
|
712
|
+
if (range.collapsed) {
|
|
713
|
+
var blockNode = this.getImmediateBlockNode(range.startContainer, blockTags);
|
|
714
|
+
if (blockNode) {
|
|
715
|
+
blockNodes.add(blockNode);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
else {
|
|
719
|
+
while (treeWalker.nextNode()) {
|
|
720
|
+
var blockNode = this.getImmediateBlockNode(treeWalker.currentNode, blockTags);
|
|
721
|
+
if (blockNode) {
|
|
722
|
+
blockNodes.add(blockNode);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
return Array.from(blockNodes);
|
|
727
|
+
};
|
|
728
|
+
Table.prototype.getImmediateBlockNode = function (node, blockTags) {
|
|
729
|
+
var parentNode = node.nodeType === Node.TEXT_NODE ? node.parentNode : node;
|
|
730
|
+
while (parentNode && parentNode.nodeType === Node.ELEMENT_NODE) {
|
|
731
|
+
var element = parentNode;
|
|
732
|
+
if (blockTags.indexOf(element.tagName) > -1) {
|
|
733
|
+
return element;
|
|
734
|
+
}
|
|
735
|
+
parentNode = parentNode.parentNode;
|
|
736
|
+
}
|
|
737
|
+
return null;
|
|
738
|
+
};
|
|
739
|
+
Table.prototype.removeEmptyTextNodes = function (element) {
|
|
740
|
+
var children = element.childNodes;
|
|
741
|
+
for (var i = children.length - 1; i >= 0; i--) {
|
|
742
|
+
var node = children[i];
|
|
743
|
+
if (node.nodeType === Node.TEXT_NODE && node.nodeValue.trim() === '') {
|
|
744
|
+
element.removeChild(node);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
Table.prototype.tabSelection = function (event, selection, ele) {
|
|
749
|
+
var allHeadBodyTRElements = ele.closest('table').querySelectorAll('thead, tbody, tr');
|
|
750
|
+
for (var i = 0; i < allHeadBodyTRElements.length; i++) {
|
|
751
|
+
this.removeEmptyTextNodes(allHeadBodyTRElements[i]);
|
|
752
|
+
}
|
|
753
|
+
this.previousTableElement = ele;
|
|
754
|
+
var insideList = this.insideList(selection.range);
|
|
755
|
+
if ((event.keyCode === 37 || event.keyCode === 39) ||
|
|
756
|
+
insideList) {
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
event.preventDefault();
|
|
760
|
+
util_2.removeClassWithAttr([ele], classes.CLS_TABLE_SEL);
|
|
761
|
+
this.removeTableSelection();
|
|
762
|
+
if (!event.shiftKey && event.keyCode !== 37) {
|
|
763
|
+
var nextElement = (!ej2_base_2.isNullOrUndefined(ele.nextSibling)) ? ele.nextSibling :
|
|
764
|
+
(!ej2_base_2.isNullOrUndefined(ej2_base_1.closest(ele, 'tr').nextSibling) ? ej2_base_1.closest(ele, 'tr').nextSibling.childNodes[0] :
|
|
765
|
+
(!ej2_base_2.isNullOrUndefined(ej2_base_1.closest(ele, 'table').nextSibling)) ?
|
|
766
|
+
(ej2_base_1.closest(ele, 'table').nextSibling.nodeName.toLowerCase() === 'td') ?
|
|
767
|
+
ej2_base_1.closest(ele, 'table').nextSibling : ele : ele);
|
|
768
|
+
if (ele === nextElement && ele.nodeName === 'TH') {
|
|
769
|
+
nextElement = ej2_base_1.closest(ele, 'table').rows[1].cells[0];
|
|
770
|
+
}
|
|
771
|
+
if (event.keyCode === 39 && ele === nextElement) {
|
|
772
|
+
nextElement = ej2_base_1.closest(ele, 'table').nextSibling;
|
|
773
|
+
}
|
|
774
|
+
if (nextElement) {
|
|
775
|
+
(nextElement.textContent.trim() !== '' && ej2_base_1.closest(nextElement, 'td')) ?
|
|
776
|
+
selection.setSelectionNode(this.contentModule.getDocument(), nextElement) :
|
|
777
|
+
selection.setSelectionText(this.contentModule.getDocument(), nextElement, nextElement, 0, 0);
|
|
778
|
+
}
|
|
779
|
+
if (ele === nextElement && event.keyCode !== 39 && nextElement) {
|
|
780
|
+
ele.classList.add(classes.CLS_TABLE_SEL);
|
|
781
|
+
this.addRow(selection, event, true);
|
|
782
|
+
util_2.removeClassWithAttr([ele], classes.CLS_TABLE_SEL);
|
|
783
|
+
this.removeTableSelection();
|
|
784
|
+
nextElement = nextElement.parentElement.nextSibling ? nextElement.parentElement.nextSibling.firstChild :
|
|
785
|
+
nextElement.parentElement.firstChild;
|
|
786
|
+
(nextElement.textContent.trim() !== '' && ej2_base_1.closest(nextElement, 'td')) ?
|
|
787
|
+
selection.setSelectionNode(this.contentModule.getDocument(), nextElement) :
|
|
788
|
+
selection.setSelectionText(this.contentModule.getDocument(), nextElement, nextElement, 0, 0);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
else {
|
|
792
|
+
var prevElement = (!ej2_base_2.isNullOrUndefined(ele.previousSibling)) ? ele.previousSibling :
|
|
793
|
+
(!ej2_base_2.isNullOrUndefined(ej2_base_1.closest(ele, 'tr').previousSibling) ?
|
|
794
|
+
ej2_base_1.closest(ele, 'tr').previousSibling.childNodes[ej2_base_1.closest(ele, 'tr').previousSibling.childNodes.length - 1] :
|
|
795
|
+
(!ej2_base_2.isNullOrUndefined(ej2_base_1.closest(ele, 'table').previousSibling)) ?
|
|
796
|
+
(ej2_base_1.closest(ele, 'table').previousSibling.nodeName.toLowerCase() === 'td') ? ej2_base_1.closest(ele, 'table').previousSibling :
|
|
797
|
+
ele : ele);
|
|
798
|
+
if (ele === prevElement && ele.cellIndex === 0 &&
|
|
799
|
+
ej2_base_1.closest(ele, 'table').tHead && ele.nodeName !== 'TH') {
|
|
800
|
+
var clsTble = ej2_base_1.closest(ele, 'table');
|
|
801
|
+
prevElement = clsTble.rows[0].cells[clsTble.rows[0].cells.length - 1];
|
|
802
|
+
}
|
|
803
|
+
if (event.keyCode === 37 && ele === prevElement) {
|
|
804
|
+
prevElement = ej2_base_1.closest(ele, 'table').previousSibling;
|
|
805
|
+
}
|
|
806
|
+
if (!ej2_base_1.isNullOrUndefined(prevElement) && prevElement.firstChild.nodeName === 'TABLE') {
|
|
807
|
+
var tableChild = prevElement;
|
|
808
|
+
while (!ej2_base_1.isNullOrUndefined(tableChild.firstChild) && tableChild.firstChild.nodeName === 'TABLE' && tableChild.firstChild.rows.length > 0 && tableChild.firstChild.rows[0].cells.length > 0) {
|
|
809
|
+
tableChild = tableChild.firstChild.rows[0].cells[0];
|
|
810
|
+
}
|
|
811
|
+
prevElement = tableChild;
|
|
812
|
+
}
|
|
813
|
+
if (prevElement) {
|
|
814
|
+
(prevElement.textContent.trim() !== '' && ej2_base_1.closest(prevElement, 'td')) ?
|
|
815
|
+
selection.setSelectionNode(this.contentModule.getDocument(), prevElement) :
|
|
816
|
+
selection.setSelectionText(this.contentModule.getDocument(), prevElement, prevElement, 0, 0);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
Table.prototype.tableArrowNavigation = function (event, selection, ele) {
|
|
821
|
+
var selText = selection.range.startContainer;
|
|
822
|
+
this.previousTableElement = ele;
|
|
823
|
+
if ((event.keyCode === 40 && selText.nodeType === 3 && (selText.nextSibling && selText.nextSibling.nodeName === 'BR' ||
|
|
824
|
+
selText.parentNode && selText.parentNode.nodeName !== 'TD')) ||
|
|
825
|
+
(event.keyCode === 38 && selText.nodeType === 3 && (selText.previousSibling && selText.previousSibling.nodeName === 'BR' ||
|
|
826
|
+
selText.parentNode && selText.parentNode.nodeName !== 'TD'))) {
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
event.preventDefault();
|
|
830
|
+
util_2.removeClassWithAttr([ele], classes.CLS_TABLE_SEL);
|
|
831
|
+
this.removeTableSelection();
|
|
832
|
+
if (event.keyCode === 40) {
|
|
833
|
+
ele = (!ej2_base_2.isNullOrUndefined(ej2_base_1.closest(ele, 'tr').nextElementSibling)) ?
|
|
834
|
+
ej2_base_1.closest(ele, 'tr').nextElementSibling.children[ele.cellIndex] :
|
|
835
|
+
(ej2_base_1.closest(ele, 'table').tHead && ele.nodeName === 'TH') ?
|
|
836
|
+
ej2_base_1.closest(ele, 'table').rows[1].cells[ele.cellIndex] :
|
|
837
|
+
(!ej2_base_2.isNullOrUndefined(ej2_base_1.closest(ele, 'table').nextSibling)) ? ej2_base_1.closest(ele, 'table').nextSibling :
|
|
838
|
+
ele;
|
|
839
|
+
}
|
|
840
|
+
else {
|
|
841
|
+
ele = (!ej2_base_2.isNullOrUndefined(ej2_base_1.closest(ele, 'tr').previousElementSibling)) ?
|
|
842
|
+
ej2_base_1.closest(ele, 'tr').previousElementSibling.children[ele.cellIndex] :
|
|
843
|
+
(ej2_base_1.closest(ele, 'table').tHead && ele.nodeName !== 'TH') ?
|
|
844
|
+
ej2_base_1.closest(ele, 'table').tHead.rows[0].cells[ele.cellIndex] :
|
|
845
|
+
(!ej2_base_2.isNullOrUndefined(ej2_base_1.closest(ele, 'table').previousSibling)) ? ej2_base_1.closest(ele, 'table').previousSibling :
|
|
846
|
+
ele;
|
|
847
|
+
}
|
|
848
|
+
if (ele) {
|
|
849
|
+
selection.setSelectionText(this.contentModule.getDocument(), ele, ele, 0, 0);
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
Table.prototype.hideTableQuickToolbar = function () {
|
|
853
|
+
if (this.quickToolObj && this.quickToolObj.tableQTBar && document.body.contains(this.quickToolObj.tableQTBar.element)) {
|
|
854
|
+
this.quickToolObj.tableQTBar.hidePopup();
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
Table.prototype.tableHeader = function (selection, e) {
|
|
858
|
+
this.parent.formatter.process(this.parent, e, e.originalEvent, { selection: selection, subCommand: e.item.subCommand });
|
|
859
|
+
};
|
|
860
|
+
Table.prototype.getAnchorNode = function (element) {
|
|
861
|
+
var selectParent = ej2_base_1.closest(element, 'a');
|
|
862
|
+
return (selectParent ? selectParent : element);
|
|
863
|
+
};
|
|
864
|
+
Table.prototype.editAreaClickHandler = function (e) {
|
|
865
|
+
if (this.parent.readonly || !ej2_base_1.isNullOrUndefined(ej2_base_1.closest(e.args.target, '.e-img-caption'))) {
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
var args = e.args;
|
|
869
|
+
var showOnRightClick = this.parent.quickToolbarSettings.showOnRightClick;
|
|
870
|
+
if (args.which === 2 || (showOnRightClick && args.which === 1) || (!showOnRightClick && args.which === 3)) {
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
if (this.parent.editorMode === 'HTML' && this.parent.quickToolbarModule && this.parent.quickToolbarModule.tableQTBar) {
|
|
874
|
+
this.quickToolObj = this.parent.quickToolbarModule;
|
|
875
|
+
var target = args.target;
|
|
876
|
+
this.contentModule = this.rendererFactory.getRenderer(enum_1.RenderType.Content);
|
|
877
|
+
var isPopupOpen = this.quickToolObj.tableQTBar.element.classList.contains('e-rte-pop');
|
|
878
|
+
if (isPopupOpen) {
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.contentModule.getDocument());
|
|
882
|
+
var closestTable = ej2_base_1.closest(target, 'table');
|
|
883
|
+
var startNode = this.parent.getRange().startContainer.parentElement;
|
|
884
|
+
var endNode = this.parent.getRange().endContainer.parentElement;
|
|
885
|
+
var isAnchorEle = this.getAnchorNode(target);
|
|
886
|
+
var currentTime = new Date().getTime();
|
|
887
|
+
var ismacRightClick = this.parent.userAgentData.getPlatform() === 'macOS' && args.which === 3;
|
|
888
|
+
if (target && target.nodeName !== 'A' && isAnchorEle.nodeName !== 'A' && target.nodeName !== 'IMG' && target.nodeName !== 'VIDEO' && !target.classList.contains(classes.CLS_CLICKELEM) &&
|
|
889
|
+
target.nodeName !== 'AUDIO' && (startNode === endNode || ismacRightClick) && (target.nodeName === 'TD' || target.nodeName === 'TH' ||
|
|
890
|
+
target.nodeName === 'TABLE' || (closestTable && this.parent.contentModule.getEditPanel().contains(closestTable)))
|
|
891
|
+
&& !(range.startContainer.nodeType === 3 && !(range.collapsed || ismacRightClick)) &&
|
|
892
|
+
currentTime - this.resizeEndTime > 100 && !(ismacRightClick && (range.collapsed && range.startOffset !== 0)) && !(ismacRightClick && range.endContainer.nodeName === '#text')) {
|
|
893
|
+
var range_1 = this.parent.formatter.editorManager.nodeSelection.getRange(this.contentModule.getDocument());
|
|
894
|
+
this.parent.formatter.editorManager.nodeSelection.save(range_1, this.contentModule.getDocument());
|
|
895
|
+
this.parent.formatter.editorManager.nodeSelection.Clear(this.contentModule.getDocument());
|
|
896
|
+
var pageX = void 0;
|
|
897
|
+
var pageY = void 0;
|
|
898
|
+
if (ej2_base_1.Browser.isDevice && e.args.touches) {
|
|
899
|
+
pageX = (this.parent.iframeSettings.enable) ? window.pageXOffset + this.parent.element.getBoundingClientRect().left +
|
|
900
|
+
e.args.changedTouches[0].clientX : e.args.changedTouches[0].pageX;
|
|
901
|
+
pageY = (this.parent.iframeSettings.enable) ? window.pageYOffset + this.parent.element.getBoundingClientRect().top +
|
|
902
|
+
(!this.parent.inlineMode.enable ? this.parent.toolbarModule.getToolbarHeight() : 0)
|
|
903
|
+
+ e.args.changedTouches[0].clientY : e.args.changedTouches[0].pageY;
|
|
904
|
+
}
|
|
905
|
+
else {
|
|
906
|
+
pageX = (this.parent.iframeSettings.enable) ? window.pageXOffset
|
|
907
|
+
+ this.parent.element.getBoundingClientRect().left + args.clientX : args.pageX;
|
|
908
|
+
pageY = (this.parent.iframeSettings.enable) ? window.pageYOffset + this.parent.element.getBoundingClientRect().top +
|
|
909
|
+
this.parent.toolbarModule.getToolbarHeight() + args.clientY : args.pageY;
|
|
910
|
+
}
|
|
911
|
+
this.quickToolObj.tableQTBar.showPopup(pageX, pageY, target);
|
|
912
|
+
this.parent.formatter.editorManager.nodeSelection.restore();
|
|
913
|
+
}
|
|
914
|
+
else {
|
|
915
|
+
this.hideTableQuickToolbar();
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
Table.prototype.tableCellSelect = function (e) {
|
|
920
|
+
var target = e.target;
|
|
921
|
+
var row = Array.prototype.slice.call(target.parentElement.parentElement.children).indexOf(target.parentElement);
|
|
922
|
+
var col = Array.prototype.slice.call(target.parentElement.children).indexOf(target);
|
|
923
|
+
var list = this.dlgDiv.querySelectorAll('.e-rte-tablecell');
|
|
924
|
+
Array.prototype.forEach.call(list, function (item) {
|
|
925
|
+
var parentIndex = Array.prototype.slice.call(item.parentElement.parentElement.children).indexOf(item.parentElement);
|
|
926
|
+
var cellIndex = Array.prototype.slice.call(item.parentElement.children).indexOf(item);
|
|
927
|
+
util_2.removeClassWithAttr([item], 'e-active');
|
|
928
|
+
if (parentIndex <= row && cellIndex <= col) {
|
|
929
|
+
ej2_base_2.addClass([item], 'e-active');
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
this.tblHeader.innerHTML = (col + 1) + 'x' + (row + 1);
|
|
933
|
+
};
|
|
934
|
+
Table.prototype.tableMouseUp = function () {
|
|
935
|
+
this.unwireTableSelectionEvents();
|
|
936
|
+
this.isTableMoveActive = false;
|
|
937
|
+
};
|
|
938
|
+
Table.prototype.tableMouseLeave = function () {
|
|
939
|
+
if (!ej2_base_1.Browser.isDevice) {
|
|
940
|
+
this.unwireTableSelectionEvents();
|
|
941
|
+
this.isTableMoveActive = false;
|
|
942
|
+
this.resetTableSelection();
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
Table.prototype.tableCellLeave = function (e) {
|
|
946
|
+
util_2.removeClassWithAttr(this.dlgDiv.querySelectorAll('.e-rte-tablecell'), 'e-active');
|
|
947
|
+
ej2_base_2.addClass([this.dlgDiv.querySelector('.e-rte-tablecell')], 'e-active');
|
|
948
|
+
this.tblHeader.innerHTML = 1 + 'x' + 1;
|
|
949
|
+
};
|
|
950
|
+
Table.prototype.tableCellClick = function (e) {
|
|
951
|
+
var target = e.target;
|
|
952
|
+
var row = Array.prototype.slice.call(target.parentElement.parentElement.children).indexOf(target.parentElement) + 1;
|
|
953
|
+
var col = Array.prototype.slice.call(target.parentElement.children).indexOf(target) + 1;
|
|
954
|
+
this.self.tableInsert(row, col, e, this);
|
|
955
|
+
};
|
|
956
|
+
Table.prototype.tableInsert = function (row, col, e, selectionObj) {
|
|
957
|
+
var proxy = (selectionObj.self) ? selectionObj.self : this;
|
|
958
|
+
var startContainer = selectionObj.selection.range.startContainer;
|
|
959
|
+
if (startContainer.nodeName === 'P' && startContainer.textContent.trim() === '' && !(startContainer.childNodes.length > 0)) {
|
|
960
|
+
startContainer.innerHTML = '<br />';
|
|
961
|
+
}
|
|
962
|
+
var parentNode = startContainer.parentNode;
|
|
963
|
+
if (proxy.parent.editorMode === 'HTML' &&
|
|
964
|
+
((proxy.parent.iframeSettings.enable && !util_1.hasClass(parentNode.ownerDocument.querySelector('body'), 'e-lib')) ||
|
|
965
|
+
(!proxy.parent.iframeSettings.enable && ej2_base_1.isNullOrUndefined(ej2_base_1.closest(parentNode, '[id=' + "'" + proxy.contentModule.getPanel().id + "'" + ']'))))) {
|
|
966
|
+
proxy.contentModule.getEditPanel().focus();
|
|
967
|
+
var range = proxy.parent.formatter.editorManager.nodeSelection.getRange(proxy.contentModule.getDocument());
|
|
968
|
+
selectionObj.selection = proxy.parent.formatter.editorManager.nodeSelection.save(range, proxy.contentModule.getDocument());
|
|
969
|
+
}
|
|
970
|
+
var value = {
|
|
971
|
+
rows: row, columns: col, width: {
|
|
972
|
+
minWidth: proxy.parent.tableSettings.minWidth,
|
|
973
|
+
maxWidth: proxy.parent.tableSettings.maxWidth,
|
|
974
|
+
width: proxy.parent.tableSettings.width
|
|
975
|
+
},
|
|
976
|
+
selection: selectionObj.selection
|
|
977
|
+
};
|
|
978
|
+
if (proxy.popupObj) {
|
|
979
|
+
var rows = Array.prototype.slice.call(e.target.parentElement.parentElement.children);
|
|
980
|
+
for (var i = 0; i < rows.length; i++) {
|
|
981
|
+
ej2_base_2.EventHandler.remove(rows[i], 'mouseleave', this.tableCellLeave);
|
|
982
|
+
var cells = Array.prototype.slice.call(rows[i].children);
|
|
983
|
+
for (var j = 0; j < cells.length; j++) {
|
|
984
|
+
ej2_base_2.EventHandler.remove(cells[j], 'mousemove', this.tableCellSelect);
|
|
985
|
+
ej2_base_2.EventHandler.remove(cells[j], 'mouseup', this.tableCellClick);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
proxy.popupObj.hide();
|
|
989
|
+
}
|
|
990
|
+
if (proxy.editdlgObj) {
|
|
991
|
+
proxy.editdlgObj.hide();
|
|
992
|
+
}
|
|
993
|
+
var x = window.scrollX;
|
|
994
|
+
var y = window.scrollY;
|
|
995
|
+
proxy.parent.formatter.process(proxy.parent, selectionObj.args, selectionObj.args.originalEvent, value);
|
|
996
|
+
proxy.contentModule.getEditPanel().focus();
|
|
997
|
+
window.scrollTo(x, y);
|
|
998
|
+
proxy.parent.on(events.mouseDown, proxy.cellSelect, proxy);
|
|
999
|
+
var selection = proxy.parent.formatter.editorManager.nodeSelection.get(proxy.contentModule.getDocument());
|
|
1000
|
+
if (!ej2_base_2.isNullOrUndefined(selection) && !ej2_base_2.isNullOrUndefined(selection.anchorNode) &&
|
|
1001
|
+
selection.anchorNode.nodeType === Node.ELEMENT_NODE && (selection.anchorNode.tagName === 'TD'
|
|
1002
|
+
|| selection.anchorNode.tagName === 'TH')) {
|
|
1003
|
+
proxy.curTable = ej2_base_1.closest(selection.anchorNode, 'table');
|
|
1004
|
+
proxy.activeCell = selection.anchorNode;
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
1007
|
+
Table.prototype.cellSelect = function (e) {
|
|
1008
|
+
var target = e.args.target;
|
|
1009
|
+
var tdNode = ej2_base_1.closest(target, 'td,th');
|
|
1010
|
+
target = (target.nodeName !== 'TD' && tdNode && this.parent.contentModule.getEditPanel().contains(tdNode)) ?
|
|
1011
|
+
tdNode : target;
|
|
1012
|
+
if (!ej2_base_1.isNullOrUndefined(this.activeCell) && e.args.shiftKey && !ej2_base_1.isNullOrUndefined(target) && !ej2_base_1.isNullOrUndefined(target.tagName)
|
|
1013
|
+
&& (target.tagName === 'TD' || target.tagName === 'TH') && this.activeCell !== target) {
|
|
1014
|
+
this.parent.formatter.editorManager.observer.notify('TABLE_MOVE', { event: e.args, selectNode: [this.activeCell] });
|
|
1015
|
+
e.args.preventDefault();
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1018
|
+
if (!(this.parent.quickToolbarSettings.showOnRightClick && e.args.which === 3 &&
|
|
1019
|
+
target.classList.contains(classes.CLS_TABLE_SEL))) {
|
|
1020
|
+
if (this.isTableMoveActive) {
|
|
1021
|
+
this.unwireTableSelectionEvents();
|
|
1022
|
+
this.isTableMoveActive = false;
|
|
1023
|
+
}
|
|
1024
|
+
this.activeCell = null;
|
|
1025
|
+
this.heightcheck();
|
|
1026
|
+
this.removeCellSelectClasses();
|
|
1027
|
+
this.removeTableSelection();
|
|
1028
|
+
}
|
|
1029
|
+
if (target && (target.tagName === 'TD' || target.tagName === 'TH')) {
|
|
1030
|
+
ej2_base_2.addClass([target], classes.CLS_TABLE_SEL);
|
|
1031
|
+
this.activeCell = target;
|
|
1032
|
+
this.curTable = (this.curTable) ? this.curTable : ej2_base_1.closest(target, 'table');
|
|
1033
|
+
this.wireTableSelectionEvents();
|
|
1034
|
+
this.isTableMoveActive = true;
|
|
1035
|
+
this.removeResizeElement();
|
|
1036
|
+
if (this.helper && this.contentModule.getEditPanel().contains(this.helper)) {
|
|
1037
|
+
ej2_base_1.detach(this.helper);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
Table.prototype.heightcheck = function () {
|
|
1042
|
+
var table = this.parent.contentModule.getEditPanel().querySelector('td.e-cell-select');
|
|
1043
|
+
if (table && table.querySelector('img') && table.querySelector('img').style.height.includes('%')) {
|
|
1044
|
+
table.style.height = 'inherit';
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
Table.prototype.wireTableSelectionEvents = function () {
|
|
1048
|
+
ej2_base_2.EventHandler.add(this.curTable, 'mousemove', this.tableMove, this);
|
|
1049
|
+
ej2_base_2.EventHandler.add(this.curTable, 'mouseup', this.tableMouseUp, this);
|
|
1050
|
+
ej2_base_2.EventHandler.add(this.curTable, 'mouseleave', this.tableMouseLeave, this);
|
|
1051
|
+
};
|
|
1052
|
+
Table.prototype.unwireTableSelectionEvents = function () {
|
|
1053
|
+
ej2_base_2.EventHandler.remove(this.curTable, 'mousemove', this.tableMove);
|
|
1054
|
+
ej2_base_2.EventHandler.remove(this.curTable, 'mouseup', this.tableMouseUp);
|
|
1055
|
+
ej2_base_2.EventHandler.remove(this.curTable, 'mouseleave', this.tableMouseLeave);
|
|
1056
|
+
};
|
|
1057
|
+
Table.prototype.removeCellSelectClasses = function () {
|
|
1058
|
+
util_2.removeClassWithAttr(this.contentModule.getEditPanel().querySelectorAll('table td, table th'), classes.CLS_TABLE_SEL_END);
|
|
1059
|
+
util_2.removeClassWithAttr(this.contentModule.getEditPanel().querySelectorAll('table td, table th'), classes.CLS_TABLE_MULTI_CELL);
|
|
1060
|
+
util_2.removeClassWithAttr(this.contentModule.getEditPanel().querySelectorAll('table td, table th'), classes.CLS_TABLE_SEL);
|
|
1061
|
+
};
|
|
1062
|
+
Table.prototype.tableMove = function (event) {
|
|
1063
|
+
this.parent.formatter.editorManager.observer.notify('TABLE_MOVE', { event: event, selectNode: [this.activeCell] });
|
|
1064
|
+
};
|
|
1065
|
+
Table.prototype.resizeHelper = function (e) {
|
|
1066
|
+
if (this.parent.readonly) {
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
if (this.isTableMoveActive) {
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
if (e && e.buttons && e.buttons > 0) {
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
var target = e.target || e.targetTouches[0].target;
|
|
1076
|
+
var closestTable = ej2_base_1.closest(target, 'table.e-rte-table, table.e-rte-paste-table, table.e-rte-custom-table');
|
|
1077
|
+
var isResizing = this.parent.contentModule.getEditPanel().querySelectorAll('.e-table-box.e-rbox-select, .e-table-rhelper.e-column-helper, .e-table-rhelper.e-row-helper').length > 0;
|
|
1078
|
+
if (!isResizing && !ej2_base_1.isNullOrUndefined(this.curTable) && !ej2_base_1.isNullOrUndefined(closestTable) && closestTable !== this.curTable &&
|
|
1079
|
+
this.parent.contentModule.getEditPanel().contains(closestTable)) {
|
|
1080
|
+
this.removeResizeElement();
|
|
1081
|
+
this.removeHelper(e);
|
|
1082
|
+
this.cancelResizeAction();
|
|
1083
|
+
}
|
|
1084
|
+
if (!isResizing && (target.nodeName === 'TABLE' || target.nodeName === 'TD' || target.nodeName === 'TH')) {
|
|
1085
|
+
this.curTable = (closestTable && this.parent.contentModule.getEditPanel().contains(closestTable))
|
|
1086
|
+
&& (target.nodeName === 'TD' || target.nodeName === 'TH') ?
|
|
1087
|
+
closestTable : target;
|
|
1088
|
+
this.removeResizeElement();
|
|
1089
|
+
this.tableResizeEleCreation(this.curTable, e);
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
Table.prototype.tableResizeEleCreation = function (table, e) {
|
|
1093
|
+
this.parent.preventDefaultResize(e);
|
|
1094
|
+
var columns = this.calMaxCol(this.curTable);
|
|
1095
|
+
var rows = [];
|
|
1096
|
+
for (var i = 0; i < table.rows.length; i++) {
|
|
1097
|
+
for (var j = 0; j < table.rows[i].cells.length; j++) {
|
|
1098
|
+
if (!table.rows[i].cells[j].hasAttribute('rowspan')) {
|
|
1099
|
+
rows.push(Array.prototype.slice.call(table.rows[i].cells, 0, table.rows[i].cells.length)[j]);
|
|
1100
|
+
break;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
var height = parseInt(getComputedStyle(table).height, 10);
|
|
1105
|
+
var width = parseInt(getComputedStyle(table).width, 10);
|
|
1106
|
+
var pos = this.calcPos(table);
|
|
1107
|
+
for (var i = 0; columns.length >= i; i++) {
|
|
1108
|
+
var colReEle = this.parent.createElement('span', {
|
|
1109
|
+
attrs: {
|
|
1110
|
+
'data-col': (i).toString(), 'unselectable': 'on', 'contenteditable': 'false'
|
|
1111
|
+
}
|
|
1112
|
+
});
|
|
1113
|
+
colReEle.classList.add(classes.CLS_RTE_TABLE_RESIZE, classes.CLS_TB_COL_RES);
|
|
1114
|
+
if (columns.length === i) {
|
|
1115
|
+
colReEle.style.cssText = 'height: ' + height + 'px; width: 4px; top: ' + pos.top +
|
|
1116
|
+
'px; left:' + ((columns[i - 1].classList.contains('e-multi-cells-select') ? 0 : pos.left) + this.calcPos(columns[i - 1]).left + columns[i - 1].offsetWidth - 2) + 'px;';
|
|
1117
|
+
}
|
|
1118
|
+
else {
|
|
1119
|
+
colReEle.style.cssText = 'height: ' + height + 'px; width: 4px; top: ' + pos.top +
|
|
1120
|
+
'px; left:' + ((columns[i].classList.contains('e-multi-cells-select') ? 0 : pos.left) + this.calcPos(columns[i]).left - 2) + 'px;';
|
|
1121
|
+
}
|
|
1122
|
+
this.contentModule.getEditPanel().appendChild(colReEle);
|
|
1123
|
+
}
|
|
1124
|
+
for (var i = 0; rows.length > i; i++) {
|
|
1125
|
+
var rowReEle = this.parent.createElement('span', {
|
|
1126
|
+
attrs: {
|
|
1127
|
+
'data-row': (i).toString(), 'unselectable': 'on', 'contenteditable': 'false'
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
rowReEle.classList.add(classes.CLS_RTE_TABLE_RESIZE, classes.CLS_TB_ROW_RES);
|
|
1131
|
+
var rowPosLeft = !ej2_base_1.isNullOrUndefined(table.getAttribute('cellspacing')) || table.getAttribute('cellspacing') !== '' ?
|
|
1132
|
+
0 : this.calcPos(rows[i]).left;
|
|
1133
|
+
rowReEle.style.cssText = 'width: ' + width + 'px; height: 4px; top: ' +
|
|
1134
|
+
(this.calcPos(rows[i]).top + (rows[i].classList.contains('e-multi-cells-select') ? 0 : pos.top) + rows[i].offsetHeight - 2) +
|
|
1135
|
+
'px; left:' + (rowPosLeft + pos.left) + 'px;';
|
|
1136
|
+
this.contentModule.getEditPanel().appendChild(rowReEle);
|
|
1137
|
+
}
|
|
1138
|
+
var tableReBox = this.parent.createElement('span', {
|
|
1139
|
+
className: classes.CLS_TB_BOX_RES + this.parent.getCssClass(true), attrs: {
|
|
1140
|
+
'data-col': columns.length.toString(), 'unselectable': 'on', 'contenteditable': 'false'
|
|
1141
|
+
}
|
|
1142
|
+
});
|
|
1143
|
+
tableReBox.style.cssText = 'top: ' + (pos.top + height - 4) +
|
|
1144
|
+
'px; left:' + (pos.left + width - 4) + 'px;';
|
|
1145
|
+
if (ej2_base_1.Browser.isDevice) {
|
|
1146
|
+
tableReBox.classList.add('e-rmob');
|
|
1147
|
+
}
|
|
1148
|
+
this.contentModule.getEditPanel().appendChild(tableReBox);
|
|
1149
|
+
};
|
|
1150
|
+
Table.prototype.removeResizeElement = function () {
|
|
1151
|
+
var item = this.parent.contentModule.getEditPanel().
|
|
1152
|
+
querySelectorAll('.e-column-resize, .e-row-resize, .e-table-box');
|
|
1153
|
+
if (item.length > 0) {
|
|
1154
|
+
for (var i = 0; i < item.length; i++) {
|
|
1155
|
+
ej2_base_1.detach(item[i]);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
Table.prototype.calcPos = function (elem) {
|
|
1160
|
+
var parentOffset = {
|
|
1161
|
+
top: 0,
|
|
1162
|
+
left: 0
|
|
1163
|
+
};
|
|
1164
|
+
var offset = elem.getBoundingClientRect();
|
|
1165
|
+
var doc = elem.ownerDocument;
|
|
1166
|
+
var offsetParent = elem.offsetParent || doc.documentElement;
|
|
1167
|
+
var isNestedTable = false;
|
|
1168
|
+
while (offsetParent &&
|
|
1169
|
+
(offsetParent === doc.body || offsetParent === doc.documentElement) &&
|
|
1170
|
+
offsetParent.style.position === 'static') {
|
|
1171
|
+
offsetParent = offsetParent.parentNode;
|
|
1172
|
+
}
|
|
1173
|
+
if (offsetParent.nodeName === 'TD' && elem.nodeName === 'TABLE') {
|
|
1174
|
+
offsetParent = ej2_base_1.closest(offsetParent, '.e-rte-content');
|
|
1175
|
+
isNestedTable = true;
|
|
1176
|
+
}
|
|
1177
|
+
if (offsetParent && offsetParent !== elem && offsetParent.nodeType === 1) {
|
|
1178
|
+
parentOffset = offsetParent.getBoundingClientRect();
|
|
1179
|
+
}
|
|
1180
|
+
if (isNestedTable) {
|
|
1181
|
+
isNestedTable = false;
|
|
1182
|
+
var topValue = this.parent.inputElement && this.parent.inputElement.scrollTop > 0 ?
|
|
1183
|
+
(this.parent.inputElement.scrollTop + offset.top) - parentOffset.top : offset.top - parentOffset.top;
|
|
1184
|
+
var leftValue = this.parent.inputElement && this.parent.inputElement.scrollLeft > 0 ?
|
|
1185
|
+
(this.parent.inputElement.scrollLeft + offset.left) - parentOffset.left : offset.left - parentOffset.left;
|
|
1186
|
+
return {
|
|
1187
|
+
top: topValue,
|
|
1188
|
+
left: leftValue
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
else {
|
|
1192
|
+
return {
|
|
1193
|
+
top: elem.offsetTop,
|
|
1194
|
+
left: elem.offsetLeft
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
Table.prototype.getPointX = function (e) {
|
|
1199
|
+
if (e.touches && e.touches.length) {
|
|
1200
|
+
return e.touches[0].pageX;
|
|
1201
|
+
}
|
|
1202
|
+
else {
|
|
1203
|
+
return e.pageX;
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1206
|
+
Table.prototype.getPointY = function (e) {
|
|
1207
|
+
if (e.touches && e.touches.length) {
|
|
1208
|
+
return e.touches[0].pageY;
|
|
1209
|
+
}
|
|
1210
|
+
else {
|
|
1211
|
+
return e.pageY;
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
Table.prototype.resizeStart = function (e) {
|
|
1215
|
+
var _this = this;
|
|
1216
|
+
if (this.parent.readonly) {
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
if (ej2_base_1.Browser.isDevice) {
|
|
1220
|
+
this.resizeHelper(e);
|
|
1221
|
+
}
|
|
1222
|
+
var target = e.target;
|
|
1223
|
+
if (target.classList.contains(classes.CLS_TB_COL_RES) ||
|
|
1224
|
+
target.classList.contains(classes.CLS_TB_ROW_RES) ||
|
|
1225
|
+
target.classList.contains(classes.CLS_TB_BOX_RES)) {
|
|
1226
|
+
this.resetResizeHelper(this.curTable);
|
|
1227
|
+
e.preventDefault();
|
|
1228
|
+
this.parent.preventDefaultResize(e);
|
|
1229
|
+
util_2.removeClassWithAttr(this.curTable.querySelectorAll('td,th'), classes.CLS_TABLE_SEL);
|
|
1230
|
+
this.removeTableSelection();
|
|
1231
|
+
this.pageX = this.getPointX(e);
|
|
1232
|
+
this.pageY = this.getPointY(e);
|
|
1233
|
+
this.resizeBtnInit();
|
|
1234
|
+
this.hideTableQuickToolbar();
|
|
1235
|
+
if (target.classList.contains(classes.CLS_TB_COL_RES)) {
|
|
1236
|
+
this.resizeBtnStat.column = true;
|
|
1237
|
+
if (parseInt(target.getAttribute('data-col'), 10) === this.calMaxCol(this.curTable).length) {
|
|
1238
|
+
this.currentColumnResize = 'last';
|
|
1239
|
+
this.colIndex = parseInt(target.getAttribute('data-col'), 10) - 1;
|
|
1240
|
+
this.columnEle = this.calMaxCol(this.curTable)[this.colIndex];
|
|
1241
|
+
}
|
|
1242
|
+
else {
|
|
1243
|
+
if (parseInt(target.getAttribute('data-col'), 10) === 0) {
|
|
1244
|
+
this.currentColumnResize = 'first';
|
|
1245
|
+
}
|
|
1246
|
+
else {
|
|
1247
|
+
this.currentColumnResize = 'middle';
|
|
1248
|
+
var cellColl = this.curTable.rows[0].cells;
|
|
1249
|
+
var cellCount = 0;
|
|
1250
|
+
for (var cell = 0; cell < cellColl.length; cell++) {
|
|
1251
|
+
cellCount = cellCount + cellColl[cell].colSpan;
|
|
1252
|
+
}
|
|
1253
|
+
var sizes = new Array(cellCount);
|
|
1254
|
+
var colGroupEle = ej2_base_1.createElement('colgroup');
|
|
1255
|
+
var rowSpanCells = new Map();
|
|
1256
|
+
for (var i = 0; i < this.curTable.rows.length; i++) {
|
|
1257
|
+
var currentColIndex = 0;
|
|
1258
|
+
for (var k = 0; k < this.curTable.rows[i].cells.length; k++) {
|
|
1259
|
+
for (var l = 1; l < this.curTable.rows[i].cells[k].rowSpan; l++) {
|
|
1260
|
+
var key = "" + (i + l) + currentColIndex;
|
|
1261
|
+
rowSpanCells.set(key, this.curTable.rows[i].cells[k]);
|
|
1262
|
+
}
|
|
1263
|
+
var cellIndex = this.getCellIndex(rowSpanCells, i, k);
|
|
1264
|
+
if (cellIndex > currentColIndex) {
|
|
1265
|
+
currentColIndex = cellIndex;
|
|
1266
|
+
}
|
|
1267
|
+
var width = this.curTable.rows[i].cells[k].offsetWidth;
|
|
1268
|
+
if (!sizes[currentColIndex] || width < sizes[currentColIndex]) {
|
|
1269
|
+
sizes[currentColIndex] = width;
|
|
1270
|
+
}
|
|
1271
|
+
currentColIndex += 1 + this.curTable.rows[i].cells[k].colSpan - 1;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
for (var size = 0; size < sizes.length; size++) {
|
|
1275
|
+
var cell = ej2_base_1.createElement('col');
|
|
1276
|
+
cell.appendChild(ej2_base_1.createElement('br'));
|
|
1277
|
+
cell.style.width = this.convertPixelToPercentage(sizes[size], parseInt(getComputedStyle(this.curTable).width, 10)) + '%';
|
|
1278
|
+
colGroupEle.appendChild(cell);
|
|
1279
|
+
}
|
|
1280
|
+
this.curTable.insertBefore(colGroupEle, this.curTable.firstChild);
|
|
1281
|
+
for (var i = 0; i < this.curTable.rows.length; i++) {
|
|
1282
|
+
for (var k = 0; k < this.curTable.rows[i].cells.length; k++) {
|
|
1283
|
+
this.curTable.rows[i].cells[k].style.width = '';
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
this.colIndex = parseInt(target.getAttribute('data-col'), 10);
|
|
1288
|
+
this.columnEle = this.calMaxCol(this.curTable)[this.colIndex];
|
|
1289
|
+
}
|
|
1290
|
+
this.moveEle = e.target;
|
|
1291
|
+
this.appendHelper();
|
|
1292
|
+
}
|
|
1293
|
+
if (target.classList.contains(classes.CLS_TB_ROW_RES)) {
|
|
1294
|
+
this.rowEle = this.curTable.rows[parseInt(target.getAttribute('data-row'), 10)];
|
|
1295
|
+
this.resizeBtnStat.row = true;
|
|
1296
|
+
this.appendHelper();
|
|
1297
|
+
}
|
|
1298
|
+
if (target.classList.contains(classes.CLS_TB_BOX_RES)) {
|
|
1299
|
+
this.resizeBtnStat.tableBox = true;
|
|
1300
|
+
}
|
|
1301
|
+
if (ej2_base_1.Browser.isDevice && this.helper && !this.helper.classList.contains('e-reicon')) {
|
|
1302
|
+
this.helper.classList.add('e-reicon');
|
|
1303
|
+
ej2_base_2.EventHandler.add(document, ej2_base_1.Browser.touchStartEvent, this.removeHelper, this);
|
|
1304
|
+
ej2_base_2.EventHandler.add(this.helper, ej2_base_1.Browser.touchStartEvent, this.resizeStart, this);
|
|
1305
|
+
}
|
|
1306
|
+
else {
|
|
1307
|
+
var args = { event: e, requestType: 'Table' };
|
|
1308
|
+
this.parent.trigger(events.resizeStart, args, function (resizeStartArgs) {
|
|
1309
|
+
if (resizeStartArgs.cancel) {
|
|
1310
|
+
_this.cancelResizeAction();
|
|
1311
|
+
}
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
if (this.isResizeBind) {
|
|
1315
|
+
ej2_base_2.EventHandler.add(this.contentModule.getDocument(), ej2_base_1.Browser.touchMoveEvent, this.resizing, this);
|
|
1316
|
+
ej2_base_2.EventHandler.add(this.contentModule.getDocument(), ej2_base_1.Browser.touchEndEvent, this.resizeEnd, this);
|
|
1317
|
+
this.isResizeBind = false;
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
Table.prototype.getCellIndex = function (rowSpanCells, rowIndex, colIndex) {
|
|
1322
|
+
var cellKey = "" + rowIndex + colIndex;
|
|
1323
|
+
var spannedCell = rowSpanCells.get(cellKey);
|
|
1324
|
+
if (spannedCell) {
|
|
1325
|
+
return this.getCellIndex(rowSpanCells, rowIndex, colIndex + spannedCell.colSpan);
|
|
1326
|
+
}
|
|
1327
|
+
else {
|
|
1328
|
+
return colIndex;
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
Table.prototype.removeHelper = function (e) {
|
|
1332
|
+
var cls = e.target.classList;
|
|
1333
|
+
if (!(cls.contains('e-reicon')) && this.helper) {
|
|
1334
|
+
ej2_base_2.EventHandler.remove(document, ej2_base_1.Browser.touchStartEvent, this.removeHelper);
|
|
1335
|
+
ej2_base_2.EventHandler.remove(this.helper, ej2_base_1.Browser.touchStartEvent, this.resizeStart);
|
|
1336
|
+
if (this.helper && this.contentModule.getEditPanel().contains(this.helper)) {
|
|
1337
|
+
ej2_base_1.detach(this.helper);
|
|
1338
|
+
}
|
|
1339
|
+
this.pageX = null;
|
|
1340
|
+
this.helper = null;
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
Table.prototype.appendHelper = function () {
|
|
1344
|
+
this.helper = this.parent.createElement('div', {
|
|
1345
|
+
className: 'e-table-rhelper' + this.parent.getCssClass(true)
|
|
1346
|
+
});
|
|
1347
|
+
if (ej2_base_1.Browser.isDevice) {
|
|
1348
|
+
this.helper.classList.add('e-reicon');
|
|
1349
|
+
}
|
|
1350
|
+
this.contentModule.getEditPanel().appendChild(this.helper);
|
|
1351
|
+
this.setHelperHeight();
|
|
1352
|
+
};
|
|
1353
|
+
Table.prototype.setHelperHeight = function () {
|
|
1354
|
+
var pos = this.calcPos(this.curTable);
|
|
1355
|
+
if (this.resizeBtnStat.column) {
|
|
1356
|
+
this.helper.classList.add('e-column-helper');
|
|
1357
|
+
this.helper.style.cssText = 'height: ' + getComputedStyle(this.curTable).height + '; top: ' +
|
|
1358
|
+
pos.top + 'px; left:' + ((pos.left + this.calcPos(this.columnEle).left) +
|
|
1359
|
+
(this.currentColumnResize === 'last' ? this.columnEle.offsetWidth : 0) - 1) + 'px;';
|
|
1360
|
+
}
|
|
1361
|
+
else {
|
|
1362
|
+
this.helper.classList.add('e-row-helper');
|
|
1363
|
+
this.helper.style.cssText = 'width: ' + getComputedStyle(this.curTable).width + '; top: ' +
|
|
1364
|
+
(this.calcPos(this.rowEle).top + pos.top + this.rowEle.offsetHeight - 1) +
|
|
1365
|
+
'px; left:' + (this.calcPos(this.rowEle).left + pos.left) + 'px;';
|
|
1366
|
+
}
|
|
1367
|
+
};
|
|
1368
|
+
Table.prototype.updateHelper = function () {
|
|
1369
|
+
var pos = this.calcPos(this.curTable);
|
|
1370
|
+
if (this.resizeBtnStat.column) {
|
|
1371
|
+
var left = (pos.left + this.calcPos(this.columnEle).left) +
|
|
1372
|
+
(this.currentColumnResize === 'last' ? this.columnEle.offsetWidth : 0) - 1;
|
|
1373
|
+
this.helper.style.left = left + 'px';
|
|
1374
|
+
this.helper.style.height = this.curTable.offsetHeight + 'px';
|
|
1375
|
+
}
|
|
1376
|
+
else {
|
|
1377
|
+
var top_1 = this.calcPos(this.rowEle).top + pos.top + this.rowEle.offsetHeight - 1;
|
|
1378
|
+
this.helper.style.top = top_1 + 'px';
|
|
1379
|
+
}
|
|
1380
|
+
};
|
|
1381
|
+
Table.prototype.calMaxCol = function (curTable) {
|
|
1382
|
+
var cellColl = curTable.rows[0].cells;
|
|
1383
|
+
var cellCount = 0;
|
|
1384
|
+
for (var cell = 0; cell < cellColl.length; cell++) {
|
|
1385
|
+
cellCount = cellCount + cellColl[cell].colSpan;
|
|
1386
|
+
}
|
|
1387
|
+
var cells = new Array(cellCount);
|
|
1388
|
+
var rowSpanCells = new Map();
|
|
1389
|
+
for (var i = 0; i < curTable.rows.length; i++) {
|
|
1390
|
+
var currentColIndex = 0;
|
|
1391
|
+
for (var k = 0; k < curTable.rows[i].cells.length; k++) {
|
|
1392
|
+
for (var l = 1; l < curTable.rows[i].cells[k].rowSpan; l++) {
|
|
1393
|
+
var key = "" + (i + l) + currentColIndex;
|
|
1394
|
+
rowSpanCells.set(key, curTable.rows[i].cells[k]);
|
|
1395
|
+
}
|
|
1396
|
+
var cellIndex = this.getCellIndex(rowSpanCells, i, k);
|
|
1397
|
+
if (cellIndex > currentColIndex) {
|
|
1398
|
+
currentColIndex = cellIndex;
|
|
1399
|
+
}
|
|
1400
|
+
var width = curTable.rows[i].cells[k].offsetWidth;
|
|
1401
|
+
if (!cells[currentColIndex] || width < cells[currentColIndex].offsetWidth) {
|
|
1402
|
+
cells[currentColIndex] = curTable.rows[i].cells[k];
|
|
1403
|
+
}
|
|
1404
|
+
currentColIndex += 1 + curTable.rows[i].cells[k].colSpan - 1;
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
return cells;
|
|
1408
|
+
};
|
|
1409
|
+
Table.prototype.resizing = function (e) {
|
|
1410
|
+
var _this = this;
|
|
1411
|
+
var pageX = this.getPointX(e);
|
|
1412
|
+
var pageY = this.getPointY(e);
|
|
1413
|
+
var mouseX = (this.parent.enableRtl) ? -(pageX - this.pageX) : (pageX - this.pageX);
|
|
1414
|
+
var mouseY = (this.parent.enableRtl) ? -(pageY - this.pageY) : (pageY - this.pageY);
|
|
1415
|
+
this.pageX = pageX;
|
|
1416
|
+
this.pageY = pageY;
|
|
1417
|
+
var maxiumWidth;
|
|
1418
|
+
var currentTdElement = this.curTable.closest('td');
|
|
1419
|
+
var args = { event: e, requestType: 'table' };
|
|
1420
|
+
this.parent.trigger(events.onResize, args, function (resizingArgs) {
|
|
1421
|
+
if (resizingArgs.cancel) {
|
|
1422
|
+
_this.cancelResizeAction();
|
|
1423
|
+
}
|
|
1424
|
+
else {
|
|
1425
|
+
var tableReBox = _this.contentModule.getEditPanel().querySelector('.e-table-box');
|
|
1426
|
+
var tableWidth = parseInt(getComputedStyle(_this.curTable).width, 10);
|
|
1427
|
+
var tableHeight = !isNaN(parseInt(_this.curTable.style.height, 10)) ?
|
|
1428
|
+
parseInt(_this.curTable.style.height, 10) : parseInt(getComputedStyle(_this.curTable).height, 10);
|
|
1429
|
+
var paddingSize = +getComputedStyle(_this.contentModule.getEditPanel()).paddingRight.match(/\d/g).join('');
|
|
1430
|
+
var rteWidth = _this.contentModule.getEditPanel().offsetWidth -
|
|
1431
|
+
(_this.contentModule.getEditPanel().offsetWidth -
|
|
1432
|
+
_this.contentModule.getEditPanel().clientWidth) - paddingSize * 2;
|
|
1433
|
+
var widthCompare = void 0;
|
|
1434
|
+
if (!ej2_base_1.isNullOrUndefined(_this.curTable.parentElement.closest('table')) && !ej2_base_1.isNullOrUndefined(_this.curTable.closest('td')) &&
|
|
1435
|
+
_this.contentModule.getEditPanel().contains(_this.curTable.closest('td'))) {
|
|
1436
|
+
var currentTd = _this.curTable.closest('td');
|
|
1437
|
+
var currentTDPad = +getComputedStyle(currentTd).paddingRight.match(/\d/g).join('');
|
|
1438
|
+
widthCompare = currentTd.offsetWidth - (currentTd.offsetWidth - currentTd.clientWidth) - currentTDPad * 2;
|
|
1439
|
+
}
|
|
1440
|
+
else {
|
|
1441
|
+
widthCompare = rteWidth;
|
|
1442
|
+
}
|
|
1443
|
+
if (_this.resizeBtnStat.column) {
|
|
1444
|
+
if (_this.curTable.closest('li')) {
|
|
1445
|
+
widthCompare = _this.curTable.closest('li').offsetWidth;
|
|
1446
|
+
}
|
|
1447
|
+
var colGroup = _this.curTable.querySelectorAll('colgroup > col');
|
|
1448
|
+
var currentTableWidth = void 0;
|
|
1449
|
+
if (_this.curTable.style.width !== '' && _this.curTable.style.width.includes('%')) {
|
|
1450
|
+
currentTableWidth = parseFloat(_this.curTable.style.width.split('%')[0]);
|
|
1451
|
+
}
|
|
1452
|
+
else {
|
|
1453
|
+
currentTableWidth = _this.getCurrentTableWidth(_this.curTable.offsetWidth, _this.parent.inputElement.offsetWidth);
|
|
1454
|
+
}
|
|
1455
|
+
var currentCol = _this.calMaxCol(_this.curTable)[_this.colIndex];
|
|
1456
|
+
var currentColResizableWidth = _this.getCurrentColWidth(currentCol, tableWidth);
|
|
1457
|
+
if (_this.currentColumnResize === 'first') {
|
|
1458
|
+
mouseX = mouseX - 0.75;
|
|
1459
|
+
_this.removeResizeElement();
|
|
1460
|
+
if (currentTdElement) {
|
|
1461
|
+
maxiumWidth = _this.curTable.getBoundingClientRect().right - _this.calcPos(currentTdElement).left;
|
|
1462
|
+
_this.curTable.style.maxWidth = maxiumWidth + 'px';
|
|
1463
|
+
}
|
|
1464
|
+
if (((mouseX !== 0 && 5 < currentColResizableWidth) || mouseX < 0) && currentTableWidth <= 100 &&
|
|
1465
|
+
_this.convertPixelToPercentage(tableWidth - mouseX, widthCompare) <= 100) {
|
|
1466
|
+
var firstColumnsCell = _this.findFirstLastColCells(_this.curTable, true);
|
|
1467
|
+
_this.curTable.style.width = _this.convertPixelToPercentage(tableWidth - mouseX, widthCompare) > 100 ? (100 + '%') :
|
|
1468
|
+
(_this.convertPixelToPercentage(tableWidth - mouseX, widthCompare) + '%');
|
|
1469
|
+
var differenceWidth = currentTableWidth - _this.convertPixelToPercentage(tableWidth - mouseX, widthCompare);
|
|
1470
|
+
var preMarginLeft = 0;
|
|
1471
|
+
var widthType = _this.curTable.style.width.indexOf('%') > -1;
|
|
1472
|
+
if (!widthType && _this.curTable.offsetWidth > _this.contentModule.getEditPanel().offsetWidth) {
|
|
1473
|
+
_this.curTable.style.width = rteWidth + 'px';
|
|
1474
|
+
return;
|
|
1475
|
+
}
|
|
1476
|
+
if (widthType && parseFloat(_this.curTable.style.width.split('%')[0]) > 100) {
|
|
1477
|
+
_this.curTable.style.width = '100%';
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
if (!ej2_base_1.isNullOrUndefined(_this.curTable.style.marginLeft) && _this.curTable.style.marginLeft !== '') {
|
|
1481
|
+
var regex = /[-+]?\d*\.\d+|\d+/;
|
|
1482
|
+
var value = _this.curTable.style.marginLeft.match(regex);
|
|
1483
|
+
if (!ej2_base_1.isNullOrUndefined(value)) {
|
|
1484
|
+
preMarginLeft = parseFloat(value[0]);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
var currentMarginLeft = preMarginLeft + differenceWidth;
|
|
1488
|
+
if (currentMarginLeft && currentMarginLeft > 100) {
|
|
1489
|
+
var width = parseFloat(_this.curTable.style.width);
|
|
1490
|
+
currentMarginLeft = 100 - width;
|
|
1491
|
+
}
|
|
1492
|
+
if (!_this.curTable.classList.contains('e-rte-paste-table') && currentMarginLeft && currentMarginLeft < 1) {
|
|
1493
|
+
_this.curTable.style.marginLeft = null;
|
|
1494
|
+
_this.curTable.style.width = '100%';
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1497
|
+
_this.curTable.style.marginLeft = 'calc(' + (_this.curTable.style.width === '100%' ? 0 : currentMarginLeft) + '%)';
|
|
1498
|
+
for (var i = 0; i < firstColumnsCell.length; i++) {
|
|
1499
|
+
var currentColumnCellWidth = _this.getCurrentColWidth(firstColumnsCell[i], tableWidth);
|
|
1500
|
+
firstColumnsCell[i].style.width = (currentColumnCellWidth - differenceWidth) + '%';
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
else if (_this.currentColumnResize === 'last') {
|
|
1505
|
+
mouseX = mouseX + 0.75;
|
|
1506
|
+
_this.removeResizeElement();
|
|
1507
|
+
if (currentTdElement) {
|
|
1508
|
+
maxiumWidth = currentTdElement.getBoundingClientRect().right - _this.curTable.getBoundingClientRect().left;
|
|
1509
|
+
_this.curTable.style.maxWidth = maxiumWidth + 'px';
|
|
1510
|
+
}
|
|
1511
|
+
if (((mouseX !== 0 && 5 < currentColResizableWidth) || mouseX > 0) &&
|
|
1512
|
+
currentTableWidth <= 100 && _this.convertPixelToPercentage(tableWidth + mouseX, widthCompare) <= 100) {
|
|
1513
|
+
var lastColumnsCell = _this.findFirstLastColCells(_this.curTable, false);
|
|
1514
|
+
_this.curTable.style.width = _this.convertPixelToPercentage(tableWidth + mouseX, widthCompare) > 100 ? (100 + '%') : (_this.convertPixelToPercentage(tableWidth + mouseX, widthCompare) + '%');
|
|
1515
|
+
var differenceWidth = currentTableWidth - _this.convertPixelToPercentage(tableWidth + mouseX, widthCompare);
|
|
1516
|
+
for (var i = 0; i < lastColumnsCell.length; i++) {
|
|
1517
|
+
var currentColumnCellWidth = _this.getCurrentColWidth(lastColumnsCell[i], tableWidth);
|
|
1518
|
+
lastColumnsCell[i].style.width = (currentColumnCellWidth - differenceWidth) + '%';
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
else {
|
|
1523
|
+
var actualwid = colGroup[_this.colIndex].offsetWidth - mouseX;
|
|
1524
|
+
var totalwid = colGroup[_this.colIndex].offsetWidth + colGroup[_this.colIndex - 1].offsetWidth;
|
|
1525
|
+
if ((totalwid - actualwid) > 20 && actualwid > 20) {
|
|
1526
|
+
var leftColumnWidth = totalwid - actualwid;
|
|
1527
|
+
var rightColWidth = actualwid;
|
|
1528
|
+
colGroup[_this.colIndex - 1].style.width = _this.convertPixelToPercentage(leftColumnWidth, tableWidth) + '%';
|
|
1529
|
+
colGroup[_this.colIndex].style.width = _this.convertPixelToPercentage(rightColWidth, tableWidth) + '%';
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
_this.updateHelper();
|
|
1533
|
+
}
|
|
1534
|
+
else if (_this.resizeBtnStat.row) {
|
|
1535
|
+
_this.parent.preventDefaultResize(e);
|
|
1536
|
+
var tableTrElementPixel = [];
|
|
1537
|
+
var currentTableTrElement = _this.curTable.querySelectorAll('tr');
|
|
1538
|
+
for (var i = 0; i < currentTableTrElement.length; i++) {
|
|
1539
|
+
if (_this.rowEle !== currentTableTrElement[i]) {
|
|
1540
|
+
tableTrElementPixel[i] = (parseFloat(currentTableTrElement[i].clientHeight.toString()));
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
_this.curTable.style.height = (parseFloat(_this.curTable.clientHeight.toString()) + ((mouseY > 0) ? 0 : mouseY)) + 'px';
|
|
1544
|
+
for (var i = 0; i < currentTableTrElement.length; i++) {
|
|
1545
|
+
if (_this.rowEle === currentTableTrElement[i]) {
|
|
1546
|
+
currentTableTrElement[i].style.height = (parseFloat(currentTableTrElement[i].clientHeight.toString()) + mouseY) + 'px';
|
|
1547
|
+
}
|
|
1548
|
+
else {
|
|
1549
|
+
currentTableTrElement[i].style.height = tableTrElementPixel[i] + 'px';
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
if (!ej2_base_1.isNullOrUndefined(tableReBox)) {
|
|
1553
|
+
tableReBox.style.cssText = 'top: ' + (_this.calcPos(_this.curTable).top + tableHeight - 4) +
|
|
1554
|
+
'px; left:' + (_this.calcPos(_this.curTable).left + tableWidth - 4) + 'px;';
|
|
1555
|
+
}
|
|
1556
|
+
_this.updateHelper();
|
|
1557
|
+
}
|
|
1558
|
+
else if (_this.resizeBtnStat.tableBox) {
|
|
1559
|
+
if (currentTdElement) {
|
|
1560
|
+
var tableBoxPosition = _this.curTable.getBoundingClientRect().left
|
|
1561
|
+
- currentTdElement.getBoundingClientRect().left;
|
|
1562
|
+
maxiumWidth = Math.abs(tableBoxPosition - currentTdElement.getBoundingClientRect().width) - 5;
|
|
1563
|
+
_this.curTable.style.maxWidth = maxiumWidth + 'px';
|
|
1564
|
+
}
|
|
1565
|
+
_this.curTable.style.height = tableHeight + mouseY + 'px';
|
|
1566
|
+
if (!ej2_base_1.isNullOrUndefined(tableReBox)) {
|
|
1567
|
+
tableReBox.classList.add('e-rbox-select');
|
|
1568
|
+
tableReBox.style.cssText = 'top: ' + (_this.calcPos(_this.curTable).top + parseInt(getComputedStyle(_this.curTable).height, 10) - 4) +
|
|
1569
|
+
'px; left:' + (_this.calcPos(_this.curTable).left + tableWidth - 4) + 'px;';
|
|
1570
|
+
}
|
|
1571
|
+
if (_this.curTable.closest('li')) {
|
|
1572
|
+
widthCompare = _this.curTable.closest('li').offsetWidth;
|
|
1573
|
+
}
|
|
1574
|
+
var widthType = _this.curTable.style.width.indexOf('%') > -1;
|
|
1575
|
+
if (widthType && parseFloat(_this.curTable.style.width.split('%')[0]) > 100) {
|
|
1576
|
+
_this.curTable.style.width = '100%';
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
if (!widthType && _this.curTable.offsetWidth > _this.contentModule.getEditPanel().offsetWidth) {
|
|
1580
|
+
_this.curTable.style.width = rteWidth + 'px';
|
|
1581
|
+
return;
|
|
1582
|
+
}
|
|
1583
|
+
_this.curTable.style.width = widthType ? _this.convertPixelToPercentage(tableWidth + mouseX, widthCompare) + '%'
|
|
1584
|
+
: tableWidth + mouseX + 'px';
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
});
|
|
1588
|
+
};
|
|
1589
|
+
Table.prototype.getCurrentColWidth = function (col, tableWidth) {
|
|
1590
|
+
var currentColWidth = 0;
|
|
1591
|
+
if (col.style.width !== '' && col.style.width.includes('%')) {
|
|
1592
|
+
currentColWidth = parseFloat(col.style.width.split('%')[0]);
|
|
1593
|
+
}
|
|
1594
|
+
else {
|
|
1595
|
+
currentColWidth = this.convertPixelToPercentage(col.offsetWidth, tableWidth);
|
|
1596
|
+
}
|
|
1597
|
+
return currentColWidth;
|
|
1598
|
+
};
|
|
1599
|
+
Table.prototype.getCurrentTableWidth = function (tableWidth, parentWidth) {
|
|
1600
|
+
var currentTableWidth = 0;
|
|
1601
|
+
currentTableWidth = tableWidth / parentWidth * 100;
|
|
1602
|
+
return currentTableWidth;
|
|
1603
|
+
};
|
|
1604
|
+
Table.prototype.findFirstLastColCells = function (table, isFirst) {
|
|
1605
|
+
var resultColumns = [];
|
|
1606
|
+
var rows = table.rows;
|
|
1607
|
+
var rowSpanCellIndexs = [];
|
|
1608
|
+
var _loop_1 = function (i) {
|
|
1609
|
+
var cellIndex = isFirst ? 0 : rows[i].cells.length - 1;
|
|
1610
|
+
var column = rows[i].cells[cellIndex];
|
|
1611
|
+
for (var rowSpan = 1; rowSpan < column.rowSpan; rowSpan++) {
|
|
1612
|
+
var key = i + rowSpan + "-" + cellIndex;
|
|
1613
|
+
rowSpanCellIndexs.push(key);
|
|
1614
|
+
}
|
|
1615
|
+
var spannedCellKey = i + "-" + cellIndex;
|
|
1616
|
+
if (rowSpanCellIndexs.length === 0 || (isFirst && rowSpanCellIndexs.indexOf(spannedCellKey) === -1) || (!isFirst && rowSpanCellIndexs.indexOf(spannedCellKey) === -1 && rowSpanCellIndexs.every(function (key) { return key.split('-')[0] !== i.toString(); }))) {
|
|
1617
|
+
resultColumns.push(column);
|
|
1618
|
+
}
|
|
1619
|
+
};
|
|
1620
|
+
for (var i = 0; i < rows.length; i++) {
|
|
1621
|
+
_loop_1(i);
|
|
1622
|
+
}
|
|
1623
|
+
return resultColumns;
|
|
1624
|
+
};
|
|
1625
|
+
Table.prototype.convertPixelToPercentage = function (value, offsetValue) {
|
|
1626
|
+
return (value / offsetValue) * 100;
|
|
1627
|
+
};
|
|
1628
|
+
Table.prototype.cancelResizeAction = function () {
|
|
1629
|
+
this.isResizeBind = true;
|
|
1630
|
+
ej2_base_2.EventHandler.remove(this.contentModule.getDocument(), ej2_base_1.Browser.touchMoveEvent, this.resizing);
|
|
1631
|
+
ej2_base_2.EventHandler.remove(this.contentModule.getDocument(), ej2_base_1.Browser.touchEndEvent, this.resizeEnd);
|
|
1632
|
+
this.removeResizeElement();
|
|
1633
|
+
};
|
|
1634
|
+
Table.prototype.resizeEnd = function (e) {
|
|
1635
|
+
this.resizeBtnInit();
|
|
1636
|
+
this.isResizeBind = true;
|
|
1637
|
+
ej2_base_2.EventHandler.remove(this.contentModule.getDocument(), ej2_base_1.Browser.touchMoveEvent, this.resizing);
|
|
1638
|
+
ej2_base_2.EventHandler.remove(this.contentModule.getDocument(), ej2_base_1.Browser.touchEndEvent, this.resizeEnd);
|
|
1639
|
+
if (this.contentModule.getEditPanel().querySelector('.e-table-box') &&
|
|
1640
|
+
this.contentModule.getEditPanel().contains(this.contentModule.getEditPanel().querySelector('.e-table-box'))) {
|
|
1641
|
+
this.removeResizeElement();
|
|
1642
|
+
}
|
|
1643
|
+
if (this.helper && this.contentModule.getEditPanel().contains(this.helper)) {
|
|
1644
|
+
ej2_base_1.detach(this.helper);
|
|
1645
|
+
this.helper = null;
|
|
1646
|
+
}
|
|
1647
|
+
this.resetResizeHelper(this.curTable);
|
|
1648
|
+
this.pageX = null;
|
|
1649
|
+
this.pageY = null;
|
|
1650
|
+
this.moveEle = null;
|
|
1651
|
+
var currentTableTrElement = this.curTable.querySelectorAll('tr');
|
|
1652
|
+
var tableTrPercentage = [];
|
|
1653
|
+
for (var i = 0; i < currentTableTrElement.length; i++) {
|
|
1654
|
+
var percentage = (parseFloat(currentTableTrElement[i].clientHeight.toString())
|
|
1655
|
+
/ parseFloat(this.curTable.clientHeight.toString())) * 100;
|
|
1656
|
+
tableTrPercentage[i] = percentage;
|
|
1657
|
+
}
|
|
1658
|
+
for (var i = 0; i < currentTableTrElement.length; i++) {
|
|
1659
|
+
if (currentTableTrElement[i].parentElement.nodeName === 'THEAD') {
|
|
1660
|
+
currentTableTrElement[i].parentElement.style.height = tableTrPercentage[i] + '%';
|
|
1661
|
+
currentTableTrElement[i].style.height = tableTrPercentage[i] + '%';
|
|
1662
|
+
}
|
|
1663
|
+
else {
|
|
1664
|
+
currentTableTrElement[i].style.height = tableTrPercentage[i] + '%';
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
var args = { event: e, requestType: 'table' };
|
|
1668
|
+
this.parent.trigger(events.resizeStop, args);
|
|
1669
|
+
this.parent.formatter.saveData();
|
|
1670
|
+
this.resizeEndTime = new Date().getTime();
|
|
1671
|
+
};
|
|
1672
|
+
Table.prototype.resetResizeHelper = function (curTable) {
|
|
1673
|
+
var colHelper = this.parent.element.querySelectorAll('.e-table-rhelper.e-column-helper');
|
|
1674
|
+
Array.from(colHelper).forEach(function (element) {
|
|
1675
|
+
if (element.parentNode) {
|
|
1676
|
+
element.parentNode.removeChild(element);
|
|
1677
|
+
}
|
|
1678
|
+
});
|
|
1679
|
+
var rowHelper = this.parent.element.querySelectorAll('.e-table-rhelper.e-row-helper');
|
|
1680
|
+
Array.from(rowHelper).forEach(function (element) {
|
|
1681
|
+
if (element.parentNode) {
|
|
1682
|
+
element.parentNode.removeChild(element);
|
|
1683
|
+
}
|
|
1684
|
+
});
|
|
1685
|
+
if (parseInt(curTable.style.width, 10) === 0) {
|
|
1686
|
+
curTable.style.width = curTable.offsetWidth + 'px';
|
|
1687
|
+
}
|
|
1688
|
+
var colGroup = curTable.querySelector('colgroup');
|
|
1689
|
+
if (colGroup) {
|
|
1690
|
+
for (var i = 0; i < curTable.rows.length; i++) {
|
|
1691
|
+
for (var k = 0; k < curTable.rows[i].cells.length; k++) {
|
|
1692
|
+
var width = this.convertPixelToPercentage(curTable.rows[i].cells[k].offsetWidth, parseInt(getComputedStyle(curTable).width, 10)) + '%';
|
|
1693
|
+
curTable.rows[i].cells[k].style.width = width;
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
curTable.removeChild(colGroup);
|
|
1697
|
+
}
|
|
1698
|
+
};
|
|
1699
|
+
Table.prototype.resizeBtnInit = function () {
|
|
1700
|
+
return this.resizeBtnStat = { column: false, row: false, tableBox: false };
|
|
1701
|
+
};
|
|
1702
|
+
Table.prototype.addRow = function (selectCell, e, tabkey) {
|
|
1703
|
+
var cmd;
|
|
1704
|
+
if (tabkey) {
|
|
1705
|
+
cmd = {
|
|
1706
|
+
item: { command: 'Table', subCommand: 'InsertRowAfter' }
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
var value = {
|
|
1710
|
+
selection: selectCell,
|
|
1711
|
+
subCommand: (tabkey) ? cmd.item.subCommand : e.item.subCommand
|
|
1712
|
+
};
|
|
1713
|
+
this.parent.formatter.process(this.parent, (tabkey) ? cmd : e, e, value);
|
|
1714
|
+
};
|
|
1715
|
+
Table.prototype.addColumn = function (selectCell, e) {
|
|
1716
|
+
this.parent.formatter.process(this.parent, e, e, { selection: selectCell, width: this.parent.tableSettings.width, subCommand: e.item.subCommand });
|
|
1717
|
+
};
|
|
1718
|
+
Table.prototype.removeRowColumn = function (selectCell, e) {
|
|
1719
|
+
this.parent.formatter.process(this.parent, e, e, { selection: selectCell, subCommand: e.item.subCommand });
|
|
1720
|
+
this.hideTableQuickToolbar();
|
|
1721
|
+
};
|
|
1722
|
+
Table.prototype.removeTable = function (selection, args, delKey) {
|
|
1723
|
+
var cmd;
|
|
1724
|
+
if (delKey) {
|
|
1725
|
+
cmd = { item: { command: 'Table', subCommand: 'TableRemove' } };
|
|
1726
|
+
}
|
|
1727
|
+
var value = {
|
|
1728
|
+
selection: selection,
|
|
1729
|
+
subCommand: (delKey) ? cmd.item.subCommand : args.item.subCommand
|
|
1730
|
+
};
|
|
1731
|
+
this.parent.formatter.process(this.parent, (delKey) ? cmd : args, args.originalEvent, value);
|
|
1732
|
+
this.contentModule.getEditPanel().focus();
|
|
1733
|
+
if (this.parent.inputElement.innerHTML === null || this.parent.inputElement.innerHTML === '') {
|
|
1734
|
+
if (this.parent.enterKey === 'DIV') {
|
|
1735
|
+
this.contentModule.getEditPanel().innerHTML = '<div><br/></div>';
|
|
1736
|
+
}
|
|
1737
|
+
else if (this.parent.enterKey === 'BR') {
|
|
1738
|
+
this.contentModule.getEditPanel().innerHTML = '<br/>';
|
|
1739
|
+
}
|
|
1740
|
+
else {
|
|
1741
|
+
this.contentModule.getEditPanel().innerHTML = '<p><br/></p>';
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
this.removeResizeElement();
|
|
1745
|
+
this.hideTableQuickToolbar();
|
|
1746
|
+
};
|
|
1747
|
+
Table.prototype.renderDlgContent = function (args) {
|
|
1748
|
+
var _this = this;
|
|
1749
|
+
var argsTarget = args.args.originalEvent.target;
|
|
1750
|
+
if (ej2_base_1.Browser.isDevice || this.parent.inlineMode.enable || !ej2_base_2.isNullOrUndefined(ej2_base_1.closest(argsTarget, '.e-rte-text-popup'))) {
|
|
1751
|
+
this.insertTableDialog(args);
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
if (this.popupObj) {
|
|
1755
|
+
this.popupObj.hide();
|
|
1756
|
+
return;
|
|
1757
|
+
}
|
|
1758
|
+
this.hideTableQuickToolbar();
|
|
1759
|
+
var header = '1X1';
|
|
1760
|
+
var insertbtn = this.l10n.getConstant('inserttablebtn');
|
|
1761
|
+
this.dlgDiv = this.parent.createElement('div', { className: 'e-rte-table-popup' + this.parent.getCssClass(true), id: this.rteID + '_table' });
|
|
1762
|
+
this.createTablePopupBoundFn = this.createTablePopupKeyDown.bind(this);
|
|
1763
|
+
this.dlgDiv.addEventListener('keydown', this.createTablePopupBoundFn);
|
|
1764
|
+
this.tblHeader = this.parent.createElement('div', { className: 'e-rte-popup-header' + this.parent.getCssClass(true) });
|
|
1765
|
+
this.tblHeader.innerHTML = header;
|
|
1766
|
+
this.dlgDiv.appendChild(this.tblHeader);
|
|
1767
|
+
var tableDiv = this.parent.createElement('div', { className: 'e-rte-table-span' + this.parent.getCssClass(true) });
|
|
1768
|
+
this.drawTable(tableDiv, args);
|
|
1769
|
+
this.dlgDiv.appendChild(tableDiv);
|
|
1770
|
+
this.dlgDiv.appendChild(this.parent.createElement('span', { className: 'e-span-border' + this.parent.getCssClass(true) }));
|
|
1771
|
+
var btnEle = this.parent.createElement('button', {
|
|
1772
|
+
className: 'e-insert-table-btn' + this.parent.getCssClass(true), id: this.rteID + '_insertTable',
|
|
1773
|
+
attrs: { type: 'button', tabindex: '0' }
|
|
1774
|
+
});
|
|
1775
|
+
if (!ej2_base_1.isNullOrUndefined(this.parent.getToolbarElement().querySelector('.e-expended-nav'))) {
|
|
1776
|
+
this.parent.getToolbarElement().querySelector('.e-expended-nav').setAttribute('tabindex', '1');
|
|
1777
|
+
}
|
|
1778
|
+
this.dlgDiv.appendChild(btnEle);
|
|
1779
|
+
this.createTableButton = new ej2_buttons_1.Button({
|
|
1780
|
+
iconCss: 'e-icons e-create-table', content: insertbtn, cssClass: 'e-flat' + this.parent.getCssClass(true),
|
|
1781
|
+
enableRtl: this.parent.enableRtl, locale: this.parent.locale
|
|
1782
|
+
});
|
|
1783
|
+
this.createTableButton.isStringTemplate = true;
|
|
1784
|
+
this.createTableButton.appendTo(btnEle);
|
|
1785
|
+
ej2_base_2.EventHandler.add(btnEle, 'click', this.insertTableDialog, { self: this, args: args.args, selection: args.selection });
|
|
1786
|
+
this.parent.getToolbar().parentElement.appendChild(this.dlgDiv);
|
|
1787
|
+
var target = args.args.originalEvent.target;
|
|
1788
|
+
target = target.classList.contains('e-toolbar-item') ? target.firstChild : target.parentElement;
|
|
1789
|
+
this.popupObj = new ej2_popups_1.Popup(this.dlgDiv, {
|
|
1790
|
+
targetType: 'relative',
|
|
1791
|
+
relateTo: target,
|
|
1792
|
+
collision: { X: 'fit', Y: 'none' },
|
|
1793
|
+
offsetY: 8,
|
|
1794
|
+
viewPortElement: this.parent.element,
|
|
1795
|
+
position: { X: 'left', Y: 'bottom' },
|
|
1796
|
+
enableRtl: this.parent.enableRtl,
|
|
1797
|
+
zIndex: 10001,
|
|
1798
|
+
close: function (event) {
|
|
1799
|
+
ej2_base_2.EventHandler.remove(btnEle, 'click', _this.insertTableDialog);
|
|
1800
|
+
_this.dlgDiv.removeEventListener('keydown', _this.createTablePopupBoundFn);
|
|
1801
|
+
ej2_base_1.detach(btnEle);
|
|
1802
|
+
if (_this.createTableButton && !_this.createTableButton.isDestroyed) {
|
|
1803
|
+
_this.createTableButton.destroy();
|
|
1804
|
+
_this.createTableButton.element = null;
|
|
1805
|
+
_this.createTableButton = null;
|
|
1806
|
+
}
|
|
1807
|
+
_this.parent.isBlur = false;
|
|
1808
|
+
_this.popupObj.element.parentElement.style.zIndex = '';
|
|
1809
|
+
_this.popupObj.destroy();
|
|
1810
|
+
ej2_base_1.detach(_this.popupObj.element);
|
|
1811
|
+
_this.popupObj = null;
|
|
1812
|
+
}
|
|
1813
|
+
});
|
|
1814
|
+
ej2_base_2.addClass([this.popupObj.element], 'e-popup-open');
|
|
1815
|
+
this.popupObj.element.parentElement.style.zIndex = '11';
|
|
1816
|
+
if (!ej2_base_1.isNullOrUndefined(this.parent.cssClass)) {
|
|
1817
|
+
ej2_base_2.addClass([this.popupObj.element], this.parent.getCssClass());
|
|
1818
|
+
}
|
|
1819
|
+
btnEle.focus();
|
|
1820
|
+
this.popupObj.refreshPosition(target);
|
|
1821
|
+
};
|
|
1822
|
+
Table.prototype.onIframeMouseDown = function () {
|
|
1823
|
+
if (this.popupObj) {
|
|
1824
|
+
this.popupObj.hide();
|
|
1825
|
+
}
|
|
1826
|
+
if (this.parent.inlineMode.enable && this.editdlgObj) {
|
|
1827
|
+
this.editdlgObj.hide();
|
|
1828
|
+
}
|
|
1829
|
+
if (!ej2_base_1.isNullOrUndefined(this.parent) && !ej2_base_1.isNullOrUndefined(this.parent.contentModule) && !ej2_base_1.isNullOrUndefined(this.parent.contentModule.getEditPanel())) {
|
|
1830
|
+
this.removeResizeElement();
|
|
1831
|
+
}
|
|
1832
|
+
};
|
|
1833
|
+
Table.prototype.docClick = function (e) {
|
|
1834
|
+
var target = e.args.target;
|
|
1835
|
+
if (target && target.classList && ((this.popupObj && !ej2_base_1.closest(target, '[id=' + "'" + this.popupObj.element.id + "'" + ']') ||
|
|
1836
|
+
(this.editdlgObj && !ej2_base_1.closest(target, '#' + this.editdlgObj.element.id)))) && !target.classList.contains('e-create-table') &&
|
|
1837
|
+
target.offsetParent && !target.offsetParent.classList.contains('e-rte-backgroundcolor-dropdown')) {
|
|
1838
|
+
if (this.popupObj) {
|
|
1839
|
+
this.popupObj.hide();
|
|
1840
|
+
}
|
|
1841
|
+
if (this.editdlgObj) {
|
|
1842
|
+
this.parent.notify(events.documentClickClosedBy, { closedBy: 'outside click' });
|
|
1843
|
+
this.editdlgObj.hide();
|
|
1844
|
+
}
|
|
1845
|
+
this.parent.isBlur = true;
|
|
1846
|
+
util_1.dispatchEvent(this.parent.element, 'focusout');
|
|
1847
|
+
}
|
|
1848
|
+
var closestEle = ej2_base_1.closest(target, 'td');
|
|
1849
|
+
var isExist = closestEle && this.parent.contentModule.getEditPanel().contains(closestEle) ? true : false;
|
|
1850
|
+
if (target && target.tagName !== 'TD' && target.tagName !== 'TH' && !isExist &&
|
|
1851
|
+
ej2_base_1.closest(target, '.e-rte-quick-popup') === null && target.offsetParent &&
|
|
1852
|
+
!target.offsetParent.classList.contains('e-quick-dropdown') &&
|
|
1853
|
+
!target.offsetParent.classList.contains('e-rte-backgroundcolor-dropdown') && !ej2_base_1.closest(target, '.e-rte-dropdown-popup')
|
|
1854
|
+
&& !ej2_base_1.closest(target, '.e-rte-elements')) {
|
|
1855
|
+
var isToolbarClick = target && target.closest('.e-toolbar') ? true : false;
|
|
1856
|
+
if (!isToolbarClick) {
|
|
1857
|
+
this.removeCellSelectClasses();
|
|
1858
|
+
}
|
|
1859
|
+
this.removeTableSelection();
|
|
1860
|
+
if (!ej2_base_1.Browser.isIE) {
|
|
1861
|
+
this.hideTableQuickToolbar();
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
if (target && target.classList && !target.classList.contains(classes.CLS_TB_COL_RES) &&
|
|
1865
|
+
!target.classList.contains(classes.CLS_TB_ROW_RES) && !target.classList.contains(classes.CLS_TB_BOX_RES)) {
|
|
1866
|
+
this.removeResizeElement();
|
|
1867
|
+
}
|
|
1868
|
+
};
|
|
1869
|
+
Table.prototype.drawTable = function (tableDiv, args) {
|
|
1870
|
+
var rowDiv;
|
|
1871
|
+
var tableCell;
|
|
1872
|
+
for (var row = 0; row < 3; row++) {
|
|
1873
|
+
rowDiv = this.parent.createElement('div', { className: 'e-rte-table-row' + this.parent.getCssClass(true), attrs: { 'data-column': '' + row } });
|
|
1874
|
+
ej2_base_2.EventHandler.add(rowDiv, 'mouseleave', this.tableCellLeave, this);
|
|
1875
|
+
for (var col = 0; col < 10; col++) {
|
|
1876
|
+
tableCell = this.parent.createElement('div', { className: 'e-rte-tablecell e-default' + this.parent.getCssClass(true), attrs: { 'data-cell': '' + col } });
|
|
1877
|
+
rowDiv.appendChild(tableCell);
|
|
1878
|
+
tableCell.style.display = 'inline-block';
|
|
1879
|
+
if (col === 0 && row === 0) {
|
|
1880
|
+
ej2_base_2.addClass([tableCell], 'e-active');
|
|
1881
|
+
}
|
|
1882
|
+
ej2_base_2.EventHandler.add(tableCell, 'mousemove', this.tableCellSelect, this);
|
|
1883
|
+
ej2_base_2.EventHandler.add(tableCell, 'mouseup', this.tableCellClick, { self: this, args: args.args, selection: args.selection });
|
|
1884
|
+
}
|
|
1885
|
+
tableDiv.appendChild(rowDiv);
|
|
1886
|
+
}
|
|
1887
|
+
};
|
|
1888
|
+
Table.prototype.editTable = function (args) {
|
|
1889
|
+
var _this = this;
|
|
1890
|
+
this.createDialog(args);
|
|
1891
|
+
var editContent = this.tableDlgContent(args);
|
|
1892
|
+
var update = this.l10n.getConstant('dialogUpdate');
|
|
1893
|
+
var cancel = this.l10n.getConstant('dialogCancel');
|
|
1894
|
+
var editHeader = this.l10n.getConstant('tableEditHeader');
|
|
1895
|
+
this.editdlgObj.setProperties({
|
|
1896
|
+
height: 'initial', width: '290px', content: editContent, header: editHeader,
|
|
1897
|
+
buttons: [{
|
|
1898
|
+
click: this.applyProperties.bind(this, args),
|
|
1899
|
+
buttonModel: { content: update, cssClass: 'e-flat e-size-update' + this.parent.getCssClass(true), isPrimary: true }
|
|
1900
|
+
},
|
|
1901
|
+
{
|
|
1902
|
+
click: function (e) {
|
|
1903
|
+
_this.cancelDialog(e);
|
|
1904
|
+
},
|
|
1905
|
+
buttonModel: { cssClass: 'e-flat e-cancel' + this.parent.getCssClass(true), content: cancel }
|
|
1906
|
+
}],
|
|
1907
|
+
cssClass: this.editdlgObj.cssClass + ' e-rte-edit-table-prop-dialog'
|
|
1908
|
+
});
|
|
1909
|
+
this.editdlgObj.element.style.maxHeight = 'none';
|
|
1910
|
+
this.editdlgObj.content.querySelector('input').focus();
|
|
1911
|
+
this.hideTableQuickToolbar();
|
|
1912
|
+
};
|
|
1913
|
+
Table.prototype.insertTableDialog = function (args) {
|
|
1914
|
+
var proxy = (this.self) ? this.self : this;
|
|
1915
|
+
if (proxy.popupObj) {
|
|
1916
|
+
proxy.popupObj.hide();
|
|
1917
|
+
}
|
|
1918
|
+
proxy.createDialog(args);
|
|
1919
|
+
var dlgContent = proxy.tableCellDlgContent();
|
|
1920
|
+
var insert = proxy.l10n.getConstant('dialogInsert');
|
|
1921
|
+
var cancel = proxy.l10n.getConstant('dialogCancel');
|
|
1922
|
+
if (ej2_base_2.isNullOrUndefined(proxy.editdlgObj)) {
|
|
1923
|
+
return;
|
|
1924
|
+
}
|
|
1925
|
+
proxy.editdlgObj.setProperties({
|
|
1926
|
+
height: 'initial', width: '290px', content: dlgContent,
|
|
1927
|
+
buttons: [{
|
|
1928
|
+
click: proxy.customTable.bind(this, args),
|
|
1929
|
+
buttonModel: { content: insert, cssClass: 'e-flat e-insert-table' + ' ' + proxy.parent.cssClass, isPrimary: true }
|
|
1930
|
+
},
|
|
1931
|
+
{
|
|
1932
|
+
click: function (e) {
|
|
1933
|
+
proxy.cancelDialog(e);
|
|
1934
|
+
},
|
|
1935
|
+
buttonModel: { cssClass: 'e-flat e-cancel' + ' ' + proxy.parent.cssClass, content: cancel }
|
|
1936
|
+
}]
|
|
1937
|
+
});
|
|
1938
|
+
if (!ej2_base_1.isNullOrUndefined(proxy.parent.cssClass)) {
|
|
1939
|
+
proxy.editdlgObj.setProperties({ cssClass: proxy.parent.cssClass });
|
|
1940
|
+
}
|
|
1941
|
+
proxy.editdlgObj.element.style.maxHeight = 'none';
|
|
1942
|
+
proxy.editdlgObj.content.querySelector('input').focus();
|
|
1943
|
+
};
|
|
1944
|
+
Table.prototype.tableCellDlgContent = function () {
|
|
1945
|
+
var tableColumn = this.l10n.getConstant('columns');
|
|
1946
|
+
var tableRow = this.l10n.getConstant('rows');
|
|
1947
|
+
var tableWrap = this.parent.createElement('div', { className: 'e-cell-wrap' + this.parent.getCssClass(true) });
|
|
1948
|
+
var content = '<div class="e-rte-field' + this.parent.getCssClass(true) + '"><input type="text" '
|
|
1949
|
+
+ ' data-role ="none" id="tableColumn" class="e-table-column' + this.parent.getCssClass(true) + '"/></div>'
|
|
1950
|
+
+ '<div class="e-rte-field' + this.parent.getCssClass(true) + '"><input type="text" data-role ="none" id="tableRow" class="e-table-row' + this.parent.getCssClass(true) + '" /></div>';
|
|
1951
|
+
var contentElem = util_1.parseHtml(content);
|
|
1952
|
+
tableWrap.appendChild(contentElem);
|
|
1953
|
+
this.columnTextBox = new ej2_inputs_1.NumericTextBox({
|
|
1954
|
+
format: 'n0',
|
|
1955
|
+
min: 1,
|
|
1956
|
+
value: 3,
|
|
1957
|
+
placeholder: tableColumn,
|
|
1958
|
+
floatLabelType: 'Auto',
|
|
1959
|
+
max: 50,
|
|
1960
|
+
enableRtl: this.parent.enableRtl, locale: this.parent.locale,
|
|
1961
|
+
cssClass: this.parent.getCssClass()
|
|
1962
|
+
});
|
|
1963
|
+
this.columnTextBox.isStringTemplate = true;
|
|
1964
|
+
this.columnTextBox.appendTo(tableWrap.querySelector('#tableColumn'));
|
|
1965
|
+
this.rowTextBox = new ej2_inputs_1.NumericTextBox({
|
|
1966
|
+
format: 'n0',
|
|
1967
|
+
min: 1,
|
|
1968
|
+
value: 3,
|
|
1969
|
+
placeholder: tableRow,
|
|
1970
|
+
floatLabelType: 'Auto',
|
|
1971
|
+
max: 1000,
|
|
1972
|
+
enableRtl: this.parent.enableRtl, locale: this.parent.locale,
|
|
1973
|
+
cssClass: this.parent.getCssClass()
|
|
1974
|
+
});
|
|
1975
|
+
this.rowTextBox.isStringTemplate = true;
|
|
1976
|
+
this.rowTextBox.appendTo(tableWrap.querySelector('#tableRow'));
|
|
1977
|
+
return tableWrap;
|
|
1978
|
+
};
|
|
1979
|
+
Table.prototype.clearDialogObj = function () {
|
|
1980
|
+
if (this.editdlgObj) {
|
|
1981
|
+
this.editdlgObj.destroy();
|
|
1982
|
+
ej2_base_1.detach(this.editdlgObj.element);
|
|
1983
|
+
this.editdlgObj = null;
|
|
1984
|
+
}
|
|
1985
|
+
};
|
|
1986
|
+
Table.prototype.createDialog = function (args) {
|
|
1987
|
+
var _this = this;
|
|
1988
|
+
if (this.editdlgObj) {
|
|
1989
|
+
this.editdlgObj.hide({ returnValue: true });
|
|
1990
|
+
return;
|
|
1991
|
+
}
|
|
1992
|
+
var tableDialog = this.parent.createElement('div', {
|
|
1993
|
+
className: 'e-rte-edit-table' + this.parent.getCssClass(true), id: this.rteID + '_tabledialog'
|
|
1994
|
+
});
|
|
1995
|
+
this.parent.rootContainer.appendChild(tableDialog);
|
|
1996
|
+
var insert = this.l10n.getConstant('dialogInsert');
|
|
1997
|
+
var cancel = this.l10n.getConstant('dialogCancel');
|
|
1998
|
+
var header = this.l10n.getConstant('tabledialogHeader');
|
|
1999
|
+
var dialogModel = {
|
|
2000
|
+
header: header,
|
|
2001
|
+
cssClass: classes.CLS_RTE_ELEMENTS + this.parent.getCssClass(true),
|
|
2002
|
+
enableRtl: this.parent.enableRtl,
|
|
2003
|
+
locale: this.parent.locale,
|
|
2004
|
+
showCloseIcon: true, closeOnEscape: true, width: (ej2_base_1.Browser.isDevice) ? '290px' : '340px', height: 'initial',
|
|
2005
|
+
position: { X: 'center', Y: (ej2_base_1.Browser.isDevice) ? 'center' : 'top' },
|
|
2006
|
+
isModal: ej2_base_1.Browser.isDevice,
|
|
2007
|
+
buttons: [{
|
|
2008
|
+
buttonModel: { content: insert, cssClass: 'e-flat e-insert-table' + this.parent.getCssClass(true), isPrimary: true }
|
|
2009
|
+
},
|
|
2010
|
+
{
|
|
2011
|
+
click: function (e) {
|
|
2012
|
+
_this.cancelDialog(e);
|
|
2013
|
+
},
|
|
2014
|
+
buttonModel: { cssClass: 'e-flat e-cancel' + this.parent.getCssClass(true), content: cancel }
|
|
2015
|
+
}],
|
|
2016
|
+
target: (ej2_base_1.Browser.isDevice) ? document.body : this.parent.element,
|
|
2017
|
+
animationSettings: { effect: 'None' },
|
|
2018
|
+
close: function (event) {
|
|
2019
|
+
_this.parent.isBlur = false;
|
|
2020
|
+
_this.editdlgObj.destroy();
|
|
2021
|
+
ej2_base_1.detach(_this.editdlgObj.element);
|
|
2022
|
+
_this.dialogRenderObj.close(event);
|
|
2023
|
+
_this.editdlgObj = null;
|
|
2024
|
+
}
|
|
2025
|
+
};
|
|
2026
|
+
this.editdlgObj = this.dialogRenderObj.render(dialogModel);
|
|
2027
|
+
this.editdlgObj.appendTo(tableDialog);
|
|
2028
|
+
if (this.quickToolObj && this.quickToolObj.inlineQTBar && document.body.contains(this.quickToolObj.inlineQTBar.element)) {
|
|
2029
|
+
this.quickToolObj.inlineQTBar.hidePopup();
|
|
2030
|
+
}
|
|
2031
|
+
if (this.quickToolObj && this.quickToolObj.textQTBar &&
|
|
2032
|
+
this.parent.element.ownerDocument.body.contains(this.quickToolObj.textQTBar.element)) {
|
|
2033
|
+
this.quickToolObj.textQTBar.hidePopup();
|
|
2034
|
+
}
|
|
2035
|
+
};
|
|
2036
|
+
Table.prototype.customTable = function (args, e) {
|
|
2037
|
+
var proxy = (this.self) ? this.self : this;
|
|
2038
|
+
if (proxy && proxy.rowTextBox && proxy.rowTextBox.value && proxy.columnTextBox && proxy.columnTextBox.value) {
|
|
2039
|
+
var argument = ((ej2_base_1.Browser.isDevice || (!ej2_base_2.isNullOrUndefined(args.args)
|
|
2040
|
+
&& !ej2_base_2.isNullOrUndefined(args.args.originalEvent) &&
|
|
2041
|
+
args.args.originalEvent.action === 'insert-table')
|
|
2042
|
+
|| proxy.parent.inlineMode.enable ||
|
|
2043
|
+
((!ej2_base_2.isNullOrUndefined(proxy.parent.quickToolbarSettings.text)) && !(args instanceof PointerEvent))) ? args :
|
|
2044
|
+
this);
|
|
2045
|
+
proxy.tableInsert(proxy.rowTextBox.value, proxy.columnTextBox.value, e, argument);
|
|
2046
|
+
}
|
|
2047
|
+
};
|
|
2048
|
+
Table.prototype.cancelDialog = function (e) {
|
|
2049
|
+
this.parent.isBlur = false;
|
|
2050
|
+
this.editdlgObj.hide({ returnValue: true });
|
|
2051
|
+
};
|
|
2052
|
+
Table.prototype.applyProperties = function (args, e) {
|
|
2053
|
+
var dialogEle = this.editdlgObj.element;
|
|
2054
|
+
if (dialogEle && args && args.selectNode.length > 0 && args.selectNode[0]) {
|
|
2055
|
+
var selectedElement = (args.selectNode[0] && args.selectNode[0].nodeType === 3 ?
|
|
2056
|
+
args.selectNode[0].parentNode : args.selectNode[0]);
|
|
2057
|
+
var table = selectedElement ? ej2_base_1.closest(selectedElement, 'table') : null;
|
|
2058
|
+
if (table) {
|
|
2059
|
+
table.style.width = dialogEle.querySelector('.e-table-width') ? dialogEle.querySelector('.e-table-width').value + 'px'
|
|
2060
|
+
: table.style.width;
|
|
2061
|
+
if (dialogEle.querySelector('.e-cell-padding') && dialogEle.querySelector('.e-cell-padding').value !== '') {
|
|
2062
|
+
var tdElm = table.querySelectorAll('td');
|
|
2063
|
+
for (var i = 0; i < tdElm.length; i++) {
|
|
2064
|
+
var padVal = '';
|
|
2065
|
+
if (tdElm[i].style.padding === '') {
|
|
2066
|
+
padVal = tdElm[i].getAttribute('style') + ' padding:' +
|
|
2067
|
+
dialogEle.querySelector('.e-cell-padding').value + 'px;';
|
|
2068
|
+
}
|
|
2069
|
+
else {
|
|
2070
|
+
tdElm[i].style.padding = dialogEle.querySelector('.e-cell-padding').value + 'px';
|
|
2071
|
+
padVal = tdElm[i].getAttribute('style');
|
|
2072
|
+
}
|
|
2073
|
+
tdElm[i].style.cssText = padVal;
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
table.cellSpacing = dialogEle.querySelector('.e-cell-spacing') ? dialogEle.querySelector('.e-cell-spacing').value
|
|
2077
|
+
: table.cellSpacing;
|
|
2078
|
+
if (!ej2_base_1.isNullOrUndefined(table.cellSpacing) && table.cellSpacing !== '0') {
|
|
2079
|
+
ej2_base_2.addClass([table], classes.CLS_TABLE_BORDER);
|
|
2080
|
+
}
|
|
2081
|
+
else {
|
|
2082
|
+
util_2.removeClassWithAttr([table], classes.CLS_TABLE_BORDER);
|
|
2083
|
+
}
|
|
2084
|
+
this.parent.formatter.saveData();
|
|
2085
|
+
this.editdlgObj.hide({ returnValue: true });
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
};
|
|
2089
|
+
Table.prototype.tableDlgContent = function (e) {
|
|
2090
|
+
var selectNode = e.selectParent[0];
|
|
2091
|
+
var tableWidth = this.l10n.getConstant('tableWidth');
|
|
2092
|
+
var cellPadding = this.l10n.getConstant('cellpadding');
|
|
2093
|
+
var cellSpacing = this.l10n.getConstant('cellspacing');
|
|
2094
|
+
var tableWrap = this.parent.createElement('div', { className: 'e-table-sizewrap' + this.parent.getCssClass(true) });
|
|
2095
|
+
var widthVal = ej2_base_1.closest(selectNode, 'table').getClientRects()[0].width;
|
|
2096
|
+
var padVal = ej2_base_1.closest(selectNode, 'td').style.padding;
|
|
2097
|
+
var brdSpcVal = ej2_base_1.closest(selectNode, 'table').getAttribute('cellspacing');
|
|
2098
|
+
var content = '<div class="e-rte-field' + this.parent.getCssClass(true) + '"><input type="text" data-role ="none" id="tableWidth" class="e-table-width' + this.parent.getCssClass(true) + '" '
|
|
2099
|
+
+ ' /></div>' + '<div class="e-rte-field' + this.parent.getCssClass(true) + '"><input type="text" data-role ="none" id="cellPadding" class="e-cell-padding' + this.parent.getCssClass(true) + '" />'
|
|
2100
|
+
+ ' </div><div class="e-rte-field' + this.parent.getCssClass(true) + '"><input type="text" data-role ="none" id="cellSpacing" class="e-cell-spacing' + this.parent.getCssClass(true) + '" /></div>';
|
|
2101
|
+
var contentElem = util_1.parseHtml(content);
|
|
2102
|
+
tableWrap.appendChild(contentElem);
|
|
2103
|
+
this.tableWidthNum = new ej2_inputs_1.NumericTextBox({
|
|
2104
|
+
format: 'n0',
|
|
2105
|
+
min: 0,
|
|
2106
|
+
value: widthVal,
|
|
2107
|
+
placeholder: tableWidth,
|
|
2108
|
+
floatLabelType: 'Auto',
|
|
2109
|
+
enableRtl: this.parent.enableRtl, locale: this.parent.locale
|
|
2110
|
+
});
|
|
2111
|
+
this.tableWidthNum.isStringTemplate = true;
|
|
2112
|
+
this.tableWidthNum.appendTo(tableWrap.querySelector('#tableWidth'));
|
|
2113
|
+
this.tableCellPadding = new ej2_inputs_1.NumericTextBox({
|
|
2114
|
+
format: 'n0',
|
|
2115
|
+
min: 0,
|
|
2116
|
+
value: padVal !== '' ? parseInt(padVal, null) : 0,
|
|
2117
|
+
placeholder: cellPadding,
|
|
2118
|
+
floatLabelType: 'Auto',
|
|
2119
|
+
enableRtl: this.parent.enableRtl, locale: this.parent.locale
|
|
2120
|
+
});
|
|
2121
|
+
this.tableCellPadding.isStringTemplate = true;
|
|
2122
|
+
this.tableCellPadding.appendTo(tableWrap.querySelector('#cellPadding'));
|
|
2123
|
+
this.tableCellSpacing = new ej2_inputs_1.NumericTextBox({
|
|
2124
|
+
format: 'n0',
|
|
2125
|
+
min: 0,
|
|
2126
|
+
value: brdSpcVal !== '' && !ej2_base_1.isNullOrUndefined(brdSpcVal) ? parseInt(brdSpcVal, null) : 0,
|
|
2127
|
+
placeholder: cellSpacing,
|
|
2128
|
+
floatLabelType: 'Auto',
|
|
2129
|
+
enableRtl: this.parent.enableRtl, locale: this.parent.locale
|
|
2130
|
+
});
|
|
2131
|
+
this.tableCellSpacing.isStringTemplate = true;
|
|
2132
|
+
this.tableCellSpacing.appendTo(tableWrap.querySelector('#cellSpacing'));
|
|
2133
|
+
return tableWrap;
|
|
2134
|
+
};
|
|
2135
|
+
Table.prototype.destroy = function () {
|
|
2136
|
+
if (this.isDestroyed) {
|
|
2137
|
+
return;
|
|
2138
|
+
}
|
|
2139
|
+
if (this.resizeIconPositionTime) {
|
|
2140
|
+
clearTimeout(this.resizeIconPositionTime);
|
|
2141
|
+
this.resizeIconPositionTime = null;
|
|
2142
|
+
}
|
|
2143
|
+
this.removeEventListener();
|
|
2144
|
+
ej2_base_2.EventHandler.remove(this.parent.contentModule.getDocument(), 'selectionchange', this.tableCellsKeyboardSelection);
|
|
2145
|
+
if (this.curTable) {
|
|
2146
|
+
ej2_base_2.EventHandler.remove(this.curTable, 'mouseleave', this.tableMouseLeave);
|
|
2147
|
+
}
|
|
2148
|
+
if (this.tableCellSpacing && !this.tableCellSpacing.isDestroyed) {
|
|
2149
|
+
this.tableCellSpacing.destroy();
|
|
2150
|
+
this.tableCellSpacing = null;
|
|
2151
|
+
}
|
|
2152
|
+
if (this.tableCellPadding && !this.tableCellPadding.isDestroyed) {
|
|
2153
|
+
this.tableCellPadding.destroy();
|
|
2154
|
+
this.tableCellPadding = null;
|
|
2155
|
+
}
|
|
2156
|
+
if (this.tableWidthNum && !this.tableWidthNum.isDestroyed) {
|
|
2157
|
+
this.tableWidthNum.destroy();
|
|
2158
|
+
this.tableWidthNum = null;
|
|
2159
|
+
}
|
|
2160
|
+
if (this.rowTextBox && !this.rowTextBox.isDestroyed) {
|
|
2161
|
+
this.rowTextBox.destroy();
|
|
2162
|
+
this.rowTextBox = null;
|
|
2163
|
+
}
|
|
2164
|
+
if (this.columnTextBox && !this.columnTextBox.isDestroyed) {
|
|
2165
|
+
this.columnTextBox.destroy();
|
|
2166
|
+
this.columnTextBox = null;
|
|
2167
|
+
}
|
|
2168
|
+
if (this.createTableButton && !this.createTableButton.isDestroyed) {
|
|
2169
|
+
this.createTableButton.destroy();
|
|
2170
|
+
this.createTableButton = null;
|
|
2171
|
+
}
|
|
2172
|
+
this.createTablePopupBoundFn = null;
|
|
2173
|
+
this.isDestroyed = true;
|
|
2174
|
+
};
|
|
2175
|
+
Table.prototype.getModuleName = function () {
|
|
2176
|
+
return 'table';
|
|
2177
|
+
};
|
|
2178
|
+
Table.prototype.afterKeyDown = function () {
|
|
2179
|
+
var _this = this;
|
|
2180
|
+
if (this.curTable) {
|
|
2181
|
+
this.resizeIconPositionTime = setTimeout(function () {
|
|
2182
|
+
_this.updateResizeIconPosition();
|
|
2183
|
+
}, 1);
|
|
2184
|
+
}
|
|
2185
|
+
};
|
|
2186
|
+
Table.prototype.updateResizeIconPosition = function () {
|
|
2187
|
+
var tableReBox = this.parent.contentModule.getEditPanel().querySelector('.e-table-box');
|
|
2188
|
+
if (!ej2_base_1.isNullOrUndefined(tableReBox)) {
|
|
2189
|
+
var tablePosition = this.calcPos(this.curTable);
|
|
2190
|
+
tableReBox.style.cssText = 'top: ' + (tablePosition.top + parseInt(getComputedStyle(this.curTable).height, 10) - 4) +
|
|
2191
|
+
'px; left:' + (tablePosition.left + parseInt(getComputedStyle(this.curTable).width, 10) - 4) + 'px;';
|
|
2192
|
+
}
|
|
2193
|
+
};
|
|
2194
|
+
Table.prototype.createTablePopupKeyDown = function (e) {
|
|
2195
|
+
if (e.key === 'Escape') {
|
|
2196
|
+
var popupRootElem = e.target.closest('.e-rte-table-popup');
|
|
2197
|
+
var popup = ej2_base_1.getComponent(popupRootElem, 'popup');
|
|
2198
|
+
var tableToolbarButton = popup.relateTo;
|
|
2199
|
+
popup.hide();
|
|
2200
|
+
tableToolbarButton.focus({ preventScroll: true });
|
|
2201
|
+
}
|
|
2202
|
+
};
|
|
2203
|
+
return Table;
|
|
2204
|
+
}());
|
|
2205
|
+
exports.Table = Table;
|
|
2206
|
+
});
|