@visactor/vrender-core 0.21.14 → 0.22.0-vstory.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/animate/Ticker/default-ticker.d.ts +2 -0
- package/cjs/animate/Ticker/default-ticker.js +7 -1
- package/cjs/animate/Ticker/default-ticker.js.map +1 -1
- package/cjs/animate/animate.js +2 -2
- package/cjs/animate/animate.js.map +1 -1
- package/cjs/animate/custom-animate.js +15 -27
- package/cjs/animate/custom-animate.js.map +1 -1
- package/cjs/animate/easing-func.d.ts +1 -0
- package/cjs/animate/easing-func.js +16 -0
- package/cjs/animate/easing-func.js.map +1 -0
- package/cjs/animate/easing.d.ts +4 -0
- package/cjs/animate/easing.js +24 -1
- package/cjs/animate/easing.js.map +1 -1
- package/cjs/animate/index.d.ts +1 -0
- package/cjs/animate/index.js +1 -1
- package/cjs/animate/index.js.map +1 -1
- package/cjs/canvas/util.js +1 -2
- package/cjs/common/3d-interceptor.js +2 -1
- package/cjs/common/bezier-utils.d.ts +3 -0
- package/cjs/common/bezier-utils.js +17 -2
- package/cjs/common/bezier-utils.js.map +1 -1
- package/cjs/common/custom-path2d.d.ts +4 -0
- package/cjs/common/custom-path2d.js +43 -11
- package/cjs/common/custom-path2d.js.map +1 -1
- package/cjs/common/inversify/container.js +6 -9
- package/cjs/common/inversify/container.js.map +1 -1
- package/cjs/common/render-area.d.ts +4 -0
- package/cjs/common/render-area.js +76 -17
- package/cjs/common/render-area.js.map +1 -1
- package/cjs/common/render-command-list.js +2 -1
- package/cjs/common/render-curve.d.ts +1 -1
- package/cjs/common/render-curve.js.map +1 -1
- package/cjs/common/segment/curve/arc.d.ts +4 -1
- package/cjs/common/segment/curve/arc.js +10 -1
- package/cjs/common/segment/curve/arc.js.map +1 -1
- package/cjs/common/segment/curve/base.d.ts +4 -1
- package/cjs/common/segment/curve/base.js.map +1 -1
- package/cjs/common/segment/curve/cubic-bezier.d.ts +5 -1
- package/cjs/common/segment/curve/cubic-bezier.js +24 -3
- package/cjs/common/segment/curve/cubic-bezier.js.map +1 -1
- package/cjs/common/segment/curve/curve-context.js +5 -4
- package/cjs/common/segment/curve/curve-context.js.map +1 -1
- package/cjs/common/segment/curve/ellipse.d.ts +4 -1
- package/cjs/common/segment/curve/ellipse.js +9 -0
- package/cjs/common/segment/curve/ellipse.js.map +1 -1
- package/cjs/common/segment/curve/line.d.ts +4 -1
- package/cjs/common/segment/curve/line.js +18 -0
- package/cjs/common/segment/curve/line.js.map +1 -1
- package/cjs/common/segment/curve/move.d.ts +4 -1
- package/cjs/common/segment/curve/move.js +9 -0
- package/cjs/common/segment/curve/move.js.map +1 -1
- package/cjs/common/segment/curve/path.d.ts +2 -1
- package/cjs/common/segment/curve/path.js +5 -2
- package/cjs/common/segment/curve/path.js.map +1 -1
- package/cjs/common/segment/curve/quadratic-bezier.d.ts +6 -2
- package/cjs/common/segment/curve/quadratic-bezier.js +23 -5
- package/cjs/common/segment/curve/quadratic-bezier.js.map +1 -1
- package/cjs/common/segment/step.js +1 -1
- package/cjs/common/segment/step.js.map +1 -1
- package/cjs/common/shape/rect.d.ts +1 -1
- package/cjs/common/shape/rect.js +30 -25
- package/cjs/common/shape/rect.js.map +1 -1
- package/cjs/common/store.js +1 -1
- package/cjs/core/contributions/env/base-contribution.d.ts +2 -0
- package/cjs/core/contributions/env/base-contribution.js +6 -0
- package/cjs/core/contributions/env/base-contribution.js.map +1 -1
- package/cjs/core/contributions/textMeasure/AtextMeasure.js +0 -10
- package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/cjs/core/global.d.ts +2 -3
- package/cjs/core/global.js +7 -7
- package/cjs/core/global.js.map +1 -1
- package/cjs/graphic/builtin-symbol/rect.d.ts +2 -1
- package/cjs/graphic/builtin-symbol/rect.js +28 -0
- package/cjs/graphic/builtin-symbol/rect.js.map +1 -1
- package/cjs/graphic/builtin-symbol/utils.d.ts +2 -1
- package/cjs/graphic/builtin-symbol/utils.js +5 -0
- package/cjs/graphic/builtin-symbol/utils.js.map +1 -1
- package/cjs/graphic/config.js +20 -5
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/graphic.d.ts +1 -1
- package/cjs/graphic/graphic.js +20 -6
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/group.js +1 -1
- package/cjs/graphic/group.js.map +1 -1
- package/cjs/graphic/line.js +2 -2
- package/cjs/graphic/line.js.map +1 -1
- package/cjs/graphic/richtext/line.js +13 -1
- package/cjs/graphic/richtext/line.js.map +1 -1
- package/cjs/graphic/richtext/paragraph.d.ts +9 -1
- package/cjs/graphic/richtext/paragraph.js +49 -5
- package/cjs/graphic/richtext/paragraph.js.map +1 -1
- package/cjs/graphic/richtext/utils.d.ts +4 -0
- package/cjs/graphic/richtext/utils.js +23 -10
- package/cjs/graphic/richtext/utils.js.map +1 -1
- package/cjs/graphic/richtext/wrapper.d.ts +1 -0
- package/cjs/graphic/richtext/wrapper.js +1 -1
- package/cjs/graphic/richtext/wrapper.js.map +1 -1
- package/cjs/graphic/richtext.d.ts +8 -2
- package/cjs/graphic/richtext.js +43 -4
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +2 -1
- package/cjs/index.js.map +1 -1
- package/cjs/interface/animate.d.ts +5 -39
- package/cjs/interface/animate.js.map +1 -1
- package/cjs/interface/color.js.map +1 -1
- package/cjs/interface/context.d.ts +1 -0
- package/cjs/interface/context.js.map +1 -1
- package/cjs/interface/global.d.ts +4 -1
- package/cjs/interface/global.js.map +1 -1
- package/cjs/interface/graphic/group.d.ts +1 -0
- package/cjs/interface/graphic/group.js.map +1 -1
- package/cjs/interface/graphic/image.d.ts +1 -0
- package/cjs/interface/graphic/image.js.map +1 -1
- package/cjs/interface/graphic/path.d.ts +1 -0
- package/cjs/interface/graphic/path.js.map +1 -1
- package/cjs/interface/graphic/rect.d.ts +1 -0
- package/cjs/interface/graphic/rect.js.map +1 -1
- package/cjs/interface/graphic/richText.d.ts +13 -0
- package/cjs/interface/graphic/richText.js.map +1 -1
- package/cjs/interface/graphic/symbol.d.ts +2 -0
- package/cjs/interface/graphic/symbol.js.map +1 -1
- package/cjs/interface/graphic.d.ts +12 -3
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/path.d.ts +5 -0
- package/cjs/interface/path.js.map +1 -1
- package/cjs/interface/picker.d.ts +13 -0
- package/cjs/interface/picker.js.map +1 -1
- package/cjs/picker/constants.d.ts +2 -0
- package/cjs/picker/constants.js +3 -2
- package/cjs/picker/constants.js.map +1 -1
- package/cjs/picker/pick-interceptor.d.ts +7 -2
- package/cjs/picker/pick-interceptor.js +19 -2
- package/cjs/picker/pick-interceptor.js.map +1 -1
- package/cjs/picker/pick-modules.js +7 -4
- package/cjs/picker/pick-modules.js.map +1 -1
- package/cjs/picker/picker-service.d.ts +4 -2
- package/cjs/picker/picker-service.js +13 -12
- package/cjs/picker/picker-service.js.map +1 -1
- package/cjs/plugins/builtin-plugin/edit-module.d.ts +17 -6
- package/cjs/plugins/builtin-plugin/edit-module.js +128 -42
- package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +1 -0
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js +3 -0
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +1 -0
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +91 -32
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +517 -193
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/cjs/render/contributions/render/arc3d-render.js.map +1 -1
- package/cjs/render/contributions/render/area-render.d.ts +1 -1
- package/cjs/render/contributions/render/area-render.js +36 -16
- package/cjs/render/contributions/render/area-render.js.map +1 -1
- package/cjs/render/contributions/render/base-render.d.ts +1 -0
- package/cjs/render/contributions/render/base-render.js +20 -2
- package/cjs/render/contributions/render/base-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/base-contribution-render.d.ts +7 -1
- package/cjs/render/contributions/render/contributions/base-contribution-render.js +16 -8
- package/cjs/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js +29 -2
- package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/group-contribution-render.js +8 -3
- package/cjs/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/image-contribution-render.d.ts +1 -1
- package/cjs/render/contributions/render/contributions/image-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/rect-contribution-render.js +4 -4
- package/cjs/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.d.ts +8 -1
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.js +30 -2
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/text-contribution-render.js +5 -3
- package/cjs/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/draw-contribution.js +3 -3
- package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
- package/cjs/render/contributions/render/group-render.js +2 -2
- package/cjs/render/contributions/render/group-render.js.map +1 -1
- package/cjs/render/contributions/render/image-render.js +3 -3
- package/cjs/render/contributions/render/image-render.js.map +1 -1
- package/cjs/render/contributions/render/line-render.js +31 -9
- package/cjs/render/contributions/render/line-render.js.map +1 -1
- package/cjs/render/contributions/render/path-render.js.map +1 -1
- package/cjs/render/contributions/render/polygon-render.js.map +1 -1
- package/cjs/render/contributions/render/rect-render.js +2 -2
- package/cjs/render/contributions/render/rect-render.js.map +1 -1
- package/cjs/render/contributions/render/richtext-render.js +1 -1
- package/cjs/render/contributions/render/richtext-render.js.map +1 -1
- package/cjs/render/contributions/render/symbol-render.js +15 -13
- package/cjs/render/contributions/render/symbol-render.js.map +1 -1
- package/cjs/render/contributions/render/utils.d.ts +1 -2
- package/cjs/render/contributions/render/utils.js +4 -20
- package/cjs/render/contributions/render/utils.js.map +1 -1
- package/cjs/resource-loader/loader.js +1 -1
- package/cjs/resource-loader/loader.js.map +1 -1
- package/dist/index.es.js +9073 -7513
- package/es/animate/Ticker/default-ticker.d.ts +2 -0
- package/es/animate/Ticker/default-ticker.js +7 -1
- package/es/animate/Ticker/default-ticker.js.map +1 -1
- package/es/animate/animate.js +4 -5
- package/es/animate/animate.js.map +1 -1
- package/es/animate/custom-animate.js +15 -27
- package/es/animate/custom-animate.js.map +1 -1
- package/es/animate/easing-func.d.ts +1 -0
- package/es/animate/easing-func.js +10 -0
- package/es/animate/easing-func.js.map +1 -0
- package/es/animate/easing.d.ts +4 -0
- package/es/animate/easing.js +24 -1
- package/es/animate/easing.js.map +1 -1
- package/es/animate/index.d.ts +1 -0
- package/es/animate/index.js +2 -0
- package/es/animate/index.js.map +1 -1
- package/es/canvas/util.js +1 -2
- package/es/common/3d-interceptor.js +2 -1
- package/es/common/bezier-utils.d.ts +3 -0
- package/es/common/bezier-utils.js +14 -0
- package/es/common/bezier-utils.js.map +1 -1
- package/es/common/custom-path2d.d.ts +4 -0
- package/es/common/custom-path2d.js +44 -12
- package/es/common/custom-path2d.js.map +1 -1
- package/es/common/inversify/container.js +6 -9
- package/es/common/inversify/container.js.map +1 -1
- package/es/common/render-area.d.ts +4 -0
- package/es/common/render-area.js +77 -18
- package/es/common/render-area.js.map +1 -1
- package/es/common/render-command-list.js +2 -1
- package/es/common/render-curve.d.ts +1 -1
- package/es/common/render-curve.js.map +1 -1
- package/es/common/segment/curve/arc.d.ts +4 -1
- package/es/common/segment/curve/arc.js +10 -1
- package/es/common/segment/curve/arc.js.map +1 -1
- package/es/common/segment/curve/base.d.ts +4 -1
- package/es/common/segment/curve/base.js.map +1 -1
- package/es/common/segment/curve/cubic-bezier.d.ts +5 -1
- package/es/common/segment/curve/cubic-bezier.js +22 -1
- package/es/common/segment/curve/cubic-bezier.js.map +1 -1
- package/es/common/segment/curve/curve-context.js +6 -3
- package/es/common/segment/curve/curve-context.js.map +1 -1
- package/es/common/segment/curve/ellipse.d.ts +4 -1
- package/es/common/segment/curve/ellipse.js +9 -0
- package/es/common/segment/curve/ellipse.js.map +1 -1
- package/es/common/segment/curve/line.d.ts +4 -1
- package/es/common/segment/curve/line.js +18 -0
- package/es/common/segment/curve/line.js.map +1 -1
- package/es/common/segment/curve/move.d.ts +4 -1
- package/es/common/segment/curve/move.js +9 -0
- package/es/common/segment/curve/move.js.map +1 -1
- package/es/common/segment/curve/path.d.ts +2 -1
- package/es/common/segment/curve/path.js +5 -2
- package/es/common/segment/curve/path.js.map +1 -1
- package/es/common/segment/curve/quadratic-bezier.d.ts +6 -2
- package/es/common/segment/curve/quadratic-bezier.js +28 -5
- package/es/common/segment/curve/quadratic-bezier.js.map +1 -1
- package/es/common/segment/step.js +1 -1
- package/es/common/segment/step.js.map +1 -1
- package/es/common/shape/rect.d.ts +1 -1
- package/es/common/shape/rect.js +30 -25
- package/es/common/shape/rect.js.map +1 -1
- package/es/common/store.js +1 -1
- package/es/core/contributions/env/base-contribution.d.ts +2 -0
- package/es/core/contributions/env/base-contribution.js +6 -0
- package/es/core/contributions/env/base-contribution.js.map +1 -1
- package/es/core/contributions/textMeasure/AtextMeasure.js +0 -10
- package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/es/core/global.d.ts +2 -3
- package/es/core/global.js +7 -8
- package/es/core/global.js.map +1 -1
- package/es/graphic/builtin-symbol/rect.d.ts +2 -1
- package/es/graphic/builtin-symbol/rect.js +28 -0
- package/es/graphic/builtin-symbol/rect.js.map +1 -1
- package/es/graphic/builtin-symbol/utils.d.ts +2 -1
- package/es/graphic/builtin-symbol/utils.js +5 -0
- package/es/graphic/builtin-symbol/utils.js.map +1 -1
- package/es/graphic/config.js +20 -5
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/graphic.d.ts +1 -1
- package/es/graphic/graphic.js +20 -6
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/group.js +1 -1
- package/es/graphic/group.js.map +1 -1
- package/es/graphic/line.js +2 -2
- package/es/graphic/line.js.map +1 -1
- package/es/graphic/richtext/line.js +13 -1
- package/es/graphic/richtext/line.js.map +1 -1
- package/es/graphic/richtext/paragraph.d.ts +9 -1
- package/es/graphic/richtext/paragraph.js +49 -5
- package/es/graphic/richtext/paragraph.js.map +1 -1
- package/es/graphic/richtext/utils.d.ts +4 -0
- package/es/graphic/richtext/utils.js +19 -6
- package/es/graphic/richtext/utils.js.map +1 -1
- package/es/graphic/richtext/wrapper.d.ts +1 -0
- package/es/graphic/richtext/wrapper.js +1 -1
- package/es/graphic/richtext/wrapper.js.map +1 -1
- package/es/graphic/richtext.d.ts +8 -2
- package/es/graphic/richtext.js +43 -5
- package/es/graphic/richtext.js.map +1 -1
- package/es/index.d.ts +2 -0
- package/es/index.js +4 -0
- package/es/index.js.map +1 -1
- package/es/interface/animate.d.ts +5 -39
- package/es/interface/animate.js.map +1 -1
- package/es/interface/color.js.map +1 -1
- package/es/interface/context.d.ts +1 -0
- package/es/interface/context.js.map +1 -1
- package/es/interface/global.d.ts +4 -1
- package/es/interface/global.js.map +1 -1
- package/es/interface/graphic/group.d.ts +1 -0
- package/es/interface/graphic/group.js.map +1 -1
- package/es/interface/graphic/image.d.ts +1 -0
- package/es/interface/graphic/image.js.map +1 -1
- package/es/interface/graphic/path.d.ts +1 -0
- package/es/interface/graphic/path.js.map +1 -1
- package/es/interface/graphic/rect.d.ts +1 -0
- package/es/interface/graphic/rect.js.map +1 -1
- package/es/interface/graphic/richText.d.ts +13 -0
- package/es/interface/graphic/richText.js.map +1 -1
- package/es/interface/graphic/symbol.d.ts +2 -0
- package/es/interface/graphic/symbol.js.map +1 -1
- package/es/interface/graphic.d.ts +12 -3
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/path.d.ts +5 -0
- package/es/interface/path.js.map +1 -1
- package/es/interface/picker.d.ts +13 -0
- package/es/interface/picker.js.map +1 -1
- package/es/picker/constants.d.ts +2 -0
- package/es/picker/constants.js +4 -0
- package/es/picker/constants.js.map +1 -1
- package/es/picker/pick-interceptor.d.ts +7 -2
- package/es/picker/pick-interceptor.js +19 -1
- package/es/picker/pick-interceptor.js.map +1 -1
- package/es/picker/pick-modules.js +5 -3
- package/es/picker/pick-modules.js.map +1 -1
- package/es/picker/picker-service.d.ts +4 -2
- package/es/picker/picker-service.js +13 -13
- package/es/picker/picker-service.js.map +1 -1
- package/es/plugins/builtin-plugin/edit-module.d.ts +17 -6
- package/es/plugins/builtin-plugin/edit-module.js +123 -40
- package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +1 -0
- package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js +3 -0
- package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +1 -0
- package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +91 -32
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js +516 -189
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/es/render/contributions/render/arc3d-render.js.map +1 -1
- package/es/render/contributions/render/area-render.d.ts +1 -1
- package/es/render/contributions/render/area-render.js +36 -16
- package/es/render/contributions/render/area-render.js.map +1 -1
- package/es/render/contributions/render/base-render.d.ts +1 -0
- package/es/render/contributions/render/base-render.js +21 -2
- package/es/render/contributions/render/base-render.js.map +1 -1
- package/es/render/contributions/render/contributions/base-contribution-render.d.ts +7 -1
- package/es/render/contributions/render/contributions/base-contribution-render.js +16 -8
- package/es/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/base-texture-contribution-render.js +29 -2
- package/es/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/group-contribution-render.js +8 -3
- package/es/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/image-contribution-render.d.ts +1 -1
- package/es/render/contributions/render/contributions/image-contribution-render.js +2 -2
- package/es/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/rect-contribution-render.js +4 -4
- package/es/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/symbol-contribution-render.d.ts +8 -1
- package/es/render/contributions/render/contributions/symbol-contribution-render.js +26 -0
- package/es/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/text-contribution-render.js +5 -3
- package/es/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
- package/es/render/contributions/render/draw-contribution.js +4 -5
- package/es/render/contributions/render/draw-contribution.js.map +1 -1
- package/es/render/contributions/render/group-render.js +2 -2
- package/es/render/contributions/render/group-render.js.map +1 -1
- package/es/render/contributions/render/image-render.js +3 -2
- package/es/render/contributions/render/image-render.js.map +1 -1
- package/es/render/contributions/render/line-render.js +31 -9
- package/es/render/contributions/render/line-render.js.map +1 -1
- package/es/render/contributions/render/path-render.js.map +1 -1
- package/es/render/contributions/render/polygon-render.js.map +1 -1
- package/es/render/contributions/render/rect-render.js +2 -2
- package/es/render/contributions/render/rect-render.js.map +1 -1
- package/es/render/contributions/render/richtext-render.js +1 -1
- package/es/render/contributions/render/richtext-render.js.map +1 -1
- package/es/render/contributions/render/symbol-render.js +16 -14
- package/es/render/contributions/render/symbol-render.js.map +1 -1
- package/es/render/contributions/render/utils.d.ts +1 -2
- package/es/render/contributions/render/utils.js +0 -18
- package/es/render/contributions/render/utils.js.map +1 -1
- package/es/resource-loader/loader.js +1 -1
- package/es/resource-loader/loader.js.map +1 -1
- package/package.json +2 -2
- package/cjs/common/inversify/annotation/optional.d.ts +0 -2
- package/cjs/common/inversify/annotation/optional.js +0 -14
- package/cjs/common/inversify/annotation/optional.js.map +0 -1
- package/es/common/inversify/annotation/optional.d.ts +0 -2
- package/es/common/inversify/annotation/optional.js +0 -12
- package/es/common/inversify/annotation/optional.js.map +0 -1
|
@@ -1,81 +1,135 @@
|
|
|
1
|
-
import { isObject,
|
|
1
|
+
import { isObject, merge } from "@visactor/vutils";
|
|
2
2
|
|
|
3
3
|
import { Generator } from "../../common/generator";
|
|
4
4
|
|
|
5
|
-
import { createGroup, createLine, createRect } from "../../graphic";
|
|
5
|
+
import { createGroup, createLine, createRect, createRichText, getRichTextBounds, RichText } from "../../graphic";
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { DefaultTicker, DefaultTimeline } from "../../animate";
|
|
8
|
+
|
|
9
|
+
import { EditModule, findConfigIndexByCursorIdx, getDefaultCharacterConfig } from "./edit-module";
|
|
10
|
+
|
|
11
|
+
import { application } from "../../application";
|
|
12
|
+
|
|
13
|
+
import { getWordStartEndIdx } from "../../graphic/richtext/utils";
|
|
8
14
|
|
|
9
15
|
class Selection {
|
|
10
|
-
constructor(
|
|
16
|
+
constructor(selectionStartCursorIdx, curCursorIdx, rt) {
|
|
11
17
|
this.curCursorIdx = curCursorIdx, this.selectionStartCursorIdx = selectionStartCursorIdx,
|
|
12
|
-
this.cacheCurCursorIdx = cacheCurCursorIdx, this.cacheSelectionStartCursorIdx = cacheSelectionStartCursorIdx,
|
|
13
18
|
this.rt = rt;
|
|
14
19
|
}
|
|
20
|
+
isEmpty() {
|
|
21
|
+
return this.selectionStartCursorIdx === this.curCursorIdx;
|
|
22
|
+
}
|
|
23
|
+
getSelectionPureText() {
|
|
24
|
+
const minCursorIdx = Math.min(this.selectionStartCursorIdx, this.curCursorIdx), maxCursorIdx = Math.max(this.selectionStartCursorIdx, this.curCursorIdx);
|
|
25
|
+
if (minCursorIdx === maxCursorIdx) return "";
|
|
26
|
+
const config = this.rt.attribute.textConfig, startIdx = findConfigIndexByCursorIdx(config, Math.ceil(minCursorIdx)), endIdx = findConfigIndexByCursorIdx(config, Math.floor(maxCursorIdx));
|
|
27
|
+
let str = "";
|
|
28
|
+
for (let i = startIdx; i <= endIdx; i++) str += config[i].text;
|
|
29
|
+
return str;
|
|
30
|
+
}
|
|
15
31
|
hasFormat(key) {
|
|
16
32
|
return null != this.getFormat(key);
|
|
17
33
|
}
|
|
18
|
-
|
|
34
|
+
_getFormat(key, cursorIdx) {
|
|
35
|
+
var _a;
|
|
19
36
|
if (!this.rt) return null;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
37
|
+
let idx = Math.round(cursorIdx);
|
|
38
|
+
const config = this.rt.attribute.textConfig;
|
|
39
|
+
if (!config.length) return null;
|
|
40
|
+
for (let i = 0; i < config.length; i++) if ("\n" !== config[i].text && (idx--, idx < 0)) return config[i][key];
|
|
41
|
+
return null !== (_a = config[Math.min(idx, config.length - 1)][key]) && void 0 !== _a ? _a : this.rt.attribute[key];
|
|
42
|
+
}
|
|
43
|
+
getFormat(key) {
|
|
44
|
+
return this.getAllFormat(key)[0];
|
|
26
45
|
}
|
|
27
46
|
getAllFormat(key) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
set.add(item[key]);
|
|
47
|
+
const valSet = new Set, minCursorIdx = Math.min(this.selectionStartCursorIdx, this.curCursorIdx), maxCursorIdx = Math.max(this.selectionStartCursorIdx, this.curCursorIdx);
|
|
48
|
+
if (minCursorIdx === maxCursorIdx) return [ this._getFormat(key, minCursorIdx) ];
|
|
49
|
+
for (let i = Math.ceil(minCursorIdx); i <= Math.floor(maxCursorIdx); i++) {
|
|
50
|
+
const val = this._getFormat(key, i);
|
|
51
|
+
val && valSet.add(val);
|
|
34
52
|
}
|
|
35
|
-
return Array.from(
|
|
53
|
+
return Array.from(valSet.values());
|
|
36
54
|
}
|
|
37
55
|
}
|
|
38
56
|
|
|
39
57
|
export const FORMAT_TEXT_COMMAND = "FORMAT_TEXT_COMMAND";
|
|
40
58
|
|
|
59
|
+
export const FORMAT_ALL_TEXT_COMMAND = "FORMAT_ALL_TEXT_COMMAND";
|
|
60
|
+
|
|
41
61
|
export const FORMAT_ELEMENT_COMMAND = "FORMAT_ELEMENT_COMMAND";
|
|
42
62
|
|
|
43
63
|
export class RichTextEditPlugin {
|
|
64
|
+
static tryUpdateRichtext(richtext) {
|
|
65
|
+
const cache = richtext.getFrameCache();
|
|
66
|
+
if (!RichText.AllSingleCharacter(cache)) {
|
|
67
|
+
const tc = RichText.TransformTextConfig2SingleCharacter(richtext.attribute.textConfig);
|
|
68
|
+
richtext.setAttributes({
|
|
69
|
+
textConfig: tc
|
|
70
|
+
}), richtext.doUpdateFrameCache(tc);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
static CreateSelection(rt) {
|
|
74
|
+
if (!rt) return null;
|
|
75
|
+
const {textConfig: textConfig = []} = rt.attribute;
|
|
76
|
+
return new Selection(0, textConfig.length - 1, rt);
|
|
77
|
+
}
|
|
44
78
|
constructor() {
|
|
45
79
|
this.name = "RichTextEditPlugin", this.activeEvent = "onRegister", this._uid = Generator.GenAutoIncrementId(),
|
|
46
|
-
this.key = this.name + this._uid, this.editing = !1, this.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
80
|
+
this.key = this.name + this._uid, this.editing = !1, this.focusing = !1, this.pointerDown = !1,
|
|
81
|
+
this.formatTextCommandCb = (payload, p) => {
|
|
82
|
+
const rt = p.currRt;
|
|
83
|
+
if (!rt) return;
|
|
84
|
+
const selectionData = p.getSelection();
|
|
85
|
+
if (!selectionData) return;
|
|
86
|
+
const {selectionStartCursorIdx: selectionStartCursorIdx, curCursorIdx: curCursorIdx} = selectionData, minCursorIdx = Math.min(selectionStartCursorIdx, curCursorIdx), maxCursorIdx = Math.max(selectionStartCursorIdx, curCursorIdx), minConfigIdx = findConfigIndexByCursorIdx(rt.attribute.textConfig, minCursorIdx), maxConfigIdx = findConfigIndexByCursorIdx(rt.attribute.textConfig, maxCursorIdx), config = rt.attribute.textConfig.slice(minConfigIdx, maxConfigIdx);
|
|
87
|
+
this._formatTextCommand(payload, config, rt);
|
|
88
|
+
}, this.formatAllTextCommandCb = (payload, p) => {
|
|
89
|
+
const rt = p.currRt;
|
|
90
|
+
if (!rt) return;
|
|
91
|
+
const config = rt.attribute.textConfig;
|
|
92
|
+
this._formatTextCommand(payload, config, rt);
|
|
93
|
+
}, this.handleKeyDown = e => {
|
|
94
|
+
this.currRt && this.editing && (this.copyToClipboard(e) || this.fullSelection(e) || this.directKey(e));
|
|
95
|
+
}, this.handleInput = (text, isComposing, cursorIdx, rt) => {
|
|
96
|
+
this.currRt && (this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.hideSelection(),
|
|
97
|
+
this.updateCbs.forEach((cb => cb("input", this))));
|
|
98
|
+
}, this.handleChange = (text, isComposing, cursorIdx, rt) => {
|
|
99
|
+
if (!this.currRt) return;
|
|
100
|
+
this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.curCursorIdx = cursorIdx,
|
|
101
|
+
this.selectionStartCursorIdx = cursorIdx;
|
|
102
|
+
const p = this.computedCursorPosByCursorIdx(cursorIdx, rt);
|
|
103
|
+
this.setCursorAndTextArea(p.x, p.y1, p.y2, rt), this.hideSelection(), this.updateCbs.forEach((cb => cb("change", this)));
|
|
104
|
+
}, this.handleFocusIn = () => {
|
|
105
|
+
throw new Error("不会走到这里 handleFocusIn");
|
|
106
|
+
}, this.handleFocusOut = () => {
|
|
107
|
+
throw new Error("不会走到这里 handleFocusOut");
|
|
53
108
|
}, this.handleMove = e => {
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
109
|
+
this.currRt && !this.currRt.attribute.editable && this.deFocus(!0), this.isEditableRichtext(e) ? (this.handleEnter(),
|
|
110
|
+
e.target.once("pointerleave", this.handleLeave), this.tryShowSelection(e, !1)) : this.handleLeave();
|
|
111
|
+
}, this.handleEnter = () => {
|
|
112
|
+
this.editing = !0, this.pluginService.stage.setCursor("text");
|
|
113
|
+
}, this.handleLeave = () => {
|
|
114
|
+
this.editing = !1, this.pluginService.stage.setCursor("default");
|
|
56
115
|
}, this.handlePointerDown = e => {
|
|
57
|
-
this.editing
|
|
58
|
-
this.updateCbs.forEach((cb => cb(this.editing ? "onfocus" : "defocus", this)));
|
|
116
|
+
this.editing && this.isEditableRichtext(e) ? this.onFocus(e) : this.deFocus(!0),
|
|
117
|
+
this.triggerRender(), this.pointerDown = !0, this.updateCbs.forEach((cb => cb(this.editing ? "onfocus" : "defocus", this)));
|
|
59
118
|
}, this.handlePointerUp = e => {
|
|
60
119
|
this.pointerDown = !1;
|
|
61
|
-
}, this.
|
|
62
|
-
this.editing
|
|
63
|
-
}, this.handleLeave = e => {
|
|
64
|
-
this.editing = !1, this.pluginService.stage.setCursor("default");
|
|
120
|
+
}, this.handleDBLClick = e => {
|
|
121
|
+
this.editing && this.tryShowSelection(e, !0);
|
|
65
122
|
}, this.commandCbs = new Map, this.commandCbs.set(FORMAT_TEXT_COMMAND, [ this.formatTextCommandCb ]),
|
|
66
|
-
this.updateCbs = []
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return this.selectionStartCursorIdx && this.curCursorIdx && this.selectionStartCursorIdx !== this.curCursorIdx && this.currRt ? new Selection(this.selectionStartCursorIdx, this.curCursorIdx, findCursorIndexIgnoreLinebreak(this.currRt.attribute.textConfig, this.selectionStartCursorIdx), findCursorIndexIgnoreLinebreak(this.currRt.attribute.textConfig, this.curCursorIdx), this.currRt) : null;
|
|
123
|
+
this.commandCbs.set(FORMAT_ALL_TEXT_COMMAND, [ this.formatAllTextCommandCb ]), this.updateCbs = [],
|
|
124
|
+
this.timeline = new DefaultTimeline, this.ticker = new DefaultTicker([ this.timeline ]),
|
|
125
|
+
this.deltaX = 0, this.deltaY = 0;
|
|
70
126
|
}
|
|
71
|
-
|
|
72
|
-
const rt = p.currRt;
|
|
73
|
-
if (!rt) return;
|
|
74
|
-
const selectionData = p.getSelection();
|
|
75
|
-
if (!selectionData) return;
|
|
76
|
-
const {selectionStartCursorIdx: selectionStartCursorIdx, curCursorIdx: curCursorIdx} = selectionData, config = rt.attribute.textConfig.slice(selectionStartCursorIdx + 1, curCursorIdx + 1);
|
|
127
|
+
_formatTextCommand(payload, config, rt) {
|
|
77
128
|
"bold" === payload ? config.forEach((item => item.fontWeight = "bold")) : "italic" === payload ? config.forEach((item => item.fontStyle = "italic")) : "underline" === payload ? config.forEach((item => item.underline = !0)) : "lineThrough" === payload ? config.forEach((item => item.lineThrough = !0)) : isObject(payload) && config.forEach((item => merge(item, payload))),
|
|
78
129
|
rt.setAttributes(rt.attribute);
|
|
130
|
+
const cache = rt.getFrameCache();
|
|
131
|
+
cache && (this.selectionRangeByCursorIdx(this.selectionStartCursorIdx, this.curCursorIdx, cache),
|
|
132
|
+
this.tryShowInputBounds());
|
|
79
133
|
}
|
|
80
134
|
dispatchCommand(command, payload) {
|
|
81
135
|
const cbs = this.commandCbs.get(command);
|
|
@@ -84,36 +138,295 @@ export class RichTextEditPlugin {
|
|
|
84
138
|
registerCommand(command, cb) {
|
|
85
139
|
(this.commandCbs.get(command) || []).push(cb);
|
|
86
140
|
}
|
|
141
|
+
removeCommand(command, cb) {
|
|
142
|
+
const cbs = this.commandCbs.get(command) || [], idx = cbs.indexOf(cb);
|
|
143
|
+
idx > -1 && cbs.splice(idx, 1);
|
|
144
|
+
}
|
|
87
145
|
registerUpdateListener(cb) {
|
|
88
146
|
(this.updateCbs || []).push(cb);
|
|
89
147
|
}
|
|
148
|
+
removeUpdateListener(cb) {
|
|
149
|
+
const cbs = this.updateCbs || [], idx = cbs.indexOf(cb);
|
|
150
|
+
idx > -1 && cbs.splice(idx, 1);
|
|
151
|
+
}
|
|
90
152
|
activate(context) {
|
|
91
153
|
this.pluginService = context, this.editModule = new EditModule, context.stage.on("pointermove", this.handleMove),
|
|
92
154
|
context.stage.on("pointerdown", this.handlePointerDown), context.stage.on("pointerup", this.handlePointerUp),
|
|
93
|
-
context.stage.on("pointerleave", this.handlePointerUp),
|
|
94
|
-
this.editModule.
|
|
155
|
+
context.stage.on("pointerleave", this.handlePointerUp), context.stage.on("dblclick", this.handleDBLClick),
|
|
156
|
+
application.global.addEventListener("keydown", this.handleKeyDown), this.editModule.onInput(this.handleInput),
|
|
157
|
+
this.editModule.onChange(this.handleChange), this.editModule.onFocusOut(this.handleFocusOut);
|
|
95
158
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
159
|
+
copyToClipboard(e) {
|
|
160
|
+
if (application.global.isMacOS() && e.metaKey && "c" === e.key || !application.global.isMacOS() && e.ctrlKey && "c" === e.key) {
|
|
161
|
+
const text = this.getSelection().getSelectionPureText();
|
|
162
|
+
return application.global.copyToClipBoard(text), e.preventDefault(), !0;
|
|
163
|
+
}
|
|
164
|
+
return !1;
|
|
165
|
+
}
|
|
166
|
+
selectionRange(startIdx, endIdx) {
|
|
167
|
+
const currRt = this.currRt;
|
|
168
|
+
if (!currRt) return;
|
|
169
|
+
const cache = currRt.getFrameCache();
|
|
170
|
+
if (!cache) return;
|
|
171
|
+
const {lines: lines} = cache, totalCursorCount = lines.reduce(((total, line) => total + line.paragraphs.length), 0) - 1;
|
|
172
|
+
startIdx > endIdx && ([startIdx, endIdx] = [ endIdx, startIdx ]), startIdx = Math.min(Math.max(startIdx, -.1), totalCursorCount + .1),
|
|
173
|
+
endIdx = Math.min(Math.max(endIdx, -.1), totalCursorCount + .1), this.selectionRangeByCursorIdx(startIdx, endIdx, cache);
|
|
174
|
+
}
|
|
175
|
+
selectionRangeByCursorIdx(startCursorIdx, endCursorIdx, cache) {
|
|
176
|
+
this.curCursorIdx = endCursorIdx, this.selectionStartCursorIdx = startCursorIdx;
|
|
177
|
+
const {x: x, y1: y1, y2: y2} = this.computedCursorPosByCursorIdx(this.selectionStartCursorIdx, this.currRt);
|
|
178
|
+
this.startCursorPos = {
|
|
179
|
+
x: x,
|
|
180
|
+
y: (y1 + y2) / 2
|
|
181
|
+
};
|
|
182
|
+
const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
|
|
183
|
+
this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt), this._tryShowSelection(pos, cache);
|
|
184
|
+
}
|
|
185
|
+
fullSelection(e) {
|
|
186
|
+
if (application.global.isMacOS() && e.metaKey && "a" === e.key || !application.global.isMacOS() && e.ctrlKey && "a" === e.key) {
|
|
187
|
+
const currRt = this.currRt;
|
|
188
|
+
if (!currRt) return;
|
|
189
|
+
const cache = currRt.getFrameCache();
|
|
190
|
+
if (!cache) return;
|
|
191
|
+
const {lines: lines} = cache;
|
|
192
|
+
if (0 === lines.length) return;
|
|
193
|
+
if (!lines[0].paragraphs || 0 === lines[0].paragraphs.length) return;
|
|
194
|
+
const totalCursorCount = lines.reduce(((total, line) => total + line.paragraphs.length), 0) - 1;
|
|
195
|
+
return this.selectionRange(-.1, totalCursorCount + .1), e.preventDefault(), !0;
|
|
196
|
+
}
|
|
197
|
+
return !1;
|
|
198
|
+
}
|
|
199
|
+
directKey(e) {
|
|
200
|
+
if ("ArrowUp" !== e.key && "ArrowDown" !== e.key && "ArrowLeft" !== e.key && "ArrowRight" !== e.key) return !1;
|
|
201
|
+
const cache = this.currRt.getFrameCache();
|
|
202
|
+
if (!cache) return !1;
|
|
203
|
+
let x = 0, y = 0;
|
|
204
|
+
"ArrowUp" === e.key ? y = -1 : "ArrowDown" === e.key ? y = 1 : "ArrowLeft" === e.key ? x = -1 : "ArrowRight" === e.key && (x = 1);
|
|
205
|
+
const {lineInfo: lineInfo, columnInfo: columnInfo} = this.getColumnByIndex(cache, Math.round(this.curCursorIdx)), {lines: lines} = cache, totalCursorCount = lines.reduce(((total, line) => total + line.paragraphs.length), 0) - 1;
|
|
206
|
+
if (x) {
|
|
207
|
+
x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 2] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + .2 : x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 1] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + 1 - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - 1 + .2 : this.curCursorIdx += x,
|
|
208
|
+
this.curCursorIdx < -.1 ? this.curCursorIdx = -.1 : this.curCursorIdx > totalCursorCount + .1 && (this.curCursorIdx = totalCursorCount + .1);
|
|
209
|
+
const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
|
|
210
|
+
this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt), this.hideSelection();
|
|
211
|
+
}
|
|
212
|
+
if (y) {
|
|
213
|
+
if (y > 0 && lineInfo === cache.lines[cache.lines.length - 1]) return;
|
|
214
|
+
if (y < 0 && lineInfo === cache.lines[0]) return;
|
|
215
|
+
const lineIdx = cache.lines.findIndex((item => item === lineInfo)) + y;
|
|
216
|
+
if (lineIdx < 0 || lineIdx >= cache.lines.length) return;
|
|
217
|
+
const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt), posX = pos.x;
|
|
218
|
+
let posY = (pos.y1 + pos.y2) / 2;
|
|
219
|
+
posY += y * lineInfo.height;
|
|
220
|
+
const nextLineInfo = cache.lines[lineIdx], {columnInfo: columnInfo, delta: delta} = this.getColumnAndIndexByLinePoint(nextLineInfo, {
|
|
221
|
+
x: posX,
|
|
222
|
+
y: posY
|
|
223
|
+
});
|
|
224
|
+
if (!columnInfo) return;
|
|
225
|
+
let cursorIdx = this.getColumnIndex(cache, columnInfo) + delta;
|
|
226
|
+
const data = this.computedCursorPosByCursorIdx(cursorIdx, this.currRt);
|
|
227
|
+
cursorIdx < -.1 ? cursorIdx = -.1 : cursorIdx > totalCursorCount + .1 && (cursorIdx = totalCursorCount + .1),
|
|
228
|
+
this.curCursorIdx = cursorIdx, this.selectionStartCursorIdx = cursorIdx, this.setCursorAndTextArea(data.x, data.y1, data.y2, this.currRt);
|
|
229
|
+
}
|
|
230
|
+
return !0;
|
|
231
|
+
}
|
|
232
|
+
tryShowShadowPlaceholder() {
|
|
233
|
+
if (!this.currRt) return;
|
|
234
|
+
const shadowRoot = this.currRt.shadowRoot;
|
|
235
|
+
if (shadowRoot) {
|
|
236
|
+
const placeholder = shadowRoot.getElementsByType("richtext")[0];
|
|
237
|
+
placeholder && shadowRoot.removeChild(placeholder);
|
|
238
|
+
}
|
|
239
|
+
const {textConfig: textConfig, editOptions: editOptions} = this.currRt.attribute;
|
|
240
|
+
if (textConfig && textConfig.length) return;
|
|
241
|
+
if (!editOptions || !editOptions.placeholder) return;
|
|
242
|
+
const {placeholder: placeholder, placeholderColor: placeholderColor = "rgba(0, 0, 0, 0.6)", placeholderFontFamily: placeholderFontFamily, placeholderFontSize: placeholderFontSize} = editOptions, shadow = this.getShadow(this.currRt), textConfigItem = Object.assign(Object.assign({}, getDefaultCharacterConfig(this.currRt.attribute)), {
|
|
243
|
+
text: placeholder
|
|
244
|
+
});
|
|
245
|
+
placeholderColor && (textConfigItem.fill = placeholderColor), placeholderFontFamily && (textConfigItem.fontFamily = placeholderFontFamily),
|
|
246
|
+
placeholderFontSize && (textConfigItem.fontSize = placeholderFontSize), this.shadowPlaceHolder = createRichText(Object.assign(Object.assign({}, this.currRt.attribute), {
|
|
247
|
+
x: 0,
|
|
248
|
+
y: 0,
|
|
249
|
+
pickable: !1,
|
|
250
|
+
editable: !1,
|
|
251
|
+
editOptions: null,
|
|
252
|
+
angle: 0,
|
|
253
|
+
_debug_bounds: !1,
|
|
254
|
+
textConfig: [ textConfigItem ]
|
|
255
|
+
})), shadow.add(this.shadowPlaceHolder);
|
|
256
|
+
}
|
|
257
|
+
tryShowInputBounds() {
|
|
258
|
+
if (!this.currRt || !this.focusing) return;
|
|
259
|
+
const {editOptions: editOptions = {}} = this.currRt.attribute, {boundsStrokeWhenInput: boundsStrokeWhenInput} = editOptions;
|
|
260
|
+
if (!editOptions || !boundsStrokeWhenInput) return;
|
|
261
|
+
const {attribute: attribute} = this.currRt;
|
|
262
|
+
let b = this.currRt.AABBBounds, h = b.height();
|
|
263
|
+
if (!attribute.textConfig.length && this.editLine) {
|
|
264
|
+
const {points: points} = this.editLine.attribute;
|
|
265
|
+
h = points[1].y - points[0].y, b = getRichTextBounds(Object.assign({}, this.shadowPlaceHolder.attribute));
|
|
266
|
+
}
|
|
267
|
+
this.shadowBounds = this.shadowBounds || createRect({}), this.shadowBounds.setAttributes({
|
|
268
|
+
x: 0,
|
|
269
|
+
y: 0,
|
|
270
|
+
width: b.width(),
|
|
271
|
+
height: h,
|
|
272
|
+
fill: !1,
|
|
273
|
+
stroke: boundsStrokeWhenInput,
|
|
274
|
+
lineWidth: 1,
|
|
275
|
+
zIndex: -1
|
|
276
|
+
});
|
|
277
|
+
this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds();
|
|
278
|
+
}
|
|
279
|
+
trySyncPlaceholderToTextConfig() {
|
|
280
|
+
if (!this.currRt) return;
|
|
281
|
+
const {textConfig: textConfig, editOptions: editOptions} = this.currRt.attribute;
|
|
282
|
+
if (textConfig && textConfig.length) return;
|
|
283
|
+
if (!(editOptions && editOptions.placeholder && editOptions.syncPlaceHolderToTextConfig)) return;
|
|
284
|
+
const {placeholder: placeholder} = editOptions;
|
|
285
|
+
this.currRt.setAttributes({
|
|
286
|
+
textConfig: [ Object.assign({
|
|
287
|
+
text: placeholder
|
|
288
|
+
}, getDefaultCharacterConfig(this.currRt.attribute)) ]
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
deactivate(context) {
|
|
292
|
+
context.stage.off("pointermove", this.handleMove), context.stage.off("pointerdown", this.handlePointerDown),
|
|
293
|
+
context.stage.off("pointerup", this.handlePointerUp), context.stage.off("pointerleave", this.handlePointerUp),
|
|
294
|
+
context.stage.off("dblclick", this.handleDBLClick), application.global.addEventListener("keydown", this.handleKeyDown);
|
|
295
|
+
}
|
|
296
|
+
onFocus(e, data) {
|
|
297
|
+
this.updateCbs && this.updateCbs.forEach((cb => cb("beforeOnfocus", this))), this.deFocus(!1),
|
|
298
|
+
this.focusing = !0;
|
|
299
|
+
const target = e.target;
|
|
300
|
+
if (!target || "richtext" !== target.type) return;
|
|
301
|
+
this.currRt = target, RichTextEditPlugin.tryUpdateRichtext(target);
|
|
302
|
+
const shadowRoot = this.getShadow(target), cache = target.getFrameCache();
|
|
303
|
+
if (cache) {
|
|
304
|
+
if (this.computeGlobalDelta(cache), shadowRoot.setAttributes({
|
|
305
|
+
shadowRootIdx: 1,
|
|
306
|
+
pickable: !1,
|
|
307
|
+
x: this.deltaX,
|
|
308
|
+
y: this.deltaY
|
|
309
|
+
}), !this.editLine) {
|
|
310
|
+
const line = createLine({
|
|
311
|
+
x: 0,
|
|
312
|
+
y: 0,
|
|
313
|
+
lineWidth: 1,
|
|
314
|
+
stroke: "black"
|
|
115
315
|
});
|
|
316
|
+
this.addAnimateToLine(line), this.editLine = line, this.ticker.start(!0);
|
|
317
|
+
const g = createGroup({
|
|
318
|
+
x: 0,
|
|
319
|
+
y: 0,
|
|
320
|
+
width: 0,
|
|
321
|
+
height: 0
|
|
322
|
+
});
|
|
323
|
+
this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
|
|
324
|
+
}
|
|
325
|
+
if (data = data || this.computedCursorPosByEvent(e, cache)) {
|
|
326
|
+
const {x: x, y1: y1, y2: y2, cursorIndex: cursorIndex} = data;
|
|
327
|
+
this.startCursorPos = {
|
|
328
|
+
x: x,
|
|
329
|
+
y: (y1 + y2) / 2
|
|
330
|
+
}, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex,
|
|
331
|
+
this.setCursorAndTextArea(x, y1, y2, target);
|
|
116
332
|
} else {
|
|
333
|
+
const x = 0, y1 = 0, y2 = getRichTextBounds(Object.assign(Object.assign({}, target.attribute), {
|
|
334
|
+
textConfig: [ {
|
|
335
|
+
text: "a"
|
|
336
|
+
} ]
|
|
337
|
+
})).height();
|
|
338
|
+
this.startCursorPos = {
|
|
339
|
+
x: x,
|
|
340
|
+
y: (y1 + y2) / 2
|
|
341
|
+
}, this.curCursorIdx = -.1, this.selectionStartCursorIdx = -.1, this.setCursorAndTextArea(x, y1, y2, target);
|
|
342
|
+
}
|
|
343
|
+
this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.currRt.addUpdateBoundTag();
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
offsetLineBgAndShadowBounds() {
|
|
347
|
+
const rt = this.currRt, {textBaseline: textBaseline} = rt.attribute;
|
|
348
|
+
let b, dy = 0, attr = rt.attribute;
|
|
349
|
+
"middle" !== textBaseline && "bottom" !== textBaseline || (attr.textConfig.length || (attr = Object.assign(Object.assign({}, attr), {
|
|
350
|
+
textConfig: [ {
|
|
351
|
+
text: "a"
|
|
352
|
+
} ]
|
|
353
|
+
})), b = getRichTextBounds(attr)), "middle" === textBaseline ? dy = -b.height() / 2 : "bottom" === textBaseline && (dy = -b.height()),
|
|
354
|
+
this.editLine && this.editLine.setAttributes({
|
|
355
|
+
dy: dy
|
|
356
|
+
}), this.editBg && this.editBg.setAttributes({
|
|
357
|
+
dy: dy
|
|
358
|
+
}), this.shadowBounds && this.shadowBounds.setAttributes({
|
|
359
|
+
dy: dy
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
deFocus(trulyDeFocus = !1) {
|
|
363
|
+
const currRt = this.currRt;
|
|
364
|
+
if (!currRt) return;
|
|
365
|
+
this.updateCbs && this.updateCbs.forEach((cb => cb("beforeDefocus", this, {
|
|
366
|
+
trulyDeFocus: trulyDeFocus
|
|
367
|
+
}))), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), currRt.detachShadow()),
|
|
368
|
+
this.currRt = null, this.editLine && (this.editLine.parent && this.editLine.parent.removeChild(this.editLine),
|
|
369
|
+
this.editLine.release(), this.editLine = null, this.editBg.parent && this.editBg.parent.removeChild(this.editBg),
|
|
370
|
+
this.editBg.release(), this.editBg = null), trulyDeFocus && (this.shadowBounds && (this.shadowBounds.parent && this.shadowBounds.parent.removeChild(this.shadowBounds),
|
|
371
|
+
this.shadowBounds.release(), this.shadowBounds = null), this.shadowPlaceHolder && (this.shadowPlaceHolder.parent && this.shadowPlaceHolder.parent.removeChild(this.shadowPlaceHolder),
|
|
372
|
+
this.shadowPlaceHolder.release(), this.shadowPlaceHolder = null)), this.focusing = !1;
|
|
373
|
+
const textConfig = currRt.attribute.textConfig;
|
|
374
|
+
let lastConfig = textConfig[textConfig.length - 1], cleared = !1;
|
|
375
|
+
for (;lastConfig && "\n" === lastConfig.text; ) textConfig.pop(), lastConfig = textConfig[textConfig.length - 1],
|
|
376
|
+
cleared = !0;
|
|
377
|
+
cleared && currRt.setAttributes({
|
|
378
|
+
textConfig: textConfig
|
|
379
|
+
}), currRt.removeEventListener("pointerleave", this.handleLeave);
|
|
380
|
+
}
|
|
381
|
+
addAnimateToLine(line) {
|
|
382
|
+
line.animates && line.animates.forEach((animate => {
|
|
383
|
+
animate.stop(), animate.release();
|
|
384
|
+
}));
|
|
385
|
+
line.animate({
|
|
386
|
+
timeline: this.timeline
|
|
387
|
+
}).to({
|
|
388
|
+
opacity: 1
|
|
389
|
+
}, 10, "linear").wait(700).to({
|
|
390
|
+
opacity: 0
|
|
391
|
+
}, 10, "linear").wait(700).loop(1 / 0);
|
|
392
|
+
}
|
|
393
|
+
tryShowSelection(e, dblclick) {
|
|
394
|
+
const cache = e.target.getFrameCache();
|
|
395
|
+
if (cache && this.editBg && this.startCursorPos) if (dblclick) {
|
|
396
|
+
const currCursorData = this.computedCursorPosByEvent(e, cache);
|
|
397
|
+
if (!currCursorData) return;
|
|
398
|
+
const lineInfo = currCursorData.lineInfo, columnIndex = lineInfo.paragraphs.findIndex((item => item === currCursorData.columnInfo));
|
|
399
|
+
if (columnIndex < 0) return;
|
|
400
|
+
const str = lineInfo.paragraphs.reduce(((str, item) => str + item.text), "");
|
|
401
|
+
let idx = 0;
|
|
402
|
+
for (let i = 0; i < cache.lines.length; i++) {
|
|
403
|
+
const line = cache.lines[i];
|
|
404
|
+
if (line === lineInfo) break;
|
|
405
|
+
idx += line.paragraphs.length;
|
|
406
|
+
}
|
|
407
|
+
const {startIdx: startIdx, endIdx: endIdx} = getWordStartEndIdx(str, columnIndex);
|
|
408
|
+
this.selectionRange(idx + startIdx - .1, idx + endIdx - .1);
|
|
409
|
+
} else if (this.pointerDown) {
|
|
410
|
+
const currCursorData = this.computedCursorPosByEvent(e, cache);
|
|
411
|
+
if (!currCursorData) return;
|
|
412
|
+
this.curCursorIdx = currCursorData.cursorIndex, this._tryShowSelection(currCursorData, cache);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
_tryShowSelection(currCursorData, cache) {
|
|
416
|
+
let startCursorPos = this.startCursorPos, endCursorPos = {
|
|
417
|
+
x: currCursorData.x,
|
|
418
|
+
y: (currCursorData.y1 + currCursorData.y2) / 2
|
|
419
|
+
}, line0Info = this.getLineByPoint(cache, startCursorPos), line1Info = this.getLineByPoint(cache, endCursorPos);
|
|
420
|
+
if (line0Info && line1Info) {
|
|
421
|
+
if ((startCursorPos.y > endCursorPos.y || startCursorPos.y === endCursorPos.y && startCursorPos.x > endCursorPos.x) && ([startCursorPos, endCursorPos] = [ endCursorPos, startCursorPos ],
|
|
422
|
+
[line1Info, line0Info] = [ line0Info, line1Info ]), this.hideSelection(), line0Info === line1Info) this.editBg.setAttributes({
|
|
423
|
+
x: startCursorPos.x,
|
|
424
|
+
y: line0Info.top,
|
|
425
|
+
width: endCursorPos.x - startCursorPos.x,
|
|
426
|
+
height: line0Info.height,
|
|
427
|
+
fill: "#336df4",
|
|
428
|
+
fillOpacity: .2
|
|
429
|
+
}); else {
|
|
117
430
|
this.editBg.setAttributes({
|
|
118
431
|
x: 0,
|
|
119
432
|
y: line0Info.top,
|
|
@@ -127,9 +440,9 @@ export class RichTextEditPlugin {
|
|
|
127
440
|
if (i === startIdx) {
|
|
128
441
|
const p = line.paragraphs[line.paragraphs.length - 1];
|
|
129
442
|
this.editBg.add(createRect({
|
|
130
|
-
x:
|
|
443
|
+
x: startCursorPos.x,
|
|
131
444
|
y: y,
|
|
132
|
-
width: p.left + p.width -
|
|
445
|
+
width: p.left + p.width - startCursorPos.x,
|
|
133
446
|
height: line.height,
|
|
134
447
|
fill: "#336df4",
|
|
135
448
|
fillOpacity: .2
|
|
@@ -139,7 +452,7 @@ export class RichTextEditPlugin {
|
|
|
139
452
|
this.editBg.add(createRect({
|
|
140
453
|
x: p.left,
|
|
141
454
|
y: y,
|
|
142
|
-
width:
|
|
455
|
+
width: endCursorPos.x - p.left,
|
|
143
456
|
height: line.height,
|
|
144
457
|
fill: "#336df4",
|
|
145
458
|
fillOpacity: .2
|
|
@@ -158,8 +471,8 @@ export class RichTextEditPlugin {
|
|
|
158
471
|
y += line.height;
|
|
159
472
|
}
|
|
160
473
|
}
|
|
161
|
-
this.
|
|
162
|
-
this.
|
|
474
|
+
this.setCursorAndTextArea(currCursorData.x, currCursorData.y1, currCursorData.y2, this.currRt),
|
|
475
|
+
this.triggerRender(), this.updateCbs.forEach((cb => cb("selection", this)));
|
|
163
476
|
}
|
|
164
477
|
}
|
|
165
478
|
hideSelection() {
|
|
@@ -167,78 +480,32 @@ export class RichTextEditPlugin {
|
|
|
167
480
|
fill: "transparent"
|
|
168
481
|
}));
|
|
169
482
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
x: 0,
|
|
176
|
-
y: 0
|
|
177
|
-
};
|
|
178
|
-
return e.target.globalTransMatrix.transformPoint(p, p1), p1;
|
|
483
|
+
getShadow(rt) {
|
|
484
|
+
const sr = rt.shadowRoot || rt.attachShadow();
|
|
485
|
+
return sr.setAttributes({
|
|
486
|
+
boundsMode: "empty"
|
|
487
|
+
}), sr;
|
|
179
488
|
}
|
|
180
489
|
getLineByPoint(cache, p1) {
|
|
181
490
|
let lineInfo = cache.lines[0];
|
|
182
491
|
for (let i = 0; i < cache.lines.length && !(lineInfo.top <= p1.y && lineInfo.top + lineInfo.height >= p1.y); i++) lineInfo = cache.lines[i + 1];
|
|
183
492
|
return lineInfo;
|
|
184
493
|
}
|
|
185
|
-
|
|
186
|
-
let columnInfo = lineInfo.paragraphs[0];
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
this.deFocus(e);
|
|
192
|
-
const target = e.target;
|
|
193
|
-
this.tryUpdateRichtext(target);
|
|
194
|
-
const shadowRoot = target.attachShadow();
|
|
195
|
-
shadowRoot.setAttributes({
|
|
196
|
-
shadowRootIdx: -1
|
|
197
|
-
});
|
|
198
|
-
const cache = target.getFrameCache();
|
|
199
|
-
if (!cache) return;
|
|
200
|
-
if (!this.editLine) {
|
|
201
|
-
const line = createLine({
|
|
202
|
-
x: 0,
|
|
203
|
-
y: 0,
|
|
204
|
-
lineWidth: 1,
|
|
205
|
-
stroke: "black"
|
|
206
|
-
});
|
|
207
|
-
line.animate().to({
|
|
208
|
-
opacity: 1
|
|
209
|
-
}, 10, "linear").wait(700).to({
|
|
210
|
-
opacity: 0
|
|
211
|
-
}, 10, "linear").wait(700).loop(1 / 0), this.editLine = line;
|
|
212
|
-
const g = createGroup({
|
|
213
|
-
x: 0,
|
|
214
|
-
y: 0,
|
|
215
|
-
width: 0,
|
|
216
|
-
height: 0
|
|
217
|
-
});
|
|
218
|
-
this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
|
|
494
|
+
getColumnAndIndexByLinePoint(lineInfo, p1) {
|
|
495
|
+
let columnInfo = lineInfo.paragraphs[0], delta = 0;
|
|
496
|
+
if (lineInfo.paragraphs.length) {
|
|
497
|
+
const start = lineInfo.paragraphs[0], end = lineInfo.paragraphs[lineInfo.paragraphs.length - 1];
|
|
498
|
+
p1.x <= start.left ? (delta = -.1, columnInfo = start) : p1.x >= end.left + end.width && (delta = .1,
|
|
499
|
+
columnInfo = end);
|
|
219
500
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
let y1 = lineInfo.top, y2 = lineInfo.top + lineInfo.height, x = columnInfo.left + columnInfo.width;
|
|
225
|
-
y1 += 2, y2 -= 2;
|
|
226
|
-
let cursorIndex = this.getColumnIndex(cache, columnInfo);
|
|
227
|
-
p1.x < columnInfo.left + columnInfo.width / 2 && (x = columnInfo.left, cursorIndex -= 1),
|
|
228
|
-
this.lastPoint = {
|
|
229
|
-
x: x,
|
|
230
|
-
y: (y1 + y2) / 2
|
|
231
|
-
}, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex,
|
|
232
|
-
this.setCursorAndTextArea(x, y1, y2, target);
|
|
501
|
+
if (!delta) for (let i = 0; i < lineInfo.paragraphs.length; i++) if (columnInfo = lineInfo.paragraphs[i],
|
|
502
|
+
columnInfo.left <= p1.x && columnInfo.left + columnInfo.width >= p1.x) {
|
|
503
|
+
delta = p1.x > columnInfo.left + columnInfo.width / 2 ? .1 : -.1;
|
|
504
|
+
break;
|
|
233
505
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
let y1 = lineInfo.top, y2 = lineInfo.top + lineInfo.height;
|
|
238
|
-
return y1 += 2, y2 -= 2, {
|
|
239
|
-
x: columnInfo.left + ("left" === orient ? 0 : columnInfo.width),
|
|
240
|
-
y1: y1,
|
|
241
|
-
y2: y2
|
|
506
|
+
return {
|
|
507
|
+
columnInfo: columnInfo,
|
|
508
|
+
delta: delta
|
|
242
509
|
};
|
|
243
510
|
}
|
|
244
511
|
getColumnIndex(cache, cInfo) {
|
|
@@ -249,19 +516,35 @@ export class RichTextEditPlugin {
|
|
|
249
516
|
}
|
|
250
517
|
return -1;
|
|
251
518
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
519
|
+
isRichtext(e) {
|
|
520
|
+
return !(!e.target || "richtext" !== e.target.type);
|
|
521
|
+
}
|
|
522
|
+
isEditableRichtext(e) {
|
|
523
|
+
return this.isRichtext(e) && !!e.target.attribute.editable;
|
|
524
|
+
}
|
|
525
|
+
triggerRender() {
|
|
526
|
+
this.pluginService.stage.renderNextFrame();
|
|
527
|
+
}
|
|
528
|
+
computeGlobalDelta(cache) {
|
|
529
|
+
this.deltaX = 0, this.deltaY = 0;
|
|
530
|
+
const height = cache.height, actualHeight = cache.actualHeight, width = cache.lines.reduce(((w, item) => Math.max(w, item.actualWidth)), 0);
|
|
531
|
+
"center" === cache.globalAlign ? this.deltaX = -width / 2 : "right" === cache.globalAlign && (this.deltaX = -width),
|
|
532
|
+
"middle" === cache.verticalDirection ? this.deltaY = height / 2 - actualHeight / 2 : "bottom" === cache.verticalDirection && (this.deltaY = height - actualHeight);
|
|
533
|
+
}
|
|
534
|
+
getEventPosition(e) {
|
|
535
|
+
const p = this.pluginService.stage.eventPointTransform(e), p1 = {
|
|
536
|
+
x: 0,
|
|
537
|
+
y: 0
|
|
538
|
+
};
|
|
539
|
+
e.target.globalTransMatrix.transformPoint(p, p1), p1.x -= this.deltaX, p1.y -= this.deltaY;
|
|
540
|
+
const rt = this.currRt, {textBaseline: textBaseline} = rt.attribute;
|
|
541
|
+
let dy = 0;
|
|
542
|
+
if ("middle" === textBaseline) {
|
|
543
|
+
dy = getRichTextBounds(rt.attribute).height() / 2;
|
|
544
|
+
} else if ("bottom" === textBaseline) {
|
|
545
|
+
dy = getRichTextBounds(rt.attribute).height();
|
|
263
546
|
}
|
|
264
|
-
return
|
|
547
|
+
return p1.y += dy, p1;
|
|
265
548
|
}
|
|
266
549
|
setCursorAndTextArea(x, y1, y2, rt) {
|
|
267
550
|
this.editLine.setAttributes({
|
|
@@ -272,7 +555,7 @@ export class RichTextEditPlugin {
|
|
|
272
555
|
x: x,
|
|
273
556
|
y: y2
|
|
274
557
|
} ]
|
|
275
|
-
});
|
|
558
|
+
}), this.addAnimateToLine(this.editLine);
|
|
276
559
|
const out = {
|
|
277
560
|
x: 0,
|
|
278
561
|
y: 0
|
|
@@ -282,54 +565,98 @@ export class RichTextEditPlugin {
|
|
|
282
565
|
y: y1
|
|
283
566
|
}, out);
|
|
284
567
|
const {left: left, top: top} = this.pluginService.stage.window.getBoundingClientRect();
|
|
285
|
-
out.x += left, out.y += top, this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
|
|
286
|
-
}
|
|
287
|
-
setCursor(x, y1, y2) {
|
|
288
|
-
this.editLine.setAttributes({
|
|
289
|
-
points: [ {
|
|
290
|
-
x: x,
|
|
291
|
-
y: y1
|
|
292
|
-
}, {
|
|
293
|
-
x: x,
|
|
294
|
-
y: y2
|
|
295
|
-
} ]
|
|
296
|
-
});
|
|
568
|
+
out.x += left, out.y += top, this.offsetLineBgAndShadowBounds(), this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
|
|
297
569
|
}
|
|
298
|
-
|
|
299
|
-
this.
|
|
570
|
+
computedCursorPosByEvent(e, cache) {
|
|
571
|
+
const p1 = this.getEventPosition(e), lineInfo = this.getLineByPoint(cache, p1);
|
|
572
|
+
if (!lineInfo) return;
|
|
573
|
+
const {columnInfo: columnInfo, delta: delta} = this.getColumnAndIndexByLinePoint(lineInfo, p1);
|
|
574
|
+
if (!columnInfo) return;
|
|
575
|
+
const y1 = lineInfo.top, y2 = lineInfo.top + lineInfo.height;
|
|
576
|
+
let cursorIndex = this.getColumnIndex(cache, columnInfo);
|
|
577
|
+
cursorIndex += delta;
|
|
578
|
+
return {
|
|
579
|
+
x: columnInfo.left + (delta > 0 ? columnInfo.width : 0),
|
|
580
|
+
y1: y1,
|
|
581
|
+
y2: y2,
|
|
582
|
+
cursorIndex: cursorIndex,
|
|
583
|
+
lineInfo: lineInfo,
|
|
584
|
+
columnInfo: columnInfo
|
|
585
|
+
};
|
|
300
586
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
})), richtext.setAttributes({
|
|
322
|
-
textConfig: tc
|
|
323
|
-
}), richtext.doUpdateFrameCache(tc);
|
|
587
|
+
computedCursorPosByCursorIdx(cursorIdx, rt) {
|
|
588
|
+
var _a, _b, _c;
|
|
589
|
+
const idx = Math.round(cursorIdx), leftRight = cursorIdx - idx, cache = rt.getFrameCache(), column = this.getColumnByIndex(cache, idx), height = null !== (_a = rt.attribute.fontSize) && void 0 !== _a ? _a : null === (_c = null === (_b = rt.attribute.textConfig) || void 0 === _b ? void 0 : _b[0]) || void 0 === _c ? void 0 : _c.fontSize;
|
|
590
|
+
if (!column) {
|
|
591
|
+
if (!cache.lines.length) {
|
|
592
|
+
return {
|
|
593
|
+
x: 0,
|
|
594
|
+
y1: 0,
|
|
595
|
+
y2: getRichTextBounds(Object.assign(Object.assign({}, rt.attribute), {
|
|
596
|
+
textConfig: [ {
|
|
597
|
+
text: "a"
|
|
598
|
+
} ]
|
|
599
|
+
})).height()
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
return {
|
|
603
|
+
x: 0,
|
|
604
|
+
y1: 0,
|
|
605
|
+
y2: height
|
|
606
|
+
};
|
|
324
607
|
}
|
|
608
|
+
const {lineInfo: lineInfo, columnInfo: columnInfo} = column, y1 = lineInfo.top, y2 = lineInfo.top + lineInfo.height;
|
|
609
|
+
return {
|
|
610
|
+
x: columnInfo.left + (leftRight < 0 ? 0 : columnInfo.width),
|
|
611
|
+
y1: y1,
|
|
612
|
+
y2: y2,
|
|
613
|
+
lineInfo: lineInfo,
|
|
614
|
+
columnInfo: columnInfo
|
|
615
|
+
};
|
|
325
616
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
617
|
+
getColumnByIndex(cache, index) {
|
|
618
|
+
for (let i = 0, inputIndex = 0; i < cache.lines.length; i++) {
|
|
619
|
+
const lineInfo = cache.lines[i];
|
|
620
|
+
for (let j = 0; j < lineInfo.paragraphs.length; j++) {
|
|
621
|
+
const columnInfo = lineInfo.paragraphs[j];
|
|
622
|
+
if (inputIndex === index) return {
|
|
623
|
+
lineInfo: lineInfo,
|
|
624
|
+
columnInfo: columnInfo
|
|
625
|
+
};
|
|
626
|
+
inputIndex++;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return null;
|
|
330
630
|
}
|
|
331
631
|
release() {
|
|
332
|
-
this.editModule.release();
|
|
632
|
+
this.deactivate(this.pluginService), this.editModule.release();
|
|
633
|
+
}
|
|
634
|
+
getSelection(defaultAll = !1) {
|
|
635
|
+
return this.currRt ? null != this.selectionStartCursorIdx && null != this.curCursorIdx ? new Selection(this.selectionStartCursorIdx, this.curCursorIdx, this.currRt) : defaultAll ? RichTextEditPlugin.CreateSelection(this.currRt) : null : null;
|
|
636
|
+
}
|
|
637
|
+
forceFocus(params) {
|
|
638
|
+
const {target: target, e: e, cursorIndex: cursorIndex} = params;
|
|
639
|
+
target && (this.currRt = target, e ? this._forceFocusByEvent(e) : this._forceFocusByCursorIndex(null != cursorIndex ? cursorIndex : -.1));
|
|
640
|
+
}
|
|
641
|
+
_forceFocusByEvent(e) {
|
|
642
|
+
this.handleEnter(), this.handlePointerDown(e), this.handlePointerUp(e);
|
|
643
|
+
}
|
|
644
|
+
_forceFocusByCursorIndex(cursorIndex) {
|
|
645
|
+
const richtext = this.currRt;
|
|
646
|
+
if (!richtext) return;
|
|
647
|
+
let x = 0, y1 = 0, y2 = 2, lineInfo = null, columnInfo = null;
|
|
648
|
+
const data = this.computedCursorPosByCursorIdx(cursorIndex, richtext);
|
|
649
|
+
x = data.x, y1 = data.y1, y2 = data.y2, lineInfo = data.lineInfo, columnInfo = data.columnInfo,
|
|
650
|
+
this.onFocus({
|
|
651
|
+
target: this.currRt
|
|
652
|
+
}, {
|
|
653
|
+
x: x,
|
|
654
|
+
y1: y1,
|
|
655
|
+
y2: y2,
|
|
656
|
+
cursorIndex: cursorIndex,
|
|
657
|
+
lineInfo: lineInfo,
|
|
658
|
+
columnInfo: columnInfo
|
|
659
|
+
});
|
|
333
660
|
}
|
|
334
661
|
}
|
|
335
662
|
//# sourceMappingURL=richtext-edit-plugin.js.map
|