@itwin/core-markup 4.0.0-dev.6 → 4.0.0-dev.60

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 (45) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/lib/cjs/Markup.d.ts +310 -310
  3. package/lib/cjs/Markup.js +419 -420
  4. package/lib/cjs/Markup.js.map +1 -1
  5. package/lib/cjs/MarkupTool.d.ts +38 -38
  6. package/lib/cjs/MarkupTool.js +88 -88
  7. package/lib/cjs/MarkupTool.js.map +1 -1
  8. package/lib/cjs/RedlineTool.d.ts +145 -145
  9. package/lib/cjs/RedlineTool.js +512 -512
  10. package/lib/cjs/RedlineTool.js.map +1 -1
  11. package/lib/cjs/SelectTool.d.ts +126 -126
  12. package/lib/cjs/SelectTool.js +741 -741
  13. package/lib/cjs/SelectTool.js.map +1 -1
  14. package/lib/cjs/SvgJsExt.d.ts +85 -85
  15. package/lib/cjs/SvgJsExt.js +185 -185
  16. package/lib/cjs/TextEdit.d.ts +43 -43
  17. package/lib/cjs/TextEdit.js +196 -196
  18. package/lib/cjs/TextEdit.js.map +1 -1
  19. package/lib/cjs/Undo.d.ts +46 -46
  20. package/lib/cjs/Undo.js +168 -168
  21. package/lib/cjs/core-markup.d.ts +18 -18
  22. package/lib/cjs/core-markup.js +38 -34
  23. package/lib/cjs/core-markup.js.map +1 -1
  24. package/lib/esm/Markup.d.ts +310 -310
  25. package/lib/esm/Markup.js +415 -415
  26. package/lib/esm/Markup.js.map +1 -1
  27. package/lib/esm/MarkupTool.d.ts +38 -38
  28. package/lib/esm/MarkupTool.js +85 -84
  29. package/lib/esm/MarkupTool.js.map +1 -1
  30. package/lib/esm/RedlineTool.d.ts +145 -145
  31. package/lib/esm/RedlineTool.js +508 -498
  32. package/lib/esm/RedlineTool.js.map +1 -1
  33. package/lib/esm/SelectTool.d.ts +126 -126
  34. package/lib/esm/SelectTool.js +735 -734
  35. package/lib/esm/SelectTool.js.map +1 -1
  36. package/lib/esm/SvgJsExt.d.ts +85 -85
  37. package/lib/esm/SvgJsExt.js +180 -180
  38. package/lib/esm/TextEdit.d.ts +43 -43
  39. package/lib/esm/TextEdit.js +193 -191
  40. package/lib/esm/TextEdit.js.map +1 -1
  41. package/lib/esm/Undo.d.ts +46 -46
  42. package/lib/esm/Undo.js +164 -164
  43. package/lib/esm/core-markup.d.ts +18 -18
  44. package/lib/esm/core-markup.js +22 -22
  45. package/package.json +15 -15
package/lib/esm/Undo.js CHANGED
@@ -1,165 +1,165 @@
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 MarkupTools
7
- */
8
- import { assert } from "@itwin/core-bentley";
9
- import { MarkupApp } from "./Markup";
10
- /* @internal */
11
- class UndoAction {
12
- constructor(cmdName) {
13
- this.cmdName = cmdName;
14
- this.cmdId = 0;
15
- }
16
- }
17
- /** created when a new element is added to the markup
18
- * @internal
19
- */
20
- class AddAction extends UndoAction {
21
- constructor(cmdName, _elem) {
22
- super(cmdName);
23
- this._elem = _elem;
24
- this._parent = _elem.parent();
25
- assert(this._parent !== undefined);
26
- this._index = _elem.position();
27
- }
28
- reinstate() { this._parent.add(this._elem, this._index); }
29
- reverse() {
30
- MarkupApp.markup.selected.drop(this._elem);
31
- this._elem.remove();
32
- }
33
- }
34
- /** created when an existing element is deleted from the markup
35
- * @internal
36
- */
37
- class DeleteAction extends UndoAction {
38
- constructor(cmdName, _elem) {
39
- super(cmdName);
40
- this._elem = _elem;
41
- this._parent = _elem.parent();
42
- assert(this._parent !== undefined);
43
- this._index = _elem.position();
44
- }
45
- reverse() { this._parent.add(this._elem, this._index); }
46
- reinstate() {
47
- MarkupApp.markup.selected.drop(this._elem);
48
- this._elem.remove();
49
- }
50
- }
51
- /** created when an existing element's position is moved in the display order. This can also include re-parenting
52
- * @internal
53
- */
54
- class RepositionAction extends UndoAction {
55
- constructor(cmdName, _elem, _oldIndex, _oldParent) {
56
- super(cmdName);
57
- this._elem = _elem;
58
- this._oldIndex = _oldIndex;
59
- this._oldParent = _oldParent;
60
- this._newParent = _elem.parent();
61
- assert(this._newParent !== undefined);
62
- this._newIndex = _elem.position();
63
- }
64
- reinstate() {
65
- this._newParent.add(this._elem, this._newIndex);
66
- }
67
- reverse() {
68
- this._oldParent.add(this._elem, this._oldIndex);
69
- if (this._elem.inSelection)
70
- MarkupApp.markup.selected.drop(this._elem);
71
- }
72
- }
73
- /** created when an existing element's properties are modified.
74
- * @internal
75
- */
76
- class ModifyAction extends UndoAction {
77
- constructor(cmdName, _newElem, _oldElement) {
78
- super(cmdName);
79
- this._newElem = _newElem;
80
- this._oldElement = _oldElement;
81
- assert(_newElem !== undefined && _oldElement !== undefined);
82
- MarkupApp.markup.selected.replace(_oldElement, _newElem);
83
- }
84
- reinstate() {
85
- this._oldElement.replace(this._newElem);
86
- MarkupApp.markup.selected.replace(this._oldElement, this._newElem);
87
- }
88
- reverse() {
89
- this._newElem.replace(this._oldElement);
90
- MarkupApp.markup.selected.replace(this._newElem, this._oldElement);
91
- }
92
- }
93
- /** Stores the sequence of operations performed on a Markup. Facilitates undo/redo of the operations.
94
- * @public
95
- */
96
- export class UndoManager {
97
- constructor() {
98
- this._currentCmd = 0;
99
- this._grouped = 0;
100
- this._stack = [];
101
- this._currentPos = 0;
102
- this._cmdName = "";
103
- }
104
- addAction(action) {
105
- this._stack.length = this._currentPos;
106
- action.cmdId = this._currentCmd;
107
- this._stack.push(action);
108
- this._currentPos = this.size;
109
- }
110
- /** @internal */
111
- get size() { return this._stack.length; }
112
- startCommand() {
113
- if (0 === this._grouped)
114
- ++this._currentCmd;
115
- }
116
- startGroup() {
117
- this.startCommand();
118
- ++this._grouped;
119
- }
120
- endGroup() { --this._grouped; }
121
- /** Perform a series of changes to markup elements that should all be reversed as a single operation.
122
- * @param fn the function that performs the changes to the elements. It must call the onXXX methods of this class to store
123
- * the operations in the undo buffer.
124
- * @note all of the onXXX methods of this class should *only* be called from within the callback function of this method.
125
- */
126
- performOperation(cmdName, fn) {
127
- this._cmdName = cmdName;
128
- this.startGroup();
129
- fn();
130
- this.endGroup();
131
- }
132
- /** call this from within a [[performOperation]] function *after* an element has been added to a markup */
133
- onAdded(elem) { this.addAction(new AddAction(this._cmdName, elem)); }
134
- /** call this from within a [[performOperation]] function *before* an element is about to be deleted from a markup */
135
- onDelete(elem) { this.addAction(new DeleteAction(this._cmdName, elem)); }
136
- /** call this from within a [[performOperation]] function *after* an element has been moved in display order in a markup */
137
- onRepositioned(elem, oldIndex, oldParent) { this.addAction(new RepositionAction(this._cmdName, elem, oldIndex, oldParent)); }
138
- /** call this from within a [[performOperation]] function *after* an element has been modified in a markup */
139
- onModified(newElem, oldElem) { this.addAction(new ModifyAction(this._cmdName, newElem, oldElem)); }
140
- /** determine whether there are any un-reversed operations */
141
- get undoPossible() { return this._currentPos > 0; }
142
- /** determine whether there are any reversed operations */
143
- get redoPossible() { return this._currentPos < this.size; }
144
- /** the name of the operation that can be undone (or undefined) */
145
- get undoString() { return this.undoPossible ? this._stack[this._currentPos - 1].cmdName : undefined; }
146
- /** the name of the operation that can be redone (or undefined) */
147
- get redoString() { return this.redoPossible ? this._stack[this._currentPos].cmdName : undefined; }
148
- /** reverse the most recent operation, if any */
149
- doUndo() {
150
- if (this._currentPos === 0)
151
- return; // no operations have been performed
152
- const cmdId = this._stack[this._currentPos - 1].cmdId;
153
- while (this._currentPos > 0 && cmdId === this._stack[this._currentPos - 1].cmdId)
154
- this._stack[--this._currentPos].reverse();
155
- }
156
- /** reinstate the most recently reversed operation, if any */
157
- doRedo() {
158
- if (this._currentPos === this.size)
159
- return; // no operations have been reversed.
160
- const cmdId = this._stack[this._currentPos].cmdId;
161
- while (this._currentPos < this.size && cmdId === this._stack[this._currentPos].cmdId)
162
- this._stack[this._currentPos++].reinstate();
163
- }
164
- }
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 MarkupTools
7
+ */
8
+ import { assert } from "@itwin/core-bentley";
9
+ import { MarkupApp } from "./Markup";
10
+ /* @internal */
11
+ class UndoAction {
12
+ constructor(cmdName) {
13
+ this.cmdName = cmdName;
14
+ this.cmdId = 0;
15
+ }
16
+ }
17
+ /** created when a new element is added to the markup
18
+ * @internal
19
+ */
20
+ class AddAction extends UndoAction {
21
+ constructor(cmdName, _elem) {
22
+ super(cmdName);
23
+ this._elem = _elem;
24
+ this._parent = _elem.parent();
25
+ assert(this._parent !== undefined);
26
+ this._index = _elem.position();
27
+ }
28
+ reinstate() { this._parent.add(this._elem, this._index); }
29
+ reverse() {
30
+ MarkupApp.markup.selected.drop(this._elem);
31
+ this._elem.remove();
32
+ }
33
+ }
34
+ /** created when an existing element is deleted from the markup
35
+ * @internal
36
+ */
37
+ class DeleteAction extends UndoAction {
38
+ constructor(cmdName, _elem) {
39
+ super(cmdName);
40
+ this._elem = _elem;
41
+ this._parent = _elem.parent();
42
+ assert(this._parent !== undefined);
43
+ this._index = _elem.position();
44
+ }
45
+ reverse() { this._parent.add(this._elem, this._index); }
46
+ reinstate() {
47
+ MarkupApp.markup.selected.drop(this._elem);
48
+ this._elem.remove();
49
+ }
50
+ }
51
+ /** created when an existing element's position is moved in the display order. This can also include re-parenting
52
+ * @internal
53
+ */
54
+ class RepositionAction extends UndoAction {
55
+ constructor(cmdName, _elem, _oldIndex, _oldParent) {
56
+ super(cmdName);
57
+ this._elem = _elem;
58
+ this._oldIndex = _oldIndex;
59
+ this._oldParent = _oldParent;
60
+ this._newParent = _elem.parent();
61
+ assert(this._newParent !== undefined);
62
+ this._newIndex = _elem.position();
63
+ }
64
+ reinstate() {
65
+ this._newParent.add(this._elem, this._newIndex);
66
+ }
67
+ reverse() {
68
+ this._oldParent.add(this._elem, this._oldIndex);
69
+ if (this._elem.inSelection)
70
+ MarkupApp.markup.selected.drop(this._elem);
71
+ }
72
+ }
73
+ /** created when an existing element's properties are modified.
74
+ * @internal
75
+ */
76
+ class ModifyAction extends UndoAction {
77
+ constructor(cmdName, _newElem, _oldElement) {
78
+ super(cmdName);
79
+ this._newElem = _newElem;
80
+ this._oldElement = _oldElement;
81
+ assert(_newElem !== undefined && _oldElement !== undefined);
82
+ MarkupApp.markup.selected.replace(_oldElement, _newElem);
83
+ }
84
+ reinstate() {
85
+ this._oldElement.replace(this._newElem);
86
+ MarkupApp.markup.selected.replace(this._oldElement, this._newElem);
87
+ }
88
+ reverse() {
89
+ this._newElem.replace(this._oldElement);
90
+ MarkupApp.markup.selected.replace(this._newElem, this._oldElement);
91
+ }
92
+ }
93
+ /** Stores the sequence of operations performed on a Markup. Facilitates undo/redo of the operations.
94
+ * @public
95
+ */
96
+ export class UndoManager {
97
+ constructor() {
98
+ this._currentCmd = 0;
99
+ this._grouped = 0;
100
+ this._stack = [];
101
+ this._currentPos = 0;
102
+ this._cmdName = "";
103
+ }
104
+ addAction(action) {
105
+ this._stack.length = this._currentPos;
106
+ action.cmdId = this._currentCmd;
107
+ this._stack.push(action);
108
+ this._currentPos = this.size;
109
+ }
110
+ /** @internal */
111
+ get size() { return this._stack.length; }
112
+ startCommand() {
113
+ if (0 === this._grouped)
114
+ ++this._currentCmd;
115
+ }
116
+ startGroup() {
117
+ this.startCommand();
118
+ ++this._grouped;
119
+ }
120
+ endGroup() { --this._grouped; }
121
+ /** Perform a series of changes to markup elements that should all be reversed as a single operation.
122
+ * @param fn the function that performs the changes to the elements. It must call the onXXX methods of this class to store
123
+ * the operations in the undo buffer.
124
+ * @note all of the onXXX methods of this class should *only* be called from within the callback function of this method.
125
+ */
126
+ performOperation(cmdName, fn) {
127
+ this._cmdName = cmdName;
128
+ this.startGroup();
129
+ fn();
130
+ this.endGroup();
131
+ }
132
+ /** call this from within a [[performOperation]] function *after* an element has been added to a markup */
133
+ onAdded(elem) { this.addAction(new AddAction(this._cmdName, elem)); }
134
+ /** call this from within a [[performOperation]] function *before* an element is about to be deleted from a markup */
135
+ onDelete(elem) { this.addAction(new DeleteAction(this._cmdName, elem)); }
136
+ /** call this from within a [[performOperation]] function *after* an element has been moved in display order in a markup */
137
+ onRepositioned(elem, oldIndex, oldParent) { this.addAction(new RepositionAction(this._cmdName, elem, oldIndex, oldParent)); }
138
+ /** call this from within a [[performOperation]] function *after* an element has been modified in a markup */
139
+ onModified(newElem, oldElem) { this.addAction(new ModifyAction(this._cmdName, newElem, oldElem)); }
140
+ /** determine whether there are any un-reversed operations */
141
+ get undoPossible() { return this._currentPos > 0; }
142
+ /** determine whether there are any reversed operations */
143
+ get redoPossible() { return this._currentPos < this.size; }
144
+ /** the name of the operation that can be undone (or undefined) */
145
+ get undoString() { return this.undoPossible ? this._stack[this._currentPos - 1].cmdName : undefined; }
146
+ /** the name of the operation that can be redone (or undefined) */
147
+ get redoString() { return this.redoPossible ? this._stack[this._currentPos].cmdName : undefined; }
148
+ /** reverse the most recent operation, if any */
149
+ doUndo() {
150
+ if (this._currentPos === 0)
151
+ return; // no operations have been performed
152
+ const cmdId = this._stack[this._currentPos - 1].cmdId;
153
+ while (this._currentPos > 0 && cmdId === this._stack[this._currentPos - 1].cmdId)
154
+ this._stack[--this._currentPos].reverse();
155
+ }
156
+ /** reinstate the most recently reversed operation, if any */
157
+ doRedo() {
158
+ if (this._currentPos === this.size)
159
+ return; // no operations have been reversed.
160
+ const cmdId = this._stack[this._currentPos].cmdId;
161
+ while (this._currentPos < this.size && cmdId === this._stack[this._currentPos].cmdId)
162
+ this._stack[this._currentPos++].reinstate();
163
+ }
164
+ }
165
165
  //# sourceMappingURL=Undo.js.map
@@ -1,19 +1,19 @@
1
- export * from "./Markup";
2
- export * from "./MarkupTool";
3
- export * from "./RedlineTool";
4
- export * from "./SelectTool";
5
- export * from "./TextEdit";
6
- export * from "./Undo";
7
- export * from "./SvgJsExt";
8
- /** @docs-package-description
9
- * The core-markup package supplies tools for creating, editing, and saving SVG-based markups of Viewports.
10
- */
11
- /**
12
- * @docs-group-description MarkupApp
13
- * Classes for configuring and administering the markup system.
14
- */
15
- /**
16
- * @docs-group-description MarkupTools
17
- * Classes for supplying interactive tools for creating and editing markup elements.
18
- */
1
+ export * from "./Markup";
2
+ export * from "./MarkupTool";
3
+ export * from "./RedlineTool";
4
+ export * from "./SelectTool";
5
+ export * from "./TextEdit";
6
+ export * from "./Undo";
7
+ export * from "./SvgJsExt";
8
+ /** @docs-package-description
9
+ * The core-markup package supplies tools for creating, editing, and saving SVG-based markups of Viewports.
10
+ */
11
+ /**
12
+ * @docs-group-description MarkupApp
13
+ * Classes for configuring and administering the markup system.
14
+ */
15
+ /**
16
+ * @docs-group-description MarkupTools
17
+ * Classes for supplying interactive tools for creating and editing markup elements.
18
+ */
19
19
  //# sourceMappingURL=core-markup.d.ts.map
@@ -1,23 +1,23 @@
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
- export * from "./Markup";
6
- export * from "./MarkupTool";
7
- export * from "./RedlineTool";
8
- export * from "./SelectTool";
9
- export * from "./TextEdit";
10
- export * from "./Undo";
11
- export * from "./SvgJsExt";
12
- /** @docs-package-description
13
- * The core-markup package supplies tools for creating, editing, and saving SVG-based markups of Viewports.
14
- */
15
- /**
16
- * @docs-group-description MarkupApp
17
- * Classes for configuring and administering the markup system.
18
- */
19
- /**
20
- * @docs-group-description MarkupTools
21
- * Classes for supplying interactive tools for creating and editing markup elements.
22
- */
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
+ export * from "./Markup";
6
+ export * from "./MarkupTool";
7
+ export * from "./RedlineTool";
8
+ export * from "./SelectTool";
9
+ export * from "./TextEdit";
10
+ export * from "./Undo";
11
+ export * from "./SvgJsExt";
12
+ /** @docs-package-description
13
+ * The core-markup package supplies tools for creating, editing, and saving SVG-based markups of Viewports.
14
+ */
15
+ /**
16
+ * @docs-group-description MarkupApp
17
+ * Classes for configuring and administering the markup system.
18
+ */
19
+ /**
20
+ * @docs-group-description MarkupTools
21
+ * Classes for supplying interactive tools for creating and editing markup elements.
22
+ */
23
23
  //# sourceMappingURL=core-markup.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-markup",
3
- "version": "4.0.0-dev.6",
3
+ "version": "4.0.0-dev.60",
4
4
  "description": "iTwin.js markup package",
5
5
  "main": "lib/cjs/core-markup.js",
6
6
  "module": "lib/esm/core-markup.js",
@@ -26,22 +26,22 @@
26
26
  "@svgdotjs/svg.js": "3.0.13"
27
27
  },
28
28
  "peerDependencies": {
29
- "@itwin/core-bentley": "^4.0.0-dev.6",
30
- "@itwin/core-common": "^4.0.0-dev.6",
31
- "@itwin/core-frontend": "^4.0.0-dev.6",
32
- "@itwin/core-geometry": "^4.0.0-dev.6"
29
+ "@itwin/core-bentley": "^4.0.0-dev.60",
30
+ "@itwin/core-common": "^4.0.0-dev.60",
31
+ "@itwin/core-frontend": "^4.0.0-dev.60",
32
+ "@itwin/core-geometry": "^4.0.0-dev.60"
33
33
  },
34
34
  "devDependencies": {
35
- "@itwin/build-tools": "4.0.0-dev.6",
36
- "@itwin/core-bentley": "4.0.0-dev.6",
37
- "@itwin/core-common": "4.0.0-dev.6",
38
- "@itwin/core-frontend": "4.0.0-dev.6",
39
- "@itwin/core-geometry": "4.0.0-dev.6",
40
- "@itwin/certa": "4.0.0-dev.6",
41
- "@itwin/eslint-plugin": "4.0.0-dev.6",
35
+ "@itwin/build-tools": "4.0.0-dev.60",
36
+ "@itwin/core-bentley": "4.0.0-dev.60",
37
+ "@itwin/core-common": "4.0.0-dev.60",
38
+ "@itwin/core-frontend": "4.0.0-dev.60",
39
+ "@itwin/core-geometry": "4.0.0-dev.60",
40
+ "@itwin/certa": "4.0.0-dev.60",
41
+ "@itwin/eslint-plugin": "^4.0.0-dev.32",
42
42
  "@types/chai": "4.3.1",
43
43
  "@types/mocha": "^8.2.2",
44
- "@types/node": "18.11.5",
44
+ "@types/node": "^18.11.5",
45
45
  "babel-loader": "~8.2.5",
46
46
  "babel-plugin-istanbul": "~6.1.1",
47
47
  "chai": "^4.1.2",
@@ -52,8 +52,8 @@
52
52
  "nyc": "^15.1.0",
53
53
  "rimraf": "^3.0.2",
54
54
  "source-map-loader": "^4.0.0",
55
- "typescript": "~4.4.0",
56
- "webpack": "^5.64.4"
55
+ "typescript": "~5.0.2",
56
+ "webpack": "^5.76.0"
57
57
  },
58
58
  "nyc": {
59
59
  "extends": "./node_modules/@itwin/build-tools/.nycrc"