@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,76 +0,0 @@
|
|
1
|
-
import { read } from "fs";
|
2
|
-
import { Subject } from "rxjs";
|
3
|
-
import { debounceTime, filter } from 'rxjs/operators'
|
4
|
-
import { EditorContext } from "./document-context";
|
5
|
-
import { ElementReader } from "./element-reader";
|
6
|
-
import { ElementSerialize } from "./element-serialize";
|
7
|
-
|
8
|
-
export interface DocumentHistoryItem {
|
9
|
-
content: any,
|
10
|
-
time: Date
|
11
|
-
}
|
12
|
-
/**
|
13
|
-
* 支持文档重做和撤销的类
|
14
|
-
*/
|
15
|
-
export class DocumentHistory {
|
16
|
-
task: Promise<void> = Promise.resolve();
|
17
|
-
constructor(public docCtx: EditorContext, public reader: ElementReader, onDocChangedEvent: Subject<void>) {
|
18
|
-
onDocChangedEvent.pipe(filter(() => this.docCtx.viewOptions.enableUndo), debounceTime(1500)).subscribe(() => {
|
19
|
-
this.task.then(() => {
|
20
|
-
if (!this.docCtx.viewOptions.enableUndo || !this.docCtx.isDirty) {
|
21
|
-
return;
|
22
|
-
}
|
23
|
-
this.generateHistoryItem();
|
24
|
-
});
|
25
|
-
});
|
26
|
-
}
|
27
|
-
private _undoStack: DocumentHistoryItem[] = [];
|
28
|
-
private _index: number = -1;
|
29
|
-
maxLength: number = 50;
|
30
|
-
generateHistoryItem(): void {
|
31
|
-
console.log('生成历史记录');
|
32
|
-
if (this.maxLength === this._undoStack.length) {
|
33
|
-
this._undoStack.shift();
|
34
|
-
}
|
35
|
-
this._undoStack.splice(this._index + 1, this._undoStack.length - this._index - 1);
|
36
|
-
const content = ElementSerialize.serialize(this.docCtx.document, this.docCtx.viewOptions);
|
37
|
-
this._undoStack.push({
|
38
|
-
content,
|
39
|
-
time: new Date()
|
40
|
-
});
|
41
|
-
this._index++;
|
42
|
-
}
|
43
|
-
|
44
|
-
get index() {
|
45
|
-
return this._index;
|
46
|
-
}
|
47
|
-
|
48
|
-
get canUndo() {
|
49
|
-
return this._index > 0;
|
50
|
-
}
|
51
|
-
|
52
|
-
get canRedo() {
|
53
|
-
return this._index < this._undoStack.length - 1;
|
54
|
-
}
|
55
|
-
|
56
|
-
undo() {
|
57
|
-
if (this.canUndo) {
|
58
|
-
this._index--;
|
59
|
-
this.reader.read(this._undoStack[this._index].content);
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
redo() {
|
64
|
-
if (this.canRedo) {
|
65
|
-
this._index++;
|
66
|
-
this.reader.read(this._undoStack[this._index].content);
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
clear() {
|
71
|
-
this._undoStack = [];
|
72
|
-
this._index = -1;
|
73
|
-
this.generateHistoryItem();
|
74
|
-
}
|
75
|
-
|
76
|
-
}
|
@@ -1,74 +0,0 @@
|
|
1
|
-
import { IImageLoader, ImageSourceItem } from "./document-context";
|
2
|
-
import { ImgLoadStatus } from "./element-define";
|
3
|
-
|
4
|
-
export class DocumentImagesLoader implements IImageLoader {
|
5
|
-
images: Array<ImageSourceItem> = [];
|
6
|
-
|
7
|
-
clear(): void {
|
8
|
-
this.images.length = 0;
|
9
|
-
}
|
10
|
-
|
11
|
-
loadImage(src: string, onCallback: (status: ImgLoadStatus) => void): void {
|
12
|
-
if (!src) {
|
13
|
-
return;
|
14
|
-
}
|
15
|
-
//已经存在的资源不需要重新加载
|
16
|
-
let matchItem = this.images.find(item => item.src === src);
|
17
|
-
if (matchItem) {
|
18
|
-
if (matchItem.loadStatus === 'no') {
|
19
|
-
matchItem.cbs.push(onCallback);
|
20
|
-
} else {
|
21
|
-
onCallback(matchItem.loadStatus);
|
22
|
-
}
|
23
|
-
return;
|
24
|
-
}
|
25
|
-
const ele = new Image();
|
26
|
-
ele.src = src;
|
27
|
-
const task = new Promise<void>((r, i) => {
|
28
|
-
ele.onload = (e) => { this.invokeImgLoad(src, 'completed'); r(); };
|
29
|
-
ele.onerror = (e) => { this.invokeImgLoad(src, 'error'); r(); };
|
30
|
-
});
|
31
|
-
const imgItem: ImageSourceItem = {
|
32
|
-
ele,
|
33
|
-
src,
|
34
|
-
cbs: [onCallback],
|
35
|
-
loadStatus: 'no',
|
36
|
-
task
|
37
|
-
};
|
38
|
-
this.images.push(imgItem)
|
39
|
-
// if (this.viewOptions.resourceMode === 'immediate') {
|
40
|
-
// ele.onload = (e) => { this.invokeImgLoad(src, 'completed'); };
|
41
|
-
// ele.onerror = (e) => { this.invokeImgLoad(src, 'error'); };
|
42
|
-
// }
|
43
|
-
}
|
44
|
-
|
45
|
-
invokeImgLoad(src: string, status: ImgLoadStatus): void {
|
46
|
-
const img = this.images.find(item => item.src === src);
|
47
|
-
if (img) {
|
48
|
-
img.loadStatus = status;
|
49
|
-
img.cbs.forEach(cb => cb(status));
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
getLoadTasks(): Array<Promise<void>> {
|
54
|
-
return this.images.map(item => item.task);
|
55
|
-
}
|
56
|
-
|
57
|
-
|
58
|
-
getImage(src: string): HTMLImageElement | undefined {
|
59
|
-
const img = this.images.find(item => item.src === src);
|
60
|
-
return img?.ele;
|
61
|
-
}
|
62
|
-
|
63
|
-
/**
|
64
|
-
* 判断图片是否都已经加载完毕
|
65
|
-
* 用于打印时判断,如果当前图片没有加载完毕就打印,图片是打印不出来
|
66
|
-
* @returns
|
67
|
-
*/
|
68
|
-
imagesLoadCompleted(): boolean {
|
69
|
-
if (this.images.length === 0) {
|
70
|
-
return true;
|
71
|
-
}
|
72
|
-
return this.images.every(item => ['completed', 'error'].includes(item.loadStatus))
|
73
|
-
}
|
74
|
-
}
|
@@ -1,244 +0,0 @@
|
|
1
|
-
import { fromEvent, Subject } from "rxjs";
|
2
|
-
import { LeafElement } from "./element-define";
|
3
|
-
import { KeyboradElementEvent } from "./element-event-define";
|
4
|
-
import { DocumentEvent } from "./document-event";
|
5
|
-
import { EditorContext } from "./document-context";
|
6
|
-
|
7
|
-
export interface ICompositionStartInfo {
|
8
|
-
element: LeafElement, offset: number
|
9
|
-
}
|
10
|
-
export interface InputData {
|
11
|
-
composition?: boolean;
|
12
|
-
//开启输入法后的光标的起点位置
|
13
|
-
compositionStartInfo?: ICompositionStartInfo;
|
14
|
-
//输入法之前输入的内容
|
15
|
-
prevInputData?: string;
|
16
|
-
data: string
|
17
|
-
}
|
18
|
-
|
19
|
-
/**
|
20
|
-
* 输入处理
|
21
|
-
*/
|
22
|
-
export class DocumentInput {
|
23
|
-
/**
|
24
|
-
* 光标是否可见
|
25
|
-
*/
|
26
|
-
private _cursorVisibility = false;
|
27
|
-
/**
|
28
|
-
* 光标闪烁状态
|
29
|
-
*/
|
30
|
-
private _cursorBlinksState = false;
|
31
|
-
private cursorBlinksIntervalID: any;
|
32
|
-
//是否是开启输入法了
|
33
|
-
private compositionStart = false;
|
34
|
-
//开启输入法后输入的文字
|
35
|
-
private compositionPrevData!: string;
|
36
|
-
//开启输入法后的的元素
|
37
|
-
private compositionStartInfo!: ICompositionStartInfo | null;
|
38
|
-
//输入内容事件
|
39
|
-
onInputEvent: Subject<InputData> = new Subject();
|
40
|
-
//backspace 键盘事件
|
41
|
-
onBackspaceEvent: Subject<KeyboardEvent> = new Subject();
|
42
|
-
//delete 键盘事件
|
43
|
-
onDeleteEvent: Subject<KeyboardEvent> = new Subject();
|
44
|
-
//enter 键盘事件
|
45
|
-
onEnterEvent: Subject<void> = new Subject();
|
46
|
-
//左键
|
47
|
-
onLeftEvent: Subject<void> = new Subject();
|
48
|
-
//右键
|
49
|
-
onRightEvent: Subject<void> = new Subject();
|
50
|
-
//复制
|
51
|
-
onCopyEvent: Subject<ClipboardEvent> = new Subject();
|
52
|
-
//剪切
|
53
|
-
onCutEvent: Subject<ClipboardEvent> = new Subject();
|
54
|
-
//粘贴
|
55
|
-
onPasteEvent: Subject<ClipboardEvent> = new Subject();
|
56
|
-
//插入换行符
|
57
|
-
onInsertBr: Subject<void> = new Subject();
|
58
|
-
//ctrl+A 全选事件
|
59
|
-
onSelectAllEvent: Subject<void> = new Subject();
|
60
|
-
//home 事件
|
61
|
-
onHomeEvent: Subject<void> = new Subject();
|
62
|
-
//end 事件
|
63
|
-
onEndEvent: Subject<void> = new Subject();
|
64
|
-
onUpEvent: Subject<void> = new Subject();
|
65
|
-
onDownEvent: Subject<void> = new Subject();
|
66
|
-
constructor(private editInput: HTMLInputElement, private editCursor: HTMLSpanElement, private cursorWrapper: HTMLDivElement, private docCtx: EditorContext) {
|
67
|
-
this.startCursorBlinks();
|
68
|
-
fromEvent(this.editInput, 'blur').subscribe(() => {
|
69
|
-
this._cursorVisibility = false;
|
70
|
-
//console.log('输入框 blur');
|
71
|
-
})
|
72
|
-
fromEvent(this.editInput, 'focus').subscribe(() => {
|
73
|
-
//console.log('输入框 focus');
|
74
|
-
})
|
75
|
-
fromEvent(this.editInput, 'input').subscribe(() => {
|
76
|
-
if (this.compositionStart) {
|
77
|
-
return;
|
78
|
-
}
|
79
|
-
if (!this.editInput.value) {
|
80
|
-
return;
|
81
|
-
}
|
82
|
-
//console.log('输入文字了');
|
83
|
-
if (!this.compositionStart) {
|
84
|
-
const { startControl, startOffset } = this.docCtx.selectionState;
|
85
|
-
this.onInputEvent.next({
|
86
|
-
data: this.editInput.value, prevInputData: '', compositionStartInfo: {
|
87
|
-
element: startControl as LeafElement,
|
88
|
-
offset: startOffset
|
89
|
-
}
|
90
|
-
});
|
91
|
-
this.editInput.value = '';
|
92
|
-
}
|
93
|
-
})
|
94
|
-
fromEvent<CompositionEvent>(this.editInput, 'compositionstart').subscribe((evt) => {
|
95
|
-
this.compositionStart = true;
|
96
|
-
this.compositionPrevData = '';
|
97
|
-
const { startControl, startOffset } = this.docCtx.selectionState;
|
98
|
-
//console.log('输入法开始');
|
99
|
-
this.compositionStartInfo = {
|
100
|
-
element: startControl as LeafElement,
|
101
|
-
offset: startOffset
|
102
|
-
};
|
103
|
-
});
|
104
|
-
fromEvent<CompositionEvent>(this.editInput, 'compositionupdate').subscribe((evt) => {
|
105
|
-
if (evt.data === this.compositionPrevData) {
|
106
|
-
return;
|
107
|
-
}
|
108
|
-
//console.log('输入了:' + evt.data);
|
109
|
-
this.onInputEvent.next({
|
110
|
-
data: evt.data,
|
111
|
-
compositionStartInfo: this.compositionStartInfo as ICompositionStartInfo,
|
112
|
-
composition: true,
|
113
|
-
prevInputData: this.compositionPrevData
|
114
|
-
});
|
115
|
-
this.compositionPrevData = evt.data;
|
116
|
-
});
|
117
|
-
fromEvent<CompositionEvent>(this.editInput, 'compositionend').subscribe((evt) => {
|
118
|
-
//console.log('compositionend')
|
119
|
-
this.compositionStart = false;
|
120
|
-
this.editInput.value = "";
|
121
|
-
this.compositionPrevData = '';
|
122
|
-
// this.onInputEvent.next({
|
123
|
-
// data: evt.data,
|
124
|
-
// compositionStartOffset: this.compositionStartOffset,
|
125
|
-
// compositionRecordContent: this.compositionRecordContent
|
126
|
-
// });
|
127
|
-
// this.onInputEvent.next({
|
128
|
-
// data: evt.data,
|
129
|
-
// compositionStartInfo: this.compositionStartInfo,
|
130
|
-
// composition: true,
|
131
|
-
// prevInputData: ''
|
132
|
-
// });
|
133
|
-
this.compositionStartInfo = null;
|
134
|
-
//this.compositionRecordContent = '';
|
135
|
-
});
|
136
|
-
fromEvent<KeyboardEvent>(this.editInput, 'keydown').subscribe((evt) => {
|
137
|
-
const keyEvent = new KeyboradElementEvent(this.docCtx);
|
138
|
-
keyEvent.sourceEvent = evt;
|
139
|
-
if (DocumentEvent.invokeEvent('ElementKeyDown', this.docCtx.selectionState.startControl as LeafElement, keyEvent, 'Capture', this.docCtx)) {
|
140
|
-
return;
|
141
|
-
}
|
142
|
-
if (evt.keyCode === 8) {
|
143
|
-
this.onBackspaceEvent.next(evt);
|
144
|
-
} else if (evt.keyCode === 13 && !evt.shiftKey) {
|
145
|
-
this.onEnterEvent.next();
|
146
|
-
} else if (evt.keyCode === 37) {
|
147
|
-
this.onLeftEvent.next();
|
148
|
-
} else if (evt.keyCode === 39) {
|
149
|
-
this.onRightEvent.next();
|
150
|
-
} else if (evt.keyCode === 38) {
|
151
|
-
this.onUpEvent.next();
|
152
|
-
} else if (evt.keyCode === 40) {
|
153
|
-
this.onDownEvent.next();
|
154
|
-
}
|
155
|
-
else if (evt.keyCode === 9) {
|
156
|
-
evt.preventDefault();
|
157
|
-
} else if (evt.keyCode === 13 && evt.shiftKey) {
|
158
|
-
evt.preventDefault();
|
159
|
-
this.onInsertBr.next();
|
160
|
-
} else if (evt.keyCode === 46) {
|
161
|
-
this.onDeleteEvent.next(evt);
|
162
|
-
} else if (evt.ctrlKey && evt.keyCode === 65) {
|
163
|
-
evt.preventDefault();
|
164
|
-
this.onSelectAllEvent.next();
|
165
|
-
} else if (evt.keyCode === 36) {
|
166
|
-
this.onHomeEvent.next();
|
167
|
-
}
|
168
|
-
else if (evt.keyCode === 35) {
|
169
|
-
this.onEndEvent.next();
|
170
|
-
}
|
171
|
-
});
|
172
|
-
fromEvent<ClipboardEvent>(this.editInput, "copy").subscribe(evt => {
|
173
|
-
this.onCopyEvent.next(evt);
|
174
|
-
});
|
175
|
-
fromEvent<ClipboardEvent>(this.editInput, "paste").subscribe(evt => {
|
176
|
-
this.onPasteEvent.next(evt);
|
177
|
-
});
|
178
|
-
fromEvent<ClipboardEvent>(this.editInput, "cut").subscribe(evt => {
|
179
|
-
this.onCutEvent.next(evt);
|
180
|
-
});
|
181
|
-
}
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
/**
|
186
|
-
* 设置光标闪烁
|
187
|
-
*/
|
188
|
-
startCursorBlinks() {
|
189
|
-
// this.cursorBlinksIntervalID = setInterval(() => {
|
190
|
-
// //this.setCursorBlinks();
|
191
|
-
// }, 500);
|
192
|
-
}
|
193
|
-
|
194
|
-
destroy(): void {
|
195
|
-
clearInterval(this.cursorBlinksIntervalID);
|
196
|
-
}
|
197
|
-
|
198
|
-
/**
|
199
|
-
* 设置光标闪烁
|
200
|
-
*/
|
201
|
-
setCursorBlinks() {
|
202
|
-
this.editCursor.style.background = this._cursorBlinksState ? 'transparent' : 'black';
|
203
|
-
this._cursorBlinksState = !this._cursorBlinksState;
|
204
|
-
}
|
205
|
-
|
206
|
-
/**
|
207
|
-
* 设置光标位置
|
208
|
-
* @param position
|
209
|
-
*/
|
210
|
-
setCursorPosition(position: { x: number; y: number; height: number; }) {
|
211
|
-
this.cursorWrapper.style.left = position.x + 'px';
|
212
|
-
this.cursorWrapper.style.top = position.y + 'px';
|
213
|
-
this.cursorWrapper.style.height = position.height + 'px';
|
214
|
-
this.setCursorVisibility(true);
|
215
|
-
//this.setCursorInputStatus();
|
216
|
-
}
|
217
|
-
|
218
|
-
/**
|
219
|
-
* 设置虚拟光标的可见性
|
220
|
-
* @param visibility
|
221
|
-
*/
|
222
|
-
setCursorVisibility(visibility: boolean) {
|
223
|
-
this.cursorWrapper.style.display = visibility ? 'block' : 'none';
|
224
|
-
if (visibility) {
|
225
|
-
this.setInputFocus(true);
|
226
|
-
}
|
227
|
-
}
|
228
|
-
|
229
|
-
/**
|
230
|
-
* 设置输入状态
|
231
|
-
* @param focus
|
232
|
-
*/
|
233
|
-
setInputFocus(focus: boolean): void {
|
234
|
-
if (focus) {
|
235
|
-
this.editInput.readOnly = false;
|
236
|
-
this.editInput.focus();
|
237
|
-
|
238
|
-
} else {
|
239
|
-
//this.editInput.blur();
|
240
|
-
this.editInput.readOnly = true;
|
241
|
-
this.docCtx.selectionState.cursorPos = null;
|
242
|
-
}
|
243
|
-
}
|
244
|
-
}
|
@@ -1,110 +0,0 @@
|
|
1
|
-
import { ElementMeasure } from "./element-measure";
|
2
|
-
import { ElementPaint } from "./element-paint";
|
3
|
-
import { ElementRenderCut } from "./element-render-cut";
|
4
|
-
import { DocumentRenderObject } from "./impl/document/doc-impl";
|
5
|
-
import { RenderContenxtType } from "./render-context";
|
6
|
-
import { Element, SelectionContentRange, ViewOptions } from "./element-define";
|
7
|
-
import { DocumentContainerRender } from "./impl/document/doc-container-impl";
|
8
|
-
import { ElementUtil } from "./element-util";
|
9
|
-
import { DocumentSelection } from "./document-selection";
|
10
|
-
import { CommsContainerRenderObject } from "./impl/comments/comments-container-impl";
|
11
|
-
import { RangeUtil } from "./range-util";
|
12
|
-
import { SelectionOverlays } from "./selection-overlays";
|
13
|
-
import { EditorContext } from "./document-context";
|
14
|
-
import { CommContentElement, CommentRangeStatus } from "./impl/comments/comment-content-impl";
|
15
|
-
|
16
|
-
export class DocumentPaint {
|
17
|
-
elementMeasure: ElementMeasure;
|
18
|
-
elementRenderCut: ElementRenderCut;
|
19
|
-
elementPaint: ElementPaint;
|
20
|
-
docPages!: Array<DocumentRenderObject>;
|
21
|
-
docContainer!: DocumentContainerRender;
|
22
|
-
commsContainer!: CommsContainerRenderObject;
|
23
|
-
constructor(private viewOptions: ViewOptions, private renderContext: RenderContenxtType, private docCtx: EditorContext, private selectedSets: Map<Element, SelectionContentRange>) {
|
24
|
-
this.elementMeasure = new ElementMeasure(this.viewOptions, this.renderContext);
|
25
|
-
this.elementRenderCut = new ElementRenderCut(this.viewOptions, this.renderContext);
|
26
|
-
this.elementPaint = new ElementPaint(this.viewOptions, this.renderContext);
|
27
|
-
}
|
28
|
-
|
29
|
-
rePages(): void {
|
30
|
-
// const destroyItems = [this.docContainer, this.commsContainer];
|
31
|
-
// destroyItems.forEach(item => item?.destroy())
|
32
|
-
//Promise.resolve().then(() => { destroyItems.forEach(item => item?.destroy()) });
|
33
|
-
if (!this.docCtx.document.length) {
|
34
|
-
return;
|
35
|
-
}
|
36
|
-
this.docContainer = new DocumentContainerRender();
|
37
|
-
this.docCtx.selectionState.renderContainer = this.docContainer;
|
38
|
-
this.docContainer.rect.width = this.viewOptions.docPageSettings.width;
|
39
|
-
// console.time('排版计时');
|
40
|
-
const documentRender = this.elementMeasure.measureDocument(this.docCtx.document);
|
41
|
-
this.commsContainer = documentRender.getChild(3) as CommsContainerRenderObject;
|
42
|
-
if (this.commsContainer) {
|
43
|
-
this.commsContainer = this.commsContainer.clone() as CommsContainerRenderObject;
|
44
|
-
}
|
45
|
-
//console.timeEnd('排版计时');
|
46
|
-
//console.time('断页计时');
|
47
|
-
const docPages = this.elementRenderCut.cutPage(documentRender, this.docCtx.document);
|
48
|
-
//console.timeEnd('断页计时');
|
49
|
-
this.docContainer.addPages(docPages);
|
50
|
-
ElementUtil.remeasure(this.docContainer);
|
51
|
-
this.setCommRangeMark();
|
52
|
-
this.docPages = docPages;
|
53
|
-
|
54
|
-
|
55
|
-
}
|
56
|
-
|
57
|
-
/**
|
58
|
-
* 获取设置文档容器的总高度
|
59
|
-
*/
|
60
|
-
getDocumentContainerHeight(): number {
|
61
|
-
if (this.docPages.length > 0) {
|
62
|
-
const lastPage = this.docPages[this.docPages.length - 1];
|
63
|
-
const lastPageY = lastPage.rect.y + lastPage.rect.height + this.viewOptions.docSpace;
|
64
|
-
return lastPageY + (this.viewOptions.viewSettings.height * (this.viewOptions.scale - 1));
|
65
|
-
}
|
66
|
-
else {
|
67
|
-
return 0;
|
68
|
-
}
|
69
|
-
}
|
70
|
-
|
71
|
-
refreshView(rePaint = false): void {
|
72
|
-
//console.time('计时');
|
73
|
-
this.elementPaint.drawPages(this.docContainer, this.selectedSets, this.commsContainer, rePaint);
|
74
|
-
//console.timeEnd('计时');
|
75
|
-
|
76
|
-
}
|
77
|
-
|
78
|
-
getDocPages(): Array<DocumentRenderObject> {
|
79
|
-
return this.docPages;
|
80
|
-
}
|
81
|
-
|
82
|
-
getDocContainer(): DocumentContainerRender {
|
83
|
-
return this.docContainer;
|
84
|
-
}
|
85
|
-
|
86
|
-
/***
|
87
|
-
* 设置审阅区间样式痕迹
|
88
|
-
*/
|
89
|
-
setCommRangeMark(): void {
|
90
|
-
if (!this.viewOptions.showReviewWindow) {
|
91
|
-
return;
|
92
|
-
}
|
93
|
-
const cce = this.docCtx.document.commentsContainerElement;
|
94
|
-
const set = new Map<Element, SelectionContentRange>();
|
95
|
-
const commentRangeStatus: Array<CommentRangeStatus> = [];
|
96
|
-
for (let i = 0; i < cce.length; i++) {
|
97
|
-
const commContent = cce.getChild(i) as CommContentElement;
|
98
|
-
const { startMark, endMark, props: { id }, focus } = commContent;
|
99
|
-
const ancestorCommonControl = DocumentSelection.getAncestorCommonControl(startMark, endMark);
|
100
|
-
const commonRange = RangeUtil.getSelctionRange(startMark, 0, endMark, 1, ancestorCommonControl);
|
101
|
-
SelectionOverlays.addToCommentSets(commonRange, set);
|
102
|
-
commentRangeStatus.push({
|
103
|
-
commContent,
|
104
|
-
range: commonRange
|
105
|
-
})
|
106
|
-
}
|
107
|
-
this.commsContainer.selectedSet = set;
|
108
|
-
this.commsContainer.commentRangeStatus = commentRangeStatus;
|
109
|
-
}
|
110
|
-
}
|
@@ -1,134 +0,0 @@
|
|
1
|
-
import { EditorContext } from "./document-context";
|
2
|
-
import { DocumentPaint } from "./document-paint";
|
3
|
-
import { exportCanvasToPDF, printNodes } from "./document-print";
|
4
|
-
import { SelectionState } from "./document-selection";
|
5
|
-
import { ViewOptions } from "./element-define";
|
6
|
-
import { ElementPaint } from "./element-paint";
|
7
|
-
import { ElementReader } from "./element-reader";
|
8
|
-
import { ElementUtil } from "./element-util";
|
9
|
-
import { DocumentElement, DocumentRenderObject } from "./impl/document/doc-impl";
|
10
|
-
import { RenderContenxt, RenderContenxtType } from "./render-context";
|
11
|
-
|
12
|
-
/**
|
13
|
-
* 离屏打印
|
14
|
-
*/
|
15
|
-
export class DocumentPrintOffscreen {
|
16
|
-
documentPaint: DocumentPaint;
|
17
|
-
viewOptions: ViewOptions;
|
18
|
-
docCtx: EditorContext;
|
19
|
-
renderCtx: RenderContenxt;
|
20
|
-
elementReader: ElementReader;
|
21
|
-
ctx: CanvasRenderingContext2D;
|
22
|
-
constructor() {
|
23
|
-
this.viewOptions = new ViewOptions();
|
24
|
-
this.viewOptions.copyRightInfo = '万达信息电子病历编辑器,www.wondersgroup.com';
|
25
|
-
this.viewOptions.showCharRect = true;
|
26
|
-
this.viewOptions.drawCharRectColor = 'green';
|
27
|
-
this.viewOptions.showLineRect = true;
|
28
|
-
this.viewOptions.docSpace = 20;
|
29
|
-
this.viewOptions.reviewWindowWidth = 200;
|
30
|
-
this.viewOptions.mmToPixelsRatio = 3.7795001220703126;
|
31
|
-
//整个画布的尺寸
|
32
|
-
this.viewOptions.viewSettings = {
|
33
|
-
width: 1000,
|
34
|
-
height: 800
|
35
|
-
};
|
36
|
-
this.viewOptions.editUser = {
|
37
|
-
id: '6666',
|
38
|
-
name: '管理员'
|
39
|
-
};
|
40
|
-
const canvas = document.createElement('canvas');
|
41
|
-
this.ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
|
42
|
-
const ss = new SelectionState();
|
43
|
-
this.docCtx = new EditorContext(ss, this.viewOptions);
|
44
|
-
this.renderCtx = new RenderContenxt(this.ctx, this.viewOptions, this.docCtx);
|
45
|
-
this.documentPaint = new DocumentPaint(this.viewOptions, this.renderCtx, this.docCtx, new Map());
|
46
|
-
this.elementReader = new ElementReader(this.docCtx, this.viewOptions, this.renderCtx);
|
47
|
-
this.docCtx.syncRefresh = () => {
|
48
|
-
};
|
49
|
-
}
|
50
|
-
async print(data: any | DocumentElement, ranges: Array<number> | null = null): Promise<void> {
|
51
|
-
await this.prepare(data);
|
52
|
-
const canvasNodes = this.getCanvasNodes(this.documentPaint.docPages, ranges);
|
53
|
-
if (!canvasNodes.length) {
|
54
|
-
console.warn('无可打印页')
|
55
|
-
return;
|
56
|
-
}
|
57
|
-
const docProps = this.docCtx.document.props;
|
58
|
-
printNodes(canvasNodes, { ...docProps });
|
59
|
-
}
|
60
|
-
|
61
|
-
/**
|
62
|
-
* 导出PDF
|
63
|
-
* @param fileName
|
64
|
-
* @param ss
|
65
|
-
* @param viewOptions
|
66
|
-
* @param docCtx
|
67
|
-
* @param ranges
|
68
|
-
*/
|
69
|
-
async exportToPDF(data: any | DocumentElement, fileName: string, ranges: Array<number> | null = null): Promise<void> {
|
70
|
-
await this.prepare(data);
|
71
|
-
const canvasNodes = this.getCanvasNodes(this.documentPaint.docPages, ranges);
|
72
|
-
if (!canvasNodes.length) {
|
73
|
-
console.warn('无可导出页')
|
74
|
-
return;
|
75
|
-
}
|
76
|
-
exportCanvasToPDF(fileName, canvasNodes, this.docCtx.document.props);
|
77
|
-
}
|
78
|
-
|
79
|
-
|
80
|
-
/**
|
81
|
-
* 获取绘制的图片,格式为Base64编码
|
82
|
-
*/
|
83
|
-
async getImagesContent(data: any | DocumentElement, ranges: Array<number> | null = null): Promise<Array<string>> {
|
84
|
-
await this.prepare(data);
|
85
|
-
const canvasNodes = this.getCanvasNodes(this.documentPaint.docPages, ranges);
|
86
|
-
if (!canvasNodes.length) {
|
87
|
-
console.warn('无可导出页')
|
88
|
-
return [];
|
89
|
-
}
|
90
|
-
return canvasNodes.map(node => node.toDataURL());
|
91
|
-
}
|
92
|
-
|
93
|
-
/**
|
94
|
-
* 读取数据,排版
|
95
|
-
* @param data
|
96
|
-
*/
|
97
|
-
private async prepare(data: any | DocumentElement,): Promise<void> {
|
98
|
-
this.elementReader.read(data);
|
99
|
-
this.documentPaint.rePages();
|
100
|
-
await Promise.all(this.docCtx.imageLoader.getLoadTasks());
|
101
|
-
this.renderCtx.setCanvasProps(this.viewOptions.docPageSettings);
|
102
|
-
}
|
103
|
-
|
104
|
-
private getCanvasNodes(printPages: Array<DocumentRenderObject>, printRanges: Array<number> | null = null): Array<HTMLCanvasElement> {
|
105
|
-
const { width, height } = this.viewOptions.docPageSettings;
|
106
|
-
const canvasList: Array<HTMLCanvasElement> = [];
|
107
|
-
for (let i = 0; i < printPages.length; i++) {
|
108
|
-
if (printRanges && printRanges.indexOf(i) === -1) {
|
109
|
-
continue;
|
110
|
-
}
|
111
|
-
const canvasNode = document.createElement('canvas');
|
112
|
-
canvasNode.style.cursor = 'text';
|
113
|
-
canvasNode.style.width = width + 'px';
|
114
|
-
canvasNode.style.height = height + 'px';
|
115
|
-
const ctx = canvasNode.getContext('2d') as CanvasRenderingContext2D;
|
116
|
-
ElementUtil.setCanvasProps(canvasNode, ctx, this.viewOptions.docPageSettings);
|
117
|
-
const renderCtx = new RenderContenxt(ctx, this.viewOptions, this.docCtx);
|
118
|
-
renderCtx.setCanvasProps(this.viewOptions.docPageSettings);
|
119
|
-
renderCtx.drawMode = 'print';
|
120
|
-
const doc = printPages[i];
|
121
|
-
const tmp = ElementUtil.cloneRect(doc.rect);
|
122
|
-
doc.rect.x = 0;
|
123
|
-
doc.rect.y = 0;
|
124
|
-
ElementPaint.drawPage(renderCtx, doc, { x: 0, y: 0 });
|
125
|
-
renderCtx.overlaysContext.clear();
|
126
|
-
renderCtx.mainCtx.fillStyle = 'white';
|
127
|
-
renderCtx.mainCtx.fillRect(0, 0, width, height);
|
128
|
-
renderCtx.commit(this.viewOptions.docPageSettings);
|
129
|
-
doc.rect = tmp;
|
130
|
-
canvasList.push(canvasNode);
|
131
|
-
}
|
132
|
-
return canvasList;
|
133
|
-
}
|
134
|
-
}
|