@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,186 +1,186 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module MarkupApp
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.initSvgExt = exports.Title = void 0;
11
- const core_geometry_1 = require("@itwin/core-geometry");
12
- const svg_js_1 = require("@svgdotjs/svg.js");
13
- const Markup_1 = require("./Markup");
14
- const OLDCOLOR = "Color";
15
- /** this is the SVG.js way of adding methods to classes */
16
- (0, svg_js_1.extend)(svg_js_1.Element, {
17
- forElementsOfGroup(fn) {
18
- const me = this;
19
- if (me instanceof svg_js_1.G)
20
- me.each((i, children) => { const child = children[i]; if (child instanceof svg_js_1.Element)
21
- fn(child); }, false);
22
- },
23
- cloneMarkup() {
24
- const me = this;
25
- const cloned = me.clone();
26
- cloned.node.removeAttribute("id");
27
- cloned.resetColor();
28
- return cloned;
29
- },
30
- overrideColor(color) {
31
- const me = this;
32
- me.forElementsOfGroup((child) => child.overrideColor(color)); // Do children first, getComputedStyle will inherit from group for unspecified values...
33
- let oldColor = me.data(OLDCOLOR);
34
- if (undefined === oldColor) {
35
- const css = window.getComputedStyle(me.node);
36
- const colorOrNone = (c) => (c && c !== "none") ? c : "none";
37
- oldColor = { fill: colorOrNone(css.fill), stroke: colorOrNone(css.stroke) };
38
- me.data(OLDCOLOR, oldColor);
39
- }
40
- const toColor = (val) => (!val || val === "none") ? "none" : color;
41
- me.css({ fill: toColor(oldColor.fill), stroke: toColor(oldColor.stroke) });
42
- },
43
- resetColor() {
44
- const me = this;
45
- const oldColor = me.data(OLDCOLOR);
46
- if (undefined !== oldColor)
47
- me.css(oldColor).data(OLDCOLOR, null); // change to old color and remove data object
48
- me.forElementsOfGroup((child) => child.resetColor());
49
- },
50
- hilite() { const me = this; if (!me.inSelection) {
51
- me.overrideColor(Markup_1.MarkupApp.props.hilite.color);
52
- me.inSelection = true;
53
- } },
54
- unHilite() { const me = this; if (me.inSelection) {
55
- me.resetColor();
56
- me.inSelection = undefined;
57
- } },
58
- flash() { const me = this; if (!me.inSelection)
59
- me.overrideColor(Markup_1.MarkupApp.props.hilite.flash); },
60
- unFlash() { const me = this; if (!me.inSelection)
61
- me.resetColor(); },
62
- markupStretch(w, h, x, y, _mtx) { const me = this; me.size(w, h).move(x, y); },
63
- isChildOf(svg) {
64
- const parent = this.parent();
65
- return (parent === svg) ? true : (parent instanceof svg_js_1.Element) ? parent.isChildOf(svg) : false;
66
- },
67
- getChildOrGroupOf(svg) {
68
- const me = this;
69
- const parents = me.parents(svg.parent());
70
- if (0 === parents.length || parents[parents.length - 1].node !== svg.node)
71
- return undefined;
72
- if (parents.length > 1) {
73
- for (let index = parents.length - 2; index >= 0; --index)
74
- if (parents[index] instanceof svg_js_1.G || parents[index] instanceof svg_js_1.Text)
75
- return parents[index];
76
- }
77
- return me;
78
- },
79
- getNpcToVp() {
80
- const me = this;
81
- const bb = me.bbox();
82
- return new svg_js_1.Matrix().scaleO(bb.w, bb.h).translateO(bb.x, bb.y).lmultiplyO(me.matrixify());
83
- },
84
- getOutline(expand) {
85
- const me = this;
86
- const box = me.bbox();
87
- if (expand === undefined)
88
- expand = 0;
89
- return new svg_js_1.Rect().move(box.x - expand, box.y - expand).size(box.w + (expand * 2), box.h + (expand * 2)).transform(me.matrixify());
90
- },
91
- });
92
- (0, svg_js_1.extend)(svg_js_1.G, {
93
- markupStretch(_w, _h, _x, _y, mtx) { this.attr("transform", mtx); },
94
- });
95
- (0, svg_js_1.extend)(svg_js_1.Text, {
96
- getFontSize() { const me = this; return parseFloat(window.getComputedStyle(me.node).fontSize); },
97
- markupStretch(_w, _h, _x, _y, mtx) { this.attr("transform", mtx); },
98
- getMarkup() {
99
- const node = this.node;
100
- let text = "";
101
- node.childNodes.forEach((child) => {
102
- if (child.nodeName === "tspan" || child.nodeName === "#text") {
103
- if (text.length !== 0)
104
- text += "\n";
105
- text += child.textContent;
106
- }
107
- });
108
- return text;
109
- },
110
- createMarkup(val, spacing) {
111
- spacing = spacing ? spacing : 1;
112
- const me = this;
113
- me.clear();
114
- if (val === "")
115
- return;
116
- const lines = val.split("\n");
117
- me.plain(lines[0]);
118
- const x = me.attr("x");
119
- me.build(true);
120
- for (let i = 1; i < lines.length; ++i) {
121
- const tspan = me.tspan(lines[i]);
122
- tspan.dy(spacing);
123
- tspan.x(x);
124
- }
125
- me.build(false);
126
- me.dom = {};
127
- },
128
- // override for Text so that empty text will return a size
129
- getOutline(expand) {
130
- const me = this;
131
- const node = me.node;
132
- const content = node.textContent;
133
- if (content !== null && content.length > 0)
134
- return svg_js_1.Element.prototype.getOutline.call(me, expand);
135
- node.textContent = "M";
136
- const outline = svg_js_1.Element.prototype.getOutline.call(me, expand);
137
- node.textContent = content;
138
- return outline;
139
- },
140
- writeDataToDom() {
141
- const me = this;
142
- const dom = me.dom; // strip off useless "leading" data
143
- me.dom = {};
144
- svg_js_1.Element.prototype.writeDataToDom.call(me);
145
- me.dom = dom;
146
- return me;
147
- },
148
- });
149
- (0, svg_js_1.extend)(svg_js_1.Matrix, {
150
- toIModelTransform() {
151
- const m = this;
152
- return core_geometry_1.Transform.createRowValues(m.a, m.c, 0, m.e, m.b, m.d, 0, m.f, 0, 0, 1, 0);
153
- },
154
- fromIModelTransform(t) {
155
- const m = this;
156
- const o = t.origin;
157
- const mtx = t.matrix;
158
- m.a = mtx.coffs[0];
159
- m.b = mtx.coffs[3];
160
- m.c = mtx.coffs[1];
161
- m.d = mtx.coffs[4];
162
- m.e = o.x;
163
- m.f = o.y;
164
- return this;
165
- },
166
- });
167
- /** Dummy class so a <title> inside a <g> will work.
168
- * @internal
169
- */
170
- class Title extends svg_js_1.Element {
171
- constructor(node) { super((0, svg_js_1.nodeOrNew)("title", node)); }
172
- scale() { return this; }
173
- size() { return this; }
174
- move() { return this; }
175
- dmove() { return this; }
176
- bbox() { return new svg_js_1.Box(); }
177
- screenCTM() { return new svg_js_1.Matrix(); }
178
- }
179
- exports.Title = Title;
180
- (0, svg_js_1.register)(Title, "Title");
181
- /** only for tests
182
- * @internal
183
- */
184
- function initSvgExt() { }
185
- exports.initSvgExt = initSvgExt;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module MarkupApp
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.initSvgExt = exports.Title = void 0;
11
+ const core_geometry_1 = require("@itwin/core-geometry");
12
+ const svg_js_1 = require("@svgdotjs/svg.js");
13
+ const Markup_1 = require("./Markup");
14
+ const OLDCOLOR = "Color";
15
+ /** this is the SVG.js way of adding methods to classes */
16
+ (0, svg_js_1.extend)(svg_js_1.Element, {
17
+ forElementsOfGroup(fn) {
18
+ const me = this;
19
+ if (me instanceof svg_js_1.G)
20
+ me.each((i, children) => { const child = children[i]; if (child instanceof svg_js_1.Element)
21
+ fn(child); }, false);
22
+ },
23
+ cloneMarkup() {
24
+ const me = this;
25
+ const cloned = me.clone();
26
+ cloned.node.removeAttribute("id");
27
+ cloned.resetColor();
28
+ return cloned;
29
+ },
30
+ overrideColor(color) {
31
+ const me = this;
32
+ me.forElementsOfGroup((child) => child.overrideColor(color)); // Do children first, getComputedStyle will inherit from group for unspecified values...
33
+ let oldColor = me.data(OLDCOLOR);
34
+ if (undefined === oldColor) {
35
+ const css = window.getComputedStyle(me.node);
36
+ const colorOrNone = (c) => (c && c !== "none") ? c : "none";
37
+ oldColor = { fill: colorOrNone(css.fill), stroke: colorOrNone(css.stroke) };
38
+ me.data(OLDCOLOR, oldColor);
39
+ }
40
+ const toColor = (val) => (!val || val === "none") ? "none" : color;
41
+ me.css({ fill: toColor(oldColor.fill), stroke: toColor(oldColor.stroke) });
42
+ },
43
+ resetColor() {
44
+ const me = this;
45
+ const oldColor = me.data(OLDCOLOR);
46
+ if (undefined !== oldColor)
47
+ me.css(oldColor).data(OLDCOLOR, null); // change to old color and remove data object
48
+ me.forElementsOfGroup((child) => child.resetColor());
49
+ },
50
+ hilite() { const me = this; if (!me.inSelection) {
51
+ me.overrideColor(Markup_1.MarkupApp.props.hilite.color);
52
+ me.inSelection = true;
53
+ } },
54
+ unHilite() { const me = this; if (me.inSelection) {
55
+ me.resetColor();
56
+ me.inSelection = undefined;
57
+ } },
58
+ flash() { const me = this; if (!me.inSelection)
59
+ me.overrideColor(Markup_1.MarkupApp.props.hilite.flash); },
60
+ unFlash() { const me = this; if (!me.inSelection)
61
+ me.resetColor(); },
62
+ markupStretch(w, h, x, y, _mtx) { const me = this; me.size(w, h).move(x, y); },
63
+ isChildOf(svg) {
64
+ const parent = this.parent();
65
+ return (parent === svg) ? true : (parent instanceof svg_js_1.Element) ? parent.isChildOf(svg) : false;
66
+ },
67
+ getChildOrGroupOf(svg) {
68
+ const me = this;
69
+ const parents = me.parents(svg.parent());
70
+ if (0 === parents.length || parents[parents.length - 1].node !== svg.node)
71
+ return undefined;
72
+ if (parents.length > 1) {
73
+ for (let index = parents.length - 2; index >= 0; --index)
74
+ if (parents[index] instanceof svg_js_1.G || parents[index] instanceof svg_js_1.Text)
75
+ return parents[index];
76
+ }
77
+ return me;
78
+ },
79
+ getNpcToVp() {
80
+ const me = this;
81
+ const bb = me.bbox();
82
+ return new svg_js_1.Matrix().scaleO(bb.w, bb.h).translateO(bb.x, bb.y).lmultiplyO(me.matrixify());
83
+ },
84
+ getOutline(expand) {
85
+ const me = this;
86
+ const box = me.bbox();
87
+ if (expand === undefined)
88
+ expand = 0;
89
+ return new svg_js_1.Rect().move(box.x - expand, box.y - expand).size(box.w + (expand * 2), box.h + (expand * 2)).transform(me.matrixify());
90
+ },
91
+ });
92
+ (0, svg_js_1.extend)(svg_js_1.G, {
93
+ markupStretch(_w, _h, _x, _y, mtx) { this.attr("transform", mtx); },
94
+ });
95
+ (0, svg_js_1.extend)(svg_js_1.Text, {
96
+ getFontSize() { const me = this; return parseFloat(window.getComputedStyle(me.node).fontSize); },
97
+ markupStretch(_w, _h, _x, _y, mtx) { this.attr("transform", mtx); },
98
+ getMarkup() {
99
+ const node = this.node;
100
+ let text = "";
101
+ node.childNodes.forEach((child) => {
102
+ if (child.nodeName === "tspan" || child.nodeName === "#text") {
103
+ if (text.length !== 0)
104
+ text += "\n";
105
+ text += child.textContent;
106
+ }
107
+ });
108
+ return text;
109
+ },
110
+ createMarkup(val, spacing) {
111
+ spacing = spacing ? spacing : 1;
112
+ const me = this;
113
+ me.clear();
114
+ if (val === "")
115
+ return;
116
+ const lines = val.split("\n");
117
+ me.plain(lines[0]);
118
+ const x = me.attr("x");
119
+ me.build(true);
120
+ for (let i = 1; i < lines.length; ++i) {
121
+ const tspan = me.tspan(lines[i]);
122
+ tspan.dy(spacing);
123
+ tspan.x(x);
124
+ }
125
+ me.build(false);
126
+ me.dom = {};
127
+ },
128
+ // override for Text so that empty text will return a size
129
+ getOutline(expand) {
130
+ const me = this;
131
+ const node = me.node;
132
+ const content = node.textContent;
133
+ if (content !== null && content.length > 0)
134
+ return svg_js_1.Element.prototype.getOutline.call(me, expand);
135
+ node.textContent = "M";
136
+ const outline = svg_js_1.Element.prototype.getOutline.call(me, expand);
137
+ node.textContent = content;
138
+ return outline;
139
+ },
140
+ writeDataToDom() {
141
+ const me = this;
142
+ const dom = me.dom; // strip off useless "leading" data
143
+ me.dom = {};
144
+ svg_js_1.Element.prototype.writeDataToDom.call(me);
145
+ me.dom = dom;
146
+ return me;
147
+ },
148
+ });
149
+ (0, svg_js_1.extend)(svg_js_1.Matrix, {
150
+ toIModelTransform() {
151
+ const m = this;
152
+ return core_geometry_1.Transform.createRowValues(m.a, m.c, 0, m.e, m.b, m.d, 0, m.f, 0, 0, 1, 0);
153
+ },
154
+ fromIModelTransform(t) {
155
+ const m = this;
156
+ const o = t.origin;
157
+ const mtx = t.matrix;
158
+ m.a = mtx.coffs[0];
159
+ m.b = mtx.coffs[3];
160
+ m.c = mtx.coffs[1];
161
+ m.d = mtx.coffs[4];
162
+ m.e = o.x;
163
+ m.f = o.y;
164
+ return this;
165
+ },
166
+ });
167
+ /** Dummy class so a <title> inside a <g> will work.
168
+ * @internal
169
+ */
170
+ class Title extends svg_js_1.Element {
171
+ constructor(node) { super((0, svg_js_1.nodeOrNew)("title", node)); }
172
+ scale() { return this; }
173
+ size() { return this; }
174
+ move() { return this; }
175
+ dmove() { return this; }
176
+ bbox() { return new svg_js_1.Box(); }
177
+ screenCTM() { return new svg_js_1.Matrix(); }
178
+ }
179
+ exports.Title = Title;
180
+ (0, svg_js_1.register)(Title, "Title");
181
+ /** only for tests
182
+ * @internal
183
+ */
184
+ function initSvgExt() { }
185
+ exports.initSvgExt = initSvgExt;
186
186
  //# 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