@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,2494 @@
|
|
|
1
|
+
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-buttons", "@syncfusion/ej2-inputs", "@syncfusion/ej2-popups", "../../common/config", "../../common/util", "../base/classes", "../base/constant", "../base/enum", "../base/util"], function (require, exports, ej2_base_1, ej2_buttons_1, ej2_inputs_1, ej2_popups_1, config_1, util_1, classes, events, enum_1, util_2) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
var Image = (function () {
|
|
5
|
+
function Image(parent, serviceLocator) {
|
|
6
|
+
this.isImgUploaded = false;
|
|
7
|
+
this.isAllowedTypes = true;
|
|
8
|
+
this.pageX = null;
|
|
9
|
+
this.pageY = null;
|
|
10
|
+
this.deletedImg = [];
|
|
11
|
+
this.parent = parent;
|
|
12
|
+
this.rteID = parent.element.id;
|
|
13
|
+
this.i10n = serviceLocator.getService('rteLocale');
|
|
14
|
+
this.rendererFactory = serviceLocator.getService('rendererFactory');
|
|
15
|
+
this.dialogRenderObj = serviceLocator.getService('dialogRenderObject');
|
|
16
|
+
this.addEventListener();
|
|
17
|
+
this.drop = this.dragDrop.bind(this);
|
|
18
|
+
this.drag = this.dragOver.bind(this);
|
|
19
|
+
this.enter = this.dragEnter.bind(this);
|
|
20
|
+
this.start = this.dragStart.bind(this);
|
|
21
|
+
this.docClick = this.onDocumentClick.bind(this);
|
|
22
|
+
this.isDestroyed = false;
|
|
23
|
+
}
|
|
24
|
+
Image.prototype.addEventListener = function () {
|
|
25
|
+
if (this.parent.isDestroyed) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this.parent.on(events.keyDown, this.onKeyDown, this);
|
|
29
|
+
this.parent.on(events.keyUp, this.onKeyUp, this);
|
|
30
|
+
this.parent.on(events.insertImage, this.insertImage, this);
|
|
31
|
+
this.parent.on(events.showImageDialog, this.showDialog, this);
|
|
32
|
+
this.parent.on(events.closeImageDialog, this.closeDialog, this);
|
|
33
|
+
this.parent.on(events.windowResize, this.onWindowResize, this);
|
|
34
|
+
this.parent.on(events.insertCompleted, this.showImageQuickToolbar, this);
|
|
35
|
+
this.parent.on(events.clearDialogObj, this.clearDialogObj, this);
|
|
36
|
+
this.parent.on(events.imageToolbarAction, this.onToolbarAction, this);
|
|
37
|
+
this.parent.on(events.imageCaption, this.caption, this);
|
|
38
|
+
this.parent.on(events.imageDelete, this.deleteImg, this);
|
|
39
|
+
this.parent.on(events.imageLink, this.insertImgLink, this);
|
|
40
|
+
this.parent.on(events.imageAlt, this.insertAltText, this);
|
|
41
|
+
this.parent.on(events.editAreaClick, this.editAreaClickHandler, this);
|
|
42
|
+
this.parent.on(events.iframeMouseDown, this.onIframeMouseDown, this);
|
|
43
|
+
this.parent.on(events.imageSize, this.imageSize, this);
|
|
44
|
+
this.parent.on(events.dropDownSelect, this.alignmentSelect, this);
|
|
45
|
+
this.parent.on(events.initialEnd, this.afterRender, this);
|
|
46
|
+
this.parent.on(events.dynamicModule, this.afterRender, this);
|
|
47
|
+
this.parent.on(events.paste, this.imagePaste, this);
|
|
48
|
+
this.parent.on(events.bindCssClass, this.setCssClass, this);
|
|
49
|
+
this.parent.on(events.destroy, this.destroy, this);
|
|
50
|
+
};
|
|
51
|
+
Image.prototype.removeEventListener = function () {
|
|
52
|
+
if (this.parent.isDestroyed) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.parent.off(events.keyDown, this.onKeyDown);
|
|
56
|
+
this.parent.off(events.keyUp, this.onKeyUp);
|
|
57
|
+
this.parent.off(events.windowResize, this.onWindowResize);
|
|
58
|
+
this.parent.off(events.insertImage, this.insertImage);
|
|
59
|
+
this.parent.off(events.showImageDialog, this.showDialog);
|
|
60
|
+
this.parent.off(events.closeImageDialog, this.closeDialog);
|
|
61
|
+
this.parent.off(events.insertCompleted, this.showImageQuickToolbar);
|
|
62
|
+
this.parent.off(events.clearDialogObj, this.clearDialogObj);
|
|
63
|
+
this.parent.off(events.imageCaption, this.caption);
|
|
64
|
+
this.parent.off(events.imageToolbarAction, this.onToolbarAction);
|
|
65
|
+
this.parent.off(events.imageDelete, this.deleteImg);
|
|
66
|
+
this.parent.off(events.imageLink, this.insertImgLink);
|
|
67
|
+
this.parent.off(events.imageAlt, this.insertAltText);
|
|
68
|
+
this.parent.off(events.editAreaClick, this.editAreaClickHandler);
|
|
69
|
+
this.parent.off(events.iframeMouseDown, this.onIframeMouseDown);
|
|
70
|
+
this.parent.off(events.imageSize, this.imageSize);
|
|
71
|
+
this.parent.off(events.dropDownSelect, this.alignmentSelect);
|
|
72
|
+
this.parent.off(events.initialEnd, this.afterRender);
|
|
73
|
+
this.parent.off(events.dynamicModule, this.afterRender);
|
|
74
|
+
this.parent.off(events.paste, this.imagePaste);
|
|
75
|
+
this.parent.off(events.bindCssClass, this.setCssClass);
|
|
76
|
+
this.parent.off(events.destroy, this.destroy);
|
|
77
|
+
var dropElement = this.parent.iframeSettings.enable ? this.parent.inputElement.ownerDocument
|
|
78
|
+
: this.parent.inputElement;
|
|
79
|
+
dropElement.removeEventListener('drop', this.drop, true);
|
|
80
|
+
dropElement.removeEventListener('dragstart', this.drag, true);
|
|
81
|
+
dropElement.removeEventListener('dragenter', this.enter, true);
|
|
82
|
+
dropElement.removeEventListener('dragover', this.start, true);
|
|
83
|
+
this.drop = null;
|
|
84
|
+
this.drag = null;
|
|
85
|
+
this.enter = null;
|
|
86
|
+
this.start = null;
|
|
87
|
+
if (!ej2_base_1.isNullOrUndefined(this.contentModule)) {
|
|
88
|
+
ej2_base_1.EventHandler.remove(this.contentModule.getEditPanel(), ej2_base_1.Browser.touchEndEvent, this.imageClick);
|
|
89
|
+
this.parent.formatter.editorManager.observer.off(events.checkUndo, this.undoStack);
|
|
90
|
+
if (this.parent.insertImageSettings.resize) {
|
|
91
|
+
ej2_base_1.EventHandler.remove(this.parent.contentModule.getEditPanel(), ej2_base_1.Browser.touchStartEvent, this.resizeStart);
|
|
92
|
+
this.parent.element.ownerDocument.removeEventListener('mousedown', this.docClick);
|
|
93
|
+
this.docClick = null;
|
|
94
|
+
ej2_base_1.EventHandler.remove(this.contentModule.getEditPanel(), 'cut', this.onCutHandler);
|
|
95
|
+
ej2_base_1.EventHandler.remove(this.contentModule.getDocument(), ej2_base_1.Browser.touchMoveEvent, this.resizing);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
Image.prototype.updateCss = function (currentObj, e) {
|
|
100
|
+
if (currentObj && e.cssClass) {
|
|
101
|
+
if (ej2_base_1.isNullOrUndefined(e.oldCssClass)) {
|
|
102
|
+
currentObj.setProperties({ cssClass: (currentObj.cssClass + ' ' + e.cssClass).trim() });
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
currentObj.setProperties({ cssClass: (currentObj.cssClass.replace(e.oldCssClass, '').trim() + ' ' + e.cssClass).trim() });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
Image.prototype.setCssClass = function (e) {
|
|
110
|
+
if (this.popupObj && e.cssClass) {
|
|
111
|
+
if (ej2_base_1.isNullOrUndefined(e.oldCssClass)) {
|
|
112
|
+
ej2_base_1.addClass([this.popupObj.element], e.cssClass);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
ej2_base_1.removeClass([this.popupObj.element], e.oldCssClass);
|
|
116
|
+
ej2_base_1.addClass([this.popupObj.element], e.cssClass);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
this.updateCss(this.checkBoxObj, e);
|
|
120
|
+
this.updateCss(this.widthNum, e);
|
|
121
|
+
this.updateCss(this.heightNum, e);
|
|
122
|
+
this.updateCss(this.uploadObj, e);
|
|
123
|
+
this.updateCss(this.dialogObj, e);
|
|
124
|
+
};
|
|
125
|
+
Image.prototype.onIframeMouseDown = function (e) {
|
|
126
|
+
var target = e.target;
|
|
127
|
+
if (this.dialogObj) {
|
|
128
|
+
this.dialogObj.hide({ returnValue: true });
|
|
129
|
+
}
|
|
130
|
+
if (!(!ej2_base_1.isNullOrUndefined(this.parent.currentTarget) && this.parent.currentTarget.nodeName === 'IMG') && (this.imgEle && this.imgResizeDiv && this.contentModule.getEditPanel().contains(this.imgResizeDiv))) {
|
|
131
|
+
this.cancelResizeAction();
|
|
132
|
+
}
|
|
133
|
+
if (this.contentModule.getEditPanel().querySelector('.e-img-resize') && (this.parent.currentTarget.nodeName === 'IMG')) {
|
|
134
|
+
if (!ej2_base_1.isNullOrUndefined(this.prevSelectedImgEle) && this.prevSelectedImgEle !== target) {
|
|
135
|
+
this.prevSelectedImgEle.style.outline = '';
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
Image.prototype.afterRender = function () {
|
|
140
|
+
this.contentModule = this.rendererFactory.getRenderer(enum_1.RenderType.Content);
|
|
141
|
+
ej2_base_1.EventHandler.add(this.contentModule.getEditPanel(), ej2_base_1.Browser.touchEndEvent, this.imageClick, this);
|
|
142
|
+
if (this.parent.insertImageSettings.resize) {
|
|
143
|
+
ej2_base_1.EventHandler.add(this.parent.contentModule.getEditPanel(), ej2_base_1.Browser.touchStartEvent, this.resizeStart, this);
|
|
144
|
+
this.parent.element.ownerDocument.addEventListener('mousedown', this.docClick);
|
|
145
|
+
ej2_base_1.EventHandler.add(this.contentModule.getEditPanel(), 'cut', this.onCutHandler, this);
|
|
146
|
+
}
|
|
147
|
+
var dropElement = this.parent.iframeSettings.enable ? this.parent.inputElement.ownerDocument :
|
|
148
|
+
this.parent.inputElement;
|
|
149
|
+
dropElement.addEventListener('drop', this.drop, true);
|
|
150
|
+
dropElement.addEventListener('dragstart', this.drag, true);
|
|
151
|
+
dropElement.addEventListener('dragenter', this.enter, true);
|
|
152
|
+
dropElement.addEventListener('dragover', this.start, true);
|
|
153
|
+
};
|
|
154
|
+
Image.prototype.undoStack = function (args) {
|
|
155
|
+
if ((args.subCommand.toLowerCase() === 'undo' || args.subCommand.toLowerCase() === 'redo') && this.parent.editorMode === 'HTML') {
|
|
156
|
+
for (var i = 0; i < this.parent.formatter.getUndoRedoStack().length; i++) {
|
|
157
|
+
var temp = this.parent.createElement('div');
|
|
158
|
+
var contentElem = this.parent.formatter.getUndoRedoStack()[i].text;
|
|
159
|
+
temp.appendChild(contentElem.cloneNode(true));
|
|
160
|
+
var img = temp.querySelectorAll('img');
|
|
161
|
+
if (temp.querySelector('.e-img-resize') && img.length > 0) {
|
|
162
|
+
for (var j = 0; j < img.length; j++) {
|
|
163
|
+
img[j].style.outline = '';
|
|
164
|
+
}
|
|
165
|
+
ej2_base_1.detach(temp.querySelector('.e-img-resize'));
|
|
166
|
+
var clonedElement = temp.cloneNode(true);
|
|
167
|
+
var fragment = document.createDocumentFragment();
|
|
168
|
+
while (clonedElement.firstChild) {
|
|
169
|
+
fragment.appendChild(clonedElement.firstChild);
|
|
170
|
+
}
|
|
171
|
+
this.parent.formatter.getUndoRedoStack()[i].text = fragment;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
Image.prototype.resizeEnd = function (e) {
|
|
177
|
+
this.resizeBtnInit();
|
|
178
|
+
if (this.imgEle.parentElement) {
|
|
179
|
+
this.imgEle.parentElement.style.cursor = 'auto';
|
|
180
|
+
}
|
|
181
|
+
if (ej2_base_1.Browser.isDevice) {
|
|
182
|
+
ej2_base_1.removeClass([e.target.parentElement], 'e-mob-span');
|
|
183
|
+
}
|
|
184
|
+
var args = { event: e, requestType: 'images' };
|
|
185
|
+
this.parent.trigger(events.resizeStop, args);
|
|
186
|
+
this.parent.formatter.editorManager.observer.on(events.checkUndo, this.undoStack, this);
|
|
187
|
+
this.parent.formatter.saveData();
|
|
188
|
+
ej2_base_1.EventHandler.remove(this.contentModule.getDocument(), ej2_base_1.Browser.touchMoveEvent, this.resizing);
|
|
189
|
+
ej2_base_1.EventHandler.remove(this.contentModule.getDocument(), ej2_base_1.Browser.touchEndEvent, this.resizeEnd);
|
|
190
|
+
};
|
|
191
|
+
Image.prototype.resizeStart = function (e, ele) {
|
|
192
|
+
var _this = this;
|
|
193
|
+
if (this.parent.readonly) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
var target = ele ? ele : e.target;
|
|
197
|
+
this.prevSelectedImgEle = this.imgEle;
|
|
198
|
+
if (target.tagName === 'IMG') {
|
|
199
|
+
this.parent.preventDefaultResize(e);
|
|
200
|
+
var img = target;
|
|
201
|
+
if (this.imgResizeDiv && this.contentModule.getEditPanel().contains(this.imgResizeDiv)) {
|
|
202
|
+
ej2_base_1.detach(this.imgResizeDiv);
|
|
203
|
+
}
|
|
204
|
+
this.imageResize(img);
|
|
205
|
+
}
|
|
206
|
+
if (target.classList.contains('e-rte-imageboxmark')) {
|
|
207
|
+
if (this.parent.formatter.getUndoRedoStack().length === 0) {
|
|
208
|
+
this.parent.formatter.saveData();
|
|
209
|
+
}
|
|
210
|
+
this.pageX = this.getPointX(e);
|
|
211
|
+
this.pageY = this.getPointY(e);
|
|
212
|
+
e.preventDefault();
|
|
213
|
+
e.stopImmediatePropagation();
|
|
214
|
+
this.resizeBtnInit();
|
|
215
|
+
if (this.quickToolObj) {
|
|
216
|
+
this.quickToolObj.imageQTBar.hidePopup();
|
|
217
|
+
}
|
|
218
|
+
var handlers = ['topLeft', 'topRight', 'botLeft', 'botRight'];
|
|
219
|
+
for (var i = 0; i < handlers.length; i++) {
|
|
220
|
+
var handler = handlers[i];
|
|
221
|
+
if (target.classList.contains('e-rte-' + handler)) {
|
|
222
|
+
this.resizeBtnStat[handler] = true;
|
|
223
|
+
this.currentResizeHandler = handler;
|
|
224
|
+
this.aspectRatio = this.findAspectRatio(this.imgEle);
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (ej2_base_1.Browser.isDevice && this.contentModule.getEditPanel().contains(this.imgResizeDiv) &&
|
|
229
|
+
!this.imgResizeDiv.classList.contains('e-mob-span')) {
|
|
230
|
+
ej2_base_1.addClass([this.imgResizeDiv], 'e-mob-span');
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
var args = { event: e, requestType: 'images' };
|
|
234
|
+
this.parent.trigger(events.resizeStart, args, function (resizeStartArgs) {
|
|
235
|
+
if (resizeStartArgs.cancel) {
|
|
236
|
+
_this.cancelResizeAction();
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
ej2_base_1.EventHandler.add(this.contentModule.getDocument(), ej2_base_1.Browser.touchMoveEvent, this.resizing, this);
|
|
241
|
+
ej2_base_1.EventHandler.add(this.contentModule.getDocument(), ej2_base_1.Browser.touchEndEvent, this.resizeEnd, this);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
Image.prototype.imageClick = function (e) {
|
|
245
|
+
if (ej2_base_1.Browser.isDevice) {
|
|
246
|
+
if ((e.target.tagName === 'IMG' &&
|
|
247
|
+
e.target.parentElement.tagName === 'A') ||
|
|
248
|
+
(e.target.tagName === 'IMG')) {
|
|
249
|
+
this.contentModule.getEditPanel().setAttribute('contenteditable', 'false');
|
|
250
|
+
e.target.focus();
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
if (!this.parent.readonly) {
|
|
254
|
+
this.contentModule.getEditPanel().setAttribute('contenteditable', 'true');
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (e.target.tagName === 'IMG' &&
|
|
259
|
+
e.target.parentElement.tagName === 'A') {
|
|
260
|
+
e.preventDefault();
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
Image.prototype.onCutHandler = function () {
|
|
264
|
+
if (this.imgResizeDiv && this.contentModule.getEditPanel().contains(this.imgResizeDiv)) {
|
|
265
|
+
this.cancelResizeAction();
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
Image.prototype.imageResize = function (e) {
|
|
269
|
+
this.resizeBtnInit();
|
|
270
|
+
this.imgEle = e;
|
|
271
|
+
ej2_base_1.addClass([this.imgEle], 'e-resize');
|
|
272
|
+
this.imgResizeDiv = this.parent.createElement('span', { className: 'e-img-resize' + this.parent.getCssClass(true), id: this.rteID + '_imgResize' });
|
|
273
|
+
this.imgResizeDiv.appendChild(this.parent.createElement('span', {
|
|
274
|
+
className: 'e-rte-imageboxmark e-rte-topLeft' + this.parent.getCssClass(true), styles: 'cursor: nwse-resize'
|
|
275
|
+
}));
|
|
276
|
+
this.imgResizeDiv.appendChild(this.parent.createElement('span', {
|
|
277
|
+
className: 'e-rte-imageboxmark e-rte-topRight' + this.parent.getCssClass(true), styles: 'cursor: nesw-resize'
|
|
278
|
+
}));
|
|
279
|
+
this.imgResizeDiv.appendChild(this.parent.createElement('span', {
|
|
280
|
+
className: 'e-rte-imageboxmark e-rte-botLeft' + this.parent.getCssClass(true), styles: 'cursor: nesw-resize'
|
|
281
|
+
}));
|
|
282
|
+
this.imgResizeDiv.appendChild(this.parent.createElement('span', {
|
|
283
|
+
className: 'e-rte-imageboxmark e-rte-botRight' + this.parent.getCssClass(true), styles: 'cursor: nwse-resize'
|
|
284
|
+
}));
|
|
285
|
+
if (ej2_base_1.Browser.isDevice) {
|
|
286
|
+
ej2_base_1.addClass([this.imgResizeDiv], 'e-mob-rte');
|
|
287
|
+
}
|
|
288
|
+
e.style.outline = '2px solid #4a90e2';
|
|
289
|
+
this.imgResizePos(e, this.imgResizeDiv);
|
|
290
|
+
this.resizeImgDupPos(e);
|
|
291
|
+
this.contentModule.getEditPanel().appendChild(this.imgResizeDiv);
|
|
292
|
+
if (this.parent.element.style.height === 'auto') {
|
|
293
|
+
this.imgResizePos(e, this.imgResizeDiv);
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
Image.prototype.getPointX = function (e) {
|
|
297
|
+
if (this.parent.iframeSettings.enable) {
|
|
298
|
+
if (e.touches && e.touches.length) {
|
|
299
|
+
return e.touches[0].screenX;
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
return e.screenX;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
if (e.touches && e.touches.length) {
|
|
307
|
+
return e.touches[0].pageX;
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
return e.pageX;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
Image.prototype.getPointY = function (e) {
|
|
315
|
+
if (this.parent.iframeSettings.enable) {
|
|
316
|
+
if (e.touches && e.touches.length) {
|
|
317
|
+
return e.touches[0].screenY;
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
return e.screenY;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
if (e.touches && e.touches.length) {
|
|
325
|
+
return e.touches[0].pageY;
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
return e.pageY;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
Image.prototype.imgResizePos = function (e, imgResizeDiv) {
|
|
333
|
+
var pos = this.calcPos(e);
|
|
334
|
+
var top = pos.top;
|
|
335
|
+
var left = pos.left;
|
|
336
|
+
var imgWid = e.getBoundingClientRect().width;
|
|
337
|
+
var imgHgt = e.getBoundingClientRect().height;
|
|
338
|
+
var borWid = (ej2_base_1.Browser.isDevice) ? (4 * parseInt((e.style.outline.slice(-3)), 10)) + 2 :
|
|
339
|
+
(2 * parseInt((e.style.outline.slice(-3)), 10)) + 2;
|
|
340
|
+
var devWid = ((ej2_base_1.Browser.isDevice) ? 0 : 2);
|
|
341
|
+
imgResizeDiv.querySelector('.e-rte-botLeft').style.left = (left - borWid) + 'px';
|
|
342
|
+
imgResizeDiv.querySelector('.e-rte-botLeft').style.top = ((imgHgt - borWid) + top) + 'px';
|
|
343
|
+
imgResizeDiv.querySelector('.e-rte-botRight').style.left = ((imgWid - (borWid - devWid)) + left) + 'px';
|
|
344
|
+
imgResizeDiv.querySelector('.e-rte-botRight').style.top = ((imgHgt - borWid) + top) + 'px';
|
|
345
|
+
imgResizeDiv.querySelector('.e-rte-topRight').style.left = ((imgWid - (borWid - devWid)) + left) + 'px';
|
|
346
|
+
imgResizeDiv.querySelector('.e-rte-topRight').style.top = (top - (borWid)) + 'px';
|
|
347
|
+
imgResizeDiv.querySelector('.e-rte-topLeft').style.left = (left - borWid) + 'px';
|
|
348
|
+
imgResizeDiv.querySelector('.e-rte-topLeft').style.top = (top - borWid) + 'px';
|
|
349
|
+
};
|
|
350
|
+
Image.prototype.calcPos = function (elem) {
|
|
351
|
+
var ignoreOffset = ['TD', 'TH', 'TABLE', 'A'];
|
|
352
|
+
var parentOffset = { top: 0, left: 0 };
|
|
353
|
+
var elementOffset;
|
|
354
|
+
var doc = elem.ownerDocument;
|
|
355
|
+
var offsetParent = ((elem.offsetParent && (elem.offsetParent.classList.contains('e-img-caption') ||
|
|
356
|
+
ignoreOffset.indexOf(elem.offsetParent.tagName) > -1)) ?
|
|
357
|
+
ej2_base_1.closest(elem, '#' + this.parent.getID() + '_rte-edit-view') : elem.offsetParent) || doc.documentElement;
|
|
358
|
+
while (offsetParent &&
|
|
359
|
+
(offsetParent === doc.body || offsetParent === doc.documentElement) &&
|
|
360
|
+
offsetParent.style.position === 'static') {
|
|
361
|
+
offsetParent = offsetParent.parentNode;
|
|
362
|
+
}
|
|
363
|
+
if (offsetParent && offsetParent !== elem && offsetParent.nodeType === 1) {
|
|
364
|
+
parentOffset = offsetParent.getBoundingClientRect();
|
|
365
|
+
}
|
|
366
|
+
if (elem.offsetParent && (elem.offsetParent.classList.contains('e-img-caption'))) {
|
|
367
|
+
elementOffset = elem.getBoundingClientRect();
|
|
368
|
+
return {
|
|
369
|
+
top: elementOffset.top - parentOffset.top,
|
|
370
|
+
left: elementOffset.left - parentOffset.left
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
return {
|
|
375
|
+
top: elem.offsetTop,
|
|
376
|
+
left: elem.offsetLeft
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
Image.prototype.setAspectRatio = function (img, expectedX, expectedY) {
|
|
381
|
+
if (ej2_base_1.isNullOrUndefined(img.width)) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
var width = img.width;
|
|
385
|
+
var height = img.height;
|
|
386
|
+
var sameHeightWidth = (width === height);
|
|
387
|
+
var factor = this.parent.insertImageSettings.resizeByPercent ? '%' : 'px';
|
|
388
|
+
var emptyStyleDimension = (img.style.width === '' && img.style.height === '');
|
|
389
|
+
if (!sameHeightWidth && !emptyStyleDimension) {
|
|
390
|
+
if (img.style.width !== '' && img.style.height !== '') {
|
|
391
|
+
if (this.parent.insertImageSettings.resizeByPercent) {
|
|
392
|
+
this.setImageWidth(img, expectedX, factor);
|
|
393
|
+
this.removeImageHeight(img);
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
this.setImageWidth(img, expectedX, factor);
|
|
397
|
+
this.setImageHeight(img, expectedY, factor);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
else if (img.style.width !== '') {
|
|
401
|
+
if (this.parent.insertImageSettings.resizeByPercent) {
|
|
402
|
+
this.setImageWidth(img, expectedX, factor);
|
|
403
|
+
this.removeImageHeight(img);
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
this.setImageWidth(img, expectedX, factor);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
else if (img.style.height !== '') {
|
|
410
|
+
if (this.parent.insertImageSettings.resizeByPercent) {
|
|
411
|
+
this.setImageWidth(img, expectedX, factor);
|
|
412
|
+
this.removeImageHeight(img);
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
this.setImageHeight(img, expectedY, factor);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
this.setImageWidth(img, expectedX, factor);
|
|
421
|
+
if (this.parent.insertImageSettings.resizeByPercent) {
|
|
422
|
+
this.removeImageHeight(img);
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
this.setImageHeight(img, expectedY, factor);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
Image.prototype.setImageWidth = function (img, value, suffix) {
|
|
430
|
+
img.style.width = this.getImageDimension(value, img) + suffix;
|
|
431
|
+
if (!this.parent.insertImageSettings.resizeByPercent) {
|
|
432
|
+
img.setAttribute('width', value.toString());
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
Image.prototype.setImageHeight = function (img, value, suffix) {
|
|
436
|
+
img.style.height = this.getImageDimension(value, img) + suffix;
|
|
437
|
+
if (!this.parent.insertImageSettings.resizeByPercent) {
|
|
438
|
+
img.setAttribute('height', value.toString());
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
Image.prototype.removeImageHeight = function (img) {
|
|
442
|
+
img.style.height = '';
|
|
443
|
+
img.removeAttribute('height');
|
|
444
|
+
};
|
|
445
|
+
Image.prototype.getImageDimension = function (value, img) {
|
|
446
|
+
if (this.parent.insertImageSettings.resizeByPercent) {
|
|
447
|
+
var rootElem = img.parentElement;
|
|
448
|
+
return this.pixToPerc(value, rootElem);
|
|
449
|
+
}
|
|
450
|
+
else {
|
|
451
|
+
return value;
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
Image.prototype.adjustDimensionsByAspectRatio = function (width, height, aspectRatio) {
|
|
455
|
+
height = Math.round(width / aspectRatio);
|
|
456
|
+
width = Math.round(height * aspectRatio);
|
|
457
|
+
return { width: width, height: height };
|
|
458
|
+
};
|
|
459
|
+
Image.prototype.pixToPerc = function (expected, parentEle) {
|
|
460
|
+
return expected / parseFloat(getComputedStyle(parentEle).width) * 100;
|
|
461
|
+
};
|
|
462
|
+
Image.prototype.imgDupMouseMove = function (width, height, e) {
|
|
463
|
+
var _this = this;
|
|
464
|
+
var args = { event: e, requestType: 'images' };
|
|
465
|
+
this.parent.trigger(events.onResize, args, function (resizingArgs) {
|
|
466
|
+
if (resizingArgs.cancel) {
|
|
467
|
+
_this.cancelResizeAction();
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
if ((parseInt(_this.parent.insertImageSettings.minWidth, 10) >= parseInt(width, 10) ||
|
|
471
|
+
(parseInt(_this.parent.getInsertImgMaxWidth(), 10) <= parseInt(width, 10) &&
|
|
472
|
+
ej2_base_1.isNullOrUndefined(_this.imgEle.style.width)))) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
if (!_this.parent.insertImageSettings.resizeByPercent &&
|
|
476
|
+
(parseInt(_this.parent.insertImageSettings.minHeight, 10) >= parseInt(height, 10) ||
|
|
477
|
+
parseInt(_this.parent.insertImageSettings.maxHeight, 10) <= parseInt(height, 10))) {
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
_this.imgEle.parentElement.style.cursor = 'pointer';
|
|
481
|
+
_this.setAspectRatio(_this.imgEle, parseInt(width, 10), parseInt(height, 10));
|
|
482
|
+
_this.resizeImgDupPos(_this.imgEle);
|
|
483
|
+
_this.imgResizePos(_this.imgEle, _this.imgResizeDiv);
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
};
|
|
487
|
+
Image.prototype.resizing = function (e) {
|
|
488
|
+
if (!this.parent) {
|
|
489
|
+
this.cancelResizeAction();
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (this.resizeBtnStat.botRight || this.resizeBtnStat.botLeft || this.resizeBtnStat.topRight || this.resizeBtnStat.topLeft) {
|
|
493
|
+
if (this.parent.iframeSettings.enable) {
|
|
494
|
+
var resizeFactor = this.getResizeFactor(this.currentResizeHandler);
|
|
495
|
+
var currentScreenX = this.getPointX(e);
|
|
496
|
+
var currentScreenY = this.getPointY(e);
|
|
497
|
+
var currentWidth = this.imgEle.clientWidth;
|
|
498
|
+
var currentHeight = this.imgEle.clientHeight;
|
|
499
|
+
var deltaX = currentScreenX - this.pageX;
|
|
500
|
+
var deltaY = currentScreenY - this.pageY;
|
|
501
|
+
var width = deltaX * resizeFactor[0] + currentWidth;
|
|
502
|
+
var height = deltaY * resizeFactor[1] + currentHeight;
|
|
503
|
+
var dimensions = this.adjustDimensions(width, height, deltaX, deltaY, this.aspectRatio);
|
|
504
|
+
this.pageX = currentScreenX;
|
|
505
|
+
this.pageY = currentScreenY;
|
|
506
|
+
this.imgDupMouseMove(dimensions.width + 'px', dimensions.height + 'px', e);
|
|
507
|
+
this.parent.autoResize();
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
var pageX = this.getPointX(e);
|
|
511
|
+
var pageY = this.getPointY(e);
|
|
512
|
+
var resizeFactor = this.getResizeFactor(this.currentResizeHandler);
|
|
513
|
+
var diffX = (pageX - this.pageX);
|
|
514
|
+
var diffY = (pageY - this.pageY);
|
|
515
|
+
var currentWidth = this.imgEle.clientWidth;
|
|
516
|
+
var currentHeight = this.imgEle.clientHeight;
|
|
517
|
+
var width = diffX * resizeFactor[0] + currentWidth;
|
|
518
|
+
var height = diffY * resizeFactor[1] + currentHeight;
|
|
519
|
+
var dimensions = this.adjustDimensions(width, height, diffX, diffY, this.aspectRatio);
|
|
520
|
+
this.pageX = pageX;
|
|
521
|
+
this.pageY = pageY;
|
|
522
|
+
this.imgDupMouseMove(dimensions.width + 'px', dimensions.height + 'px', e);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
Image.prototype.adjustDimensions = function (width, height, diffX, diffY, aspectRatio) {
|
|
527
|
+
width = (width < 16) ? 16 : width;
|
|
528
|
+
height = (height < 16) ? 16 : height;
|
|
529
|
+
var dimensions = this.adjustDimensionsByAspectRatio(width, height, aspectRatio);
|
|
530
|
+
return dimensions;
|
|
531
|
+
};
|
|
532
|
+
Image.prototype.getResizeFactor = function (value) {
|
|
533
|
+
return config_1.imageResizeFactor[value];
|
|
534
|
+
};
|
|
535
|
+
Image.prototype.findAspectRatio = function (image) {
|
|
536
|
+
return image.clientWidth / image.clientHeight;
|
|
537
|
+
};
|
|
538
|
+
Image.prototype.cancelResizeAction = function () {
|
|
539
|
+
ej2_base_1.EventHandler.remove(this.contentModule.getDocument(), ej2_base_1.Browser.touchMoveEvent, this.resizing);
|
|
540
|
+
ej2_base_1.EventHandler.remove(this.contentModule.getDocument(), ej2_base_1.Browser.touchEndEvent, this.resizeEnd);
|
|
541
|
+
if (this.imgEle && this.imgResizeDiv && this.contentModule.getEditPanel().contains(this.imgResizeDiv)) {
|
|
542
|
+
ej2_base_1.detach(this.imgResizeDiv);
|
|
543
|
+
this.imgEle.style.outline = '';
|
|
544
|
+
this.imgResizeDiv = null;
|
|
545
|
+
this.pageX = null;
|
|
546
|
+
this.pageY = null;
|
|
547
|
+
this.currentResizeHandler = null;
|
|
548
|
+
this.aspectRatio = null;
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
Image.prototype.resizeImgDupPos = function (e) {
|
|
552
|
+
this.imgDupPos = {
|
|
553
|
+
width: (e.style.width !== '' && (this.parent.insertImageSettings &&
|
|
554
|
+
!this.parent.insertImageSettings.resizeByPercent)) ? this.imgEle.style.width : e.width + 'px',
|
|
555
|
+
height: (e.style.height !== '') ? this.imgEle.style.height : e.height + 'px'
|
|
556
|
+
};
|
|
557
|
+
};
|
|
558
|
+
Image.prototype.resizeBtnInit = function () {
|
|
559
|
+
this.aspectRatio = null;
|
|
560
|
+
this.currentResizeHandler = null;
|
|
561
|
+
return this.resizeBtnStat = { botLeft: false, botRight: false, topRight: false, topLeft: false };
|
|
562
|
+
};
|
|
563
|
+
Image.prototype.onToolbarAction = function (args) {
|
|
564
|
+
if (util_1.isIDevice()) {
|
|
565
|
+
this.parent.notify(events.selectionRestore, {});
|
|
566
|
+
}
|
|
567
|
+
var item = args.args.item;
|
|
568
|
+
switch (item.subCommand) {
|
|
569
|
+
case 'Replace':
|
|
570
|
+
if (this.parent.fileManagerSettings.enable) {
|
|
571
|
+
this.parent.notify(events.renderFileManager, args);
|
|
572
|
+
}
|
|
573
|
+
else {
|
|
574
|
+
this.parent.notify(events.insertImage, args);
|
|
575
|
+
}
|
|
576
|
+
break;
|
|
577
|
+
case 'Caption':
|
|
578
|
+
this.parent.notify(events.imageCaption, args);
|
|
579
|
+
break;
|
|
580
|
+
case 'InsertLink':
|
|
581
|
+
this.parent.notify(events.imageLink, args);
|
|
582
|
+
break;
|
|
583
|
+
case 'AltText':
|
|
584
|
+
this.parent.notify(events.imageAlt, args);
|
|
585
|
+
break;
|
|
586
|
+
case 'Remove':
|
|
587
|
+
this.parent.notify(events.imageDelete, args);
|
|
588
|
+
break;
|
|
589
|
+
case 'Dimension':
|
|
590
|
+
this.parent.notify(events.imageSize, args);
|
|
591
|
+
break;
|
|
592
|
+
case 'OpenImageLink':
|
|
593
|
+
this.openImgLink(args);
|
|
594
|
+
break;
|
|
595
|
+
case 'EditImageLink':
|
|
596
|
+
this.editImgLink(args);
|
|
597
|
+
break;
|
|
598
|
+
case 'RemoveImageLink':
|
|
599
|
+
this.removeImgLink(args);
|
|
600
|
+
break;
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
Image.prototype.openImgLink = function (e) {
|
|
604
|
+
var sanitizedHTML = this.parent.htmlEditorModule.sanitizeHelper(e.selectParent[0].parentNode.outerHTML);
|
|
605
|
+
var tempEle = document.createElement('div');
|
|
606
|
+
tempEle.innerHTML = sanitizedHTML;
|
|
607
|
+
var target = e.selectParent[0].parentNode.target === '' ? '_self' : '_blank';
|
|
608
|
+
this.parent.formatter.process(this.parent, e.args, e.args, {
|
|
609
|
+
url: tempEle.firstChild.href, target: target, selectNode: e.selectNode,
|
|
610
|
+
subCommand: e.args.item.subCommand
|
|
611
|
+
});
|
|
612
|
+
tempEle.remove();
|
|
613
|
+
};
|
|
614
|
+
Image.prototype.editImgLink = function (e) {
|
|
615
|
+
var selectParentEle = e.selectParent[0].parentNode;
|
|
616
|
+
var linkUpdate = this.i10n.getConstant('dialogUpdate');
|
|
617
|
+
var inputDetails = {
|
|
618
|
+
url: selectParentEle.href, target: selectParentEle.target,
|
|
619
|
+
header: 'Edit Link', btnText: linkUpdate
|
|
620
|
+
};
|
|
621
|
+
this.insertImgLink(e, inputDetails);
|
|
622
|
+
};
|
|
623
|
+
Image.prototype.removeImgLink = function (e) {
|
|
624
|
+
if (ej2_base_1.Browser.isIE) {
|
|
625
|
+
this.contentModule.getEditPanel().focus();
|
|
626
|
+
}
|
|
627
|
+
e.selection.restore();
|
|
628
|
+
var isCapLink = (this.contentModule.getEditPanel().contains(this.captionEle) && ej2_base_1.select('a', this.captionEle)) ?
|
|
629
|
+
true : false;
|
|
630
|
+
var selectParent = isCapLink ? [this.captionEle] : [e.selectNode[0].parentElement];
|
|
631
|
+
this.parent.formatter.process(this.parent, e.args, e.args, {
|
|
632
|
+
insertElement: e.selectNode[0], selectParent: selectParent, selection: e.selection,
|
|
633
|
+
subCommand: e.args.item.subCommand
|
|
634
|
+
});
|
|
635
|
+
if (this.quickToolObj && document.body.contains(this.quickToolObj.imageQTBar.element)) {
|
|
636
|
+
this.quickToolObj.imageQTBar.hidePopup();
|
|
637
|
+
if (!ej2_base_1.isNullOrUndefined(e.selectParent)) {
|
|
638
|
+
ej2_base_1.removeClass([e.selectParent[0]], 'e-img-focus');
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
if (isCapLink) {
|
|
642
|
+
ej2_base_1.select('.e-img-inner', this.captionEle).focus();
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
Image.prototype.onKeyDown = function (event) {
|
|
646
|
+
var originalEvent = event.args;
|
|
647
|
+
var range;
|
|
648
|
+
var save;
|
|
649
|
+
var selectNodeEle;
|
|
650
|
+
var selectParentEle;
|
|
651
|
+
this.deletedImg = [];
|
|
652
|
+
var isCursor;
|
|
653
|
+
var keyCodeValues = [27, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
|
|
654
|
+
44, 45, 9, 16, 17, 18, 19, 20, 33, 34, 35, 36, 37, 38, 39, 40, 91, 92, 93, 144, 145, 182, 183];
|
|
655
|
+
if (this.parent.editorMode === 'HTML') {
|
|
656
|
+
range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
|
|
657
|
+
isCursor = range.startContainer === range.endContainer && range.startOffset === range.endOffset;
|
|
658
|
+
}
|
|
659
|
+
if (!isCursor && this.parent.editorMode === 'HTML' && keyCodeValues.indexOf(originalEvent.which) < 0) {
|
|
660
|
+
var nodes = this.parent.formatter.editorManager.nodeSelection.getNodeCollection(range);
|
|
661
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
662
|
+
if (nodes[i].nodeName === 'IMG') {
|
|
663
|
+
this.deletedImg.push(nodes[i]);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
if (this.parent.editorMode === 'HTML' && ((originalEvent.which === 8 && originalEvent.code === 'Backspace') ||
|
|
668
|
+
(originalEvent.which === 46 && originalEvent.code === 'Delete'))) {
|
|
669
|
+
var isCursor_1 = range.startContainer === range.endContainer && range.startOffset === range.endOffset;
|
|
670
|
+
if ((originalEvent.which === 8 && originalEvent.code === 'Backspace' && isCursor_1)) {
|
|
671
|
+
this.checkImageBack(range);
|
|
672
|
+
}
|
|
673
|
+
else if ((originalEvent.which === 46 && originalEvent.code === 'Delete' && isCursor_1)) {
|
|
674
|
+
this.checkImageDel(range);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
if (!ej2_base_1.isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection) &&
|
|
678
|
+
originalEvent.code !== 'KeyK') {
|
|
679
|
+
range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
|
|
680
|
+
selectNodeEle = this.parent.formatter.editorManager.nodeSelection.getNodeCollection(range);
|
|
681
|
+
selectParentEle = this.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range);
|
|
682
|
+
if (!originalEvent.ctrlKey && originalEvent.key && (originalEvent.key.length === 1 || originalEvent.action === 'enter') &&
|
|
683
|
+
(!ej2_base_1.isNullOrUndefined(selectParentEle[0]) && selectParentEle[0].tagName === 'IMG') && selectParentEle[0].parentElement) {
|
|
684
|
+
if (this.contentModule.getEditPanel().querySelector('.e-img-resize')) {
|
|
685
|
+
this.removeResizeEle();
|
|
686
|
+
}
|
|
687
|
+
ej2_base_1.removeClass([selectParentEle[0]], 'e-img-focus');
|
|
688
|
+
if (this.quickToolObj && this.quickToolObj.imageQTBar) {
|
|
689
|
+
this.quickToolObj.imageQTBar.hidePopup();
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
if (originalEvent.ctrlKey && (originalEvent.keyCode === 89 || originalEvent.keyCode === 90)) {
|
|
694
|
+
if (this.parent.editorMode !== 'Markdown') {
|
|
695
|
+
this.undoStack({ subCommand: (originalEvent.keyCode === 90 ? 'undo' : 'redo') });
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
if (originalEvent.keyCode === 8 || originalEvent.keyCode === 46) {
|
|
699
|
+
if (selectNodeEle && selectNodeEle[0] && selectNodeEle[0].nodeName === 'IMG' && selectNodeEle.length < 1) {
|
|
700
|
+
if (!ej2_base_1.isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection)) {
|
|
701
|
+
save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
|
|
702
|
+
}
|
|
703
|
+
originalEvent.preventDefault();
|
|
704
|
+
var event_1 = {
|
|
705
|
+
selectNode: selectNodeEle, selection: save, selectParent: selectParentEle,
|
|
706
|
+
args: {
|
|
707
|
+
item: { command: 'Images', subCommand: 'Remove' },
|
|
708
|
+
originalEvent: originalEvent
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
this.deleteImg(event_1, originalEvent.keyCode);
|
|
712
|
+
}
|
|
713
|
+
if (this.parent.contentModule.getEditPanel().querySelector('.e-img-resize')) {
|
|
714
|
+
this.removeResizeEle();
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
if (originalEvent.code === 'Backspace') {
|
|
718
|
+
originalEvent.action = 'backspace';
|
|
719
|
+
}
|
|
720
|
+
switch (originalEvent.action) {
|
|
721
|
+
case 'escape':
|
|
722
|
+
if (!ej2_base_1.isNullOrUndefined(this.dialogObj)) {
|
|
723
|
+
this.dialogObj.close();
|
|
724
|
+
}
|
|
725
|
+
break;
|
|
726
|
+
case 'backspace':
|
|
727
|
+
case 'delete':
|
|
728
|
+
if (this.parent.editorMode !== 'Markdown') {
|
|
729
|
+
if (range.startContainer.nodeType === 3) {
|
|
730
|
+
if (originalEvent.code === 'Backspace') {
|
|
731
|
+
if (range.startContainer.previousElementSibling && range.startOffset === 0 &&
|
|
732
|
+
range.startContainer.previousElementSibling.classList.contains(classes.CLS_CAPTION) &&
|
|
733
|
+
range.startContainer.previousElementSibling.classList.contains(classes.CLS_CAPINLINE)) {
|
|
734
|
+
ej2_base_1.detach(range.startContainer.previousElementSibling);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
else {
|
|
738
|
+
if (range.startContainer.nextElementSibling &&
|
|
739
|
+
range.endContainer.textContent.length === range.endOffset &&
|
|
740
|
+
range.startContainer.nextElementSibling.classList.contains(classes.CLS_CAPTION) &&
|
|
741
|
+
range.startContainer.nextElementSibling.classList.contains(classes.CLS_CAPINLINE)) {
|
|
742
|
+
ej2_base_1.detach(range.startContainer.nextElementSibling);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
else if (range.startContainer.nodeType === 1) {
|
|
747
|
+
if (range.startContainer.querySelector('.' + classes.CLS_CAPTION + '.' + classes.CLS_CAPINLINE)) {
|
|
748
|
+
ej2_base_1.detach(range.startContainer.querySelector('.' + classes.CLS_CAPTION + '.' + classes.CLS_CAPINLINE));
|
|
749
|
+
}
|
|
750
|
+
else if (range.startContainer.querySelector('.' + classes.CLS_CAPTION + '.' + classes.CLS_IMGBREAK)) {
|
|
751
|
+
ej2_base_1.detach(range.startContainer.querySelector('.' + classes.CLS_CAPTION + '.' + classes.CLS_IMGBREAK));
|
|
752
|
+
}
|
|
753
|
+
else if (range.startContainer.classList.contains('e-img-wrap') && ej2_base_1.closest(range.startContainer, '.' + classes.CLS_CAPTION)) {
|
|
754
|
+
var parentElem = range.startContainer.parentElement.parentElement;
|
|
755
|
+
ej2_base_1.detach(ej2_base_1.closest(range.startContainer, '.' + classes.CLS_CAPTION));
|
|
756
|
+
if (parentElem && parentElem.textContent.trim() === '') {
|
|
757
|
+
var brElem = this.parent.createElement('br');
|
|
758
|
+
brElem.classList.add('e-rte-image-remove-focus');
|
|
759
|
+
parentElem.appendChild(brElem);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
break;
|
|
765
|
+
case 'insert-image':
|
|
766
|
+
if (!ej2_base_1.isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection)) {
|
|
767
|
+
save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
|
|
768
|
+
}
|
|
769
|
+
this.openDialog(true, originalEvent, save, selectNodeEle, selectParentEle);
|
|
770
|
+
originalEvent.preventDefault();
|
|
771
|
+
break;
|
|
772
|
+
}
|
|
773
|
+
if (originalEvent.ctrlKey && originalEvent.key === 'a') {
|
|
774
|
+
this.handleSelectAll();
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
Image.prototype.handleSelectAll = function () {
|
|
778
|
+
this.cancelResizeAction();
|
|
779
|
+
var imgFocusNodes = this.parent.inputElement.querySelectorAll('.' + classes.CLS_IMG_FOCUS);
|
|
780
|
+
ej2_base_1.removeClass(imgFocusNodes, classes.CLS_IMG_FOCUS);
|
|
781
|
+
};
|
|
782
|
+
Image.prototype.openDialog = function (isInternal, event, selection, ele, parentEle) {
|
|
783
|
+
var range;
|
|
784
|
+
var save;
|
|
785
|
+
var selectNodeEle;
|
|
786
|
+
var selectParentEle;
|
|
787
|
+
if (!isInternal && !ej2_base_1.isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection)) {
|
|
788
|
+
range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
|
|
789
|
+
save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
|
|
790
|
+
selectNodeEle = this.parent.formatter.editorManager.nodeSelection.getNodeCollection(range);
|
|
791
|
+
selectParentEle = this.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range);
|
|
792
|
+
}
|
|
793
|
+
else {
|
|
794
|
+
save = selection;
|
|
795
|
+
selectNodeEle = ele;
|
|
796
|
+
selectParentEle = parentEle;
|
|
797
|
+
}
|
|
798
|
+
if (this.parent.editorMode === 'HTML') {
|
|
799
|
+
this.insertImage({
|
|
800
|
+
args: {
|
|
801
|
+
item: { command: 'Images', subCommand: 'Image' },
|
|
802
|
+
originalEvent: event,
|
|
803
|
+
name: !isInternal ? 'showDialog' : null
|
|
804
|
+
},
|
|
805
|
+
selectNode: selectNodeEle,
|
|
806
|
+
selection: save,
|
|
807
|
+
selectParent: selectParentEle
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
else {
|
|
811
|
+
this.insertImage({
|
|
812
|
+
args: {
|
|
813
|
+
item: { command: 'Images', subCommand: 'Image' },
|
|
814
|
+
originalEvent: event,
|
|
815
|
+
name: !isInternal ? 'showDialog' : null
|
|
816
|
+
},
|
|
817
|
+
member: 'image',
|
|
818
|
+
text: this.parent.formatter.editorManager.markdownSelection.getSelectedText(this.parent.contentModule.getEditPanel()),
|
|
819
|
+
module: 'Markdown',
|
|
820
|
+
name: 'insertImage'
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
Image.prototype.showDialog = function (args) {
|
|
825
|
+
if (!ej2_base_1.isNullOrUndefined(args.originalEvent)) {
|
|
826
|
+
this.openDialog(false, args.originalEvent);
|
|
827
|
+
}
|
|
828
|
+
else {
|
|
829
|
+
this.openDialog(false);
|
|
830
|
+
}
|
|
831
|
+
this.setCssClass({ cssClass: this.parent.getCssClass() });
|
|
832
|
+
};
|
|
833
|
+
Image.prototype.closeDialog = function () {
|
|
834
|
+
if (this.dialogObj) {
|
|
835
|
+
this.dialogObj.hide({ returnValue: true });
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
Image.prototype.onKeyUp = function () {
|
|
839
|
+
if (!ej2_base_1.isNullOrUndefined(this.deletedImg) && this.deletedImg.length > 0) {
|
|
840
|
+
var deleteImages = Array.from(this.deletedImg);
|
|
841
|
+
for (var i = deleteImages.length - 1; i >= 0; i--) {
|
|
842
|
+
var args = {
|
|
843
|
+
element: this.deletedImg[i],
|
|
844
|
+
src: this.deletedImg[i].getAttribute('src')
|
|
845
|
+
};
|
|
846
|
+
this.parent.trigger(events.afterImageDelete, args);
|
|
847
|
+
this.deletedImg.splice(i, 1);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
Image.prototype.checkImageBack = function (range) {
|
|
852
|
+
if (range.startContainer.nodeName === '#text' && range.startOffset === 0 &&
|
|
853
|
+
!ej2_base_1.isNullOrUndefined(range.startContainer.previousSibling) && range.startContainer.previousSibling.nodeName === 'IMG') {
|
|
854
|
+
this.deletedImg.push(range.startContainer.previousSibling);
|
|
855
|
+
}
|
|
856
|
+
else if (range.startContainer.nodeName !== '#text' && !ej2_base_1.isNullOrUndefined(range.startContainer.childNodes[range.startOffset - 1]) &&
|
|
857
|
+
range.startContainer.childNodes[range.startOffset - 1].nodeName === 'IMG') {
|
|
858
|
+
this.deletedImg.push(range.startContainer.childNodes[range.startOffset - 1]);
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
Image.prototype.checkImageDel = function (range) {
|
|
862
|
+
if (range.startContainer.nodeName === '#text' && range.startOffset === range.startContainer.textContent.length &&
|
|
863
|
+
!ej2_base_1.isNullOrUndefined(range.startContainer.nextSibling) && range.startContainer.nextSibling.nodeName === 'IMG') {
|
|
864
|
+
this.deletedImg.push(range.startContainer.nextSibling);
|
|
865
|
+
}
|
|
866
|
+
else if (range.startContainer.nodeName !== '#text' && !ej2_base_1.isNullOrUndefined(range.startContainer.childNodes[range.startOffset]) &&
|
|
867
|
+
range.startContainer.childNodes[range.startOffset].nodeName === 'IMG') {
|
|
868
|
+
this.deletedImg.push(range.startContainer.childNodes[range.startOffset]);
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
Image.prototype.alignmentSelect = function (e) {
|
|
872
|
+
var item = e.item;
|
|
873
|
+
if (!document.body.contains(document.body.querySelector('.e-rte-quick-toolbar')) || item.command !== 'Images') {
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
|
|
877
|
+
var selectNodeEle = this.parent.formatter.editorManager.nodeSelection.getNodeCollection(range);
|
|
878
|
+
selectNodeEle = (selectNodeEle[0].nodeName === 'IMG') ? selectNodeEle : [this.imgEle];
|
|
879
|
+
var args = { args: e, selectNode: selectNodeEle };
|
|
880
|
+
if (this.parent.formatter.getUndoRedoStack().length === 0) {
|
|
881
|
+
this.parent.formatter.saveData();
|
|
882
|
+
}
|
|
883
|
+
switch (item.subCommand) {
|
|
884
|
+
case 'JustifyLeft':
|
|
885
|
+
this.alignImage(args);
|
|
886
|
+
break;
|
|
887
|
+
case 'JustifyCenter':
|
|
888
|
+
this.alignImage(args);
|
|
889
|
+
break;
|
|
890
|
+
case 'JustifyRight':
|
|
891
|
+
this.alignImage(args);
|
|
892
|
+
break;
|
|
893
|
+
case 'Inline':
|
|
894
|
+
this.inline(args);
|
|
895
|
+
break;
|
|
896
|
+
case 'Break':
|
|
897
|
+
this.break(args);
|
|
898
|
+
break;
|
|
899
|
+
}
|
|
900
|
+
if (this.quickToolObj && document.body.contains(this.quickToolObj.imageQTBar.element)) {
|
|
901
|
+
this.quickToolObj.imageQTBar.hidePopup();
|
|
902
|
+
ej2_base_1.removeClass([selectNodeEle[0]], 'e-img-focus');
|
|
903
|
+
}
|
|
904
|
+
this.cancelResizeAction();
|
|
905
|
+
};
|
|
906
|
+
Image.prototype.imageWithLinkQTBarItemUpdate = function () {
|
|
907
|
+
var items = this.quickToolObj.imageQTBar.toolbarElement.querySelectorAll('.e-toolbar-item');
|
|
908
|
+
for (var i = 0; i < items.length; i++) {
|
|
909
|
+
if (items[i].getAttribute('title') === this.i10n.getConstant('openLink') ||
|
|
910
|
+
items[i].getAttribute('title') === this.i10n.getConstant('editLink') ||
|
|
911
|
+
items[i].getAttribute('title') === this.i10n.getConstant('removeLink')) {
|
|
912
|
+
ej2_base_1.addClass([items[i]], 'e-link-groups');
|
|
913
|
+
items[i].style.display = 'none';
|
|
914
|
+
}
|
|
915
|
+
else if (items[i].getAttribute('title') === 'Insert Link') {
|
|
916
|
+
items[i].style.display = '';
|
|
917
|
+
}
|
|
918
|
+
else if (items[i].classList.contains('e-rte-horizontal-separator')) {
|
|
919
|
+
ej2_base_1.detach(items[i]);
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
var newItems = this.quickToolObj.imageQTBar.toolbarElement.querySelectorAll('.e-toolbar-item:not(.e-link-groups)');
|
|
923
|
+
this.quickToolObj.imageQTBar.addQTBarItem(['-'], Math.round(newItems.length / 2));
|
|
924
|
+
};
|
|
925
|
+
Image.prototype.showImageQuickToolbar = function (e) {
|
|
926
|
+
var _this = this;
|
|
927
|
+
if ((e.type !== 'Images' && e.type !== 'Replace') || ej2_base_1.isNullOrUndefined(this.parent.quickToolbarModule)
|
|
928
|
+
|| ej2_base_1.isNullOrUndefined(this.parent.quickToolbarModule.imageQTBar) || ej2_base_1.isNullOrUndefined(e.args)) {
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
this.quickToolObj = this.parent.quickToolbarModule;
|
|
932
|
+
var args = e.args;
|
|
933
|
+
var target = e.elements;
|
|
934
|
+
[].forEach.call(e.elements, function (element, index) {
|
|
935
|
+
if (index === 0) {
|
|
936
|
+
target = element;
|
|
937
|
+
}
|
|
938
|
+
});
|
|
939
|
+
if (target && !ej2_base_1.closest(target, 'a')) {
|
|
940
|
+
this.imageWithLinkQTBarItemUpdate();
|
|
941
|
+
}
|
|
942
|
+
if (target.nodeName === 'IMG') {
|
|
943
|
+
ej2_base_1.addClass([target], ['e-img-focus']);
|
|
944
|
+
}
|
|
945
|
+
var pageY = (this.parent.iframeSettings.enable) ? window.pageYOffset +
|
|
946
|
+
this.parent.element.getBoundingClientRect().top + args.clientY : args.pageY;
|
|
947
|
+
if (this.parent.quickToolbarModule.imageQTBar) {
|
|
948
|
+
if (e.isNotify) {
|
|
949
|
+
this.imageQTPopupTime = setTimeout(function () {
|
|
950
|
+
_this.parent.formatter.editorManager.nodeSelection.Clear(_this.contentModule.getDocument());
|
|
951
|
+
_this.parent.formatter.editorManager.nodeSelection.setSelectionContents(_this.contentModule.getDocument(), target);
|
|
952
|
+
_this.quickToolObj.imageQTBar.showPopup(args.pageX, pageY, target);
|
|
953
|
+
if (_this.parent.insertImageSettings.resize === true) {
|
|
954
|
+
_this.resizeStart(e.args, target);
|
|
955
|
+
}
|
|
956
|
+
}, 400);
|
|
957
|
+
}
|
|
958
|
+
else {
|
|
959
|
+
var coordinates = target.getBoundingClientRect();
|
|
960
|
+
this.quickToolObj.imageQTBar.showPopup(coordinates.left, coordinates.top, target, 'Image');
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
Image.prototype.hideImageQuickToolbar = function () {
|
|
965
|
+
if (!ej2_base_1.isNullOrUndefined(this.contentModule.getEditPanel().querySelector('.e-img-focus'))) {
|
|
966
|
+
ej2_base_1.removeClass([this.contentModule.getEditPanel().querySelector('.e-img-focus')], 'e-img-focus');
|
|
967
|
+
if (this.quickToolObj && this.quickToolObj.imageQTBar && document.body.contains(this.quickToolObj.imageQTBar.element)) {
|
|
968
|
+
this.quickToolObj.imageQTBar.hidePopup();
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
Image.prototype.editAreaClickHandler = function (e) {
|
|
973
|
+
if (this.parent.readonly) {
|
|
974
|
+
this.hideImageQuickToolbar();
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
var args = e.args;
|
|
978
|
+
var showOnRightClick = this.parent.quickToolbarSettings.showOnRightClick;
|
|
979
|
+
if (args.which === 2 || (showOnRightClick && args.which === 1) || (!showOnRightClick && args.which === 3)) {
|
|
980
|
+
if ((showOnRightClick && args.which === 1) && !ej2_base_1.isNullOrUndefined(args.target) &&
|
|
981
|
+
args.target.tagName === 'IMG') {
|
|
982
|
+
this.parent.formatter.editorManager.nodeSelection.Clear(this.contentModule.getDocument());
|
|
983
|
+
this.parent.formatter.editorManager.nodeSelection.setSelectionContents(this.contentModule.getDocument(), args.target);
|
|
984
|
+
}
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
if (this.parent.editorMode === 'HTML' && this.parent.quickToolbarModule && this.parent.quickToolbarModule.imageQTBar) {
|
|
988
|
+
this.quickToolObj = this.parent.quickToolbarModule;
|
|
989
|
+
var target = args.target;
|
|
990
|
+
this.contentModule = this.rendererFactory.getRenderer(enum_1.RenderType.Content);
|
|
991
|
+
var isPopupOpen = this.quickToolObj.imageQTBar.element.classList.contains('e-rte-pop');
|
|
992
|
+
if (target.nodeName === 'IMG' && this.parent.quickToolbarModule) {
|
|
993
|
+
if (isPopupOpen) {
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
this.parent.formatter.editorManager.nodeSelection.Clear(this.contentModule.getDocument());
|
|
997
|
+
this.parent.formatter.editorManager.nodeSelection.setSelectionContents(this.contentModule.getDocument(), target);
|
|
998
|
+
if (util_1.isIDevice()) {
|
|
999
|
+
this.parent.notify(events.selectionSave, e);
|
|
1000
|
+
}
|
|
1001
|
+
ej2_base_1.addClass([target], 'e-img-focus');
|
|
1002
|
+
var items = this.quickToolObj.imageQTBar.toolbarElement.querySelectorAll('.e-toolbar-item');
|
|
1003
|
+
var separator = void 0;
|
|
1004
|
+
if (ej2_base_1.closest(target, 'a')) {
|
|
1005
|
+
for (var i = 0; i < items.length; i++) {
|
|
1006
|
+
if (items[i].getAttribute('title') === this.i10n.getConstant('openLink') ||
|
|
1007
|
+
items[i].getAttribute('title') === this.i10n.getConstant('editLink') ||
|
|
1008
|
+
items[i].getAttribute('title') === this.i10n.getConstant('removeLink')) {
|
|
1009
|
+
items[i].style.display = '';
|
|
1010
|
+
ej2_base_1.removeClass([items[i]], 'e-link-groups');
|
|
1011
|
+
}
|
|
1012
|
+
else if (items[i].getAttribute('title') === 'Insert Link') {
|
|
1013
|
+
items[i].style.display = 'none';
|
|
1014
|
+
}
|
|
1015
|
+
else if (items[i].classList.contains('e-rte-horizontal-separator')) {
|
|
1016
|
+
separator = items[i];
|
|
1017
|
+
ej2_base_1.detach(items[i]);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
var newItems = this.quickToolObj.imageQTBar.toolbarElement.querySelectorAll('.e-toolbar-item:not(.e-link-groups)');
|
|
1021
|
+
this.quickToolObj.imageQTBar.addQTBarItem(['-'], Math.round(newItems.length / 2));
|
|
1022
|
+
}
|
|
1023
|
+
else if (!ej2_base_1.closest(target, 'a')) {
|
|
1024
|
+
this.imageWithLinkQTBarItemUpdate();
|
|
1025
|
+
}
|
|
1026
|
+
this.showImageQuickToolbar({ args: args, type: 'Images', elements: [args.target] });
|
|
1027
|
+
}
|
|
1028
|
+
else {
|
|
1029
|
+
this.hideImageQuickToolbar();
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
};
|
|
1033
|
+
Image.prototype.insertImgLink = function (e, inputDetails) {
|
|
1034
|
+
var _this = this;
|
|
1035
|
+
if (e.selectNode[0].nodeName !== 'IMG') {
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
this.imagDialog(e);
|
|
1039
|
+
if (!ej2_base_1.isNullOrUndefined(this.dialogObj)) {
|
|
1040
|
+
var linkWrap = this.parent.createElement('div', { className: 'e-img-linkwrap' + this.parent.getCssClass(true) });
|
|
1041
|
+
var linkUrl = this.i10n.getConstant('linkurl');
|
|
1042
|
+
var content = '<div class="e-rte-field' + this.parent.getCssClass(true) + '">' +
|
|
1043
|
+
'<input type="text" data-role ="none" class="e-input e-img-link' + this.parent.getCssClass(true) + '" spellcheck="false" placeholder="' + linkUrl + '"/></div>' +
|
|
1044
|
+
'<div class="e-rte-label"></div>' + '<div class="e-rte-field">' +
|
|
1045
|
+
'<input type="checkbox" class="e-rte-linkTarget' + this.parent.getCssClass(true) + '" data-role ="none"></div>';
|
|
1046
|
+
var contentElem = util_2.parseHtml(content);
|
|
1047
|
+
linkWrap.appendChild(contentElem);
|
|
1048
|
+
var linkTarget = linkWrap.querySelector('.e-rte-linkTarget');
|
|
1049
|
+
var inputLink = linkWrap.querySelector('.e-img-link');
|
|
1050
|
+
var linkOpenLabel = this.i10n.getConstant('linkOpenInNewWindow');
|
|
1051
|
+
this.checkBoxObj = new ej2_buttons_1.CheckBox({
|
|
1052
|
+
label: linkOpenLabel, checked: true, enableRtl: this.parent.enableRtl, cssClass: this.parent.getCssClass(),
|
|
1053
|
+
change: function (e) {
|
|
1054
|
+
if (e.checked) {
|
|
1055
|
+
target_1 = '_blank';
|
|
1056
|
+
}
|
|
1057
|
+
else {
|
|
1058
|
+
target_1 = null;
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
});
|
|
1062
|
+
this.checkBoxObj.isStringTemplate = true;
|
|
1063
|
+
this.checkBoxObj.createElement = this.parent.createElement;
|
|
1064
|
+
this.checkBoxObj.appendTo(linkTarget);
|
|
1065
|
+
var target_1 = '_blank';
|
|
1066
|
+
var imageLabel = this.i10n.getConstant('imageLinkAriaLabel');
|
|
1067
|
+
var linkUpdate = this.i10n.getConstant('dialogUpdate');
|
|
1068
|
+
var linkargs_1 = {
|
|
1069
|
+
args: e.args,
|
|
1070
|
+
selfImage: this, selection: e.selection,
|
|
1071
|
+
selectNode: e.selectNode, selectParent: e.selectParent, link: inputLink, target: target_1, ariaLabel: imageLabel
|
|
1072
|
+
};
|
|
1073
|
+
this.dialogObj.setProperties({
|
|
1074
|
+
width: '290px',
|
|
1075
|
+
header: this.parent.localeObj.getConstant('imageInsertLinkHeader'),
|
|
1076
|
+
content: linkWrap,
|
|
1077
|
+
buttons: [{
|
|
1078
|
+
click: function (e) {
|
|
1079
|
+
_this.insertlink(linkargs_1);
|
|
1080
|
+
},
|
|
1081
|
+
buttonModel: {
|
|
1082
|
+
content: linkUpdate, cssClass: 'e-flat e-update-link' + this.parent.getCssClass(true), isPrimary: true
|
|
1083
|
+
}
|
|
1084
|
+
}],
|
|
1085
|
+
cssClass: this.dialogObj.cssClass + ' e-rte-img-link-dialog'
|
|
1086
|
+
});
|
|
1087
|
+
if (!ej2_base_1.isNullOrUndefined(this.parent.cssClass)) {
|
|
1088
|
+
this.dialogObj.setProperties({ cssClass: this.parent.cssClass });
|
|
1089
|
+
}
|
|
1090
|
+
if (!ej2_base_1.isNullOrUndefined(inputDetails)) {
|
|
1091
|
+
inputLink.value = inputDetails.url;
|
|
1092
|
+
this.checkBoxObj.checked = (inputDetails.target) ? true : false;
|
|
1093
|
+
this.dialogObj.header = inputDetails.header;
|
|
1094
|
+
}
|
|
1095
|
+
this.dialogObj.element.style.maxHeight = 'inherit';
|
|
1096
|
+
this.dialogObj.content.querySelector('input').focus();
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
Image.prototype.insertAltText = function (e) {
|
|
1100
|
+
var _this = this;
|
|
1101
|
+
if (e.selectNode[0].nodeName !== 'IMG') {
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1104
|
+
this.imagDialog(e);
|
|
1105
|
+
var altText = this.i10n.getConstant('altText');
|
|
1106
|
+
if (!ej2_base_1.isNullOrUndefined(this.dialogObj)) {
|
|
1107
|
+
var altWrap = this.parent.createElement('div', { className: 'e-img-altwrap' + this.parent.getCssClass(true) });
|
|
1108
|
+
var altHeader = this.i10n.getConstant('alternateHeader');
|
|
1109
|
+
var linkUpdate = this.i10n.getConstant('dialogUpdate');
|
|
1110
|
+
var getAlt = (e.selectNode[0].getAttribute('alt') === null) ? '' :
|
|
1111
|
+
e.selectNode[0].getAttribute('alt');
|
|
1112
|
+
var content = '<div class="e-rte-field' + this.parent.getCssClass(true) + '">' +
|
|
1113
|
+
'<input type="text" spellcheck="false" class="e-input e-img-alt' + this.parent.getCssClass(true) + '" placeholder="' + altText + '"/>' +
|
|
1114
|
+
'</div>';
|
|
1115
|
+
var contentElem = util_2.parseHtml(content);
|
|
1116
|
+
contentElem.querySelector('input').setAttribute('value', getAlt);
|
|
1117
|
+
altWrap.appendChild(contentElem);
|
|
1118
|
+
var inputAlt = altWrap.querySelector('.e-img-alt');
|
|
1119
|
+
var altArgs_1 = {
|
|
1120
|
+
args: e.args, selfImage: this, selection: e.selection, selectNode: e.selectNode,
|
|
1121
|
+
alt: inputAlt
|
|
1122
|
+
};
|
|
1123
|
+
this.dialogObj.setProperties({
|
|
1124
|
+
width: '290px', header: altHeader, content: altWrap,
|
|
1125
|
+
buttons: [{
|
|
1126
|
+
click: function (e) {
|
|
1127
|
+
_this.insertAlt(altArgs_1);
|
|
1128
|
+
},
|
|
1129
|
+
buttonModel: {
|
|
1130
|
+
content: linkUpdate, cssClass: 'e-flat e-update-alt' + this.parent.getCssClass(true), isPrimary: true
|
|
1131
|
+
}
|
|
1132
|
+
}],
|
|
1133
|
+
cssClass: this.dialogObj.cssClass + ' e-rte-img-alt-dialog'
|
|
1134
|
+
});
|
|
1135
|
+
if (!ej2_base_1.isNullOrUndefined(this.parent.cssClass)) {
|
|
1136
|
+
this.dialogObj.setProperties({ cssClass: this.parent.cssClass });
|
|
1137
|
+
}
|
|
1138
|
+
this.dialogObj.element.style.maxHeight = 'inherit';
|
|
1139
|
+
this.dialogObj.content.querySelector('input').focus();
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
Image.prototype.insertAlt = function (e) {
|
|
1143
|
+
if (!ej2_base_1.isNullOrUndefined(e.alt)) {
|
|
1144
|
+
e.selection.restore();
|
|
1145
|
+
if (this.parent.formatter.getUndoRedoStack().length === 0) {
|
|
1146
|
+
this.parent.formatter.saveData();
|
|
1147
|
+
}
|
|
1148
|
+
var altText = e.alt.value;
|
|
1149
|
+
this.parent.formatter.process(this.parent, e.args, e.args, {
|
|
1150
|
+
altText: altText, selectNode: e.selectNode,
|
|
1151
|
+
subCommand: e.args.item.subCommand
|
|
1152
|
+
});
|
|
1153
|
+
this.dialogObj.hide({ returnValue: false });
|
|
1154
|
+
if (this.parent.iframeSettings.enable) {
|
|
1155
|
+
this.parent.inputElement.focus({ preventScroll: true });
|
|
1156
|
+
}
|
|
1157
|
+
else {
|
|
1158
|
+
e.selectNode[0].focus({ preventScroll: true });
|
|
1159
|
+
}
|
|
1160
|
+
e.selection.restore();
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
Image.prototype.handleKeyDown = function () {
|
|
1164
|
+
var linkelem = this.parent.element.querySelector('#' + this.rteID + '_image_dialog-content');
|
|
1165
|
+
var linkUrl = linkelem.querySelector('.e-img-link');
|
|
1166
|
+
if (linkUrl.classList.contains('e-error') && (linkUrl.value.length >= 1 && linkUrl.value.trim() !== ' ')) {
|
|
1167
|
+
ej2_base_1.removeClass([linkUrl], 'e-error');
|
|
1168
|
+
}
|
|
1169
|
+
};
|
|
1170
|
+
Image.prototype.insertlink = function (e) {
|
|
1171
|
+
if (e.selectNode[0].nodeName !== 'IMG') {
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1174
|
+
var url = e.link.value;
|
|
1175
|
+
if (url.trim() === '') {
|
|
1176
|
+
ej2_base_1.addClass([e.link], 'e-error');
|
|
1177
|
+
e.link.setSelectionRange(0, url.length);
|
|
1178
|
+
e.link.focus();
|
|
1179
|
+
ej2_base_1.EventHandler.add(e.link, 'input', this.handleKeyDown, this);
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
else {
|
|
1183
|
+
ej2_base_1.EventHandler.remove(e.link, 'input', this.handleKeyDown);
|
|
1184
|
+
ej2_base_1.removeClass([e.link], 'e-error');
|
|
1185
|
+
}
|
|
1186
|
+
if (!this.isUrl(url)) {
|
|
1187
|
+
if (!this.parent.enableAutoUrl) {
|
|
1188
|
+
url = url.indexOf('http') > -1 ? url : 'http://' + url;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
else {
|
|
1192
|
+
ej2_base_1.removeClass([e.link], 'e-error');
|
|
1193
|
+
}
|
|
1194
|
+
var proxy = e.selfImage;
|
|
1195
|
+
if (proxy.parent.editorMode === 'HTML') {
|
|
1196
|
+
e.selection.restore();
|
|
1197
|
+
}
|
|
1198
|
+
if (proxy.parent.formatter.getUndoRedoStack().length === 0) {
|
|
1199
|
+
proxy.parent.formatter.saveData();
|
|
1200
|
+
}
|
|
1201
|
+
if (e.selectNode[0].parentElement.nodeName === 'A') {
|
|
1202
|
+
proxy.parent.formatter.process(proxy.parent, e.args, e.args, {
|
|
1203
|
+
url: url, target: proxy.checkBoxObj.checked ? '_blank' : null, ariaLabel: proxy.checkBoxObj.checked ? this.i10n.getConstant('imageLinkAriaLabel') : null, selectNode: e.selectNode,
|
|
1204
|
+
subCommand: e.args.item.subCommand
|
|
1205
|
+
});
|
|
1206
|
+
proxy.dialogObj.hide({ returnValue: true });
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
proxy.parent.formatter.process(proxy.parent, e.args, e.args, {
|
|
1210
|
+
url: url, target: proxy.checkBoxObj.checked ? '_blank' : null, ariaLabel: proxy.checkBoxObj.checked ? this.i10n.getConstant('imageLinkAriaLabel') : null, selectNode: e.selectNode,
|
|
1211
|
+
subCommand: e.args.item.subCommand, selection: e.selection
|
|
1212
|
+
});
|
|
1213
|
+
var captionEle = ej2_base_1.closest(e.selectNode[0], '.e-img-caption');
|
|
1214
|
+
if (captionEle) {
|
|
1215
|
+
var captionSpan = ej2_base_1.select('.' + classes.CLS_IMG_INNER, captionEle);
|
|
1216
|
+
if (captionEle) {
|
|
1217
|
+
captionSpan.focus();
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
proxy.dialogObj.hide({ returnValue: false });
|
|
1221
|
+
};
|
|
1222
|
+
Image.prototype.isUrl = function (url) {
|
|
1223
|
+
var regExp = RegExp;
|
|
1224
|
+
var regexp = new regExp('(ftp|http|https)://(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@\\-\\/]))?', 'gi');
|
|
1225
|
+
return regexp.test(url);
|
|
1226
|
+
};
|
|
1227
|
+
Image.prototype.deleteImg = function (e, keyCode) {
|
|
1228
|
+
if (e.selectNode[0].nodeName !== 'IMG') {
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
var args = {
|
|
1232
|
+
element: e.selectNode[0],
|
|
1233
|
+
src: e.selectNode[0].getAttribute('src')
|
|
1234
|
+
};
|
|
1235
|
+
if (this.parent.formatter.getUndoRedoStack().length === 0) {
|
|
1236
|
+
this.parent.formatter.saveData();
|
|
1237
|
+
}
|
|
1238
|
+
var restoreStartElement = e.selection.range.startContainer;
|
|
1239
|
+
if (e.selection.range.startContainer.nodeName === 'SPAN' &&
|
|
1240
|
+
restoreStartElement.classList.contains('e-img-wrap') &&
|
|
1241
|
+
restoreStartElement.parentElement.classList.contains('e-img-caption')) {
|
|
1242
|
+
restoreStartElement = restoreStartElement.parentElement;
|
|
1243
|
+
if (!ej2_base_1.isNullOrUndefined(restoreStartElement.previousSibling)) {
|
|
1244
|
+
var lastNode = restoreStartElement.previousSibling;
|
|
1245
|
+
while (lastNode.nodeName !== '#text' && lastNode.nodeName !== 'BR') {
|
|
1246
|
+
lastNode = lastNode.lastChild;
|
|
1247
|
+
}
|
|
1248
|
+
this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.contentModule.getDocument(), lastNode, lastNode.nodeName !== 'BR' ? lastNode.textContent.length : 0);
|
|
1249
|
+
}
|
|
1250
|
+
else if (!ej2_base_1.isNullOrUndefined(restoreStartElement.nextSibling)) {
|
|
1251
|
+
var firstNode = restoreStartElement.nextSibling;
|
|
1252
|
+
while (firstNode.nodeName !== '#text' && firstNode.nodeName !== 'BR') {
|
|
1253
|
+
firstNode = firstNode.firstChild;
|
|
1254
|
+
}
|
|
1255
|
+
this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.contentModule.getDocument(), firstNode, 0);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
else {
|
|
1259
|
+
e.selection.restore();
|
|
1260
|
+
}
|
|
1261
|
+
if (this.contentModule.getEditPanel().querySelector('.e-img-resize')) {
|
|
1262
|
+
this.removeResizeEle();
|
|
1263
|
+
}
|
|
1264
|
+
this.parent.formatter.process(this.parent, e.args, e.args, {
|
|
1265
|
+
selectNode: e.selectNode,
|
|
1266
|
+
captionClass: classes.CLS_CAPTION,
|
|
1267
|
+
subCommand: e.args.item.subCommand
|
|
1268
|
+
});
|
|
1269
|
+
if (this.quickToolObj && document.body.contains(this.quickToolObj.imageQTBar.element)) {
|
|
1270
|
+
this.quickToolObj.imageQTBar.hidePopup();
|
|
1271
|
+
}
|
|
1272
|
+
this.cancelResizeAction();
|
|
1273
|
+
if (ej2_base_1.isNullOrUndefined(keyCode)) {
|
|
1274
|
+
this.parent.trigger(events.afterImageDelete, args);
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
Image.prototype.caption = function (e) {
|
|
1278
|
+
var selectNode = e.selectNode[0];
|
|
1279
|
+
if (selectNode.nodeName !== 'IMG') {
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
e.selection.restore();
|
|
1283
|
+
if (this.parent.formatter.getUndoRedoStack().length === 0) {
|
|
1284
|
+
this.parent.formatter.saveData();
|
|
1285
|
+
}
|
|
1286
|
+
this.cancelResizeAction();
|
|
1287
|
+
ej2_base_1.addClass([selectNode], 'e-rte-image');
|
|
1288
|
+
var subCommand = (e.args.item) ?
|
|
1289
|
+
e.args.item.subCommand : 'Caption';
|
|
1290
|
+
if (!ej2_base_1.isNullOrUndefined(ej2_base_1.closest(selectNode, '.' + classes.CLS_CAPTION))) {
|
|
1291
|
+
ej2_base_1.detach(ej2_base_1.closest(selectNode, '.' + classes.CLS_CAPTION));
|
|
1292
|
+
if (ej2_base_1.Browser.isIE) {
|
|
1293
|
+
this.contentModule.getEditPanel().focus();
|
|
1294
|
+
e.selection.restore();
|
|
1295
|
+
}
|
|
1296
|
+
if (selectNode.parentElement.tagName === 'A') {
|
|
1297
|
+
this.parent.formatter.process(this.parent, e.args, e.args, { insertElement: selectNode.parentElement, selectNode: e.selectNode, subCommand: subCommand });
|
|
1298
|
+
}
|
|
1299
|
+
else {
|
|
1300
|
+
this.parent.formatter.process(this.parent, e.args, e.args, { insertElement: selectNode, selectNode: e.selectNode, subCommand: subCommand });
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
else {
|
|
1304
|
+
this.captionEle = this.parent.createElement('span', {
|
|
1305
|
+
className: classes.CLS_CAPTION + ' ' + classes.CLS_RTE_CAPTION + this.parent.getCssClass(true),
|
|
1306
|
+
attrs: { contenteditable: 'false', draggable: 'false', style: 'width:' + this.parent.insertImageSettings.width }
|
|
1307
|
+
});
|
|
1308
|
+
var imgWrap = this.parent.createElement('span', { className: 'e-img-wrap' + this.parent.getCssClass(true) });
|
|
1309
|
+
var imgInner = this.parent.createElement('span', { className: 'e-img-inner' + this.parent.getCssClass(true),
|
|
1310
|
+
attrs: { contenteditable: 'true' } });
|
|
1311
|
+
var parent_1 = e.selectNode[0].parentElement;
|
|
1312
|
+
if (parent_1.tagName === 'A') {
|
|
1313
|
+
parent_1.setAttribute('contenteditable', 'true');
|
|
1314
|
+
}
|
|
1315
|
+
imgWrap.appendChild(parent_1.tagName === 'A' ? parent_1 : e.selectNode[0]);
|
|
1316
|
+
imgWrap.appendChild(imgInner);
|
|
1317
|
+
var imgCaption = this.i10n.getConstant('imageCaption');
|
|
1318
|
+
imgInner.innerHTML = imgCaption;
|
|
1319
|
+
this.captionEle.appendChild(imgWrap);
|
|
1320
|
+
if (selectNode.classList.contains(classes.CLS_IMGINLINE)) {
|
|
1321
|
+
ej2_base_1.addClass([this.captionEle], classes.CLS_CAPINLINE);
|
|
1322
|
+
}
|
|
1323
|
+
if (selectNode.classList.contains(classes.CLS_IMGBREAK)) {
|
|
1324
|
+
ej2_base_1.addClass([this.captionEle], classes.CLS_IMGBREAK);
|
|
1325
|
+
}
|
|
1326
|
+
if (selectNode.classList.contains(classes.CLS_IMGLEFT)) {
|
|
1327
|
+
ej2_base_1.addClass([this.captionEle], classes.CLS_IMGLEFT);
|
|
1328
|
+
}
|
|
1329
|
+
if (selectNode.classList.contains(classes.CLS_IMGRIGHT)) {
|
|
1330
|
+
ej2_base_1.addClass([this.captionEle], classes.CLS_IMGRIGHT);
|
|
1331
|
+
}
|
|
1332
|
+
if (selectNode.classList.contains(classes.CLS_IMGCENTER)) {
|
|
1333
|
+
ej2_base_1.addClass([this.captionEle], classes.CLS_IMGCENTER);
|
|
1334
|
+
}
|
|
1335
|
+
this.parent.formatter.process(this.parent, e.args, e.args, { insertElement: this.captionEle, selectNode: e.selectNode, subCommand: subCommand });
|
|
1336
|
+
this.parent.formatter.editorManager.nodeSelection.setSelectionText(this.contentModule.getDocument(), imgInner.childNodes[0], imgInner.childNodes[0], 0, imgInner.childNodes[0].textContent.length);
|
|
1337
|
+
}
|
|
1338
|
+
if (this.quickToolObj && document.body.contains(this.quickToolObj.imageQTBar.element)) {
|
|
1339
|
+
this.quickToolObj.imageQTBar.hidePopup();
|
|
1340
|
+
ej2_base_1.removeClass([selectNode], 'e-img-focus');
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
Image.prototype.imageSize = function (e) {
|
|
1344
|
+
var _this = this;
|
|
1345
|
+
if (e.selectNode[0].nodeName !== 'IMG') {
|
|
1346
|
+
return;
|
|
1347
|
+
}
|
|
1348
|
+
this.imagDialog(e);
|
|
1349
|
+
if (!ej2_base_1.isNullOrUndefined(this.dialogObj)) {
|
|
1350
|
+
var imgSizeHeader = this.i10n.getConstant('imageSizeHeader');
|
|
1351
|
+
var linkUpdate = this.i10n.getConstant('dialogUpdate');
|
|
1352
|
+
this.changedHeightValue = null;
|
|
1353
|
+
this.changedWidthValue = null;
|
|
1354
|
+
var dialogContent = this.imgsizeInput(e);
|
|
1355
|
+
var selectObj_1 = { args: e.args, selfImage: this, selection: e.selection, selectNode: e.selectNode };
|
|
1356
|
+
this.dialogObj.setProperties({
|
|
1357
|
+
width: '290px', header: imgSizeHeader, content: dialogContent,
|
|
1358
|
+
buttons: [{
|
|
1359
|
+
click: function (e) {
|
|
1360
|
+
_this.insertSize(selectObj_1);
|
|
1361
|
+
},
|
|
1362
|
+
buttonModel: {
|
|
1363
|
+
content: linkUpdate, cssClass: 'e-flat e-update-size' + this.parent.getCssClass(true), isPrimary: true
|
|
1364
|
+
}
|
|
1365
|
+
}],
|
|
1366
|
+
cssClass: this.dialogObj.cssClass + ' e-rte-img-size-dialog'
|
|
1367
|
+
});
|
|
1368
|
+
if (!ej2_base_1.isNullOrUndefined(this.parent.cssClass)) {
|
|
1369
|
+
this.dialogObj.setProperties({ cssClass: this.parent.cssClass });
|
|
1370
|
+
}
|
|
1371
|
+
this.dialogObj.element.style.maxHeight = 'inherit';
|
|
1372
|
+
this.dialogObj.content.querySelector('input').focus();
|
|
1373
|
+
}
|
|
1374
|
+
};
|
|
1375
|
+
Image.prototype.break = function (e) {
|
|
1376
|
+
if (e.selectNode[0].nodeName !== 'IMG') {
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
var subCommand = e.args.item.subCommand;
|
|
1380
|
+
this.parent.formatter.process(this.parent, e.args, e.args, { selectNode: e.selectNode, subCommand: subCommand });
|
|
1381
|
+
};
|
|
1382
|
+
Image.prototype.inline = function (e) {
|
|
1383
|
+
if (e.selectNode[0].nodeName !== 'IMG') {
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
var subCommand = e.args.item.subCommand;
|
|
1387
|
+
this.parent.formatter.process(this.parent, e.args, e.args, { selectNode: e.selectNode, subCommand: subCommand });
|
|
1388
|
+
};
|
|
1389
|
+
Image.prototype.alignImage = function (e) {
|
|
1390
|
+
var subCommand = e.args.item.subCommand;
|
|
1391
|
+
this.parent.formatter.process(this.parent, e.args, e.args, { selectNode: e.selectNode, subCommand: subCommand });
|
|
1392
|
+
};
|
|
1393
|
+
Image.prototype.clearDialogObj = function () {
|
|
1394
|
+
if (this.uploadObj && !this.uploadObj.isDestroyed) {
|
|
1395
|
+
this.uploadObj.destroy();
|
|
1396
|
+
ej2_base_1.detach(this.uploadObj.element);
|
|
1397
|
+
this.uploadObj = null;
|
|
1398
|
+
}
|
|
1399
|
+
if (this.checkBoxObj && !this.checkBoxObj.isDestroyed) {
|
|
1400
|
+
this.checkBoxObj.destroy();
|
|
1401
|
+
ej2_base_1.detach(this.checkBoxObj.element);
|
|
1402
|
+
this.checkBoxObj = null;
|
|
1403
|
+
}
|
|
1404
|
+
if (this.popupObj && !this.popupObj.isDestroyed) {
|
|
1405
|
+
this.popupObj.destroy();
|
|
1406
|
+
ej2_base_1.detach(this.popupObj.element);
|
|
1407
|
+
this.popupObj = null;
|
|
1408
|
+
}
|
|
1409
|
+
if (this.widthNum && !this.widthNum.isDestroyed) {
|
|
1410
|
+
this.widthNum.destroy();
|
|
1411
|
+
ej2_base_1.detach(this.widthNum.element);
|
|
1412
|
+
this.widthNum = null;
|
|
1413
|
+
}
|
|
1414
|
+
if (this.heightNum && !this.heightNum.isDestroyed) {
|
|
1415
|
+
this.heightNum.destroy();
|
|
1416
|
+
ej2_base_1.detach(this.heightNum.element);
|
|
1417
|
+
this.heightNum = null;
|
|
1418
|
+
}
|
|
1419
|
+
if (this.browseButton && !this.browseButton.isDestroyed) {
|
|
1420
|
+
this.browseButton.destroy();
|
|
1421
|
+
ej2_base_1.detach(this.browseButton.element);
|
|
1422
|
+
this.browseButton = null;
|
|
1423
|
+
}
|
|
1424
|
+
if (this.dialogObj && !this.dialogObj.isDestroyed) {
|
|
1425
|
+
if ((this.dialogObj.element && this.dialogObj.element.querySelector('.e-img-link') && this.dialogObj.element.querySelector('.e-img-link') !== null)) {
|
|
1426
|
+
ej2_base_1.EventHandler.remove(this.dialogObj.element.querySelector('.e-img-link'), 'input', this.handleKeyDown);
|
|
1427
|
+
}
|
|
1428
|
+
this.dialogObj.destroy();
|
|
1429
|
+
ej2_base_1.detach(this.dialogObj.element);
|
|
1430
|
+
this.dialogObj = null;
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1433
|
+
Image.prototype.imagDialog = function (e) {
|
|
1434
|
+
var _this = this;
|
|
1435
|
+
if (this.dialogObj) {
|
|
1436
|
+
this.dialogObj.hide({ returnValue: true });
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
var imgDialog = this.parent.createElement('div', { className: 'e-rte-img-dialog' + this.parent.getCssClass(true), id: this.rteID + '_image' });
|
|
1440
|
+
this.parent.rootContainer.appendChild(imgDialog);
|
|
1441
|
+
var imgInsert = this.i10n.getConstant('dialogInsert');
|
|
1442
|
+
var imglinkCancel = this.i10n.getConstant('dialogCancel');
|
|
1443
|
+
var imgHeader = this.i10n.getConstant('imageHeader');
|
|
1444
|
+
var selection = e.selection;
|
|
1445
|
+
var selectObj = { selfImage: this, selection: e.selection, args: e.args, selectParent: e.selectParent };
|
|
1446
|
+
var dialogModel = {
|
|
1447
|
+
header: imgHeader,
|
|
1448
|
+
cssClass: classes.CLS_RTE_ELEMENTS + this.parent.getCssClass(true),
|
|
1449
|
+
enableRtl: this.parent.enableRtl,
|
|
1450
|
+
locale: this.parent.locale,
|
|
1451
|
+
showCloseIcon: true, closeOnEscape: true, width: (ej2_base_1.Browser.isDevice) ? '290px' : '340px',
|
|
1452
|
+
isModal: ej2_base_1.Browser.isDevice,
|
|
1453
|
+
buttons: [{
|
|
1454
|
+
click: this.insertImageUrl.bind(selectObj),
|
|
1455
|
+
buttonModel: { content: imgInsert, cssClass: 'e-flat e-insertImage' + this.parent.getCssClass(true), isPrimary: true, disabled: this.parent.editorMode === 'Markdown' ? false : true }
|
|
1456
|
+
},
|
|
1457
|
+
{
|
|
1458
|
+
click: this.cancelDialog.bind(this),
|
|
1459
|
+
buttonModel: { cssClass: 'e-flat e-cancel' + this.parent.getCssClass(true), content: imglinkCancel }
|
|
1460
|
+
}],
|
|
1461
|
+
target: (ej2_base_1.Browser.isDevice) ? document.body : this.parent.element,
|
|
1462
|
+
animationSettings: { effect: 'None' },
|
|
1463
|
+
close: function (event) {
|
|
1464
|
+
if (event && event.closedBy !== 'user action' && _this.uploadObj && _this.uploadObj.filesData.length > 0) {
|
|
1465
|
+
_this.uploadObj.remove();
|
|
1466
|
+
}
|
|
1467
|
+
_this.parent.isBlur = false;
|
|
1468
|
+
if (event && !ej2_base_1.isNullOrUndefined(event.event) && event.event.returnValue) {
|
|
1469
|
+
if (_this.parent.editorMode === 'HTML') {
|
|
1470
|
+
selection.restore();
|
|
1471
|
+
}
|
|
1472
|
+
else {
|
|
1473
|
+
_this.parent.formatter.editorManager.markdownSelection.restore(_this.parent.contentModule.getEditPanel());
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
_this.clearDialogObj();
|
|
1477
|
+
_this.dialogRenderObj.close(event);
|
|
1478
|
+
}
|
|
1479
|
+
};
|
|
1480
|
+
var dialogContent = this.parent.createElement('div', { className: 'e-img-content' + this.parent.getCssClass(true) });
|
|
1481
|
+
if ((!ej2_base_1.isNullOrUndefined(this.parent.insertImageSettings.path) && this.parent.editorMode === 'Markdown')
|
|
1482
|
+
|| this.parent.editorMode === 'HTML') {
|
|
1483
|
+
dialogContent.appendChild(this.imgUpload(e));
|
|
1484
|
+
}
|
|
1485
|
+
var linkHeader = this.parent.createElement('div', { className: 'e-linkheader' + this.parent.getCssClass(true) });
|
|
1486
|
+
var linkHeaderText = this.i10n.getConstant('imageLinkHeader');
|
|
1487
|
+
if (this.parent.editorMode === 'HTML') {
|
|
1488
|
+
linkHeader.innerHTML = linkHeaderText;
|
|
1489
|
+
}
|
|
1490
|
+
else {
|
|
1491
|
+
linkHeader.innerHTML = this.i10n.getConstant('mdimageLink');
|
|
1492
|
+
}
|
|
1493
|
+
dialogContent.appendChild(linkHeader);
|
|
1494
|
+
dialogContent.appendChild(this.imageUrlPopup(e));
|
|
1495
|
+
if (e.selectNode && e.selectNode[0].nodeName === 'IMG') {
|
|
1496
|
+
dialogModel.header = this.parent.localeObj.getConstant('editImageHeader');
|
|
1497
|
+
dialogModel.content = dialogContent;
|
|
1498
|
+
dialogModel.buttons[0].buttonModel.cssClass = dialogModel.buttons[0].buttonModel.cssClass + ' e-updateImage';
|
|
1499
|
+
}
|
|
1500
|
+
else {
|
|
1501
|
+
dialogModel.content = dialogContent;
|
|
1502
|
+
}
|
|
1503
|
+
this.dialogObj = this.dialogRenderObj.render(dialogModel);
|
|
1504
|
+
this.dialogObj.createElement = this.parent.createElement;
|
|
1505
|
+
this.dialogObj.appendTo(imgDialog);
|
|
1506
|
+
if (ej2_base_1.isNullOrUndefined(this.dialogObj)) {
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1509
|
+
if (e.selectNode && e.selectNode[0].nodeName === 'IMG' && (e.name === 'insertImage')) {
|
|
1510
|
+
this.dialogObj.element.querySelector('.e-insertImage').textContent = this.parent.localeObj.getConstant('dialogUpdate');
|
|
1511
|
+
}
|
|
1512
|
+
imgDialog.style.maxHeight = 'inherit';
|
|
1513
|
+
if (this.quickToolObj) {
|
|
1514
|
+
if (this.quickToolObj.imageQTBar && document.body.contains(this.quickToolObj.imageQTBar.element)) {
|
|
1515
|
+
this.quickToolObj.imageQTBar.hidePopup();
|
|
1516
|
+
if (!ej2_base_1.isNullOrUndefined(e.selectParent)) {
|
|
1517
|
+
ej2_base_1.removeClass([e.selectParent[0]], 'e-img-focus');
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
if (this.quickToolObj.inlineQTBar && document.body.contains(this.quickToolObj.inlineQTBar.element)) {
|
|
1521
|
+
this.quickToolObj.inlineQTBar.hidePopup();
|
|
1522
|
+
}
|
|
1523
|
+
if (this.quickToolObj.textQTBar && this.parent.element.ownerDocument.body.contains(this.quickToolObj.textQTBar.element)) {
|
|
1524
|
+
this.quickToolObj.textQTBar.hidePopup();
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
};
|
|
1528
|
+
Image.prototype.cancelDialog = function () {
|
|
1529
|
+
this.parent.isBlur = false;
|
|
1530
|
+
if (!ej2_base_1.isNullOrUndefined(this.uploadObj) && this.uploadObj.filesData.length > 0) {
|
|
1531
|
+
this.uploadObj.remove();
|
|
1532
|
+
}
|
|
1533
|
+
this.dialogObj.hide({ returnValue: true });
|
|
1534
|
+
};
|
|
1535
|
+
Image.prototype.onDocumentClick = function (e) {
|
|
1536
|
+
var target = e.target;
|
|
1537
|
+
if (ej2_base_1.isNullOrUndefined(this.contentModule.getEditPanel())) {
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
if (target.nodeName === 'IMG') {
|
|
1541
|
+
this.imgEle = target;
|
|
1542
|
+
}
|
|
1543
|
+
if (!this.parent) {
|
|
1544
|
+
return;
|
|
1545
|
+
}
|
|
1546
|
+
if (target.nodeName !== '#document') {
|
|
1547
|
+
this.parent.currentTarget = e.target;
|
|
1548
|
+
}
|
|
1549
|
+
if (!ej2_base_1.isNullOrUndefined(this.dialogObj) && ((!ej2_base_1.closest(target, '[id=' + "'" + this.dialogObj.element.id + "'" + ']') && this.parent.toolbarSettings.enable && this.parent.getToolbarElement() &&
|
|
1550
|
+
!this.parent.getToolbarElement().contains(e.target)) ||
|
|
1551
|
+
(this.parent.getToolbarElement() && this.parent.getToolbarElement().contains(e.target) &&
|
|
1552
|
+
!ej2_base_1.closest(target, '#' + this.parent.getID() + '_toolbar_Image') &&
|
|
1553
|
+
!target.querySelector('#' + this.parent.getID() + '_toolbar_Image')))) {
|
|
1554
|
+
if (e.offsetX > e.target.clientWidth || e.offsetY > e.target.clientHeight) {
|
|
1555
|
+
}
|
|
1556
|
+
else {
|
|
1557
|
+
this.parent.notify(events.documentClickClosedBy, { closedBy: "outside click" });
|
|
1558
|
+
this.dialogObj.hide({ returnValue: true });
|
|
1559
|
+
this.parent.isBlur = true;
|
|
1560
|
+
util_2.dispatchEvent(this.parent.element, 'focusout');
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
if (!(this.parent.iframeSettings.enable && !ej2_base_1.isNullOrUndefined(this.parent.currentTarget) && this.parent.currentTarget.nodeName === 'IMG') &&
|
|
1564
|
+
e.target.tagName !== 'IMG' && this.imgResizeDiv && !(this.quickToolObj &&
|
|
1565
|
+
this.quickToolObj.imageQTBar && this.quickToolObj.imageQTBar.element.contains(e.target)) &&
|
|
1566
|
+
this.contentModule.getEditPanel().contains(this.imgResizeDiv)) {
|
|
1567
|
+
this.cancelResizeAction();
|
|
1568
|
+
}
|
|
1569
|
+
if (this.contentModule.getEditPanel().querySelector('.e-img-resize') && !(this.parent.iframeSettings.enable && this.parent.currentTarget.nodeName === 'IMG')) {
|
|
1570
|
+
if (target.tagName !== 'IMG') {
|
|
1571
|
+
this.removeResizeEle();
|
|
1572
|
+
}
|
|
1573
|
+
if (target.tagName !== 'IMG' && !ej2_base_1.isNullOrUndefined(this.imgEle)) {
|
|
1574
|
+
this.imgEle.style.outline = '';
|
|
1575
|
+
}
|
|
1576
|
+
else if (!ej2_base_1.isNullOrUndefined(this.prevSelectedImgEle) && this.prevSelectedImgEle !== target) {
|
|
1577
|
+
this.prevSelectedImgEle.style.outline = '';
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
if (target.tagName !== 'IMG') {
|
|
1581
|
+
var items = this.contentModule.getEditPanel().querySelectorAll('img');
|
|
1582
|
+
for (var i = 0; i < items.length; i++) {
|
|
1583
|
+
ej2_base_1.removeClass([items[i]], 'e-img-focus');
|
|
1584
|
+
ej2_base_1.removeClass([items[i]], 'e-resize');
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
if (this.parent.inlineMode.enable && target && this.dialogObj && !ej2_base_1.closest(target, '#' + this.dialogObj.element.id)) {
|
|
1588
|
+
this.dialogObj.hide();
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1591
|
+
Image.prototype.removeResizeEle = function () {
|
|
1592
|
+
ej2_base_1.EventHandler.remove(this.contentModule.getDocument(), ej2_base_1.Browser.touchMoveEvent, this.resizing);
|
|
1593
|
+
ej2_base_1.EventHandler.remove(this.contentModule.getDocument(), ej2_base_1.Browser.touchEndEvent, this.resizeEnd);
|
|
1594
|
+
ej2_base_1.detach(this.contentModule.getEditPanel().querySelector('.e-img-resize'));
|
|
1595
|
+
};
|
|
1596
|
+
Image.prototype.onWindowResize = function () {
|
|
1597
|
+
if (!ej2_base_1.isNullOrUndefined(this.contentModule) && !ej2_base_1.isNullOrUndefined(this.contentModule.getEditPanel().querySelector('.e-img-resize'))) {
|
|
1598
|
+
this.cancelResizeAction();
|
|
1599
|
+
}
|
|
1600
|
+
};
|
|
1601
|
+
Image.prototype.imageUrlPopup = function (e) {
|
|
1602
|
+
var _this = this;
|
|
1603
|
+
var imgUrl = this.parent.createElement('div', { className: 'imgUrl' + this.parent.getCssClass(true) });
|
|
1604
|
+
var placeUrl = this.i10n.getConstant('imageUrl');
|
|
1605
|
+
this.inputUrl = this.parent.createElement('input', {
|
|
1606
|
+
className: 'e-input e-img-url' + this.parent.getCssClass(true),
|
|
1607
|
+
attrs: { placeholder: placeUrl, spellcheck: 'false', 'aria-label': this.i10n.getConstant('imageLinkHeader') }
|
|
1608
|
+
});
|
|
1609
|
+
this.inputUrl.addEventListener('input', function () {
|
|
1610
|
+
if (!ej2_base_1.isNullOrUndefined(_this.inputUrl)) {
|
|
1611
|
+
if (_this.inputUrl.value.length === 0) {
|
|
1612
|
+
_this.dialogObj.getButtons(0).element.disabled = true;
|
|
1613
|
+
}
|
|
1614
|
+
else {
|
|
1615
|
+
_this.dialogObj.getButtons(0).element.removeAttribute('disabled');
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
});
|
|
1619
|
+
if (e.selectNode && e.selectNode[0].nodeName === 'IMG') {
|
|
1620
|
+
var regex = new RegExp(/([^\S]|^)(((https?:\/\/)|(www\.))(\S+))/gi);
|
|
1621
|
+
this.inputUrl.value = e.selectNode[0].src.match(regex) ? e.selectNode[0].src : '';
|
|
1622
|
+
}
|
|
1623
|
+
imgUrl.appendChild(this.inputUrl);
|
|
1624
|
+
return imgUrl;
|
|
1625
|
+
};
|
|
1626
|
+
Image.prototype.insertImageUrl = function (e) {
|
|
1627
|
+
var proxy = this.selfImage;
|
|
1628
|
+
proxy.isImgUploaded = false;
|
|
1629
|
+
var url = proxy.inputUrl.value;
|
|
1630
|
+
if (e.target && e.target.nodeName === 'BUTTON' && e.target.classList.contains('e-updateImage')) {
|
|
1631
|
+
var element = this.selectNode && this.selectNode[0] && this.selectNode[0].nodeName === 'IMG' ?
|
|
1632
|
+
this.selectNode[0] : null;
|
|
1633
|
+
var args = {
|
|
1634
|
+
element: element,
|
|
1635
|
+
src: url
|
|
1636
|
+
};
|
|
1637
|
+
proxy.parent.trigger(events.afterImageDelete, args);
|
|
1638
|
+
}
|
|
1639
|
+
if (proxy.parent.editorMode === 'Markdown' && url === '') {
|
|
1640
|
+
url = 'http://';
|
|
1641
|
+
}
|
|
1642
|
+
if (proxy.parent.formatter.getUndoRedoStack().length === 0) {
|
|
1643
|
+
proxy.parent.formatter.saveData();
|
|
1644
|
+
}
|
|
1645
|
+
var previousSubCommand = this.args.item.subCommand;
|
|
1646
|
+
this.args.item.subCommand = e.target.innerHTML === 'Update' ? 'Replace' : this.args.item.subCommand;
|
|
1647
|
+
if (!ej2_base_1.isNullOrUndefined(proxy.uploadUrl) && proxy.uploadUrl.url !== '') {
|
|
1648
|
+
proxy.uploadUrl.cssClass = ((this.selectParent && this.selectParent[0].classList && this.selectParent[0].classList.contains('e-imgbreak') === true)) ? classes.CLS_IMGBREAK : (proxy.parent.insertImageSettings.display === 'inline' ?
|
|
1649
|
+
classes.CLS_IMGINLINE : classes.CLS_IMGBREAK);
|
|
1650
|
+
proxy.dialogObj.hide({ returnValue: false });
|
|
1651
|
+
if (proxy.dialogObj !== null) {
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1654
|
+
proxy.parent.formatter.process(proxy.parent, this.args, this.args.originalEvent, proxy.uploadUrl);
|
|
1655
|
+
proxy.uploadUrl.url = '';
|
|
1656
|
+
if (proxy.contentModule.getEditPanel().querySelector('.e-img-resize')) {
|
|
1657
|
+
proxy.imgEle.style.outline = '';
|
|
1658
|
+
proxy.removeResizeEle();
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
else if (url !== '') {
|
|
1662
|
+
if (proxy.parent.editorMode === 'HTML' && ej2_base_1.isNullOrUndefined(ej2_base_1.closest(this.selection.range.startContainer.parentNode, '[id=' + "'" + proxy.contentModule.getPanel().id + "'" + ']'))) {
|
|
1663
|
+
if (proxy.contentModule.getPanel().tagName === 'IFRAME' && this.args.item.subCommand === 'Replace') {
|
|
1664
|
+
proxy.contentModule.getPanel();
|
|
1665
|
+
}
|
|
1666
|
+
else {
|
|
1667
|
+
proxy.contentModule.getEditPanel();
|
|
1668
|
+
}
|
|
1669
|
+
var range = proxy.parent.formatter.editorManager.nodeSelection.getRange(proxy.contentModule.getDocument());
|
|
1670
|
+
this.selection = proxy.parent.formatter.editorManager.nodeSelection.save(range, proxy.contentModule.getDocument());
|
|
1671
|
+
this.selectParent = proxy.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range);
|
|
1672
|
+
}
|
|
1673
|
+
var regex = /[\w-]+.(jpg|png|jpeg|gif)/g;
|
|
1674
|
+
var matchUrl = (!ej2_base_1.isNullOrUndefined(url.match(regex)) && proxy.parent.editorMode === 'HTML') ? url.match(regex)[0] : '';
|
|
1675
|
+
var value = {
|
|
1676
|
+
cssClass: ((this.selectParent && this.selectParent[0].classList && this.selectParent[0].classList.contains('e-imgbreak') === true)) ? classes.CLS_IMGBREAK : (proxy.parent.insertImageSettings.display === 'inline' ? classes.CLS_IMGINLINE : classes.CLS_IMGBREAK),
|
|
1677
|
+
url: url, selection: this.selection, altText: matchUrl,
|
|
1678
|
+
selectParent: this.selectParent, width: {
|
|
1679
|
+
width: proxy.parent.insertImageSettings.width, minWidth: proxy.parent.insertImageSettings.minWidth,
|
|
1680
|
+
maxWidth: proxy.parent.getInsertImgMaxWidth()
|
|
1681
|
+
},
|
|
1682
|
+
height: {
|
|
1683
|
+
height: proxy.parent.insertImageSettings.height, minHeight: proxy.parent.insertImageSettings.minHeight,
|
|
1684
|
+
maxHeight: proxy.parent.insertImageSettings.maxHeight
|
|
1685
|
+
}
|
|
1686
|
+
};
|
|
1687
|
+
proxy.dialogObj.hide({ returnValue: false });
|
|
1688
|
+
if (proxy.dialogObj !== null) {
|
|
1689
|
+
return;
|
|
1690
|
+
}
|
|
1691
|
+
proxy.parent.formatter.process(proxy.parent, this.args, this.args.originalEvent, value);
|
|
1692
|
+
}
|
|
1693
|
+
this.args.item.subCommand = previousSubCommand;
|
|
1694
|
+
};
|
|
1695
|
+
Image.prototype.imgsizeInput = function (e) {
|
|
1696
|
+
var _this = this;
|
|
1697
|
+
var selectNode = e.selectNode[0];
|
|
1698
|
+
var imgHeight = this.i10n.getConstant('imageHeight');
|
|
1699
|
+
var imgWidth = this.i10n.getConstant('imageWidth');
|
|
1700
|
+
var imgSizeWrap = this.parent.createElement('div', { className: 'e-img-sizewrap' + this.parent.getCssClass(true) });
|
|
1701
|
+
var widthVal = ej2_base_1.isNullOrUndefined(this.changedWidthValue) && (selectNode.style.width.toString() === 'auto' ||
|
|
1702
|
+
selectNode.style.width !== '') ? selectNode.style.width : !ej2_base_1.isNullOrUndefined(this.changedWidthValue) ?
|
|
1703
|
+
this.changedWidthValue : (parseInt(selectNode.getClientRects()[0].width.toString(), 10)).toString();
|
|
1704
|
+
var heightVal = ej2_base_1.isNullOrUndefined(this.changedHeightValue) && (selectNode.style.height.toString() === 'auto' ||
|
|
1705
|
+
selectNode.style.height !== '') ? selectNode.style.height : !ej2_base_1.isNullOrUndefined(this.changedHeightValue) ?
|
|
1706
|
+
this.changedHeightValue : (parseInt(selectNode.getClientRects()[0].height.toString(), 10)).toString();
|
|
1707
|
+
if (selectNode.style.width === '') {
|
|
1708
|
+
widthVal = 'auto';
|
|
1709
|
+
}
|
|
1710
|
+
if (selectNode.style.height === '') {
|
|
1711
|
+
heightVal = 'auto';
|
|
1712
|
+
}
|
|
1713
|
+
this.changedWidthValue = null;
|
|
1714
|
+
this.changedHeightValue = null;
|
|
1715
|
+
var content = '<div class="e-rte-label' + this.parent.getCssClass(true) + '"><label>' + imgWidth +
|
|
1716
|
+
'</label></div><div class="e-rte-field' + this.parent.getCssClass(true) + '"><input type="text" id="imgwidth" class="e-img-width' + this.parent.getCssClass(true) + '"/></div>' +
|
|
1717
|
+
'<div class="e-rte-label' + this.parent.getCssClass(true) + '">' + '<label>' + imgHeight + '</label></div><div class="e-rte-field' + this.parent.getCssClass(true) + '"> ' +
|
|
1718
|
+
'<input type="text" id="imgheight" class="e-img-height' + this.parent.getCssClass(true) + '"/></div>';
|
|
1719
|
+
var contentElem = util_2.parseHtml(content);
|
|
1720
|
+
contentElem.getElementById('imgwidth').setAttribute('value', widthVal);
|
|
1721
|
+
contentElem.getElementById('imgheight').setAttribute('value', heightVal);
|
|
1722
|
+
imgSizeWrap.appendChild(contentElem);
|
|
1723
|
+
this.widthNum = new ej2_inputs_1.TextBox({
|
|
1724
|
+
value: ej2_base_1.formatUnit(widthVal),
|
|
1725
|
+
enableRtl: this.parent.enableRtl,
|
|
1726
|
+
cssClass: this.parent.getCssClass(),
|
|
1727
|
+
input: function (e) {
|
|
1728
|
+
_this.inputWidthValue = ej2_base_1.formatUnit(_this.inputValue(e.value));
|
|
1729
|
+
}
|
|
1730
|
+
});
|
|
1731
|
+
this.widthNum.createElement = this.parent.createElement;
|
|
1732
|
+
this.widthNum.appendTo(imgSizeWrap.querySelector('#imgwidth'));
|
|
1733
|
+
this.heightNum = new ej2_inputs_1.TextBox({
|
|
1734
|
+
value: ej2_base_1.formatUnit(heightVal),
|
|
1735
|
+
enableRtl: this.parent.enableRtl,
|
|
1736
|
+
cssClass: this.parent.getCssClass(),
|
|
1737
|
+
input: function (e) {
|
|
1738
|
+
_this.inputHeightValue = ej2_base_1.formatUnit(_this.inputValue(e.value));
|
|
1739
|
+
}
|
|
1740
|
+
});
|
|
1741
|
+
this.heightNum.createElement = this.parent.createElement;
|
|
1742
|
+
this.heightNum.appendTo(imgSizeWrap.querySelector('#imgheight'));
|
|
1743
|
+
return imgSizeWrap;
|
|
1744
|
+
};
|
|
1745
|
+
Image.prototype.inputValue = function (value) {
|
|
1746
|
+
if (value === 'auto' || value.indexOf('%') !== -1 || value.indexOf('px') !== -1
|
|
1747
|
+
|| value.match(/(\d+)/)) {
|
|
1748
|
+
return value;
|
|
1749
|
+
}
|
|
1750
|
+
else {
|
|
1751
|
+
return 'auto';
|
|
1752
|
+
}
|
|
1753
|
+
};
|
|
1754
|
+
Image.prototype.insertSize = function (e) {
|
|
1755
|
+
e.selection.restore();
|
|
1756
|
+
var proxy = e.selfImage;
|
|
1757
|
+
if (proxy.parent.formatter.getUndoRedoStack().length === 0) {
|
|
1758
|
+
proxy.parent.formatter.saveData();
|
|
1759
|
+
}
|
|
1760
|
+
var dialogEle = proxy.dialogObj.element;
|
|
1761
|
+
this.changedWidthValue = this.inputWidthValue;
|
|
1762
|
+
this.changedHeightValue = this.inputHeightValue;
|
|
1763
|
+
var width = dialogEle.querySelector('.e-img-width').value;
|
|
1764
|
+
var height = dialogEle.parentElement.querySelector('.e-img-height').value;
|
|
1765
|
+
proxy.parent.formatter.process(this.parent, e.args, e.args, {
|
|
1766
|
+
width: width, height: height, selectNode: e.selectNode,
|
|
1767
|
+
subCommand: e.args.item.subCommand
|
|
1768
|
+
});
|
|
1769
|
+
if (this.imgResizeDiv) {
|
|
1770
|
+
proxy.imgResizePos(e.selectNode[0], this.imgResizeDiv);
|
|
1771
|
+
}
|
|
1772
|
+
proxy.dialogObj.hide({ returnValue: true });
|
|
1773
|
+
proxy.parent.inputElement.focus({ preventScroll: true });
|
|
1774
|
+
};
|
|
1775
|
+
Image.prototype.insertImage = function (e) {
|
|
1776
|
+
this.imagDialog(e);
|
|
1777
|
+
if (!ej2_base_1.isNullOrUndefined(this.dialogObj)) {
|
|
1778
|
+
this.dialogObj.element.style.maxHeight = 'inherit';
|
|
1779
|
+
var dialogContent = this.dialogObj.element.querySelector('.e-img-content');
|
|
1780
|
+
if (((!ej2_base_1.isNullOrUndefined(this.parent.insertImageSettings.path) && this.parent.editorMode === 'Markdown')
|
|
1781
|
+
|| this.parent.editorMode === 'HTML')) {
|
|
1782
|
+
document.getElementById(this.rteID + '_insertImage').focus();
|
|
1783
|
+
}
|
|
1784
|
+
else {
|
|
1785
|
+
dialogContent.querySelector('.e-img-url').focus();
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
Image.prototype.imgUpload = function (e) {
|
|
1790
|
+
var _this = this;
|
|
1791
|
+
var save;
|
|
1792
|
+
var selectParent;
|
|
1793
|
+
var proxy = this;
|
|
1794
|
+
var iframe = proxy.parent.iframeSettings.enable;
|
|
1795
|
+
if (proxy.parent.editorMode === 'HTML' && (!iframe && ej2_base_1.isNullOrUndefined(ej2_base_1.closest(e.selection.range.startContainer.parentNode, '[id='
|
|
1796
|
+
+ "'" + this.parent.contentModule.getPanel().id + "'" + ']'))
|
|
1797
|
+
|| (iframe && !util_2.hasClass(e.selection.range.startContainer.parentNode.ownerDocument.querySelector('body'), 'e-lib')))) {
|
|
1798
|
+
this.contentModule.getEditPanel().focus();
|
|
1799
|
+
var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
|
|
1800
|
+
save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
|
|
1801
|
+
selectParent = this.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range);
|
|
1802
|
+
}
|
|
1803
|
+
else {
|
|
1804
|
+
save = e.selection;
|
|
1805
|
+
selectParent = e.selectParent;
|
|
1806
|
+
}
|
|
1807
|
+
var uploadParentEle = this.parent.createElement('div', { className: 'e-img-uploadwrap e-droparea' + this.parent.getCssClass(true) });
|
|
1808
|
+
var deviceImgUpMsg = this.i10n.getConstant('imageDeviceUploadMessage');
|
|
1809
|
+
var imgUpMsg = this.i10n.getConstant('imageUploadMessage');
|
|
1810
|
+
var span = this.parent.createElement('span', { className: 'e-droptext' + this.parent.getCssClass(true) });
|
|
1811
|
+
var spanMsg = this.parent.createElement('span', {
|
|
1812
|
+
className: 'e-rte-upload-text' + this.parent.getCssClass(true), innerHTML: ((ej2_base_1.Browser.isDevice) ? deviceImgUpMsg : imgUpMsg)
|
|
1813
|
+
});
|
|
1814
|
+
span.appendChild(spanMsg);
|
|
1815
|
+
var btnEle = this.parent.createElement('button', {
|
|
1816
|
+
className: 'e-browsebtn' + this.parent.getCssClass(true), id: this.rteID + '_insertImage', attrs: { autofocus: 'true', type: 'button' }
|
|
1817
|
+
});
|
|
1818
|
+
span.appendChild(btnEle);
|
|
1819
|
+
uploadParentEle.appendChild(span);
|
|
1820
|
+
var browserMsg = this.i10n.getConstant('browse');
|
|
1821
|
+
this.browseButton = new ej2_buttons_1.Button({ content: browserMsg, enableRtl: this.parent.enableRtl });
|
|
1822
|
+
this.browseButton.isStringTemplate = true;
|
|
1823
|
+
this.browseButton.createElement = this.parent.createElement;
|
|
1824
|
+
this.browseButton.appendTo(btnEle);
|
|
1825
|
+
var btnClick = (ej2_base_1.Browser.isDevice) ? span : btnEle;
|
|
1826
|
+
ej2_base_1.EventHandler.add(btnClick, 'click', this.fileSelect, this);
|
|
1827
|
+
var uploadEle = this.parent.createElement('input', {
|
|
1828
|
+
id: this.rteID + '_upload', attrs: { type: 'File', name: 'UploadFiles' }, className: this.parent.getCssClass()
|
|
1829
|
+
});
|
|
1830
|
+
uploadParentEle.appendChild(uploadEle);
|
|
1831
|
+
var altText;
|
|
1832
|
+
var selectArgs;
|
|
1833
|
+
var filesData;
|
|
1834
|
+
var previousFileInfo = null;
|
|
1835
|
+
this.uploadObj = new ej2_inputs_1.Uploader({
|
|
1836
|
+
asyncSettings: { saveUrl: this.parent.insertImageSettings.saveUrl, removeUrl: this.parent.insertImageSettings.removeUrl },
|
|
1837
|
+
dropArea: span, multiple: false, enableRtl: this.parent.enableRtl, cssClass: this.parent.getCssClass(),
|
|
1838
|
+
allowedExtensions: this.parent.insertImageSettings.allowedTypes.toString(),
|
|
1839
|
+
selected: function (e) {
|
|
1840
|
+
proxy.isImgUploaded = true;
|
|
1841
|
+
selectArgs = e;
|
|
1842
|
+
filesData = e.filesData;
|
|
1843
|
+
_this.parent.trigger(events.imageSelected, selectArgs, function (selectArgs) {
|
|
1844
|
+
if (!selectArgs.cancel) {
|
|
1845
|
+
if (ej2_base_1.isNullOrUndefined(selectArgs.filesData[0])) {
|
|
1846
|
+
return;
|
|
1847
|
+
}
|
|
1848
|
+
_this.checkExtension(selectArgs.filesData[0]);
|
|
1849
|
+
altText = selectArgs.filesData[0].name.replace(/\.[a-zA-Z0-9]+$/, '');
|
|
1850
|
+
if (_this.parent.editorMode === 'HTML' && ej2_base_1.isNullOrUndefined(_this.parent.insertImageSettings.path)) {
|
|
1851
|
+
var reader_1 = new FileReader();
|
|
1852
|
+
reader_1.addEventListener('load', function (e) {
|
|
1853
|
+
var url = _this.parent.insertImageSettings.saveFormat === 'Base64' ? reader_1.result :
|
|
1854
|
+
URL.createObjectURL(util_2.convertToBlob(reader_1.result));
|
|
1855
|
+
proxy.uploadUrl = {
|
|
1856
|
+
url: url, selection: save, altText: altText,
|
|
1857
|
+
selectParent: selectParent,
|
|
1858
|
+
width: {
|
|
1859
|
+
width: proxy.parent.insertImageSettings.width, minWidth: proxy.parent.insertImageSettings.minWidth,
|
|
1860
|
+
maxWidth: proxy.parent.getInsertImgMaxWidth()
|
|
1861
|
+
}, height: {
|
|
1862
|
+
height: proxy.parent.insertImageSettings.height,
|
|
1863
|
+
minHeight: proxy.parent.insertImageSettings.minHeight,
|
|
1864
|
+
maxHeight: proxy.parent.insertImageSettings.maxHeight
|
|
1865
|
+
}
|
|
1866
|
+
};
|
|
1867
|
+
proxy.inputUrl.setAttribute('disabled', 'true');
|
|
1868
|
+
if (!ej2_base_1.isNullOrUndefined(_this.dialogObj)) {
|
|
1869
|
+
var button = _this.dialogObj.getButtons(0);
|
|
1870
|
+
if (!ej2_base_1.isNullOrUndefined(button)) {
|
|
1871
|
+
if (ej2_base_1.isNullOrUndefined(proxy.parent.insertImageSettings.saveUrl) && _this.isAllowedTypes
|
|
1872
|
+
&& selectArgs.filesData[0].size <= _this.uploadObj.maxFileSize) {
|
|
1873
|
+
button.element.removeAttribute('disabled');
|
|
1874
|
+
}
|
|
1875
|
+
else {
|
|
1876
|
+
button.element.setAttribute('disabled', 'true');
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
});
|
|
1881
|
+
reader_1.readAsDataURL(selectArgs.filesData[0].rawFile);
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
});
|
|
1885
|
+
},
|
|
1886
|
+
beforeUpload: function (args) {
|
|
1887
|
+
_this.parent.trigger(events.beforeImageUpload, args);
|
|
1888
|
+
},
|
|
1889
|
+
uploading: function (e) {
|
|
1890
|
+
if (!_this.parent.isServerRendered) {
|
|
1891
|
+
_this.parent.trigger(events.imageUploading, e);
|
|
1892
|
+
}
|
|
1893
|
+
},
|
|
1894
|
+
success: function (e) {
|
|
1895
|
+
e.detectImageSource = enum_1.ImageInputSource.Uploaded;
|
|
1896
|
+
_this.parent.trigger(events.imageUploadSuccess, e, function (e) {
|
|
1897
|
+
var isReplaceWithoutRemovalAction = false;
|
|
1898
|
+
if (!ej2_base_1.isNullOrUndefined(previousFileInfo) && previousFileInfo.name !== e.file.name && e.operation.toLocaleLowerCase() === 'remove') {
|
|
1899
|
+
isReplaceWithoutRemovalAction = true;
|
|
1900
|
+
}
|
|
1901
|
+
if (!ej2_base_1.isNullOrUndefined(_this.parent.insertImageSettings.path) && !isReplaceWithoutRemovalAction) {
|
|
1902
|
+
var url = _this.parent.insertImageSettings.path + (e).file.name;
|
|
1903
|
+
if (!ej2_base_1.isNullOrUndefined(previousFileInfo) && e.operation === 'upload') {
|
|
1904
|
+
_this.uploadObj.remove(previousFileInfo);
|
|
1905
|
+
}
|
|
1906
|
+
var value = { url: url, selection: save };
|
|
1907
|
+
proxy.uploadUrl = {
|
|
1908
|
+
url: url, selection: save, altText: altText, selectParent: selectParent,
|
|
1909
|
+
width: {
|
|
1910
|
+
width: proxy.parent.insertImageSettings.width, minWidth: proxy.parent.insertImageSettings.minWidth,
|
|
1911
|
+
maxWidth: proxy.parent.getInsertImgMaxWidth()
|
|
1912
|
+
}, height: {
|
|
1913
|
+
height: proxy.parent.insertImageSettings.height, minHeight: proxy.parent.insertImageSettings.minHeight,
|
|
1914
|
+
maxHeight: proxy.parent.insertImageSettings.maxHeight
|
|
1915
|
+
}
|
|
1916
|
+
};
|
|
1917
|
+
if (e && e.operation && e.operation.toLocaleUpperCase() !== 'REMOVE') {
|
|
1918
|
+
proxy.inputUrl.setAttribute('disabled', 'true');
|
|
1919
|
+
}
|
|
1920
|
+
previousFileInfo = e.file;
|
|
1921
|
+
}
|
|
1922
|
+
if (e.operation === 'upload' && !ej2_base_1.isNullOrUndefined(_this.dialogObj)) {
|
|
1923
|
+
_this.dialogObj.getButtons(0).element.removeAttribute('disabled');
|
|
1924
|
+
}
|
|
1925
|
+
});
|
|
1926
|
+
},
|
|
1927
|
+
failure: function (e) {
|
|
1928
|
+
_this.parent.trigger(events.imageUploadFailed, e);
|
|
1929
|
+
},
|
|
1930
|
+
removing: function (removeEventArgs) {
|
|
1931
|
+
_this.parent.trigger(events.imageRemoving, removeEventArgs, function (e) {
|
|
1932
|
+
proxy.isImgUploaded = false;
|
|
1933
|
+
_this.dialogObj.getButtons(0).element.disabled = true;
|
|
1934
|
+
proxy.inputUrl.removeAttribute('disabled');
|
|
1935
|
+
if (proxy.uploadUrl) {
|
|
1936
|
+
proxy.uploadUrl.url = '';
|
|
1937
|
+
}
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
});
|
|
1941
|
+
this.uploadObj.isStringTemplate = true;
|
|
1942
|
+
this.uploadObj.createElement = this.parent.createElement;
|
|
1943
|
+
this.uploadObj.appendTo(uploadEle);
|
|
1944
|
+
return uploadParentEle;
|
|
1945
|
+
};
|
|
1946
|
+
Image.prototype.checkExtension = function (e) {
|
|
1947
|
+
if (this.uploadObj.allowedExtensions) {
|
|
1948
|
+
if (e.type) {
|
|
1949
|
+
if (this.uploadObj.allowedExtensions.toLocaleLowerCase().indexOf(('.' + e.type).toLocaleLowerCase()) === -1) {
|
|
1950
|
+
this.dialogObj.getButtons(0).element.setAttribute('disabled', 'disabled');
|
|
1951
|
+
this.isAllowedTypes = false;
|
|
1952
|
+
}
|
|
1953
|
+
else {
|
|
1954
|
+
this.isAllowedTypes = true;
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
};
|
|
1959
|
+
Image.prototype.fileSelect = function () {
|
|
1960
|
+
this.dialogObj.element.getElementsByClassName('e-file-select-wrap')[0].querySelector('button').click();
|
|
1961
|
+
return false;
|
|
1962
|
+
};
|
|
1963
|
+
Image.prototype.dragStart = function (e) {
|
|
1964
|
+
if (e.target.nodeName === 'IMG') {
|
|
1965
|
+
e.dataTransfer.effectAllowed = 'copyMove';
|
|
1966
|
+
e.target.classList.add(classes.CLS_RTE_DRAG_IMAGE);
|
|
1967
|
+
}
|
|
1968
|
+
else {
|
|
1969
|
+
return true;
|
|
1970
|
+
}
|
|
1971
|
+
};
|
|
1972
|
+
Image.prototype.dragEnter = function (e) {
|
|
1973
|
+
e.dataTransfer.dropEffect = 'copy';
|
|
1974
|
+
e.preventDefault();
|
|
1975
|
+
};
|
|
1976
|
+
Image.prototype.dragOver = function (e) {
|
|
1977
|
+
if ((ej2_base_1.Browser.info.name === 'edge' && e.dataTransfer.items[0].type.split('/')[0].indexOf('image') > -1) ||
|
|
1978
|
+
(ej2_base_1.Browser.isIE && e.dataTransfer.types[0] === 'Files')) {
|
|
1979
|
+
e.preventDefault();
|
|
1980
|
+
}
|
|
1981
|
+
else {
|
|
1982
|
+
return true;
|
|
1983
|
+
}
|
|
1984
|
+
};
|
|
1985
|
+
Image.prototype.dragDrop = function (args) {
|
|
1986
|
+
var _this = this;
|
|
1987
|
+
this.parent.trigger(events.beforeImageDrop, args, function (e) {
|
|
1988
|
+
var imgElement = _this.parent.inputElement.ownerDocument.querySelector('.' + classes.CLS_RTE_DRAG_IMAGE);
|
|
1989
|
+
var isImgOrFileDrop = (imgElement && imgElement.tagName === 'IMG') || e.dataTransfer.files.length > 0;
|
|
1990
|
+
if (!e.cancel && isImgOrFileDrop) {
|
|
1991
|
+
if (ej2_base_1.closest(e.target, '#' + _this.parent.getID() + '_toolbar') ||
|
|
1992
|
+
_this.parent.inputElement.contentEditable === 'false') {
|
|
1993
|
+
e.preventDefault();
|
|
1994
|
+
return;
|
|
1995
|
+
}
|
|
1996
|
+
if (_this.parent.element.querySelector('.' + classes.CLS_IMG_RESIZE)) {
|
|
1997
|
+
ej2_base_1.detach(_this.imgResizeDiv);
|
|
1998
|
+
}
|
|
1999
|
+
e.preventDefault();
|
|
2000
|
+
var range = void 0;
|
|
2001
|
+
if (_this.contentModule.getDocument().caretRangeFromPoint) {
|
|
2002
|
+
range = _this.contentModule.getDocument().caretRangeFromPoint(e.clientX, e.clientY);
|
|
2003
|
+
}
|
|
2004
|
+
else if ((e.rangeParent)) {
|
|
2005
|
+
range = _this.contentModule.getDocument().createRange();
|
|
2006
|
+
range.setStart(e.rangeParent, e.rangeOffset);
|
|
2007
|
+
}
|
|
2008
|
+
else {
|
|
2009
|
+
range = _this.getDropRange(e.clientX, e.clientY);
|
|
2010
|
+
}
|
|
2011
|
+
_this.parent.notify(events.selectRange, { range: range });
|
|
2012
|
+
var uploadArea = _this.parent.element.querySelector('.' + classes.CLS_DROPAREA);
|
|
2013
|
+
if (uploadArea) {
|
|
2014
|
+
return;
|
|
2015
|
+
}
|
|
2016
|
+
_this.insertDragImage(e);
|
|
2017
|
+
}
|
|
2018
|
+
else {
|
|
2019
|
+
if (isImgOrFileDrop) {
|
|
2020
|
+
e.preventDefault();
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
});
|
|
2024
|
+
};
|
|
2025
|
+
Image.prototype.getDropRange = function (x, y) {
|
|
2026
|
+
var startRange = this.contentModule.getDocument().createRange();
|
|
2027
|
+
this.parent.formatter.editorManager.nodeSelection.setRange(this.contentModule.getDocument(), startRange);
|
|
2028
|
+
var elem = this.contentModule.getDocument().elementFromPoint(x, y);
|
|
2029
|
+
var startNode = (elem.childNodes.length > 0 ? elem.childNodes[0] : elem);
|
|
2030
|
+
var startCharIndexCharacter = 0;
|
|
2031
|
+
if (this.parent.inputElement.firstChild.innerHTML === '<br>') {
|
|
2032
|
+
startRange.setStart(startNode, startCharIndexCharacter);
|
|
2033
|
+
startRange.setEnd(startNode, startCharIndexCharacter);
|
|
2034
|
+
}
|
|
2035
|
+
else {
|
|
2036
|
+
var rangeRect = void 0;
|
|
2037
|
+
do {
|
|
2038
|
+
startCharIndexCharacter++;
|
|
2039
|
+
startRange.setStart(startNode, startCharIndexCharacter);
|
|
2040
|
+
startRange.setEnd(startNode, startCharIndexCharacter + 1);
|
|
2041
|
+
rangeRect = startRange.getBoundingClientRect();
|
|
2042
|
+
} while (rangeRect.left < x && startCharIndexCharacter < startNode.length - 1);
|
|
2043
|
+
}
|
|
2044
|
+
return startRange;
|
|
2045
|
+
};
|
|
2046
|
+
Image.prototype.insertDragImage = function (e) {
|
|
2047
|
+
var _this = this;
|
|
2048
|
+
e.preventDefault();
|
|
2049
|
+
var activePopupElement = this.parent.element.querySelector('' + classes.CLS_POPUP_OPEN);
|
|
2050
|
+
this.parent.notify(events.drop, { args: e });
|
|
2051
|
+
if (activePopupElement) {
|
|
2052
|
+
activePopupElement.classList.add(classes.CLS_HIDE);
|
|
2053
|
+
}
|
|
2054
|
+
var imgElement = this.parent.inputElement.ownerDocument.querySelector('.' + classes.CLS_RTE_DRAG_IMAGE);
|
|
2055
|
+
var actionBeginArgs = {
|
|
2056
|
+
requestType: 'Images',
|
|
2057
|
+
name: 'ImageDragAndDrop',
|
|
2058
|
+
cancel: false,
|
|
2059
|
+
originalEvent: e
|
|
2060
|
+
};
|
|
2061
|
+
if (e.dataTransfer.files.length > 0 && imgElement === null) {
|
|
2062
|
+
if (e.dataTransfer.files.length > 1) {
|
|
2063
|
+
return;
|
|
2064
|
+
}
|
|
2065
|
+
var imgFiles_1 = e.dataTransfer.files;
|
|
2066
|
+
var fileName = imgFiles_1[0].name;
|
|
2067
|
+
var imgType = fileName.substring(fileName.lastIndexOf('.'));
|
|
2068
|
+
var allowedTypes = this.parent.insertImageSettings.allowedTypes;
|
|
2069
|
+
for (var i = 0; i < allowedTypes.length; i++) {
|
|
2070
|
+
if (imgType.toLocaleLowerCase() === allowedTypes[i].toLowerCase()) {
|
|
2071
|
+
if (this.parent.insertImageSettings.saveUrl) {
|
|
2072
|
+
this.onSelect(e);
|
|
2073
|
+
}
|
|
2074
|
+
else {
|
|
2075
|
+
this.parent.trigger(events.actionBegin, actionBeginArgs, function (actionBeginArgs) {
|
|
2076
|
+
if (!actionBeginArgs.cancel) {
|
|
2077
|
+
var args = { args: e, text: '', file: imgFiles_1[0] };
|
|
2078
|
+
e.preventDefault();
|
|
2079
|
+
_this.imagePaste(args);
|
|
2080
|
+
}
|
|
2081
|
+
else {
|
|
2082
|
+
actionBeginArgs.originalEvent.preventDefault();
|
|
2083
|
+
}
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
else {
|
|
2090
|
+
this.parent.trigger(events.actionBegin, actionBeginArgs, function (actionBeginArgs) {
|
|
2091
|
+
if (!actionBeginArgs.cancel) {
|
|
2092
|
+
var range = _this.parent.formatter.editorManager.nodeSelection.getRange(_this.parent.contentModule.getDocument());
|
|
2093
|
+
if (imgElement && imgElement.tagName === 'IMG') {
|
|
2094
|
+
var imgCaption = imgElement.closest('.e-rte-img-caption');
|
|
2095
|
+
if (!ej2_base_1.isNullOrUndefined(imgCaption)) {
|
|
2096
|
+
range.insertNode(imgCaption);
|
|
2097
|
+
}
|
|
2098
|
+
else {
|
|
2099
|
+
var anchorElement = imgElement.closest('a');
|
|
2100
|
+
var isAnchorValid = anchorElement && anchorElement.tagName === 'A' &&
|
|
2101
|
+
_this.hasOnlyImage(anchorElement);
|
|
2102
|
+
if (isAnchorValid) {
|
|
2103
|
+
range.insertNode(anchorElement);
|
|
2104
|
+
}
|
|
2105
|
+
else {
|
|
2106
|
+
range.insertNode(imgElement);
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
imgElement.classList.remove(classes.CLS_RTE_DRAG_IMAGE);
|
|
2110
|
+
var imgArgs_1 = { elements: [imgElement] };
|
|
2111
|
+
imgElement.addEventListener('load', function () {
|
|
2112
|
+
_this.parent.trigger(events.actionComplete, imgArgs_1);
|
|
2113
|
+
});
|
|
2114
|
+
_this.parent.formatter.editorManager.nodeSelection.Clear(_this.contentModule.getDocument());
|
|
2115
|
+
var args = e;
|
|
2116
|
+
if (_this.parent.insertImageSettings.resize) {
|
|
2117
|
+
_this.resizeStart(args, imgElement);
|
|
2118
|
+
}
|
|
2119
|
+
_this.hideImageQuickToolbar();
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
else {
|
|
2123
|
+
actionBeginArgs.originalEvent.preventDefault();
|
|
2124
|
+
}
|
|
2125
|
+
});
|
|
2126
|
+
}
|
|
2127
|
+
};
|
|
2128
|
+
Image.prototype.hasOnlyImage = function (anchor) {
|
|
2129
|
+
var imageFound = false;
|
|
2130
|
+
for (var i = 0; i < anchor.childNodes.length; i++) {
|
|
2131
|
+
var currentNode = anchor.childNodes[i];
|
|
2132
|
+
if (currentNode.nodeType === Node.TEXT_NODE) {
|
|
2133
|
+
var text = currentNode.textContent.replace(/[\u200B\u200C\u200D]/g, '').trim();
|
|
2134
|
+
if (text !== '') {
|
|
2135
|
+
return false;
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
else if (currentNode.nodeType === Node.ELEMENT_NODE) {
|
|
2139
|
+
if (currentNode.tagName === 'IMG') {
|
|
2140
|
+
if (imageFound) {
|
|
2141
|
+
return false;
|
|
2142
|
+
}
|
|
2143
|
+
imageFound = true;
|
|
2144
|
+
}
|
|
2145
|
+
else {
|
|
2146
|
+
return false;
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
return imageFound;
|
|
2151
|
+
};
|
|
2152
|
+
Image.prototype.onSelect = function (args) {
|
|
2153
|
+
var _this = this;
|
|
2154
|
+
var proxy = this;
|
|
2155
|
+
var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
|
|
2156
|
+
var parentElement = this.parent.createElement('ul', { className: classes.CLS_UPLOAD_FILES });
|
|
2157
|
+
this.parent.rootContainer.appendChild(parentElement);
|
|
2158
|
+
var validFiles = {
|
|
2159
|
+
name: args.dataTransfer.files[0].name,
|
|
2160
|
+
size: args.dataTransfer.files[0].size,
|
|
2161
|
+
status: '',
|
|
2162
|
+
statusCode: '',
|
|
2163
|
+
type: args.dataTransfer.files[0].type,
|
|
2164
|
+
rawFile: args.dataTransfer.files[0],
|
|
2165
|
+
validationMessages: {}
|
|
2166
|
+
};
|
|
2167
|
+
var imageTag = this.parent.createElement('IMG');
|
|
2168
|
+
imageTag.style.opacity = '0.5';
|
|
2169
|
+
imageTag.classList.add(classes.CLS_RTE_IMAGE);
|
|
2170
|
+
imageTag.classList.add(classes.CLS_IMGINLINE);
|
|
2171
|
+
imageTag.classList.add(classes.CLS_RESIZE);
|
|
2172
|
+
var file = validFiles.rawFile;
|
|
2173
|
+
var reader = new FileReader();
|
|
2174
|
+
reader.addEventListener('load', function () {
|
|
2175
|
+
var url = URL.createObjectURL(util_2.convertToBlob(reader.result));
|
|
2176
|
+
imageTag.src = proxy.parent.insertImageSettings.saveFormat === 'Blob' ? url : reader.result;
|
|
2177
|
+
});
|
|
2178
|
+
if (file) {
|
|
2179
|
+
reader.readAsDataURL(file);
|
|
2180
|
+
}
|
|
2181
|
+
var selection = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
|
|
2182
|
+
var imageCommand = {
|
|
2183
|
+
cssClass: (this.parent.insertImageSettings.display === 'inline' ? classes.CLS_IMGINLINE : classes.CLS_IMGBREAK),
|
|
2184
|
+
url: this.parent.insertImageSettings.path + file.name,
|
|
2185
|
+
selection: selection,
|
|
2186
|
+
altText: file.name.replace(/\.[a-zA-Z0-9]+$/, ''),
|
|
2187
|
+
width: {
|
|
2188
|
+
width: this.parent.insertImageSettings.width, minWidth: this.parent.insertImageSettings.minWidth,
|
|
2189
|
+
maxWidth: this.parent.getInsertImgMaxWidth()
|
|
2190
|
+
},
|
|
2191
|
+
height: {
|
|
2192
|
+
height: this.parent.insertImageSettings.height, minHeight: this.parent.insertImageSettings.minHeight,
|
|
2193
|
+
maxHeight: this.parent.insertImageSettings.maxHeight
|
|
2194
|
+
}
|
|
2195
|
+
};
|
|
2196
|
+
var actionBeginArgs = {
|
|
2197
|
+
requestType: 'Image',
|
|
2198
|
+
name: 'ImageDragAndDrop',
|
|
2199
|
+
cancel: false,
|
|
2200
|
+
originalEvent: args,
|
|
2201
|
+
itemCollection: imageCommand
|
|
2202
|
+
};
|
|
2203
|
+
this.parent.trigger(events.actionBegin, actionBeginArgs, function (actionBeginArgs) {
|
|
2204
|
+
if (!actionBeginArgs.cancel) {
|
|
2205
|
+
var command = actionBeginArgs.itemCollection;
|
|
2206
|
+
var image_1 = ej2_base_1.createElement('img', {
|
|
2207
|
+
className: command.cssClass,
|
|
2208
|
+
attrs: { src: command.url, alt: command.altText }
|
|
2209
|
+
});
|
|
2210
|
+
image_1.style.opacity = '0.5';
|
|
2211
|
+
image_1.classList.add(classes.CLS_RTE_IMAGE);
|
|
2212
|
+
image_1.classList.add(classes.CLS_IMGINLINE);
|
|
2213
|
+
image_1.classList.add(classes.CLS_RESIZE);
|
|
2214
|
+
range.insertNode(image_1);
|
|
2215
|
+
_this.uploadMethod(args, image_1);
|
|
2216
|
+
image_1.addEventListener('load', function (e) {
|
|
2217
|
+
var actionCompleteArgs = {
|
|
2218
|
+
requestType: 'Image',
|
|
2219
|
+
name: 'InsertDropImage',
|
|
2220
|
+
elements: [image_1],
|
|
2221
|
+
event: e,
|
|
2222
|
+
editorMode: 'HTML'
|
|
2223
|
+
};
|
|
2224
|
+
_this.parent.trigger(events.actionComplete, actionCompleteArgs);
|
|
2225
|
+
});
|
|
2226
|
+
ej2_base_1.detach(parentElement);
|
|
2227
|
+
}
|
|
2228
|
+
else {
|
|
2229
|
+
actionBeginArgs.originalEvent.preventDefault();
|
|
2230
|
+
}
|
|
2231
|
+
});
|
|
2232
|
+
};
|
|
2233
|
+
Image.prototype.uploadMethod = function (dragEvent, imageElement) {
|
|
2234
|
+
var _this = this;
|
|
2235
|
+
var isUploading = false;
|
|
2236
|
+
var proxy = this;
|
|
2237
|
+
var popupEle = this.parent.createElement('div');
|
|
2238
|
+
this.parent.rootContainer.appendChild(popupEle);
|
|
2239
|
+
var uploadEle = this.parent.createElement('input', {
|
|
2240
|
+
id: this.rteID + '_upload', attrs: { type: 'File', name: 'UploadFiles' }
|
|
2241
|
+
});
|
|
2242
|
+
this.popupObj = new ej2_popups_1.Popup(popupEle, {
|
|
2243
|
+
relateTo: imageElement,
|
|
2244
|
+
height: '85px',
|
|
2245
|
+
width: '300px',
|
|
2246
|
+
content: uploadEle,
|
|
2247
|
+
viewPortElement: this.parent.inputElement,
|
|
2248
|
+
enableRtl: this.parent.enableRtl,
|
|
2249
|
+
zIndex: 10001,
|
|
2250
|
+
close: function (event) {
|
|
2251
|
+
_this.parent.isBlur = false;
|
|
2252
|
+
_this.popupObj.destroy();
|
|
2253
|
+
ej2_base_1.detach(_this.popupObj.element);
|
|
2254
|
+
_this.popupObj = null;
|
|
2255
|
+
if (!_this.parent.inlineMode.enable) {
|
|
2256
|
+
_this.parent.toolbarModule.baseToolbar.toolbarObj.disable(false);
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
});
|
|
2260
|
+
this.popupObj.element.style.display = 'none';
|
|
2261
|
+
ej2_base_1.addClass([this.popupObj.element], classes.CLS_POPUP_OPEN);
|
|
2262
|
+
ej2_base_1.addClass([this.popupObj.element], classes.CLS_RTE_UPLOAD_POPUP);
|
|
2263
|
+
if (!ej2_base_1.isNullOrUndefined(this.parent.cssClass)) {
|
|
2264
|
+
ej2_base_1.addClass([this.popupObj.element], this.parent.cssClass.replace(/\s+/g, ' ').trim().split(' '));
|
|
2265
|
+
}
|
|
2266
|
+
var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
|
|
2267
|
+
var timeOut = dragEvent.dataTransfer.files[0].size > 1000000 ? 300 : 100;
|
|
2268
|
+
this.imageDragPopupTime = setTimeout(function () {
|
|
2269
|
+
proxy.refreshPopup(imageElement);
|
|
2270
|
+
}, timeOut);
|
|
2271
|
+
this.uploadObj = new ej2_inputs_1.Uploader({
|
|
2272
|
+
asyncSettings: {
|
|
2273
|
+
saveUrl: this.parent.insertImageSettings.saveUrl,
|
|
2274
|
+
removeUrl: this.parent.insertImageSettings.removeUrl
|
|
2275
|
+
},
|
|
2276
|
+
cssClass: classes.CLS_RTE_DIALOG_UPLOAD + this.parent.getCssClass(true),
|
|
2277
|
+
dropArea: this.parent.element,
|
|
2278
|
+
allowedExtensions: this.parent.insertImageSettings.allowedTypes.toString(),
|
|
2279
|
+
removing: function () {
|
|
2280
|
+
_this.parent.inputElement.contentEditable = 'true';
|
|
2281
|
+
isUploading = false;
|
|
2282
|
+
ej2_base_1.detach(imageElement);
|
|
2283
|
+
_this.popupObj.close();
|
|
2284
|
+
},
|
|
2285
|
+
canceling: function () {
|
|
2286
|
+
_this.parent.inputElement.contentEditable = 'true';
|
|
2287
|
+
isUploading = false;
|
|
2288
|
+
ej2_base_1.detach(imageElement);
|
|
2289
|
+
_this.popupObj.close();
|
|
2290
|
+
_this.quickToolObj.imageQTBar.hidePopup();
|
|
2291
|
+
_this.uploadCancelTime = setTimeout(function () {
|
|
2292
|
+
_this.uploadObj.destroy();
|
|
2293
|
+
}, 900);
|
|
2294
|
+
},
|
|
2295
|
+
beforeUpload: function (args) {
|
|
2296
|
+
_this.parent.trigger(events.beforeImageUpload, args);
|
|
2297
|
+
if (!_this.parent.inlineMode.enable) {
|
|
2298
|
+
_this.parent.toolbarModule.baseToolbar.toolbarObj.disable(true);
|
|
2299
|
+
}
|
|
2300
|
+
},
|
|
2301
|
+
uploading: function (e) {
|
|
2302
|
+
if (!_this.parent.isServerRendered) {
|
|
2303
|
+
isUploading = true;
|
|
2304
|
+
_this.parent.trigger(events.imageUploading, e, function (imageUploadingArgs) {
|
|
2305
|
+
if (imageUploadingArgs.cancel) {
|
|
2306
|
+
if (!ej2_base_1.isNullOrUndefined(imageElement)) {
|
|
2307
|
+
ej2_base_1.detach(imageElement);
|
|
2308
|
+
}
|
|
2309
|
+
if (!ej2_base_1.isNullOrUndefined(_this.popupObj.element)) {
|
|
2310
|
+
ej2_base_1.detach(_this.popupObj.element);
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
else {
|
|
2314
|
+
_this.parent.inputElement.contentEditable = 'false';
|
|
2315
|
+
}
|
|
2316
|
+
});
|
|
2317
|
+
}
|
|
2318
|
+
},
|
|
2319
|
+
selected: function (e) {
|
|
2320
|
+
if (isUploading) {
|
|
2321
|
+
e.cancel = true;
|
|
2322
|
+
}
|
|
2323
|
+
},
|
|
2324
|
+
failure: function (e) {
|
|
2325
|
+
isUploading = false;
|
|
2326
|
+
_this.parent.inputElement.contentEditable = 'true';
|
|
2327
|
+
var args = {
|
|
2328
|
+
args: dragEvent,
|
|
2329
|
+
type: 'Images',
|
|
2330
|
+
isNotify: undefined,
|
|
2331
|
+
elements: imageElement
|
|
2332
|
+
};
|
|
2333
|
+
_this.uploadFailureTime = setTimeout(function () {
|
|
2334
|
+
_this.uploadFailure(imageElement, args, e);
|
|
2335
|
+
}, 900);
|
|
2336
|
+
},
|
|
2337
|
+
success: function (e) {
|
|
2338
|
+
if (e.operation === 'cancel') {
|
|
2339
|
+
return;
|
|
2340
|
+
}
|
|
2341
|
+
isUploading = false;
|
|
2342
|
+
_this.parent.inputElement.contentEditable = 'true';
|
|
2343
|
+
var args = {
|
|
2344
|
+
args: dragEvent,
|
|
2345
|
+
type: 'Images',
|
|
2346
|
+
isNotify: undefined,
|
|
2347
|
+
elements: imageElement
|
|
2348
|
+
};
|
|
2349
|
+
_this.uploadSuccessTime = setTimeout(function () {
|
|
2350
|
+
_this.uploadSuccess(imageElement, dragEvent, args, e);
|
|
2351
|
+
}, 900);
|
|
2352
|
+
}
|
|
2353
|
+
});
|
|
2354
|
+
this.uploadObj.appendTo(this.popupObj.element.childNodes[0]);
|
|
2355
|
+
this.popupObj.element.querySelector('.e-rte-dialog-upload .e-file-select-wrap').style.display = 'none';
|
|
2356
|
+
range.selectNodeContents(imageElement);
|
|
2357
|
+
this.parent.formatter.editorManager.nodeSelection.setRange(this.contentModule.getDocument(), range);
|
|
2358
|
+
};
|
|
2359
|
+
Image.prototype.refreshPopup = function (imageElement) {
|
|
2360
|
+
var imgPosition = this.parent.iframeSettings.enable ? this.parent.element.offsetTop +
|
|
2361
|
+
imageElement.offsetTop : imageElement.offsetTop;
|
|
2362
|
+
var rtePosition = this.parent.element.offsetTop + this.parent.element.offsetHeight;
|
|
2363
|
+
if (imgPosition > rtePosition) {
|
|
2364
|
+
this.popupObj.offsetY = this.parent.iframeSettings.enable ? -30 : -65;
|
|
2365
|
+
this.popupObj.element.style.display = 'block';
|
|
2366
|
+
}
|
|
2367
|
+
else {
|
|
2368
|
+
if (this.popupObj) {
|
|
2369
|
+
this.popupObj.refreshPosition(imageElement);
|
|
2370
|
+
this.popupObj.element.style.display = 'block';
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
};
|
|
2374
|
+
Image.prototype.uploadFailure = function (imgEle, args, e) {
|
|
2375
|
+
ej2_base_1.detach(imgEle);
|
|
2376
|
+
if (this.popupObj) {
|
|
2377
|
+
this.popupObj.close();
|
|
2378
|
+
}
|
|
2379
|
+
this.parent.trigger(events.imageUploadFailed, e);
|
|
2380
|
+
this.uploadObj.destroy();
|
|
2381
|
+
};
|
|
2382
|
+
Image.prototype.uploadSuccess = function (imageElement, dragEvent, args, e) {
|
|
2383
|
+
var _this = this;
|
|
2384
|
+
imageElement.style.opacity = '1';
|
|
2385
|
+
imageElement.classList.add(classes.CLS_IMG_FOCUS);
|
|
2386
|
+
e.element = imageElement;
|
|
2387
|
+
e.detectImageSource = enum_1.ImageInputSource.Dropped;
|
|
2388
|
+
this.parent.trigger(events.imageUploadSuccess, e, function (e) {
|
|
2389
|
+
if (!ej2_base_1.isNullOrUndefined(_this.parent.insertImageSettings.path)) {
|
|
2390
|
+
var url = _this.parent.insertImageSettings.path + e.file.name;
|
|
2391
|
+
imageElement.src = url;
|
|
2392
|
+
imageElement.setAttribute('alt', e.file.name);
|
|
2393
|
+
}
|
|
2394
|
+
});
|
|
2395
|
+
if (this.popupObj) {
|
|
2396
|
+
this.popupObj.close();
|
|
2397
|
+
this.uploadObj.destroy();
|
|
2398
|
+
}
|
|
2399
|
+
this.showImageQuickToolbar(args);
|
|
2400
|
+
this.resizeStart(dragEvent, imageElement);
|
|
2401
|
+
};
|
|
2402
|
+
Image.prototype.imagePaste = function (args) {
|
|
2403
|
+
var _this = this;
|
|
2404
|
+
if (args.text.length === 0 && !ej2_base_1.isNullOrUndefined(args.file)) {
|
|
2405
|
+
var proxy_1 = this;
|
|
2406
|
+
var reader_2 = new FileReader();
|
|
2407
|
+
args.args.preventDefault();
|
|
2408
|
+
reader_2.addEventListener('load', function (e) {
|
|
2409
|
+
var url = {
|
|
2410
|
+
cssClass: (proxy_1.parent.insertImageSettings.display === 'inline' ? classes.CLS_IMGINLINE : classes.CLS_IMGBREAK),
|
|
2411
|
+
url: _this.parent.insertImageSettings.saveFormat === 'Base64' || !ej2_base_1.isNullOrUndefined(args.callBack) ?
|
|
2412
|
+
reader_2.result : URL.createObjectURL(util_2.convertToBlob(reader_2.result)),
|
|
2413
|
+
width: {
|
|
2414
|
+
width: proxy_1.parent.insertImageSettings.width, minWidth: proxy_1.parent.insertImageSettings.minWidth,
|
|
2415
|
+
maxWidth: proxy_1.parent.getInsertImgMaxWidth()
|
|
2416
|
+
},
|
|
2417
|
+
height: {
|
|
2418
|
+
height: proxy_1.parent.insertImageSettings.height, minHeight: proxy_1.parent.insertImageSettings.minHeight,
|
|
2419
|
+
maxHeight: proxy_1.parent.insertImageSettings.maxHeight
|
|
2420
|
+
}
|
|
2421
|
+
};
|
|
2422
|
+
if (!ej2_base_1.isNullOrUndefined(args.callBack)) {
|
|
2423
|
+
args.callBack(url);
|
|
2424
|
+
return;
|
|
2425
|
+
}
|
|
2426
|
+
else {
|
|
2427
|
+
proxy_1.parent.formatter.process(proxy_1.parent, { item: { command: 'Images', subCommand: 'Image' } }, args.args, url);
|
|
2428
|
+
_this.showPopupToolBar(args, url);
|
|
2429
|
+
}
|
|
2430
|
+
});
|
|
2431
|
+
reader_2.readAsDataURL(args.file);
|
|
2432
|
+
}
|
|
2433
|
+
};
|
|
2434
|
+
Image.prototype.showPopupToolBar = function (e, url) {
|
|
2435
|
+
var _this = this;
|
|
2436
|
+
var imageSrc = 'img[src="' + url.url + '"]';
|
|
2437
|
+
var imageElement = this.parent.inputElement.querySelector(imageSrc);
|
|
2438
|
+
this.parent.quickToolbarModule.createQTBar('Image', 'MultiRow', this.parent.quickToolbarSettings.image, enum_1.RenderType.ImageToolbar);
|
|
2439
|
+
var args = {
|
|
2440
|
+
args: e.args,
|
|
2441
|
+
type: 'Images',
|
|
2442
|
+
isNotify: undefined,
|
|
2443
|
+
elements: imageElement
|
|
2444
|
+
};
|
|
2445
|
+
if (imageElement) {
|
|
2446
|
+
this.showImageQTbarTime = setTimeout(function () {
|
|
2447
|
+
_this.showImageQuickToolbar(args);
|
|
2448
|
+
if (_this.parent.insertImageSettings.resize) {
|
|
2449
|
+
_this.resizeStart(e.args, imageElement);
|
|
2450
|
+
}
|
|
2451
|
+
}, 0);
|
|
2452
|
+
}
|
|
2453
|
+
};
|
|
2454
|
+
Image.prototype.destroy = function () {
|
|
2455
|
+
if (this.isDestroyed) {
|
|
2456
|
+
return;
|
|
2457
|
+
}
|
|
2458
|
+
this.prevSelectedImgEle = undefined;
|
|
2459
|
+
if (!ej2_base_1.isNullOrUndefined(this.imageQTPopupTime)) {
|
|
2460
|
+
clearTimeout(this.imageQTPopupTime);
|
|
2461
|
+
this.imageQTPopupTime = null;
|
|
2462
|
+
}
|
|
2463
|
+
if (!ej2_base_1.isNullOrUndefined(this.imageDragPopupTime)) {
|
|
2464
|
+
clearTimeout(this.imageDragPopupTime);
|
|
2465
|
+
this.imageDragPopupTime = null;
|
|
2466
|
+
}
|
|
2467
|
+
if (!ej2_base_1.isNullOrUndefined(this.uploadCancelTime)) {
|
|
2468
|
+
clearTimeout(this.uploadCancelTime);
|
|
2469
|
+
this.uploadCancelTime = null;
|
|
2470
|
+
}
|
|
2471
|
+
if (!ej2_base_1.isNullOrUndefined(this.uploadFailureTime)) {
|
|
2472
|
+
clearTimeout(this.uploadFailureTime);
|
|
2473
|
+
this.uploadFailureTime = null;
|
|
2474
|
+
}
|
|
2475
|
+
if (!ej2_base_1.isNullOrUndefined(this.showImageQTbarTime)) {
|
|
2476
|
+
clearTimeout(this.showImageQTbarTime);
|
|
2477
|
+
this.showImageQTbarTime = null;
|
|
2478
|
+
}
|
|
2479
|
+
if (!ej2_base_1.isNullOrUndefined(this.uploadSuccessTime)) {
|
|
2480
|
+
clearTimeout(this.uploadSuccessTime);
|
|
2481
|
+
this.uploadSuccessTime = null;
|
|
2482
|
+
}
|
|
2483
|
+
this.removeEventListener();
|
|
2484
|
+
this.clearDialogObj();
|
|
2485
|
+
this.cancelResizeAction();
|
|
2486
|
+
this.isDestroyed = true;
|
|
2487
|
+
};
|
|
2488
|
+
Image.prototype.getModuleName = function () {
|
|
2489
|
+
return 'image';
|
|
2490
|
+
};
|
|
2491
|
+
return Image;
|
|
2492
|
+
}());
|
|
2493
|
+
exports.Image = Image;
|
|
2494
|
+
});
|