@inditextech/weave-sdk 0.59.0 → 0.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sdk.cjs +1494 -91
- package/dist/sdk.d.cts +433 -12
- package/dist/sdk.d.cts.map +1 -1
- package/dist/sdk.d.ts +433 -12
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +1480 -91
- package/dist/sdk.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.cjs
CHANGED
|
@@ -18256,13 +18256,6 @@ function getVisibleNodesInViewport(stage, referenceLayer) {
|
|
|
18256
18256
|
});
|
|
18257
18257
|
return visibleNodes;
|
|
18258
18258
|
}
|
|
18259
|
-
function getClosestParentWithId(el) {
|
|
18260
|
-
while (el) {
|
|
18261
|
-
if (el.id) return el;
|
|
18262
|
-
el = el.parentElement;
|
|
18263
|
-
}
|
|
18264
|
-
return null;
|
|
18265
|
-
}
|
|
18266
18259
|
function isInShadowDOM(el) {
|
|
18267
18260
|
return el?.getRootNode() instanceof ShadowRoot;
|
|
18268
18261
|
}
|
|
@@ -20334,7 +20327,6 @@ var WeaveNode = class {
|
|
|
20334
20327
|
}
|
|
20335
20328
|
});
|
|
20336
20329
|
node.on("pointerover", (e) => {
|
|
20337
|
-
e.cancelBubble = true;
|
|
20338
20330
|
const stage = this.instance.getStage();
|
|
20339
20331
|
const activeAction = this.instance.getActiveAction();
|
|
20340
20332
|
const isNodeSelectionEnabled = this.getSelectionPlugin()?.isEnabled();
|
|
@@ -20345,16 +20337,22 @@ var WeaveNode = class {
|
|
|
20345
20337
|
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && isLocked$1) {
|
|
20346
20338
|
const stage$1 = this.instance.getStage();
|
|
20347
20339
|
stage$1.container().style.cursor = "default";
|
|
20340
|
+
e.cancelBubble = true;
|
|
20348
20341
|
}
|
|
20349
20342
|
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !isLocked$1 && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20350
20343
|
const stage$1 = this.instance.getStage();
|
|
20351
20344
|
stage$1.container().style.cursor = "pointer";
|
|
20352
20345
|
this.setHoverState(realNode);
|
|
20346
|
+
e.cancelBubble = true;
|
|
20347
|
+
}
|
|
20348
|
+
if (!isTargetable) {
|
|
20349
|
+
this.hideHoverState();
|
|
20350
|
+
e.cancelBubble = true;
|
|
20353
20351
|
}
|
|
20354
|
-
if (!isTargetable) this.hideHoverState();
|
|
20355
20352
|
if (this.isPasting()) {
|
|
20356
20353
|
const stage$1 = this.instance.getStage();
|
|
20357
20354
|
stage$1.container().style.cursor = "crosshair";
|
|
20355
|
+
e.cancelBubble = true;
|
|
20358
20356
|
}
|
|
20359
20357
|
});
|
|
20360
20358
|
}
|
|
@@ -22023,7 +22021,7 @@ var WeaveRegisterManager = class {
|
|
|
22023
22021
|
|
|
22024
22022
|
//#endregion
|
|
22025
22023
|
//#region package.json
|
|
22026
|
-
var version = "0.
|
|
22024
|
+
var version = "0.61.0";
|
|
22027
22025
|
|
|
22028
22026
|
//#endregion
|
|
22029
22027
|
//#region src/managers/setup.ts
|
|
@@ -22073,6 +22071,30 @@ var WeaveSetupManager = class {
|
|
|
22073
22071
|
}
|
|
22074
22072
|
};
|
|
22075
22073
|
|
|
22074
|
+
//#endregion
|
|
22075
|
+
//#region src/plugins/stage-grid/constants.ts
|
|
22076
|
+
const WEAVE_STAGE_GRID_KEY = "stageGrid";
|
|
22077
|
+
const WEAVE_GRID_TYPES = {
|
|
22078
|
+
["LINES"]: "lines",
|
|
22079
|
+
["DOTS"]: "dots"
|
|
22080
|
+
};
|
|
22081
|
+
const WEAVE_GRID_DEFAULT_SIZE = 50;
|
|
22082
|
+
const WEAVE_GRID_DEFAULT_TYPE = WEAVE_GRID_TYPES.LINES;
|
|
22083
|
+
const WEAVE_GRID_DEFAULT_COLOR = "rgba(0,0,0,0.1)";
|
|
22084
|
+
const WEAVE_GRID_DEFAULT_ORIGIN_COLOR = "rgba(255,0,0,0.1)";
|
|
22085
|
+
const WEAVE_GRID_DEFAULT_STROKE = .5;
|
|
22086
|
+
const WEAVE_GRID_DEFAULT_MAJOR_LINE_RATIO = 4;
|
|
22087
|
+
const WEAVE_GRID_DEFAULT_RADIUS = 1;
|
|
22088
|
+
const WEAVE_GRID_DEFAULT_MAJOR_DOT_RATIO = 2;
|
|
22089
|
+
const WEAVE_GRID_DEFAULT_MAJOR_EVERY = 10;
|
|
22090
|
+
const WEAVE_GRID_DEFAULT_DOT_MAX_DOTS_PER_AXIS = 250;
|
|
22091
|
+
const WEAVE_GRID_LAYER_ID = "gridLayer";
|
|
22092
|
+
|
|
22093
|
+
//#endregion
|
|
22094
|
+
//#region src/plugins/comments-renderer/constants.ts
|
|
22095
|
+
const WEAVE_COMMENTS_RENDERER_KEY = "commentsRenderer";
|
|
22096
|
+
const WEAVE_COMMENTS_TOOL_LAYER_ID = "commentsLayer";
|
|
22097
|
+
|
|
22076
22098
|
//#endregion
|
|
22077
22099
|
//#region src/managers/stage.ts
|
|
22078
22100
|
var WeaveStageManager = class {
|
|
@@ -22099,6 +22121,14 @@ var WeaveStageManager = class {
|
|
|
22099
22121
|
const stage = this.getStage();
|
|
22100
22122
|
return stage.findOne(`#${WEAVE_NODES_SELECTION_LAYER_ID}`);
|
|
22101
22123
|
}
|
|
22124
|
+
getCommentsLayer() {
|
|
22125
|
+
const stage = this.getStage();
|
|
22126
|
+
return stage.findOne(`#${WEAVE_COMMENTS_TOOL_LAYER_ID}`);
|
|
22127
|
+
}
|
|
22128
|
+
getGridLayer() {
|
|
22129
|
+
const stage = this.getStage();
|
|
22130
|
+
return stage.findOne(`#${WEAVE_GRID_LAYER_ID}`);
|
|
22131
|
+
}
|
|
22102
22132
|
getUtilityLayer() {
|
|
22103
22133
|
const stage = this.getStage();
|
|
22104
22134
|
return stage.findOne(`#${__inditextech_weave_types.WEAVE_UTILITY_LAYER_ID}`);
|
|
@@ -22224,25 +22254,6 @@ var WeaveStoreManager = class {
|
|
|
22224
22254
|
}
|
|
22225
22255
|
};
|
|
22226
22256
|
|
|
22227
|
-
//#endregion
|
|
22228
|
-
//#region src/plugins/stage-grid/constants.ts
|
|
22229
|
-
const WEAVE_STAGE_GRID_KEY = "stageGrid";
|
|
22230
|
-
const WEAVE_GRID_TYPES = {
|
|
22231
|
-
["LINES"]: "lines",
|
|
22232
|
-
["DOTS"]: "dots"
|
|
22233
|
-
};
|
|
22234
|
-
const WEAVE_GRID_DEFAULT_SIZE = 50;
|
|
22235
|
-
const WEAVE_GRID_DEFAULT_TYPE = WEAVE_GRID_TYPES.LINES;
|
|
22236
|
-
const WEAVE_GRID_DEFAULT_COLOR = "rgba(0,0,0,0.1)";
|
|
22237
|
-
const WEAVE_GRID_DEFAULT_ORIGIN_COLOR = "rgba(255,0,0,0.1)";
|
|
22238
|
-
const WEAVE_GRID_DEFAULT_STROKE = .5;
|
|
22239
|
-
const WEAVE_GRID_DEFAULT_MAJOR_LINE_RATIO = 4;
|
|
22240
|
-
const WEAVE_GRID_DEFAULT_RADIUS = 1;
|
|
22241
|
-
const WEAVE_GRID_DEFAULT_MAJOR_DOT_RATIO = 2;
|
|
22242
|
-
const WEAVE_GRID_DEFAULT_MAJOR_EVERY = 10;
|
|
22243
|
-
const WEAVE_GRID_DEFAULT_DOT_MAX_DOTS_PER_AXIS = 250;
|
|
22244
|
-
const WEAVE_GRID_LAYER_ID = "gridLayer";
|
|
22245
|
-
|
|
22246
22257
|
//#endregion
|
|
22247
22258
|
//#region src/managers/export.ts
|
|
22248
22259
|
var WeaveExportManager = class {
|
|
@@ -22544,6 +22555,12 @@ var Weave = class {
|
|
|
22544
22555
|
getSelectionLayer() {
|
|
22545
22556
|
return this.stageManager.getSelectionLayer();
|
|
22546
22557
|
}
|
|
22558
|
+
getCommentsLayer() {
|
|
22559
|
+
return this.stageManager.getCommentsLayer();
|
|
22560
|
+
}
|
|
22561
|
+
getGridLayer() {
|
|
22562
|
+
return this.stageManager.getGridLayer();
|
|
22563
|
+
}
|
|
22547
22564
|
getUtilityLayer() {
|
|
22548
22565
|
return this.stageManager.getUtilityLayer();
|
|
22549
22566
|
}
|
|
@@ -22559,6 +22576,17 @@ var Weave = class {
|
|
|
22559
22576
|
getContainerNodes() {
|
|
22560
22577
|
return this.stageManager.getContainerNodes();
|
|
22561
22578
|
}
|
|
22579
|
+
getClosestParentWithWeaveId(el) {
|
|
22580
|
+
const weaveContainer = this.getStageConfiguration().container;
|
|
22581
|
+
let weaveId = void 0;
|
|
22582
|
+
if (weaveContainer instanceof HTMLElement) weaveId = weaveContainer.id;
|
|
22583
|
+
if (typeof weaveContainer === "string") weaveId = weaveContainer;
|
|
22584
|
+
while (el) {
|
|
22585
|
+
if (el.id && el.id === weaveId) return el;
|
|
22586
|
+
el = el.parentElement;
|
|
22587
|
+
}
|
|
22588
|
+
return null;
|
|
22589
|
+
}
|
|
22562
22590
|
getRegisterManager() {
|
|
22563
22591
|
return this.registerManager;
|
|
22564
22592
|
}
|
|
@@ -23738,7 +23766,7 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
23738
23766
|
}
|
|
23739
23767
|
setupEvents() {
|
|
23740
23768
|
const stage = this.instance.getStage();
|
|
23741
|
-
|
|
23769
|
+
window.addEventListener("keydown", (e) => {
|
|
23742
23770
|
if (e.key === "Escape" && this.instance.getActiveAction() === IMAGE_TOOL_ACTION_NAME) {
|
|
23743
23771
|
this.cancelAction();
|
|
23744
23772
|
return;
|
|
@@ -23757,13 +23785,13 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
23757
23785
|
if (this.state === IMAGE_TOOL_STATE.DEFINING_POSITION) this.state = IMAGE_TOOL_STATE.SELECTED_POSITION;
|
|
23758
23786
|
});
|
|
23759
23787
|
stage.on("pointermove", (e) => {
|
|
23788
|
+
if (this.state === IMAGE_TOOL_STATE.IDLE) return;
|
|
23789
|
+
this.setCursor();
|
|
23760
23790
|
if (this.pointers.size === 2 && this.instance.getActiveAction() === IMAGE_TOOL_ACTION_NAME) {
|
|
23761
23791
|
this.state = IMAGE_TOOL_STATE.DEFINING_POSITION;
|
|
23762
23792
|
return;
|
|
23763
23793
|
}
|
|
23764
23794
|
if ([IMAGE_TOOL_STATE.DEFINING_POSITION, IMAGE_TOOL_STATE.SELECTED_POSITION].includes(this.state) && this.tempImageNode && this.instance.getActiveAction() === IMAGE_TOOL_ACTION_NAME && e.evt.pointerType === "mouse") {
|
|
23765
|
-
stage.container().style.cursor = "crosshair";
|
|
23766
|
-
stage.container().focus();
|
|
23767
23795
|
const mousePos = stage.getRelativePointerPosition();
|
|
23768
23796
|
this.tempImageNode.setAttrs({
|
|
23769
23797
|
x: (mousePos?.x ?? 0) + this.cursorPadding,
|
|
@@ -23781,13 +23809,12 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
23781
23809
|
this.state = state;
|
|
23782
23810
|
}
|
|
23783
23811
|
loadImage(imageURL, options, position) {
|
|
23784
|
-
const stage = this.instance.getStage();
|
|
23785
23812
|
const imageOptions = {
|
|
23786
23813
|
crossOrigin: "anonymous",
|
|
23787
23814
|
...options
|
|
23788
23815
|
};
|
|
23789
|
-
|
|
23790
|
-
|
|
23816
|
+
this.setCursor();
|
|
23817
|
+
this.setFocusStage();
|
|
23791
23818
|
this.imageId = v4_default();
|
|
23792
23819
|
this.imageURL = imageURL;
|
|
23793
23820
|
this.preloadImgs[this.imageId] = new Image();
|
|
@@ -23814,8 +23841,8 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
23814
23841
|
}
|
|
23815
23842
|
addImageNode(position) {
|
|
23816
23843
|
const stage = this.instance.getStage();
|
|
23817
|
-
|
|
23818
|
-
|
|
23844
|
+
this.setCursor();
|
|
23845
|
+
this.setFocusStage();
|
|
23819
23846
|
if (position) {
|
|
23820
23847
|
this.setState(IMAGE_TOOL_STATE.SELECTED_POSITION);
|
|
23821
23848
|
this.handleAdding(position);
|
|
@@ -23921,6 +23948,16 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
23921
23948
|
this.clickPoint = null;
|
|
23922
23949
|
this.setState(IMAGE_TOOL_STATE.IDLE);
|
|
23923
23950
|
}
|
|
23951
|
+
setCursor() {
|
|
23952
|
+
const stage = this.instance.getStage();
|
|
23953
|
+
stage.container().style.cursor = "crosshair";
|
|
23954
|
+
}
|
|
23955
|
+
setFocusStage() {
|
|
23956
|
+
const stage = this.instance.getStage();
|
|
23957
|
+
stage.container().tabIndex = 1;
|
|
23958
|
+
stage.container().blur();
|
|
23959
|
+
stage.container().focus();
|
|
23960
|
+
}
|
|
23924
23961
|
};
|
|
23925
23962
|
|
|
23926
23963
|
//#endregion
|
|
@@ -25406,6 +25443,710 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
25406
25443
|
}
|
|
25407
25444
|
};
|
|
25408
25445
|
|
|
25446
|
+
//#endregion
|
|
25447
|
+
//#region src/nodes/comment/constants.ts
|
|
25448
|
+
const WEAVE_COMMENT_STATUS = {
|
|
25449
|
+
PENDING: "pending",
|
|
25450
|
+
RESOLVED: "resolved"
|
|
25451
|
+
};
|
|
25452
|
+
const WEAVE_COMMENT_CREATE_ACTION = {
|
|
25453
|
+
CREATE: "create",
|
|
25454
|
+
CLOSE: "close"
|
|
25455
|
+
};
|
|
25456
|
+
const WEAVE_COMMENT_VIEW_ACTION = {
|
|
25457
|
+
REPLY: "reply",
|
|
25458
|
+
MARK_RESOLVED: "markResolved",
|
|
25459
|
+
EDIT: "edit",
|
|
25460
|
+
DELETE: "delete",
|
|
25461
|
+
CLOSE: "close"
|
|
25462
|
+
};
|
|
25463
|
+
const WEAVE_COMMENT_NODE_ACTION = {
|
|
25464
|
+
IDLE: "idle",
|
|
25465
|
+
CREATING: "creating",
|
|
25466
|
+
VIEWING: "viewing"
|
|
25467
|
+
};
|
|
25468
|
+
const WEAVE_COMMENT_NODE_TYPE = "comment";
|
|
25469
|
+
const WEAVE_COMMENT_NODE_DEFAULTS = {
|
|
25470
|
+
style: {
|
|
25471
|
+
stroke: "#000000",
|
|
25472
|
+
strokeWidth: 0,
|
|
25473
|
+
shadowColor: "rgba(0,0,0,0.25)",
|
|
25474
|
+
shadowBlur: 4,
|
|
25475
|
+
shadowOffsetX: 0,
|
|
25476
|
+
shadowOffsetY: 0,
|
|
25477
|
+
shadowOpacity: .8,
|
|
25478
|
+
contracted: {
|
|
25479
|
+
width: 40,
|
|
25480
|
+
height: 40,
|
|
25481
|
+
circlePadding: 2,
|
|
25482
|
+
userName: {
|
|
25483
|
+
fontFamily: "arial, sans-serif",
|
|
25484
|
+
fontSize: 14,
|
|
25485
|
+
fontStyle: "normal"
|
|
25486
|
+
}
|
|
25487
|
+
},
|
|
25488
|
+
expanded: {
|
|
25489
|
+
width: 250,
|
|
25490
|
+
userNameLeftMargin: 8,
|
|
25491
|
+
dateLeftMargin: 8,
|
|
25492
|
+
contentTopMargin: 8,
|
|
25493
|
+
contentBottomMargin: 12,
|
|
25494
|
+
userName: {
|
|
25495
|
+
fontFamily: "arial, sans-serif",
|
|
25496
|
+
fontSize: 12,
|
|
25497
|
+
fontStyle: "bold",
|
|
25498
|
+
color: "#000000"
|
|
25499
|
+
},
|
|
25500
|
+
date: {
|
|
25501
|
+
fontFamily: "arial, sans-serif",
|
|
25502
|
+
fontSize: 12,
|
|
25503
|
+
fontStyle: "normal",
|
|
25504
|
+
color: "#757575"
|
|
25505
|
+
},
|
|
25506
|
+
content: {
|
|
25507
|
+
fontFamily: "arial, sans-serif",
|
|
25508
|
+
fontSize: 12,
|
|
25509
|
+
maxLines: 3,
|
|
25510
|
+
fontStyle: "normal",
|
|
25511
|
+
color: "#000000"
|
|
25512
|
+
}
|
|
25513
|
+
},
|
|
25514
|
+
creating: {
|
|
25515
|
+
paddingX: 16,
|
|
25516
|
+
paddingY: -8,
|
|
25517
|
+
stroke: "#1a1aff",
|
|
25518
|
+
strokeWidth: 2
|
|
25519
|
+
},
|
|
25520
|
+
viewing: {
|
|
25521
|
+
paddingX: 16,
|
|
25522
|
+
paddingY: -18,
|
|
25523
|
+
stroke: "#1a1aff",
|
|
25524
|
+
strokeWidth: 2
|
|
25525
|
+
}
|
|
25526
|
+
},
|
|
25527
|
+
formatDate: (date) => date
|
|
25528
|
+
};
|
|
25529
|
+
|
|
25530
|
+
//#endregion
|
|
25531
|
+
//#region src/nodes/comment/text-max-lines.ts
|
|
25532
|
+
var TextWithMaxLines = class extends konva.default.Text {
|
|
25533
|
+
constructor(config) {
|
|
25534
|
+
super(config);
|
|
25535
|
+
this._maxLines = config.maxLines;
|
|
25536
|
+
this._fullText = config.text?.toString() ?? "";
|
|
25537
|
+
this.on("textChange widthChange fontSizeChange fontFamilyChange fontStyleChange paddingChange alignChange letterSpacingChange lineHeightChange wrapChange", () => this._applyTruncation());
|
|
25538
|
+
this._applyTruncation();
|
|
25539
|
+
}
|
|
25540
|
+
get maxLines() {
|
|
25541
|
+
return this._maxLines;
|
|
25542
|
+
}
|
|
25543
|
+
set maxLines(v) {
|
|
25544
|
+
this._maxLines = v;
|
|
25545
|
+
this._applyTruncation();
|
|
25546
|
+
}
|
|
25547
|
+
setText(text) {
|
|
25548
|
+
if (typeof text === "undefined") return this;
|
|
25549
|
+
this._fullText = text ?? "";
|
|
25550
|
+
super.setText(this._fullText);
|
|
25551
|
+
this._applyTruncation();
|
|
25552
|
+
return this;
|
|
25553
|
+
}
|
|
25554
|
+
_applyTruncation() {
|
|
25555
|
+
if (!this._maxLines || this._maxLines <= 0) {
|
|
25556
|
+
super.setText(this._fullText);
|
|
25557
|
+
return;
|
|
25558
|
+
}
|
|
25559
|
+
super.setText(this._fullText);
|
|
25560
|
+
const selfAny = this;
|
|
25561
|
+
if (typeof selfAny._setTextData === "function") selfAny._setTextData();
|
|
25562
|
+
let textArr = selfAny.textArr || [];
|
|
25563
|
+
if (textArr.length > this._maxLines) {
|
|
25564
|
+
const visible = textArr.slice(0, this._maxLines).map((l) => l.text);
|
|
25565
|
+
const candidate = visible[visible.length - 1] + "…";
|
|
25566
|
+
super.setText([...visible.slice(0, -1), candidate].join("\n"));
|
|
25567
|
+
if (typeof selfAny._setTextData === "function") selfAny._setTextData();
|
|
25568
|
+
textArr = selfAny.textArr || [];
|
|
25569
|
+
}
|
|
25570
|
+
const lines = textArr.length;
|
|
25571
|
+
const fontSize = this.fontSize();
|
|
25572
|
+
const lineHeight = this.lineHeight() || 1;
|
|
25573
|
+
this.height(fontSize * lineHeight * lines);
|
|
25574
|
+
}
|
|
25575
|
+
};
|
|
25576
|
+
|
|
25577
|
+
//#endregion
|
|
25578
|
+
//#region src/nodes/comment/comment.ts
|
|
25579
|
+
var WeaveCommentNode = class extends WeaveNode {
|
|
25580
|
+
nodeType = WEAVE_COMMENT_NODE_TYPE;
|
|
25581
|
+
constructor(params) {
|
|
25582
|
+
super();
|
|
25583
|
+
this.config = (0, import_lodash.merge)(WEAVE_COMMENT_NODE_DEFAULTS, params.config);
|
|
25584
|
+
this.commentDomVisibleId = null;
|
|
25585
|
+
this.commentDomVisible = false;
|
|
25586
|
+
this.commentDomAction = null;
|
|
25587
|
+
this.showResolved = false;
|
|
25588
|
+
}
|
|
25589
|
+
onRender(props) {
|
|
25590
|
+
const { id } = props;
|
|
25591
|
+
const commentParams = { ...props };
|
|
25592
|
+
delete commentParams.zIndex;
|
|
25593
|
+
const widthContracted = this.config.style.contracted.width;
|
|
25594
|
+
const heightContracted = this.config.style.contracted.height;
|
|
25595
|
+
const circlePaddingContracted = this.config.style.contracted.circlePadding;
|
|
25596
|
+
const widthExpanded = this.config.style.expanded.width;
|
|
25597
|
+
const userNameLeftMargin = this.config.style.expanded.userNameLeftMargin;
|
|
25598
|
+
const dateLeftMargin = this.config.style.expanded.dateLeftMargin;
|
|
25599
|
+
const contentTopMargin = this.config.style.expanded.contentTopMargin;
|
|
25600
|
+
const contentBottomMargin = this.config.style.expanded.contentBottomMargin;
|
|
25601
|
+
const userNameShortFontFamily = this.config.style.contracted.userName.fontFamily;
|
|
25602
|
+
const userNameShortFontSize = this.config.style.contracted.userName.fontSize;
|
|
25603
|
+
const userNameShortFontStyle = this.config.style.contracted.userName.fontStyle;
|
|
25604
|
+
const userNameFontFamily = this.config.style.expanded.userName.fontFamily;
|
|
25605
|
+
const userNameFontSize = this.config.style.expanded.userName.fontSize;
|
|
25606
|
+
const userNameFontStyle = this.config.style.expanded.userName.fontStyle;
|
|
25607
|
+
const userNameColor = this.config.style.expanded.userName.color;
|
|
25608
|
+
const dateFontFamily = this.config.style.expanded.date.fontFamily;
|
|
25609
|
+
const dateFontSize = this.config.style.expanded.date.fontSize;
|
|
25610
|
+
const dateFontStyle = this.config.style.expanded.date.fontStyle;
|
|
25611
|
+
const dateColor = this.config.style.expanded.date.color;
|
|
25612
|
+
const contentMaxLines = this.config.style.expanded.content.maxLines;
|
|
25613
|
+
const contentFontFamily = this.config.style.expanded.content.fontFamily;
|
|
25614
|
+
const contentFontSize = this.config.style.expanded.content.fontSize;
|
|
25615
|
+
const contentFontStyle = this.config.style.expanded.content.fontStyle;
|
|
25616
|
+
const contentColor = this.config.style.expanded.content.color;
|
|
25617
|
+
const commentNode = new konva.default.Group({
|
|
25618
|
+
...commentParams,
|
|
25619
|
+
name: "comment",
|
|
25620
|
+
isTargetable: false,
|
|
25621
|
+
isExpanded: false,
|
|
25622
|
+
commentAction: null,
|
|
25623
|
+
listening: true,
|
|
25624
|
+
draggable: this.config.model.canUserDrag(commentParams.commentModel)
|
|
25625
|
+
});
|
|
25626
|
+
this.setupDefaultNodeAugmentation(commentNode);
|
|
25627
|
+
const background = new konva.default.Shape({
|
|
25628
|
+
id: `${id}-bg`,
|
|
25629
|
+
x: 0,
|
|
25630
|
+
y: -heightContracted,
|
|
25631
|
+
isTargetable: false,
|
|
25632
|
+
fill: commentParams.userBackgroundColor ?? "#0000FF",
|
|
25633
|
+
stroke: this.config.style.stroke,
|
|
25634
|
+
strokeWidth: this.config.style.strokeWidth,
|
|
25635
|
+
width: widthContracted,
|
|
25636
|
+
height: heightContracted,
|
|
25637
|
+
shadowColor: this.config.style.shadowColor,
|
|
25638
|
+
shadowBlur: this.config.style.shadowBlur,
|
|
25639
|
+
shadowOffsetX: this.config.style.shadowOffsetX,
|
|
25640
|
+
shadowOffsetY: this.config.style.shadowOffsetY,
|
|
25641
|
+
shadowOpacity: this.config.style.shadowOpacity,
|
|
25642
|
+
strokeScaleEnabled: false,
|
|
25643
|
+
listening: true,
|
|
25644
|
+
draggable: false,
|
|
25645
|
+
hitFunc: (ctx, shape) => {
|
|
25646
|
+
ctx.beginPath();
|
|
25647
|
+
ctx.rect(0, 0, shape.width(), shape.height());
|
|
25648
|
+
ctx.closePath();
|
|
25649
|
+
ctx.fillStrokeShape(shape);
|
|
25650
|
+
},
|
|
25651
|
+
sceneFunc: (ctx, shape) => {
|
|
25652
|
+
ctx.imageSmoothingEnabled = false;
|
|
25653
|
+
const w = shape.width();
|
|
25654
|
+
const h = shape.height();
|
|
25655
|
+
const rWant = shape.getParent()?.getAttrs().isExpanded ? widthContracted / 2 : shape.width() / 2;
|
|
25656
|
+
const r = Math.min(rWant, w / 2, h / 2);
|
|
25657
|
+
ctx.beginPath();
|
|
25658
|
+
ctx.moveTo(r, 0);
|
|
25659
|
+
ctx.lineTo(w - r, 0);
|
|
25660
|
+
ctx.arcTo(w, 0, w, r, r);
|
|
25661
|
+
ctx.lineTo(w, h - r);
|
|
25662
|
+
ctx.arcTo(w, h, w - r, h, r);
|
|
25663
|
+
ctx.lineTo(0, h);
|
|
25664
|
+
ctx.lineTo(0, r);
|
|
25665
|
+
ctx.arcTo(0, 0, r, 0, r);
|
|
25666
|
+
ctx.closePath();
|
|
25667
|
+
ctx.fillStrokeShape(shape);
|
|
25668
|
+
}
|
|
25669
|
+
});
|
|
25670
|
+
commentNode.add(background);
|
|
25671
|
+
const internalCircleBigName = new konva.default.Circle({
|
|
25672
|
+
id: `${id}-circle-big-name`,
|
|
25673
|
+
x: widthContracted / 2,
|
|
25674
|
+
y: -(heightContracted / 2),
|
|
25675
|
+
fill: commentParams.userBackgroundColor ?? "#0000FF",
|
|
25676
|
+
radius: widthContracted / 2 - 2 * circlePaddingContracted,
|
|
25677
|
+
listening: false,
|
|
25678
|
+
draggable: false
|
|
25679
|
+
});
|
|
25680
|
+
internalCircleBigName.hide();
|
|
25681
|
+
commentNode.add(internalCircleBigName);
|
|
25682
|
+
const internalBigName = new konva.default.Text({
|
|
25683
|
+
id: `${id}-big-name`,
|
|
25684
|
+
x: circlePaddingContracted,
|
|
25685
|
+
y: -(heightContracted - circlePaddingContracted),
|
|
25686
|
+
text: this.config.model.getUserShortName(commentParams.commentModel),
|
|
25687
|
+
fontFamily: userNameShortFontFamily,
|
|
25688
|
+
fontSize: userNameShortFontSize,
|
|
25689
|
+
fontStyle: userNameShortFontStyle,
|
|
25690
|
+
fill: commentParams.userForegroundColor ?? "#FFFFFF",
|
|
25691
|
+
align: "center",
|
|
25692
|
+
verticalAlign: "middle",
|
|
25693
|
+
width: widthContracted - 2 * circlePaddingContracted,
|
|
25694
|
+
height: heightContracted - 2 * circlePaddingContracted,
|
|
25695
|
+
listening: false,
|
|
25696
|
+
draggable: false
|
|
25697
|
+
});
|
|
25698
|
+
internalBigName.hide();
|
|
25699
|
+
commentNode.add(internalBigName);
|
|
25700
|
+
const internalUserName = new konva.default.Text({
|
|
25701
|
+
id: `${id}-user-name`,
|
|
25702
|
+
x: widthContracted - 2 * circlePaddingContracted + userNameLeftMargin,
|
|
25703
|
+
text: this.config.model.getUserFullName(commentParams.commentModel),
|
|
25704
|
+
wrap: "none",
|
|
25705
|
+
ellipsis: true,
|
|
25706
|
+
fontFamily: userNameFontFamily,
|
|
25707
|
+
fontSize: userNameFontSize,
|
|
25708
|
+
fontStyle: userNameFontStyle,
|
|
25709
|
+
fill: userNameColor,
|
|
25710
|
+
align: "left",
|
|
25711
|
+
verticalAlign: "middle",
|
|
25712
|
+
width: (widthExpanded - (widthContracted - 2 * circlePaddingContracted) - 8) / 2,
|
|
25713
|
+
height: heightContracted - 2 * circlePaddingContracted,
|
|
25714
|
+
listening: false,
|
|
25715
|
+
draggable: false
|
|
25716
|
+
});
|
|
25717
|
+
internalUserName.hide();
|
|
25718
|
+
commentNode.add(internalUserName);
|
|
25719
|
+
const commentDate = this.config.formatDate(this.config.model.getDate(commentParams.commentModel));
|
|
25720
|
+
const internalDate = new konva.default.Text({
|
|
25721
|
+
id: `${id}-date`,
|
|
25722
|
+
x: widthContracted - 2 * circlePaddingContracted + userNameLeftMargin + (widthExpanded - (widthContracted - 2 * circlePaddingContracted) - 8) / 2,
|
|
25723
|
+
text: commentDate,
|
|
25724
|
+
ellipsis: true,
|
|
25725
|
+
fontFamily: dateFontFamily,
|
|
25726
|
+
fontStyle: dateFontStyle,
|
|
25727
|
+
fontSize: dateFontSize,
|
|
25728
|
+
fill: dateColor,
|
|
25729
|
+
align: "left",
|
|
25730
|
+
verticalAlign: "middle",
|
|
25731
|
+
width: (widthExpanded - (widthContracted - 2 * circlePaddingContracted) - 8) / 2,
|
|
25732
|
+
height: heightContracted - 2 * circlePaddingContracted,
|
|
25733
|
+
listening: false,
|
|
25734
|
+
draggable: false
|
|
25735
|
+
});
|
|
25736
|
+
internalDate.hide();
|
|
25737
|
+
commentNode.add(internalDate);
|
|
25738
|
+
const dateWidth = internalDate.measureSize(commentDate);
|
|
25739
|
+
internalDate.setAttrs({
|
|
25740
|
+
x: widthExpanded - circlePaddingContracted - dateWidth.width - userNameLeftMargin,
|
|
25741
|
+
width: dateWidth.width
|
|
25742
|
+
});
|
|
25743
|
+
internalUserName.setAttrs({ width: widthExpanded - (widthContracted - 2 * circlePaddingContracted) - userNameLeftMargin - dateLeftMargin - dateWidth.width });
|
|
25744
|
+
const commentContent = this.config.model.getContent(commentParams.commentModel);
|
|
25745
|
+
const internalComment = new TextWithMaxLines({
|
|
25746
|
+
id: `${id}-comment`,
|
|
25747
|
+
x: widthContracted - 2 * circlePaddingContracted + userNameLeftMargin,
|
|
25748
|
+
text: commentContent,
|
|
25749
|
+
wrap: "word",
|
|
25750
|
+
ellipsis: true,
|
|
25751
|
+
fontFamily: contentFontFamily,
|
|
25752
|
+
fontSize: contentFontSize,
|
|
25753
|
+
maxLines: contentMaxLines,
|
|
25754
|
+
fontStyle: contentFontStyle,
|
|
25755
|
+
lineHeight: 1.2,
|
|
25756
|
+
fill: contentColor,
|
|
25757
|
+
align: "left",
|
|
25758
|
+
verticalAlign: "top",
|
|
25759
|
+
width: widthExpanded - (widthContracted - 2 * circlePaddingContracted) - userNameLeftMargin - dateLeftMargin,
|
|
25760
|
+
height: heightContracted - 2 * circlePaddingContracted,
|
|
25761
|
+
listening: false,
|
|
25762
|
+
draggable: false
|
|
25763
|
+
});
|
|
25764
|
+
internalComment.hide();
|
|
25765
|
+
commentNode.add(internalComment);
|
|
25766
|
+
const expandedHeight = internalCircleBigName.getClientRect().height + internalComment.getClientRect().height + contentBottomMargin;
|
|
25767
|
+
internalUserName.setAttrs({ y: -expandedHeight + circlePaddingContracted });
|
|
25768
|
+
internalDate.setAttrs({ y: -expandedHeight + circlePaddingContracted });
|
|
25769
|
+
internalComment.setAttrs({ y: -expandedHeight + circlePaddingContracted + heightContracted - contentTopMargin });
|
|
25770
|
+
commentNode.getTransformerProperties = () => {
|
|
25771
|
+
const baseConfig = this.defaultGetTransformerProperties({});
|
|
25772
|
+
return {
|
|
25773
|
+
...baseConfig,
|
|
25774
|
+
resizeEnabled: false,
|
|
25775
|
+
rotateEnabled: false,
|
|
25776
|
+
enabledAnchors: [],
|
|
25777
|
+
borderStrokeWidth: 0,
|
|
25778
|
+
padding: 0
|
|
25779
|
+
};
|
|
25780
|
+
};
|
|
25781
|
+
commentNode.allowedAnchors = () => {
|
|
25782
|
+
return [];
|
|
25783
|
+
};
|
|
25784
|
+
commentNode.on("dragstart", (e) => {
|
|
25785
|
+
this.contractNode(e.target);
|
|
25786
|
+
e.target.setAttrs({ isDragging: true });
|
|
25787
|
+
this.onUpdate(e.target, {});
|
|
25788
|
+
});
|
|
25789
|
+
commentNode.on("dragend", (e) => {
|
|
25790
|
+
e.target.setAttrs({ isDragging: false });
|
|
25791
|
+
this.onUpdate(e.target, {});
|
|
25792
|
+
this.normalizeNodeSize(e.target);
|
|
25793
|
+
this.instance.emitEvent("onCommentDragEnd", { node: e.target });
|
|
25794
|
+
});
|
|
25795
|
+
commentNode.on("pointerup", (e) => {
|
|
25796
|
+
const node = e.target.getParent();
|
|
25797
|
+
if (this.commentDomVisible) {
|
|
25798
|
+
const nodeToClose = this.instance.getStage().findOne(`#${this.commentDomVisibleId}`);
|
|
25799
|
+
if (nodeToClose) {
|
|
25800
|
+
this.closeCommentDOM(nodeToClose);
|
|
25801
|
+
this.contractNode(nodeToClose);
|
|
25802
|
+
}
|
|
25803
|
+
}
|
|
25804
|
+
this.openCommentDOM(node);
|
|
25805
|
+
});
|
|
25806
|
+
commentNode.on("pointermove", (e) => {
|
|
25807
|
+
const stage$1 = this.instance.getStage();
|
|
25808
|
+
stage$1.container().style.cursor = "pointer";
|
|
25809
|
+
e.cancelBubble = true;
|
|
25810
|
+
});
|
|
25811
|
+
commentNode.on("pointerenter", (e) => {
|
|
25812
|
+
const node = e.target.getParent();
|
|
25813
|
+
const commentAction = node.getAttrs().commentAction;
|
|
25814
|
+
if (commentAction !== WEAVE_COMMENT_NODE_ACTION.IDLE) return;
|
|
25815
|
+
if (this.commentDomVisible && this.commentDomVisibleId === node.getAttrs().id) return;
|
|
25816
|
+
node.setAttrs({ isHovered: true });
|
|
25817
|
+
this.expandNode(node);
|
|
25818
|
+
});
|
|
25819
|
+
commentNode.on("pointerleave", (e) => {
|
|
25820
|
+
const node = e.target.getParent();
|
|
25821
|
+
const commentAction = node.getAttrs().commentAction;
|
|
25822
|
+
if (commentAction !== WEAVE_COMMENT_NODE_ACTION.IDLE) return;
|
|
25823
|
+
if (this.commentDomVisible && this.commentDomVisibleId === node.getAttrs().id) return;
|
|
25824
|
+
node.setAttrs({ isHovered: false });
|
|
25825
|
+
this.contractNode(node);
|
|
25826
|
+
});
|
|
25827
|
+
const stage = this.instance.getStage();
|
|
25828
|
+
stage?.on("scaleXChange scaleYChange", () => {
|
|
25829
|
+
this.normalizeNodeSize(commentNode);
|
|
25830
|
+
});
|
|
25831
|
+
return commentNode;
|
|
25832
|
+
}
|
|
25833
|
+
onUpdate(nodeInstance, nextProps) {
|
|
25834
|
+
const commentNode = nodeInstance;
|
|
25835
|
+
commentNode.setAttrs({ ...nextProps });
|
|
25836
|
+
const commentAction = commentNode.getAttrs().commentAction;
|
|
25837
|
+
if (this.config.model.getStatus(commentNode.getAttrs()?.commentModel) === "resolved" && !commentNode.getAttrs().isExpanded && commentNode.getAttrs().commentAction !== WEAVE_COMMENT_NODE_ACTION.VIEWING) commentNode.setAttrs({ opacity: .5 });
|
|
25838
|
+
else commentNode.setAttrs({ opacity: 1 });
|
|
25839
|
+
if (this.showResolved && this.config.model.getStatus(commentNode.getAttrs()?.commentModel) === WEAVE_COMMENT_STATUS.RESOLVED) commentNode.show();
|
|
25840
|
+
if (!this.showResolved && this.config.model.getStatus(commentNode.getAttrs()?.commentModel) === WEAVE_COMMENT_STATUS.RESOLVED) commentNode.hide();
|
|
25841
|
+
const background = commentNode.findOne(`#${commentNode.id()}-bg`);
|
|
25842
|
+
if (background && commentNode.getAttrs().commentAction === WEAVE_COMMENT_NODE_ACTION.VIEWING) background.setAttrs({
|
|
25843
|
+
stroke: this.config.style.viewing.stroke,
|
|
25844
|
+
strokeWidth: this.config.style.viewing.strokeWidth
|
|
25845
|
+
});
|
|
25846
|
+
if (background && commentNode.getAttrs().commentAction === WEAVE_COMMENT_NODE_ACTION.CREATING) background.setAttrs({
|
|
25847
|
+
stroke: this.config.style.creating.stroke,
|
|
25848
|
+
strokeWidth: this.config.style.creating.strokeWidth
|
|
25849
|
+
});
|
|
25850
|
+
if (background && commentNode.getAttrs().commentAction === WEAVE_COMMENT_NODE_ACTION.IDLE) background.setAttrs({
|
|
25851
|
+
stroke: this.config.style.stroke,
|
|
25852
|
+
strokeWidth: this.config.style.strokeWidth
|
|
25853
|
+
});
|
|
25854
|
+
if (background && commentNode.getAttrs().isDragging) background.setAttrs({
|
|
25855
|
+
stroke: this.config.style.viewing.stroke,
|
|
25856
|
+
strokeWidth: this.config.style.viewing.strokeWidth
|
|
25857
|
+
});
|
|
25858
|
+
if (commentAction === WEAVE_COMMENT_NODE_ACTION.CREATING) {
|
|
25859
|
+
const commentDomElement = this.createCommentDOM(commentNode);
|
|
25860
|
+
commentNode.setAttrs({ commentAction: WEAVE_COMMENT_NODE_ACTION.CREATING });
|
|
25861
|
+
this.commentDomAction = WEAVE_COMMENT_NODE_ACTION.CREATING;
|
|
25862
|
+
this.commentDomVisibleId = commentNode.id();
|
|
25863
|
+
this.commentDomVisible = true;
|
|
25864
|
+
this.config.createComment(commentDomElement, commentNode, (node, content, action) => {
|
|
25865
|
+
this.finishCreateCommentDOM(node);
|
|
25866
|
+
if (action === WEAVE_COMMENT_CREATE_ACTION.CLOSE) {
|
|
25867
|
+
this.onDestroy(node);
|
|
25868
|
+
this.instance.emitEvent("onCommentFinishCreate", {
|
|
25869
|
+
node,
|
|
25870
|
+
action
|
|
25871
|
+
});
|
|
25872
|
+
return;
|
|
25873
|
+
}
|
|
25874
|
+
if (action === WEAVE_COMMENT_CREATE_ACTION.CREATE && content !== "") {
|
|
25875
|
+
this.instance.emitEvent("onCommentCreate", {
|
|
25876
|
+
node,
|
|
25877
|
+
position: {
|
|
25878
|
+
x: node.x(),
|
|
25879
|
+
y: node.y()
|
|
25880
|
+
},
|
|
25881
|
+
content
|
|
25882
|
+
});
|
|
25883
|
+
this.onUpdate(node, {
|
|
25884
|
+
commentModel: this.config.model.setContent(node.getAttrs().commentModel ?? {}, content),
|
|
25885
|
+
commentAction: WEAVE_COMMENT_NODE_ACTION.IDLE
|
|
25886
|
+
});
|
|
25887
|
+
this.contractNode(node);
|
|
25888
|
+
this.instance.emitEvent("onCommentFinishCreate", {
|
|
25889
|
+
node,
|
|
25890
|
+
action
|
|
25891
|
+
});
|
|
25892
|
+
}
|
|
25893
|
+
});
|
|
25894
|
+
this.normalizeNodeSize(commentNode);
|
|
25895
|
+
return;
|
|
25896
|
+
}
|
|
25897
|
+
if (commentAction === WEAVE_COMMENT_NODE_ACTION.IDLE) {
|
|
25898
|
+
const internalRect = commentNode.findOne(`#${commentNode.id()}-bg`);
|
|
25899
|
+
internalRect?.setAttrs({ fill: "#FFFFFF" });
|
|
25900
|
+
const internalCircleBigName = commentNode.findOne(`#${commentNode.id()}-circle-big-name`);
|
|
25901
|
+
internalCircleBigName?.show();
|
|
25902
|
+
const internalBigName = commentNode.findOne(`#${commentNode.id()}-big-name`);
|
|
25903
|
+
internalBigName?.show();
|
|
25904
|
+
this.normalizeNodeSize(commentNode);
|
|
25905
|
+
return;
|
|
25906
|
+
}
|
|
25907
|
+
this.normalizeNodeSize(commentNode);
|
|
25908
|
+
}
|
|
25909
|
+
onDestroy(nodeInstance) {
|
|
25910
|
+
nodeInstance.destroy();
|
|
25911
|
+
}
|
|
25912
|
+
expandNode(commentNode) {
|
|
25913
|
+
const widthExpanded = this.config.style.expanded.width;
|
|
25914
|
+
const circlePaddingContracted = this.config.style.contracted.circlePadding;
|
|
25915
|
+
const internalCircleBigName = commentNode.findOne(`#${commentNode.id()}-circle-big-name`);
|
|
25916
|
+
const internalComment = commentNode.findOne(`#${commentNode.id()}-comment`);
|
|
25917
|
+
const heightExpanded = (internalCircleBigName?.getClientRect().height ?? 0) + (internalComment?.getClientRect().height ?? 0) + 12;
|
|
25918
|
+
const background = commentNode.findOne(`#${commentNode.id()}-bg`);
|
|
25919
|
+
background?.setAttrs({
|
|
25920
|
+
y: -heightExpanded,
|
|
25921
|
+
width: widthExpanded,
|
|
25922
|
+
height: heightExpanded
|
|
25923
|
+
});
|
|
25924
|
+
internalCircleBigName?.setAttrs({ y: -heightExpanded + circlePaddingContracted * 2 + internalCircleBigName.radius() });
|
|
25925
|
+
const internalBigName = commentNode.findOne(`#${commentNode.id()}-big-name`);
|
|
25926
|
+
internalBigName?.setAttrs({ y: -heightExpanded + circlePaddingContracted });
|
|
25927
|
+
const internalUserName = commentNode.findOne(`#${commentNode.id()}-user-name`);
|
|
25928
|
+
internalUserName?.show();
|
|
25929
|
+
const internalDateName = commentNode.findOne(`#${commentNode.id()}-date`);
|
|
25930
|
+
internalDateName?.show();
|
|
25931
|
+
internalComment?.show();
|
|
25932
|
+
commentNode.setAttrs({
|
|
25933
|
+
isExpanded: true,
|
|
25934
|
+
opacity: 1
|
|
25935
|
+
});
|
|
25936
|
+
const actualZIndex = commentNode.zIndex();
|
|
25937
|
+
commentNode.setAttrs({ contractedZIndex: actualZIndex });
|
|
25938
|
+
commentNode.moveToTop();
|
|
25939
|
+
this.normalizeNodeSize(commentNode);
|
|
25940
|
+
}
|
|
25941
|
+
contractNode(commentNode) {
|
|
25942
|
+
const widthContracted = this.config.style.contracted.width;
|
|
25943
|
+
const heightContracted = this.config.style.contracted.height;
|
|
25944
|
+
const circlePaddingContracted = this.config.style.contracted.circlePadding;
|
|
25945
|
+
const background = commentNode.findOne(`#${commentNode.id()}-bg`);
|
|
25946
|
+
background?.setAttrs({
|
|
25947
|
+
y: -heightContracted,
|
|
25948
|
+
width: widthContracted,
|
|
25949
|
+
height: heightContracted
|
|
25950
|
+
});
|
|
25951
|
+
const internalCircleBigName = commentNode.findOne(`#${commentNode.id()}-circle-big-name`);
|
|
25952
|
+
internalCircleBigName?.setAttrs({ y: -(heightContracted / 2) });
|
|
25953
|
+
const internalBigName = commentNode.findOne(`#${commentNode.id()}-big-name`);
|
|
25954
|
+
internalBigName?.setAttrs({ y: -(heightContracted - circlePaddingContracted) });
|
|
25955
|
+
const internalUserName = commentNode.findOne(`#${commentNode.id()}-user-name`);
|
|
25956
|
+
internalUserName?.hide();
|
|
25957
|
+
const internalDateName = commentNode.findOne(`#${commentNode.id()}-date`);
|
|
25958
|
+
internalDateName?.hide();
|
|
25959
|
+
const internalComment = commentNode.findOne(`#${commentNode.id()}-comment`);
|
|
25960
|
+
internalComment?.hide();
|
|
25961
|
+
if (this.config.model.getStatus(commentNode.getAttrs()?.commentModel) === WEAVE_COMMENT_STATUS.RESOLVED && commentNode.getAttrs().commentAction !== WEAVE_COMMENT_NODE_ACTION.VIEWING) commentNode.setAttrs({ opacity: .5 });
|
|
25962
|
+
commentNode.setAttrs({ isExpanded: false });
|
|
25963
|
+
if (commentNode.getAttrs().contractedZIndex) {
|
|
25964
|
+
commentNode.zIndex(commentNode.getAttrs().contractedZIndex);
|
|
25965
|
+
commentNode.setAttrs({ contractedZIndex: void 0 });
|
|
25966
|
+
}
|
|
25967
|
+
this.normalizeNodeSize(commentNode);
|
|
25968
|
+
}
|
|
25969
|
+
finishCreateCommentDOM(commentNode) {
|
|
25970
|
+
this.instance.removeEventListener("onZoomChange", this.onZoomChangeHandler(commentNode).bind(this));
|
|
25971
|
+
this.instance.removeEventListener("onStageMove", this.onStageMoveHandler(commentNode).bind(this));
|
|
25972
|
+
const superContainer = document.getElementById(`${commentNode.id()}_supercontainer`);
|
|
25973
|
+
if (!superContainer) return;
|
|
25974
|
+
superContainer.remove();
|
|
25975
|
+
this.commentDomAction = null;
|
|
25976
|
+
this.commentDomVisibleId = null;
|
|
25977
|
+
this.commentDomVisible = false;
|
|
25978
|
+
}
|
|
25979
|
+
setCommentDOMPosition(commentNode, commentAction) {
|
|
25980
|
+
const stage = this.instance.getStage();
|
|
25981
|
+
this.normalizeNodeSize(commentNode);
|
|
25982
|
+
const rect = commentNode.getClientRect({
|
|
25983
|
+
relativeTo: stage,
|
|
25984
|
+
skipShadow: true,
|
|
25985
|
+
skipStroke: true
|
|
25986
|
+
});
|
|
25987
|
+
const scaleX = stage.scaleX();
|
|
25988
|
+
const scaleY = stage.scaleY();
|
|
25989
|
+
const stagePos = stage.position();
|
|
25990
|
+
const widthContracted = this.config.style.contracted.width;
|
|
25991
|
+
let paddingX = 8;
|
|
25992
|
+
let paddingY = 0;
|
|
25993
|
+
if (commentAction === WEAVE_COMMENT_NODE_ACTION.CREATING) {
|
|
25994
|
+
paddingX = this.config.style.creating.paddingX;
|
|
25995
|
+
paddingY = this.config.style.creating.paddingY;
|
|
25996
|
+
}
|
|
25997
|
+
if (commentAction === WEAVE_COMMENT_NODE_ACTION.VIEWING) {
|
|
25998
|
+
paddingX = this.config.style.viewing.paddingX;
|
|
25999
|
+
paddingY = this.config.style.viewing.paddingY;
|
|
26000
|
+
}
|
|
26001
|
+
const x = stagePos.x + rect.x * scaleX + widthContracted + paddingX;
|
|
26002
|
+
const y = stagePos.y + rect.y * scaleY + paddingY;
|
|
26003
|
+
const position = {
|
|
26004
|
+
x,
|
|
26005
|
+
y
|
|
26006
|
+
};
|
|
26007
|
+
const container = document.getElementById(`${commentNode.id()}_container`);
|
|
26008
|
+
if (!container) return;
|
|
26009
|
+
container.style.position = "absolute";
|
|
26010
|
+
container.style.top = position.y + "px";
|
|
26011
|
+
container.style.left = position.x + "px";
|
|
26012
|
+
}
|
|
26013
|
+
createCommentDOM(commentNode) {
|
|
26014
|
+
const stage = this.instance.getStage();
|
|
26015
|
+
const superContainer = document.createElement("div");
|
|
26016
|
+
superContainer.id = `${commentNode.id()}_supercontainer`;
|
|
26017
|
+
superContainer.style.position = "absolute";
|
|
26018
|
+
superContainer.style.top = "0px";
|
|
26019
|
+
superContainer.style.left = "0px";
|
|
26020
|
+
superContainer.style.bottom = "0px";
|
|
26021
|
+
superContainer.style.right = "0px";
|
|
26022
|
+
superContainer.style.overflow = "hidden";
|
|
26023
|
+
superContainer.style.pointerEvents = "none";
|
|
26024
|
+
const container = document.createElement("div");
|
|
26025
|
+
container.id = `${commentNode.id()}_container`;
|
|
26026
|
+
superContainer.appendChild(container);
|
|
26027
|
+
stage.container().appendChild(superContainer);
|
|
26028
|
+
this.setCommentDOMPosition(commentNode, commentNode.getAttrs().commentAction);
|
|
26029
|
+
this.instance.addEventListener("onZoomChange", this.onZoomChangeHandler(commentNode).bind(this));
|
|
26030
|
+
this.instance.addEventListener("onStageMove", this.onStageMoveHandler(commentNode).bind(this));
|
|
26031
|
+
return container;
|
|
26032
|
+
}
|
|
26033
|
+
onZoomChangeHandler = (commentNode) => () => {
|
|
26034
|
+
if (!this.commentDomVisible) return;
|
|
26035
|
+
this.setCommentDOMPosition(commentNode, commentNode.getAttrs().commentAction);
|
|
26036
|
+
};
|
|
26037
|
+
normalizeNodeSize(node) {
|
|
26038
|
+
const abs = node.getAbsoluteScale();
|
|
26039
|
+
node.scale({
|
|
26040
|
+
x: node.scaleX() / abs.x,
|
|
26041
|
+
y: node.scaleY() / abs.y
|
|
26042
|
+
});
|
|
26043
|
+
if (node instanceof konva.default.Group) node.getChildren().forEach((child) => this.normalizeNodeSize(child));
|
|
26044
|
+
}
|
|
26045
|
+
onStageMoveHandler = (commentNode) => () => {
|
|
26046
|
+
if (!this.commentDomVisible) return;
|
|
26047
|
+
this.setCommentDOMPosition(commentNode, commentNode.getAttrs().commentAction);
|
|
26048
|
+
};
|
|
26049
|
+
openCommentDOM(commentNode) {
|
|
26050
|
+
this.contractNode(commentNode);
|
|
26051
|
+
commentNode.setAttrs({ commentAction: WEAVE_COMMENT_NODE_ACTION.VIEWING });
|
|
26052
|
+
this.onUpdate(commentNode, { commentAction: WEAVE_COMMENT_NODE_ACTION.VIEWING });
|
|
26053
|
+
this.commentDomAction = WEAVE_COMMENT_NODE_ACTION.VIEWING;
|
|
26054
|
+
this.commentDomVisibleId = commentNode.id();
|
|
26055
|
+
this.commentDomVisible = true;
|
|
26056
|
+
const commentDomElement = this.createCommentDOM(commentNode);
|
|
26057
|
+
this.instance.emitEvent("onCommentView", { node: commentNode });
|
|
26058
|
+
this.config.viewComment(commentDomElement, commentNode, (nodeF, content, action) => {
|
|
26059
|
+
switch (action) {
|
|
26060
|
+
case WEAVE_COMMENT_VIEW_ACTION.REPLY: break;
|
|
26061
|
+
case WEAVE_COMMENT_VIEW_ACTION.MARK_RESOLVED: {
|
|
26062
|
+
this.finishCreateCommentDOM(nodeF);
|
|
26063
|
+
this.onUpdate(nodeF, { commentModel: this.config.model.setMarkResolved(nodeF.getAttrs().commentModel ?? {}) });
|
|
26064
|
+
break;
|
|
26065
|
+
}
|
|
26066
|
+
case WEAVE_COMMENT_VIEW_ACTION.EDIT: {
|
|
26067
|
+
nodeF.setAttrs({ content });
|
|
26068
|
+
this.onUpdate(nodeF, { commentAction: WEAVE_COMMENT_NODE_ACTION.IDLE });
|
|
26069
|
+
break;
|
|
26070
|
+
}
|
|
26071
|
+
case WEAVE_COMMENT_VIEW_ACTION.DELETE: {
|
|
26072
|
+
this.finishCreateCommentDOM(nodeF);
|
|
26073
|
+
nodeF.destroy();
|
|
26074
|
+
break;
|
|
26075
|
+
}
|
|
26076
|
+
case WEAVE_COMMENT_VIEW_ACTION.CLOSE: {
|
|
26077
|
+
this.finishCreateCommentDOM(nodeF);
|
|
26078
|
+
this.contractNode(nodeF);
|
|
26079
|
+
nodeF.setAttrs({ commentAction: WEAVE_COMMENT_NODE_ACTION.IDLE });
|
|
26080
|
+
this.onUpdate(nodeF, { commentAction: WEAVE_COMMENT_NODE_ACTION.IDLE });
|
|
26081
|
+
this.instance.emitEvent("onCommentFinishCreate", {
|
|
26082
|
+
node: nodeF,
|
|
26083
|
+
action
|
|
26084
|
+
});
|
|
26085
|
+
break;
|
|
26086
|
+
}
|
|
26087
|
+
default: break;
|
|
26088
|
+
}
|
|
26089
|
+
});
|
|
26090
|
+
}
|
|
26091
|
+
closeCommentDOM(commentNode) {
|
|
26092
|
+
this.finishCreateCommentDOM(commentNode);
|
|
26093
|
+
if (commentNode.getAttrs().isHovered) this.expandNode(commentNode);
|
|
26094
|
+
commentNode.setAttrs({ commentAction: WEAVE_COMMENT_NODE_ACTION.IDLE });
|
|
26095
|
+
this.onUpdate(commentNode, { commentAction: WEAVE_COMMENT_NODE_ACTION.IDLE });
|
|
26096
|
+
}
|
|
26097
|
+
afterCreatePersist(commentNode, comment) {
|
|
26098
|
+
commentNode.setAttrs({ commentModel: comment });
|
|
26099
|
+
this.normalizeNodeSize(commentNode);
|
|
26100
|
+
}
|
|
26101
|
+
open(commentNode) {
|
|
26102
|
+
this.openCommentDOM(commentNode);
|
|
26103
|
+
}
|
|
26104
|
+
focusOn(nodeId, duration = .5) {
|
|
26105
|
+
if (this.commentDomVisible && this.commentDomVisibleId) {
|
|
26106
|
+
const commentNode = this.instance.getStage().findOne(`#${this.commentDomVisibleId}`);
|
|
26107
|
+
if (commentNode) {
|
|
26108
|
+
this.closeCommentDOM(commentNode);
|
|
26109
|
+
this.contractNode(commentNode);
|
|
26110
|
+
}
|
|
26111
|
+
}
|
|
26112
|
+
const node = this.instance.getStage().findOne(`#${nodeId}`);
|
|
26113
|
+
if (node) {
|
|
26114
|
+
const stage = this.instance.getStage();
|
|
26115
|
+
const stageWidth = stage.width();
|
|
26116
|
+
const stageHeight = stage.height();
|
|
26117
|
+
const scale = stage.scaleX();
|
|
26118
|
+
const box = node.getClientRect({ relativeTo: stage });
|
|
26119
|
+
const nodeCenterX = box.x + box.width / 2;
|
|
26120
|
+
const nodeCenterY = box.y + box.height / 2;
|
|
26121
|
+
const targetX = stageWidth / 2 - nodeCenterX * scale;
|
|
26122
|
+
const targetY = stageHeight / 2 - nodeCenterY * scale;
|
|
26123
|
+
const tween = new konva.default.Tween({
|
|
26124
|
+
node: stage,
|
|
26125
|
+
duration,
|
|
26126
|
+
x: targetX,
|
|
26127
|
+
y: targetY,
|
|
26128
|
+
easing: konva.default.Easings.EaseInOut,
|
|
26129
|
+
onFinish: () => {
|
|
26130
|
+
this.openCommentDOM(node);
|
|
26131
|
+
}
|
|
26132
|
+
});
|
|
26133
|
+
tween.play();
|
|
26134
|
+
}
|
|
26135
|
+
}
|
|
26136
|
+
isCommentViewing() {
|
|
26137
|
+
return this.commentDomAction === WEAVE_COMMENT_NODE_ACTION.VIEWING && this.commentDomVisible;
|
|
26138
|
+
}
|
|
26139
|
+
isCommentCreating() {
|
|
26140
|
+
return this.commentDomAction === WEAVE_COMMENT_NODE_ACTION.CREATING && this.commentDomVisible;
|
|
26141
|
+
}
|
|
26142
|
+
getCommentId(node) {
|
|
26143
|
+
return this.config.model.getId(node.getAttrs().commentModel);
|
|
26144
|
+
}
|
|
26145
|
+
setShowResolved(show) {
|
|
26146
|
+
this.showResolved = show;
|
|
26147
|
+
}
|
|
26148
|
+
};
|
|
26149
|
+
|
|
25409
26150
|
//#endregion
|
|
25410
26151
|
//#region src/plugins/stage-zoom/constants.ts
|
|
25411
26152
|
const WEAVE_STAGE_ZOOM_TYPE = {
|
|
@@ -25817,7 +26558,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
25817
26558
|
const shadowHost = getTopmostShadowHost(stage.container());
|
|
25818
26559
|
if (shadowHost) elementUnderMouse = shadowHost.elementFromPoint(mouseX, mouseY);
|
|
25819
26560
|
}
|
|
25820
|
-
if (!this.enabled || !performZoom ||
|
|
26561
|
+
if (!this.enabled || !performZoom || this.instance.getClosestParentWithWeaveId(elementUnderMouse) !== stage.container()) return;
|
|
25821
26562
|
e.preventDefault();
|
|
25822
26563
|
const delta = e.deltaY > 0 ? 1 : -1;
|
|
25823
26564
|
this.zoomVelocity += delta;
|
|
@@ -26029,7 +26770,7 @@ var WeaveMoveToolAction = class extends WeaveAction {
|
|
|
26029
26770
|
}
|
|
26030
26771
|
setupEvents() {
|
|
26031
26772
|
const stage = this.instance.getStage();
|
|
26032
|
-
|
|
26773
|
+
window.addEventListener("keydown", (e) => {
|
|
26033
26774
|
if (e.key === "Escape" && this.instance.getActiveAction() === MOVE_TOOL_ACTION_NAME) {
|
|
26034
26775
|
this.cancelAction();
|
|
26035
26776
|
return;
|
|
@@ -26165,6 +26906,10 @@ var WeaveEraserToolAction = class extends WeaveAction {
|
|
|
26165
26906
|
}
|
|
26166
26907
|
setupEvents() {
|
|
26167
26908
|
const stage = this.instance.getStage();
|
|
26909
|
+
stage.on("pointermove", () => {
|
|
26910
|
+
if (this.state === ERASER_TOOL_STATE.IDLE) return;
|
|
26911
|
+
this.setCursor();
|
|
26912
|
+
});
|
|
26168
26913
|
stage.on("pointerclick", () => {
|
|
26169
26914
|
if (!this.erasing) return;
|
|
26170
26915
|
const nodeIntersected = this.instance.pointIntersectsElement();
|
|
@@ -26180,7 +26925,7 @@ var WeaveEraserToolAction = class extends WeaveAction {
|
|
|
26180
26925
|
}
|
|
26181
26926
|
}
|
|
26182
26927
|
});
|
|
26183
|
-
|
|
26928
|
+
window.addEventListener("keydown", (e) => {
|
|
26184
26929
|
if (e.key === "Escape" && this.instance.getActiveAction() === ERASER_TOOL_ACTION_NAME) {
|
|
26185
26930
|
this.cancelAction();
|
|
26186
26931
|
return;
|
|
@@ -26192,9 +26937,8 @@ var WeaveEraserToolAction = class extends WeaveAction {
|
|
|
26192
26937
|
this.state = state;
|
|
26193
26938
|
}
|
|
26194
26939
|
setEraser() {
|
|
26195
|
-
|
|
26196
|
-
|
|
26197
|
-
stage.container().focus();
|
|
26940
|
+
this.setCursor();
|
|
26941
|
+
this.setFocusStage();
|
|
26198
26942
|
this.erasing = true;
|
|
26199
26943
|
this.setState(ERASER_TOOL_STATE.ERASING);
|
|
26200
26944
|
}
|
|
@@ -26223,6 +26967,16 @@ var WeaveEraserToolAction = class extends WeaveAction {
|
|
|
26223
26967
|
}
|
|
26224
26968
|
this.setState(ERASER_TOOL_STATE.IDLE);
|
|
26225
26969
|
}
|
|
26970
|
+
setCursor() {
|
|
26971
|
+
const stage = this.instance.getStage();
|
|
26972
|
+
stage.container().style.cursor = "crosshair";
|
|
26973
|
+
}
|
|
26974
|
+
setFocusStage() {
|
|
26975
|
+
const stage = this.instance.getStage();
|
|
26976
|
+
stage.container().tabIndex = 1;
|
|
26977
|
+
stage.container().blur();
|
|
26978
|
+
stage.container().focus();
|
|
26979
|
+
}
|
|
26226
26980
|
};
|
|
26227
26981
|
|
|
26228
26982
|
//#endregion
|
|
@@ -26269,7 +27023,7 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
26269
27023
|
}
|
|
26270
27024
|
setupEvents() {
|
|
26271
27025
|
const stage = this.instance.getStage();
|
|
26272
|
-
|
|
27026
|
+
window.addEventListener("keydown", (e) => {
|
|
26273
27027
|
if (e.key === "Enter" && this.instance.getActiveAction() === RECTANGLE_TOOL_ACTION_NAME) {
|
|
26274
27028
|
this.cancelAction();
|
|
26275
27029
|
return;
|
|
@@ -26279,6 +27033,10 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
26279
27033
|
return;
|
|
26280
27034
|
}
|
|
26281
27035
|
});
|
|
27036
|
+
stage.on("pointermove", () => {
|
|
27037
|
+
if (this.state === RECTANGLE_TOOL_STATE.IDLE) return;
|
|
27038
|
+
this.setCursor();
|
|
27039
|
+
});
|
|
26282
27040
|
stage.on("pointerdown", (e) => {
|
|
26283
27041
|
this.setTapStart(e);
|
|
26284
27042
|
this.pointers.set(e.evt.pointerId, {
|
|
@@ -26292,6 +27050,8 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
26292
27050
|
if (this.state === RECTANGLE_TOOL_STATE.ADDING) this.handleAdding();
|
|
26293
27051
|
});
|
|
26294
27052
|
stage.on("pointermove", (e) => {
|
|
27053
|
+
if (this.state === RECTANGLE_TOOL_STATE.IDLE) return;
|
|
27054
|
+
this.setCursor();
|
|
26295
27055
|
if (!this.isPressed(e)) return;
|
|
26296
27056
|
if (!this.pointers.has(e.evt.pointerId)) return;
|
|
26297
27057
|
if (this.pointers.size === 2 && this.instance.getActiveAction() === RECTANGLE_TOOL_ACTION_NAME) {
|
|
@@ -26312,9 +27072,8 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
26312
27072
|
this.state = state;
|
|
26313
27073
|
}
|
|
26314
27074
|
addRectangle() {
|
|
26315
|
-
|
|
26316
|
-
|
|
26317
|
-
stage.container().focus();
|
|
27075
|
+
this.setCursor();
|
|
27076
|
+
this.setFocusStage();
|
|
26318
27077
|
this.instance.emitEvent("onAddingRectangle");
|
|
26319
27078
|
this.clickPoint = null;
|
|
26320
27079
|
this.setState(RECTANGLE_TOOL_STATE.ADDING);
|
|
@@ -26417,11 +27176,21 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
26417
27176
|
this.clickPoint = null;
|
|
26418
27177
|
this.setState(RECTANGLE_TOOL_STATE.IDLE);
|
|
26419
27178
|
}
|
|
26420
|
-
|
|
26421
|
-
|
|
26422
|
-
|
|
26423
|
-
|
|
26424
|
-
|
|
27179
|
+
setCursor() {
|
|
27180
|
+
const stage = this.instance.getStage();
|
|
27181
|
+
stage.container().style.cursor = "crosshair";
|
|
27182
|
+
}
|
|
27183
|
+
setFocusStage() {
|
|
27184
|
+
const stage = this.instance.getStage();
|
|
27185
|
+
stage.container().tabIndex = 1;
|
|
27186
|
+
stage.container().blur();
|
|
27187
|
+
stage.container().focus();
|
|
27188
|
+
}
|
|
27189
|
+
};
|
|
27190
|
+
|
|
27191
|
+
//#endregion
|
|
27192
|
+
//#region src/actions/ellipse-tool/constants.ts
|
|
27193
|
+
const ELLIPSE_TOOL_ACTION_NAME = "ellipseTool";
|
|
26425
27194
|
const ELLIPSE_TOOL_STATE = {
|
|
26426
27195
|
["IDLE"]: "idle",
|
|
26427
27196
|
["ADDING"]: "adding",
|
|
@@ -26463,7 +27232,7 @@ var WeaveEllipseToolAction = class extends WeaveAction {
|
|
|
26463
27232
|
}
|
|
26464
27233
|
setupEvents() {
|
|
26465
27234
|
const stage = this.instance.getStage();
|
|
26466
|
-
|
|
27235
|
+
window.addEventListener("keydown", (e) => {
|
|
26467
27236
|
if (e.key === "Enter" && this.instance.getActiveAction() === ELLIPSE_TOOL_ACTION_NAME) {
|
|
26468
27237
|
this.cancelAction();
|
|
26469
27238
|
return;
|
|
@@ -26489,6 +27258,8 @@ var WeaveEllipseToolAction = class extends WeaveAction {
|
|
|
26489
27258
|
}
|
|
26490
27259
|
});
|
|
26491
27260
|
stage.on("pointermove", (e) => {
|
|
27261
|
+
if (this.state === ELLIPSE_TOOL_STATE.IDLE) return;
|
|
27262
|
+
this.setCursor();
|
|
26492
27263
|
if (!this.isPressed(e)) return;
|
|
26493
27264
|
if (!this.pointers.has(e.evt.pointerId)) return;
|
|
26494
27265
|
if (this.pointers.size === 2 && this.instance.getActiveAction() === ELLIPSE_TOOL_ACTION_NAME) {
|
|
@@ -26515,9 +27286,8 @@ var WeaveEllipseToolAction = class extends WeaveAction {
|
|
|
26515
27286
|
this.state = state;
|
|
26516
27287
|
}
|
|
26517
27288
|
addEllipse() {
|
|
26518
|
-
|
|
26519
|
-
|
|
26520
|
-
stage.container().focus();
|
|
27289
|
+
this.setCursor();
|
|
27290
|
+
this.setFocusStage();
|
|
26521
27291
|
this.instance.emitEvent("onAddingEllipse");
|
|
26522
27292
|
this.clickPoint = null;
|
|
26523
27293
|
this.setState(ELLIPSE_TOOL_STATE.ADDING);
|
|
@@ -26623,6 +27393,16 @@ var WeaveEllipseToolAction = class extends WeaveAction {
|
|
|
26623
27393
|
this.clickPoint = null;
|
|
26624
27394
|
this.setState(ELLIPSE_TOOL_STATE.IDLE);
|
|
26625
27395
|
}
|
|
27396
|
+
setCursor() {
|
|
27397
|
+
const stage = this.instance.getStage();
|
|
27398
|
+
stage.container().style.cursor = "crosshair";
|
|
27399
|
+
}
|
|
27400
|
+
setFocusStage() {
|
|
27401
|
+
const stage = this.instance.getStage();
|
|
27402
|
+
stage.container().tabIndex = 1;
|
|
27403
|
+
stage.container().blur();
|
|
27404
|
+
stage.container().focus();
|
|
27405
|
+
}
|
|
26626
27406
|
};
|
|
26627
27407
|
|
|
26628
27408
|
//#endregion
|
|
@@ -26670,7 +27450,7 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
26670
27450
|
}
|
|
26671
27451
|
setupEvents() {
|
|
26672
27452
|
const stage = this.instance.getStage();
|
|
26673
|
-
|
|
27453
|
+
window.addEventListener("keydown", (e) => {
|
|
26674
27454
|
if (e.key === "Enter" && this.instance.getActiveAction() === PEN_TOOL_ACTION_NAME) {
|
|
26675
27455
|
this.cancelAction();
|
|
26676
27456
|
return;
|
|
@@ -26694,6 +27474,8 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
26694
27474
|
if (this.tempMainLineNode && this.state === PEN_TOOL_STATE.ADDING) this.state = PEN_TOOL_STATE.DEFINING_SIZE;
|
|
26695
27475
|
});
|
|
26696
27476
|
stage.on("pointermove", () => {
|
|
27477
|
+
if (this.state === PEN_TOOL_STATE.IDLE) return;
|
|
27478
|
+
this.setCursor();
|
|
26697
27479
|
if (this.pointers.size === 2 && this.instance.getActiveAction() === PEN_TOOL_ACTION_NAME) {
|
|
26698
27480
|
this.state = PEN_TOOL_STATE.ADDING;
|
|
26699
27481
|
return;
|
|
@@ -26710,9 +27492,8 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
26710
27492
|
this.state = state;
|
|
26711
27493
|
}
|
|
26712
27494
|
addLine() {
|
|
26713
|
-
|
|
26714
|
-
|
|
26715
|
-
stage.container().focus();
|
|
27495
|
+
this.setCursor();
|
|
27496
|
+
this.setFocusStage();
|
|
26716
27497
|
this.instance.emitEvent("onAddingPen");
|
|
26717
27498
|
this.tempPoint = void 0;
|
|
26718
27499
|
this.tempNextPoint = void 0;
|
|
@@ -26865,6 +27646,16 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
26865
27646
|
this.clickPoint = null;
|
|
26866
27647
|
this.setState(PEN_TOOL_STATE.IDLE);
|
|
26867
27648
|
}
|
|
27649
|
+
setCursor() {
|
|
27650
|
+
const stage = this.instance.getStage();
|
|
27651
|
+
stage.container().style.cursor = "crosshair";
|
|
27652
|
+
}
|
|
27653
|
+
setFocusStage() {
|
|
27654
|
+
const stage = this.instance.getStage();
|
|
27655
|
+
stage.container().tabIndex = 1;
|
|
27656
|
+
stage.container().blur();
|
|
27657
|
+
stage.container().focus();
|
|
27658
|
+
}
|
|
26868
27659
|
};
|
|
26869
27660
|
|
|
26870
27661
|
//#endregion
|
|
@@ -26910,9 +27701,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
26910
27701
|
}
|
|
26911
27702
|
setupEvents() {
|
|
26912
27703
|
const stage = this.instance.getStage();
|
|
26913
|
-
|
|
26914
|
-
stage.container().focus();
|
|
26915
|
-
stage.container().addEventListener("keydown", (e) => {
|
|
27704
|
+
window.addEventListener("keydown", (e) => {
|
|
26916
27705
|
if (e.key === "Enter" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) {
|
|
26917
27706
|
this.cancelAction();
|
|
26918
27707
|
return;
|
|
@@ -26931,9 +27720,10 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
26931
27720
|
};
|
|
26932
27721
|
stage.on("pointerdown", handlePointerDown);
|
|
26933
27722
|
const handlePointerMove = (e) => {
|
|
27723
|
+
if (this.state === BRUSH_TOOL_STATE.INACTIVE) return;
|
|
27724
|
+
this.setCursor();
|
|
26934
27725
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
26935
27726
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
26936
|
-
stage.container().style.cursor = "crosshair";
|
|
26937
27727
|
const pointPressure = this.getEventPressure(e);
|
|
26938
27728
|
this.handleMovement(pointPressure);
|
|
26939
27729
|
e.evt.stopPropagation();
|
|
@@ -27027,7 +27817,6 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
27027
27817
|
}
|
|
27028
27818
|
}
|
|
27029
27819
|
handleEndStroke() {
|
|
27030
|
-
const stage = this.instance.getStage();
|
|
27031
27820
|
const tempStroke = this.instance.getStage().findOne(`#${this.strokeId}`);
|
|
27032
27821
|
if (tempStroke) {
|
|
27033
27822
|
const nodeHandler = this.instance.getNodeHandler("stroke");
|
|
@@ -27051,9 +27840,8 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
27051
27840
|
if (tempStroke.getAttrs().strokeElements.length >= 3) this.instance.addNode(nodeHandler.serialize(tempStroke), this.container?.getAttrs().id);
|
|
27052
27841
|
}
|
|
27053
27842
|
this.clickPoint = null;
|
|
27054
|
-
|
|
27055
|
-
|
|
27056
|
-
stage.container().focus();
|
|
27843
|
+
this.setCursor();
|
|
27844
|
+
this.setFocusStage();
|
|
27057
27845
|
this.setState(BRUSH_TOOL_STATE.IDLE);
|
|
27058
27846
|
}
|
|
27059
27847
|
}
|
|
@@ -27073,7 +27861,8 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
27073
27861
|
this.props = this.initProps();
|
|
27074
27862
|
this.setState(BRUSH_TOOL_STATE.IDLE);
|
|
27075
27863
|
this.instance.emitEvent("onAddingBrush");
|
|
27076
|
-
|
|
27864
|
+
this.setCursor();
|
|
27865
|
+
this.setFocusStage();
|
|
27077
27866
|
}
|
|
27078
27867
|
cleanup() {
|
|
27079
27868
|
const stage = this.instance.getStage();
|
|
@@ -27092,6 +27881,16 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
27092
27881
|
const zoomPlugin = this.instance.getPlugin("stageZoom");
|
|
27093
27882
|
return zoomPlugin;
|
|
27094
27883
|
}
|
|
27884
|
+
setCursor() {
|
|
27885
|
+
const stage = this.instance.getStage();
|
|
27886
|
+
stage.container().style.cursor = "crosshair";
|
|
27887
|
+
}
|
|
27888
|
+
setFocusStage() {
|
|
27889
|
+
const stage = this.instance.getStage();
|
|
27890
|
+
stage.container().tabIndex = 1;
|
|
27891
|
+
stage.container().blur();
|
|
27892
|
+
stage.container().focus();
|
|
27893
|
+
}
|
|
27095
27894
|
};
|
|
27096
27895
|
|
|
27097
27896
|
//#endregion
|
|
@@ -27127,12 +27926,16 @@ var WeaveTextToolAction = class extends WeaveAction {
|
|
|
27127
27926
|
}
|
|
27128
27927
|
setupEvents() {
|
|
27129
27928
|
const stage = this.instance.getStage();
|
|
27130
|
-
|
|
27929
|
+
window.addEventListener("keydown", (e) => {
|
|
27131
27930
|
if (e.key === "Escape" && this.instance.getActiveAction() === TEXT_TOOL_ACTION_NAME) {
|
|
27132
27931
|
this.cancelAction();
|
|
27133
27932
|
return;
|
|
27134
27933
|
}
|
|
27135
27934
|
});
|
|
27935
|
+
stage.on("pointermove", () => {
|
|
27936
|
+
if (this.state === TEXT_TOOL_STATE.IDLE) return;
|
|
27937
|
+
this.setCursor();
|
|
27938
|
+
});
|
|
27136
27939
|
stage.on("pointerclick", () => {
|
|
27137
27940
|
if (this.state === TEXT_TOOL_STATE.IDLE) return;
|
|
27138
27941
|
if (this.state === TEXT_TOOL_STATE.ADDING) {
|
|
@@ -27146,14 +27949,13 @@ var WeaveTextToolAction = class extends WeaveAction {
|
|
|
27146
27949
|
this.state = state;
|
|
27147
27950
|
}
|
|
27148
27951
|
addText() {
|
|
27149
|
-
const stage = this.instance.getStage();
|
|
27150
27952
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
27151
27953
|
if (selectionPlugin) {
|
|
27152
27954
|
const tr = selectionPlugin.getTransformer();
|
|
27153
27955
|
tr.hide();
|
|
27154
27956
|
}
|
|
27155
|
-
|
|
27156
|
-
|
|
27957
|
+
this.setCursor();
|
|
27958
|
+
this.setFocusStage();
|
|
27157
27959
|
this.instance.emitEvent("onAddingText");
|
|
27158
27960
|
this.clickPoint = null;
|
|
27159
27961
|
this.setState(TEXT_TOOL_STATE.ADDING);
|
|
@@ -27203,6 +28005,16 @@ var WeaveTextToolAction = class extends WeaveAction {
|
|
|
27203
28005
|
this.clickPoint = null;
|
|
27204
28006
|
this.setState(TEXT_TOOL_STATE.IDLE);
|
|
27205
28007
|
}
|
|
28008
|
+
setCursor() {
|
|
28009
|
+
const stage = this.instance.getStage();
|
|
28010
|
+
stage.container().style.cursor = "crosshair";
|
|
28011
|
+
}
|
|
28012
|
+
setFocusStage() {
|
|
28013
|
+
const stage = this.instance.getStage();
|
|
28014
|
+
stage.container().tabIndex = 1;
|
|
28015
|
+
stage.container().blur();
|
|
28016
|
+
stage.container().focus();
|
|
28017
|
+
}
|
|
27206
28018
|
};
|
|
27207
28019
|
|
|
27208
28020
|
//#endregion
|
|
@@ -27250,7 +28062,7 @@ var WeaveStarToolAction = class extends WeaveAction {
|
|
|
27250
28062
|
}
|
|
27251
28063
|
setupEvents() {
|
|
27252
28064
|
const stage = this.instance.getStage();
|
|
27253
|
-
|
|
28065
|
+
window.addEventListener("keydown", (e) => {
|
|
27254
28066
|
if (e.key === "Enter" && this.instance.getActiveAction() === STAR_TOOL_ACTION_NAME) {
|
|
27255
28067
|
this.cancelAction();
|
|
27256
28068
|
return;
|
|
@@ -27276,6 +28088,8 @@ var WeaveStarToolAction = class extends WeaveAction {
|
|
|
27276
28088
|
}
|
|
27277
28089
|
});
|
|
27278
28090
|
stage.on("pointermove", (e) => {
|
|
28091
|
+
if (this.state === STAR_TOOL_STATE.IDLE) return;
|
|
28092
|
+
this.setCursor();
|
|
27279
28093
|
if (!this.isPressed(e)) return;
|
|
27280
28094
|
if (!this.pointers.has(e.evt.pointerId)) return;
|
|
27281
28095
|
if (this.pointers.size === 2 && this.instance.getActiveAction() === STAR_TOOL_ACTION_NAME) {
|
|
@@ -27302,9 +28116,8 @@ var WeaveStarToolAction = class extends WeaveAction {
|
|
|
27302
28116
|
this.state = state;
|
|
27303
28117
|
}
|
|
27304
28118
|
addStar() {
|
|
27305
|
-
|
|
27306
|
-
|
|
27307
|
-
stage.container().focus();
|
|
28119
|
+
this.setCursor();
|
|
28120
|
+
this.setFocusStage();
|
|
27308
28121
|
this.instance.emitEvent("onAddingStar");
|
|
27309
28122
|
this.clickPoint = null;
|
|
27310
28123
|
this.setState(STAR_TOOL_STATE.ADDING);
|
|
@@ -27411,6 +28224,16 @@ var WeaveStarToolAction = class extends WeaveAction {
|
|
|
27411
28224
|
this.clickPoint = null;
|
|
27412
28225
|
this.setState(STAR_TOOL_STATE.IDLE);
|
|
27413
28226
|
}
|
|
28227
|
+
setCursor() {
|
|
28228
|
+
const stage = this.instance.getStage();
|
|
28229
|
+
stage.container().style.cursor = "crosshair";
|
|
28230
|
+
}
|
|
28231
|
+
setFocusStage() {
|
|
28232
|
+
const stage = this.instance.getStage();
|
|
28233
|
+
stage.container().tabIndex = 1;
|
|
28234
|
+
stage.container().blur();
|
|
28235
|
+
stage.container().focus();
|
|
28236
|
+
}
|
|
27414
28237
|
};
|
|
27415
28238
|
|
|
27416
28239
|
//#endregion
|
|
@@ -27463,7 +28286,7 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
27463
28286
|
}
|
|
27464
28287
|
setupEvents() {
|
|
27465
28288
|
const stage = this.instance.getStage();
|
|
27466
|
-
|
|
28289
|
+
window.addEventListener("keydown", (e) => {
|
|
27467
28290
|
if (e.key === "Enter" && this.instance.getActiveAction() === ARROW_TOOL_ACTION_NAME) {
|
|
27468
28291
|
this.cancelAction();
|
|
27469
28292
|
return;
|
|
@@ -27487,6 +28310,8 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
27487
28310
|
if (this.tempMainArrowNode && this.state === ARROW_TOOL_STATE.ADDING) this.state = ARROW_TOOL_STATE.DEFINING_SIZE;
|
|
27488
28311
|
});
|
|
27489
28312
|
stage.on("pointermove", () => {
|
|
28313
|
+
if (this.state === ARROW_TOOL_STATE.IDLE) return;
|
|
28314
|
+
this.setCursor();
|
|
27490
28315
|
if (this.pointers.size === 2 && this.instance.getActiveAction() === ARROW_TOOL_ACTION_NAME) {
|
|
27491
28316
|
this.state = ARROW_TOOL_STATE.ADDING;
|
|
27492
28317
|
return;
|
|
@@ -27503,9 +28328,8 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
27503
28328
|
this.state = state;
|
|
27504
28329
|
}
|
|
27505
28330
|
addArrow() {
|
|
27506
|
-
|
|
27507
|
-
|
|
27508
|
-
stage.container().focus();
|
|
28331
|
+
this.setCursor();
|
|
28332
|
+
this.setFocusStage();
|
|
27509
28333
|
this.instance.emitEvent("onAddingArrow");
|
|
27510
28334
|
this.tempPoint = void 0;
|
|
27511
28335
|
this.tempNextPoint = void 0;
|
|
@@ -27658,6 +28482,16 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
27658
28482
|
this.clickPoint = null;
|
|
27659
28483
|
this.setState(ARROW_TOOL_STATE.IDLE);
|
|
27660
28484
|
}
|
|
28485
|
+
setCursor() {
|
|
28486
|
+
const stage = this.instance.getStage();
|
|
28487
|
+
stage.container().style.cursor = "crosshair";
|
|
28488
|
+
}
|
|
28489
|
+
setFocusStage() {
|
|
28490
|
+
const stage = this.instance.getStage();
|
|
28491
|
+
stage.container().tabIndex = 1;
|
|
28492
|
+
stage.container().blur();
|
|
28493
|
+
stage.container().focus();
|
|
28494
|
+
}
|
|
27661
28495
|
};
|
|
27662
28496
|
|
|
27663
28497
|
//#endregion
|
|
@@ -27703,7 +28537,7 @@ var WeaveRegularPolygonToolAction = class extends WeaveAction {
|
|
|
27703
28537
|
}
|
|
27704
28538
|
setupEvents() {
|
|
27705
28539
|
const stage = this.instance.getStage();
|
|
27706
|
-
|
|
28540
|
+
window.addEventListener("keydown", (e) => {
|
|
27707
28541
|
if (e.key === "Enter" && this.instance.getActiveAction() === REGULAR_POLYGON_TOOL_ACTION_NAME) {
|
|
27708
28542
|
this.cancelAction();
|
|
27709
28543
|
return;
|
|
@@ -27729,6 +28563,8 @@ var WeaveRegularPolygonToolAction = class extends WeaveAction {
|
|
|
27729
28563
|
}
|
|
27730
28564
|
});
|
|
27731
28565
|
stage.on("pointermove", (e) => {
|
|
28566
|
+
if (this.state === REGULAR_POLYGON_TOOL_STATE.IDLE) return;
|
|
28567
|
+
this.setCursor();
|
|
27732
28568
|
if (!this.isPressed(e)) return;
|
|
27733
28569
|
if (!this.pointers.has(e.evt.pointerId)) return;
|
|
27734
28570
|
if (this.pointers.size === 2 && this.instance.getActiveAction() === REGULAR_POLYGON_TOOL_ACTION_NAME) {
|
|
@@ -27755,9 +28591,8 @@ var WeaveRegularPolygonToolAction = class extends WeaveAction {
|
|
|
27755
28591
|
this.state = state;
|
|
27756
28592
|
}
|
|
27757
28593
|
addRegularPolygon() {
|
|
27758
|
-
|
|
27759
|
-
|
|
27760
|
-
stage.container().focus();
|
|
28594
|
+
this.setCursor();
|
|
28595
|
+
this.setFocusStage();
|
|
27761
28596
|
this.instance.emitEvent("onAddingRegularPolygon");
|
|
27762
28597
|
this.clickPoint = null;
|
|
27763
28598
|
this.setState(REGULAR_POLYGON_TOOL_STATE.ADDING);
|
|
@@ -27857,6 +28692,16 @@ var WeaveRegularPolygonToolAction = class extends WeaveAction {
|
|
|
27857
28692
|
this.clickPoint = null;
|
|
27858
28693
|
this.setState(REGULAR_POLYGON_TOOL_STATE.IDLE);
|
|
27859
28694
|
}
|
|
28695
|
+
setCursor() {
|
|
28696
|
+
const stage = this.instance.getStage();
|
|
28697
|
+
stage.container().style.cursor = "crosshair";
|
|
28698
|
+
}
|
|
28699
|
+
setFocusStage() {
|
|
28700
|
+
const stage = this.instance.getStage();
|
|
28701
|
+
stage.container().tabIndex = 1;
|
|
28702
|
+
stage.container().blur();
|
|
28703
|
+
stage.container().focus();
|
|
28704
|
+
}
|
|
27860
28705
|
};
|
|
27861
28706
|
|
|
27862
28707
|
//#endregion
|
|
@@ -27894,12 +28739,16 @@ var WeaveFrameToolAction = class extends WeaveAction {
|
|
|
27894
28739
|
}
|
|
27895
28740
|
setupEvents() {
|
|
27896
28741
|
const stage = this.instance.getStage();
|
|
27897
|
-
|
|
28742
|
+
window.addEventListener("keydown", (e) => {
|
|
27898
28743
|
if (e.key === "Escape" && this.instance.getActiveAction() === FRAME_TOOL_ACTION_NAME) {
|
|
27899
28744
|
this.cancelAction();
|
|
27900
28745
|
return;
|
|
27901
28746
|
}
|
|
27902
28747
|
});
|
|
28748
|
+
stage.on("pointermove", () => {
|
|
28749
|
+
if (this.state === FRAME_TOOL_STATE.IDLE) return;
|
|
28750
|
+
this.setCursor();
|
|
28751
|
+
});
|
|
27903
28752
|
stage.on("pointerclick", () => {
|
|
27904
28753
|
if (this.state === FRAME_TOOL_STATE.IDLE) return;
|
|
27905
28754
|
if (this.state === FRAME_TOOL_STATE.ADDING) {
|
|
@@ -27913,9 +28762,8 @@ var WeaveFrameToolAction = class extends WeaveAction {
|
|
|
27913
28762
|
this.state = state;
|
|
27914
28763
|
}
|
|
27915
28764
|
addFrame() {
|
|
27916
|
-
|
|
27917
|
-
|
|
27918
|
-
stage.container().focus();
|
|
28765
|
+
this.setCursor();
|
|
28766
|
+
this.setFocusStage();
|
|
27919
28767
|
this.instance.emitEvent("onAddingFrame");
|
|
27920
28768
|
this.frameId = null;
|
|
27921
28769
|
this.clickPoint = null;
|
|
@@ -27968,6 +28816,16 @@ var WeaveFrameToolAction = class extends WeaveAction {
|
|
|
27968
28816
|
this.clickPoint = null;
|
|
27969
28817
|
this.setState(FRAME_TOOL_STATE.IDLE);
|
|
27970
28818
|
}
|
|
28819
|
+
setCursor() {
|
|
28820
|
+
const stage = this.instance.getStage();
|
|
28821
|
+
stage.container().style.cursor = "crosshair";
|
|
28822
|
+
}
|
|
28823
|
+
setFocusStage() {
|
|
28824
|
+
const stage = this.instance.getStage();
|
|
28825
|
+
stage.container().tabIndex = 1;
|
|
28826
|
+
stage.container().blur();
|
|
28827
|
+
stage.container().focus();
|
|
28828
|
+
}
|
|
27971
28829
|
};
|
|
27972
28830
|
|
|
27973
28831
|
//#endregion
|
|
@@ -28315,6 +29173,268 @@ var WeaveAlignNodesToolAction = class extends WeaveAction {
|
|
|
28315
29173
|
}
|
|
28316
29174
|
};
|
|
28317
29175
|
|
|
29176
|
+
//#endregion
|
|
29177
|
+
//#region src/actions/comment-tool/constants.ts
|
|
29178
|
+
const WEAVE_COMMENT_TOOL_ACTION_NAME = "commentTool";
|
|
29179
|
+
const WEAVE_COMMENT_TOOL_STATE = {
|
|
29180
|
+
["IDLE"]: "idle",
|
|
29181
|
+
["ADDING"]: "adding",
|
|
29182
|
+
["SELECTED_POSITION"]: "selectedPosition",
|
|
29183
|
+
["CREATING_COMMENT"]: "creatingComment",
|
|
29184
|
+
["ADDED"]: "added"
|
|
29185
|
+
};
|
|
29186
|
+
const WEAVE_COMMENT_TOOL_DEFAULT_CONFIG = { style: { cursor: {
|
|
29187
|
+
add: "crosshair",
|
|
29188
|
+
block: "not-allowed"
|
|
29189
|
+
} } };
|
|
29190
|
+
|
|
29191
|
+
//#endregion
|
|
29192
|
+
//#region src/actions/comment-tool/comment-tool.ts
|
|
29193
|
+
var WeaveCommentToolAction = class extends WeaveAction {
|
|
29194
|
+
initialized = false;
|
|
29195
|
+
onPropsChange = void 0;
|
|
29196
|
+
constructor(params) {
|
|
29197
|
+
super();
|
|
29198
|
+
const { config } = params ?? {};
|
|
29199
|
+
this.config = (0, import_lodash.merge)(WEAVE_COMMENT_TOOL_DEFAULT_CONFIG, config);
|
|
29200
|
+
this.pointers = new Map();
|
|
29201
|
+
this.initialized = false;
|
|
29202
|
+
this.state = WEAVE_COMMENT_TOOL_STATE.IDLE;
|
|
29203
|
+
this.commentId = null;
|
|
29204
|
+
this.clickPoint = null;
|
|
29205
|
+
}
|
|
29206
|
+
getName() {
|
|
29207
|
+
return WEAVE_COMMENT_TOOL_ACTION_NAME;
|
|
29208
|
+
}
|
|
29209
|
+
initProps() {
|
|
29210
|
+
return {
|
|
29211
|
+
colorToken: "#000000",
|
|
29212
|
+
width: 300,
|
|
29213
|
+
height: 300,
|
|
29214
|
+
opacity: 1
|
|
29215
|
+
};
|
|
29216
|
+
}
|
|
29217
|
+
extractCursorUrl(cursor) {
|
|
29218
|
+
const lower = cursor.toLowerCase();
|
|
29219
|
+
const start = lower.indexOf("url(");
|
|
29220
|
+
if (start === -1) return null;
|
|
29221
|
+
let i = start + 4;
|
|
29222
|
+
const len = cursor.length;
|
|
29223
|
+
while (i < len && /\s/.test(cursor[i])) i++;
|
|
29224
|
+
let quote = null;
|
|
29225
|
+
if (cursor[i] === "\"" || cursor[i] === "'") {
|
|
29226
|
+
quote = cursor[i];
|
|
29227
|
+
i++;
|
|
29228
|
+
}
|
|
29229
|
+
let buf = "";
|
|
29230
|
+
for (; i < len; i++) {
|
|
29231
|
+
const ch = cursor[i];
|
|
29232
|
+
if (quote) {
|
|
29233
|
+
if (ch === quote) {
|
|
29234
|
+
i++;
|
|
29235
|
+
break;
|
|
29236
|
+
}
|
|
29237
|
+
buf += ch;
|
|
29238
|
+
} else {
|
|
29239
|
+
if (ch === ")") break;
|
|
29240
|
+
buf += ch;
|
|
29241
|
+
}
|
|
29242
|
+
}
|
|
29243
|
+
const url = buf.trim();
|
|
29244
|
+
if (!url) return null;
|
|
29245
|
+
return this.isAllowedUrl(url) ? url : null;
|
|
29246
|
+
}
|
|
29247
|
+
isAllowedUrl(value) {
|
|
29248
|
+
if (/^https?:\/\//i.test(value)) return true;
|
|
29249
|
+
if (/^(javascript|data|blob|ftp):/i.test(value)) return false;
|
|
29250
|
+
return true;
|
|
29251
|
+
}
|
|
29252
|
+
preloadCursors() {
|
|
29253
|
+
const stage = this.instance.getStage();
|
|
29254
|
+
const cursorUrls = [{
|
|
29255
|
+
src: this.extractCursorUrl(this.config.style.cursor.add) ?? "",
|
|
29256
|
+
cursor: this.config.style.cursor.add
|
|
29257
|
+
}, {
|
|
29258
|
+
src: this.extractCursorUrl(this.config.style.cursor.block) ?? "",
|
|
29259
|
+
cursor: this.config.style.cursor.block
|
|
29260
|
+
}];
|
|
29261
|
+
const actualCursor = stage.container().style.cursor;
|
|
29262
|
+
cursorUrls.forEach(({ src, cursor }) => {
|
|
29263
|
+
const img = new Image();
|
|
29264
|
+
img.onload = () => {
|
|
29265
|
+
stage.container().style.cursor = cursor;
|
|
29266
|
+
stage.container().style.cursor = actualCursor;
|
|
29267
|
+
};
|
|
29268
|
+
img.src = src;
|
|
29269
|
+
});
|
|
29270
|
+
}
|
|
29271
|
+
onInit() {
|
|
29272
|
+
this.preloadCursors();
|
|
29273
|
+
const stage = this.instance.getStage();
|
|
29274
|
+
stage.on("pointermove", () => {
|
|
29275
|
+
if (this.state === WEAVE_COMMENT_TOOL_STATE.IDLE) return;
|
|
29276
|
+
this.setCursor();
|
|
29277
|
+
});
|
|
29278
|
+
this.instance.addEventListener("onCommentView", () => {
|
|
29279
|
+
if (this.instance.getActiveAction() !== WEAVE_COMMENT_TOOL_ACTION_NAME) return;
|
|
29280
|
+
this.setState(WEAVE_COMMENT_TOOL_STATE.ADDING);
|
|
29281
|
+
});
|
|
29282
|
+
this.instance.addEventListener("onCommentFinishCreate", ({ action }) => {
|
|
29283
|
+
if (this.instance.getActiveAction() !== WEAVE_COMMENT_TOOL_ACTION_NAME) return;
|
|
29284
|
+
if (this.state !== WEAVE_COMMENT_TOOL_STATE.CREATING_COMMENT) {
|
|
29285
|
+
this.setCursor();
|
|
29286
|
+
return;
|
|
29287
|
+
}
|
|
29288
|
+
if (action !== "create") {
|
|
29289
|
+
this.setState(WEAVE_COMMENT_TOOL_STATE.ADDING);
|
|
29290
|
+
this.setCursor();
|
|
29291
|
+
return;
|
|
29292
|
+
}
|
|
29293
|
+
this.setCursor();
|
|
29294
|
+
this.commentId = null;
|
|
29295
|
+
this.clickPoint = null;
|
|
29296
|
+
this.setState(WEAVE_COMMENT_TOOL_STATE.ADDING);
|
|
29297
|
+
});
|
|
29298
|
+
}
|
|
29299
|
+
setupEvents() {
|
|
29300
|
+
const stage = this.instance.getStage();
|
|
29301
|
+
const commentNodeHandler = this.instance.getNodeHandler("comment");
|
|
29302
|
+
window.addEventListener("keydown", (e) => {
|
|
29303
|
+
if (this.instance.getActiveAction() !== WEAVE_COMMENT_TOOL_ACTION_NAME) return;
|
|
29304
|
+
if (commentNodeHandler?.isCommentViewing()) return;
|
|
29305
|
+
if (e.key === "Escape" && this.state == WEAVE_COMMENT_TOOL_STATE.ADDING) {
|
|
29306
|
+
this.cancelAction();
|
|
29307
|
+
return;
|
|
29308
|
+
}
|
|
29309
|
+
if (e.key === "Escape" && this.state === WEAVE_COMMENT_TOOL_STATE.CREATING_COMMENT) this.setState(WEAVE_COMMENT_TOOL_STATE.ADDING);
|
|
29310
|
+
});
|
|
29311
|
+
stage.on("pointermove", (e) => {
|
|
29312
|
+
if (this.state === WEAVE_COMMENT_TOOL_STATE.IDLE) return;
|
|
29313
|
+
if (commentNodeHandler?.isCommentViewing()) {
|
|
29314
|
+
this.setCursorBlock();
|
|
29315
|
+
return;
|
|
29316
|
+
}
|
|
29317
|
+
if (commentNodeHandler?.isCommentCreating()) {
|
|
29318
|
+
this.setCursorBlock();
|
|
29319
|
+
return;
|
|
29320
|
+
}
|
|
29321
|
+
const isCommentNode = this.isCommentNode(e.target);
|
|
29322
|
+
if (isCommentNode) return;
|
|
29323
|
+
this.setCursor();
|
|
29324
|
+
});
|
|
29325
|
+
stage.on("pointerdown", (e) => {
|
|
29326
|
+
this.setTapStart(e);
|
|
29327
|
+
this.pointers.set(e.evt.pointerId, {
|
|
29328
|
+
x: e.evt.clientX,
|
|
29329
|
+
y: e.evt.clientY
|
|
29330
|
+
});
|
|
29331
|
+
if (this.state === WEAVE_COMMENT_TOOL_STATE.IDLE) return;
|
|
29332
|
+
if (commentNodeHandler?.isCommentViewing()) return;
|
|
29333
|
+
if (commentNodeHandler?.isCommentCreating()) return;
|
|
29334
|
+
const isCommentNode = this.isCommentNode(e.target);
|
|
29335
|
+
if (!isCommentNode && this.pointers.size === 1 && this.instance.getActiveAction() === WEAVE_COMMENT_TOOL_ACTION_NAME && this.state === WEAVE_COMMENT_TOOL_STATE.ADDING) {
|
|
29336
|
+
this.setCursor();
|
|
29337
|
+
this.setState(WEAVE_COMMENT_TOOL_STATE.SELECTED_POSITION);
|
|
29338
|
+
return;
|
|
29339
|
+
}
|
|
29340
|
+
if (isCommentNode && this.instance.getActiveAction() === WEAVE_COMMENT_TOOL_ACTION_NAME) this.setState(WEAVE_COMMENT_TOOL_STATE.ADDING);
|
|
29341
|
+
});
|
|
29342
|
+
stage.on("pointerup", (e) => {
|
|
29343
|
+
this.pointers.delete(e.evt.pointerId);
|
|
29344
|
+
if (this.state === WEAVE_COMMENT_TOOL_STATE.IDLE) return;
|
|
29345
|
+
if (commentNodeHandler?.isCommentViewing()) return;
|
|
29346
|
+
const isCommentNode = this.isCommentNode(e.target);
|
|
29347
|
+
if (!isCommentNode && this.state === WEAVE_COMMENT_TOOL_STATE.SELECTED_POSITION) {
|
|
29348
|
+
this.handleAdding();
|
|
29349
|
+
e.cancelBubble = true;
|
|
29350
|
+
}
|
|
29351
|
+
if (isCommentNode && this.instance.getActiveAction() === WEAVE_COMMENT_TOOL_ACTION_NAME) this.setState(WEAVE_COMMENT_TOOL_STATE.ADDING);
|
|
29352
|
+
});
|
|
29353
|
+
this.initialized = true;
|
|
29354
|
+
}
|
|
29355
|
+
setState(state) {
|
|
29356
|
+
this.state = state;
|
|
29357
|
+
}
|
|
29358
|
+
enableAddingComment() {
|
|
29359
|
+
const commentNodeHandler = this.instance.getNodeHandler("comment");
|
|
29360
|
+
if (commentNodeHandler) {
|
|
29361
|
+
const commentVisible = commentNodeHandler?.isCommentViewing() || commentNodeHandler?.isCommentCreating();
|
|
29362
|
+
if (commentVisible) this.setCursorBlock();
|
|
29363
|
+
if (!commentVisible) this.setCursor();
|
|
29364
|
+
} else this.setCursor();
|
|
29365
|
+
this.instance.emitEvent("onStartAddingComment");
|
|
29366
|
+
this.commentId = null;
|
|
29367
|
+
this.clickPoint = null;
|
|
29368
|
+
this.setState(WEAVE_COMMENT_TOOL_STATE.ADDING);
|
|
29369
|
+
}
|
|
29370
|
+
handleAdding() {
|
|
29371
|
+
const mainLayer = this.instance.getMainLayer();
|
|
29372
|
+
if (!mainLayer) return;
|
|
29373
|
+
const mousePoint = mainLayer.getRelativePointerPosition();
|
|
29374
|
+
this.clickPoint = mousePoint;
|
|
29375
|
+
this.commentId = v4_default();
|
|
29376
|
+
const nodeHandler = this.instance.getNodeHandler("comment");
|
|
29377
|
+
if (nodeHandler && this.clickPoint) {
|
|
29378
|
+
const node = nodeHandler.onRender({
|
|
29379
|
+
id: this.commentId,
|
|
29380
|
+
x: this.clickPoint.x,
|
|
29381
|
+
y: this.clickPoint.y,
|
|
29382
|
+
userForegroundColor: this.config.getUserForegroundColor(this.config.getUser()),
|
|
29383
|
+
userBackgroundColor: this.config.getUserBackgroundColor(this.config.getUser()),
|
|
29384
|
+
content: "",
|
|
29385
|
+
commentModel: this.config.model.getCreateModel()
|
|
29386
|
+
});
|
|
29387
|
+
node.moveToTop();
|
|
29388
|
+
this.getCommentsLayer()?.add(node);
|
|
29389
|
+
nodeHandler.onUpdate(node, { commentAction: WEAVE_COMMENT_NODE_ACTION.CREATING });
|
|
29390
|
+
this.setState(WEAVE_COMMENT_TOOL_STATE.CREATING_COMMENT);
|
|
29391
|
+
}
|
|
29392
|
+
}
|
|
29393
|
+
trigger(cancelAction) {
|
|
29394
|
+
if (!this.instance) throw new Error("Instance not defined");
|
|
29395
|
+
if (!this.initialized) this.setupEvents();
|
|
29396
|
+
const stage = this.instance.getStage();
|
|
29397
|
+
stage.container().tabIndex = 1;
|
|
29398
|
+
stage.container().focus();
|
|
29399
|
+
this.cancelAction = cancelAction;
|
|
29400
|
+
this.props = this.initProps();
|
|
29401
|
+
this.enableAddingComment();
|
|
29402
|
+
}
|
|
29403
|
+
cleanup() {
|
|
29404
|
+
const stage = this.instance.getStage();
|
|
29405
|
+
stage.container().style.cursor = "default";
|
|
29406
|
+
this.instance.emitEvent("onFinishAddingComment");
|
|
29407
|
+
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
29408
|
+
if (selectionPlugin) {
|
|
29409
|
+
const node = stage.findOne(`#${this.commentId}`);
|
|
29410
|
+
if (node) selectionPlugin.setSelectedNodes([node]);
|
|
29411
|
+
this.instance.triggerAction("selectionTool");
|
|
29412
|
+
}
|
|
29413
|
+
this.commentId = null;
|
|
29414
|
+
this.clickPoint = null;
|
|
29415
|
+
this.setState(WEAVE_COMMENT_TOOL_STATE.IDLE);
|
|
29416
|
+
}
|
|
29417
|
+
getCommentsLayer() {
|
|
29418
|
+
const commentsRendererPlugin = this.instance.getPlugin(WEAVE_COMMENTS_RENDERER_KEY);
|
|
29419
|
+
if (commentsRendererPlugin) return commentsRendererPlugin.getCommentsLayer();
|
|
29420
|
+
return null;
|
|
29421
|
+
}
|
|
29422
|
+
isCommentNode(node) {
|
|
29423
|
+
if (node.getAttrs().name?.includes("comment")) return true;
|
|
29424
|
+
if (node.getParent() && node.getParent() === this.instance.getStage()) return false;
|
|
29425
|
+
if (node.getParent() && node.getParent() !== this.instance.getStage()) return this.isCommentNode(node.getParent());
|
|
29426
|
+
return false;
|
|
29427
|
+
}
|
|
29428
|
+
setCursor() {
|
|
29429
|
+
const stage = this.instance.getStage();
|
|
29430
|
+
stage.container().style.cursor = this.config.style.cursor.add;
|
|
29431
|
+
}
|
|
29432
|
+
setCursorBlock() {
|
|
29433
|
+
const stage = this.instance.getStage();
|
|
29434
|
+
stage.container().style.cursor = this.config.style.cursor.block;
|
|
29435
|
+
}
|
|
29436
|
+
};
|
|
29437
|
+
|
|
28318
29438
|
//#endregion
|
|
28319
29439
|
//#region src/plugins/stage-grid/stage-grid.ts
|
|
28320
29440
|
var WeaveStageGridPlugin = class extends WeavePlugin {
|
|
@@ -28707,7 +29827,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
28707
29827
|
const shadowHost = getTopmostShadowHost(stage.container());
|
|
28708
29828
|
if (shadowHost) elementUnderMouse = shadowHost.elementFromPoint(mouseX, mouseY);
|
|
28709
29829
|
}
|
|
28710
|
-
if (!this.enabled || this.isCtrlOrMetaPressed || e.buttons === 4 || !performPanning ||
|
|
29830
|
+
if (!this.enabled || this.isCtrlOrMetaPressed || e.buttons === 4 || !performPanning || this.instance.getClosestParentWithWeaveId(elementUnderMouse) !== stage.container()) return;
|
|
28711
29831
|
this.getContextMenuPlugin()?.cancelLongPressTimer();
|
|
28712
29832
|
stage.x(stage.x() - e.deltaX);
|
|
28713
29833
|
stage.y(stage.y() - e.deltaY);
|
|
@@ -28766,6 +29886,186 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
28766
29886
|
}
|
|
28767
29887
|
};
|
|
28768
29888
|
|
|
29889
|
+
//#endregion
|
|
29890
|
+
//#region src/plugins/stage-minimap/constants.ts
|
|
29891
|
+
const WEAVE_STAGE_MINIMAP_KEY = "stageMinimap";
|
|
29892
|
+
const STAGE_MINIMAP_DEFAULT_CONFIG = { style: { viewportReference: {
|
|
29893
|
+
fill: "rgba(0,0,0,0.2)",
|
|
29894
|
+
strokeScaleEnabled: false,
|
|
29895
|
+
stroke: "#e12d3c",
|
|
29896
|
+
strokeWidth: 1
|
|
29897
|
+
} } };
|
|
29898
|
+
|
|
29899
|
+
//#endregion
|
|
29900
|
+
//#region src/plugins/stage-minimap/stage-minimap.ts
|
|
29901
|
+
var WeaveStageMinimapPlugin = class extends WeavePlugin {
|
|
29902
|
+
getLayerName = void 0;
|
|
29903
|
+
initLayer = void 0;
|
|
29904
|
+
constructor(params) {
|
|
29905
|
+
super();
|
|
29906
|
+
this.config = (0, import_lodash.merge)(STAGE_MINIMAP_DEFAULT_CONFIG, params.config);
|
|
29907
|
+
this.initialized = false;
|
|
29908
|
+
}
|
|
29909
|
+
getName() {
|
|
29910
|
+
return WEAVE_STAGE_MINIMAP_KEY;
|
|
29911
|
+
}
|
|
29912
|
+
async setupMinimap() {
|
|
29913
|
+
if (this.initialized) return;
|
|
29914
|
+
const container = this.config.getContainer();
|
|
29915
|
+
if (!container) return;
|
|
29916
|
+
let preview = document.getElementById(this.config.id);
|
|
29917
|
+
const windowAspectRatio = window.innerWidth / window.innerHeight;
|
|
29918
|
+
if (!preview) {
|
|
29919
|
+
preview = document.createElement("div");
|
|
29920
|
+
preview.id = this.config.id;
|
|
29921
|
+
preview.style.width = `${this.config.width}px`;
|
|
29922
|
+
preview.style.height = `${Math.round(this.config.width / windowAspectRatio)}px`;
|
|
29923
|
+
container.appendChild(preview);
|
|
29924
|
+
}
|
|
29925
|
+
this.minimapStage = new konva.default.Stage({
|
|
29926
|
+
id: "minimap",
|
|
29927
|
+
container: this.config.id,
|
|
29928
|
+
width: this.config.width,
|
|
29929
|
+
height: Math.round(this.config.width / windowAspectRatio)
|
|
29930
|
+
});
|
|
29931
|
+
const mainLayer = this.instance.getMainLayer();
|
|
29932
|
+
if (mainLayer) {
|
|
29933
|
+
this.minimapLayer = new konva.default.Layer();
|
|
29934
|
+
this.minimapStage.add(this.minimapLayer);
|
|
29935
|
+
this.minimapViewportReference = new konva.default.Rect({
|
|
29936
|
+
...this.config.style.viewportReference,
|
|
29937
|
+
id: "minimapViewportReference",
|
|
29938
|
+
listening: false
|
|
29939
|
+
});
|
|
29940
|
+
this.minimapLayer.add(this.minimapViewportReference);
|
|
29941
|
+
await this.updateMinimapContent();
|
|
29942
|
+
this.updateMinimapViewportReference();
|
|
29943
|
+
}
|
|
29944
|
+
const stage = this.instance.getStage();
|
|
29945
|
+
stage.on("dragmove wheel dragend scaleXChange scaleYChange xChange yChange", () => {
|
|
29946
|
+
this.updateMinimapViewportReference();
|
|
29947
|
+
});
|
|
29948
|
+
this.initialized = true;
|
|
29949
|
+
}
|
|
29950
|
+
async updateMinimapContent() {
|
|
29951
|
+
const stage = this.instance.getStage();
|
|
29952
|
+
const mainLayer = this.instance.getMainLayer();
|
|
29953
|
+
if (!mainLayer) return;
|
|
29954
|
+
const box = mainLayer.getClientRect({
|
|
29955
|
+
skipShadow: true,
|
|
29956
|
+
skipStroke: true
|
|
29957
|
+
});
|
|
29958
|
+
if (box.width === 0 || box.height === 0) return;
|
|
29959
|
+
box.x -= this.config.fitToContentPadding;
|
|
29960
|
+
box.y -= this.config.fitToContentPadding;
|
|
29961
|
+
box.width += this.config.fitToContentPadding * 2;
|
|
29962
|
+
box.height += this.config.fitToContentPadding * 2;
|
|
29963
|
+
this.hideLayers();
|
|
29964
|
+
const pixelRatio = .5;
|
|
29965
|
+
const dataUrl = await stage.toDataURL({
|
|
29966
|
+
x: box.x,
|
|
29967
|
+
y: box.y,
|
|
29968
|
+
width: box.width,
|
|
29969
|
+
height: box.height,
|
|
29970
|
+
pixelRatio
|
|
29971
|
+
});
|
|
29972
|
+
this.showLayers();
|
|
29973
|
+
const img = new window.Image();
|
|
29974
|
+
img.onload = () => {
|
|
29975
|
+
const actualImage = this.minimapStage.findOne("#minimapStageImage");
|
|
29976
|
+
if (actualImage) actualImage.destroy();
|
|
29977
|
+
const fitScale = Math.min(this.minimapStage.width() / (box.width * pixelRatio), this.minimapStage.height() / (box.height * pixelRatio));
|
|
29978
|
+
const centerOffset = {
|
|
29979
|
+
x: (this.minimapStage.width() - box.width * pixelRatio * fitScale) / 2,
|
|
29980
|
+
y: (this.minimapStage.height() - box.height * pixelRatio * fitScale) / 2
|
|
29981
|
+
};
|
|
29982
|
+
this.minimapStageImage = new konva.default.Image({
|
|
29983
|
+
id: "minimapStageImage",
|
|
29984
|
+
image: img,
|
|
29985
|
+
x: centerOffset.x,
|
|
29986
|
+
y: centerOffset.y,
|
|
29987
|
+
scaleX: fitScale,
|
|
29988
|
+
scaleY: fitScale,
|
|
29989
|
+
listening: false
|
|
29990
|
+
});
|
|
29991
|
+
this.minimapLayer.add(this.minimapStageImage);
|
|
29992
|
+
this.minimapStageImage.moveToBottom();
|
|
29993
|
+
};
|
|
29994
|
+
img.src = dataUrl;
|
|
29995
|
+
}
|
|
29996
|
+
updateMinimapViewportReference() {
|
|
29997
|
+
const stage = this.instance.getStage();
|
|
29998
|
+
const mainLayer = this.instance.getMainLayer();
|
|
29999
|
+
if (!mainLayer) return;
|
|
30000
|
+
const box = mainLayer.getClientRect({
|
|
30001
|
+
relativeTo: stage,
|
|
30002
|
+
skipShadow: true,
|
|
30003
|
+
skipStroke: true
|
|
30004
|
+
});
|
|
30005
|
+
if (box.width === 0 || box.height === 0) return;
|
|
30006
|
+
box.x -= this.config.fitToContentPadding;
|
|
30007
|
+
box.y -= this.config.fitToContentPadding;
|
|
30008
|
+
box.width += this.config.fitToContentPadding * 2;
|
|
30009
|
+
box.height += this.config.fitToContentPadding * 2;
|
|
30010
|
+
const fitScale = Math.min(this.minimapStage.width() / box.width, this.minimapStage.height() / box.height);
|
|
30011
|
+
const centerOffset = {
|
|
30012
|
+
x: (this.minimapStage.width() - box.width * fitScale) / 2,
|
|
30013
|
+
y: (this.minimapStage.height() - box.height * fitScale) / 2
|
|
30014
|
+
};
|
|
30015
|
+
const sX = stage.scaleX() ?? 1;
|
|
30016
|
+
const sY = stage.scaleY() ?? 1;
|
|
30017
|
+
const x = stage.x();
|
|
30018
|
+
const y = stage.y();
|
|
30019
|
+
const visible = {
|
|
30020
|
+
x: -x / sX,
|
|
30021
|
+
y: -y / sY,
|
|
30022
|
+
width: stage.width() / sX,
|
|
30023
|
+
height: stage.height() / sY
|
|
30024
|
+
};
|
|
30025
|
+
const realX = (visible.x - box.x) * fitScale + centerOffset.x;
|
|
30026
|
+
const realY = (visible.y - box.y) * fitScale + centerOffset.y;
|
|
30027
|
+
const realWidth = visible.width * fitScale;
|
|
30028
|
+
const realHeight = visible.height * fitScale;
|
|
30029
|
+
this.minimapViewportReference.setAttrs({
|
|
30030
|
+
x: realX,
|
|
30031
|
+
y: realY,
|
|
30032
|
+
width: realWidth,
|
|
30033
|
+
height: realHeight
|
|
30034
|
+
});
|
|
30035
|
+
}
|
|
30036
|
+
onRender() {
|
|
30037
|
+
this.setupMinimap();
|
|
30038
|
+
}
|
|
30039
|
+
onInit() {
|
|
30040
|
+
this.instance.addEventListener("onStateChange", async () => {
|
|
30041
|
+
await this.updateMinimapContent();
|
|
30042
|
+
this.updateMinimapViewportReference();
|
|
30043
|
+
});
|
|
30044
|
+
}
|
|
30045
|
+
showLayers() {
|
|
30046
|
+
const selectionLayer = this.instance.getSelectionLayer();
|
|
30047
|
+
const gridLayer = this.instance.getGridLayer();
|
|
30048
|
+
const commentsLayer = this.instance.getCommentsLayer();
|
|
30049
|
+
if (selectionLayer) selectionLayer.show();
|
|
30050
|
+
if (gridLayer) gridLayer.show();
|
|
30051
|
+
if (commentsLayer) commentsLayer.show();
|
|
30052
|
+
}
|
|
30053
|
+
hideLayers() {
|
|
30054
|
+
const selectionLayer = this.instance.getSelectionLayer();
|
|
30055
|
+
const gridLayer = this.instance.getGridLayer();
|
|
30056
|
+
const commentsLayer = this.instance.getCommentsLayer();
|
|
30057
|
+
if (selectionLayer) selectionLayer.hide();
|
|
30058
|
+
if (gridLayer) gridLayer.hide();
|
|
30059
|
+
if (commentsLayer) commentsLayer.hide();
|
|
30060
|
+
}
|
|
30061
|
+
enable() {
|
|
30062
|
+
this.enabled = true;
|
|
30063
|
+
}
|
|
30064
|
+
disable() {
|
|
30065
|
+
this.enabled = false;
|
|
30066
|
+
}
|
|
30067
|
+
};
|
|
30068
|
+
|
|
28769
30069
|
//#endregion
|
|
28770
30070
|
//#region src/plugins/stage-resize/constants.ts
|
|
28771
30071
|
const WEAVE_STAGE_RESIZE_KEY = "stageResize";
|
|
@@ -30083,6 +31383,95 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
|
|
|
30083
31383
|
}
|
|
30084
31384
|
};
|
|
30085
31385
|
|
|
31386
|
+
//#endregion
|
|
31387
|
+
//#region src/plugins/comments-renderer/comments-renderer.ts
|
|
31388
|
+
var WeaveCommentsRendererPlugin = class extends WeavePlugin {
|
|
31389
|
+
comments = [];
|
|
31390
|
+
getLayerName = void 0;
|
|
31391
|
+
constructor(params) {
|
|
31392
|
+
super();
|
|
31393
|
+
const { config } = params ?? {};
|
|
31394
|
+
this.config = config;
|
|
31395
|
+
this.comments = [];
|
|
31396
|
+
}
|
|
31397
|
+
getName() {
|
|
31398
|
+
return WEAVE_COMMENTS_RENDERER_KEY;
|
|
31399
|
+
}
|
|
31400
|
+
onInit() {}
|
|
31401
|
+
setComments(comments) {
|
|
31402
|
+
this.comments = comments;
|
|
31403
|
+
}
|
|
31404
|
+
initCommentsLayer() {
|
|
31405
|
+
const stage = this.instance.getStage();
|
|
31406
|
+
const commentsLayer = new konva.default.Layer({ id: WEAVE_COMMENTS_TOOL_LAYER_ID });
|
|
31407
|
+
stage.add(commentsLayer);
|
|
31408
|
+
const selectionLayer = this.instance.getSelectionLayer();
|
|
31409
|
+
if (selectionLayer) {
|
|
31410
|
+
const selectionLayerZIndex = selectionLayer.getZIndex();
|
|
31411
|
+
commentsLayer.setZIndex(selectionLayerZIndex + 1);
|
|
31412
|
+
}
|
|
31413
|
+
return commentsLayer;
|
|
31414
|
+
}
|
|
31415
|
+
deleteComments() {
|
|
31416
|
+
const commentsLayer = this.getCommentsLayer();
|
|
31417
|
+
if (commentsLayer) commentsLayer.destroyChildren();
|
|
31418
|
+
}
|
|
31419
|
+
render() {
|
|
31420
|
+
if (!this.isEnabled()) return;
|
|
31421
|
+
this.deleteComments();
|
|
31422
|
+
const resolved = this.comments.filter((comment) => this.config.model.getStatus(comment) === WEAVE_COMMENT_STATUS.RESOLVED);
|
|
31423
|
+
for (let i = 0; i < resolved.length; i++) {
|
|
31424
|
+
const comment = resolved[i];
|
|
31425
|
+
const commentsNodeHandler = this.instance.getNodeHandler(WEAVE_COMMENT_NODE_TYPE);
|
|
31426
|
+
if (commentsNodeHandler) {
|
|
31427
|
+
const node = commentsNodeHandler.onRender({
|
|
31428
|
+
id: this.config.model.getId(comment),
|
|
31429
|
+
x: this.config.model.getPosition(comment).x,
|
|
31430
|
+
y: this.config.model.getPosition(comment).y,
|
|
31431
|
+
userForegroundColor: this.config.getUserForegroundColor(this.config.model.getUser(comment)),
|
|
31432
|
+
userBackgroundColor: this.config.getUserBackgroundColor(this.config.model.getUser(comment)),
|
|
31433
|
+
commentModel: comment
|
|
31434
|
+
});
|
|
31435
|
+
node.moveToBottom();
|
|
31436
|
+
this.getCommentsLayer()?.add(node);
|
|
31437
|
+
commentsNodeHandler.onUpdate(node, { commentAction: "idle" });
|
|
31438
|
+
}
|
|
31439
|
+
}
|
|
31440
|
+
const pending = this.comments.filter((comment) => this.config.model.getStatus(comment) === WEAVE_COMMENT_STATUS.PENDING);
|
|
31441
|
+
for (let i = 0; i < pending.length; i++) {
|
|
31442
|
+
const comment = pending[i];
|
|
31443
|
+
const commentsNodeHandler = this.instance.getNodeHandler(WEAVE_COMMENT_NODE_TYPE);
|
|
31444
|
+
if (commentsNodeHandler) {
|
|
31445
|
+
const node = commentsNodeHandler.onRender({
|
|
31446
|
+
id: this.config.model.getId(comment),
|
|
31447
|
+
x: this.config.model.getPosition(comment).x,
|
|
31448
|
+
y: this.config.model.getPosition(comment).y,
|
|
31449
|
+
userForegroundColor: this.config.getUserForegroundColor(this.config.model.getUser(comment)),
|
|
31450
|
+
userBackgroundColor: this.config.getUserBackgroundColor(this.config.model.getUser(comment)),
|
|
31451
|
+
commentModel: comment
|
|
31452
|
+
});
|
|
31453
|
+
node.moveToTop();
|
|
31454
|
+
this.getCommentsLayer()?.add(node);
|
|
31455
|
+
commentsNodeHandler.onUpdate(node, { commentAction: "idle" });
|
|
31456
|
+
}
|
|
31457
|
+
}
|
|
31458
|
+
}
|
|
31459
|
+
getCommentsLayer() {
|
|
31460
|
+
const commentsLayerId = `#${WEAVE_COMMENTS_TOOL_LAYER_ID}`;
|
|
31461
|
+
const commentLayer = this.instance.getStage()?.findOne(commentsLayerId);
|
|
31462
|
+
if (!commentLayer) return this.initCommentsLayer();
|
|
31463
|
+
return commentLayer;
|
|
31464
|
+
}
|
|
31465
|
+
enable() {
|
|
31466
|
+
this.enabled = true;
|
|
31467
|
+
this.render();
|
|
31468
|
+
}
|
|
31469
|
+
disable() {
|
|
31470
|
+
this.enabled = false;
|
|
31471
|
+
this.deleteComments();
|
|
31472
|
+
}
|
|
31473
|
+
};
|
|
31474
|
+
|
|
30086
31475
|
//#endregion
|
|
30087
31476
|
exports.ALIGN_NODES_ALIGN_TO = ALIGN_NODES_ALIGN_TO
|
|
30088
31477
|
exports.ALIGN_NODES_TOOL_ACTION_NAME = ALIGN_NODES_TOOL_ACTION_NAME
|
|
@@ -30130,6 +31519,17 @@ exports.TEXT_LAYOUT = TEXT_LAYOUT
|
|
|
30130
31519
|
exports.TEXT_TOOL_ACTION_NAME = TEXT_TOOL_ACTION_NAME
|
|
30131
31520
|
exports.TEXT_TOOL_STATE = TEXT_TOOL_STATE
|
|
30132
31521
|
exports.WEAVE_ARROW_NODE_TYPE = WEAVE_ARROW_NODE_TYPE
|
|
31522
|
+
exports.WEAVE_COMMENTS_RENDERER_KEY = WEAVE_COMMENTS_RENDERER_KEY
|
|
31523
|
+
exports.WEAVE_COMMENTS_TOOL_LAYER_ID = WEAVE_COMMENTS_TOOL_LAYER_ID
|
|
31524
|
+
exports.WEAVE_COMMENT_CREATE_ACTION = WEAVE_COMMENT_CREATE_ACTION
|
|
31525
|
+
exports.WEAVE_COMMENT_NODE_ACTION = WEAVE_COMMENT_NODE_ACTION
|
|
31526
|
+
exports.WEAVE_COMMENT_NODE_DEFAULTS = WEAVE_COMMENT_NODE_DEFAULTS
|
|
31527
|
+
exports.WEAVE_COMMENT_NODE_TYPE = WEAVE_COMMENT_NODE_TYPE
|
|
31528
|
+
exports.WEAVE_COMMENT_STATUS = WEAVE_COMMENT_STATUS
|
|
31529
|
+
exports.WEAVE_COMMENT_TOOL_ACTION_NAME = WEAVE_COMMENT_TOOL_ACTION_NAME
|
|
31530
|
+
exports.WEAVE_COMMENT_TOOL_DEFAULT_CONFIG = WEAVE_COMMENT_TOOL_DEFAULT_CONFIG
|
|
31531
|
+
exports.WEAVE_COMMENT_TOOL_STATE = WEAVE_COMMENT_TOOL_STATE
|
|
31532
|
+
exports.WEAVE_COMMENT_VIEW_ACTION = WEAVE_COMMENT_VIEW_ACTION
|
|
30133
31533
|
exports.WEAVE_COPY_PASTE_CONFIG_DEFAULT = WEAVE_COPY_PASTE_CONFIG_DEFAULT
|
|
30134
31534
|
exports.WEAVE_COPY_PASTE_NODES_KEY = WEAVE_COPY_PASTE_NODES_KEY
|
|
30135
31535
|
exports.WEAVE_COPY_PASTE_PASTE_CATCHER_ID = WEAVE_COPY_PASTE_PASTE_CATCHER_ID
|
|
@@ -30182,6 +31582,9 @@ exports.WeaveAlignNodesToolAction = WeaveAlignNodesToolAction
|
|
|
30182
31582
|
exports.WeaveArrowNode = WeaveArrowNode
|
|
30183
31583
|
exports.WeaveArrowToolAction = WeaveArrowToolAction
|
|
30184
31584
|
exports.WeaveBrushToolAction = WeaveBrushToolAction
|
|
31585
|
+
exports.WeaveCommentNode = WeaveCommentNode
|
|
31586
|
+
exports.WeaveCommentToolAction = WeaveCommentToolAction
|
|
31587
|
+
exports.WeaveCommentsRendererPlugin = WeaveCommentsRendererPlugin
|
|
30185
31588
|
exports.WeaveConnectedUsersPlugin = WeaveConnectedUsersPlugin
|
|
30186
31589
|
exports.WeaveContextMenuPlugin = WeaveContextMenuPlugin
|
|
30187
31590
|
exports.WeaveCopyPasteNodesPlugin = WeaveCopyPasteNodesPlugin
|
|
@@ -30213,6 +31616,7 @@ exports.WeaveRegularPolygonToolAction = WeaveRegularPolygonToolAction
|
|
|
30213
31616
|
exports.WeaveSelectionToolAction = WeaveSelectionToolAction
|
|
30214
31617
|
exports.WeaveStageDropAreaPlugin = WeaveStageDropAreaPlugin
|
|
30215
31618
|
exports.WeaveStageGridPlugin = WeaveStageGridPlugin
|
|
31619
|
+
exports.WeaveStageMinimapPlugin = WeaveStageMinimapPlugin
|
|
30216
31620
|
exports.WeaveStageNode = WeaveStageNode
|
|
30217
31621
|
exports.WeaveStagePanningPlugin = WeaveStagePanningPlugin
|
|
30218
31622
|
exports.WeaveStageResizePlugin = WeaveStageResizePlugin
|
|
@@ -30231,7 +31635,6 @@ exports.clearContainerTargets = clearContainerTargets
|
|
|
30231
31635
|
exports.containerOverCursor = containerOverCursor
|
|
30232
31636
|
exports.containsNodeDeep = containsNodeDeep
|
|
30233
31637
|
exports.getBoundingBox = getBoundingBox
|
|
30234
|
-
exports.getClosestParentWithId = getClosestParentWithId
|
|
30235
31638
|
exports.getExportBoundingBox = getExportBoundingBox
|
|
30236
31639
|
exports.getSelectedNodesMetadata = getSelectedNodesMetadata
|
|
30237
31640
|
exports.getTargetAndSkipNodes = getTargetAndSkipNodes
|