@itwin/core-markup 4.0.0-dev.52 → 4.0.0-dev.55

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.
Files changed (44) hide show
  1. package/lib/cjs/Markup.d.ts +310 -310
  2. package/lib/cjs/Markup.js +419 -419
  3. package/lib/cjs/Markup.js.map +1 -1
  4. package/lib/cjs/MarkupTool.d.ts +38 -38
  5. package/lib/cjs/MarkupTool.js +88 -88
  6. package/lib/cjs/MarkupTool.js.map +1 -1
  7. package/lib/cjs/RedlineTool.d.ts +145 -145
  8. package/lib/cjs/RedlineTool.js +512 -512
  9. package/lib/cjs/RedlineTool.js.map +1 -1
  10. package/lib/cjs/SelectTool.d.ts +126 -126
  11. package/lib/cjs/SelectTool.js +741 -741
  12. package/lib/cjs/SelectTool.js.map +1 -1
  13. package/lib/cjs/SvgJsExt.d.ts +85 -85
  14. package/lib/cjs/SvgJsExt.js +185 -185
  15. package/lib/cjs/TextEdit.d.ts +43 -43
  16. package/lib/cjs/TextEdit.js +196 -196
  17. package/lib/cjs/TextEdit.js.map +1 -1
  18. package/lib/cjs/Undo.d.ts +46 -46
  19. package/lib/cjs/Undo.js +168 -168
  20. package/lib/cjs/core-markup.d.ts +18 -18
  21. package/lib/cjs/core-markup.js +38 -34
  22. package/lib/cjs/core-markup.js.map +1 -1
  23. package/lib/esm/Markup.d.ts +310 -310
  24. package/lib/esm/Markup.js +415 -414
  25. package/lib/esm/Markup.js.map +1 -1
  26. package/lib/esm/MarkupTool.d.ts +38 -38
  27. package/lib/esm/MarkupTool.js +85 -84
  28. package/lib/esm/MarkupTool.js.map +1 -1
  29. package/lib/esm/RedlineTool.d.ts +145 -145
  30. package/lib/esm/RedlineTool.js +508 -498
  31. package/lib/esm/RedlineTool.js.map +1 -1
  32. package/lib/esm/SelectTool.d.ts +126 -126
  33. package/lib/esm/SelectTool.js +735 -734
  34. package/lib/esm/SelectTool.js.map +1 -1
  35. package/lib/esm/SvgJsExt.d.ts +85 -85
  36. package/lib/esm/SvgJsExt.js +180 -180
  37. package/lib/esm/TextEdit.d.ts +43 -43
  38. package/lib/esm/TextEdit.js +193 -191
  39. package/lib/esm/TextEdit.js.map +1 -1
  40. package/lib/esm/Undo.d.ts +46 -46
  41. package/lib/esm/Undo.js +164 -164
  42. package/lib/esm/core-markup.d.ts +18 -18
  43. package/lib/esm/core-markup.js +22 -22
  44. package/package.json +13 -13
@@ -1,181 +1,181 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- /** @packageDocumentation
6
- * @module MarkupApp
7
- */
8
- import { Transform } from "@itwin/core-geometry";
9
- import { Box, extend, G, Element as MarkupElement, Matrix, nodeOrNew, Rect, register, Text } from "@svgdotjs/svg.js";
10
- import { MarkupApp } from "./Markup";
11
- const OLDCOLOR = "Color";
12
- /** this is the SVG.js way of adding methods to classes */
13
- extend(MarkupElement, {
14
- forElementsOfGroup(fn) {
15
- const me = this;
16
- if (me instanceof G)
17
- me.each((i, children) => { const child = children[i]; if (child instanceof MarkupElement)
18
- fn(child); }, false);
19
- },
20
- cloneMarkup() {
21
- const me = this;
22
- const cloned = me.clone();
23
- cloned.node.removeAttribute("id");
24
- cloned.resetColor();
25
- return cloned;
26
- },
27
- overrideColor(color) {
28
- const me = this;
29
- me.forElementsOfGroup((child) => child.overrideColor(color)); // Do children first, getComputedStyle will inherit from group for unspecified values...
30
- let oldColor = me.data(OLDCOLOR);
31
- if (undefined === oldColor) {
32
- const css = window.getComputedStyle(me.node);
33
- const colorOrNone = (c) => (c && c !== "none") ? c : "none";
34
- oldColor = { fill: colorOrNone(css.fill), stroke: colorOrNone(css.stroke) };
35
- me.data(OLDCOLOR, oldColor);
36
- }
37
- const toColor = (val) => (!val || val === "none") ? "none" : color;
38
- me.css({ fill: toColor(oldColor.fill), stroke: toColor(oldColor.stroke) });
39
- },
40
- resetColor() {
41
- const me = this;
42
- const oldColor = me.data(OLDCOLOR);
43
- if (undefined !== oldColor)
44
- me.css(oldColor).data(OLDCOLOR, null); // change to old color and remove data object
45
- me.forElementsOfGroup((child) => child.resetColor());
46
- },
47
- hilite() { const me = this; if (!me.inSelection) {
48
- me.overrideColor(MarkupApp.props.hilite.color);
49
- me.inSelection = true;
50
- } },
51
- unHilite() { const me = this; if (me.inSelection) {
52
- me.resetColor();
53
- me.inSelection = undefined;
54
- } },
55
- flash() { const me = this; if (!me.inSelection)
56
- me.overrideColor(MarkupApp.props.hilite.flash); },
57
- unFlash() { const me = this; if (!me.inSelection)
58
- me.resetColor(); },
59
- markupStretch(w, h, x, y, _mtx) { const me = this; me.size(w, h).move(x, y); },
60
- isChildOf(svg) {
61
- const parent = this.parent();
62
- return (parent === svg) ? true : (parent instanceof MarkupElement) ? parent.isChildOf(svg) : false;
63
- },
64
- getChildOrGroupOf(svg) {
65
- const me = this;
66
- const parents = me.parents(svg.parent());
67
- if (0 === parents.length || parents[parents.length - 1].node !== svg.node)
68
- return undefined;
69
- if (parents.length > 1) {
70
- for (let index = parents.length - 2; index >= 0; --index)
71
- if (parents[index] instanceof G || parents[index] instanceof Text)
72
- return parents[index];
73
- }
74
- return me;
75
- },
76
- getNpcToVp() {
77
- const me = this;
78
- const bb = me.bbox();
79
- return new Matrix().scaleO(bb.w, bb.h).translateO(bb.x, bb.y).lmultiplyO(me.matrixify());
80
- },
81
- getOutline(expand) {
82
- const me = this;
83
- const box = me.bbox();
84
- if (expand === undefined)
85
- expand = 0;
86
- return new Rect().move(box.x - expand, box.y - expand).size(box.w + (expand * 2), box.h + (expand * 2)).transform(me.matrixify());
87
- },
88
- });
89
- extend(G, {
90
- markupStretch(_w, _h, _x, _y, mtx) { this.attr("transform", mtx); },
91
- });
92
- extend(Text, {
93
- getFontSize() { const me = this; return parseFloat(window.getComputedStyle(me.node).fontSize); },
94
- markupStretch(_w, _h, _x, _y, mtx) { this.attr("transform", mtx); },
95
- getMarkup() {
96
- const node = this.node;
97
- let text = "";
98
- node.childNodes.forEach((child) => {
99
- if (child.nodeName === "tspan" || child.nodeName === "#text") {
100
- if (text.length !== 0)
101
- text += "\n";
102
- text += child.textContent;
103
- }
104
- });
105
- return text;
106
- },
107
- createMarkup(val, spacing) {
108
- spacing = spacing ? spacing : 1;
109
- const me = this;
110
- me.clear();
111
- if (val === "")
112
- return;
113
- const lines = val.split("\n");
114
- me.plain(lines[0]);
115
- const x = me.attr("x");
116
- me.build(true);
117
- for (let i = 1; i < lines.length; ++i) {
118
- const tspan = me.tspan(lines[i]);
119
- tspan.dy(spacing);
120
- tspan.x(x);
121
- }
122
- me.build(false);
123
- me.dom = {};
124
- },
125
- // override for Text so that empty text will return a size
126
- getOutline(expand) {
127
- const me = this;
128
- const node = me.node;
129
- const content = node.textContent;
130
- if (content !== null && content.length > 0)
131
- return MarkupElement.prototype.getOutline.call(me, expand);
132
- node.textContent = "M";
133
- const outline = MarkupElement.prototype.getOutline.call(me, expand);
134
- node.textContent = content;
135
- return outline;
136
- },
137
- writeDataToDom() {
138
- const me = this;
139
- const dom = me.dom; // strip off useless "leading" data
140
- me.dom = {};
141
- MarkupElement.prototype.writeDataToDom.call(me);
142
- me.dom = dom;
143
- return me;
144
- },
145
- });
146
- extend(Matrix, {
147
- toIModelTransform() {
148
- const m = this;
149
- return Transform.createRowValues(m.a, m.c, 0, m.e, m.b, m.d, 0, m.f, 0, 0, 1, 0);
150
- },
151
- fromIModelTransform(t) {
152
- const m = this;
153
- const o = t.origin;
154
- const mtx = t.matrix;
155
- m.a = mtx.coffs[0];
156
- m.b = mtx.coffs[3];
157
- m.c = mtx.coffs[1];
158
- m.d = mtx.coffs[4];
159
- m.e = o.x;
160
- m.f = o.y;
161
- return this;
162
- },
163
- });
164
- /** Dummy class so a <title> inside a <g> will work.
165
- * @internal
166
- */
167
- export class Title extends MarkupElement {
168
- constructor(node) { super(nodeOrNew("title", node)); }
169
- scale() { return this; }
170
- size() { return this; }
171
- move() { return this; }
172
- dmove() { return this; }
173
- bbox() { return new Box(); }
174
- screenCTM() { return new Matrix(); }
175
- }
176
- register(Title, "Title");
177
- /** only for tests
178
- * @internal
179
- */
180
- export function initSvgExt() { }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module MarkupApp
7
+ */
8
+ import { Transform } from "@itwin/core-geometry";
9
+ import { Box, extend, G, Element as MarkupElement, Matrix, nodeOrNew, Rect, register, Text } from "@svgdotjs/svg.js";
10
+ import { MarkupApp } from "./Markup";
11
+ const OLDCOLOR = "Color";
12
+ /** this is the SVG.js way of adding methods to classes */
13
+ extend(MarkupElement, {
14
+ forElementsOfGroup(fn) {
15
+ const me = this;
16
+ if (me instanceof G)
17
+ me.each((i, children) => { const child = children[i]; if (child instanceof MarkupElement)
18
+ fn(child); }, false);
19
+ },
20
+ cloneMarkup() {
21
+ const me = this;
22
+ const cloned = me.clone();
23
+ cloned.node.removeAttribute("id");
24
+ cloned.resetColor();
25
+ return cloned;
26
+ },
27
+ overrideColor(color) {
28
+ const me = this;
29
+ me.forElementsOfGroup((child) => child.overrideColor(color)); // Do children first, getComputedStyle will inherit from group for unspecified values...
30
+ let oldColor = me.data(OLDCOLOR);
31
+ if (undefined === oldColor) {
32
+ const css = window.getComputedStyle(me.node);
33
+ const colorOrNone = (c) => (c && c !== "none") ? c : "none";
34
+ oldColor = { fill: colorOrNone(css.fill), stroke: colorOrNone(css.stroke) };
35
+ me.data(OLDCOLOR, oldColor);
36
+ }
37
+ const toColor = (val) => (!val || val === "none") ? "none" : color;
38
+ me.css({ fill: toColor(oldColor.fill), stroke: toColor(oldColor.stroke) });
39
+ },
40
+ resetColor() {
41
+ const me = this;
42
+ const oldColor = me.data(OLDCOLOR);
43
+ if (undefined !== oldColor)
44
+ me.css(oldColor).data(OLDCOLOR, null); // change to old color and remove data object
45
+ me.forElementsOfGroup((child) => child.resetColor());
46
+ },
47
+ hilite() { const me = this; if (!me.inSelection) {
48
+ me.overrideColor(MarkupApp.props.hilite.color);
49
+ me.inSelection = true;
50
+ } },
51
+ unHilite() { const me = this; if (me.inSelection) {
52
+ me.resetColor();
53
+ me.inSelection = undefined;
54
+ } },
55
+ flash() { const me = this; if (!me.inSelection)
56
+ me.overrideColor(MarkupApp.props.hilite.flash); },
57
+ unFlash() { const me = this; if (!me.inSelection)
58
+ me.resetColor(); },
59
+ markupStretch(w, h, x, y, _mtx) { const me = this; me.size(w, h).move(x, y); },
60
+ isChildOf(svg) {
61
+ const parent = this.parent();
62
+ return (parent === svg) ? true : (parent instanceof MarkupElement) ? parent.isChildOf(svg) : false;
63
+ },
64
+ getChildOrGroupOf(svg) {
65
+ const me = this;
66
+ const parents = me.parents(svg.parent());
67
+ if (0 === parents.length || parents[parents.length - 1].node !== svg.node)
68
+ return undefined;
69
+ if (parents.length > 1) {
70
+ for (let index = parents.length - 2; index >= 0; --index)
71
+ if (parents[index] instanceof G || parents[index] instanceof Text)
72
+ return parents[index];
73
+ }
74
+ return me;
75
+ },
76
+ getNpcToVp() {
77
+ const me = this;
78
+ const bb = me.bbox();
79
+ return new Matrix().scaleO(bb.w, bb.h).translateO(bb.x, bb.y).lmultiplyO(me.matrixify());
80
+ },
81
+ getOutline(expand) {
82
+ const me = this;
83
+ const box = me.bbox();
84
+ if (expand === undefined)
85
+ expand = 0;
86
+ return new Rect().move(box.x - expand, box.y - expand).size(box.w + (expand * 2), box.h + (expand * 2)).transform(me.matrixify());
87
+ },
88
+ });
89
+ extend(G, {
90
+ markupStretch(_w, _h, _x, _y, mtx) { this.attr("transform", mtx); },
91
+ });
92
+ extend(Text, {
93
+ getFontSize() { const me = this; return parseFloat(window.getComputedStyle(me.node).fontSize); },
94
+ markupStretch(_w, _h, _x, _y, mtx) { this.attr("transform", mtx); },
95
+ getMarkup() {
96
+ const node = this.node;
97
+ let text = "";
98
+ node.childNodes.forEach((child) => {
99
+ if (child.nodeName === "tspan" || child.nodeName === "#text") {
100
+ if (text.length !== 0)
101
+ text += "\n";
102
+ text += child.textContent;
103
+ }
104
+ });
105
+ return text;
106
+ },
107
+ createMarkup(val, spacing) {
108
+ spacing = spacing ? spacing : 1;
109
+ const me = this;
110
+ me.clear();
111
+ if (val === "")
112
+ return;
113
+ const lines = val.split("\n");
114
+ me.plain(lines[0]);
115
+ const x = me.attr("x");
116
+ me.build(true);
117
+ for (let i = 1; i < lines.length; ++i) {
118
+ const tspan = me.tspan(lines[i]);
119
+ tspan.dy(spacing);
120
+ tspan.x(x);
121
+ }
122
+ me.build(false);
123
+ me.dom = {};
124
+ },
125
+ // override for Text so that empty text will return a size
126
+ getOutline(expand) {
127
+ const me = this;
128
+ const node = me.node;
129
+ const content = node.textContent;
130
+ if (content !== null && content.length > 0)
131
+ return MarkupElement.prototype.getOutline.call(me, expand);
132
+ node.textContent = "M";
133
+ const outline = MarkupElement.prototype.getOutline.call(me, expand);
134
+ node.textContent = content;
135
+ return outline;
136
+ },
137
+ writeDataToDom() {
138
+ const me = this;
139
+ const dom = me.dom; // strip off useless "leading" data
140
+ me.dom = {};
141
+ MarkupElement.prototype.writeDataToDom.call(me);
142
+ me.dom = dom;
143
+ return me;
144
+ },
145
+ });
146
+ extend(Matrix, {
147
+ toIModelTransform() {
148
+ const m = this;
149
+ return Transform.createRowValues(m.a, m.c, 0, m.e, m.b, m.d, 0, m.f, 0, 0, 1, 0);
150
+ },
151
+ fromIModelTransform(t) {
152
+ const m = this;
153
+ const o = t.origin;
154
+ const mtx = t.matrix;
155
+ m.a = mtx.coffs[0];
156
+ m.b = mtx.coffs[3];
157
+ m.c = mtx.coffs[1];
158
+ m.d = mtx.coffs[4];
159
+ m.e = o.x;
160
+ m.f = o.y;
161
+ return this;
162
+ },
163
+ });
164
+ /** Dummy class so a <title> inside a <g> will work.
165
+ * @internal
166
+ */
167
+ export class Title extends MarkupElement {
168
+ constructor(node) { super(nodeOrNew("title", node)); }
169
+ scale() { return this; }
170
+ size() { return this; }
171
+ move() { return this; }
172
+ dmove() { return this; }
173
+ bbox() { return new Box(); }
174
+ screenCTM() { return new Matrix(); }
175
+ }
176
+ register(Title, "Title");
177
+ /** only for tests
178
+ * @internal
179
+ */
180
+ export function initSvgExt() { }
181
181
  //# sourceMappingURL=SvgJsExt.js.map
@@ -1,44 +1,44 @@
1
- /** @packageDocumentation
2
- * @module MarkupTools
3
- */
4
- import { BeButtonEvent, EventHandled } from "@itwin/core-frontend";
5
- import { G, Text as MarkupText } from "@svgdotjs/svg.js";
6
- import { MarkupTool } from "./MarkupTool";
7
- import { RedlineTool } from "./RedlineTool";
8
- /** Tool to place new text notes on a Markup.
9
- * @public
10
- */
11
- export declare class PlaceTextTool extends RedlineTool {
12
- static toolId: string;
13
- static iconSpec: string;
14
- protected _nRequiredPoints: number;
15
- protected _minPoints: number;
16
- protected _value: string;
17
- onPostInstall(): Promise<void>;
18
- protected showPrompt(): void;
19
- protected createMarkup(svg: G, ev: BeButtonEvent, isDynamics: boolean): Promise<void>;
20
- onResetButtonUp(_ev: BeButtonEvent): Promise<EventHandled>;
21
- }
22
- /** Tool for editing text. Started automatically by the place text tool and by clicking on text from the SelectTool
23
- * @public
24
- */
25
- export declare class EditTextTool extends MarkupTool {
26
- text?: G | MarkupText | undefined;
27
- private _fromPlaceTool;
28
- static toolId: string;
29
- static iconSpec: string;
30
- editor?: HTMLTextAreaElement;
31
- editDiv?: HTMLDivElement;
32
- boxed?: G;
33
- constructor(text?: G | MarkupText | undefined, _fromPlaceTool?: boolean);
34
- protected showPrompt(): void;
35
- /** Open the text editor */
36
- startEditor(): void;
37
- /** Called when EditText exits, saves the edited value into the text element */
38
- onCleanup(): Promise<void>;
39
- onInstall(): Promise<boolean>;
40
- onResetButtonUp(_ev: BeButtonEvent): Promise<EventHandled>;
41
- onDataButtonUp(_ev: BeButtonEvent): Promise<EventHandled>;
42
- onMouseStartDrag(_ev: BeButtonEvent): Promise<EventHandled>;
43
- }
1
+ /** @packageDocumentation
2
+ * @module MarkupTools
3
+ */
4
+ import { BeButtonEvent, EventHandled } from "@itwin/core-frontend";
5
+ import { G, Text as MarkupText } from "@svgdotjs/svg.js";
6
+ import { MarkupTool } from "./MarkupTool";
7
+ import { RedlineTool } from "./RedlineTool";
8
+ /** Tool to place new text notes on a Markup.
9
+ * @public
10
+ */
11
+ export declare class PlaceTextTool extends RedlineTool {
12
+ static toolId: string;
13
+ static iconSpec: string;
14
+ protected _nRequiredPoints: number;
15
+ protected _minPoints: number;
16
+ protected _value: string;
17
+ onPostInstall(): Promise<void>;
18
+ protected showPrompt(): void;
19
+ protected createMarkup(svg: G, ev: BeButtonEvent, isDynamics: boolean): Promise<void>;
20
+ onResetButtonUp(_ev: BeButtonEvent): Promise<EventHandled>;
21
+ }
22
+ /** Tool for editing text. Started automatically by the place text tool and by clicking on text from the SelectTool
23
+ * @public
24
+ */
25
+ export declare class EditTextTool extends MarkupTool {
26
+ text?: G | MarkupText | undefined;
27
+ private _fromPlaceTool;
28
+ static toolId: string;
29
+ static iconSpec: string;
30
+ editor?: HTMLTextAreaElement;
31
+ editDiv?: HTMLDivElement;
32
+ boxed?: G;
33
+ constructor(text?: G | MarkupText | undefined, _fromPlaceTool?: boolean);
34
+ protected showPrompt(): void;
35
+ /** Open the text editor */
36
+ startEditor(): void;
37
+ /** Called when EditText exits, saves the edited value into the text element */
38
+ onCleanup(): Promise<void>;
39
+ onInstall(): Promise<boolean>;
40
+ onResetButtonUp(_ev: BeButtonEvent): Promise<EventHandled>;
41
+ onDataButtonUp(_ev: BeButtonEvent): Promise<EventHandled>;
42
+ onMouseStartDrag(_ev: BeButtonEvent): Promise<EventHandled>;
43
+ }
44
44
  //# sourceMappingURL=TextEdit.d.ts.map