@hailin-zheng/editor-core 1.0.4 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{dist → lib}/doc-ruler.d.ts +0 -0
- package/{dist → lib}/doc-ruler.js +0 -0
- package/{dist → lib}/doc-ruler.js.map +0 -0
- package/{dist → lib}/framework/common-util.d.ts +0 -0
- package/{dist → lib}/framework/common-util.js +0 -0
- package/{dist → lib}/framework/common-util.js.map +0 -0
- package/{dist → lib}/framework/document-change.d.ts +0 -0
- package/{dist → lib}/framework/document-change.js +0 -0
- package/{dist → lib}/framework/document-change.js.map +0 -0
- package/{dist → lib}/framework/document-combine.d.ts +0 -0
- package/{dist → lib}/framework/document-combine.js +0 -0
- package/{dist → lib}/framework/document-combine.js.map +0 -0
- package/{dist → lib}/framework/document-comment.d.ts +0 -0
- package/{dist → lib}/framework/document-comment.js +0 -0
- package/{dist → lib}/framework/document-comment.js.map +0 -0
- package/{dist → lib}/framework/document-context.d.ts +0 -0
- package/{dist → lib}/framework/document-context.js +0 -0
- package/{dist → lib}/framework/document-context.js.map +0 -0
- package/{dist → lib}/framework/document-eval-func.d.ts +0 -0
- package/{dist → lib}/framework/document-eval-func.js +0 -0
- package/{dist → lib}/framework/document-eval-func.js.map +0 -0
- package/{dist → lib}/framework/document-event.d.ts +0 -0
- package/{dist → lib}/framework/document-event.js +0 -0
- package/{dist → lib}/framework/document-event.js.map +0 -0
- package/{dist → lib}/framework/document-history.d.ts +0 -0
- package/{dist → lib}/framework/document-history.js +0 -0
- package/{dist → lib}/framework/document-history.js.map +0 -0
- package/{dist → lib}/framework/document-images-loader.d.ts +0 -0
- package/{dist → lib}/framework/document-images-loader.js +0 -0
- package/{dist → lib}/framework/document-images-loader.js.map +0 -0
- package/{dist → lib}/framework/document-input-cursor.d.ts +0 -0
- package/{dist → lib}/framework/document-input-cursor.js +0 -0
- package/{dist → lib}/framework/document-input-cursor.js.map +0 -0
- package/{dist → lib}/framework/document-paint.d.ts +0 -0
- package/{dist → lib}/framework/document-paint.js +0 -0
- package/{dist → lib}/framework/document-paint.js.map +0 -0
- package/{dist → lib}/framework/document-print-offscreen.d.ts +0 -0
- package/{dist → lib}/framework/document-print-offscreen.js +0 -0
- package/{dist → lib}/framework/document-print-offscreen.js.map +0 -0
- package/{dist → lib}/framework/document-print.d.ts +0 -0
- package/{dist → lib}/framework/document-print.js +0 -0
- package/{dist → lib}/framework/document-print.js.map +0 -0
- package/{dist → lib}/framework/document-segmenter.d.ts +0 -0
- package/{dist → lib}/framework/document-segmenter.js +0 -0
- package/{dist → lib}/framework/document-segmenter.js.map +0 -0
- package/{dist → lib}/framework/document-selection.d.ts +0 -0
- package/{dist → lib}/framework/document-selection.js +0 -0
- package/{dist → lib}/framework/document-selection.js.map +0 -0
- package/{dist → lib}/framework/document-template.d.ts +0 -0
- package/{dist → lib}/framework/document-template.js +0 -0
- package/{dist → lib}/framework/document-template.js.map +0 -0
- package/{dist → lib}/framework/document-textline-mode.d.ts +0 -0
- package/{dist → lib}/framework/document-textline-mode.js +0 -0
- package/{dist → lib}/framework/document-textline-mode.js.map +0 -0
- package/{dist → lib}/framework/element-define.d.ts +0 -0
- package/{dist → lib}/framework/element-define.js +0 -0
- package/{dist → lib}/framework/element-define.js.map +0 -0
- package/{dist → lib}/framework/element-event-define.d.ts +0 -0
- package/{dist → lib}/framework/element-event-define.js +0 -0
- package/{dist → lib}/framework/element-event-define.js.map +0 -0
- package/{dist → lib}/framework/element-measure.d.ts +0 -0
- package/{dist → lib}/framework/element-measure.js +0 -0
- package/{dist → lib}/framework/element-measure.js.map +0 -0
- package/{dist → lib}/framework/element-paint.d.ts +0 -0
- package/{dist → lib}/framework/element-paint.js +0 -0
- package/{dist → lib}/framework/element-paint.js.map +0 -0
- package/{dist → lib}/framework/element-props.d.ts +0 -0
- package/{dist → lib}/framework/element-props.js +0 -0
- package/{dist → lib}/framework/element-props.js.map +0 -0
- package/{dist → lib}/framework/element-reader.d.ts +0 -0
- package/{dist → lib}/framework/element-reader.js +0 -0
- package/{dist → lib}/framework/element-reader.js.map +0 -0
- package/{dist → lib}/framework/element-render-cut.d.ts +0 -0
- package/{dist → lib}/framework/element-render-cut.js +0 -0
- package/{dist → lib}/framework/element-render-cut.js.map +0 -0
- package/{dist → lib}/framework/element-serialize.d.ts +0 -0
- package/{dist → lib}/framework/element-serialize.js +0 -0
- package/{dist → lib}/framework/element-serialize.js.map +0 -0
- package/{dist → lib}/framework/element-util.d.ts +0 -0
- package/{dist → lib}/framework/element-util.js +0 -0
- package/{dist → lib}/framework/element-util.js.map +0 -0
- package/{dist → lib}/framework/impl/checkbox/checkbox-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/checkbox/checkbox-impl.js +0 -0
- package/{dist → lib}/framework/impl/checkbox/checkbox-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/comments/comment-content-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/comments/comment-content-impl.js +0 -0
- package/{dist → lib}/framework/impl/comments/comment-content-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/comments/comment-element-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/comments/comment-element-impl.js +0 -0
- package/{dist → lib}/framework/impl/comments/comment-element-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/comments/comments-container-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/comments/comments-container-impl.js +0 -0
- package/{dist → lib}/framework/impl/comments/comments-container-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/comments/comments-util.d.ts +0 -0
- package/{dist → lib}/framework/impl/comments/comments-util.js +0 -0
- package/{dist → lib}/framework/impl/comments/comments-util.js.map +0 -0
- package/{dist → lib}/framework/impl/comments/validate-msg-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/comments/validate-msg-impl.js +0 -0
- package/{dist → lib}/framework/impl/comments/validate-msg-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/data-element/data-decorate-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/data-element/data-decorate-impl.js +0 -0
- package/{dist → lib}/framework/impl/data-element/data-decorate-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-barcode.d.ts +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-barcode.js +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-barcode.js.map +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-base-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-base-impl.js +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-base-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-check-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-check-impl.js +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-check-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-date-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-date-impl.js +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-date-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-group-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-group-impl.js +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-group-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-image-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-image-impl.js +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-image-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-list-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-list-impl.js +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-list-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-text-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-text-impl.js +0 -0
- package/{dist → lib}/framework/impl/data-element/data-element-text-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/decorate/fill-null-space-imple.d.ts +0 -0
- package/{dist → lib}/framework/impl/decorate/fill-null-space-imple.js +0 -0
- package/{dist → lib}/framework/impl/decorate/fill-null-space-imple.js.map +0 -0
- package/{dist → lib}/framework/impl/document/doc-body-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/document/doc-body-impl.js +0 -0
- package/{dist → lib}/framework/impl/document/doc-body-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/document/doc-body-part-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/document/doc-body-part-impl.js +0 -0
- package/{dist → lib}/framework/impl/document/doc-body-part-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/document/doc-container-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/document/doc-container-impl.js +0 -0
- package/{dist → lib}/framework/impl/document/doc-container-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/document/doc-footer-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/document/doc-footer-impl.js +0 -0
- package/{dist → lib}/framework/impl/document/doc-footer-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/document/doc-header-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/document/doc-header-impl.js +0 -0
- package/{dist → lib}/framework/impl/document/doc-header-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/document/doc-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/document/doc-impl.js +0 -0
- package/{dist → lib}/framework/impl/document/doc-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/media-formula/menstrual-history.d.ts +0 -0
- package/{dist → lib}/framework/impl/media-formula/menstrual-history.js +0 -0
- package/{dist → lib}/framework/impl/media-formula/menstrual-history.js.map +0 -0
- package/{dist → lib}/framework/impl/paragraph/p-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/paragraph/p-impl.js +0 -0
- package/{dist → lib}/framework/impl/paragraph/p-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/picture/image-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/picture/image-impl.js +0 -0
- package/{dist → lib}/framework/impl/picture/image-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/radio/radio-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/radio/radio-impl.js +0 -0
- package/{dist → lib}/framework/impl/radio/radio-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/symbol/br-symbol-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/symbol/br-symbol-impl.js +0 -0
- package/{dist → lib}/framework/impl/symbol/br-symbol-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/symbol/p-symbol-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/symbol/p-symbol-impl.js +0 -0
- package/{dist → lib}/framework/impl/symbol/p-symbol-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/table/table-cell-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/table/table-cell-impl.js +0 -0
- package/{dist → lib}/framework/impl/table/table-cell-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/table/table-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/table/table-impl.js +0 -0
- package/{dist → lib}/framework/impl/table/table-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/table/table-row-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/table/table-row-impl.js +0 -0
- package/{dist → lib}/framework/impl/table/table-row-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/table/table-split-cell-patch.d.ts +0 -0
- package/{dist → lib}/framework/impl/table/table-split-cell-patch.js +0 -0
- package/{dist → lib}/framework/impl/table/table-split-cell-patch.js.map +0 -0
- package/{dist → lib}/framework/impl/table/table-split-cell.d.ts +0 -0
- package/{dist → lib}/framework/impl/table/table-split-cell.js +0 -0
- package/{dist → lib}/framework/impl/table/table-split-cell.js.map +0 -0
- package/{dist → lib}/framework/impl/table/table-util.d.ts +0 -0
- package/{dist → lib}/framework/impl/table/table-util.js +0 -0
- package/{dist → lib}/framework/impl/table/table-util.js.map +0 -0
- package/{dist → lib}/framework/impl/text/text-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/text/text-impl.js +0 -0
- package/{dist → lib}/framework/impl/text/text-impl.js.map +0 -0
- package/{dist → lib}/framework/impl/text/track-run-impl.d.ts +0 -0
- package/{dist → lib}/framework/impl/text/track-run-impl.js +0 -0
- package/{dist → lib}/framework/impl/text/track-run-impl.js.map +0 -0
- package/{dist → lib}/framework/notify.d.ts +0 -0
- package/{dist → lib}/framework/notify.js +0 -0
- package/{dist → lib}/framework/notify.js.map +0 -0
- package/{dist → lib}/framework/range-util.d.ts +0 -0
- package/{dist → lib}/framework/range-util.js +0 -0
- package/{dist → lib}/framework/range-util.js.map +0 -0
- package/{dist → lib}/framework/render-context.d.ts +0 -0
- package/{dist → lib}/framework/render-context.js +0 -0
- package/{dist → lib}/framework/render-context.js.map +0 -0
- package/{dist → lib}/framework/render-define.d.ts +0 -0
- package/{dist → lib}/framework/render-define.js +0 -0
- package/{dist → lib}/framework/render-define.js.map +0 -0
- package/{dist → lib}/framework/selection-overlays.d.ts +0 -0
- package/{dist → lib}/framework/selection-overlays.js +0 -0
- package/{dist → lib}/framework/selection-overlays.js.map +0 -0
- package/{dist → lib}/texteditor.d.ts +0 -0
- package/{dist → lib}/texteditor.js +0 -0
- package/{dist → lib}/texteditor.js.map +0 -0
- package/{dist → lib}/util/subject.d.ts +0 -0
- package/{dist → lib}/util/subject.js +0 -0
- package/{dist → lib}/util/subject.js.map +0 -0
- package/{dist → lib}/util/table-bind.d.ts +0 -0
- package/{dist → lib}/util/table-bind.js +0 -0
- package/{dist → lib}/util/table-bind.js.map +0 -0
- package/package.json +7 -2
- package/src/med_editor/doc-ruler.ts +0 -340
- package/src/med_editor/framework/common-util.ts +0 -200
- package/src/med_editor/framework/document-change.ts +0 -1392
- package/src/med_editor/framework/document-combine.ts +0 -44
- package/src/med_editor/framework/document-comment.ts +0 -168
- package/src/med_editor/framework/document-context.ts +0 -410
- package/src/med_editor/framework/document-eval-func.ts +0 -53
- package/src/med_editor/framework/document-event.ts +0 -1082
- package/src/med_editor/framework/document-history.ts +0 -76
- package/src/med_editor/framework/document-images-loader.ts +0 -74
- package/src/med_editor/framework/document-input-cursor.ts +0 -244
- package/src/med_editor/framework/document-paint.ts +0 -110
- package/src/med_editor/framework/document-print-offscreen.ts +0 -134
- package/src/med_editor/framework/document-print.ts +0 -219
- package/src/med_editor/framework/document-segmenter.ts +0 -211
- package/src/med_editor/framework/document-selection.ts +0 -391
- package/src/med_editor/framework/document-template.ts +0 -20
- package/src/med_editor/framework/document-textline-mode.ts +0 -34
- package/src/med_editor/framework/element-define.ts +0 -674
- package/src/med_editor/framework/element-event-define.ts +0 -142
- package/src/med_editor/framework/element-measure.ts +0 -573
- package/src/med_editor/framework/element-paint.ts +0 -176
- package/src/med_editor/framework/element-props.ts +0 -938
- package/src/med_editor/framework/element-reader.ts +0 -159
- package/src/med_editor/framework/element-render-cut.ts +0 -456
- package/src/med_editor/framework/element-serialize.ts +0 -128
- package/src/med_editor/framework/element-util.ts +0 -1565
- package/src/med_editor/framework/impl/checkbox/checkbox-impl.ts +0 -71
- package/src/med_editor/framework/impl/comments/comment-content-impl.ts +0 -119
- package/src/med_editor/framework/impl/comments/comment-element-impl.ts +0 -65
- package/src/med_editor/framework/impl/comments/comments-container-impl.ts +0 -68
- package/src/med_editor/framework/impl/comments/comments-util.ts +0 -84
- package/src/med_editor/framework/impl/comments/validate-msg-impl.ts +0 -94
- package/src/med_editor/framework/impl/data-element/data-decorate-impl.ts +0 -95
- package/src/med_editor/framework/impl/data-element/data-element-barcode.ts +0 -127
- package/src/med_editor/framework/impl/data-element/data-element-base-impl.ts +0 -234
- package/src/med_editor/framework/impl/data-element/data-element-check-impl.ts +0 -146
- package/src/med_editor/framework/impl/data-element/data-element-date-impl.ts +0 -128
- package/src/med_editor/framework/impl/data-element/data-element-group-impl.ts +0 -150
- package/src/med_editor/framework/impl/data-element/data-element-image-impl.ts +0 -147
- package/src/med_editor/framework/impl/data-element/data-element-list-impl.ts +0 -142
- package/src/med_editor/framework/impl/data-element/data-element-text-impl.ts +0 -117
- package/src/med_editor/framework/impl/decorate/fill-null-space-imple.ts +0 -48
- package/src/med_editor/framework/impl/document/doc-body-impl.ts +0 -95
- package/src/med_editor/framework/impl/document/doc-body-part-impl.ts +0 -104
- package/src/med_editor/framework/impl/document/doc-container-impl.ts +0 -24
- package/src/med_editor/framework/impl/document/doc-footer-impl.ts +0 -88
- package/src/med_editor/framework/impl/document/doc-header-impl.ts +0 -100
- package/src/med_editor/framework/impl/document/doc-impl.ts +0 -226
- package/src/med_editor/framework/impl/media-formula/menstrual-history.ts +0 -175
- package/src/med_editor/framework/impl/paragraph/p-impl.ts +0 -190
- package/src/med_editor/framework/impl/picture/image-impl.ts +0 -136
- package/src/med_editor/framework/impl/radio/radio-impl.ts +0 -79
- package/src/med_editor/framework/impl/symbol/br-symbol-impl.ts +0 -60
- package/src/med_editor/framework/impl/symbol/p-symbol-impl.ts +0 -57
- package/src/med_editor/framework/impl/table/table-cell-impl.ts +0 -156
- package/src/med_editor/framework/impl/table/table-impl.ts +0 -401
- package/src/med_editor/framework/impl/table/table-row-impl.ts +0 -83
- package/src/med_editor/framework/impl/table/table-split-cell-patch.ts +0 -98
- package/src/med_editor/framework/impl/table/table-split-cell.ts +0 -475
- package/src/med_editor/framework/impl/table/table-util.ts +0 -716
- package/src/med_editor/framework/impl/text/text-impl.ts +0 -164
- package/src/med_editor/framework/impl/text/track-run-impl.ts +0 -135
- package/src/med_editor/framework/notify.ts +0 -130
- package/src/med_editor/framework/range-util.ts +0 -321
- package/src/med_editor/framework/render-context.ts +0 -431
- package/src/med_editor/framework/render-define.ts +0 -224
- package/src/med_editor/framework/selection-overlays.ts +0 -134
- package/src/med_editor/texteditor.ts +0 -1011
- package/src/med_editor/util/subject.ts +0 -118
- package/src/med_editor/util/table-bind.ts +0 -6
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225.json +0 -3573
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225.json +0 -3573
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225bug.json +0 -315
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225/346/211/271/346/263/250.json +0 -122
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225/346/226/207/346/241/243/351/252/214/350/257/201.json +0 -3599
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225/351/225/277/346/226/207/346/234/254.json +0 -24586
- package/src/med_editor//345/220/210/345/271/266/347/227/205/347/250/213/345/275/225.json +0 -2874
- package/src/med_editor//346/211/213/346/234/257/350/256/260/345/275/225.json +0 -341
- package/src/med_editor//346/231/256/351/200/232doc/347/261/273/346/226/207/346/241/243.json +0 -2201
- package/src/med_editor//346/243/200/351/252/214/347/224/263/350/257/267/345/215/225.json +0 -1069
- package/src/med_editor//347/227/205/347/250/213/345/275/225//345/206/205/351/225/234/344/270/213/346/262/273/347/226/227/350/256/260/345/275/225.json +0 -125
- package/src/med_editor//347/227/205/347/250/213/345/275/225//345/220/210/345/271/266/347/227/205/347/250/213/345/275/225/346/250/241/346/235/277.json +0 -86
- package/src/med_editor//347/227/205/347/250/213/345/275/225//346/227/245/345/270/270/347/227/205/347/250/213/350/256/260/345/275/225.json +0 -115
- package/src/med_editor//347/227/205/347/250/213/345/275/225//346/237/245/346/210/277/350/256/260/345/275/2251.json +0 -108
- package/src/med_editor//347/227/205/347/250/213/345/275/225//351/246/226/346/254/241/344/270/212/347/272/247/345/214/273/345/270/210/346/237/245/346/210/277/350/256/260/345/275/225.json +0 -272
- package/src/med_editor//351/225/277/346/234/237/345/214/273/345/230/261/345/215/225.json +0 -1070
- package/webpack.config.js +0 -46
@@ -1,340 +0,0 @@
|
|
1
|
-
import { ElementUtil } from "@/med_editor/framework/element-util";
|
2
|
-
import { DocumentCursor, SelectionState } from "./framework/document-selection";
|
3
|
-
import { Position, ViewOptions } from "./framework/element-define";
|
4
|
-
import { HitEventInfo } from "./framework/element-event-define";
|
5
|
-
import { DocumentRenderObject } from "./framework/impl/document/doc-impl";
|
6
|
-
import { ParagraphElement, ParagraphRenderObject } from "./framework/impl/paragraph/p-impl";
|
7
|
-
import { TableCellRenderObject } from "./framework/impl/table/table-cell-impl";
|
8
|
-
import { TableRowRenderObject } from "./framework/impl/table/table-row-impl";
|
9
|
-
import { RenderObject } from "./framework/render-define";
|
10
|
-
|
11
|
-
export interface RuleOptions {
|
12
|
-
width: number;
|
13
|
-
pagePL: number;
|
14
|
-
pagePR: number;
|
15
|
-
docLeft: number;
|
16
|
-
|
17
|
-
}
|
18
|
-
export class DocRule {
|
19
|
-
private ctx!: CanvasRenderingContext2D;
|
20
|
-
private options: RuleOptions;
|
21
|
-
//标尺高度
|
22
|
-
private ruleHeight = 30;
|
23
|
-
//当前标尺的位置
|
24
|
-
private thumbX: {
|
25
|
-
indent: number,
|
26
|
-
hanging: number
|
27
|
-
}
|
28
|
-
private mouseDownPos!: Position | null;
|
29
|
-
private indentThumbPoints: Array<Position> = [];
|
30
|
-
private hangThumbPoints: Array<Position> = [];
|
31
|
-
private mouseDownThumbType: 'none' | 'indent' | 'hang' = 'none';
|
32
|
-
constructor(public canvas: HTMLCanvasElement, public viewOptions: ViewOptions, public ss: SelectionState) {
|
33
|
-
this.ctx = this.canvas.getContext('2d') as CanvasRenderingContext2D;
|
34
|
-
this.options = {
|
35
|
-
width: 0,
|
36
|
-
pagePL: 0,
|
37
|
-
pagePR: 0,
|
38
|
-
docLeft: 0
|
39
|
-
};
|
40
|
-
this.thumbX = {
|
41
|
-
indent: 0,
|
42
|
-
hanging: 0
|
43
|
-
};
|
44
|
-
this.canvas.addEventListener("mousedown", (evt) => this.canvasMousedown(evt));
|
45
|
-
this.canvas.addEventListener("mousemove", (evt) => this.canvasMousemove(evt));
|
46
|
-
this.canvas.addEventListener("mouseup", (evt) => this.canvasMouseup(evt));
|
47
|
-
}
|
48
|
-
|
49
|
-
destroy(): void {
|
50
|
-
this.canvas.removeEventListener("mousedown", this.canvasMousedown);
|
51
|
-
this.canvas.removeEventListener("mousemove", this.canvasMousemove);
|
52
|
-
this.canvas.removeEventListener("mouseup", this.canvasMouseup);
|
53
|
-
}
|
54
|
-
|
55
|
-
setRuleOptions(options: RuleOptions) {
|
56
|
-
this.options = options;
|
57
|
-
const convertRatio = this.viewOptions.mmToPixelsRatio;
|
58
|
-
this.options.pagePL = Math.floor(this.options.pagePL * convertRatio);
|
59
|
-
this.options.pagePR = Math.floor(this.options.pagePR * convertRatio);
|
60
|
-
this.scaleView();
|
61
|
-
ElementUtil.setCanvasProps(this.canvas, this.ctx, { width: this.getParentWidth(), height: this.ruleHeight });
|
62
|
-
//this.canvas.style.left = this.options.docLeft + 'px';
|
63
|
-
}
|
64
|
-
|
65
|
-
getParentWidth(): number {
|
66
|
-
const parent = this.canvas.parentElement as HTMLDivElement;
|
67
|
-
return parent.getBoundingClientRect().width;
|
68
|
-
}
|
69
|
-
|
70
|
-
private fillRect(x: number, y: number, width: number, height: number, color: string) {
|
71
|
-
this.ctx.fillStyle = color;
|
72
|
-
this.ctx.fillRect(x, y, width, height);
|
73
|
-
}
|
74
|
-
|
75
|
-
private drawIndentThumb(x: number, y: number): Array<Position> {
|
76
|
-
const points: Array<Position> = [];
|
77
|
-
x -= 4;
|
78
|
-
points.push({ x: x, y });
|
79
|
-
points.push({ x: x, y: y + 3 });
|
80
|
-
points.push({ x: x + 4, y: y + 7 });
|
81
|
-
points.push({ x: x + 8, y: y + 3 });
|
82
|
-
points.push({ x: x + 8, y });
|
83
|
-
points.push({ x: x, y });
|
84
|
-
this.drawLine(points);
|
85
|
-
return points;
|
86
|
-
}
|
87
|
-
|
88
|
-
private drawHangThumb(x: number, y: number): Array<Position> {
|
89
|
-
const points: Array<{ x: number, y: number }> = [];
|
90
|
-
x -= 4;
|
91
|
-
points.push({ x: x, y });
|
92
|
-
points.push({ x: x, y: y - 3 });
|
93
|
-
points.push({ x: x + 4, y: y - 7 });
|
94
|
-
points.push({ x: x + 8, y: y - 3 });
|
95
|
-
points.push({ x: x + 8, y });
|
96
|
-
points.push({ x: x, y });
|
97
|
-
points.push({ x: x, y: y + 3 });
|
98
|
-
points.push({ x: x + 8, y: y + 3 });
|
99
|
-
points.push({ x: x + 8, y: y });
|
100
|
-
this.drawLine(points);
|
101
|
-
return points;
|
102
|
-
}
|
103
|
-
|
104
|
-
private measureText(text: string) {
|
105
|
-
this.ctx.font = "8px 'Times New Roman'";
|
106
|
-
const measure = this.ctx.measureText(text);
|
107
|
-
return measure.width;
|
108
|
-
}
|
109
|
-
|
110
|
-
private drawLine(points: Array<Position>): void {
|
111
|
-
this.ctx.beginPath();
|
112
|
-
this.ctx.save();
|
113
|
-
this.ctx.fillStyle = "white";
|
114
|
-
this.ctx.lineWidth = 0.5;
|
115
|
-
for (let j = 0; j < points.length; j++) {
|
116
|
-
let { x, y } = points[j];
|
117
|
-
x += 0.5;
|
118
|
-
y += 0.5;
|
119
|
-
if (j === 0) {
|
120
|
-
this.ctx.moveTo(x, y);
|
121
|
-
} else {
|
122
|
-
this.ctx.lineTo(x, y);
|
123
|
-
}
|
124
|
-
}
|
125
|
-
this.ctx.stroke();
|
126
|
-
this.ctx.fill();
|
127
|
-
this.ctx.closePath();
|
128
|
-
this.ctx.restore();
|
129
|
-
}
|
130
|
-
|
131
|
-
private drawText(text: string, x: number, y: number) {
|
132
|
-
this.ctx.save();
|
133
|
-
this.ctx.fillStyle = "rgb(0,0,0)";
|
134
|
-
this.ctx.textBaseline = "alphabetic";
|
135
|
-
this.ctx.font = "8px 'Times New Roman'";
|
136
|
-
this.ctx.fillText(text, x, y + 8 - 1);
|
137
|
-
this.ctx.restore();
|
138
|
-
}
|
139
|
-
|
140
|
-
/**
|
141
|
-
* 刷新新的状态
|
142
|
-
* @param indent
|
143
|
-
* @param hang
|
144
|
-
*/
|
145
|
-
refreshRule(): void {
|
146
|
-
this.ctx.clearRect(0, 0, this.canvas.width, this.ruleHeight);
|
147
|
-
this.ctx.save();
|
148
|
-
this.ctx.translate(this.options.docLeft, 0);
|
149
|
-
this.drawRule();
|
150
|
-
this.ctx.restore();
|
151
|
-
}
|
152
|
-
|
153
|
-
private canvasMousedown(evt: MouseEvent): void {
|
154
|
-
const clickPos = this.getMousePos(evt);
|
155
|
-
if (this.pointInPoly(clickPos, this.indentThumbPoints)) {
|
156
|
-
this.mouseDownThumbType = 'indent';
|
157
|
-
this.mouseDownPos = clickPos;
|
158
|
-
} else if (this.pointInPoly(clickPos, this.hangThumbPoints)) {
|
159
|
-
this.mouseDownThumbType = 'hang';
|
160
|
-
this.mouseDownPos = clickPos;
|
161
|
-
} else {
|
162
|
-
console.log("未点击在里面");
|
163
|
-
}
|
164
|
-
}
|
165
|
-
|
166
|
-
private getMousePos(evt: MouseEvent): Position {
|
167
|
-
return {
|
168
|
-
x: evt.offsetX - this.options.docLeft,
|
169
|
-
y: evt.offsetY
|
170
|
-
}
|
171
|
-
}
|
172
|
-
|
173
|
-
private canvasMousemove(evt: MouseEvent): void {
|
174
|
-
if (['indent', 'hang'].indexOf(this.mouseDownThumbType) < 0) {
|
175
|
-
return;
|
176
|
-
}
|
177
|
-
if (!this.mouseDownPos) {
|
178
|
-
return;
|
179
|
-
}
|
180
|
-
const canvasPos = this.getMousePos(evt);
|
181
|
-
let moveX = canvasPos.x - this.mouseDownPos.x;
|
182
|
-
//至少移动5px再进行修改
|
183
|
-
const remainder = moveX % 5;
|
184
|
-
if (Math.abs(remainder) < 3) {
|
185
|
-
return;
|
186
|
-
} else {
|
187
|
-
if (remainder < 0) {
|
188
|
-
moveX -= 5 + remainder;
|
189
|
-
} else {
|
190
|
-
moveX += 5 - remainder;
|
191
|
-
}
|
192
|
-
}
|
193
|
-
if (moveX === 0) {
|
194
|
-
return;
|
195
|
-
}
|
196
|
-
canvasPos.x = this.mouseDownPos.x + moveX;
|
197
|
-
const para = this.getCurrPara();
|
198
|
-
if (!para) {
|
199
|
-
throw new Error('para is null')
|
200
|
-
}
|
201
|
-
if (this.mouseDownThumbType === 'indent') {
|
202
|
-
this.thumbX.indent += moveX;
|
203
|
-
this.thumbX.indent = this.thumbX.indent < 0 ? 0 : this.thumbX.indent;
|
204
|
-
this.thumbX.indent = this.thumbX.indent > this.options.width ? this.options.width : this.thumbX.indent;
|
205
|
-
this.mouseDownPos = canvasPos;
|
206
|
-
para.props.indent += moveX;
|
207
|
-
this.drawRule();
|
208
|
-
}
|
209
|
-
if (this.mouseDownThumbType === 'hang') {
|
210
|
-
this.thumbX.hanging += moveX;
|
211
|
-
this.thumbX.hanging = this.thumbX.hanging < 0 ? 0 : this.thumbX.hanging;
|
212
|
-
this.thumbX.hanging = this.thumbX.hanging > this.options.width ? this.options.width : this.thumbX.hanging;
|
213
|
-
this.mouseDownPos = canvasPos;
|
214
|
-
para.props.hanging += moveX;
|
215
|
-
this.drawRule();
|
216
|
-
}
|
217
|
-
}
|
218
|
-
|
219
|
-
private canvasMouseup(evt: MouseEvent): void {
|
220
|
-
this.mouseDownThumbType = 'none';
|
221
|
-
this.mouseDownPos = null;
|
222
|
-
}
|
223
|
-
|
224
|
-
|
225
|
-
private pointInPoly(pt: Position, poly: Array<Position>): boolean {
|
226
|
-
let c = false;
|
227
|
-
for (let i = -1, l = poly.length, j = l - 1; ++i < l; j = i) {
|
228
|
-
if (((poly[i].y <= pt.y && pt.y < poly[j].y) || (poly[j].y <= pt.y && pt.y < poly[i].y)) && pt.x < ((poly[j].x - poly[i].x) * (pt.y - poly[i].y)) / (poly[j].y - poly[i].y) + poly[i].x) {
|
229
|
-
c = !c
|
230
|
-
}
|
231
|
-
}
|
232
|
-
return c;
|
233
|
-
}
|
234
|
-
|
235
|
-
|
236
|
-
/**
|
237
|
-
* 绘制
|
238
|
-
*/
|
239
|
-
private drawRule(): void {
|
240
|
-
this.fillRect(0, 0, this.options.pagePL, this.ruleHeight, "rgb(198,198,198)");
|
241
|
-
this.fillRect(this.options.width - this.options.pagePR, 0, this.options.pagePR, this.ruleHeight, "rgb(198,198,198)");
|
242
|
-
for (let j = 0; j < 50; j++) {
|
243
|
-
const gantWidth = 20;
|
244
|
-
const points: Array<Position> = [];
|
245
|
-
const x = j * gantWidth;
|
246
|
-
if (x > this.options.width) {
|
247
|
-
break;
|
248
|
-
}
|
249
|
-
const y = 10;
|
250
|
-
points.push({ x, y }, { x, y: y + 10 });
|
251
|
-
this.drawLine(points);
|
252
|
-
const textWidth = this.measureText(j + "");
|
253
|
-
this.drawText(j + '', x + Math.floor((gantWidth - textWidth) / 2), y + 1);
|
254
|
-
}
|
255
|
-
this.getRuleMarksPos();
|
256
|
-
this.indentThumbPoints = this.drawIndentThumb(this.thumbX.indent, 6);
|
257
|
-
this.hangThumbPoints = this.drawHangThumb(this.thumbX.hanging, 25);
|
258
|
-
}
|
259
|
-
|
260
|
-
private getRuleMarksPos(): void {
|
261
|
-
const { startControl, startOffset, startHitInfo } = this.ss;
|
262
|
-
if (!startControl || !startHitInfo) {
|
263
|
-
return;
|
264
|
-
}
|
265
|
-
const para = ElementUtil.getParentByType(startControl, ParagraphElement) as ParagraphElement;
|
266
|
-
const indent = para.props.indent;
|
267
|
-
const hanging = para.props.hanging;
|
268
|
-
const { startRegion, hitDocIndex } = this.ss.startHitInfo as HitEventInfo;
|
269
|
-
const cursorPosi = DocumentCursor.getElementCursorPos(startControl, startOffset, startRegion, hitDocIndex);
|
270
|
-
//当前段落
|
271
|
-
const paraRender = ElementUtil.getParentRender(cursorPosi.render, ParagraphRenderObject) as ParagraphRenderObject;
|
272
|
-
//当前段落位置
|
273
|
-
const paraRenderPos = ElementUtil.getRenderAbsolutePaintPos(paraRender)
|
274
|
-
//当前文档
|
275
|
-
const docRender = ElementUtil.getParentRender(paraRender, DocumentRenderObject) as DocumentRenderObject;
|
276
|
-
//当前文档位置
|
277
|
-
const docRenderPos = ElementUtil.getRenderAbsolutePaintPos(docRender)
|
278
|
-
this.thumbX.indent = paraRenderPos.x - docRenderPos.x + indent;
|
279
|
-
this.thumbX.hanging = paraRenderPos.x - docRenderPos.x + hanging;
|
280
|
-
this.setParentMarksPos(paraRender);
|
281
|
-
}
|
282
|
-
|
283
|
-
private getCurrPara(): ParagraphElement | null {
|
284
|
-
const { startControl, startOffset } = this.ss;
|
285
|
-
if (!startControl) {
|
286
|
-
return null;
|
287
|
-
}
|
288
|
-
return ElementUtil.getParentByType(startControl, ParagraphElement);
|
289
|
-
}
|
290
|
-
|
291
|
-
private setParentMarksPos(childRender: RenderObject): Array<{ pos: Position }> {
|
292
|
-
const items: Array<{ pos: Position }> = [];
|
293
|
-
const parentRender = childRender.parent;
|
294
|
-
if (!parentRender || parentRender instanceof DocumentRenderObject) {
|
295
|
-
return items;
|
296
|
-
}
|
297
|
-
if (parentRender instanceof TableRowRenderObject) {
|
298
|
-
const docRender = ElementUtil.getParentRender(parentRender, DocumentRenderObject) as DocumentRenderObject;
|
299
|
-
const docRenderPos = ElementUtil.getRenderAbsolutePaintPos(docRender)
|
300
|
-
for (let i = 0; i < parentRender.length; i++) {
|
301
|
-
const cellRender = parentRender.getChild(i) as TableCellRenderObject;
|
302
|
-
const pos = ElementUtil.getRenderAbsolutePaintPos(cellRender)
|
303
|
-
this.drawCellMark(pos.x - docRenderPos.x, 0, cellRender.padding.left);
|
304
|
-
}
|
305
|
-
}
|
306
|
-
items.push(...this.setParentMarksPos(parentRender));
|
307
|
-
return items;
|
308
|
-
}
|
309
|
-
|
310
|
-
private drawCellMark(x: number, y: number, width: number): void {
|
311
|
-
x += 0.5;
|
312
|
-
y += 0.5;
|
313
|
-
this.fillRect(x, y, width, this.ruleHeight, 'rgb(198,198,198,0.2)')
|
314
|
-
for (let i = 0; i < width; i++) {
|
315
|
-
this.ctx.save();
|
316
|
-
this.ctx.beginPath();
|
317
|
-
this.ctx.lineWidth = 0.3;
|
318
|
-
this.ctx.setLineDash([0.5, 0.5, 0.5]);
|
319
|
-
this.ctx.moveTo(x + i, y);
|
320
|
-
this.ctx.lineTo(x + i, y + this.ruleHeight);
|
321
|
-
this.ctx.stroke();
|
322
|
-
this.ctx.closePath();
|
323
|
-
this.ctx.restore();
|
324
|
-
}
|
325
|
-
}
|
326
|
-
|
327
|
-
scaleView(): void {
|
328
|
-
return;
|
329
|
-
const { scale } = this.viewOptions;
|
330
|
-
//this.canvas.style.transformOrigin = 'center center';
|
331
|
-
const parent = this.canvas.parentElement as HTMLDivElement;
|
332
|
-
if (scale === 1) {
|
333
|
-
parent.style.transform = '';
|
334
|
-
} else {
|
335
|
-
parent.style.transform = `scale(${this.viewOptions.scale})`;
|
336
|
-
}
|
337
|
-
}
|
338
|
-
|
339
|
-
|
340
|
-
}
|
@@ -1,200 +0,0 @@
|
|
1
|
-
import moment from "moment";
|
2
|
-
import { Rect } from "./element-define";
|
3
|
-
import { BorderType } from "./render-define";
|
4
|
-
interface Position {
|
5
|
-
x: number;
|
6
|
-
y: number;
|
7
|
-
}
|
8
|
-
|
9
|
-
export class CommonUtil {
|
10
|
-
|
11
|
-
/**
|
12
|
-
* 判断坐标是否在矩形框内
|
13
|
-
* @param rect
|
14
|
-
* @param position
|
15
|
-
* @returns
|
16
|
-
*/
|
17
|
-
static isInsideRectByPosition(rect: Rect, position: Position): boolean {
|
18
|
-
return position.x >= rect.x
|
19
|
-
&&
|
20
|
-
position.x <= rect.x + rect.width
|
21
|
-
&&
|
22
|
-
position.y >= rect.y
|
23
|
-
&&
|
24
|
-
position.y <= rect.y + rect.height;
|
25
|
-
}
|
26
|
-
|
27
|
-
static isInsideRectByRect(rect: Rect, position: Rect): boolean {
|
28
|
-
return position.x >= rect.x
|
29
|
-
&&
|
30
|
-
position.x <= rect.x + rect.width
|
31
|
-
&&
|
32
|
-
position.y >= rect.y
|
33
|
-
&&
|
34
|
-
position.y <= rect.y + rect.height
|
35
|
-
&&
|
36
|
-
position.y + position.height <= rect.y + rect.height
|
37
|
-
&&
|
38
|
-
position.x + position.width <= rect.x + rect.width;
|
39
|
-
}
|
40
|
-
|
41
|
-
/**
|
42
|
-
* 判断坐标是否在矩形的边框上
|
43
|
-
* @param rect
|
44
|
-
* @param borderWidth
|
45
|
-
* @param position
|
46
|
-
*/
|
47
|
-
static isInRectBorder(rect: Rect, borderWidth: number, position: Position): { borderType: BorderType } {
|
48
|
-
const leftBorderRect: Rect = { x: 0, y: 0, width: borderWidth, height: rect.height, maxWidth: 0, maxHeight: 0 };
|
49
|
-
const rightBorderRect: Rect = { x: rect.width - borderWidth, y: 0, width: borderWidth, height: rect.height, maxWidth: 0, maxHeight: 0 };
|
50
|
-
const topBorderRect: Rect = { x: 0, y: 0, width: rect.width, height: borderWidth, maxWidth: 0, maxHeight: 0 };
|
51
|
-
const bottomBorderRect: Rect = { x: 0, y: rect.height - borderWidth, width: rect.width, height: borderWidth, maxWidth: 0, maxHeight: 0 };
|
52
|
-
let borderType: BorderType = 'none';
|
53
|
-
if (this.isInsideRectByPosition(leftBorderRect, position)) {
|
54
|
-
borderType = 'left';
|
55
|
-
} else if (this.isInsideRectByPosition(rightBorderRect, position)) {
|
56
|
-
borderType = 'right';
|
57
|
-
} else if (this.isInsideRectByPosition(topBorderRect, position)) {
|
58
|
-
borderType = 'top';
|
59
|
-
} else if (this.isInsideRectByPosition(bottomBorderRect, position)) {
|
60
|
-
borderType = 'bottom';
|
61
|
-
}
|
62
|
-
return { borderType };
|
63
|
-
}
|
64
|
-
|
65
|
-
/**
|
66
|
-
* 判断坐标是否在图片的缩放操作点上
|
67
|
-
*/
|
68
|
-
static isInPictureResizePoint(rect: Rect, pos: Position, r: number): { borderType: BorderType } | null {
|
69
|
-
const { width, height } = rect;
|
70
|
-
const x = 0;
|
71
|
-
const y = 0;
|
72
|
-
const points: Array<{ x: number, y: number, type: BorderType }> = [{ x, y, type: 'left-top' }, { x: x + width, y, type: 'right-top' }, { x: x + (Math.floor(width / 2)), y: y, type: 'top-middle' }, { x, y: y + Math.floor(height / 2), type: 'left-middle' }, { x, y: y + height, type: 'left-bottom' }, { x: width, y: Math.floor(height / 2), type: 'right-middle' }, { x: x + width, y: y + height, type: 'right-bottom' }, { x: x + (Math.floor(width / 2)), y: y + height, type: 'bottom-middle' }];
|
73
|
-
for (let i = 0; i < points.length; i++) {
|
74
|
-
const point = points[i];
|
75
|
-
const { x: px, y: py } = point;
|
76
|
-
if (((px - pos.x) * (px - pos.x) + (py - pos.y) * (py - pos.y)) < r * r) {
|
77
|
-
return { borderType: point.type };
|
78
|
-
}
|
79
|
-
}
|
80
|
-
return null;
|
81
|
-
}
|
82
|
-
|
83
|
-
|
84
|
-
/**
|
85
|
-
* 整形符合连线要求
|
86
|
-
* @param points
|
87
|
-
* @param width
|
88
|
-
* @param strokeColor
|
89
|
-
*/
|
90
|
-
static resharpPoints(points: Array<Position>): Array<Position> {
|
91
|
-
let prevPoint: Position = points[0];
|
92
|
-
const array: Array<Position> = [];
|
93
|
-
array.push(prevPoint);
|
94
|
-
for (let i = 1; i < points.length; i++) {
|
95
|
-
const currPoint = points[i];
|
96
|
-
//不在同一水平线
|
97
|
-
if (currPoint.y !== prevPoint.y && currPoint.x !== prevPoint.x) {
|
98
|
-
array.push({ x: currPoint.x, y: prevPoint.y });
|
99
|
-
}
|
100
|
-
array.push(currPoint);
|
101
|
-
prevPoint = currPoint;
|
102
|
-
}
|
103
|
-
return array;
|
104
|
-
}
|
105
|
-
|
106
|
-
static getOffsetX(node: HTMLElement): number {
|
107
|
-
if (!node.parentElement) {
|
108
|
-
throw new Error('node.parentElement is null')
|
109
|
-
}
|
110
|
-
const parent = node.parentElement.getBoundingClientRect().left;
|
111
|
-
const curr = node.getBoundingClientRect().left;
|
112
|
-
return curr - parent;
|
113
|
-
}
|
114
|
-
|
115
|
-
static randomColor() {
|
116
|
-
let str = "#";
|
117
|
-
for (let i = 0; i < 6; i++) {
|
118
|
-
str += Math.floor(Math.random() * 16).toString(16);
|
119
|
-
}
|
120
|
-
return str;
|
121
|
-
}
|
122
|
-
|
123
|
-
/**
|
124
|
-
* 判断一个数值是否在另一个数值的增益区间中
|
125
|
-
* @param val
|
126
|
-
* @param offset
|
127
|
-
* @param compareValue
|
128
|
-
* @returns
|
129
|
-
*/
|
130
|
-
static ApproxmateValueInRange(val: number, offset: number, compareValue: number): boolean {
|
131
|
-
return (val - offset) <= compareValue && (val + offset) >= compareValue;
|
132
|
-
}
|
133
|
-
|
134
|
-
|
135
|
-
static getEmptyValue<T>(val: T, emptyVal: T): T {
|
136
|
-
if (!val) {
|
137
|
-
return emptyVal;
|
138
|
-
}
|
139
|
-
return val;
|
140
|
-
}
|
141
|
-
|
142
|
-
/**
|
143
|
-
* 移除并集
|
144
|
-
* @param array
|
145
|
-
* @param deleteItems
|
146
|
-
* @returns
|
147
|
-
*/
|
148
|
-
static removeUnionSet<T>(array: Array<T>, deleteItems: Array<T>): Array<T> {
|
149
|
-
const arraySet = new Set(array);
|
150
|
-
for (let i = 0; i < deleteItems.length; i++) {
|
151
|
-
const item = deleteItems[i];
|
152
|
-
if (arraySet.has(item)) {
|
153
|
-
arraySet.delete(item)
|
154
|
-
}
|
155
|
-
}
|
156
|
-
return Array.from(arraySet);
|
157
|
-
}
|
158
|
-
|
159
|
-
static nullToString(val: any): string {
|
160
|
-
if (val === null || val === undefined) {
|
161
|
-
return '';
|
162
|
-
}
|
163
|
-
return val;
|
164
|
-
}
|
165
|
-
|
166
|
-
static formatDate(date: Date, format: string): string {
|
167
|
-
return moment(date).format(format);
|
168
|
-
}
|
169
|
-
|
170
|
-
static formatNow(format: string): string {
|
171
|
-
return this.formatDate(new Date(), format);
|
172
|
-
}
|
173
|
-
|
174
|
-
static parseText(text: string, data: object): string {
|
175
|
-
const reg = /\{(.*?)\}/g;
|
176
|
-
let result = text;
|
177
|
-
let match;
|
178
|
-
while (match = reg.exec(text)) {
|
179
|
-
const key = match[1];
|
180
|
-
const value = data[key];
|
181
|
-
result = result.replace(match[0], value);
|
182
|
-
}
|
183
|
-
return result;
|
184
|
-
}
|
185
|
-
|
186
|
-
//获取和当前日期相差的秒数
|
187
|
-
static getNowDiffSeconds(date: Date | string): number {
|
188
|
-
date = typeof date === 'string' ? new Date(date) : date;
|
189
|
-
const now = new Date();
|
190
|
-
const diff = now.getTime() - date.getTime();
|
191
|
-
return diff / 1000;
|
192
|
-
}
|
193
|
-
|
194
|
-
//验证当前字符串是否为日期格式
|
195
|
-
static isDate(str: string): boolean {
|
196
|
-
const reg = /^\d{4}-\d{2}-\d{2}$/;
|
197
|
-
return reg.test(str);
|
198
|
-
}
|
199
|
-
|
200
|
-
}
|