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