editor-svg 1.0.0
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/.editorconfig +9 -0
- package/.eslintrc +46 -0
- package/.prettierrc +8 -0
- package/AGENTS.md +186 -0
- package/CHANGELOG.md +2543 -0
- package/CLAUDE.md +110 -0
- package/LICENSE +21 -0
- package/README.md +110 -0
- package/cypress/e2e/control/checkbox.cy.ts +46 -0
- package/cypress/e2e/control/select.cy.ts +56 -0
- package/cypress/e2e/control/text.cy.ts +43 -0
- package/cypress/e2e/editor.cy.ts +67 -0
- package/cypress/e2e/menus/block.cy.ts +38 -0
- package/cypress/e2e/menus/checkbox.cy.ts +33 -0
- package/cypress/e2e/menus/codeblock.cy.ts +34 -0
- package/cypress/e2e/menus/date.cy.ts +28 -0
- package/cypress/e2e/menus/format.cy.ts +40 -0
- package/cypress/e2e/menus/hyperlink.cy.ts +39 -0
- package/cypress/e2e/menus/image.cy.ts +25 -0
- package/cypress/e2e/menus/latex.cy.ts +34 -0
- package/cypress/e2e/menus/pagebreak.cy.ts +21 -0
- package/cypress/e2e/menus/painter.cy.ts +53 -0
- package/cypress/e2e/menus/print.cy.ts +25 -0
- package/cypress/e2e/menus/row.cy.ts +103 -0
- package/cypress/e2e/menus/search.cy.ts +112 -0
- package/cypress/e2e/menus/separator.cy.ts +32 -0
- package/cypress/e2e/menus/table.cy.ts +25 -0
- package/cypress/e2e/menus/text.cy.ts +304 -0
- package/cypress/e2e/menus/title.cy.ts +43 -0
- package/cypress/e2e/menus/undoRedo.cy.ts +49 -0
- package/cypress/e2e/menus/watermark.cy.ts +64 -0
- package/cypress/fixtures/example.json +3 -0
- package/cypress/fixtures/test.png +0 -0
- package/cypress/global.d.ts +13 -0
- package/cypress/support/commands.ts +5 -0
- package/cypress/support/e2e.ts +1 -0
- package/cypress/tsconfig.json +21 -0
- package/cypress.config.ts +10 -0
- package/docs/.vitepress/config.ts +191 -0
- package/docs/.vitepress/theme/components/DeepWikiBadge.vue +21 -0
- package/docs/.vitepress/theme/components/ZreadBadge.vue +21 -0
- package/docs/.vitepress/theme/index.ts +27 -0
- package/docs/en/guide/api-common.md +49 -0
- package/docs/en/guide/api-instance.md +34 -0
- package/docs/en/guide/command-execute.md +1167 -0
- package/docs/en/guide/command-get.md +355 -0
- package/docs/en/guide/contextmenu-custom.md +44 -0
- package/docs/en/guide/contextmenu-internal.md +61 -0
- package/docs/en/guide/eventbus.md +260 -0
- package/docs/en/guide/i18n.md +112 -0
- package/docs/en/guide/listener.md +126 -0
- package/docs/en/guide/option.md +214 -0
- package/docs/en/guide/override.md +57 -0
- package/docs/en/guide/plugin-custom.md +25 -0
- package/docs/en/guide/plugin-internal.md +125 -0
- package/docs/en/guide/schema.md +237 -0
- package/docs/en/guide/shortcut-custom.md +22 -0
- package/docs/en/guide/shortcut-internal.md +189 -0
- package/docs/en/guide/start.md +97 -0
- package/docs/en/index.md +43 -0
- package/docs/guide/api-common.md +49 -0
- package/docs/guide/api-instance.md +34 -0
- package/docs/guide/command-execute.md +1157 -0
- package/docs/guide/command-get.md +353 -0
- package/docs/guide/contextmenu-custom.md +44 -0
- package/docs/guide/contextmenu-internal.md +61 -0
- package/docs/guide/eventbus.md +260 -0
- package/docs/guide/i18n.md +111 -0
- package/docs/guide/listener.md +126 -0
- package/docs/guide/option.md +214 -0
- package/docs/guide/override.md +57 -0
- package/docs/guide/plugin-custom.md +25 -0
- package/docs/guide/plugin-internal.md +125 -0
- package/docs/guide/schema.md +237 -0
- package/docs/guide/shortcut-custom.md +22 -0
- package/docs/guide/shortcut-internal.md +189 -0
- package/docs/guide/start.md +97 -0
- package/docs/index.md +43 -0
- package/docs/public/favicon.png +0 -0
- package/favicon.png +0 -0
- package/index.html +435 -0
- package/package.json +55 -0
- package/pnpm-lock.yaml +4113 -0
- package/scripts/release.js +41 -0
- package/scripts/verifyCommit.js +19 -0
- package/src/assets/images/alignment.svg +1 -0
- package/src/assets/images/arrow-left.svg +1 -0
- package/src/assets/images/arrow-right.svg +1 -0
- package/src/assets/images/block.svg +1 -0
- package/src/assets/images/bold.svg +1 -0
- package/src/assets/images/catalog.svg +1 -0
- package/src/assets/images/center.svg +1 -0
- package/src/assets/images/checkbox.svg +1 -0
- package/src/assets/images/close.svg +1 -0
- package/src/assets/images/codeblock.svg +1 -0
- package/src/assets/images/color.svg +1 -0
- package/src/assets/images/control.svg +1 -0
- package/src/assets/images/date.svg +1 -0
- package/src/assets/images/exit-fullscreen.svg +1 -0
- package/src/assets/images/format.svg +1 -0
- package/src/assets/images/highlight.svg +1 -0
- package/src/assets/images/hyperlink.svg +1 -0
- package/src/assets/images/image.svg +1 -0
- package/src/assets/images/italic.svg +1 -0
- package/src/assets/images/justify.svg +7 -0
- package/src/assets/images/latex.svg +1 -0
- package/src/assets/images/left.svg +1 -0
- package/src/assets/images/line-dash-dot-dot.svg +1 -0
- package/src/assets/images/line-dash-dot.svg +1 -0
- package/src/assets/images/line-dash-large-gap.svg +1 -0
- package/src/assets/images/line-dash-small-gap.svg +1 -0
- package/src/assets/images/line-dot.svg +1 -0
- package/src/assets/images/line-double.svg +1 -0
- package/src/assets/images/line-single.svg +1 -0
- package/src/assets/images/line-wavy.svg +1 -0
- package/src/assets/images/list.svg +1 -0
- package/src/assets/images/option.svg +1 -0
- package/src/assets/images/page-break.svg +1 -0
- package/src/assets/images/page-mode.svg +1 -0
- package/src/assets/images/page-scale-add.svg +1 -0
- package/src/assets/images/page-scale-minus.svg +1 -0
- package/src/assets/images/painter.svg +1 -0
- package/src/assets/images/paper-direction.svg +1 -0
- package/src/assets/images/paper-margin.svg +1 -0
- package/src/assets/images/paper-size.svg +1 -0
- package/src/assets/images/print.svg +1 -0
- package/src/assets/images/radio.svg +4 -0
- package/src/assets/images/redo.svg +1 -0
- package/src/assets/images/request-fullscreen.svg +1 -0
- package/src/assets/images/right.svg +1 -0
- package/src/assets/images/row-margin.svg +1 -0
- package/src/assets/images/search.svg +1 -0
- package/src/assets/images/separator.svg +1 -0
- package/src/assets/images/signature-undo.svg +1 -0
- package/src/assets/images/signature.svg +1 -0
- package/src/assets/images/size-add.svg +1 -0
- package/src/assets/images/size-minus.svg +1 -0
- package/src/assets/images/strikeout.svg +1 -0
- package/src/assets/images/subscript.svg +1 -0
- package/src/assets/images/superscript.svg +1 -0
- package/src/assets/images/table.svg +1 -0
- package/src/assets/images/title.svg +1 -0
- package/src/assets/images/trash.svg +1 -0
- package/src/assets/images/underline.svg +1 -0
- package/src/assets/images/undo.svg +1 -0
- package/src/assets/images/watermark.svg +1 -0
- package/src/assets/images/word-tool.svg +1 -0
- package/src/assets/snapshots/main_v0.2.1.png +0 -0
- package/src/assets/snapshots/main_v0.2.2.png +0 -0
- package/src/assets/snapshots/main_v0.3.0.png +0 -0
- package/src/assets/snapshots/main_v0.3.1.png +0 -0
- package/src/assets/snapshots/main_v0.5.0.png +0 -0
- package/src/assets/snapshots/main_v0.5.1.png +0 -0
- package/src/assets/snapshots/main_v0.6.0.png +0 -0
- package/src/assets/snapshots/main_v0.6.1.png +0 -0
- package/src/assets/snapshots/main_v0.7.0.png +0 -0
- package/src/assets/snapshots/main_v0.7.1.png +0 -0
- package/src/assets/snapshots/main_v0.7.2.png +0 -0
- package/src/assets/snapshots/main_v0.7.3.png +0 -0
- package/src/assets/snapshots/main_v0.7.4.png +0 -0
- package/src/assets/snapshots/main_v0.7.6.png +0 -0
- package/src/assets/snapshots/main_v0.7.7.png +0 -0
- package/src/assets/snapshots/main_v0.8.0.png +0 -0
- package/src/assets/snapshots/main_v0.8.5.png +0 -0
- package/src/assets/snapshots/main_v0.8.6.png +0 -0
- package/src/assets/snapshots/main_v0.8.7.png +0 -0
- package/src/assets/snapshots/main_v0.8.8.png +0 -0
- package/src/assets/snapshots/main_v0.9.0.png +0 -0
- package/src/assets/snapshots/main_v0.9.1.png +0 -0
- package/src/assets/snapshots/main_v0.9.2.png +0 -0
- package/src/assets/snapshots/main_v0.9.23.png +0 -0
- package/src/assets/snapshots/main_v0.9.28.png +0 -0
- package/src/assets/snapshots/main_v0.9.29.png +0 -0
- package/src/assets/snapshots/main_v0.9.3.png +0 -0
- package/src/assets/snapshots/main_v0.9.30.png +0 -0
- package/src/assets/snapshots/main_v0.9.32.png +0 -0
- package/src/assets/snapshots/main_v0.9.35.png +0 -0
- package/src/assets/snapshots/main_v0.9.4.png +0 -0
- package/src/assets/snapshots/main_v0.9.5.png +0 -0
- package/src/assets/snapshots/main_v0.9.6.png +0 -0
- package/src/assets/snapshots/main_v0.9.8.png +0 -0
- package/src/components/dialog/Dialog.ts +171 -0
- package/src/components/dialog/dialog.css +131 -0
- package/src/components/signature/Signature.ts +340 -0
- package/src/components/signature/signature.css +132 -0
- package/src/editor/assets/css/block/block.css +21 -0
- package/src/editor/assets/css/contextmenu/contextmenu.css +196 -0
- package/src/editor/assets/css/control/calculator.css +85 -0
- package/src/editor/assets/css/control/select.css +44 -0
- package/src/editor/assets/css/date/datePicker.css +233 -0
- package/src/editor/assets/css/hyperlink/hyperlink.css +26 -0
- package/src/editor/assets/css/index.css +78 -0
- package/src/editor/assets/css/previewer/previewer.css +122 -0
- package/src/editor/assets/css/resizer/resizer.css +74 -0
- package/src/editor/assets/css/table/table.css +155 -0
- package/src/editor/assets/css/zone/zone.css +61 -0
- package/src/editor/assets/images/close.svg +1 -0
- package/src/editor/assets/images/delete-col.svg +1 -0
- package/src/editor/assets/images/delete-row-col.svg +1 -0
- package/src/editor/assets/images/delete-row.svg +1 -0
- package/src/editor/assets/images/delete-table.svg +1 -0
- package/src/editor/assets/images/image-change.svg +1 -0
- package/src/editor/assets/images/image-download.svg +1 -0
- package/src/editor/assets/images/image-next.svg +1 -0
- package/src/editor/assets/images/image-pre.svg +1 -0
- package/src/editor/assets/images/image.svg +1 -0
- package/src/editor/assets/images/insert-bottom-row.svg +1 -0
- package/src/editor/assets/images/insert-left-col.svg +1 -0
- package/src/editor/assets/images/insert-right-col.svg +1 -0
- package/src/editor/assets/images/insert-row-col.svg +1 -0
- package/src/editor/assets/images/insert-top-row.svg +1 -0
- package/src/editor/assets/images/merge-cancel-cell.svg +1 -0
- package/src/editor/assets/images/merge-cell.svg +1 -0
- package/src/editor/assets/images/original-size.svg +1 -0
- package/src/editor/assets/images/print.svg +1 -0
- package/src/editor/assets/images/rotate.svg +1 -0
- package/src/editor/assets/images/submenu-dropdown.svg +1 -0
- package/src/editor/assets/images/table-border-all.svg +1 -0
- package/src/editor/assets/images/table-border-dash.svg +1 -0
- package/src/editor/assets/images/table-border-empty.svg +1 -0
- package/src/editor/assets/images/table-border-external.svg +1 -0
- package/src/editor/assets/images/table-border-internal.svg +1 -0
- package/src/editor/assets/images/table-border-td-back.svg +1 -0
- package/src/editor/assets/images/table-border-td-bottom.svg +1 -0
- package/src/editor/assets/images/table-border-td-forward.svg +1 -0
- package/src/editor/assets/images/table-border-td-left.svg +1 -0
- package/src/editor/assets/images/table-border-td-right.svg +1 -0
- package/src/editor/assets/images/table-border-td-top.svg +1 -0
- package/src/editor/assets/images/table-border-td.svg +1 -0
- package/src/editor/assets/images/vertical-align-bottom.svg +1 -0
- package/src/editor/assets/images/vertical-align-middle.svg +1 -0
- package/src/editor/assets/images/vertical-align-top.svg +1 -0
- package/src/editor/assets/images/vertical-align.svg +1 -0
- package/src/editor/assets/images/zoom-in.svg +1 -0
- package/src/editor/assets/images/zoom-out.svg +1 -0
- package/src/editor/core/actuator/Actuator.ts +21 -0
- package/src/editor/core/actuator/handlers/positionContextChange.ts +13 -0
- package/src/editor/core/command/Command.ts +312 -0
- package/src/editor/core/command/CommandAdapt.ts +2733 -0
- package/src/editor/core/contextmenu/ContextMenu.ts +363 -0
- package/src/editor/core/contextmenu/menus/controlMenus.ts +25 -0
- package/src/editor/core/contextmenu/menus/globalMenus.ts +66 -0
- package/src/editor/core/contextmenu/menus/hyperlinkMenus.ts +58 -0
- package/src/editor/core/contextmenu/menus/imageMenus.ts +134 -0
- package/src/editor/core/contextmenu/menus/tableMenus.ts +331 -0
- package/src/editor/core/cursor/Cursor.ts +248 -0
- package/src/editor/core/cursor/CursorAgent.ts +75 -0
- package/src/editor/core/draw/Draw.ts +2934 -0
- package/src/editor/core/draw/control/Control.ts +1767 -0
- package/src/editor/core/draw/control/checkbox/CheckboxControl.ts +154 -0
- package/src/editor/core/draw/control/date/DateControl.ts +363 -0
- package/src/editor/core/draw/control/interactive/ControlSearch.ts +214 -0
- package/src/editor/core/draw/control/number/Calculator.ts +183 -0
- package/src/editor/core/draw/control/number/NumberControl.ts +183 -0
- package/src/editor/core/draw/control/radio/RadioControl.ts +68 -0
- package/src/editor/core/draw/control/richtext/Border.ts +52 -0
- package/src/editor/core/draw/control/select/SelectControl.ts +567 -0
- package/src/editor/core/draw/control/text/TextControl.ts +280 -0
- package/src/editor/core/draw/frame/Background.ts +117 -0
- package/src/editor/core/draw/frame/Badge.ts +88 -0
- package/src/editor/core/draw/frame/Footer.ts +155 -0
- package/src/editor/core/draw/frame/Header.ts +158 -0
- package/src/editor/core/draw/frame/LineNumber.ts +43 -0
- package/src/editor/core/draw/frame/Margin.ts +53 -0
- package/src/editor/core/draw/frame/PageBorder.ts +47 -0
- package/src/editor/core/draw/frame/PageNumber.ts +88 -0
- package/src/editor/core/draw/frame/Placeholder.ts +114 -0
- package/src/editor/core/draw/frame/Watermark.ts +188 -0
- package/src/editor/core/draw/graffiti/Graffiti.ts +125 -0
- package/src/editor/core/draw/interactive/Area.ts +312 -0
- package/src/editor/core/draw/interactive/Group.ts +198 -0
- package/src/editor/core/draw/interactive/Search.ts +527 -0
- package/src/editor/core/draw/particle/CheckboxParticle.ts +111 -0
- package/src/editor/core/draw/particle/HyperlinkParticle.ts +86 -0
- package/src/editor/core/draw/particle/ImageParticle.ts +280 -0
- package/src/editor/core/draw/particle/LabelParticle.ts +79 -0
- package/src/editor/core/draw/particle/LineBreakParticle.ts +55 -0
- package/src/editor/core/draw/particle/ListParticle.ts +255 -0
- package/src/editor/core/draw/particle/PageBreakParticle.ts +54 -0
- package/src/editor/core/draw/particle/RadioParticle.ts +99 -0
- package/src/editor/core/draw/particle/SeparatorParticle.ts +37 -0
- package/src/editor/core/draw/particle/SubscriptParticle.ts +23 -0
- package/src/editor/core/draw/particle/SuperscriptParticle.ts +23 -0
- package/src/editor/core/draw/particle/TextParticle.ts +174 -0
- package/src/editor/core/draw/particle/WhiteSpaceParticle.ts +32 -0
- package/src/editor/core/draw/particle/block/BlockParticle.ts +76 -0
- package/src/editor/core/draw/particle/block/modules/BaseBlock.ts +280 -0
- package/src/editor/core/draw/particle/block/modules/IFrameBlock.ts +47 -0
- package/src/editor/core/draw/particle/block/modules/VideoBlock.ts +61 -0
- package/src/editor/core/draw/particle/date/DateParticle.ts +111 -0
- package/src/editor/core/draw/particle/date/DatePicker.ts +577 -0
- package/src/editor/core/draw/particle/latex/LaTexParticle.ts +43 -0
- package/src/editor/core/draw/particle/latex/utils/LaTexUtils.ts +1196 -0
- package/src/editor/core/draw/particle/latex/utils/hershey.ts +1632 -0
- package/src/editor/core/draw/particle/latex/utils/symbols.ts +318 -0
- package/src/editor/core/draw/particle/previewer/Previewer.ts +582 -0
- package/src/editor/core/draw/particle/table/TableOperate.ts +988 -0
- package/src/editor/core/draw/particle/table/TableParticle.ts +558 -0
- package/src/editor/core/draw/particle/table/TableTool.ts +551 -0
- package/src/editor/core/draw/richtext/AbstractRichText.ts +59 -0
- package/src/editor/core/draw/richtext/Highlight.ts +24 -0
- package/src/editor/core/draw/richtext/Strikeout.ts +28 -0
- package/src/editor/core/draw/richtext/Underline.ts +106 -0
- package/src/editor/core/event/CanvasEvent.ts +215 -0
- package/src/editor/core/event/GlobalEvent.ts +173 -0
- package/src/editor/core/event/eventbus/EventBus.ts +50 -0
- package/src/editor/core/event/handlers/click.ts +234 -0
- package/src/editor/core/event/handlers/composition.ts +45 -0
- package/src/editor/core/event/handlers/copy.ts +72 -0
- package/src/editor/core/event/handlers/cut.ts +47 -0
- package/src/editor/core/event/handlers/drag.ts +66 -0
- package/src/editor/core/event/handlers/drop.ts +28 -0
- package/src/editor/core/event/handlers/input.ts +129 -0
- package/src/editor/core/event/handlers/keydown/backspace.ts +161 -0
- package/src/editor/core/event/handlers/keydown/delete.ts +119 -0
- package/src/editor/core/event/handlers/keydown/end.ts +69 -0
- package/src/editor/core/event/handlers/keydown/enter.ts +126 -0
- package/src/editor/core/event/handlers/keydown/home.ts +69 -0
- package/src/editor/core/event/handlers/keydown/index.ts +85 -0
- package/src/editor/core/event/handlers/keydown/left.ts +162 -0
- package/src/editor/core/event/handlers/keydown/right.ts +178 -0
- package/src/editor/core/event/handlers/keydown/tab.ts +41 -0
- package/src/editor/core/event/handlers/keydown/updown.ts +342 -0
- package/src/editor/core/event/handlers/mousedown.ts +262 -0
- package/src/editor/core/event/handlers/mouseleave.ts +14 -0
- package/src/editor/core/event/handlers/mousemove.ts +133 -0
- package/src/editor/core/event/handlers/mouseup.ts +341 -0
- package/src/editor/core/event/handlers/paste.ts +231 -0
- package/src/editor/core/history/HistoryManager.ts +61 -0
- package/src/editor/core/i18n/I18n.ts +51 -0
- package/src/editor/core/i18n/lang/en.json +92 -0
- package/src/editor/core/i18n/lang/zh-CN.json +92 -0
- package/src/editor/core/listener/Listener.ts +41 -0
- package/src/editor/core/observer/ImageObserver.ts +19 -0
- package/src/editor/core/observer/MouseObserver.ts +56 -0
- package/src/editor/core/observer/ScrollObserver.ts +88 -0
- package/src/editor/core/observer/SelectionObserver.ts +143 -0
- package/src/editor/core/override/Override.ts +14 -0
- package/src/editor/core/plugin/Plugin.ts +17 -0
- package/src/editor/core/position/Position.ts +870 -0
- package/src/editor/core/range/RangeManager.ts +723 -0
- package/src/editor/core/register/Register.ts +28 -0
- package/src/editor/core/shortcut/Shortcut.ts +80 -0
- package/src/editor/core/shortcut/keys/listKeys.ts +22 -0
- package/src/editor/core/shortcut/keys/richtextKeys.ts +102 -0
- package/src/editor/core/shortcut/keys/titleKeys.ts +62 -0
- package/src/editor/core/worker/WorkerManager.ts +96 -0
- package/src/editor/core/worker/works/catalog.ts +189 -0
- package/src/editor/core/worker/works/group.ts +34 -0
- package/src/editor/core/worker/works/value.ts +32 -0
- package/src/editor/core/worker/works/wordCount.ts +132 -0
- package/src/editor/core/zone/Zone.ts +183 -0
- package/src/editor/core/zone/ZoneTip.ts +108 -0
- package/src/editor/dataset/constant/Background.ts +10 -0
- package/src/editor/dataset/constant/Badge.ts +6 -0
- package/src/editor/dataset/constant/Checkbox.ts +12 -0
- package/src/editor/dataset/constant/Common.ts +44 -0
- package/src/editor/dataset/constant/ContextMenu.ts +61 -0
- package/src/editor/dataset/constant/Control.ts +14 -0
- package/src/editor/dataset/constant/Cursor.ts +11 -0
- package/src/editor/dataset/constant/Editor.ts +19 -0
- package/src/editor/dataset/constant/Element.ts +173 -0
- package/src/editor/dataset/constant/Footer.ts +10 -0
- package/src/editor/dataset/constant/Graffiti.ts +6 -0
- package/src/editor/dataset/constant/Group.ts +10 -0
- package/src/editor/dataset/constant/Header.ts +10 -0
- package/src/editor/dataset/constant/ImgCaption.ts +8 -0
- package/src/editor/dataset/constant/Label.ts +8 -0
- package/src/editor/dataset/constant/LineBreak.ts +7 -0
- package/src/editor/dataset/constant/LineNumber.ts +11 -0
- package/src/editor/dataset/constant/List.ts +26 -0
- package/src/editor/dataset/constant/PageBorder.ts +8 -0
- package/src/editor/dataset/constant/PageBreak.ts +7 -0
- package/src/editor/dataset/constant/PageNumber.ts +22 -0
- package/src/editor/dataset/constant/Placeholder.ts +9 -0
- package/src/editor/dataset/constant/Radio.ts +12 -0
- package/src/editor/dataset/constant/Regular.ts +23 -0
- package/src/editor/dataset/constant/Separator.ts +6 -0
- package/src/editor/dataset/constant/Shortcut.ts +3 -0
- package/src/editor/dataset/constant/Table.ts +9 -0
- package/src/editor/dataset/constant/Title.ts +38 -0
- package/src/editor/dataset/constant/Watermark.ts +17 -0
- package/src/editor/dataset/constant/WhiteSpace.ts +7 -0
- package/src/editor/dataset/constant/Zone.ts +5 -0
- package/src/editor/dataset/enum/Area.ts +5 -0
- package/src/editor/dataset/enum/Background.ts +11 -0
- package/src/editor/dataset/enum/Block.ts +4 -0
- package/src/editor/dataset/enum/Common.ts +30 -0
- package/src/editor/dataset/enum/Control.ts +39 -0
- package/src/editor/dataset/enum/Editor.ts +51 -0
- package/src/editor/dataset/enum/Element.ts +21 -0
- package/src/editor/dataset/enum/ElementStyle.ts +12 -0
- package/src/editor/dataset/enum/Event.ts +5 -0
- package/src/editor/dataset/enum/KeyMap.ts +85 -0
- package/src/editor/dataset/enum/LineNumber.ts +4 -0
- package/src/editor/dataset/enum/List.ts +23 -0
- package/src/editor/dataset/enum/Observer.ts +6 -0
- package/src/editor/dataset/enum/Row.ts +7 -0
- package/src/editor/dataset/enum/Text.ts +13 -0
- package/src/editor/dataset/enum/Title.ts +8 -0
- package/src/editor/dataset/enum/VerticalAlign.ts +5 -0
- package/src/editor/dataset/enum/Watermark.ts +4 -0
- package/src/editor/dataset/enum/table/Table.ts +19 -0
- package/src/editor/dataset/enum/table/TableTool.ts +4 -0
- package/src/editor/index.ts +241 -0
- package/src/editor/interface/Area.ts +68 -0
- package/src/editor/interface/Background.ts +9 -0
- package/src/editor/interface/Badge.ts +17 -0
- package/src/editor/interface/Block.ts +18 -0
- package/src/editor/interface/Catalog.ts +11 -0
- package/src/editor/interface/Checkbox.ts +17 -0
- package/src/editor/interface/Command.ts +3 -0
- package/src/editor/interface/Common.ts +43 -0
- package/src/editor/interface/Control.ts +250 -0
- package/src/editor/interface/Cursor.ts +7 -0
- package/src/editor/interface/Draw.ts +86 -0
- package/src/editor/interface/Editor.ts +172 -0
- package/src/editor/interface/Element.ts +273 -0
- package/src/editor/interface/Event.ts +27 -0
- package/src/editor/interface/EventBus.ts +46 -0
- package/src/editor/interface/Footer.ts +9 -0
- package/src/editor/interface/Graffiti.ts +15 -0
- package/src/editor/interface/Group.ts +8 -0
- package/src/editor/interface/Header.ts +9 -0
- package/src/editor/interface/Label.ts +8 -0
- package/src/editor/interface/LineBreak.ts +5 -0
- package/src/editor/interface/LineNumber.ts +10 -0
- package/src/editor/interface/Listener.ts +88 -0
- package/src/editor/interface/Margin.ts +1 -0
- package/src/editor/interface/PageBorder.ts +8 -0
- package/src/editor/interface/PageBreak.ts +5 -0
- package/src/editor/interface/PageNumber.ts +16 -0
- package/src/editor/interface/Placeholder.ts +7 -0
- package/src/editor/interface/Plugin.ts +8 -0
- package/src/editor/interface/Position.ts +113 -0
- package/src/editor/interface/Previewer.ts +15 -0
- package/src/editor/interface/Radio.ts +17 -0
- package/src/editor/interface/Range.ts +61 -0
- package/src/editor/interface/Row.ts +25 -0
- package/src/editor/interface/Search.ts +36 -0
- package/src/editor/interface/Separator.ts +4 -0
- package/src/editor/interface/Text.ts +15 -0
- package/src/editor/interface/Title.ts +32 -0
- package/src/editor/interface/Watermark.ts +16 -0
- package/src/editor/interface/WhiteSpace.ts +5 -0
- package/src/editor/interface/Zone.ts +3 -0
- package/src/editor/interface/contextmenu/ContextMenu.ts +76 -0
- package/src/editor/interface/i18n/I18n.ts +7 -0
- package/src/editor/interface/shortcut/Shortcut.ts +14 -0
- package/src/editor/interface/table/Colgroup.ts +4 -0
- package/src/editor/interface/table/Table.ts +9 -0
- package/src/editor/interface/table/Td.ts +36 -0
- package/src/editor/interface/table/Tr.ts +11 -0
- package/src/editor/types/index.d.ts +5 -0
- package/src/editor/utils/clipboard.ts +94 -0
- package/src/editor/utils/element.ts +1877 -0
- package/src/editor/utils/hotkey.ts +5 -0
- package/src/editor/utils/index.ts +445 -0
- package/src/editor/utils/option.ts +253 -0
- package/src/editor/utils/paragraph.ts +28 -0
- package/src/editor/utils/print.ts +99 -0
- package/src/editor/utils/ua.ts +13 -0
- package/src/main.ts +2053 -0
- package/src/mock.ts +611 -0
- package/src/plugins/copy/index.ts +30 -0
- package/src/plugins/markdown/index.ts +118 -0
- package/src/style.css +1079 -0
- package/src/utils/index.ts +45 -0
- package/src/utils/prism.ts +89 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +25 -0
- package/vite.config.ts +46 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
.dialog-mask {
|
|
2
|
+
position: fixed;
|
|
3
|
+
left: 0;
|
|
4
|
+
top: 0;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
opacity: .5;
|
|
8
|
+
background: #000000;
|
|
9
|
+
z-index: 99;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.dialog-container {
|
|
13
|
+
position: fixed;
|
|
14
|
+
top: 0;
|
|
15
|
+
right: 0;
|
|
16
|
+
bottom: 0;
|
|
17
|
+
left: 0;
|
|
18
|
+
overflow: auto;
|
|
19
|
+
z-index: 999;
|
|
20
|
+
margin: 0;
|
|
21
|
+
display: flex;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
align-items: center;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.dialog {
|
|
27
|
+
position: absolute;
|
|
28
|
+
padding: 0 30px 30px;
|
|
29
|
+
background: #ffffff;
|
|
30
|
+
box-shadow: 0 2px 12px 0 rgb(56 56 56 / 20%);
|
|
31
|
+
border: 1px solid #e2e6ed;
|
|
32
|
+
border-radius: 2px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.dialog-title {
|
|
36
|
+
position: relative;
|
|
37
|
+
border-bottom: 1px solid #e2e6ed;
|
|
38
|
+
margin-bottom: 30px;
|
|
39
|
+
height: 60px;
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
justify-content: space-between;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.dialog-title i {
|
|
46
|
+
width: 16px;
|
|
47
|
+
height: 16px;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
display: inline-block;
|
|
50
|
+
background: url(../../assets/images/close.svg);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.dialog-option__item {
|
|
54
|
+
margin-bottom: 18px;
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
justify-content: space-between;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.dialog-option__item span {
|
|
61
|
+
margin-right: 12px;
|
|
62
|
+
font-size: 14px;
|
|
63
|
+
color: #3d4757;
|
|
64
|
+
position: relative;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.dialog-option__item input,
|
|
68
|
+
.dialog-option__item textarea,
|
|
69
|
+
.dialog-option__item select {
|
|
70
|
+
width: 276px;
|
|
71
|
+
height: 30px;
|
|
72
|
+
border-radius: 2px;
|
|
73
|
+
border: 1px solid #d3d3d3;
|
|
74
|
+
min-height: 30px;
|
|
75
|
+
padding: 5px;
|
|
76
|
+
box-sizing: border-box;
|
|
77
|
+
outline: none;
|
|
78
|
+
appearance: none;
|
|
79
|
+
user-select: none;
|
|
80
|
+
font-family: inherit;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.dialog-option__item input:focus,
|
|
84
|
+
.dialog-option__item textarea:focus {
|
|
85
|
+
border-color: #4991f2;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.dialog-option__item--require::before {
|
|
89
|
+
content: "*";
|
|
90
|
+
color: #f56c6c;
|
|
91
|
+
margin-right: 4px;
|
|
92
|
+
position: absolute;
|
|
93
|
+
left: -8px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.dialog-menu {
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
justify-content: flex-end;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.dialog-menu button {
|
|
103
|
+
position: relative;
|
|
104
|
+
display: inline-block;
|
|
105
|
+
border: 1px solid #e2e6ed;
|
|
106
|
+
border-radius: 2px;
|
|
107
|
+
background: #ffffff;
|
|
108
|
+
line-height: 22px;
|
|
109
|
+
padding: 0 16px;
|
|
110
|
+
white-space: nowrap;
|
|
111
|
+
cursor: pointer;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.dialog-menu button:hover {
|
|
115
|
+
background: rgba(25, 55, 88, .04);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.dialog-menu__cancel {
|
|
119
|
+
margin-right: 16px;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.dialog-menu button[type='submit'] {
|
|
123
|
+
color: #ffffff;
|
|
124
|
+
background: #4991f2;
|
|
125
|
+
border-color: #4991f2;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.dialog-menu button[type='submit']:hover {
|
|
129
|
+
background: #5b9cf3;
|
|
130
|
+
border-color: #5b9cf3;
|
|
131
|
+
}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { EditorComponent, EDITOR_COMPONENT } from '../../editor'
|
|
2
|
+
import './signature.css'
|
|
3
|
+
|
|
4
|
+
export interface ISignatureResult {
|
|
5
|
+
value: string
|
|
6
|
+
width: number
|
|
7
|
+
height: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ISignatureOptions {
|
|
11
|
+
width?: number
|
|
12
|
+
height?: number
|
|
13
|
+
onClose?: () => void
|
|
14
|
+
onCancel?: () => void
|
|
15
|
+
onConfirm?: (payload: ISignatureResult | null) => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class Signature {
|
|
19
|
+
private readonly MAX_RECORD_COUNT = 1000
|
|
20
|
+
private readonly DEFAULT_WIDTH = 390
|
|
21
|
+
private readonly DEFAULT_HEIGHT = 180
|
|
22
|
+
private undoStack: Array<Function> = []
|
|
23
|
+
private x = 0
|
|
24
|
+
private y = 0
|
|
25
|
+
private isDrawing = false
|
|
26
|
+
private isDrawn = false
|
|
27
|
+
private linePoints: [number, number][] = []
|
|
28
|
+
private canvasWidth: number
|
|
29
|
+
private canvasHeight: number
|
|
30
|
+
private options: ISignatureOptions
|
|
31
|
+
private mask: HTMLDivElement
|
|
32
|
+
private container: HTMLDivElement
|
|
33
|
+
private trashContainer: HTMLDivElement
|
|
34
|
+
private undoContainer: HTMLDivElement
|
|
35
|
+
private canvas: HTMLCanvasElement
|
|
36
|
+
private ctx: CanvasRenderingContext2D
|
|
37
|
+
private preTimeStamp: number
|
|
38
|
+
private dpr: number
|
|
39
|
+
|
|
40
|
+
constructor(options: ISignatureOptions) {
|
|
41
|
+
this.options = options
|
|
42
|
+
this.preTimeStamp = 0
|
|
43
|
+
this.dpr = window.devicePixelRatio
|
|
44
|
+
this.canvasWidth = (options.width || this.DEFAULT_WIDTH) * this.dpr
|
|
45
|
+
this.canvasHeight = (options.height || this.DEFAULT_HEIGHT) * this.dpr
|
|
46
|
+
const { mask, container, trashContainer, undoContainer, canvas } =
|
|
47
|
+
this._render()
|
|
48
|
+
this.mask = mask
|
|
49
|
+
this.container = container
|
|
50
|
+
this.trashContainer = trashContainer
|
|
51
|
+
this.undoContainer = undoContainer
|
|
52
|
+
this.canvas = canvas
|
|
53
|
+
this.ctx = <CanvasRenderingContext2D>canvas.getContext('2d')
|
|
54
|
+
this.ctx.scale(this.dpr, this.dpr)
|
|
55
|
+
this.ctx.lineCap = 'round'
|
|
56
|
+
this._bindEvent()
|
|
57
|
+
this._clearUndoFn()
|
|
58
|
+
// this is necessary so that the screen does not move when moving - it is removed when closing the modal
|
|
59
|
+
document.documentElement.classList.add('overflow-hidden')
|
|
60
|
+
document.body.classList.add('overflow-hidden')
|
|
61
|
+
this.container.classList.add('overflow-hidden')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private _render() {
|
|
65
|
+
const { onClose, onCancel, onConfirm } = this.options
|
|
66
|
+
// 渲染遮罩层
|
|
67
|
+
const mask = document.createElement('div')
|
|
68
|
+
mask.classList.add('signature-mask')
|
|
69
|
+
mask.setAttribute(EDITOR_COMPONENT, EditorComponent.COMPONENT)
|
|
70
|
+
document.body.append(mask)
|
|
71
|
+
// 渲染容器
|
|
72
|
+
const container = document.createElement('div')
|
|
73
|
+
container.classList.add('signature-container')
|
|
74
|
+
container.setAttribute(EDITOR_COMPONENT, EditorComponent.COMPONENT)
|
|
75
|
+
// 弹窗
|
|
76
|
+
const signatureContainer = document.createElement('div')
|
|
77
|
+
signatureContainer.classList.add('signature')
|
|
78
|
+
container.append(signatureContainer)
|
|
79
|
+
// 标题容器
|
|
80
|
+
const titleContainer = document.createElement('div')
|
|
81
|
+
titleContainer.classList.add('signature-title')
|
|
82
|
+
// 标题&关闭按钮
|
|
83
|
+
const titleSpan = document.createElement('span')
|
|
84
|
+
titleSpan.append(document.createTextNode('插入签名'))
|
|
85
|
+
const titleClose = document.createElement('i')
|
|
86
|
+
titleClose.onclick = () => {
|
|
87
|
+
if (onClose) {
|
|
88
|
+
onClose()
|
|
89
|
+
}
|
|
90
|
+
this._dispose()
|
|
91
|
+
}
|
|
92
|
+
titleContainer.append(titleSpan)
|
|
93
|
+
titleContainer.append(titleClose)
|
|
94
|
+
signatureContainer.append(titleContainer)
|
|
95
|
+
// 操作区
|
|
96
|
+
const operationContainer = document.createElement('div')
|
|
97
|
+
operationContainer.classList.add('signature-operation')
|
|
98
|
+
// 撤销
|
|
99
|
+
const undoContainer = document.createElement('div')
|
|
100
|
+
undoContainer.classList.add('signature-operation__undo')
|
|
101
|
+
const undoIcon = document.createElement('i')
|
|
102
|
+
const undoLabel = document.createElement('span')
|
|
103
|
+
undoLabel.innerText = '撤销'
|
|
104
|
+
undoContainer.append(undoIcon)
|
|
105
|
+
undoContainer.append(undoLabel)
|
|
106
|
+
operationContainer.append(undoContainer)
|
|
107
|
+
// 清空画布
|
|
108
|
+
const trashContainer = document.createElement('div')
|
|
109
|
+
trashContainer.classList.add('signature-operation__trash')
|
|
110
|
+
const trashIcon = document.createElement('i')
|
|
111
|
+
const trashLabel = document.createElement('span')
|
|
112
|
+
trashLabel.innerText = '清空'
|
|
113
|
+
trashContainer.append(trashIcon)
|
|
114
|
+
trashContainer.append(trashLabel)
|
|
115
|
+
operationContainer.append(trashContainer)
|
|
116
|
+
signatureContainer.append(operationContainer)
|
|
117
|
+
// 绘图区
|
|
118
|
+
const canvasContainer = document.createElement('div')
|
|
119
|
+
canvasContainer.classList.add('signature-canvas')
|
|
120
|
+
const canvas = document.createElement('canvas')
|
|
121
|
+
canvas.width = this.canvasWidth
|
|
122
|
+
canvas.height = this.canvasHeight
|
|
123
|
+
canvas.style.width = `${this.canvasWidth / this.dpr}px`
|
|
124
|
+
canvas.style.height = `${this.canvasHeight / this.dpr}px`
|
|
125
|
+
canvasContainer.append(canvas)
|
|
126
|
+
signatureContainer.append(canvasContainer)
|
|
127
|
+
// 按钮容器
|
|
128
|
+
const menuContainer = document.createElement('div')
|
|
129
|
+
menuContainer.classList.add('signature-menu')
|
|
130
|
+
// 取消按钮
|
|
131
|
+
const cancelBtn = document.createElement('button')
|
|
132
|
+
cancelBtn.classList.add('signature-menu__cancel')
|
|
133
|
+
cancelBtn.append(document.createTextNode('取消'))
|
|
134
|
+
cancelBtn.type = 'button'
|
|
135
|
+
cancelBtn.onclick = () => {
|
|
136
|
+
if (onCancel) {
|
|
137
|
+
onCancel()
|
|
138
|
+
}
|
|
139
|
+
this._dispose()
|
|
140
|
+
}
|
|
141
|
+
menuContainer.append(cancelBtn)
|
|
142
|
+
// 确认按钮
|
|
143
|
+
const confirmBtn = document.createElement('button')
|
|
144
|
+
confirmBtn.append(document.createTextNode('确定'))
|
|
145
|
+
confirmBtn.type = 'submit'
|
|
146
|
+
confirmBtn.onclick = () => {
|
|
147
|
+
if (onConfirm) {
|
|
148
|
+
onConfirm(this._toData())
|
|
149
|
+
}
|
|
150
|
+
this._dispose()
|
|
151
|
+
}
|
|
152
|
+
menuContainer.append(confirmBtn)
|
|
153
|
+
signatureContainer.append(menuContainer)
|
|
154
|
+
// 渲染
|
|
155
|
+
document.body.append(container)
|
|
156
|
+
this.container = container
|
|
157
|
+
this.mask = mask
|
|
158
|
+
return {
|
|
159
|
+
mask,
|
|
160
|
+
canvas,
|
|
161
|
+
container,
|
|
162
|
+
trashContainer,
|
|
163
|
+
undoContainer
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private _bindEvent() {
|
|
168
|
+
this.trashContainer.onclick = this._clearCanvas.bind(this)
|
|
169
|
+
this.undoContainer.onclick = this._undo.bind(this)
|
|
170
|
+
this.canvas.onmousedown = this._startDraw.bind(this)
|
|
171
|
+
this.canvas.onmousemove = this._draw.bind(this)
|
|
172
|
+
this.container.onmouseup = this._stopDraw.bind(this)
|
|
173
|
+
this.container.ontouchmove = this.registerTouchmove.bind(this)
|
|
174
|
+
this.container.ontouchstart = this.registerTouchstart.bind(this)
|
|
175
|
+
this.container.ontouchend = this.registerTouchend.bind(this)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private _undo() {
|
|
179
|
+
if (this.undoStack.length > 1) {
|
|
180
|
+
this.undoStack.pop()
|
|
181
|
+
if (this.undoStack.length) {
|
|
182
|
+
this.undoStack[this.undoStack.length - 1]()
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private _saveUndoFn(fn: Function) {
|
|
188
|
+
this.undoStack.push(fn)
|
|
189
|
+
while (this.undoStack.length > this.MAX_RECORD_COUNT) {
|
|
190
|
+
this.undoStack.shift()
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private _clearUndoFn() {
|
|
195
|
+
const clearFn = () => {
|
|
196
|
+
this.ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight)
|
|
197
|
+
}
|
|
198
|
+
this.undoStack = [clearFn]
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
private _clearCanvas() {
|
|
202
|
+
this._clearUndoFn()
|
|
203
|
+
this.ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
private _startDraw(evt: MouseEvent) {
|
|
207
|
+
this.isDrawing = true
|
|
208
|
+
this.x = evt.offsetX
|
|
209
|
+
this.y = evt.offsetY
|
|
210
|
+
this.ctx.lineWidth = 1
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
private _draw(evt: MouseEvent) {
|
|
214
|
+
if (!this.isDrawing) return
|
|
215
|
+
// 计算鼠标移动速度
|
|
216
|
+
const curTimestamp = performance.now()
|
|
217
|
+
const distance = Math.sqrt(evt.movementX ** 2 + evt.movementY ** 2)
|
|
218
|
+
const speed = distance / (curTimestamp - this.preTimeStamp)
|
|
219
|
+
// 目标线宽:最小速度1,最大速度5,系数3
|
|
220
|
+
const SPEED_FACTOR = 3
|
|
221
|
+
const targetLineWidth = Math.min(5, Math.max(1, 5 - speed * SPEED_FACTOR))
|
|
222
|
+
// 平滑过渡算法(20%的变化比例)调整线条粗细:系数0.2
|
|
223
|
+
const SMOOTH_FACTOR = 0.2
|
|
224
|
+
this.ctx.lineWidth =
|
|
225
|
+
this.ctx.lineWidth * (1 - SMOOTH_FACTOR) + targetLineWidth * SMOOTH_FACTOR
|
|
226
|
+
// 绘制
|
|
227
|
+
const { offsetX, offsetY } = evt
|
|
228
|
+
this.ctx.beginPath()
|
|
229
|
+
this.ctx.moveTo(this.x, this.y)
|
|
230
|
+
this.ctx.lineTo(offsetX, offsetY)
|
|
231
|
+
this.ctx.stroke()
|
|
232
|
+
this.x = offsetX
|
|
233
|
+
this.y = offsetY
|
|
234
|
+
this.linePoints.push([offsetX, offsetY])
|
|
235
|
+
this.isDrawn = true
|
|
236
|
+
// 缓存之前时间戳
|
|
237
|
+
this.preTimeStamp = curTimestamp
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
private _stopDraw() {
|
|
241
|
+
this.isDrawing = false
|
|
242
|
+
if (this.isDrawn) {
|
|
243
|
+
const imageData = this.ctx.getImageData(
|
|
244
|
+
0,
|
|
245
|
+
0,
|
|
246
|
+
this.canvasWidth,
|
|
247
|
+
this.canvasHeight
|
|
248
|
+
)
|
|
249
|
+
const self = this
|
|
250
|
+
this._saveUndoFn(function () {
|
|
251
|
+
self.ctx.clearRect(0, 0, self.canvasWidth, self.canvasHeight)
|
|
252
|
+
self.ctx.putImageData(imageData, 0, 0)
|
|
253
|
+
})
|
|
254
|
+
this.isDrawn = false
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private _toData(): ISignatureResult | null {
|
|
259
|
+
if (!this.linePoints.length) return null
|
|
260
|
+
// 查找矩形四角坐标
|
|
261
|
+
const startX = this.linePoints[0][0]
|
|
262
|
+
const startY = this.linePoints[0][1]
|
|
263
|
+
let minX = startX
|
|
264
|
+
let minY = startY
|
|
265
|
+
let maxX = startX
|
|
266
|
+
let maxY = startY
|
|
267
|
+
for (let p = 0; p < this.linePoints.length; p++) {
|
|
268
|
+
const point = this.linePoints[p]
|
|
269
|
+
if (minX > point[0]) {
|
|
270
|
+
minX = point[0]
|
|
271
|
+
}
|
|
272
|
+
if (maxX < point[0]) {
|
|
273
|
+
maxX = point[0]
|
|
274
|
+
}
|
|
275
|
+
if (minY > point[1]) {
|
|
276
|
+
minY = point[1]
|
|
277
|
+
}
|
|
278
|
+
if (maxY < point[1]) {
|
|
279
|
+
maxY = point[1]
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
// 增加边框宽度
|
|
283
|
+
const lineWidth = this.ctx.lineWidth
|
|
284
|
+
minX = minX < lineWidth ? 0 : minX - lineWidth
|
|
285
|
+
minY = minY < lineWidth ? 0 : minY - lineWidth
|
|
286
|
+
maxX = maxX + lineWidth
|
|
287
|
+
maxY = maxY + lineWidth
|
|
288
|
+
const sw = maxX - minX
|
|
289
|
+
const sh = maxY - minY
|
|
290
|
+
// 裁剪图像
|
|
291
|
+
const imageData = this.ctx.getImageData(
|
|
292
|
+
minX * this.dpr,
|
|
293
|
+
minY * this.dpr,
|
|
294
|
+
sw * this.dpr,
|
|
295
|
+
sh * this.dpr
|
|
296
|
+
)
|
|
297
|
+
const canvas = document.createElement('canvas')
|
|
298
|
+
canvas.style.width = `${sw}px`
|
|
299
|
+
canvas.style.height = `${sh}px`
|
|
300
|
+
canvas.width = sw * this.dpr
|
|
301
|
+
canvas.height = sh * this.dpr
|
|
302
|
+
const ctx = <CanvasRenderingContext2D>canvas.getContext('2d')!
|
|
303
|
+
ctx.putImageData(imageData, 0, 0)
|
|
304
|
+
const value = canvas.toDataURL()
|
|
305
|
+
return {
|
|
306
|
+
value,
|
|
307
|
+
width: sw,
|
|
308
|
+
height: sh
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
private registerTouchmove(evt: TouchEvent) {
|
|
313
|
+
this.registerTouchEvent(evt, 'mousemove')
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
private registerTouchstart(evt: TouchEvent) {
|
|
317
|
+
this.registerTouchEvent(evt, 'mousedown')
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
private registerTouchend() {
|
|
321
|
+
const me = new MouseEvent('mouseup', {})
|
|
322
|
+
this.canvas.dispatchEvent(me)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
private registerTouchEvent(evt: TouchEvent, eventName: string) {
|
|
326
|
+
const touch = evt.touches[0]
|
|
327
|
+
const me = new MouseEvent(eventName, {
|
|
328
|
+
clientX: touch.clientX,
|
|
329
|
+
clientY: touch.clientY
|
|
330
|
+
})
|
|
331
|
+
this.canvas.dispatchEvent(me)
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
private _dispose() {
|
|
335
|
+
this.mask.remove()
|
|
336
|
+
this.container.remove()
|
|
337
|
+
document.documentElement.classList.remove('overflow-hidden')
|
|
338
|
+
document.body.classList.remove('overflow-hidden')
|
|
339
|
+
}
|
|
340
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
.signature-mask {
|
|
2
|
+
position: fixed;
|
|
3
|
+
left: 0;
|
|
4
|
+
top: 0;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
opacity: .5;
|
|
8
|
+
background: #000000;
|
|
9
|
+
z-index: 99;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.signature-container {
|
|
13
|
+
position: fixed;
|
|
14
|
+
top: 0;
|
|
15
|
+
right: 0;
|
|
16
|
+
bottom: 0;
|
|
17
|
+
left: 0;
|
|
18
|
+
overflow: auto;
|
|
19
|
+
z-index: 999;
|
|
20
|
+
margin: 0;
|
|
21
|
+
display: flex;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
align-items: center;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.signature {
|
|
27
|
+
position: absolute;
|
|
28
|
+
padding: 0 30px 30px;
|
|
29
|
+
background: #ffffff;
|
|
30
|
+
box-shadow: 0 2px 12px 0 rgb(56 56 56 / 20%);
|
|
31
|
+
border: 1px solid #e2e6ed;
|
|
32
|
+
border-radius: 2px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.signature-title {
|
|
36
|
+
position: relative;
|
|
37
|
+
border-bottom: 1px solid #e2e6ed;
|
|
38
|
+
margin-bottom: 15px;
|
|
39
|
+
height: 60px;
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
justify-content: space-between;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.signature-title i {
|
|
46
|
+
width: 16px;
|
|
47
|
+
height: 16px;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
display: inline-block;
|
|
50
|
+
background: url(../../assets/images/close.svg);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.signature-operation>div {
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
display: inline-flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
color: #3d4757;
|
|
58
|
+
user-select: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.signature-operation>div:hover {
|
|
62
|
+
color: #6e7175;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.signature-operation>div i {
|
|
66
|
+
width: 24px;
|
|
67
|
+
height: 24px;
|
|
68
|
+
display: inline-block;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.signature-operation__undo {
|
|
72
|
+
background: url(../../assets/images/signature-undo.svg) no-repeat;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.signature-operation__trash {
|
|
76
|
+
background: url(../../assets/images/trash.svg) no-repeat;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.signature-operation>div span {
|
|
80
|
+
font-size: 12px;
|
|
81
|
+
margin: 0 5px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.signature-canvas {
|
|
85
|
+
margin: 15px 0;
|
|
86
|
+
user-select: none;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.signature-canvas canvas {
|
|
90
|
+
background: #f3f5f7;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.signature-menu {
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
justify-content: flex-end;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.signature-menu button {
|
|
100
|
+
position: relative;
|
|
101
|
+
display: inline-block;
|
|
102
|
+
border: 1px solid #e2e6ed;
|
|
103
|
+
border-radius: 2px;
|
|
104
|
+
background: #ffffff;
|
|
105
|
+
line-height: 22px;
|
|
106
|
+
padding: 0 16px;
|
|
107
|
+
white-space: nowrap;
|
|
108
|
+
cursor: pointer;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.signature-menu button:hover {
|
|
112
|
+
background: rgba(25, 55, 88, .04);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.signature-menu__cancel {
|
|
116
|
+
margin-right: 16px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.signature-menu button[type='submit'] {
|
|
120
|
+
color: #ffffff;
|
|
121
|
+
background: #4991f2;
|
|
122
|
+
border-color: #4991f2;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.signature-menu button[type='submit']:hover {
|
|
126
|
+
background: #5b9cf3;
|
|
127
|
+
border-color: #5b9cf3;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.overflow-hidden {
|
|
131
|
+
overflow: hidden !important;
|
|
132
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.ce-block-item {
|
|
2
|
+
position: absolute;
|
|
3
|
+
z-index: 0;
|
|
4
|
+
background-color: #ffffff;
|
|
5
|
+
border: 1px solid rgb(235 236 240);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.ce-block-item .ce-resizer-selection {
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 100%;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.ce-block-item .ce-resizer-mask {
|
|
14
|
+
position: absolute;
|
|
15
|
+
top: 0;
|
|
16
|
+
bottom: 0;
|
|
17
|
+
left: 0;
|
|
18
|
+
right: 0;
|
|
19
|
+
z-index: 1;
|
|
20
|
+
background-color: transparent;
|
|
21
|
+
}
|