@inditextech/weave-sdk 5.0.0-SNAPSHOT.342.1 → 5.0.0-SNAPSHOT.366.1
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.js +1564 -1407
- package/dist/sdk.node.js +1564 -1407
- package/dist/sdk.node.stats.html +1 -1
- package/dist/sdk.stats.html +1 -1
- package/dist/types.d.ts +375 -181
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1564 -1407
- package/dist/types.js.map +1 -1
- package/dist/types.stats.html +1 -1
- package/package.json +7 -6
package/dist/sdk.js
CHANGED
|
@@ -1157,8 +1157,8 @@ var require_isArray = __commonJS({ "../../node_modules/lodash/isArray.js"(export
|
|
|
1157
1157
|
* _.isArray(_.noop);
|
|
1158
1158
|
* // => false
|
|
1159
1159
|
*/
|
|
1160
|
-
var isArray$
|
|
1161
|
-
module.exports = isArray$
|
|
1160
|
+
var isArray$13 = Array.isArray;
|
|
1161
|
+
module.exports = isArray$13;
|
|
1162
1162
|
} });
|
|
1163
1163
|
|
|
1164
1164
|
//#endregion
|
|
@@ -1383,7 +1383,7 @@ var require_isTypedArray = __commonJS({ "../../node_modules/lodash/isTypedArray.
|
|
|
1383
1383
|
//#endregion
|
|
1384
1384
|
//#region ../../node_modules/lodash/isEmpty.js
|
|
1385
1385
|
var require_isEmpty = __commonJS({ "../../node_modules/lodash/isEmpty.js"(exports, module) {
|
|
1386
|
-
var baseKeys$1 = require__baseKeys(), getTag$1 = require__getTag(), isArguments$3 = require_isArguments(), isArray$
|
|
1386
|
+
var baseKeys$1 = require__baseKeys(), getTag$1 = require__getTag(), isArguments$3 = require_isArguments(), isArray$12 = require_isArray(), isArrayLike$6 = require_isArrayLike(), isBuffer$3 = require_isBuffer(), isPrototype$2 = require__isPrototype(), isTypedArray$3 = require_isTypedArray();
|
|
1387
1387
|
/** `Object#toString` result references. */
|
|
1388
1388
|
var mapTag$1 = "[object Map]", setTag$1 = "[object Set]";
|
|
1389
1389
|
/** Used for built-in method references. */
|
|
@@ -1425,7 +1425,7 @@ var require_isEmpty = __commonJS({ "../../node_modules/lodash/isEmpty.js"(export
|
|
|
1425
1425
|
*/
|
|
1426
1426
|
function isEmpty(value) {
|
|
1427
1427
|
if (value == null) return true;
|
|
1428
|
-
if (isArrayLike$6(value) && (isArray$
|
|
1428
|
+
if (isArrayLike$6(value) && (isArray$12(value) || typeof value == "string" || typeof value.splice == "function" || isBuffer$3(value) || isTypedArray$3(value) || isArguments$3(value))) return !value.length;
|
|
1429
1429
|
var tag = getTag$1(value);
|
|
1430
1430
|
if (tag == mapTag$1 || tag == setTag$1) return !value.size;
|
|
1431
1431
|
if (isPrototype$2(value)) return !baseKeys$1(value).length;
|
|
@@ -1752,13 +1752,6 @@ const WEAVE_NODES_SELECTION_DEFAULT_CONFIG = {
|
|
|
1752
1752
|
style: { dragOpacity: .75 }
|
|
1753
1753
|
};
|
|
1754
1754
|
|
|
1755
|
-
//#endregion
|
|
1756
|
-
//#region src/plugins/context-menu/constants.ts
|
|
1757
|
-
const WEAVE_CONTEXT_MENU_PLUGIN_KEY = "contextMenu";
|
|
1758
|
-
const WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT = 4;
|
|
1759
|
-
const WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT = 4;
|
|
1760
|
-
const WEAVE_CONTEXT_MENU_TAP_HOLD_TIMEOUT = 500;
|
|
1761
|
-
|
|
1762
1755
|
//#endregion
|
|
1763
1756
|
//#region ../../node_modules/lodash/_listCacheClear.js
|
|
1764
1757
|
var require__listCacheClear = __commonJS({ "../../node_modules/lodash/_listCacheClear.js"(exports, module) {
|
|
@@ -2865,7 +2858,7 @@ var require__isIndex = __commonJS({ "../../node_modules/lodash/_isIndex.js"(expo
|
|
|
2865
2858
|
//#endregion
|
|
2866
2859
|
//#region ../../node_modules/lodash/_arrayLikeKeys.js
|
|
2867
2860
|
var require__arrayLikeKeys = __commonJS({ "../../node_modules/lodash/_arrayLikeKeys.js"(exports, module) {
|
|
2868
|
-
var baseTimes = require__baseTimes(), isArguments$2 = require_isArguments(), isArray$
|
|
2861
|
+
var baseTimes = require__baseTimes(), isArguments$2 = require_isArguments(), isArray$11 = require_isArray(), isBuffer$2 = require_isBuffer(), isIndex$2 = require__isIndex(), isTypedArray$2 = require_isTypedArray();
|
|
2869
2862
|
/** Used for built-in method references. */
|
|
2870
2863
|
var objectProto$4 = Object.prototype;
|
|
2871
2864
|
/** Used to check objects for own properties. */
|
|
@@ -2879,7 +2872,7 @@ var require__arrayLikeKeys = __commonJS({ "../../node_modules/lodash/_arrayLikeK
|
|
|
2879
2872
|
* @returns {Array} Returns the array of property names.
|
|
2880
2873
|
*/
|
|
2881
2874
|
function arrayLikeKeys$2(value, inherited) {
|
|
2882
|
-
var isArr = isArray$
|
|
2875
|
+
var isArr = isArray$11(value), isArg = !isArr && isArguments$2(value), isBuff = !isArr && !isArg && isBuffer$2(value), isType = !isArr && !isArg && !isBuff && isTypedArray$2(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
|
|
2883
2876
|
for (var key in value) if ((inherited || hasOwnProperty$3.call(value, key)) && !(skipIndexes && (key == "length" || isBuff && (key == "offset" || key == "parent") || isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || isIndex$2(key, length)))) result.push(key);
|
|
2884
2877
|
return result;
|
|
2885
2878
|
}
|
|
@@ -3000,7 +2993,7 @@ var require_toPlainObject = __commonJS({ "../../node_modules/lodash/toPlainObjec
|
|
|
3000
2993
|
//#endregion
|
|
3001
2994
|
//#region ../../node_modules/lodash/_baseMergeDeep.js
|
|
3002
2995
|
var require__baseMergeDeep = __commonJS({ "../../node_modules/lodash/_baseMergeDeep.js"(exports, module) {
|
|
3003
|
-
var assignMergeValue$1 = require__assignMergeValue(), cloneBuffer = require__cloneBuffer(), cloneTypedArray = require__cloneTypedArray(), copyArray = require__copyArray(), initCloneObject = require__initCloneObject(), isArguments$1 = require_isArguments(), isArray$
|
|
2996
|
+
var assignMergeValue$1 = require__assignMergeValue(), cloneBuffer = require__cloneBuffer(), cloneTypedArray = require__cloneTypedArray(), copyArray = require__copyArray(), initCloneObject = require__initCloneObject(), isArguments$1 = require_isArguments(), isArray$10 = require_isArray(), isArrayLikeObject = require_isArrayLikeObject(), isBuffer$1 = require_isBuffer(), isFunction = require_isFunction(), isObject$7 = require_isObject(), isPlainObject = require_isPlainObject(), isTypedArray$1 = require_isTypedArray(), safeGet$1 = require__safeGet(), toPlainObject = require_toPlainObject();
|
|
3004
2997
|
/**
|
|
3005
2998
|
* A specialized version of `baseMerge` for arrays and objects which performs
|
|
3006
2999
|
* deep merges and tracks traversed objects enabling objects with circular
|
|
@@ -3025,9 +3018,9 @@ var require__baseMergeDeep = __commonJS({ "../../node_modules/lodash/_baseMergeD
|
|
|
3025
3018
|
var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack) : void 0;
|
|
3026
3019
|
var isCommon = newValue === void 0;
|
|
3027
3020
|
if (isCommon) {
|
|
3028
|
-
var isArr = isArray$
|
|
3021
|
+
var isArr = isArray$10(srcValue), isBuff = !isArr && isBuffer$1(srcValue), isTyped = !isArr && !isBuff && isTypedArray$1(srcValue);
|
|
3029
3022
|
newValue = srcValue;
|
|
3030
|
-
if (isArr || isBuff || isTyped) if (isArray$
|
|
3023
|
+
if (isArr || isBuff || isTyped) if (isArray$10(objValue)) newValue = objValue;
|
|
3031
3024
|
else if (isArrayLikeObject(objValue)) newValue = copyArray(objValue);
|
|
3032
3025
|
else if (isBuff) {
|
|
3033
3026
|
isCommon = false;
|
|
@@ -3703,223 +3696,6 @@ function isNumber(value) {
|
|
|
3703
3696
|
return typeof value === "number" && !Number.isNaN(value);
|
|
3704
3697
|
}
|
|
3705
3698
|
|
|
3706
|
-
//#endregion
|
|
3707
|
-
//#region src/actions/selection-tool/constants.ts
|
|
3708
|
-
const SELECTION_TOOL_ACTION_NAME = "selectionTool";
|
|
3709
|
-
const SELECTION_TOOL_STATE = {
|
|
3710
|
-
["IDLE"]: "idle",
|
|
3711
|
-
["SELECTING"]: "selection"
|
|
3712
|
-
};
|
|
3713
|
-
|
|
3714
|
-
//#endregion
|
|
3715
|
-
//#region src/plugins/context-menu/context-menu.ts
|
|
3716
|
-
var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
3717
|
-
getLayerName = void 0;
|
|
3718
|
-
initLayer = void 0;
|
|
3719
|
-
constructor(params) {
|
|
3720
|
-
super();
|
|
3721
|
-
const { config } = params ?? {};
|
|
3722
|
-
this.config = {
|
|
3723
|
-
xOffset: WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT,
|
|
3724
|
-
yOffset: WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT,
|
|
3725
|
-
...config
|
|
3726
|
-
};
|
|
3727
|
-
this.initialize();
|
|
3728
|
-
}
|
|
3729
|
-
initialize() {
|
|
3730
|
-
this.timer = null;
|
|
3731
|
-
this.tapHold = false;
|
|
3732
|
-
this.contextMenuVisible = false;
|
|
3733
|
-
this.tapStart = {
|
|
3734
|
-
x: 0,
|
|
3735
|
-
y: 0,
|
|
3736
|
-
time: 0
|
|
3737
|
-
};
|
|
3738
|
-
this.tapHoldTimeout = WEAVE_CONTEXT_MENU_TAP_HOLD_TIMEOUT;
|
|
3739
|
-
this.pointers = {};
|
|
3740
|
-
}
|
|
3741
|
-
getName() {
|
|
3742
|
-
return WEAVE_CONTEXT_MENU_PLUGIN_KEY;
|
|
3743
|
-
}
|
|
3744
|
-
onInit() {
|
|
3745
|
-
this.initEvents();
|
|
3746
|
-
}
|
|
3747
|
-
isPressed(e) {
|
|
3748
|
-
return e.evt.buttons > 0;
|
|
3749
|
-
}
|
|
3750
|
-
setTapStart(e) {
|
|
3751
|
-
this.tapStart = {
|
|
3752
|
-
x: e.evt.clientX,
|
|
3753
|
-
y: e.evt.clientY,
|
|
3754
|
-
time: performance.now()
|
|
3755
|
-
};
|
|
3756
|
-
}
|
|
3757
|
-
triggerContextMenu(eventTarget, target) {
|
|
3758
|
-
const stage = this.instance.getStage();
|
|
3759
|
-
const selectionPlugin = this.getSelectionPlugin();
|
|
3760
|
-
let nodes = [];
|
|
3761
|
-
if (target && target !== stage) {
|
|
3762
|
-
const nodeHandler = this.instance.getNodeHandler(target.getAttrs().nodeType);
|
|
3763
|
-
nodes = [{
|
|
3764
|
-
instance: target,
|
|
3765
|
-
node: nodeHandler?.serialize(target)
|
|
3766
|
-
}];
|
|
3767
|
-
}
|
|
3768
|
-
const eventTargetParent = eventTarget.getParent();
|
|
3769
|
-
if (eventTargetParent instanceof Konva.Transformer) nodes = eventTargetParent.nodes().map((node) => {
|
|
3770
|
-
const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
|
|
3771
|
-
return {
|
|
3772
|
-
instance: node,
|
|
3773
|
-
node: nodeHandler?.serialize(node)
|
|
3774
|
-
};
|
|
3775
|
-
});
|
|
3776
|
-
if (this.contextMenuVisible) this.closeContextMenu();
|
|
3777
|
-
let allNodesMutexUnlocked = true;
|
|
3778
|
-
let allNodesUnlocked = true;
|
|
3779
|
-
const actUser = this.instance.getStore().getUser();
|
|
3780
|
-
for (const node of nodes) {
|
|
3781
|
-
const locked = node.instance.getAttrs().locked;
|
|
3782
|
-
const mutexInfo = this.instance.getNodeMutexLock(node.node?.key ?? "");
|
|
3783
|
-
if (locked) {
|
|
3784
|
-
allNodesUnlocked = false;
|
|
3785
|
-
break;
|
|
3786
|
-
}
|
|
3787
|
-
if (mutexInfo && mutexInfo.user.id !== actUser.id) {
|
|
3788
|
-
allNodesMutexUnlocked = false;
|
|
3789
|
-
break;
|
|
3790
|
-
}
|
|
3791
|
-
}
|
|
3792
|
-
if (!allNodesMutexUnlocked || !allNodesUnlocked) return;
|
|
3793
|
-
if (selectionPlugin && !(eventTarget.getParent() instanceof Konva.Transformer && selectionPlugin.getSelectedNodes().length > 0)) {
|
|
3794
|
-
selectionPlugin.setSelectedNodes([...nodes.map((node) => node.instance)]);
|
|
3795
|
-
selectionPlugin.getHoverTransformer().nodes([]);
|
|
3796
|
-
}
|
|
3797
|
-
const containerRect = stage.container().getBoundingClientRect();
|
|
3798
|
-
const pointerPos = stage.getPointerPosition();
|
|
3799
|
-
const relativeClickPoint = stage.getRelativePointerPosition();
|
|
3800
|
-
if (containerRect && pointerPos && relativeClickPoint && allNodesUnlocked) {
|
|
3801
|
-
const contextMenuPoint = {
|
|
3802
|
-
x: containerRect.left + pointerPos.x + (this.config.xOffset ?? 4),
|
|
3803
|
-
y: containerRect.top + pointerPos.y + (this.config.yOffset ?? 4)
|
|
3804
|
-
};
|
|
3805
|
-
const stageClickPoint = this.getStageClickPoint(pointerPos);
|
|
3806
|
-
this.contextMenuVisible = true;
|
|
3807
|
-
this.instance.emitEvent("onNodeContextMenu", {
|
|
3808
|
-
selection: nodes,
|
|
3809
|
-
contextMenuPoint,
|
|
3810
|
-
clickPoint: pointerPos,
|
|
3811
|
-
stageClickPoint,
|
|
3812
|
-
visible: true
|
|
3813
|
-
});
|
|
3814
|
-
}
|
|
3815
|
-
}
|
|
3816
|
-
closeContextMenu() {
|
|
3817
|
-
this.contextMenuVisible = false;
|
|
3818
|
-
this.instance.emitEvent("onNodeContextMenu", {
|
|
3819
|
-
selection: [],
|
|
3820
|
-
contextMenuPoint: {
|
|
3821
|
-
x: 0,
|
|
3822
|
-
y: 0
|
|
3823
|
-
},
|
|
3824
|
-
clickPoint: {
|
|
3825
|
-
x: 0,
|
|
3826
|
-
y: 0
|
|
3827
|
-
},
|
|
3828
|
-
stageClickPoint: {
|
|
3829
|
-
x: 0,
|
|
3830
|
-
y: 0
|
|
3831
|
-
},
|
|
3832
|
-
visible: false
|
|
3833
|
-
});
|
|
3834
|
-
}
|
|
3835
|
-
getSelectionPlugin() {
|
|
3836
|
-
const selectionPlugin = this.instance.getPlugin(WEAVE_NODES_SELECTION_KEY);
|
|
3837
|
-
return selectionPlugin;
|
|
3838
|
-
}
|
|
3839
|
-
cancelLongPressTimer() {
|
|
3840
|
-
if (this.timer) {
|
|
3841
|
-
clearTimeout(this.timer);
|
|
3842
|
-
this.timer = null;
|
|
3843
|
-
}
|
|
3844
|
-
}
|
|
3845
|
-
initEvents() {
|
|
3846
|
-
const stage = this.instance.getStage();
|
|
3847
|
-
stage.on("pointerdown", (e) => {
|
|
3848
|
-
this.setTapStart(e);
|
|
3849
|
-
this.pointers[e.evt.pointerId] = e.evt;
|
|
3850
|
-
if (e.evt.buttons === 0) return;
|
|
3851
|
-
if (e.evt.pointerType === "mouse") return;
|
|
3852
|
-
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
|
|
3853
|
-
if (this.timer) return;
|
|
3854
|
-
this.timer = setTimeout(() => {
|
|
3855
|
-
this.tapHold = true;
|
|
3856
|
-
const actualActions = this.instance.getActiveAction();
|
|
3857
|
-
if (actualActions !== SELECTION_TOOL_ACTION_NAME) return;
|
|
3858
|
-
delete this.pointers[e.evt.pointerId];
|
|
3859
|
-
const selectedGroup = getTargetedNode(this.instance);
|
|
3860
|
-
this.triggerContextMenu(e.target, selectedGroup);
|
|
3861
|
-
}, this.tapHoldTimeout);
|
|
3862
|
-
});
|
|
3863
|
-
stage.on("pointerup", (e) => {
|
|
3864
|
-
delete this.pointers[e.evt.pointerId];
|
|
3865
|
-
if (e.evt.pointerType === "mouse") return;
|
|
3866
|
-
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length + 1 > 1) return;
|
|
3867
|
-
if (this.timer) {
|
|
3868
|
-
clearTimeout(this.timer);
|
|
3869
|
-
this.timer = null;
|
|
3870
|
-
this.tapHold = false;
|
|
3871
|
-
}
|
|
3872
|
-
});
|
|
3873
|
-
stage.on("contextmenu", (e) => {
|
|
3874
|
-
e.evt.preventDefault();
|
|
3875
|
-
if (!this.enabled) return;
|
|
3876
|
-
const selectedGroup = getTargetedNode(this.instance);
|
|
3877
|
-
this.triggerContextMenu(e.target, selectedGroup);
|
|
3878
|
-
});
|
|
3879
|
-
this.instance.addEventListener("onStageSelection", () => {
|
|
3880
|
-
if (this.tapHold) return;
|
|
3881
|
-
const containerRect = stage.container().getBoundingClientRect();
|
|
3882
|
-
const pointerPos = stage.getPointerPosition();
|
|
3883
|
-
if (containerRect && pointerPos) {
|
|
3884
|
-
const contextMenuPoint = {
|
|
3885
|
-
x: containerRect.left + pointerPos.x + (this.config.xOffset ?? 4),
|
|
3886
|
-
y: containerRect.top + pointerPos.y + (this.config.yOffset ?? 4)
|
|
3887
|
-
};
|
|
3888
|
-
const stageClickPoint = this.getStageClickPoint(pointerPos);
|
|
3889
|
-
this.instance.emitEvent("onNodeContextMenu", {
|
|
3890
|
-
selection: [],
|
|
3891
|
-
contextMenuPoint,
|
|
3892
|
-
clickPoint: pointerPos,
|
|
3893
|
-
stageClickPoint,
|
|
3894
|
-
visible: false
|
|
3895
|
-
});
|
|
3896
|
-
}
|
|
3897
|
-
});
|
|
3898
|
-
}
|
|
3899
|
-
getStageClickPoint(pointerPos) {
|
|
3900
|
-
const stage = this.instance.getStage();
|
|
3901
|
-
const scale = stage.scale();
|
|
3902
|
-
const position = stage.position();
|
|
3903
|
-
const stageClickPoint = {
|
|
3904
|
-
x: (pointerPos.x - position.x) / scale.x,
|
|
3905
|
-
y: (pointerPos.y - position.y) / scale.y
|
|
3906
|
-
};
|
|
3907
|
-
return stageClickPoint;
|
|
3908
|
-
}
|
|
3909
|
-
isContextMenuVisible() {
|
|
3910
|
-
return this.contextMenuVisible;
|
|
3911
|
-
}
|
|
3912
|
-
isTapHold() {
|
|
3913
|
-
return this.tapHold;
|
|
3914
|
-
}
|
|
3915
|
-
enable() {
|
|
3916
|
-
this.enabled = true;
|
|
3917
|
-
}
|
|
3918
|
-
disable() {
|
|
3919
|
-
this.enabled = false;
|
|
3920
|
-
}
|
|
3921
|
-
};
|
|
3922
|
-
|
|
3923
3699
|
//#endregion
|
|
3924
3700
|
//#region src/plugins/users-selection/constants.ts
|
|
3925
3701
|
const WEAVE_USERS_SELECTION_KEY = "usersSelection";
|
|
@@ -4077,7 +3853,7 @@ var require_toNumber = __commonJS({ "../../node_modules/lodash/toNumber.js"(expo
|
|
|
4077
3853
|
var require_debounce = __commonJS({ "../../node_modules/lodash/debounce.js"(exports, module) {
|
|
4078
3854
|
var isObject$3 = require_isObject(), now = require_now(), toNumber = require_toNumber();
|
|
4079
3855
|
/** Error message constants. */
|
|
4080
|
-
var FUNC_ERROR_TEXT$
|
|
3856
|
+
var FUNC_ERROR_TEXT$2 = "Expected a function";
|
|
4081
3857
|
var nativeMax = Math.max, nativeMin = Math.min;
|
|
4082
3858
|
/**
|
|
4083
3859
|
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
@@ -4135,7 +3911,7 @@ var require_debounce = __commonJS({ "../../node_modules/lodash/debounce.js"(expo
|
|
|
4135
3911
|
*/
|
|
4136
3912
|
function debounce$1(func, wait, options) {
|
|
4137
3913
|
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
4138
|
-
if (typeof func != "function") throw new TypeError(FUNC_ERROR_TEXT$
|
|
3914
|
+
if (typeof func != "function") throw new TypeError(FUNC_ERROR_TEXT$2);
|
|
4139
3915
|
wait = toNumber(wait) || 0;
|
|
4140
3916
|
if (isObject$3(options)) {
|
|
4141
3917
|
leading = !!options.leading;
|
|
@@ -4210,7 +3986,7 @@ var require_debounce = __commonJS({ "../../node_modules/lodash/debounce.js"(expo
|
|
|
4210
3986
|
var require_throttle = __commonJS({ "../../node_modules/lodash/throttle.js"(exports, module) {
|
|
4211
3987
|
var debounce = require_debounce(), isObject$2 = require_isObject();
|
|
4212
3988
|
/** Error message constants. */
|
|
4213
|
-
var FUNC_ERROR_TEXT$
|
|
3989
|
+
var FUNC_ERROR_TEXT$1 = "Expected a function";
|
|
4214
3990
|
/**
|
|
4215
3991
|
* Creates a throttled function that only invokes `func` at most once per
|
|
4216
3992
|
* every `wait` milliseconds. The throttled function comes with a `cancel`
|
|
@@ -4257,7 +4033,7 @@ var require_throttle = __commonJS({ "../../node_modules/lodash/throttle.js"(expo
|
|
|
4257
4033
|
*/
|
|
4258
4034
|
function throttle(func, wait, options) {
|
|
4259
4035
|
var leading = true, trailing = true;
|
|
4260
|
-
if (typeof func != "function") throw new TypeError(FUNC_ERROR_TEXT$
|
|
4036
|
+
if (typeof func != "function") throw new TypeError(FUNC_ERROR_TEXT$1);
|
|
4261
4037
|
if (isObject$2(options)) {
|
|
4262
4038
|
leading = "leading" in options ? !!options.leading : leading;
|
|
4263
4039
|
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
@@ -4278,170 +4054,310 @@ const WEAVE_STAGE_NODE_TYPE = "stage";
|
|
|
4278
4054
|
const WEAVE_STAGE_DEFAULT_MODE = "default";
|
|
4279
4055
|
|
|
4280
4056
|
//#endregion
|
|
4281
|
-
//#region src/
|
|
4282
|
-
const
|
|
4283
|
-
const
|
|
4284
|
-
["
|
|
4285
|
-
["
|
|
4057
|
+
//#region src/actions/selection-tool/constants.ts
|
|
4058
|
+
const SELECTION_TOOL_ACTION_NAME = "selectionTool";
|
|
4059
|
+
const SELECTION_TOOL_STATE = {
|
|
4060
|
+
["IDLE"]: "idle",
|
|
4061
|
+
["SELECTING"]: "selection"
|
|
4286
4062
|
};
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4063
|
+
|
|
4064
|
+
//#endregion
|
|
4065
|
+
//#region src/constants.ts
|
|
4066
|
+
const DEFAULT_THROTTLE_MS = 50;
|
|
4067
|
+
const DEFAULT_ADD_NODE_OPTIONS = { emitUserChangeEvent: false };
|
|
4068
|
+
const DEFAULT_UPDATE_NODE_OPTIONS = { emitUserChangeEvent: false };
|
|
4069
|
+
const DEFAULT_REMOVE_NODE_OPTIONS = { emitUserChangeEvent: false };
|
|
4070
|
+
const DEFAULT_MOVE_NODE_OPTIONS = { emitUserChangeEvent: false };
|
|
4071
|
+
const WEAVE_DEFAULT_CONFIG = {
|
|
4072
|
+
behaviors: { axisLockThreshold: 5 },
|
|
4073
|
+
performance: { upscale: { enabled: false } }
|
|
4290
4074
|
};
|
|
4291
|
-
const WEAVE_GRID_DEFAULT_CONFIG = {
|
|
4292
|
-
type: WEAVE_GRID_TYPES.LINES,
|
|
4293
|
-
gridColor: "#b3b3b3",
|
|
4294
|
-
gridMajorColor: "#b3b3b3",
|
|
4295
|
-
gridOriginColor: "#ff746c",
|
|
4296
|
-
gridSize: 20,
|
|
4297
|
-
gridMajorEvery: 10,
|
|
4298
|
-
gridMajorRatio: 2,
|
|
4299
|
-
gridStroke: 1,
|
|
4300
|
-
gridDotType: WEAVE_GRID_DOT_TYPES.CIRCLE,
|
|
4301
|
-
gridDotRadius: 1,
|
|
4302
|
-
gridDotRectSize: 2
|
|
4303
|
-
};
|
|
4304
|
-
const WEAVE_GRID_LAYER_ID = "gridLayer";
|
|
4305
4075
|
|
|
4306
4076
|
//#endregion
|
|
4307
|
-
//#region src/plugins/
|
|
4308
|
-
const
|
|
4309
|
-
const
|
|
4310
|
-
const
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4077
|
+
//#region src/plugins/nodes-selection/gesture-detector.ts
|
|
4078
|
+
const MOVED_DISTANCE = 5;
|
|
4079
|
+
const DOUBLE_TAP_DISTANCE = 10;
|
|
4080
|
+
const DOUBLE_TAP_TIME = 300;
|
|
4081
|
+
/**
|
|
4082
|
+
* Tracks single-tap, double-tap, and drag-move gesture state for the
|
|
4083
|
+
* nodes-selection plugin. Has no dependency on Weave or Konva internals.
|
|
4084
|
+
*/
|
|
4085
|
+
var GestureDetector = class {
|
|
4086
|
+
taps = 0;
|
|
4087
|
+
tapStart = null;
|
|
4088
|
+
previousTap = null;
|
|
4089
|
+
tapTimeoutId = null;
|
|
4090
|
+
isDoubleTap = false;
|
|
4091
|
+
/** Call on every pointerdown to record the tap origin. */
|
|
4092
|
+
setTapStart(clientX, clientY) {
|
|
4093
|
+
this.taps += 1;
|
|
4094
|
+
this.tapStart = {
|
|
4095
|
+
x: clientX,
|
|
4096
|
+
y: clientY,
|
|
4097
|
+
time: performance.now()
|
|
4098
|
+
};
|
|
4099
|
+
}
|
|
4100
|
+
/** Returns true if the pointer moved more than the move threshold since tap start. */
|
|
4101
|
+
checkMoved(clientX, clientY) {
|
|
4102
|
+
if (!this.tapStart) return false;
|
|
4103
|
+
const dist = Math.hypot(clientX - this.tapStart.x, clientY - this.tapStart.y);
|
|
4104
|
+
return dist > MOVED_DISTANCE;
|
|
4105
|
+
}
|
|
4106
|
+
/** Returns true if a drag moved further than the move threshold between two stage positions. */
|
|
4107
|
+
checkMovedDrag(init, actual) {
|
|
4108
|
+
if (!this.tapStart) return false;
|
|
4109
|
+
const dist = Math.hypot(actual.x - init.x, actual.y - init.y);
|
|
4110
|
+
return dist > MOVED_DISTANCE;
|
|
4111
|
+
}
|
|
4112
|
+
/**
|
|
4113
|
+
* Call on pointerup after setTapStart to detect a double-tap.
|
|
4114
|
+
* Sets isDoubleTap = true when two taps occur close in time and space.
|
|
4115
|
+
*/
|
|
4116
|
+
checkDoubleTap(clientX, clientY) {
|
|
4117
|
+
if (!this.previousTap) return;
|
|
4118
|
+
const now$2 = performance.now();
|
|
4119
|
+
const dist = Math.hypot(clientX - this.previousTap.x, clientY - this.previousTap.y);
|
|
4120
|
+
if (this.tapTimeoutId) clearTimeout(this.tapTimeoutId);
|
|
4121
|
+
this.tapTimeoutId = setTimeout(() => {
|
|
4122
|
+
this.taps = 0;
|
|
4123
|
+
}, DOUBLE_TAP_TIME + 5);
|
|
4124
|
+
if (this.taps > 1 && now$2 - this.previousTap.time < DOUBLE_TAP_TIME && dist < DOUBLE_TAP_DISTANCE) {
|
|
4125
|
+
this.taps = 0;
|
|
4126
|
+
this.tapStart = null;
|
|
4127
|
+
this.isDoubleTap = true;
|
|
4128
|
+
}
|
|
4129
|
+
}
|
|
4130
|
+
/** Call after checkDoubleTap on pointerup to advance the tap history. */
|
|
4131
|
+
commitTap() {
|
|
4132
|
+
this.previousTap = this.tapStart;
|
|
4133
|
+
}
|
|
4134
|
+
resetDoubleTap() {
|
|
4135
|
+
this.isDoubleTap = false;
|
|
4136
|
+
}
|
|
4137
|
+
reset() {
|
|
4138
|
+
this.taps = 0;
|
|
4139
|
+
this.tapStart = null;
|
|
4140
|
+
this.previousTap = null;
|
|
4141
|
+
this.isDoubleTap = false;
|
|
4142
|
+
if (this.tapTimeoutId) {
|
|
4143
|
+
clearTimeout(this.tapTimeoutId);
|
|
4144
|
+
this.tapTimeoutId = null;
|
|
4145
|
+
}
|
|
4146
|
+
}
|
|
4335
4147
|
};
|
|
4336
4148
|
|
|
4337
4149
|
//#endregion
|
|
4338
|
-
//#region src/plugins/
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
selectionStart = null;
|
|
4347
|
-
panSpeed = {
|
|
4150
|
+
//#region src/plugins/nodes-selection/edge-panning.ts
|
|
4151
|
+
/**
|
|
4152
|
+
* Handles the rAF-driven auto-pan loop that scrolls the canvas when the
|
|
4153
|
+
* pointer is held near an edge during area selection.
|
|
4154
|
+
*/
|
|
4155
|
+
var EdgePanning = class {
|
|
4156
|
+
panLoopId = null;
|
|
4157
|
+
direction = {
|
|
4348
4158
|
x: 0,
|
|
4349
4159
|
y: 0
|
|
4350
4160
|
};
|
|
4351
|
-
|
|
4161
|
+
speed = {
|
|
4352
4162
|
x: 0,
|
|
4353
4163
|
y: 0
|
|
4354
4164
|
};
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
dragInProcess = false;
|
|
4359
|
-
dragSelectedNodes = [];
|
|
4360
|
-
transformInProcess = false;
|
|
4361
|
-
serializedSelectedNodes = [];
|
|
4362
|
-
constructor(params) {
|
|
4363
|
-
super();
|
|
4364
|
-
this.config = mergeExceptArrays(WEAVE_NODES_SELECTION_DEFAULT_CONFIG, params?.config ?? {});
|
|
4365
|
-
this.initialize();
|
|
4165
|
+
constructor(config, callbacks) {
|
|
4166
|
+
this.config = config;
|
|
4167
|
+
this.callbacks = callbacks;
|
|
4366
4168
|
}
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
"top-center",
|
|
4371
|
-
"top-right",
|
|
4372
|
-
"middle-right",
|
|
4373
|
-
"middle-left",
|
|
4374
|
-
"bottom-left",
|
|
4375
|
-
"bottom-center",
|
|
4376
|
-
"bottom-right"
|
|
4377
|
-
];
|
|
4378
|
-
this.taps = 0;
|
|
4379
|
-
this.isSpaceKeyPressed = false;
|
|
4380
|
-
this.isDoubleTap = false;
|
|
4381
|
-
this.tapStart = null;
|
|
4382
|
-
this.previousTap = null;
|
|
4383
|
-
this.active = false;
|
|
4384
|
-
this.didMove = false;
|
|
4385
|
-
this.selecting = false;
|
|
4386
|
-
this.initialized = false;
|
|
4387
|
-
this.enabled = false;
|
|
4388
|
-
this.pointers = {};
|
|
4389
|
-
this.panLoopId = null;
|
|
4390
|
-
this.tapTimeoutId = null;
|
|
4391
|
-
this.dragSelectedNodes = [];
|
|
4392
|
-
this.dragInProcess = false;
|
|
4169
|
+
/** Start the panning rAF loop. */
|
|
4170
|
+
start() {
|
|
4171
|
+
this.panLoopId = requestAnimationFrame(() => this.loop());
|
|
4393
4172
|
}
|
|
4394
|
-
|
|
4395
|
-
|
|
4173
|
+
/** Stop the panning rAF loop. */
|
|
4174
|
+
stop() {
|
|
4175
|
+
if (this.panLoopId !== null) {
|
|
4176
|
+
cancelAnimationFrame(this.panLoopId);
|
|
4177
|
+
this.panLoopId = null;
|
|
4178
|
+
}
|
|
4396
4179
|
}
|
|
4397
|
-
|
|
4398
|
-
|
|
4180
|
+
/** Reset direction and speed vectors to zero. */
|
|
4181
|
+
reset() {
|
|
4182
|
+
this.direction.x = 0;
|
|
4183
|
+
this.direction.y = 0;
|
|
4184
|
+
this.speed = {
|
|
4185
|
+
x: 0,
|
|
4186
|
+
y: 0
|
|
4187
|
+
};
|
|
4399
4188
|
}
|
|
4400
|
-
|
|
4401
|
-
|
|
4189
|
+
/**
|
|
4190
|
+
* Recalculate pan direction and speed based on current pointer position.
|
|
4191
|
+
* Should be called on every pointermove during area selection.
|
|
4192
|
+
*/
|
|
4193
|
+
updateDirection() {
|
|
4194
|
+
const stage = this.callbacks.getStage();
|
|
4195
|
+
const pos = stage.getPointerPosition();
|
|
4196
|
+
const viewWidth = stage.width();
|
|
4197
|
+
const viewHeight = stage.height();
|
|
4198
|
+
if (!pos) return;
|
|
4199
|
+
const distLeft = pos.x;
|
|
4200
|
+
const distRight = viewWidth - pos.x;
|
|
4201
|
+
const distTop = pos.y;
|
|
4202
|
+
const distBottom = viewHeight - pos.y;
|
|
4203
|
+
this.direction.x = 0;
|
|
4204
|
+
this.direction.y = 0;
|
|
4205
|
+
this.speed = {
|
|
4206
|
+
x: 0,
|
|
4207
|
+
y: 0
|
|
4208
|
+
};
|
|
4209
|
+
if (distLeft < this.config.edgeThreshold) {
|
|
4210
|
+
this.direction.x = 1;
|
|
4211
|
+
this.speed.x = this.getSpeedFromEdge(distLeft);
|
|
4212
|
+
} else if (distRight < this.config.edgeThreshold) {
|
|
4213
|
+
this.direction.x = -1;
|
|
4214
|
+
this.speed.x = this.getSpeedFromEdge(distRight);
|
|
4215
|
+
}
|
|
4216
|
+
if (distTop < this.config.edgeThreshold) {
|
|
4217
|
+
this.direction.y = 1;
|
|
4218
|
+
this.speed.y = this.getSpeedFromEdge(distTop);
|
|
4219
|
+
} else if (distBottom < this.config.edgeThreshold) {
|
|
4220
|
+
this.direction.y = -1;
|
|
4221
|
+
this.speed.y = this.getSpeedFromEdge(distBottom);
|
|
4222
|
+
}
|
|
4402
4223
|
}
|
|
4403
|
-
|
|
4404
|
-
const stage = this.
|
|
4405
|
-
const
|
|
4406
|
-
|
|
4224
|
+
getSpeedFromEdge(distanceFromEdge) {
|
|
4225
|
+
const stage = this.callbacks.getStage();
|
|
4226
|
+
const scaledDistance = distanceFromEdge / stage.scaleX();
|
|
4227
|
+
if (scaledDistance < this.config.edgeThreshold) {
|
|
4228
|
+
const factor = 1 - scaledDistance / this.config.edgeThreshold;
|
|
4229
|
+
return this.config.minScrollSpeed + (this.config.maxScrollSpeed - this.config.minScrollSpeed) * factor;
|
|
4230
|
+
}
|
|
4231
|
+
return 0;
|
|
4407
4232
|
}
|
|
4408
|
-
|
|
4409
|
-
const
|
|
4410
|
-
if (
|
|
4411
|
-
|
|
4233
|
+
loop() {
|
|
4234
|
+
const stage = this.callbacks.getStage();
|
|
4235
|
+
if (this.callbacks.isSelecting() && (this.direction.x !== 0 || this.direction.y !== 0)) {
|
|
4236
|
+
const scale = stage.scaleX();
|
|
4237
|
+
const stepX = (this.speed.x || 0) / scale;
|
|
4238
|
+
const stepY = (this.speed.y || 0) / scale;
|
|
4239
|
+
stage.x(stage.x() + this.direction.x * stepX);
|
|
4240
|
+
stage.y(stage.y() + this.direction.y * stepY);
|
|
4241
|
+
this.callbacks.onTick(this.direction.x * stepX, this.direction.y * stepY);
|
|
4242
|
+
}
|
|
4243
|
+
if (this.callbacks.isSelecting()) this.panLoopId = requestAnimationFrame(() => this.loop());
|
|
4412
4244
|
}
|
|
4413
|
-
|
|
4414
|
-
|
|
4245
|
+
};
|
|
4246
|
+
|
|
4247
|
+
//#endregion
|
|
4248
|
+
//#region src/plugins/nodes-selection/area-selection.ts
|
|
4249
|
+
/**
|
|
4250
|
+
* Manages the visual selection-rectangle drawn while the user drags an area
|
|
4251
|
+
* selection, plus the coordinate state (x1/y1/x2/y2) that tracks its bounds.
|
|
4252
|
+
*/
|
|
4253
|
+
var AreaSelector = class {
|
|
4254
|
+
x1 = 0;
|
|
4255
|
+
y1 = 0;
|
|
4256
|
+
x2 = 0;
|
|
4257
|
+
y2 = 0;
|
|
4258
|
+
/** The stage-space anchor point when area selection started (updated by edge panning). */
|
|
4259
|
+
selectionStart = null;
|
|
4260
|
+
/**
|
|
4261
|
+
* Create and add the selection Konva.Rect to the given layer.
|
|
4262
|
+
* Must be called once during plugin initialisation.
|
|
4263
|
+
*/
|
|
4264
|
+
init(layer, config, scaleX) {
|
|
4265
|
+
this.rect = new Konva.Rect({
|
|
4266
|
+
...config,
|
|
4267
|
+
...config.strokeWidth && { strokeWidth: config.strokeWidth / scaleX },
|
|
4268
|
+
...config.dash && { dash: config.dash.map((d) => d / scaleX) },
|
|
4269
|
+
visible: false,
|
|
4270
|
+
listening: false
|
|
4271
|
+
});
|
|
4272
|
+
layer.add(this.rect);
|
|
4415
4273
|
}
|
|
4416
|
-
|
|
4417
|
-
return this.
|
|
4274
|
+
getRect() {
|
|
4275
|
+
return this.rect;
|
|
4418
4276
|
}
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
return selected;
|
|
4277
|
+
/** Returns the screen-space bounding box of the selection rectangle. */
|
|
4278
|
+
getBox() {
|
|
4279
|
+
return this.rect.getClientRect();
|
|
4423
4280
|
}
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4281
|
+
/** Set the anchor corner when area selection begins. */
|
|
4282
|
+
setStart(x, y) {
|
|
4283
|
+
this.x1 = x;
|
|
4284
|
+
this.y1 = y;
|
|
4285
|
+
this.x2 = x;
|
|
4286
|
+
this.y2 = y;
|
|
4287
|
+
this.selectionStart = {
|
|
4288
|
+
x,
|
|
4289
|
+
y
|
|
4290
|
+
};
|
|
4291
|
+
}
|
|
4292
|
+
/**
|
|
4293
|
+
* Adjust stroke and dash to compensate for stage scale, reset dimensions.
|
|
4294
|
+
* Call when area selection starts so the rect looks pixel-perfect at any zoom.
|
|
4295
|
+
*/
|
|
4296
|
+
resetForScale(scaleX, config) {
|
|
4297
|
+
this.rect.strokeWidth(config.strokeWidth / scaleX);
|
|
4298
|
+
this.rect.dash(config.dash?.map((d) => d / scaleX) ?? []);
|
|
4299
|
+
this.rect.width(0);
|
|
4300
|
+
this.rect.height(0);
|
|
4301
|
+
}
|
|
4302
|
+
/**
|
|
4303
|
+
* Recalculate x2/y2 from the current pointer position and repaint the rect.
|
|
4304
|
+
* @param selectNone — Callback that clears the transformer selection; called
|
|
4305
|
+
* before updating the rect so previously selected nodes are deselected.
|
|
4306
|
+
*/
|
|
4307
|
+
update(stage, selectNone) {
|
|
4308
|
+
this.x2 = stage.getRelativePointerPosition()?.x ?? 0;
|
|
4309
|
+
this.y2 = stage.getRelativePointerPosition()?.y ?? 0;
|
|
4310
|
+
selectNone();
|
|
4311
|
+
this.rect.setAttrs({
|
|
4312
|
+
visible: true,
|
|
4313
|
+
x: Math.min(this.x1, this.x2),
|
|
4314
|
+
y: Math.min(this.y1, this.y2),
|
|
4315
|
+
width: Math.abs(this.x2 - this.x1),
|
|
4316
|
+
height: Math.abs(this.y2 - this.y1)
|
|
4435
4317
|
});
|
|
4436
|
-
|
|
4437
|
-
|
|
4318
|
+
}
|
|
4319
|
+
hide() {
|
|
4320
|
+
this.rect.setAttrs({
|
|
4321
|
+
width: 0,
|
|
4322
|
+
height: 0,
|
|
4323
|
+
visible: false
|
|
4324
|
+
});
|
|
4325
|
+
}
|
|
4326
|
+
};
|
|
4327
|
+
|
|
4328
|
+
//#endregion
|
|
4329
|
+
//#region src/plugins/nodes-selection/transformer-controller.ts
|
|
4330
|
+
/**
|
|
4331
|
+
* Creates and owns both Konva.Transformer instances (selection + hover) and
|
|
4332
|
+
* registers all transformer-level event handlers. Business-logic callbacks are
|
|
4333
|
+
* injected to keep this class decoupled from WeaveNodesSelectionPlugin internals.
|
|
4334
|
+
*/
|
|
4335
|
+
var TransformerController = class {
|
|
4336
|
+
dragInProcess = false;
|
|
4337
|
+
transformInProcess = false;
|
|
4338
|
+
didMove = false;
|
|
4339
|
+
initialPos = null;
|
|
4340
|
+
originalNodes = {};
|
|
4341
|
+
originalContainers = {};
|
|
4342
|
+
currentDragSelectedNodes = [];
|
|
4343
|
+
/** Mirrors the previous transformer node list for undo/redo handling. */
|
|
4344
|
+
prevSelectedNodes = [];
|
|
4345
|
+
constructor(instance, config, gesture, callbacks) {
|
|
4346
|
+
this.instance = instance;
|
|
4347
|
+
this.config = config;
|
|
4348
|
+
this.gesture = gesture;
|
|
4349
|
+
this.callbacks = callbacks;
|
|
4350
|
+
}
|
|
4351
|
+
/** Create transformers, add to layer, and register all events. Must be called once during onInit. */
|
|
4352
|
+
setup(layer) {
|
|
4353
|
+
this.tr = new Konva.Transformer({
|
|
4438
4354
|
id: "selectionTransformer",
|
|
4439
4355
|
...this.config.selection,
|
|
4440
4356
|
listening: true,
|
|
4441
4357
|
shouldOverdrawWholeArea: true
|
|
4442
4358
|
});
|
|
4443
|
-
|
|
4444
|
-
|
|
4359
|
+
layer.add(this.tr);
|
|
4360
|
+
this.trHover = new Konva.Transformer({
|
|
4445
4361
|
id: "hoverTransformer",
|
|
4446
4362
|
...this.config.hover,
|
|
4447
4363
|
ignoreStroke: true,
|
|
@@ -4450,94 +4366,87 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
4450
4366
|
enabledAnchors: [],
|
|
4451
4367
|
listening: false
|
|
4452
4368
|
});
|
|
4453
|
-
|
|
4369
|
+
layer.add(this.trHover);
|
|
4370
|
+
this.registerStagePointerMove();
|
|
4371
|
+
this.registerTransformerEvents();
|
|
4372
|
+
this.registerInstanceEvents();
|
|
4373
|
+
}
|
|
4374
|
+
getTransformer() {
|
|
4375
|
+
return this.tr;
|
|
4376
|
+
}
|
|
4377
|
+
getHoverTransformer() {
|
|
4378
|
+
return this.trHover;
|
|
4379
|
+
}
|
|
4380
|
+
isDragging() {
|
|
4381
|
+
return this.dragInProcess;
|
|
4382
|
+
}
|
|
4383
|
+
isTransforming() {
|
|
4384
|
+
return this.transformInProcess;
|
|
4385
|
+
}
|
|
4386
|
+
getStage() {
|
|
4387
|
+
return this.instance.getStage();
|
|
4388
|
+
}
|
|
4389
|
+
registerStagePointerMove() {
|
|
4390
|
+
const stage = this.getStage();
|
|
4454
4391
|
const handlePointerMoveInit = () => {
|
|
4455
4392
|
if (this.dragInProcess) return;
|
|
4456
|
-
if (tr.nodes().length === 1 && tr.nodes()[0].getAttrs().isContainerPrincipal) {
|
|
4393
|
+
if (this.tr.nodes().length === 1 && this.tr.nodes()[0].getAttrs().isContainerPrincipal) {
|
|
4457
4394
|
const pos = stage.getPointerPosition();
|
|
4458
4395
|
if (!pos) return;
|
|
4459
4396
|
const shapeUnder = stage.getIntersection(pos);
|
|
4460
4397
|
if (!shapeUnder) {
|
|
4461
|
-
tr.setAttrs({ listening: true });
|
|
4462
|
-
tr.forceUpdate();
|
|
4398
|
+
this.tr.setAttrs({ listening: true });
|
|
4399
|
+
this.tr.forceUpdate();
|
|
4463
4400
|
}
|
|
4464
|
-
if (shapeUnder && tr.getChildren().includes(shapeUnder) && shapeUnder.name() === "back") {
|
|
4465
|
-
tr.setAttrs({ listening: false });
|
|
4466
|
-
tr.forceUpdate();
|
|
4401
|
+
if (shapeUnder && this.tr.getChildren().includes(shapeUnder) && shapeUnder.name() === "back") {
|
|
4402
|
+
this.tr.setAttrs({ listening: false });
|
|
4403
|
+
this.tr.forceUpdate();
|
|
4467
4404
|
}
|
|
4468
|
-
if (shapeUnder && tr.nodes()[0].getChildren().includes(shapeUnder)) {
|
|
4469
|
-
tr.setAttrs({ listening: false });
|
|
4470
|
-
tr.forceUpdate();
|
|
4405
|
+
if (shapeUnder && this.tr.nodes()[0].getChildren().includes(shapeUnder)) {
|
|
4406
|
+
this.tr.setAttrs({ listening: false });
|
|
4407
|
+
this.tr.forceUpdate();
|
|
4471
4408
|
}
|
|
4472
|
-
if (shapeUnder && !tr.getChildren().includes(shapeUnder) && tr.nodes()[0].getChildren().includes(shapeUnder)) {
|
|
4473
|
-
tr.setAttrs({ listening: true });
|
|
4474
|
-
tr.forceUpdate();
|
|
4409
|
+
if (shapeUnder && !this.tr.getChildren().includes(shapeUnder) && this.tr.nodes()[0].getChildren().includes(shapeUnder)) {
|
|
4410
|
+
this.tr.setAttrs({ listening: true });
|
|
4411
|
+
this.tr.forceUpdate();
|
|
4475
4412
|
}
|
|
4476
4413
|
}
|
|
4477
4414
|
};
|
|
4478
4415
|
stage.on("pointermove", (0, import_throttle.default)(handlePointerMoveInit, DEFAULT_THROTTLE_MS));
|
|
4479
|
-
|
|
4416
|
+
}
|
|
4417
|
+
registerTransformerEvents() {
|
|
4418
|
+
const stage = this.getStage();
|
|
4419
|
+
let nodeHovered = void 0;
|
|
4420
|
+
this.tr.on("transformstart", (e) => {
|
|
4480
4421
|
this.transformInProcess = true;
|
|
4481
|
-
this.triggerSelectedNodesEvent();
|
|
4482
|
-
const selectedNodes
|
|
4483
|
-
for (const node of selectedNodes
|
|
4484
|
-
if (
|
|
4485
|
-
nodeIds: selectedNodes
|
|
4422
|
+
this.callbacks.triggerSelectedNodesEvent();
|
|
4423
|
+
const selectedNodes = this.tr.nodes();
|
|
4424
|
+
for (const node of selectedNodes) node.handleMouseout(e);
|
|
4425
|
+
if (selectedNodes.length > 1) this.instance.setMutexLock({
|
|
4426
|
+
nodeIds: selectedNodes.map((node) => node.id()),
|
|
4486
4427
|
operation: "nodes-transform"
|
|
4487
4428
|
});
|
|
4488
4429
|
this.instance.getHooks().callHook("weave:onTransformerTransformStart", {
|
|
4489
4430
|
e,
|
|
4490
|
-
nodes: selectedNodes
|
|
4431
|
+
nodes: selectedNodes
|
|
4491
4432
|
});
|
|
4492
4433
|
});
|
|
4493
|
-
let nodeHovered = void 0;
|
|
4494
|
-
tr.on("mousemove", (e) => {
|
|
4495
|
-
if (this.dragInProcess) return;
|
|
4496
|
-
const pointerPos = stage.getPointerPosition();
|
|
4497
|
-
if (!pointerPos) return;
|
|
4498
|
-
this.disable();
|
|
4499
|
-
const shape = stage.getIntersection(pointerPos);
|
|
4500
|
-
this.enable();
|
|
4501
|
-
if (shape) {
|
|
4502
|
-
const targetNode = this.instance.getInstanceRecursive(shape);
|
|
4503
|
-
if (targetNode && targetNode !== nodeHovered) {
|
|
4504
|
-
this.instance.getStage().handleMouseover(e);
|
|
4505
|
-
nodeHovered?.handleMouseout?.(e);
|
|
4506
|
-
targetNode?.handleMouseover?.(e);
|
|
4507
|
-
nodeHovered = targetNode;
|
|
4508
|
-
}
|
|
4509
|
-
targetNode?.handleMouseover?.(e);
|
|
4510
|
-
} else nodeHovered?.handleMouseout?.(e);
|
|
4511
|
-
});
|
|
4512
|
-
tr.on("mouseover", () => {
|
|
4513
|
-
const nodesSelected = tr.nodes();
|
|
4514
|
-
if (nodesSelected.length > 1) stage.container().style.cursor = "grab";
|
|
4515
|
-
});
|
|
4516
|
-
tr.on("mouseout", (e) => {
|
|
4517
|
-
this.instance.getStage().handleMouseover?.(e);
|
|
4518
|
-
nodeHovered = void 0;
|
|
4519
|
-
});
|
|
4520
|
-
window.addEventListener("mouseout", (e) => {
|
|
4521
|
-
if (nodeHovered) {
|
|
4522
|
-
nodeHovered.handleMouseout?.(e);
|
|
4523
|
-
nodeHovered = void 0;
|
|
4524
|
-
}
|
|
4525
|
-
this.instance.getStage().handleMouseover?.(e);
|
|
4526
|
-
}, { signal: this.instance.getEventsController()?.signal });
|
|
4527
4434
|
const handleTransform = (e) => {
|
|
4528
|
-
const moved = this.checkMoved(e);
|
|
4529
|
-
if (moved) this.getContextMenuPlugin()?.cancelLongPressTimer();
|
|
4530
|
-
this.triggerSelectedNodesEvent();
|
|
4435
|
+
const moved = this.gesture.checkMoved(e.evt.clientX, e.evt.clientY);
|
|
4436
|
+
if (moved) this.callbacks.getContextMenuPlugin()?.cancelLongPressTimer();
|
|
4437
|
+
this.callbacks.triggerSelectedNodesEvent();
|
|
4438
|
+
const selectedNodes = this.tr.nodes();
|
|
4531
4439
|
this.instance.getHooks().callHook("weave:onTransformerTransform", {
|
|
4532
4440
|
e,
|
|
4533
4441
|
nodes: selectedNodes
|
|
4534
4442
|
});
|
|
4535
|
-
|
|
4536
|
-
|
|
4443
|
+
const usersPresence = this.callbacks.getUsersPresencePlugin();
|
|
4444
|
+
if (usersPresence) {
|
|
4445
|
+
for (const node of this.tr.nodes()) {
|
|
4537
4446
|
let parentId = node.getParent()?.id() ?? "";
|
|
4538
4447
|
const parent = node.getParent();
|
|
4539
4448
|
if (parent?.getAttrs().nodeId) parentId = parent.getAttrs().nodeId;
|
|
4540
|
-
|
|
4449
|
+
usersPresence.setPresence(node.id(), parentId, {
|
|
4541
4450
|
x: node.x(),
|
|
4542
4451
|
y: node.y(),
|
|
4543
4452
|
width: node.width(),
|
|
@@ -4548,65 +4457,92 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
4548
4457
|
strokeScaleEnabled: false
|
|
4549
4458
|
}, false);
|
|
4550
4459
|
}
|
|
4551
|
-
|
|
4460
|
+
usersPresence.forceSendPresence();
|
|
4552
4461
|
}
|
|
4553
4462
|
};
|
|
4554
|
-
tr.on("transform", (0, import_throttle.default)(handleTransform, DEFAULT_THROTTLE_MS));
|
|
4555
|
-
tr.on("transformend", (e) => {
|
|
4463
|
+
this.tr.on("transform", (0, import_throttle.default)(handleTransform, DEFAULT_THROTTLE_MS));
|
|
4464
|
+
this.tr.on("transformend", (e) => {
|
|
4556
4465
|
this.transformInProcess = false;
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
for (const node of selectedNodes
|
|
4466
|
+
const selectedNodes = this.tr.nodes();
|
|
4467
|
+
if (selectedNodes.length > 1) this.instance.releaseMutexLock();
|
|
4468
|
+
for (const node of selectedNodes) {
|
|
4560
4469
|
node.handleDeselectNode();
|
|
4561
4470
|
node.handleSelectNode();
|
|
4562
4471
|
}
|
|
4563
|
-
tr.forceUpdate();
|
|
4564
|
-
this.triggerSelectedNodesEvent();
|
|
4472
|
+
this.tr.forceUpdate();
|
|
4473
|
+
this.callbacks.triggerSelectedNodesEvent();
|
|
4565
4474
|
this.instance.getHooks().callHook("weave:onTransformerTransformEnd", {
|
|
4566
4475
|
e,
|
|
4567
|
-
nodes: selectedNodes
|
|
4476
|
+
nodes: selectedNodes
|
|
4568
4477
|
});
|
|
4569
4478
|
});
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4479
|
+
this.tr.on("mousemove", (e) => {
|
|
4480
|
+
if (this.dragInProcess) return;
|
|
4481
|
+
const pointerPos = stage.getPointerPosition();
|
|
4482
|
+
if (!pointerPos) return;
|
|
4483
|
+
this.callbacks.disablePlugin();
|
|
4484
|
+
const shape = stage.getIntersection(pointerPos);
|
|
4485
|
+
this.callbacks.enablePlugin();
|
|
4486
|
+
if (shape) {
|
|
4487
|
+
const targetNode = this.instance.getInstanceRecursive(shape);
|
|
4488
|
+
if (targetNode && targetNode !== nodeHovered) {
|
|
4489
|
+
this.instance.getStage().handleMouseover(e);
|
|
4490
|
+
nodeHovered?.handleMouseout?.(e);
|
|
4491
|
+
targetNode?.handleMouseover?.(e);
|
|
4492
|
+
nodeHovered = targetNode;
|
|
4493
|
+
}
|
|
4494
|
+
targetNode?.handleMouseover?.(e);
|
|
4495
|
+
} else nodeHovered?.handleMouseout?.(e);
|
|
4496
|
+
});
|
|
4497
|
+
this.tr.on("mouseover", () => {
|
|
4498
|
+
const nodesSelected = this.tr.nodes();
|
|
4499
|
+
if (nodesSelected.length > 1) stage.container().style.cursor = "grab";
|
|
4500
|
+
});
|
|
4501
|
+
this.tr.on("mouseout", (e) => {
|
|
4502
|
+
this.instance.getStage().handleMouseover?.(e);
|
|
4503
|
+
nodeHovered = void 0;
|
|
4504
|
+
});
|
|
4505
|
+
window.addEventListener("mouseout", (e) => {
|
|
4506
|
+
if (nodeHovered) {
|
|
4507
|
+
nodeHovered.handleMouseout?.(e);
|
|
4508
|
+
nodeHovered = void 0;
|
|
4509
|
+
}
|
|
4510
|
+
this.instance.getStage().handleMouseover?.(e);
|
|
4511
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
4512
|
+
this.tr.on("dragstart", (e) => {
|
|
4575
4513
|
this.dragInProcess = true;
|
|
4576
4514
|
if (!e?.evt) return;
|
|
4577
|
-
|
|
4578
|
-
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
4515
|
+
const isWheelMousePressed = e.evt?.button === 1;
|
|
4579
4516
|
const mainLayer = this.instance.getMainLayer();
|
|
4580
4517
|
if (!mainLayer) return;
|
|
4581
|
-
initialPos = {
|
|
4518
|
+
this.initialPos = {
|
|
4582
4519
|
x: e.target.x(),
|
|
4583
4520
|
y: e.target.y()
|
|
4584
4521
|
};
|
|
4585
4522
|
this.didMove = false;
|
|
4586
|
-
|
|
4587
|
-
this.
|
|
4588
|
-
this.
|
|
4589
|
-
selectedNodes = tr.nodes();
|
|
4523
|
+
this.callbacks.saveDragSelectedNodes();
|
|
4524
|
+
this.callbacks.setNodesOpacityOnDrag();
|
|
4525
|
+
this.currentDragSelectedNodes = this.tr.nodes();
|
|
4590
4526
|
if (isWheelMousePressed) {
|
|
4591
4527
|
e.cancelBubble = true;
|
|
4592
4528
|
e.target.stopDrag();
|
|
4593
4529
|
return;
|
|
4594
4530
|
}
|
|
4595
|
-
for (const node of
|
|
4531
|
+
for (const node of this.currentDragSelectedNodes) {
|
|
4596
4532
|
const originalNode = node.clone();
|
|
4597
4533
|
let originalContainer = node.getParent();
|
|
4598
|
-
if (originalContainer?.getAttrs().nodeId) originalContainer = stage
|
|
4599
|
-
originalNodes[node.getAttrs().id ?? ""] = originalNode;
|
|
4600
|
-
originalContainers[node.getAttrs().id ?? ""] = originalContainer;
|
|
4534
|
+
if (originalContainer?.getAttrs().nodeId) originalContainer = stage.findOne(`#${originalContainer.getAttrs().nodeId}`);
|
|
4535
|
+
this.originalNodes[node.getAttrs().id ?? ""] = originalNode;
|
|
4536
|
+
this.originalContainers[node.getAttrs().id ?? ""] = originalContainer;
|
|
4601
4537
|
}
|
|
4602
4538
|
e.cancelBubble = true;
|
|
4603
4539
|
this.instance.getHooks().callHook("weave:onTransformerDragStart", {
|
|
4604
4540
|
e,
|
|
4605
|
-
nodes:
|
|
4541
|
+
nodes: this.currentDragSelectedNodes
|
|
4606
4542
|
});
|
|
4607
|
-
tr.forceUpdate();
|
|
4608
|
-
if (
|
|
4609
|
-
nodeIds:
|
|
4543
|
+
this.tr.forceUpdate();
|
|
4544
|
+
if (this.currentDragSelectedNodes.length > 1) this.instance.setMutexLock({
|
|
4545
|
+
nodeIds: this.currentDragSelectedNodes.map((node) => node.id()),
|
|
4610
4546
|
operation: "nodes-drag"
|
|
4611
4547
|
});
|
|
4612
4548
|
});
|
|
@@ -4615,16 +4551,15 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
4615
4551
|
x: e.target.x(),
|
|
4616
4552
|
y: e.target.y()
|
|
4617
4553
|
};
|
|
4618
|
-
|
|
4619
|
-
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
4554
|
+
const isWheelMousePressed = e.evt?.button === 1;
|
|
4620
4555
|
e.cancelBubble = true;
|
|
4621
4556
|
this.instance.getHooks().callHook("weave:onTransformerDragMove", {
|
|
4622
4557
|
e,
|
|
4623
|
-
nodes:
|
|
4558
|
+
nodes: this.currentDragSelectedNodes
|
|
4624
4559
|
});
|
|
4625
|
-
if (initialPos) {
|
|
4626
|
-
const moved = this.checkMovedDrag(initialPos, actualPos);
|
|
4627
|
-
if (moved) this.getContextMenuPlugin()?.cancelLongPressTimer();
|
|
4560
|
+
if (this.initialPos) {
|
|
4561
|
+
const moved = this.gesture.checkMovedDrag(this.initialPos, actualPos);
|
|
4562
|
+
if (moved) this.callbacks.getContextMenuPlugin()?.cancelLongPressTimer();
|
|
4628
4563
|
}
|
|
4629
4564
|
if (isWheelMousePressed) {
|
|
4630
4565
|
e.cancelBubble = true;
|
|
@@ -4633,64 +4568,65 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
4633
4568
|
}
|
|
4634
4569
|
this.didMove = true;
|
|
4635
4570
|
let selectionContainsFrames = false;
|
|
4636
|
-
for (let i = 0; i <
|
|
4637
|
-
const node =
|
|
4571
|
+
for (let i = 0; i < this.currentDragSelectedNodes.length; i++) {
|
|
4572
|
+
const node = this.currentDragSelectedNodes[i];
|
|
4638
4573
|
selectionContainsFrames = selectionContainsFrames || hasFrames(node);
|
|
4639
4574
|
node.updatePosition(node.getAbsolutePosition());
|
|
4640
4575
|
}
|
|
4641
|
-
if (
|
|
4642
|
-
originalNodes = {};
|
|
4643
|
-
originalContainers = {};
|
|
4576
|
+
if (this.currentDragSelectedNodes.length === 1) {
|
|
4577
|
+
this.originalNodes = {};
|
|
4578
|
+
this.originalContainers = {};
|
|
4644
4579
|
}
|
|
4645
|
-
if (this.isSelecting() &&
|
|
4580
|
+
if (this.callbacks.isSelecting() && this.currentDragSelectedNodes.length > 1) {
|
|
4646
4581
|
clearContainerTargets(this.instance);
|
|
4647
|
-
const layerToMove = containerOverCursor(this.instance,
|
|
4648
|
-
|
|
4649
|
-
|
|
4582
|
+
const layerToMove = containerOverCursor(this.instance, this.currentDragSelectedNodes);
|
|
4583
|
+
const usersPresence = this.callbacks.getUsersPresencePlugin();
|
|
4584
|
+
if (usersPresence && this.dragInProcess) {
|
|
4585
|
+
for (const node of this.currentDragSelectedNodes) {
|
|
4650
4586
|
let parentId = node.getParent()?.id() ?? "";
|
|
4651
4587
|
const parent = node.getParent();
|
|
4652
4588
|
if (parent?.getAttrs().nodeId) parentId = parent.getAttrs().nodeId;
|
|
4653
|
-
|
|
4589
|
+
usersPresence.setPresence(node.id(), parentId, {
|
|
4654
4590
|
x: node.x(),
|
|
4655
4591
|
y: node.y()
|
|
4656
4592
|
}, false);
|
|
4657
4593
|
}
|
|
4658
|
-
|
|
4594
|
+
usersPresence.forceSendPresence();
|
|
4659
4595
|
}
|
|
4660
4596
|
if (layerToMove && !selectionContainsFrames) layerToMove.fire(WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, { bubbles: true });
|
|
4661
4597
|
}
|
|
4662
|
-
tr.forceUpdate();
|
|
4598
|
+
this.tr.forceUpdate();
|
|
4663
4599
|
};
|
|
4664
|
-
tr.on("dragmove", handleDragMove);
|
|
4665
|
-
tr.on("dragend", (e) => {
|
|
4600
|
+
this.tr.on("dragmove", handleDragMove);
|
|
4601
|
+
this.tr.on("dragend", (e) => {
|
|
4666
4602
|
this.dragInProcess = false;
|
|
4667
4603
|
const mainLayer = this.instance.getMainLayer();
|
|
4668
4604
|
if (!mainLayer) return;
|
|
4669
4605
|
this.instance.getSelectionLayer()?.hitGraphEnabled(true);
|
|
4670
4606
|
this.instance.getMainLayer()?.hitGraphEnabled(true);
|
|
4671
4607
|
if (!this.didMove) return;
|
|
4672
|
-
if (
|
|
4608
|
+
if (this.currentDragSelectedNodes.length > 1) this.instance.releaseMutexLock();
|
|
4673
4609
|
e.cancelBubble = true;
|
|
4674
4610
|
this.instance.getHooks().callHook("weave:onTransformerDragEnd", {
|
|
4675
4611
|
e,
|
|
4676
|
-
nodes:
|
|
4612
|
+
nodes: this.currentDragSelectedNodes
|
|
4677
4613
|
});
|
|
4678
4614
|
this.instance.getCloningManager().cleanupClones();
|
|
4679
|
-
this.getStagePanningPlugin()?.cleanupEdgeMoveIntervals();
|
|
4615
|
+
this.callbacks.getStagePanningPlugin()?.cleanupEdgeMoveIntervals();
|
|
4680
4616
|
let selectionContainsFrames = false;
|
|
4681
|
-
for (let i = 0; i <
|
|
4682
|
-
const node =
|
|
4617
|
+
for (let i = 0; i < this.currentDragSelectedNodes.length; i++) {
|
|
4618
|
+
const node = this.currentDragSelectedNodes[i];
|
|
4683
4619
|
selectionContainsFrames = selectionContainsFrames || hasFrames(node);
|
|
4684
4620
|
node.updatePosition(node.getAbsolutePosition());
|
|
4685
4621
|
}
|
|
4686
|
-
if (this.isSelecting() &&
|
|
4622
|
+
if (this.callbacks.isSelecting() && this.currentDragSelectedNodes.length > 1) {
|
|
4687
4623
|
const toSelect = [];
|
|
4688
4624
|
const toUpdate = [];
|
|
4689
4625
|
this.instance.stateTransactional(() => {
|
|
4690
4626
|
const actualCursor = stage.container().style.cursor;
|
|
4691
4627
|
stage.container().style.cursor = "wait";
|
|
4692
4628
|
clearContainerTargets(this.instance);
|
|
4693
|
-
const layerToMove = containerOverCursor(this.instance,
|
|
4629
|
+
const layerToMove = containerOverCursor(this.instance, this.currentDragSelectedNodes);
|
|
4694
4630
|
const nodeUpdate = (node) => {
|
|
4695
4631
|
const isLockedToContainer = node.getAttrs().lockToContainer;
|
|
4696
4632
|
let moved = false;
|
|
@@ -4700,18 +4636,17 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
4700
4636
|
let containerToMove = this.instance.getMainLayer();
|
|
4701
4637
|
if (layerToMove) containerToMove = layerToMove;
|
|
4702
4638
|
if (containerToMove && !selectionContainsFrames) {
|
|
4703
|
-
moved = moveNodeToContainerNT(this.instance, node, containerToMove, originalNodes[node.getAttrs().id ?? ""], originalContainers[node.getAttrs().id ?? ""]);
|
|
4639
|
+
moved = moveNodeToContainerNT(this.instance, node, containerToMove, this.originalNodes[node.getAttrs().id ?? ""], this.originalContainers[node.getAttrs().id ?? ""]);
|
|
4704
4640
|
if (moved) this.instance.emitEvent("onNodeChangedContainer", {
|
|
4705
|
-
originalNode: originalNodes[node.getAttrs().id ?? ""] ?? null,
|
|
4706
|
-
originalContainer: originalContainers[node.getAttrs().id ?? ""] ?? null,
|
|
4641
|
+
originalNode: this.originalNodes[node.getAttrs().id ?? ""] ?? null,
|
|
4642
|
+
originalContainer: this.originalContainers[node.getAttrs().id ?? ""] ?? null,
|
|
4707
4643
|
newNode: node,
|
|
4708
4644
|
newContainer: containerToMove
|
|
4709
4645
|
});
|
|
4710
4646
|
toSelect.push(node.getAttrs().id ?? "");
|
|
4711
|
-
delete originalNodes[node.getAttrs().id ?? ""];
|
|
4712
|
-
delete originalContainers[node.getAttrs().id ?? ""];
|
|
4713
|
-
} else
|
|
4714
|
-
else toSelect.push(node.getAttrs().id ?? "");
|
|
4647
|
+
delete this.originalNodes[node.getAttrs().id ?? ""];
|
|
4648
|
+
delete this.originalContainers[node.getAttrs().id ?? ""];
|
|
4649
|
+
} else toSelect.push(node.getAttrs().nodeId ? node.getAttrs().nodeId ?? "" : node.getAttrs().id ?? "");
|
|
4715
4650
|
if (containerToMove) containerToMove.fire(WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, { bubbles: true });
|
|
4716
4651
|
if (!nodeHandler) return;
|
|
4717
4652
|
if (!moved) toUpdate.push(nodeHandler.serialize(node));
|
|
@@ -4723,14 +4658,14 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
4723
4658
|
toUpdate.push(nodeHandler.serialize(node));
|
|
4724
4659
|
}
|
|
4725
4660
|
};
|
|
4726
|
-
for (let i = 0; i <
|
|
4661
|
+
for (let i = 0; i < this.currentDragSelectedNodes.length; i++) nodeUpdate(this.currentDragSelectedNodes[i]);
|
|
4727
4662
|
if (toUpdate.length > 0) this.instance.updateNodesNT(toUpdate);
|
|
4728
4663
|
this.instance.runPhaseHooks("onMoveNodesToContainer", (hook) => {
|
|
4729
|
-
hook({ nodes:
|
|
4664
|
+
hook({ nodes: this.currentDragSelectedNodes });
|
|
4730
4665
|
});
|
|
4731
4666
|
stage.container().style.cursor = actualCursor;
|
|
4732
4667
|
});
|
|
4733
|
-
for (const node of
|
|
4668
|
+
for (const node of this.currentDragSelectedNodes) node.setAttrs({ isCloned: void 0 });
|
|
4734
4669
|
const finalSelectedNodes = [];
|
|
4735
4670
|
for (const nodeId of toSelect) {
|
|
4736
4671
|
const actNode = this.instance.getStage().findOne(`#${nodeId}`);
|
|
@@ -4740,17 +4675,19 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
4740
4675
|
actNode.handleSelectNode();
|
|
4741
4676
|
}
|
|
4742
4677
|
}
|
|
4743
|
-
this.setSelectedNodes(finalSelectedNodes);
|
|
4744
|
-
tr.forceUpdate();
|
|
4678
|
+
this.callbacks.setSelectedNodes(finalSelectedNodes);
|
|
4679
|
+
this.tr.forceUpdate();
|
|
4745
4680
|
}
|
|
4746
4681
|
});
|
|
4682
|
+
}
|
|
4683
|
+
registerInstanceEvents() {
|
|
4747
4684
|
this.instance.addEventListener("onNodesChange", () => {
|
|
4748
|
-
const currentSelectedNodes = tr.nodes();
|
|
4685
|
+
const currentSelectedNodes = this.tr.nodes();
|
|
4749
4686
|
const unselectedNodes = this.prevSelectedNodes.filter((node) => !currentSelectedNodes.map((node1) => node1.getAttrs().id).includes(node.getAttrs().id));
|
|
4750
4687
|
if (currentSelectedNodes.length > 1) for (const node of currentSelectedNodes) node.handleSelectNode();
|
|
4751
4688
|
if (currentSelectedNodes.length === 1) currentSelectedNodes[0]?.handleDeselectNode?.();
|
|
4752
4689
|
for (const node of unselectedNodes) node.handleDeselectNode();
|
|
4753
|
-
this.prevSelectedNodes = tr.nodes();
|
|
4690
|
+
this.prevSelectedNodes = this.tr.nodes();
|
|
4754
4691
|
});
|
|
4755
4692
|
this.instance.addEventListener("onUndoChange", () => {
|
|
4756
4693
|
this.handleUndoRedoSelectionChange();
|
|
@@ -4758,9 +4695,541 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
4758
4695
|
this.instance.addEventListener("onRedoChange", () => {
|
|
4759
4696
|
this.handleUndoRedoSelectionChange();
|
|
4760
4697
|
});
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4698
|
+
}
|
|
4699
|
+
handleUndoRedoSelectionChange() {
|
|
4700
|
+
const selectionLayer = this.instance.getSelectionLayer();
|
|
4701
|
+
const selectionFeedbackPlugin = this.callbacks.getNodesSelectionFeedbackPlugin();
|
|
4702
|
+
if (selectionLayer && selectionFeedbackPlugin) {
|
|
4703
|
+
selectionLayer.find(`.selection-halo`).forEach((node) => node.destroy());
|
|
4704
|
+
selectionFeedbackPlugin.cleanupSelectedHalos();
|
|
4705
|
+
const currentSelectedNodes = this.tr.nodes();
|
|
4706
|
+
if (currentSelectedNodes.length > 1) for (const node of currentSelectedNodes) node.handleSelectNode();
|
|
4707
|
+
if (currentSelectedNodes.length === 1) currentSelectedNodes[0].handleDeselectNode();
|
|
4708
|
+
this.prevSelectedNodes = currentSelectedNodes;
|
|
4709
|
+
}
|
|
4710
|
+
}
|
|
4711
|
+
};
|
|
4712
|
+
|
|
4713
|
+
//#endregion
|
|
4714
|
+
//#region src/plugins/context-menu/constants.ts
|
|
4715
|
+
const WEAVE_CONTEXT_MENU_PLUGIN_KEY = "contextMenu";
|
|
4716
|
+
const WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT = 4;
|
|
4717
|
+
const WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT = 4;
|
|
4718
|
+
const WEAVE_CONTEXT_MENU_TAP_HOLD_TIMEOUT = 500;
|
|
4719
|
+
|
|
4720
|
+
//#endregion
|
|
4721
|
+
//#region src/plugins/stage-grid/constants.ts
|
|
4722
|
+
const WEAVE_STAGE_GRID_PLUGIN_KEY = "stageGrid";
|
|
4723
|
+
const WEAVE_GRID_TYPES = {
|
|
4724
|
+
["LINES"]: "lines",
|
|
4725
|
+
["DOTS"]: "dots"
|
|
4726
|
+
};
|
|
4727
|
+
const WEAVE_GRID_DOT_TYPES = {
|
|
4728
|
+
["SQUARE"]: "square",
|
|
4729
|
+
["CIRCLE"]: "circle"
|
|
4730
|
+
};
|
|
4731
|
+
const WEAVE_GRID_DEFAULT_CONFIG = {
|
|
4732
|
+
type: WEAVE_GRID_TYPES.LINES,
|
|
4733
|
+
gridColor: "#b3b3b3",
|
|
4734
|
+
gridMajorColor: "#b3b3b3",
|
|
4735
|
+
gridOriginColor: "#ff746c",
|
|
4736
|
+
gridSize: 20,
|
|
4737
|
+
gridMajorEvery: 10,
|
|
4738
|
+
gridMajorRatio: 2,
|
|
4739
|
+
gridStroke: 1,
|
|
4740
|
+
gridDotType: WEAVE_GRID_DOT_TYPES.CIRCLE,
|
|
4741
|
+
gridDotRadius: 1,
|
|
4742
|
+
gridDotRectSize: 2
|
|
4743
|
+
};
|
|
4744
|
+
const WEAVE_GRID_LAYER_ID = "gridLayer";
|
|
4745
|
+
|
|
4746
|
+
//#endregion
|
|
4747
|
+
//#region src/plugins/stage-panning/constants.ts
|
|
4748
|
+
const WEAVE_STAGE_PANNING_KEY = "stagePanning";
|
|
4749
|
+
const WEAVE_STAGE_PANNING_THROTTLE_MS = 20;
|
|
4750
|
+
const WEAVE_STAGE_PANNING_DEFAULT_CONFIG = { edgePan: {
|
|
4751
|
+
offset: 25,
|
|
4752
|
+
speed: 20
|
|
4753
|
+
} };
|
|
4754
|
+
|
|
4755
|
+
//#endregion
|
|
4756
|
+
//#region src/plugins/nodes-multi-selection-feedback/constants.ts
|
|
4757
|
+
const WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_KEY = "nodesMultiSelectionFeedback";
|
|
4758
|
+
const WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_LAYER_ID = "selectionLayer";
|
|
4759
|
+
const WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_DEFAULT_CONFIG = { style: {
|
|
4760
|
+
stroke: "#ff2c2cff",
|
|
4761
|
+
strokeWidth: 2,
|
|
4762
|
+
fill: "transparent"
|
|
4763
|
+
} };
|
|
4764
|
+
|
|
4765
|
+
//#endregion
|
|
4766
|
+
//#region src/plugins/users-presence/constants.ts
|
|
4767
|
+
const WEAVE_USER_PRESENCE_KEY = "userPresence";
|
|
4768
|
+
const WEAVE_USERS_PRESENCE_PLUGIN_KEY = "usersPresence";
|
|
4769
|
+
const WEAVE_USERS_PRESENCE_CONFIG_DEFAULT_PROPS = { awarenessThrottleMs: DEFAULT_THROTTLE_MS };
|
|
4770
|
+
|
|
4771
|
+
//#endregion
|
|
4772
|
+
//#region src/plugins/nodes-selection/plugin-accessors.ts
|
|
4773
|
+
function getContextMenuPlugin(instance) {
|
|
4774
|
+
return instance.getPlugin(WEAVE_CONTEXT_MENU_PLUGIN_KEY);
|
|
4775
|
+
}
|
|
4776
|
+
function getStageGridPlugin(instance) {
|
|
4777
|
+
return instance.getPlugin(WEAVE_STAGE_GRID_PLUGIN_KEY);
|
|
4778
|
+
}
|
|
4779
|
+
function getStagePanningPlugin(instance) {
|
|
4780
|
+
return instance.getPlugin(WEAVE_STAGE_PANNING_KEY);
|
|
4781
|
+
}
|
|
4782
|
+
function getNodesSelectionFeedbackPlugin(instance) {
|
|
4783
|
+
return instance.getPlugin(WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_KEY);
|
|
4784
|
+
}
|
|
4785
|
+
function getUsersPresencePlugin(instance) {
|
|
4786
|
+
return instance.getPlugin(WEAVE_USERS_PRESENCE_PLUGIN_KEY);
|
|
4787
|
+
}
|
|
4788
|
+
|
|
4789
|
+
//#endregion
|
|
4790
|
+
//#region src/plugins/nodes-selection/events/click-tap.ts
|
|
4791
|
+
/**
|
|
4792
|
+
* Handles a single click or tap on the canvas: resolves the targeted node,
|
|
4793
|
+
* applies single/multi-selection logic, and triggers the selection-change
|
|
4794
|
+
* event. Called from both pointerdown (immediate click) and pointerup
|
|
4795
|
+
* (after area-selection ends with a tap).
|
|
4796
|
+
*/
|
|
4797
|
+
function handleClickOrTap(ctx, e) {
|
|
4798
|
+
const weave = ctx.getWeaveInstance();
|
|
4799
|
+
const stage = weave.getStage();
|
|
4800
|
+
const tr = ctx.getTransformerController().getTransformer();
|
|
4801
|
+
ctx.setClickOrTapHandled(true);
|
|
4802
|
+
e.cancelBubble = true;
|
|
4803
|
+
if (!ctx.isEnabled()) return;
|
|
4804
|
+
if (weave.getActiveAction() !== SELECTION_TOOL_ACTION_NAME) return;
|
|
4805
|
+
const contextMenuPlugin = ctx.getContextMenuPlugin();
|
|
4806
|
+
if (contextMenuPlugin?.isContextMenuVisible()) ctx.getEdgePanning().stop();
|
|
4807
|
+
ctx.hideHoverState();
|
|
4808
|
+
const selectedGroup = getTargetedNode(weave);
|
|
4809
|
+
if (!ctx.isInitialized()) return;
|
|
4810
|
+
if (e.evt.pointerType === "mouse" && e.evt?.button && e.evt?.button !== 0) return;
|
|
4811
|
+
let areNodesSelected = false;
|
|
4812
|
+
let nodeTargeted = selectedGroup && !(selectedGroup.getAttrs().active ?? false) ? selectedGroup : e.target;
|
|
4813
|
+
if (e.target === weave.getStage()) {
|
|
4814
|
+
ctx.getGesture().resetDoubleTap();
|
|
4815
|
+
ctx.getNodesSelectionFeedbackPlugin()?.cleanupSelectedHalos();
|
|
4816
|
+
return;
|
|
4817
|
+
}
|
|
4818
|
+
nodeTargeted = weave.getRealSelectedNode(nodeTargeted);
|
|
4819
|
+
if (!nodeTargeted.getAttrs().nodeType) {
|
|
4820
|
+
ctx.getGesture().resetDoubleTap();
|
|
4821
|
+
return;
|
|
4822
|
+
}
|
|
4823
|
+
const metaPressed = e.evt.shiftKey || e.evt.ctrlKey || e.evt.metaKey;
|
|
4824
|
+
const nodeSelectedIndex = tr.nodes().findIndex((node) => {
|
|
4825
|
+
return node.getAttrs().id === nodeTargeted.getAttrs().id;
|
|
4826
|
+
});
|
|
4827
|
+
const isSelected = nodeSelectedIndex !== -1;
|
|
4828
|
+
const user = weave.getStore().getUser();
|
|
4829
|
+
const isLocked = nodeTargeted.getAttrs().locked ?? false;
|
|
4830
|
+
const isMutexLocked = nodeTargeted.getAttrs().mutexLocked && nodeTargeted.getAttrs().mutexUserId !== user.id;
|
|
4831
|
+
if (isLocked || isMutexLocked) {
|
|
4832
|
+
const parent = weave.getInstanceRecursive(nodeTargeted.getParent());
|
|
4833
|
+
const mainLayer = weave.getMainLayer();
|
|
4834
|
+
const isStage = parent instanceof Konva.Stage;
|
|
4835
|
+
const isMainLayer = parent === mainLayer;
|
|
4836
|
+
const isContainerEmptyArea = e.target.getAttrs().isContainerPrincipal !== void 0 && !e.target.getAttrs().isContainerPrincipal;
|
|
4837
|
+
if (isStage || isMainLayer || isContainerEmptyArea) ctx.setSelectedNodes([]);
|
|
4838
|
+
return;
|
|
4839
|
+
}
|
|
4840
|
+
if (nodeTargeted.getAttrs().nodeId) {
|
|
4841
|
+
const realNode = stage.findOne(`#${nodeTargeted.getAttrs().nodeId}`);
|
|
4842
|
+
if (realNode) nodeTargeted = realNode;
|
|
4843
|
+
}
|
|
4844
|
+
if (typeof nodeTargeted.getAttrs().isContainerPrincipal !== "undefined" && !nodeTargeted.getAttrs().isContainerPrincipal) return;
|
|
4845
|
+
if (ctx.getGesture().isDoubleTap && !metaPressed) {
|
|
4846
|
+
ctx.getGesture().resetDoubleTap();
|
|
4847
|
+
nodeTargeted.dblClick();
|
|
4848
|
+
return;
|
|
4849
|
+
}
|
|
4850
|
+
const isCtrlOrCmdPressed = e.evt.ctrlKey || e.evt.metaKey;
|
|
4851
|
+
if (isCtrlOrCmdPressed) return;
|
|
4852
|
+
if (!metaPressed) {
|
|
4853
|
+
tr.nodes([nodeTargeted]);
|
|
4854
|
+
tr.show();
|
|
4855
|
+
areNodesSelected = true;
|
|
4856
|
+
}
|
|
4857
|
+
if (metaPressed && isSelected) {
|
|
4858
|
+
const nodes = tr.nodes().slice();
|
|
4859
|
+
nodes.splice(nodes.indexOf(nodeTargeted), 1);
|
|
4860
|
+
tr.nodes(nodes);
|
|
4861
|
+
areNodesSelected = true;
|
|
4862
|
+
}
|
|
4863
|
+
if (metaPressed && !isSelected) {
|
|
4864
|
+
tr.nodes(tr.nodes().concat([nodeTargeted]));
|
|
4865
|
+
areNodesSelected = true;
|
|
4866
|
+
}
|
|
4867
|
+
ctx.handleMultipleSelectionBehavior();
|
|
4868
|
+
ctx.handleBehaviors();
|
|
4869
|
+
if (areNodesSelected) {
|
|
4870
|
+
stage.container().tabIndex = 1;
|
|
4871
|
+
stage.container().focus();
|
|
4872
|
+
stage.container().style.cursor = (typeof nodeTargeted?.defineMousePointer === "function" ? nodeTargeted.defineMousePointer() : null) ?? "grab";
|
|
4873
|
+
}
|
|
4874
|
+
ctx.triggerSelectedNodesEvent();
|
|
4875
|
+
}
|
|
4876
|
+
|
|
4877
|
+
//#endregion
|
|
4878
|
+
//#region src/plugins/nodes-selection/events/keyboard.ts
|
|
4879
|
+
/**
|
|
4880
|
+
* Registers keydown/keyup listeners on the stage container.
|
|
4881
|
+
* Space key toggles the panning-override flag; Backspace/Delete removes
|
|
4882
|
+
* the currently selected nodes.
|
|
4883
|
+
*/
|
|
4884
|
+
function registerKeyboardHandlers(ctx) {
|
|
4885
|
+
const stage = ctx.getWeaveInstance().getStage();
|
|
4886
|
+
const signal = ctx.getWeaveInstance().getEventsController().signal;
|
|
4887
|
+
stage.container().addEventListener("keydown", (e) => {
|
|
4888
|
+
if (e.code === "Space") ctx.setSpaceKeyPressed(true);
|
|
4889
|
+
if (e.code === "Backspace" || e.code === "Delete") {
|
|
4890
|
+
Promise.resolve().then(() => {
|
|
4891
|
+
ctx.removeSelectedNodes();
|
|
4892
|
+
});
|
|
4893
|
+
return;
|
|
4894
|
+
}
|
|
4895
|
+
}, { signal });
|
|
4896
|
+
stage.container().addEventListener("keyup", (e) => {
|
|
4897
|
+
if (e.code === "Space") ctx.setSpaceKeyPressed(false);
|
|
4898
|
+
}, { signal });
|
|
4899
|
+
}
|
|
4900
|
+
|
|
4901
|
+
//#endregion
|
|
4902
|
+
//#region src/plugins/nodes-selection/events/pointer-down.ts
|
|
4903
|
+
/**
|
|
4904
|
+
* Handles the stage `pointerdown` event: records pointer state, decides
|
|
4905
|
+
* whether to start an area-selection or delegate to a click/tap handler.
|
|
4906
|
+
*/
|
|
4907
|
+
function handlePointerDown(ctx, e) {
|
|
4908
|
+
ctx.getGesture().setTapStart(e.evt.clientX, e.evt.clientY);
|
|
4909
|
+
if (e.target.getClassName().includes("custom-snap-guide")) return;
|
|
4910
|
+
ctx.setClickOrTapHandled(false);
|
|
4911
|
+
ctx.registerPointer(e.evt.pointerId, e.evt);
|
|
4912
|
+
if (e.evt.pointerType === "touch" && ctx.getPointerCount() > 1) return;
|
|
4913
|
+
if (e.evt.pointerType === "mouse" && e.evt?.button !== 0) return;
|
|
4914
|
+
if (e.evt.pointerType === "pen" && e.evt?.pressure <= .05) return;
|
|
4915
|
+
if (!ctx.isInitialized()) return;
|
|
4916
|
+
if (!ctx.isActive()) return;
|
|
4917
|
+
const stage = ctx.getWeaveInstance().getStage();
|
|
4918
|
+
if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
|
|
4919
|
+
const selectedGroup = getTargetedNode(ctx.getWeaveInstance());
|
|
4920
|
+
if (selectedGroup?.getParent() instanceof Konva.Transformer) {
|
|
4921
|
+
ctx.setAreaSelecting(false);
|
|
4922
|
+
ctx.getEdgePanning().stop();
|
|
4923
|
+
ctx.getAreaSelector().hide();
|
|
4924
|
+
return;
|
|
4925
|
+
}
|
|
4926
|
+
const isStage = e.target instanceof Konva.Stage;
|
|
4927
|
+
const isTransformer = e.target?.getParent() instanceof Konva.Transformer;
|
|
4928
|
+
const canBeTargeted = e.target.getAttrs().canBeTargeted !== false;
|
|
4929
|
+
const isContainerEmptyArea = e.target.getAttrs().isContainerPrincipal !== void 0 && !e.target.getAttrs().isContainerPrincipal;
|
|
4930
|
+
if (isTransformer) return;
|
|
4931
|
+
if (!isStage && !isContainerEmptyArea && canBeTargeted) {
|
|
4932
|
+
ctx.setAreaSelecting(false);
|
|
4933
|
+
ctx.getEdgePanning().stop();
|
|
4934
|
+
ctx.getAreaSelector().hide();
|
|
4935
|
+
handleClickOrTap(ctx, e);
|
|
4936
|
+
return;
|
|
4937
|
+
}
|
|
4938
|
+
ctx.getEdgePanning().reset();
|
|
4939
|
+
const relPos = stage.getRelativePointerPosition() ?? {
|
|
4940
|
+
x: 0,
|
|
4941
|
+
y: 0
|
|
4942
|
+
};
|
|
4943
|
+
ctx.getAreaSelector().setStart(relPos.x, relPos.y);
|
|
4944
|
+
ctx.getAreaSelector().resetForScale(stage.scaleX(), ctx.getConfiguration().selectionArea);
|
|
4945
|
+
ctx.setAreaSelecting(true);
|
|
4946
|
+
const isCtrlOrMetaPressed = e.evt.ctrlKey || e.evt.metaKey;
|
|
4947
|
+
if (isCtrlOrMetaPressed) {
|
|
4948
|
+
const tr = ctx.getTransformerController().getTransformer();
|
|
4949
|
+
const nodesSelected = tr.nodes();
|
|
4950
|
+
for (const node of nodesSelected) node.fire("onSelectionCleared", { bubbles: true });
|
|
4951
|
+
}
|
|
4952
|
+
ctx.selectNone();
|
|
4953
|
+
ctx.getWeaveInstance().emitEvent("onSelectionState", true);
|
|
4954
|
+
ctx.getEdgePanning().start();
|
|
4955
|
+
}
|
|
4956
|
+
|
|
4957
|
+
//#endregion
|
|
4958
|
+
//#region src/plugins/nodes-selection/events/pointer-move.ts
|
|
4959
|
+
/**
|
|
4960
|
+
* Handles the stage `pointermove` event: cancels long-press timers when
|
|
4961
|
+
* the pointer moves, hides the selection rect when no movement, and
|
|
4962
|
+
* updates the area-selection rectangle and edge-panning direction while
|
|
4963
|
+
* a selection drag is in progress.
|
|
4964
|
+
*/
|
|
4965
|
+
function handlePointerMove(ctx, e) {
|
|
4966
|
+
if (!e?.evt) return;
|
|
4967
|
+
const moved = ctx.getGesture().checkMoved(e.evt.clientX, e.evt.clientY);
|
|
4968
|
+
if (e.evt?.buttons === 0) return;
|
|
4969
|
+
if (e.evt.pointerType === "touch" && ctx.getPointerCount() > 1) return;
|
|
4970
|
+
if (!ctx.isInitialized()) return;
|
|
4971
|
+
if (!ctx.isActive()) return;
|
|
4972
|
+
const contextMenuPlugin = ctx.getContextMenuPlugin();
|
|
4973
|
+
if (moved) contextMenuPlugin?.cancelLongPressTimer();
|
|
4974
|
+
else ctx.getAreaSelector().hide();
|
|
4975
|
+
if (contextMenuPlugin?.isContextMenuVisible()) ctx.getEdgePanning().stop();
|
|
4976
|
+
if (ctx.getSpaceKeyPressedState()) return;
|
|
4977
|
+
if (!ctx.isAreaSelecting()) return;
|
|
4978
|
+
ctx.getAreaSelector().update(ctx.getWeaveInstance().getStage(), () => ctx.selectNone());
|
|
4979
|
+
ctx.getEdgePanning().updateDirection();
|
|
4980
|
+
}
|
|
4981
|
+
|
|
4982
|
+
//#endregion
|
|
4983
|
+
//#region src/plugins/nodes-selection/events/pointer-up.ts
|
|
4984
|
+
/**
|
|
4985
|
+
* Handles the stage `pointerup` event: ends any in-progress area-selection
|
|
4986
|
+
* (including the node-filtering/commit step), or delegates to the click/tap
|
|
4987
|
+
* handler for point interactions.
|
|
4988
|
+
*/
|
|
4989
|
+
function handlePointerUp(ctx, e) {
|
|
4990
|
+
const weave = ctx.getWeaveInstance();
|
|
4991
|
+
const stage = weave.getStage();
|
|
4992
|
+
const store = weave.getStore();
|
|
4993
|
+
const actUser = store.getUser();
|
|
4994
|
+
const tr = ctx.getTransformerController().getTransformer();
|
|
4995
|
+
tr.setAttrs({ listening: true });
|
|
4996
|
+
ctx.setAreaSelecting(false);
|
|
4997
|
+
ctx.getEdgePanning().stop();
|
|
4998
|
+
const moved = ctx.getGesture().checkMoved(e.evt.clientX, e.evt.clientY);
|
|
4999
|
+
ctx.getGesture().checkDoubleTap(e.evt.clientX, e.evt.clientY);
|
|
5000
|
+
ctx.unregisterPointer(e.evt.pointerId);
|
|
5001
|
+
ctx.getGesture().commitTap();
|
|
5002
|
+
if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
|
|
5003
|
+
const contextMenuPlugin = ctx.getContextMenuPlugin();
|
|
5004
|
+
if (!ctx.isInitialized()) {
|
|
5005
|
+
ctx.getAreaSelector().hide();
|
|
5006
|
+
return;
|
|
5007
|
+
}
|
|
5008
|
+
if (!ctx.isActive()) {
|
|
5009
|
+
ctx.getAreaSelector().hide();
|
|
5010
|
+
return;
|
|
5011
|
+
}
|
|
5012
|
+
weave.emitEvent("onSelectionState", false);
|
|
5013
|
+
if (ctx.getGesture().isDoubleTap) {
|
|
5014
|
+
ctx.getAreaSelector().hide();
|
|
5015
|
+
handleClickOrTap(ctx, e);
|
|
5016
|
+
return;
|
|
5017
|
+
}
|
|
5018
|
+
const isStage = e.target instanceof Konva.Stage;
|
|
5019
|
+
const isContainerEmptyArea = e.target.getAttrs().isContainerPrincipal !== void 0 && !e.target.getAttrs().isContainerPrincipal;
|
|
5020
|
+
if ((isStage || isContainerEmptyArea) && !moved) {
|
|
5021
|
+
ctx.setAreaSelecting(false);
|
|
5022
|
+
ctx.getEdgePanning().stop();
|
|
5023
|
+
ctx.getAreaSelector().hide();
|
|
5024
|
+
ctx.setSelectedNodes([]);
|
|
5025
|
+
return;
|
|
5026
|
+
}
|
|
5027
|
+
if (e.evt.pointerType === "touch" && ctx.getPointerCount() + 1 > 1) {
|
|
5028
|
+
ctx.getAreaSelector().hide();
|
|
5029
|
+
return;
|
|
5030
|
+
}
|
|
5031
|
+
if (contextMenuPlugin?.isContextMenuVisible()) ctx.getEdgePanning().stop();
|
|
5032
|
+
const selectedGroup = getTargetedNode(weave);
|
|
5033
|
+
if (!moved && selectedGroup?.getParent() instanceof Konva.Transformer && !ctx.wasClickOrTapHandled()) {
|
|
5034
|
+
ctx.setAreaSelecting(false);
|
|
5035
|
+
ctx.getEdgePanning().stop();
|
|
5036
|
+
ctx.getAreaSelector().hide();
|
|
5037
|
+
handleClickOrTap(ctx, e);
|
|
5038
|
+
return;
|
|
5039
|
+
}
|
|
5040
|
+
if (!ctx.getAreaSelector().getRect().visible()) {
|
|
5041
|
+
ctx.getAreaSelector().hide();
|
|
5042
|
+
return;
|
|
5043
|
+
}
|
|
5044
|
+
const shapes = stage.find((node) => {
|
|
5045
|
+
return ["Shape", "Group"].includes(node.getType()) && typeof node.getAttrs().id !== "undefined";
|
|
5046
|
+
});
|
|
5047
|
+
const box = ctx.getAreaSelector().getBox();
|
|
5048
|
+
ctx.getAreaSelector().getRect().visible(false);
|
|
5049
|
+
const selected = shapes.filter((shape) => {
|
|
5050
|
+
const shapeMutex = weave.getNodeMutexLock(shape.id());
|
|
5051
|
+
if (shapeMutex && shapeMutex.user.id !== actUser.id) return false;
|
|
5052
|
+
let parent = weave.getInstanceRecursive(shape.getParent());
|
|
5053
|
+
if (parent.getAttrs().nodeId) parent = stage.findOne(`#${parent.getAttrs().nodeId}`);
|
|
5054
|
+
if (shape.getAttrs().nodeType && shape.getAttrs().nodeType === "frame") {
|
|
5055
|
+
const frameBox = shape.getClientRect();
|
|
5056
|
+
return frameBox.x >= box.x && frameBox.y >= box.y && frameBox.x + frameBox.width <= box.x + box.width && frameBox.y + frameBox.height <= box.y + box.height;
|
|
5057
|
+
}
|
|
5058
|
+
if (shape.getAttrs().nodeType && shape?.getAttrs().nodeType === "group" && ["layer", "frame"].includes(parent?.getAttrs().nodeType)) return shape.getAttrs().nodeType && Konva.Util.haveIntersection(box, shape.getClientRect());
|
|
5059
|
+
if (shape.getAttrs().nodeType && shape.getAttrs().nodeType !== "group" && ["layer", "frame"].includes(parent?.getAttrs().nodeType)) return shape.getAttrs().nodeType && Konva.Util.haveIntersection(box, shape.getClientRect());
|
|
5060
|
+
return false;
|
|
5061
|
+
});
|
|
5062
|
+
const selectedNodes = new Set();
|
|
5063
|
+
const containerNodesIds = [];
|
|
5064
|
+
const otherNodes = [];
|
|
5065
|
+
for (const node of selected) {
|
|
5066
|
+
let realNode = node;
|
|
5067
|
+
if (node.getAttrs().nodeId) realNode = stage.findOne(`#${node.getAttrs().nodeId}`);
|
|
5068
|
+
if (!realNode) continue;
|
|
5069
|
+
const isContainer = typeof realNode.getAttrs().isContainerPrincipal !== "undefined" && realNode.getAttrs().isContainerPrincipal;
|
|
5070
|
+
if (isContainer) {
|
|
5071
|
+
containerNodesIds.push(realNode.getAttrs().id ?? "");
|
|
5072
|
+
if (!realNode.getAttrs().locked) selectedNodes.add(realNode);
|
|
5073
|
+
} else otherNodes.push(realNode);
|
|
5074
|
+
}
|
|
5075
|
+
for (const node of otherNodes) {
|
|
5076
|
+
let parent = weave.getInstanceRecursive(node.getParent());
|
|
5077
|
+
if (parent?.getAttrs().nodeId) parent = stage.findOne(`#${parent.getAttrs().nodeId}`);
|
|
5078
|
+
if (parent && !containerNodesIds.includes(parent?.getAttrs().id ?? "") && !node.getAttrs().locked) selectedNodes.add(node);
|
|
5079
|
+
}
|
|
5080
|
+
ctx.setAreaSelecting(false);
|
|
5081
|
+
ctx.getEdgePanning().stop();
|
|
5082
|
+
tr.nodes([...selectedNodes]);
|
|
5083
|
+
ctx.handleMultipleSelectionBehavior();
|
|
5084
|
+
ctx.handleBehaviors();
|
|
5085
|
+
if (tr.nodes().length > 0) {
|
|
5086
|
+
stage.container().tabIndex = 1;
|
|
5087
|
+
stage.container().focus();
|
|
5088
|
+
}
|
|
5089
|
+
ctx.triggerSelectedNodesEvent();
|
|
5090
|
+
}
|
|
5091
|
+
|
|
5092
|
+
//#endregion
|
|
5093
|
+
//#region src/plugins/nodes-selection/nodes-selection.ts
|
|
5094
|
+
var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
5095
|
+
gesture = new GestureDetector();
|
|
5096
|
+
_handledClickOrTap = false;
|
|
5097
|
+
dragSelectedNodes = [];
|
|
5098
|
+
constructor(params) {
|
|
5099
|
+
super();
|
|
5100
|
+
this.config = mergeExceptArrays(WEAVE_NODES_SELECTION_DEFAULT_CONFIG, params?.config ?? {});
|
|
5101
|
+
this.initialize();
|
|
5102
|
+
}
|
|
5103
|
+
initialize() {
|
|
5104
|
+
this._defaultEnabledAnchors = this.config.selection?.enabledAnchors ?? [
|
|
5105
|
+
"top-left",
|
|
5106
|
+
"top-center",
|
|
5107
|
+
"top-right",
|
|
5108
|
+
"middle-right",
|
|
5109
|
+
"middle-left",
|
|
5110
|
+
"bottom-left",
|
|
5111
|
+
"bottom-center",
|
|
5112
|
+
"bottom-right"
|
|
5113
|
+
];
|
|
5114
|
+
this.gesture.reset();
|
|
5115
|
+
this._isSpaceKeyPressed = false;
|
|
5116
|
+
this.active = false;
|
|
5117
|
+
this.selecting = false;
|
|
5118
|
+
this.initialized = false;
|
|
5119
|
+
this.enabled = false;
|
|
5120
|
+
this.pointers = {};
|
|
5121
|
+
this.dragSelectedNodes = [];
|
|
5122
|
+
}
|
|
5123
|
+
getName() {
|
|
5124
|
+
return WEAVE_NODES_SELECTION_KEY;
|
|
5125
|
+
}
|
|
5126
|
+
getLayerName() {
|
|
5127
|
+
return WEAVE_NODES_SELECTION_LAYER_ID;
|
|
5128
|
+
}
|
|
5129
|
+
getConfiguration() {
|
|
5130
|
+
return this.config;
|
|
5131
|
+
}
|
|
5132
|
+
getWeaveInstance() {
|
|
5133
|
+
return this.instance;
|
|
5134
|
+
}
|
|
5135
|
+
getGesture() {
|
|
5136
|
+
return this.gesture;
|
|
5137
|
+
}
|
|
5138
|
+
getAreaSelector() {
|
|
5139
|
+
return this.areaSelector;
|
|
5140
|
+
}
|
|
5141
|
+
getEdgePanning() {
|
|
5142
|
+
return this.edgePanning;
|
|
5143
|
+
}
|
|
5144
|
+
getTransformerController() {
|
|
5145
|
+
return this.transformerCtrl;
|
|
5146
|
+
}
|
|
5147
|
+
getDefaultEnabledAnchors() {
|
|
5148
|
+
return this._defaultEnabledAnchors;
|
|
5149
|
+
}
|
|
5150
|
+
isInitialized() {
|
|
5151
|
+
return this.initialized;
|
|
5152
|
+
}
|
|
5153
|
+
isActive() {
|
|
5154
|
+
return this.active;
|
|
5155
|
+
}
|
|
5156
|
+
getSpaceKeyPressedState() {
|
|
5157
|
+
return this._isSpaceKeyPressed;
|
|
5158
|
+
}
|
|
5159
|
+
setSpaceKeyPressed(val) {
|
|
5160
|
+
this._isSpaceKeyPressed = val;
|
|
5161
|
+
}
|
|
5162
|
+
getPointerCount() {
|
|
5163
|
+
return Object.keys(this.pointers).length;
|
|
5164
|
+
}
|
|
5165
|
+
registerPointer(id, evt) {
|
|
5166
|
+
this.pointers[id] = evt;
|
|
5167
|
+
}
|
|
5168
|
+
unregisterPointer(id) {
|
|
5169
|
+
delete this.pointers[id];
|
|
5170
|
+
}
|
|
5171
|
+
wasClickOrTapHandled() {
|
|
5172
|
+
return this._handledClickOrTap;
|
|
5173
|
+
}
|
|
5174
|
+
setClickOrTapHandled(val) {
|
|
5175
|
+
this._handledClickOrTap = val;
|
|
5176
|
+
}
|
|
5177
|
+
setAreaSelecting(val) {
|
|
5178
|
+
this.selecting = val;
|
|
5179
|
+
}
|
|
5180
|
+
initLayer() {
|
|
5181
|
+
const stage = this.instance.getStage();
|
|
5182
|
+
const layer = new Konva.Layer({ id: this.getLayerName() });
|
|
5183
|
+
stage.add(layer);
|
|
5184
|
+
}
|
|
5185
|
+
isPasting() {
|
|
5186
|
+
const copyPastePlugin = this.instance.getPlugin("copyPasteNodes");
|
|
5187
|
+
if (!copyPastePlugin) return false;
|
|
5188
|
+
return copyPastePlugin.isPasting();
|
|
5189
|
+
}
|
|
5190
|
+
isAreaSelecting() {
|
|
5191
|
+
return this.selecting;
|
|
5192
|
+
}
|
|
5193
|
+
isSelecting() {
|
|
5194
|
+
return this.instance.getActiveAction() === SELECTION_TOOL_ACTION_NAME;
|
|
5195
|
+
}
|
|
5196
|
+
isNodeSelected(ele) {
|
|
5197
|
+
return this.getSelectedNodes().length === 1 && this.getSelectedNodes()[0].getAttrs().id === ele.getAttrs().id;
|
|
5198
|
+
}
|
|
5199
|
+
onInit() {
|
|
5200
|
+
const stage = this.instance.getStage();
|
|
5201
|
+
const selectionLayer = this.getLayer();
|
|
5202
|
+
stage.container().tabIndex = 1;
|
|
5203
|
+
stage.container().focus();
|
|
5204
|
+
this.areaSelector = new AreaSelector();
|
|
5205
|
+
this.areaSelector.init(selectionLayer, this.config.selectionArea, stage.scaleX());
|
|
5206
|
+
this.edgePanning = new EdgePanning(this.config.panningWhenSelection, {
|
|
5207
|
+
getStage: () => this.instance.getStage(),
|
|
5208
|
+
isSelecting: () => this.isAreaSelecting(),
|
|
5209
|
+
onTick: (dx, dy) => {
|
|
5210
|
+
if (this.areaSelector.selectionStart) {
|
|
5211
|
+
this.areaSelector.selectionStart.x += dx;
|
|
5212
|
+
this.areaSelector.selectionStart.y += dy;
|
|
5213
|
+
}
|
|
5214
|
+
this.getStageGridPlugin()?.onRender();
|
|
5215
|
+
this.areaSelector.update(this.instance.getStage(), () => this.selectNone());
|
|
5216
|
+
}
|
|
5217
|
+
});
|
|
5218
|
+
const callbacks = {
|
|
5219
|
+
isSelecting: () => this.isSelecting(),
|
|
5220
|
+
setSelectedNodes: (nodes) => this.setSelectedNodes(nodes),
|
|
5221
|
+
triggerSelectedNodesEvent: () => this.triggerSelectedNodesEvent(),
|
|
5222
|
+
saveDragSelectedNodes: () => this.saveDragSelectedNodes(),
|
|
5223
|
+
setNodesOpacityOnDrag: () => this.setNodesOpacityOnDrag(),
|
|
5224
|
+
disablePlugin: () => this.disable(),
|
|
5225
|
+
enablePlugin: () => this.enable(),
|
|
5226
|
+
getContextMenuPlugin: () => this.getContextMenuPlugin(),
|
|
5227
|
+
getUsersPresencePlugin: () => this.getUsersPresencePlugin(),
|
|
5228
|
+
getStagePanningPlugin: () => this.getStagePanningPlugin(),
|
|
5229
|
+
getNodesSelectionFeedbackPlugin: () => this.getNodesSelectionFeedbackPlugin()
|
|
5230
|
+
};
|
|
5231
|
+
this.transformerCtrl = new TransformerController(this.instance, this.config, this.gesture, callbacks);
|
|
5232
|
+
this.transformerCtrl.setup(selectionLayer);
|
|
4764
5233
|
this.initEvents();
|
|
4765
5234
|
this.initialized = true;
|
|
4766
5235
|
this.instance.addEventListener("onActiveActionChange", (activeAction) => {
|
|
@@ -4771,39 +5240,21 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
4771
5240
|
this.active = true;
|
|
4772
5241
|
});
|
|
4773
5242
|
this.instance.addEventListener("onNodeRemoved", (node) => {
|
|
4774
|
-
const selectedNodes
|
|
4775
|
-
const newSelectedNodes = selectedNodes
|
|
4776
|
-
return actNode.getAttrs().id !== node.id;
|
|
4777
|
-
});
|
|
5243
|
+
const selectedNodes = this.getSelectedNodes();
|
|
5244
|
+
const newSelectedNodes = selectedNodes.filter((actNode) => actNode.getAttrs().id !== node.id);
|
|
4778
5245
|
this.setSelectedNodes(newSelectedNodes);
|
|
4779
5246
|
stage.container().tabIndex = 1;
|
|
4780
5247
|
stage.container().focus();
|
|
4781
|
-
stage.container().style.cursor = "default";
|
|
4782
|
-
});
|
|
4783
|
-
}
|
|
4784
|
-
handleUndoRedoSelectionChange() {
|
|
4785
|
-
const selectionLayer = this.instance.getSelectionLayer();
|
|
4786
|
-
const selectionFeedbackPlugin = this.getNodesSelectionFeedbackPlugin();
|
|
4787
|
-
if (selectionLayer && selectionFeedbackPlugin) {
|
|
4788
|
-
selectionLayer.find(`.selection-halo`).forEach((node) => node.destroy());
|
|
4789
|
-
selectionFeedbackPlugin.cleanupSelectedHalos();
|
|
4790
|
-
const currentSelectedNodes = this.tr.nodes();
|
|
4791
|
-
if (currentSelectedNodes.length > 1) for (const node of currentSelectedNodes) node.handleSelectNode();
|
|
4792
|
-
if (currentSelectedNodes.length === 1) currentSelectedNodes[0].handleDeselectNode();
|
|
4793
|
-
this.prevSelectedNodes = currentSelectedNodes;
|
|
4794
|
-
}
|
|
5248
|
+
stage.container().style.cursor = "default";
|
|
5249
|
+
});
|
|
4795
5250
|
}
|
|
4796
5251
|
getLayer() {
|
|
4797
5252
|
const stage = this.instance.getStage();
|
|
4798
5253
|
return stage.findOne(`#${this.getLayerName()}`);
|
|
4799
5254
|
}
|
|
4800
5255
|
triggerSelectedNodesEvent() {
|
|
4801
|
-
this.
|
|
4802
|
-
|
|
4803
|
-
this.triggerOnNodesChangeEvent();
|
|
4804
|
-
}
|
|
4805
|
-
serializeSelectedNodes() {
|
|
4806
|
-
const selectedNodes = this.tr.getNodes().map((node) => {
|
|
5256
|
+
const tr = this.transformerCtrl.getTransformer();
|
|
5257
|
+
const selectedNodes = tr.getNodes().map((node) => {
|
|
4807
5258
|
const nodeType = node.getAttr("nodeType");
|
|
4808
5259
|
const nodeHandler = this.instance.getNodeHandler(nodeType);
|
|
4809
5260
|
return {
|
|
@@ -4811,17 +5262,12 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
4811
5262
|
node: nodeHandler?.serialize(node)
|
|
4812
5263
|
};
|
|
4813
5264
|
});
|
|
4814
|
-
this.serializedSelectedNodes = selectedNodes;
|
|
4815
|
-
}
|
|
4816
|
-
triggerSelectionAwarenessEvent() {
|
|
4817
5265
|
const usersSelectionPlugin = this.instance.getPlugin(WEAVE_USERS_SELECTION_KEY);
|
|
4818
5266
|
if (usersSelectionPlugin) requestAnimationFrame(() => {
|
|
4819
|
-
usersSelectionPlugin.sendSelectionAwarenessInfo(
|
|
5267
|
+
usersSelectionPlugin.sendSelectionAwarenessInfo(tr);
|
|
4820
5268
|
});
|
|
4821
|
-
}
|
|
4822
|
-
triggerOnNodesChangeEvent() {
|
|
4823
5269
|
requestAnimationFrame(() => {
|
|
4824
|
-
this.instance.emitEvent("onNodesChange",
|
|
5270
|
+
this.instance.emitEvent("onNodesChange", selectedNodes);
|
|
4825
5271
|
});
|
|
4826
5272
|
}
|
|
4827
5273
|
removeElement(element) {
|
|
@@ -4841,334 +5287,13 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
4841
5287
|
this.selectNone();
|
|
4842
5288
|
this.triggerSelectedNodesEvent();
|
|
4843
5289
|
}
|
|
4844
|
-
updateSelectionRect() {
|
|
4845
|
-
const stage = this.instance.getStage();
|
|
4846
|
-
this.x2 = stage.getRelativePointerPosition()?.x ?? 0;
|
|
4847
|
-
this.y2 = stage.getRelativePointerPosition()?.y ?? 0;
|
|
4848
|
-
this.selectNone();
|
|
4849
|
-
this.selectionRectangle.setAttrs({
|
|
4850
|
-
visible: true,
|
|
4851
|
-
x: Math.min(this.x1, this.x2),
|
|
4852
|
-
y: Math.min(this.y1, this.y2),
|
|
4853
|
-
width: Math.abs(this.x2 - this.x1),
|
|
4854
|
-
height: Math.abs(this.y2 - this.y1)
|
|
4855
|
-
});
|
|
4856
|
-
}
|
|
4857
|
-
getSpeedFromEdge(distanceFromEdge) {
|
|
4858
|
-
const stage = this.instance.getStage();
|
|
4859
|
-
const scaledDistance = distanceFromEdge / stage.scaleX();
|
|
4860
|
-
if (scaledDistance < this.config.panningWhenSelection.edgeThreshold) {
|
|
4861
|
-
const factor = 1 - scaledDistance / this.config.panningWhenSelection.edgeThreshold;
|
|
4862
|
-
return this.config.panningWhenSelection.minScrollSpeed + (this.config.panningWhenSelection.maxScrollSpeed - this.config.panningWhenSelection.minScrollSpeed) * factor;
|
|
4863
|
-
}
|
|
4864
|
-
return 0;
|
|
4865
|
-
}
|
|
4866
|
-
updatePanDirection() {
|
|
4867
|
-
const stage = this.instance.getStage();
|
|
4868
|
-
const pos = stage.getPointerPosition();
|
|
4869
|
-
const viewWidth = stage.width();
|
|
4870
|
-
const viewHeight = stage.height();
|
|
4871
|
-
if (!pos) return;
|
|
4872
|
-
const distLeft = pos.x;
|
|
4873
|
-
const distRight = viewWidth - pos.x;
|
|
4874
|
-
const distTop = pos.y;
|
|
4875
|
-
const distBottom = viewHeight - pos.y;
|
|
4876
|
-
this.panDirection.x = 0;
|
|
4877
|
-
this.panDirection.y = 0;
|
|
4878
|
-
this.panSpeed = {
|
|
4879
|
-
x: 0,
|
|
4880
|
-
y: 0
|
|
4881
|
-
};
|
|
4882
|
-
if (distLeft < this.config.panningWhenSelection.edgeThreshold) {
|
|
4883
|
-
this.panDirection.x = 1;
|
|
4884
|
-
this.panSpeed.x = this.getSpeedFromEdge(distLeft);
|
|
4885
|
-
} else if (distRight < this.config.panningWhenSelection.edgeThreshold) {
|
|
4886
|
-
this.panDirection.x = -1;
|
|
4887
|
-
this.panSpeed.x = this.getSpeedFromEdge(distRight);
|
|
4888
|
-
}
|
|
4889
|
-
if (distTop < this.config.panningWhenSelection.edgeThreshold) {
|
|
4890
|
-
this.panDirection.y = 1;
|
|
4891
|
-
this.panSpeed.y = this.getSpeedFromEdge(distTop);
|
|
4892
|
-
} else if (distBottom < this.config.panningWhenSelection.edgeThreshold) {
|
|
4893
|
-
this.panDirection.y = -1;
|
|
4894
|
-
this.panSpeed.y = this.getSpeedFromEdge(distBottom);
|
|
4895
|
-
}
|
|
4896
|
-
}
|
|
4897
|
-
stopPanLoop() {
|
|
4898
|
-
if (this.panLoopId) {
|
|
4899
|
-
cancelAnimationFrame(this.panLoopId);
|
|
4900
|
-
this.panLoopId = null;
|
|
4901
|
-
}
|
|
4902
|
-
}
|
|
4903
|
-
panLoop() {
|
|
4904
|
-
const stage = this.instance.getStage();
|
|
4905
|
-
if (this.isAreaSelecting() && (this.panDirection.x !== 0 || this.panDirection.y !== 0)) {
|
|
4906
|
-
const scale = stage.scaleX();
|
|
4907
|
-
const stepX = (this.panSpeed.x || 0) / scale;
|
|
4908
|
-
const stepY = (this.panSpeed.y || 0) / scale;
|
|
4909
|
-
stage.x(stage.x() + this.panDirection.x * stepX);
|
|
4910
|
-
stage.y(stage.y() + this.panDirection.y * stepY);
|
|
4911
|
-
if (this.selectionStart) {
|
|
4912
|
-
this.selectionStart.x += this.panDirection.x * stepX;
|
|
4913
|
-
this.selectionStart.y += this.panDirection.y * stepY;
|
|
4914
|
-
}
|
|
4915
|
-
this.getStageGridPlugin()?.onRender();
|
|
4916
|
-
this.updateSelectionRect();
|
|
4917
|
-
}
|
|
4918
|
-
if (this.isAreaSelecting()) this.panLoopId = requestAnimationFrame(() => this.panLoop());
|
|
4919
|
-
}
|
|
4920
|
-
setTapStart(e) {
|
|
4921
|
-
this.taps = this.taps + 1;
|
|
4922
|
-
this.tapStart = {
|
|
4923
|
-
x: e.evt.clientX,
|
|
4924
|
-
y: e.evt.clientY,
|
|
4925
|
-
time: performance.now()
|
|
4926
|
-
};
|
|
4927
|
-
}
|
|
4928
|
-
checkMovedDrag(init, actual) {
|
|
4929
|
-
if (!this.tapStart) return false;
|
|
4930
|
-
const dx = actual.x - init.x;
|
|
4931
|
-
const dy = actual.y - init.y;
|
|
4932
|
-
const dist = Math.hypot(dx, dy);
|
|
4933
|
-
const MOVED_DISTANCE = 5;
|
|
4934
|
-
if (dist <= MOVED_DISTANCE) return false;
|
|
4935
|
-
return true;
|
|
4936
|
-
}
|
|
4937
|
-
checkMoved(e) {
|
|
4938
|
-
if (!this.tapStart) return false;
|
|
4939
|
-
const dx = e.evt.clientX - this.tapStart.x;
|
|
4940
|
-
const dy = e.evt.clientY - this.tapStart.y;
|
|
4941
|
-
const dist = Math.hypot(dx, dy);
|
|
4942
|
-
const MOVED_DISTANCE = 5;
|
|
4943
|
-
if (dist <= MOVED_DISTANCE) return false;
|
|
4944
|
-
return true;
|
|
4945
|
-
}
|
|
4946
|
-
checkDoubleTap(e) {
|
|
4947
|
-
if (!this.previousTap) return;
|
|
4948
|
-
const now$2 = performance.now();
|
|
4949
|
-
const dx = e.evt.clientX - this.previousTap.x;
|
|
4950
|
-
const dy = e.evt.clientY - this.previousTap.y;
|
|
4951
|
-
const dist = Math.hypot(dx, dy);
|
|
4952
|
-
const DOUBLE_TAP_DISTANCE = 10;
|
|
4953
|
-
const DOUBLE_TAP_TIME = 300;
|
|
4954
|
-
if (this.tapTimeoutId) clearTimeout(this.tapTimeoutId);
|
|
4955
|
-
this.tapTimeoutId = setTimeout(() => {
|
|
4956
|
-
this.taps = 0;
|
|
4957
|
-
}, DOUBLE_TAP_TIME + 5);
|
|
4958
|
-
if (this.taps > 1 && now$2 - this.previousTap.time < DOUBLE_TAP_TIME && dist < DOUBLE_TAP_DISTANCE) {
|
|
4959
|
-
this.taps = 0;
|
|
4960
|
-
this.tapStart = null;
|
|
4961
|
-
this.isDoubleTap = true;
|
|
4962
|
-
}
|
|
4963
|
-
}
|
|
4964
|
-
hideSelectorArea() {
|
|
4965
|
-
this.selectionRectangle.setAttrs({
|
|
4966
|
-
width: 0,
|
|
4967
|
-
height: 0,
|
|
4968
|
-
visible: false
|
|
4969
|
-
});
|
|
4970
|
-
}
|
|
4971
5290
|
initEvents() {
|
|
4972
5291
|
this.selecting = false;
|
|
4973
5292
|
const stage = this.instance.getStage();
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
this.removeSelectedNodes();
|
|
4979
|
-
});
|
|
4980
|
-
return;
|
|
4981
|
-
}
|
|
4982
|
-
}, { signal: this.instance.getEventsController()?.signal });
|
|
4983
|
-
stage.container().addEventListener("keyup", (e) => {
|
|
4984
|
-
if (e.code === "Space") this.isSpaceKeyPressed = false;
|
|
4985
|
-
}, { signal: this.instance.getEventsController()?.signal });
|
|
4986
|
-
stage.on("pointerdown", (e) => {
|
|
4987
|
-
this.setTapStart(e);
|
|
4988
|
-
if (e.target.getClassName().includes("custom-snap-guide")) return;
|
|
4989
|
-
this.handledClickOrTap = false;
|
|
4990
|
-
this.pointers[e.evt.pointerId] = e.evt;
|
|
4991
|
-
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
|
|
4992
|
-
if (e.evt.pointerType === "mouse" && e.evt?.button !== 0) return;
|
|
4993
|
-
if (e.evt.pointerType === "pen" && e.evt?.pressure <= .05) return;
|
|
4994
|
-
if (!this.initialized) return;
|
|
4995
|
-
if (!this.active) return;
|
|
4996
|
-
if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
|
|
4997
|
-
const selectedGroup = getTargetedNode(this.instance);
|
|
4998
|
-
if (selectedGroup?.getParent() instanceof Konva.Transformer) {
|
|
4999
|
-
this.selecting = false;
|
|
5000
|
-
this.stopPanLoop();
|
|
5001
|
-
this.hideSelectorArea();
|
|
5002
|
-
return;
|
|
5003
|
-
}
|
|
5004
|
-
const isStage = e.target instanceof Konva.Stage;
|
|
5005
|
-
const isTransformer = e.target?.getParent() instanceof Konva.Transformer;
|
|
5006
|
-
const canBeTargeted = e.target.getAttrs().canBeTargeted !== false;
|
|
5007
|
-
const isContainerEmptyArea = e.target.getAttrs().isContainerPrincipal !== void 0 && !e.target.getAttrs().isContainerPrincipal;
|
|
5008
|
-
if (isTransformer) return;
|
|
5009
|
-
if (!isStage && !isContainerEmptyArea && canBeTargeted) {
|
|
5010
|
-
this.selecting = false;
|
|
5011
|
-
this.stopPanLoop();
|
|
5012
|
-
this.hideSelectorArea();
|
|
5013
|
-
this.handleClickOrTap(e);
|
|
5014
|
-
return;
|
|
5015
|
-
}
|
|
5016
|
-
if (isStage || isContainerEmptyArea) {
|
|
5017
|
-
this.setSelectedNodes([]);
|
|
5018
|
-
this.serializeSelectedNodes();
|
|
5019
|
-
this.triggerOnNodesChangeEvent();
|
|
5020
|
-
}
|
|
5021
|
-
this.panDirection.x = 0;
|
|
5022
|
-
this.panDirection.y = 0;
|
|
5023
|
-
this.panSpeed = {
|
|
5024
|
-
x: 0,
|
|
5025
|
-
y: 0
|
|
5026
|
-
};
|
|
5027
|
-
const intStage = this.instance.getStage();
|
|
5028
|
-
this.x1 = intStage.getRelativePointerPosition()?.x ?? 0;
|
|
5029
|
-
this.y1 = intStage.getRelativePointerPosition()?.y ?? 0;
|
|
5030
|
-
this.x2 = intStage.getRelativePointerPosition()?.x ?? 0;
|
|
5031
|
-
this.y2 = intStage.getRelativePointerPosition()?.y ?? 0;
|
|
5032
|
-
this.selectionStart = {
|
|
5033
|
-
x: this.x1,
|
|
5034
|
-
y: this.y1
|
|
5035
|
-
};
|
|
5036
|
-
this.selectionRectangle.strokeWidth(this.config.selectionArea.strokeWidth / stage.scaleX());
|
|
5037
|
-
this.selectionRectangle.dash(this.config.selectionArea.dash?.map((d) => d / stage.scaleX()) ?? []);
|
|
5038
|
-
this.selectionRectangle.width(0);
|
|
5039
|
-
this.selectionRectangle.height(0);
|
|
5040
|
-
this.selecting = true;
|
|
5041
|
-
const isCtrlOrMetaPressed = e.evt.ctrlKey || e.evt.metaKey;
|
|
5042
|
-
if (isCtrlOrMetaPressed) {
|
|
5043
|
-
const nodesSelected = this.tr.nodes();
|
|
5044
|
-
for (const node of nodesSelected) node.fire("onSelectionCleared", { bubbles: true });
|
|
5045
|
-
}
|
|
5046
|
-
this.selectNone();
|
|
5047
|
-
this.instance.emitEvent("onSelectionState", true);
|
|
5048
|
-
this.panLoopId = requestAnimationFrame(() => this.panLoop());
|
|
5049
|
-
});
|
|
5050
|
-
const handleMouseMove = (e) => {
|
|
5051
|
-
if (!e?.evt) return;
|
|
5052
|
-
const moved = this.checkMoved(e);
|
|
5053
|
-
if (e.evt?.buttons === 0) return;
|
|
5054
|
-
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
|
|
5055
|
-
if (!this.initialized) return;
|
|
5056
|
-
if (!this.active) return;
|
|
5057
|
-
const contextMenuPlugin = this.getContextMenuPlugin();
|
|
5058
|
-
if (moved) contextMenuPlugin?.cancelLongPressTimer();
|
|
5059
|
-
else this.hideSelectorArea();
|
|
5060
|
-
if (contextMenuPlugin?.isContextMenuVisible()) this.stopPanLoop();
|
|
5061
|
-
if (this.isSpaceKeyPressed) return;
|
|
5062
|
-
if (!this.selecting) return;
|
|
5063
|
-
this.updateSelectionRect();
|
|
5064
|
-
this.updatePanDirection();
|
|
5065
|
-
};
|
|
5066
|
-
stage.on("pointermove", (0, import_throttle.default)(handleMouseMove, DEFAULT_THROTTLE_MS));
|
|
5067
|
-
this.panLoop();
|
|
5068
|
-
stage.on("pointerup", (e) => {
|
|
5069
|
-
const store = this.instance.getStore();
|
|
5070
|
-
const actUser = store.getUser();
|
|
5071
|
-
this.tr.setAttrs({ listening: true });
|
|
5072
|
-
this.selecting = false;
|
|
5073
|
-
this.stopPanLoop();
|
|
5074
|
-
const moved = this.checkMoved(e);
|
|
5075
|
-
this.checkDoubleTap(e);
|
|
5076
|
-
delete this.pointers[e.evt.pointerId];
|
|
5077
|
-
this.previousTap = this.tapStart;
|
|
5078
|
-
if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
|
|
5079
|
-
const contextMenuPlugin = this.getContextMenuPlugin();
|
|
5080
|
-
if (!this.initialized) {
|
|
5081
|
-
this.hideSelectorArea();
|
|
5082
|
-
return;
|
|
5083
|
-
}
|
|
5084
|
-
if (!this.active) {
|
|
5085
|
-
this.hideSelectorArea();
|
|
5086
|
-
return;
|
|
5087
|
-
}
|
|
5088
|
-
this.instance.emitEvent("onSelectionState", false);
|
|
5089
|
-
if (this.isDoubleTap) {
|
|
5090
|
-
this.hideSelectorArea();
|
|
5091
|
-
this.handleClickOrTap(e);
|
|
5092
|
-
return;
|
|
5093
|
-
}
|
|
5094
|
-
const isStage = e.target instanceof Konva.Stage;
|
|
5095
|
-
const isContainerEmptyArea = e.target.getAttrs().isContainerPrincipal !== void 0 && !e.target.getAttrs().isContainerPrincipal;
|
|
5096
|
-
if ((isStage || isContainerEmptyArea) && !moved) {
|
|
5097
|
-
this.selecting = false;
|
|
5098
|
-
this.stopPanLoop();
|
|
5099
|
-
this.hideSelectorArea();
|
|
5100
|
-
this.getSelectionPlugin()?.setSelectedNodes([]);
|
|
5101
|
-
return;
|
|
5102
|
-
}
|
|
5103
|
-
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length + 1 > 1) {
|
|
5104
|
-
this.hideSelectorArea();
|
|
5105
|
-
return;
|
|
5106
|
-
}
|
|
5107
|
-
if (contextMenuPlugin?.isContextMenuVisible()) this.stopPanLoop();
|
|
5108
|
-
const selectedGroup = getTargetedNode(this.instance);
|
|
5109
|
-
if (!moved && selectedGroup?.getParent() instanceof Konva.Transformer && !this.handledClickOrTap) {
|
|
5110
|
-
this.selecting = false;
|
|
5111
|
-
this.stopPanLoop();
|
|
5112
|
-
this.hideSelectorArea();
|
|
5113
|
-
this.handleClickOrTap(e);
|
|
5114
|
-
return;
|
|
5115
|
-
}
|
|
5116
|
-
if (!this.selectionRectangle.visible()) {
|
|
5117
|
-
this.hideSelectorArea();
|
|
5118
|
-
return;
|
|
5119
|
-
}
|
|
5120
|
-
const shapes = stage.find((node) => {
|
|
5121
|
-
return ["Shape", "Group"].includes(node.getType()) && typeof node.getAttrs().id !== "undefined";
|
|
5122
|
-
});
|
|
5123
|
-
const box = this.selectionRectangle.getClientRect();
|
|
5124
|
-
this.selectionRectangle.visible(false);
|
|
5125
|
-
const selected = shapes.filter((shape) => {
|
|
5126
|
-
const shapeMutex = this.instance.getNodeMutexLock(shape.id());
|
|
5127
|
-
if (shapeMutex && shapeMutex.user.id !== actUser.id) return false;
|
|
5128
|
-
let parent = this.instance.getInstanceRecursive(shape.getParent());
|
|
5129
|
-
if (parent.getAttrs().nodeId) parent = this.instance.getStage().findOne(`#${parent.getAttrs().nodeId}`);
|
|
5130
|
-
if (shape.getAttrs().nodeType && shape.getAttrs().nodeType === "frame") {
|
|
5131
|
-
const frameBox = shape.getClientRect();
|
|
5132
|
-
const isContained = frameBox.x >= box.x && frameBox.y >= box.y && frameBox.x + frameBox.width <= box.x + box.width && frameBox.y + frameBox.height <= box.y + box.height;
|
|
5133
|
-
return isContained;
|
|
5134
|
-
}
|
|
5135
|
-
if (shape.getAttrs().nodeType && shape?.getAttrs().nodeType === "group" && ["layer", "frame"].includes(parent?.getAttrs().nodeType)) return shape.getAttrs().nodeType && Konva.Util.haveIntersection(box, shape.getClientRect());
|
|
5136
|
-
if (shape.getAttrs().nodeType && shape.getAttrs().nodeType !== "group" && ["layer", "frame"].includes(parent?.getAttrs().nodeType)) return shape.getAttrs().nodeType && Konva.Util.haveIntersection(box, shape.getClientRect());
|
|
5137
|
-
return false;
|
|
5138
|
-
});
|
|
5139
|
-
const selectedNodes = new Set();
|
|
5140
|
-
const uniqueContainerNodesIds = new Set();
|
|
5141
|
-
const containerNodesIds = [];
|
|
5142
|
-
const containerNodes = [];
|
|
5143
|
-
const otherNodes = [];
|
|
5144
|
-
for (const node of selected) {
|
|
5145
|
-
let realNode = node;
|
|
5146
|
-
if (node.getAttrs().nodeId) realNode = stage.findOne(`#${node.getAttrs().nodeId}`);
|
|
5147
|
-
if (!realNode) continue;
|
|
5148
|
-
const isContainer = typeof realNode.getAttrs().isContainerPrincipal !== "undefined" && realNode.getAttrs().isContainerPrincipal;
|
|
5149
|
-
if (isContainer) {
|
|
5150
|
-
containerNodes.push(realNode);
|
|
5151
|
-
containerNodesIds.push(realNode.getAttrs().id ?? "");
|
|
5152
|
-
uniqueContainerNodesIds.add(realNode.getAttrs().id ?? "");
|
|
5153
|
-
if (!realNode.getAttrs().locked) selectedNodes.add(realNode);
|
|
5154
|
-
} else otherNodes.push(realNode);
|
|
5155
|
-
}
|
|
5156
|
-
for (const node of otherNodes) {
|
|
5157
|
-
let parent = this.instance.getInstanceRecursive(node.getParent());
|
|
5158
|
-
if (parent?.getAttrs().nodeId) parent = this.instance.getStage().findOne(`#${parent.getAttrs().nodeId}`);
|
|
5159
|
-
if (parent && !containerNodesIds.includes(parent?.getAttrs().id ?? "") && !node.getAttrs().locked) selectedNodes.add(node);
|
|
5160
|
-
}
|
|
5161
|
-
this.selecting = false;
|
|
5162
|
-
this.stopPanLoop();
|
|
5163
|
-
this.tr.nodes([...selectedNodes]);
|
|
5164
|
-
this.handleMultipleSelectionBehavior();
|
|
5165
|
-
this.handleBehaviors();
|
|
5166
|
-
if (this.tr.nodes().length > 0) {
|
|
5167
|
-
stage.container().tabIndex = 1;
|
|
5168
|
-
stage.container().focus();
|
|
5169
|
-
}
|
|
5170
|
-
this.triggerSelectedNodesEvent();
|
|
5171
|
-
});
|
|
5293
|
+
registerKeyboardHandlers(this);
|
|
5294
|
+
stage.on("pointerdown", (e) => handlePointerDown(this, e));
|
|
5295
|
+
stage.on("pointermove", (0, import_throttle.default)((e) => handlePointerMove(this, e), DEFAULT_THROTTLE_MS));
|
|
5296
|
+
stage.on("pointerup", (e) => handlePointerUp(this, e));
|
|
5172
5297
|
this.instance.addEventListener("onStateChange", () => {
|
|
5173
5298
|
requestAnimationFrame(() => {
|
|
5174
5299
|
this.syncSelection();
|
|
@@ -5181,129 +5306,53 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
5181
5306
|
});
|
|
5182
5307
|
}
|
|
5183
5308
|
handleMultipleSelectionBehavior() {
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
this.tr.
|
|
5187
|
-
|
|
5309
|
+
const tr = this.transformerCtrl.getTransformer();
|
|
5310
|
+
if (tr.nodes().length > 1 && this.config.behaviors?.onMultipleSelection) {
|
|
5311
|
+
const selectionBehavior = this.config.behaviors.onMultipleSelection(tr.nodes());
|
|
5312
|
+
tr.setAttrs(selectionBehavior);
|
|
5313
|
+
tr.forceUpdate();
|
|
5188
5314
|
}
|
|
5189
5315
|
}
|
|
5190
5316
|
syncSelection() {
|
|
5191
5317
|
const stageMode = this.instance.getStage().mode();
|
|
5192
5318
|
if (![WEAVE_STAGE_DEFAULT_MODE].includes(stageMode)) return;
|
|
5319
|
+
const tr = this.transformerCtrl.getTransformer();
|
|
5193
5320
|
const newSelectedNodes = [];
|
|
5194
|
-
const actualSelectedNodes =
|
|
5321
|
+
const actualSelectedNodes = tr.nodes();
|
|
5195
5322
|
for (const node of actualSelectedNodes) {
|
|
5196
5323
|
const existNode = this.instance.getStage().findOne(`#${node.getAttrs().id}`);
|
|
5197
5324
|
if (existNode) newSelectedNodes.push(existNode);
|
|
5198
5325
|
}
|
|
5199
|
-
|
|
5200
|
-
if (newSelectedNodes.length > 0)
|
|
5326
|
+
tr.nodes([...newSelectedNodes]);
|
|
5327
|
+
if (newSelectedNodes.length > 0) tr.forceUpdate();
|
|
5201
5328
|
this.triggerSelectedNodesEvent();
|
|
5202
5329
|
}
|
|
5203
5330
|
getSelectionPlugin() {
|
|
5204
|
-
|
|
5205
|
-
return selectionPlugin;
|
|
5331
|
+
return this.instance.getPlugin("nodesSelection");
|
|
5206
5332
|
}
|
|
5207
5333
|
hideHoverState() {
|
|
5208
5334
|
const selectionPlugin = this.getSelectionPlugin();
|
|
5209
5335
|
if (!selectionPlugin) return;
|
|
5210
5336
|
selectionPlugin.getHoverTransformer().nodes([]);
|
|
5211
5337
|
}
|
|
5212
|
-
handleClickOrTap(e) {
|
|
5213
|
-
const stage = this.instance.getStage();
|
|
5214
|
-
this.handledClickOrTap = true;
|
|
5215
|
-
e.cancelBubble = true;
|
|
5216
|
-
if (!this.enabled) return;
|
|
5217
|
-
if (this.instance.getActiveAction() !== SELECTION_TOOL_ACTION_NAME) return;
|
|
5218
|
-
const contextMenuPlugin = this.getContextMenuPlugin();
|
|
5219
|
-
if (contextMenuPlugin?.isContextMenuVisible()) this.stopPanLoop();
|
|
5220
|
-
this.hideHoverState();
|
|
5221
|
-
const selectedGroup = getTargetedNode(this.instance);
|
|
5222
|
-
if (!this.initialized) return;
|
|
5223
|
-
if (e.evt.pointerType === "mouse" && e.evt?.button && e.evt?.button !== 0) return;
|
|
5224
|
-
let areNodesSelected = false;
|
|
5225
|
-
let nodeTargeted = selectedGroup && !(selectedGroup.getAttrs().active ?? false) ? selectedGroup : e.target;
|
|
5226
|
-
if (e.target === this.instance.getStage()) {
|
|
5227
|
-
this.isDoubleTap = false;
|
|
5228
|
-
this.getNodesSelectionFeedbackPlugin()?.cleanupSelectedHalos();
|
|
5229
|
-
return;
|
|
5230
|
-
}
|
|
5231
|
-
nodeTargeted = this.instance.getRealSelectedNode(nodeTargeted);
|
|
5232
|
-
if (!nodeTargeted.getAttrs().nodeType) {
|
|
5233
|
-
this.isDoubleTap = false;
|
|
5234
|
-
return;
|
|
5235
|
-
}
|
|
5236
|
-
const metaPressed = e.evt.shiftKey || e.evt.ctrlKey || e.evt.metaKey;
|
|
5237
|
-
const nodeSelectedIndex = this.tr.nodes().findIndex((node) => {
|
|
5238
|
-
return node.getAttrs().id === nodeTargeted.getAttrs().id;
|
|
5239
|
-
});
|
|
5240
|
-
const isSelected = nodeSelectedIndex !== -1;
|
|
5241
|
-
const user = this.instance.getStore().getUser();
|
|
5242
|
-
const isLocked = nodeTargeted.getAttrs().locked ?? false;
|
|
5243
|
-
const isMutexLocked = nodeTargeted.getAttrs().mutexLocked && nodeTargeted.getAttrs().mutexUserId !== user.id;
|
|
5244
|
-
if (isLocked || isMutexLocked) {
|
|
5245
|
-
const parent = this.instance.getInstanceRecursive(nodeTargeted.getParent());
|
|
5246
|
-
const mainLayer = this.instance.getMainLayer();
|
|
5247
|
-
const isStage = parent instanceof Konva.Stage;
|
|
5248
|
-
const isMainLayer = parent === mainLayer;
|
|
5249
|
-
const isContainerEmptyArea = e.target.getAttrs().isContainerPrincipal !== void 0 && !e.target.getAttrs().isContainerPrincipal;
|
|
5250
|
-
if (isStage || isMainLayer || isContainerEmptyArea) this.getSelectionPlugin()?.setSelectedNodes([]);
|
|
5251
|
-
return;
|
|
5252
|
-
}
|
|
5253
|
-
if (nodeTargeted.getAttrs().nodeId) {
|
|
5254
|
-
const realNode = stage.findOne(`#${nodeTargeted.getAttrs().nodeId}`);
|
|
5255
|
-
if (realNode) nodeTargeted = realNode;
|
|
5256
|
-
}
|
|
5257
|
-
if (typeof nodeTargeted.getAttrs().isContainerPrincipal !== "undefined" && !nodeTargeted.getAttrs().isContainerPrincipal) return;
|
|
5258
|
-
if (this.isDoubleTap && !metaPressed) {
|
|
5259
|
-
this.isDoubleTap = false;
|
|
5260
|
-
nodeTargeted.dblClick();
|
|
5261
|
-
return;
|
|
5262
|
-
}
|
|
5263
|
-
const isCtrlOrCmdPressed = e.evt.ctrlKey || e.evt.metaKey;
|
|
5264
|
-
if (isCtrlOrCmdPressed) return;
|
|
5265
|
-
if (!metaPressed) {
|
|
5266
|
-
this.tr.nodes([nodeTargeted]);
|
|
5267
|
-
this.tr.show();
|
|
5268
|
-
areNodesSelected = true;
|
|
5269
|
-
}
|
|
5270
|
-
if (metaPressed && isSelected) {
|
|
5271
|
-
const nodes = this.tr.nodes().slice();
|
|
5272
|
-
nodes.splice(nodes.indexOf(nodeTargeted), 1);
|
|
5273
|
-
this.tr.nodes(nodes);
|
|
5274
|
-
areNodesSelected = true;
|
|
5275
|
-
}
|
|
5276
|
-
if (metaPressed && !isSelected) {
|
|
5277
|
-
const nodes = this.tr.nodes().concat([nodeTargeted]);
|
|
5278
|
-
this.tr.nodes(nodes);
|
|
5279
|
-
areNodesSelected = true;
|
|
5280
|
-
}
|
|
5281
|
-
this.handleMultipleSelectionBehavior();
|
|
5282
|
-
this.handleBehaviors();
|
|
5283
|
-
if (areNodesSelected) {
|
|
5284
|
-
stage.container().tabIndex = 1;
|
|
5285
|
-
stage.container().focus();
|
|
5286
|
-
stage.container().style.cursor = (typeof nodeTargeted?.defineMousePointer === "function" ? nodeTargeted.defineMousePointer() : null) ?? "grab";
|
|
5287
|
-
}
|
|
5288
|
-
this.triggerSelectedNodesEvent();
|
|
5289
|
-
}
|
|
5290
5338
|
getTransformer() {
|
|
5291
|
-
return this.
|
|
5339
|
+
return this.transformerCtrl.getTransformer();
|
|
5292
5340
|
}
|
|
5293
5341
|
getHoverTransformer() {
|
|
5294
|
-
return this.
|
|
5342
|
+
return this.transformerCtrl.getHoverTransformer();
|
|
5295
5343
|
}
|
|
5296
5344
|
handleBehaviors() {
|
|
5345
|
+
const tr = this.transformerCtrl.getTransformer();
|
|
5297
5346
|
const nodes = this.getSelectedNodes();
|
|
5298
5347
|
const nodesSelected = nodes.length;
|
|
5299
|
-
if (nodesSelected > 1 && !this.config.behaviors.multipleSelection.enabled || nodesSelected === 1 && !this.config.behaviors.singleSelection.enabled)
|
|
5300
|
-
if (nodesSelected > 1 && this.config.behaviors.multipleSelection.enabled || nodesSelected === 1 && this.config.behaviors.singleSelection.enabled)
|
|
5348
|
+
if (nodesSelected > 1 && !this.config.behaviors.multipleSelection.enabled || nodesSelected === 1 && !this.config.behaviors.singleSelection.enabled) tr.enabledAnchors([]);
|
|
5349
|
+
if (nodesSelected > 1 && this.config.behaviors.multipleSelection.enabled || nodesSelected === 1 && this.config.behaviors.singleSelection.enabled) tr.enabledAnchors(this._defaultEnabledAnchors);
|
|
5301
5350
|
let transformerAttrs = { ...this.config.selection };
|
|
5302
|
-
if (
|
|
5303
|
-
const currentAttrs =
|
|
5351
|
+
if (tr && tr.nodes().length > 0) {
|
|
5352
|
+
const currentAttrs = tr.getAttrs();
|
|
5304
5353
|
Object.keys(currentAttrs).forEach((key) => {
|
|
5305
|
-
if (["rotationSnaps", "enabledAnchors"].includes(key))
|
|
5306
|
-
else
|
|
5354
|
+
if (["rotationSnaps", "enabledAnchors"].includes(key)) tr.setAttr(key, []);
|
|
5355
|
+
else tr.setAttr(key, void 0);
|
|
5307
5356
|
});
|
|
5308
5357
|
}
|
|
5309
5358
|
if (nodesSelected === 1) {
|
|
@@ -5313,31 +5362,32 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
5313
5362
|
if (nodesSelected > 1) {
|
|
5314
5363
|
const anchorsArrays = [];
|
|
5315
5364
|
for (const node of nodes) anchorsArrays.push(node?.allowedAnchors?.() ?? []);
|
|
5316
|
-
|
|
5317
|
-
transformerAttrs.enabledAnchors = enabledAnchors;
|
|
5365
|
+
transformerAttrs.enabledAnchors = intersectArrays(anchorsArrays);
|
|
5318
5366
|
}
|
|
5319
|
-
if (
|
|
5367
|
+
if (tr && tr.nodes().length > 0) {
|
|
5320
5368
|
if (transformerAttrs.enabledAnchors?.length === 0) transformerAttrs.resizeEnabled = false;
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5369
|
+
tr.setAttrs(transformerAttrs);
|
|
5370
|
+
tr.forceUpdate();
|
|
5371
|
+
tr.getLayer()?.batchDraw();
|
|
5324
5372
|
}
|
|
5325
5373
|
}
|
|
5326
5374
|
setSelectedNodes(nodes) {
|
|
5327
|
-
this.
|
|
5375
|
+
const tr = this.transformerCtrl.getTransformer();
|
|
5376
|
+
tr.setNodes(nodes);
|
|
5328
5377
|
this.handleBehaviors();
|
|
5329
5378
|
if (nodes.length === 0) this.getNodesSelectionFeedbackPlugin()?.cleanupSelectedHalos();
|
|
5330
5379
|
const usersSelectionPlugin = this.instance.getPlugin(WEAVE_USERS_SELECTION_KEY);
|
|
5331
5380
|
if (usersSelectionPlugin) requestAnimationFrame(() => {
|
|
5332
|
-
usersSelectionPlugin.sendSelectionAwarenessInfo(
|
|
5381
|
+
usersSelectionPlugin.sendSelectionAwarenessInfo(tr);
|
|
5333
5382
|
});
|
|
5334
5383
|
}
|
|
5335
5384
|
getSelectedNodes() {
|
|
5336
|
-
if (!this.
|
|
5337
|
-
return this.
|
|
5385
|
+
if (!this.transformerCtrl) return [];
|
|
5386
|
+
return this.transformerCtrl.getTransformer().nodes();
|
|
5338
5387
|
}
|
|
5339
5388
|
getSelectedNodesExtended() {
|
|
5340
|
-
const
|
|
5389
|
+
const tr = this.transformerCtrl.getTransformer();
|
|
5390
|
+
return tr.getNodes().map((node) => {
|
|
5341
5391
|
const nodeType = node.getAttr("nodeType");
|
|
5342
5392
|
const nodeHandler = this.instance.getNodeHandler(nodeType);
|
|
5343
5393
|
return {
|
|
@@ -5345,17 +5395,13 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
5345
5395
|
node: nodeHandler?.serialize(node)
|
|
5346
5396
|
};
|
|
5347
5397
|
});
|
|
5348
|
-
return selectedNodes;
|
|
5349
5398
|
}
|
|
5350
5399
|
selectAll() {
|
|
5351
5400
|
const mainLayer = this.instance.getMainLayer();
|
|
5352
|
-
if (mainLayer)
|
|
5353
|
-
const nodes = mainLayer.getChildren();
|
|
5354
|
-
this.tr.nodes(nodes);
|
|
5355
|
-
}
|
|
5401
|
+
if (mainLayer) this.transformerCtrl.getTransformer().nodes(mainLayer.getChildren());
|
|
5356
5402
|
}
|
|
5357
5403
|
selectNone() {
|
|
5358
|
-
this.
|
|
5404
|
+
this.transformerCtrl.getTransformer().nodes([]);
|
|
5359
5405
|
}
|
|
5360
5406
|
enable() {
|
|
5361
5407
|
this.getLayer()?.show();
|
|
@@ -5366,36 +5412,31 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
5366
5412
|
this.enabled = false;
|
|
5367
5413
|
}
|
|
5368
5414
|
getNodesSelectionFeedbackPlugin() {
|
|
5369
|
-
|
|
5370
|
-
return selectionFeedbackPlugin;
|
|
5415
|
+
return getNodesSelectionFeedbackPlugin(this.instance);
|
|
5371
5416
|
}
|
|
5372
5417
|
getContextMenuPlugin() {
|
|
5373
|
-
|
|
5374
|
-
return contextMenuPlugin;
|
|
5418
|
+
return getContextMenuPlugin(this.instance);
|
|
5375
5419
|
}
|
|
5376
5420
|
getStageGridPlugin() {
|
|
5377
|
-
|
|
5378
|
-
return gridPlugin;
|
|
5421
|
+
return getStageGridPlugin(this.instance);
|
|
5379
5422
|
}
|
|
5380
5423
|
getStagePanningPlugin() {
|
|
5381
|
-
|
|
5382
|
-
return stagePanning;
|
|
5424
|
+
return getStagePanningPlugin(this.instance);
|
|
5383
5425
|
}
|
|
5384
5426
|
getUsersPresencePlugin() {
|
|
5385
|
-
|
|
5386
|
-
return usersPresencePlugin;
|
|
5427
|
+
return getUsersPresencePlugin(this.instance);
|
|
5387
5428
|
}
|
|
5388
5429
|
isTransforming() {
|
|
5389
|
-
return this.
|
|
5430
|
+
return this.transformerCtrl.isTransforming();
|
|
5390
5431
|
}
|
|
5391
5432
|
isDragging() {
|
|
5392
|
-
return this.
|
|
5433
|
+
return this.transformerCtrl.isDragging();
|
|
5393
5434
|
}
|
|
5394
5435
|
getSelectorConfig() {
|
|
5395
5436
|
return this.config.selection;
|
|
5396
5437
|
}
|
|
5397
5438
|
saveDragSelectedNodes() {
|
|
5398
|
-
this.dragSelectedNodes = this.
|
|
5439
|
+
this.dragSelectedNodes = this.transformerCtrl.getTransformer().nodes();
|
|
5399
5440
|
}
|
|
5400
5441
|
getDragSelectedNodes() {
|
|
5401
5442
|
return this.dragSelectedNodes;
|
|
@@ -5473,30 +5514,30 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
5473
5514
|
this.initEvents();
|
|
5474
5515
|
}
|
|
5475
5516
|
writeClipboardImage(base64Data) {
|
|
5476
|
-
return new Promise((resolve, reject
|
|
5517
|
+
return new Promise((resolve, reject) => {
|
|
5477
5518
|
setTimeout(async () => {
|
|
5478
|
-
if (navigator.clipboard === void 0) return reject
|
|
5519
|
+
if (navigator.clipboard === void 0) return reject(new Error("Clipboard API not supported"));
|
|
5479
5520
|
const res = await fetch(base64Data);
|
|
5480
5521
|
const imageBlob = await res.blob();
|
|
5481
5522
|
const item = new ClipboardItem({ [imageBlob.type]: imageBlob });
|
|
5482
5523
|
navigator.clipboard.write([item]).then(() => {
|
|
5483
5524
|
resolve();
|
|
5484
5525
|
}).catch((error) => {
|
|
5485
|
-
reject
|
|
5526
|
+
reject(error);
|
|
5486
5527
|
});
|
|
5487
5528
|
});
|
|
5488
5529
|
});
|
|
5489
5530
|
}
|
|
5490
5531
|
writeClipboardData(data) {
|
|
5491
|
-
return new Promise((resolve, reject
|
|
5532
|
+
return new Promise((resolve, reject) => {
|
|
5492
5533
|
setTimeout(async () => {
|
|
5493
|
-
if (navigator.clipboard === void 0) return reject
|
|
5534
|
+
if (navigator.clipboard === void 0) return reject(new Error("Clipboard API not supported"));
|
|
5494
5535
|
const textBlob = new Blob([data], { type: "text/plain" });
|
|
5495
5536
|
const item = new ClipboardItem({ [textBlob.type]: textBlob });
|
|
5496
5537
|
navigator.clipboard.write([item]).then(() => {
|
|
5497
5538
|
resolve();
|
|
5498
5539
|
}).catch((error) => {
|
|
5499
|
-
reject
|
|
5540
|
+
reject(error);
|
|
5500
5541
|
});
|
|
5501
5542
|
});
|
|
5502
5543
|
});
|
|
@@ -5566,7 +5607,7 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
5566
5607
|
this.focusPasteCatcher();
|
|
5567
5608
|
if (!this.enabled) return;
|
|
5568
5609
|
}
|
|
5569
|
-
}, { signal: this.instance.getEventsController()
|
|
5610
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
5570
5611
|
if (catcher) catcher.addEventListener("paste", async (e) => {
|
|
5571
5612
|
e.preventDefault();
|
|
5572
5613
|
let items = void 0;
|
|
@@ -5585,7 +5626,7 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
5585
5626
|
return;
|
|
5586
5627
|
}
|
|
5587
5628
|
this.sendExternalPasteEvent(void 0, items);
|
|
5588
|
-
}, { signal: this.instance.getEventsController()
|
|
5629
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
5589
5630
|
}
|
|
5590
5631
|
sendExternalPasteEvent(dataList, items) {
|
|
5591
5632
|
const stage = this.instance.getStage();
|
|
@@ -6828,7 +6869,7 @@ var require__arrayMap = __commonJS({ "../../node_modules/lodash/_arrayMap.js"(ex
|
|
|
6828
6869
|
//#endregion
|
|
6829
6870
|
//#region ../../node_modules/lodash/_isKey.js
|
|
6830
6871
|
var require__isKey = __commonJS({ "../../node_modules/lodash/_isKey.js"(exports, module) {
|
|
6831
|
-
var isArray$
|
|
6872
|
+
var isArray$9 = require_isArray(), isSymbol$3 = require_isSymbol();
|
|
6832
6873
|
/** Used to match property names within property paths. */
|
|
6833
6874
|
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
|
|
6834
6875
|
/**
|
|
@@ -6840,7 +6881,7 @@ var require__isKey = __commonJS({ "../../node_modules/lodash/_isKey.js"(exports,
|
|
|
6840
6881
|
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
|
6841
6882
|
*/
|
|
6842
6883
|
function isKey$3(value, object) {
|
|
6843
|
-
if (isArray$
|
|
6884
|
+
if (isArray$9(value)) return false;
|
|
6844
6885
|
var type = typeof value;
|
|
6845
6886
|
if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol$3(value)) return true;
|
|
6846
6887
|
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
|
|
@@ -6853,7 +6894,7 @@ var require__isKey = __commonJS({ "../../node_modules/lodash/_isKey.js"(exports,
|
|
|
6853
6894
|
var require_memoize = __commonJS({ "../../node_modules/lodash/memoize.js"(exports, module) {
|
|
6854
6895
|
var MapCache$1 = require__MapCache();
|
|
6855
6896
|
/** Error message constants. */
|
|
6856
|
-
var FUNC_ERROR_TEXT
|
|
6897
|
+
var FUNC_ERROR_TEXT = "Expected a function";
|
|
6857
6898
|
/**
|
|
6858
6899
|
* Creates a function that memoizes the result of `func`. If `resolver` is
|
|
6859
6900
|
* provided, it determines the cache key for storing the result based on the
|
|
@@ -6899,7 +6940,7 @@ var require_memoize = __commonJS({ "../../node_modules/lodash/memoize.js"(export
|
|
|
6899
6940
|
* _.memoize.Cache = WeakMap;
|
|
6900
6941
|
*/
|
|
6901
6942
|
function memoize$2(func, resolver) {
|
|
6902
|
-
if (typeof func != "function" || resolver != null && typeof resolver != "function") throw new TypeError(FUNC_ERROR_TEXT
|
|
6943
|
+
if (typeof func != "function" || resolver != null && typeof resolver != "function") throw new TypeError(FUNC_ERROR_TEXT);
|
|
6903
6944
|
var memoized = function() {
|
|
6904
6945
|
var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
|
|
6905
6946
|
if (cache.has(key)) return cache.get(key);
|
|
@@ -6968,7 +7009,7 @@ var require__stringToPath = __commonJS({ "../../node_modules/lodash/_stringToPat
|
|
|
6968
7009
|
//#endregion
|
|
6969
7010
|
//#region ../../node_modules/lodash/_baseToString.js
|
|
6970
7011
|
var require__baseToString = __commonJS({ "../../node_modules/lodash/_baseToString.js"(exports, module) {
|
|
6971
|
-
var Symbol$2 = require__Symbol(), arrayMap$1 = require__arrayMap(), isArray$
|
|
7012
|
+
var Symbol$2 = require__Symbol(), arrayMap$1 = require__arrayMap(), isArray$8 = require_isArray(), isSymbol$2 = require_isSymbol();
|
|
6972
7013
|
/** Used as references for various `Number` constants. */
|
|
6973
7014
|
var INFINITY$1 = Infinity;
|
|
6974
7015
|
/** Used to convert symbols to primitives and strings. */
|
|
@@ -6983,7 +7024,7 @@ var require__baseToString = __commonJS({ "../../node_modules/lodash/_baseToStrin
|
|
|
6983
7024
|
*/
|
|
6984
7025
|
function baseToString$1(value) {
|
|
6985
7026
|
if (typeof value == "string") return value;
|
|
6986
|
-
if (isArray$
|
|
7027
|
+
if (isArray$8(value)) return arrayMap$1(value, baseToString$1) + "";
|
|
6987
7028
|
if (isSymbol$2(value)) return symbolToString ? symbolToString.call(value) : "";
|
|
6988
7029
|
var result = value + "";
|
|
6989
7030
|
return result == "0" && 1 / value == -INFINITY$1 ? "-0" : result;
|
|
@@ -7025,7 +7066,7 @@ var require_toString = __commonJS({ "../../node_modules/lodash/toString.js"(expo
|
|
|
7025
7066
|
//#endregion
|
|
7026
7067
|
//#region ../../node_modules/lodash/_castPath.js
|
|
7027
7068
|
var require__castPath = __commonJS({ "../../node_modules/lodash/_castPath.js"(exports, module) {
|
|
7028
|
-
var isArray$
|
|
7069
|
+
var isArray$7 = require_isArray(), isKey$2 = require__isKey(), stringToPath = require__stringToPath(), toString = require_toString();
|
|
7029
7070
|
/**
|
|
7030
7071
|
* Casts `value` to a path array if it's not one.
|
|
7031
7072
|
*
|
|
@@ -7035,7 +7076,7 @@ var require__castPath = __commonJS({ "../../node_modules/lodash/_castPath.js"(ex
|
|
|
7035
7076
|
* @returns {Array} Returns the cast property path array.
|
|
7036
7077
|
*/
|
|
7037
7078
|
function castPath$2(value, object) {
|
|
7038
|
-
if (isArray$
|
|
7079
|
+
if (isArray$7(value)) return value;
|
|
7039
7080
|
return isKey$2(value, object) ? [value] : stringToPath(toString(value));
|
|
7040
7081
|
}
|
|
7041
7082
|
module.exports = castPath$2;
|
|
@@ -7362,7 +7403,7 @@ var require__arrayPush = __commonJS({ "../../node_modules/lodash/_arrayPush.js"(
|
|
|
7362
7403
|
//#endregion
|
|
7363
7404
|
//#region ../../node_modules/lodash/_baseGetAllKeys.js
|
|
7364
7405
|
var require__baseGetAllKeys = __commonJS({ "../../node_modules/lodash/_baseGetAllKeys.js"(exports, module) {
|
|
7365
|
-
var arrayPush = require__arrayPush(), isArray$
|
|
7406
|
+
var arrayPush = require__arrayPush(), isArray$6 = require_isArray();
|
|
7366
7407
|
/**
|
|
7367
7408
|
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses
|
|
7368
7409
|
* `keysFunc` and `symbolsFunc` to get the enumerable property names and
|
|
@@ -7376,7 +7417,7 @@ var require__baseGetAllKeys = __commonJS({ "../../node_modules/lodash/_baseGetAl
|
|
|
7376
7417
|
*/
|
|
7377
7418
|
function baseGetAllKeys$1(object, keysFunc, symbolsFunc) {
|
|
7378
7419
|
var result = keysFunc(object);
|
|
7379
|
-
return isArray$
|
|
7420
|
+
return isArray$6(object) ? result : arrayPush(result, symbolsFunc(object));
|
|
7380
7421
|
}
|
|
7381
7422
|
module.exports = baseGetAllKeys$1;
|
|
7382
7423
|
} });
|
|
@@ -7393,7 +7434,7 @@ var require__arrayFilter = __commonJS({ "../../node_modules/lodash/_arrayFilter.
|
|
|
7393
7434
|
* @param {Function} predicate The function invoked per iteration.
|
|
7394
7435
|
* @returns {Array} Returns the new filtered array.
|
|
7395
7436
|
*/
|
|
7396
|
-
function arrayFilter$
|
|
7437
|
+
function arrayFilter$1(array, predicate) {
|
|
7397
7438
|
var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
|
|
7398
7439
|
while (++index < length) {
|
|
7399
7440
|
var value = array[index];
|
|
@@ -7401,7 +7442,7 @@ var require__arrayFilter = __commonJS({ "../../node_modules/lodash/_arrayFilter.
|
|
|
7401
7442
|
}
|
|
7402
7443
|
return result;
|
|
7403
7444
|
}
|
|
7404
|
-
module.exports = arrayFilter$
|
|
7445
|
+
module.exports = arrayFilter$1;
|
|
7405
7446
|
} });
|
|
7406
7447
|
|
|
7407
7448
|
//#endregion
|
|
@@ -7434,7 +7475,7 @@ var require_stubArray = __commonJS({ "../../node_modules/lodash/stubArray.js"(ex
|
|
|
7434
7475
|
//#endregion
|
|
7435
7476
|
//#region ../../node_modules/lodash/_getSymbols.js
|
|
7436
7477
|
var require__getSymbols = __commonJS({ "../../node_modules/lodash/_getSymbols.js"(exports, module) {
|
|
7437
|
-
var arrayFilter
|
|
7478
|
+
var arrayFilter = require__arrayFilter(), stubArray = require_stubArray();
|
|
7438
7479
|
/** Used for built-in method references. */
|
|
7439
7480
|
var objectProto$2 = Object.prototype;
|
|
7440
7481
|
/** Built-in value references. */
|
|
@@ -7450,7 +7491,7 @@ var require__getSymbols = __commonJS({ "../../node_modules/lodash/_getSymbols.js
|
|
|
7450
7491
|
var getSymbols$1 = !nativeGetSymbols ? stubArray : function(object) {
|
|
7451
7492
|
if (object == null) return [];
|
|
7452
7493
|
object = Object(object);
|
|
7453
|
-
return arrayFilter
|
|
7494
|
+
return arrayFilter(nativeGetSymbols(object), function(symbol) {
|
|
7454
7495
|
return propertyIsEnumerable.call(object, symbol);
|
|
7455
7496
|
});
|
|
7456
7497
|
};
|
|
@@ -7574,7 +7615,7 @@ var require__equalObjects = __commonJS({ "../../node_modules/lodash/_equalObject
|
|
|
7574
7615
|
//#endregion
|
|
7575
7616
|
//#region ../../node_modules/lodash/_baseIsEqualDeep.js
|
|
7576
7617
|
var require__baseIsEqualDeep = __commonJS({ "../../node_modules/lodash/_baseIsEqualDeep.js"(exports, module) {
|
|
7577
|
-
var Stack$1 = require__Stack(), equalArrays = require__equalArrays(), equalByTag = require__equalByTag(), equalObjects = require__equalObjects(), getTag = require__getTag(), isArray$
|
|
7618
|
+
var Stack$1 = require__Stack(), equalArrays = require__equalArrays(), equalByTag = require__equalByTag(), equalObjects = require__equalObjects(), getTag = require__getTag(), isArray$5 = require_isArray(), isBuffer = require_isBuffer(), isTypedArray = require_isTypedArray();
|
|
7578
7619
|
/** Used to compose bitmasks for value comparisons. */
|
|
7579
7620
|
var COMPARE_PARTIAL_FLAG$2 = 1;
|
|
7580
7621
|
/** `Object#toString` result references. */
|
|
@@ -7598,7 +7639,7 @@ var require__baseIsEqualDeep = __commonJS({ "../../node_modules/lodash/_baseIsEq
|
|
|
7598
7639
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
7599
7640
|
*/
|
|
7600
7641
|
function baseIsEqualDeep$1(object, other, bitmask, customizer, equalFunc, stack) {
|
|
7601
|
-
var objIsArr = isArray$
|
|
7642
|
+
var objIsArr = isArray$5(object), othIsArr = isArray$5(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other);
|
|
7602
7643
|
objTag = objTag == argsTag ? objectTag : objTag;
|
|
7603
7644
|
othTag = othTag == argsTag ? objectTag : othTag;
|
|
7604
7645
|
var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag;
|
|
@@ -7834,7 +7875,7 @@ var require__baseHasIn = __commonJS({ "../../node_modules/lodash/_baseHasIn.js"(
|
|
|
7834
7875
|
//#endregion
|
|
7835
7876
|
//#region ../../node_modules/lodash/_hasPath.js
|
|
7836
7877
|
var require__hasPath = __commonJS({ "../../node_modules/lodash/_hasPath.js"(exports, module) {
|
|
7837
|
-
var castPath = require__castPath(), isArguments = require_isArguments(), isArray$
|
|
7878
|
+
var castPath = require__castPath(), isArguments = require_isArguments(), isArray$4 = require_isArray(), isIndex = require__isIndex(), isLength = require_isLength(), toKey$2 = require__toKey();
|
|
7838
7879
|
/**
|
|
7839
7880
|
* Checks if `path` exists on `object`.
|
|
7840
7881
|
*
|
|
@@ -7854,7 +7895,7 @@ var require__hasPath = __commonJS({ "../../node_modules/lodash/_hasPath.js"(expo
|
|
|
7854
7895
|
}
|
|
7855
7896
|
if (result || ++index != length) return result;
|
|
7856
7897
|
length = object == null ? 0 : object.length;
|
|
7857
|
-
return !!length && isLength(length) && isIndex(key, length) && (isArray$
|
|
7898
|
+
return !!length && isLength(length) && isIndex(key, length) && (isArray$4(object) || isArguments(object));
|
|
7858
7899
|
}
|
|
7859
7900
|
module.exports = hasPath$1;
|
|
7860
7901
|
} });
|
|
@@ -7991,7 +8032,7 @@ var require_property = __commonJS({ "../../node_modules/lodash/property.js"(expo
|
|
|
7991
8032
|
//#endregion
|
|
7992
8033
|
//#region ../../node_modules/lodash/_baseIteratee.js
|
|
7993
8034
|
var require__baseIteratee = __commonJS({ "../../node_modules/lodash/_baseIteratee.js"(exports, module) {
|
|
7994
|
-
var baseMatches = require__baseMatches(), baseMatchesProperty = require__baseMatchesProperty(), identity$1 = require_identity(), isArray$
|
|
8035
|
+
var baseMatches = require__baseMatches(), baseMatchesProperty = require__baseMatchesProperty(), identity$1 = require_identity(), isArray$3 = require_isArray(), property = require_property();
|
|
7995
8036
|
/**
|
|
7996
8037
|
* The base implementation of `_.iteratee`.
|
|
7997
8038
|
*
|
|
@@ -7999,13 +8040,13 @@ var require__baseIteratee = __commonJS({ "../../node_modules/lodash/_baseIterate
|
|
|
7999
8040
|
* @param {*} [value=_.identity] The value to convert to an iteratee.
|
|
8000
8041
|
* @returns {Function} Returns the iteratee.
|
|
8001
8042
|
*/
|
|
8002
|
-
function baseIteratee$
|
|
8043
|
+
function baseIteratee$1(value) {
|
|
8003
8044
|
if (typeof value == "function") return value;
|
|
8004
8045
|
if (value == null) return identity$1;
|
|
8005
|
-
if (typeof value == "object") return isArray$
|
|
8046
|
+
if (typeof value == "object") return isArray$3(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
|
|
8006
8047
|
return property(value);
|
|
8007
8048
|
}
|
|
8008
|
-
module.exports = baseIteratee$
|
|
8049
|
+
module.exports = baseIteratee$1;
|
|
8009
8050
|
} });
|
|
8010
8051
|
|
|
8011
8052
|
//#endregion
|
|
@@ -8062,14 +8103,14 @@ var require__baseEach = __commonJS({ "../../node_modules/lodash/_baseEach.js"(ex
|
|
|
8062
8103
|
* @param {Function} iteratee The function invoked per iteration.
|
|
8063
8104
|
* @returns {Array|Object} Returns `collection`.
|
|
8064
8105
|
*/
|
|
8065
|
-
var baseEach$
|
|
8066
|
-
module.exports = baseEach$
|
|
8106
|
+
var baseEach$1 = createBaseEach(baseForOwn);
|
|
8107
|
+
module.exports = baseEach$1;
|
|
8067
8108
|
} });
|
|
8068
8109
|
|
|
8069
8110
|
//#endregion
|
|
8070
8111
|
//#region ../../node_modules/lodash/_baseMap.js
|
|
8071
8112
|
var require__baseMap = __commonJS({ "../../node_modules/lodash/_baseMap.js"(exports, module) {
|
|
8072
|
-
var baseEach
|
|
8113
|
+
var baseEach = require__baseEach(), isArrayLike = require_isArrayLike();
|
|
8073
8114
|
/**
|
|
8074
8115
|
* The base implementation of `_.map` without support for iteratee shorthands.
|
|
8075
8116
|
*
|
|
@@ -8080,7 +8121,7 @@ var require__baseMap = __commonJS({ "../../node_modules/lodash/_baseMap.js"(expo
|
|
|
8080
8121
|
*/
|
|
8081
8122
|
function baseMap$1(collection, iteratee) {
|
|
8082
8123
|
var index = -1, result = isArrayLike(collection) ? Array(collection.length) : [];
|
|
8083
|
-
baseEach
|
|
8124
|
+
baseEach(collection, function(value, key, collection$1) {
|
|
8084
8125
|
result[++index] = iteratee(value, key, collection$1);
|
|
8085
8126
|
});
|
|
8086
8127
|
return result;
|
|
@@ -8170,7 +8211,7 @@ var require__compareMultiple = __commonJS({ "../../node_modules/lodash/_compareM
|
|
|
8170
8211
|
//#endregion
|
|
8171
8212
|
//#region ../../node_modules/lodash/_baseOrderBy.js
|
|
8172
8213
|
var require__baseOrderBy = __commonJS({ "../../node_modules/lodash/_baseOrderBy.js"(exports, module) {
|
|
8173
|
-
var arrayMap = require__arrayMap(), baseGet = require__baseGet(), baseIteratee
|
|
8214
|
+
var arrayMap = require__arrayMap(), baseGet = require__baseGet(), baseIteratee = require__baseIteratee(), baseMap = require__baseMap(), baseSortBy = require__baseSortBy(), baseUnary = require__baseUnary(), compareMultiple = require__compareMultiple(), identity = require_identity(), isArray$2 = require_isArray();
|
|
8174
8215
|
/**
|
|
8175
8216
|
* The base implementation of `_.orderBy` without param guards.
|
|
8176
8217
|
*
|
|
@@ -8182,14 +8223,14 @@ var require__baseOrderBy = __commonJS({ "../../node_modules/lodash/_baseOrderBy.
|
|
|
8182
8223
|
*/
|
|
8183
8224
|
function baseOrderBy$1(collection, iteratees, orders) {
|
|
8184
8225
|
if (iteratees.length) iteratees = arrayMap(iteratees, function(iteratee) {
|
|
8185
|
-
if (isArray$
|
|
8226
|
+
if (isArray$2(iteratee)) return function(value) {
|
|
8186
8227
|
return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
|
|
8187
8228
|
};
|
|
8188
8229
|
return iteratee;
|
|
8189
8230
|
});
|
|
8190
8231
|
else iteratees = [identity];
|
|
8191
8232
|
var index = -1;
|
|
8192
|
-
iteratees = arrayMap(iteratees, baseUnary(baseIteratee
|
|
8233
|
+
iteratees = arrayMap(iteratees, baseUnary(baseIteratee));
|
|
8193
8234
|
var result = baseMap(collection, function(value, key, collection$1) {
|
|
8194
8235
|
var criteria = arrayMap(iteratees, function(iteratee) {
|
|
8195
8236
|
return iteratee(value);
|
|
@@ -8210,7 +8251,7 @@ var require__baseOrderBy = __commonJS({ "../../node_modules/lodash/_baseOrderBy.
|
|
|
8210
8251
|
//#endregion
|
|
8211
8252
|
//#region ../../node_modules/lodash/orderBy.js
|
|
8212
8253
|
var require_orderBy = __commonJS({ "../../node_modules/lodash/orderBy.js"(exports, module) {
|
|
8213
|
-
var baseOrderBy = require__baseOrderBy(), isArray$
|
|
8254
|
+
var baseOrderBy = require__baseOrderBy(), isArray$1 = require_isArray();
|
|
8214
8255
|
/**
|
|
8215
8256
|
* This method is like `_.sortBy` except that it allows specifying the sort
|
|
8216
8257
|
* orders of the iteratees to sort by. If `orders` is unspecified, all values
|
|
@@ -8242,9 +8283,9 @@ var require_orderBy = __commonJS({ "../../node_modules/lodash/orderBy.js"(export
|
|
|
8242
8283
|
*/
|
|
8243
8284
|
function orderBy(collection, iteratees, orders, guard) {
|
|
8244
8285
|
if (collection == null) return [];
|
|
8245
|
-
if (!isArray$
|
|
8286
|
+
if (!isArray$1(iteratees)) iteratees = iteratees == null ? [] : [iteratees];
|
|
8246
8287
|
orders = guard ? void 0 : orders;
|
|
8247
|
-
if (!isArray$
|
|
8288
|
+
if (!isArray$1(orders)) orders = orders == null ? [] : [orders];
|
|
8248
8289
|
return baseOrderBy(collection, iteratees, orders);
|
|
8249
8290
|
}
|
|
8250
8291
|
module.exports = orderBy;
|
|
@@ -8312,8 +8353,7 @@ var WeaveGroupsManager = class {
|
|
|
8312
8353
|
tr.hide();
|
|
8313
8354
|
selectionPlugin.setSelectedNodes([]);
|
|
8314
8355
|
}
|
|
8315
|
-
|
|
8316
|
-
if (typeof parentNodeId === "undefined") parentNodeId = WEAVE_NODE_LAYER_ID;
|
|
8356
|
+
const parentNodeId = parentId ?? WEAVE_NODE_LAYER_ID;
|
|
8317
8357
|
const parentLayer = stage.findOne(`#${parentNodeId}`);
|
|
8318
8358
|
const groupId = v4_default();
|
|
8319
8359
|
const groupInstance = new Konva.Group({
|
|
@@ -9442,7 +9482,7 @@ var WeaveRegisterManager = class {
|
|
|
9442
9482
|
|
|
9443
9483
|
//#endregion
|
|
9444
9484
|
//#region package.json
|
|
9445
|
-
var version = "5.0.0-SNAPSHOT.
|
|
9485
|
+
var version = "5.0.0-SNAPSHOT.366.1";
|
|
9446
9486
|
|
|
9447
9487
|
//#endregion
|
|
9448
9488
|
//#region src/managers/setup.ts
|
|
@@ -9639,143 +9679,34 @@ var WeaveActionsManager = class {
|
|
|
9639
9679
|
actionsHandlers[actionName].cleanup?.();
|
|
9640
9680
|
this.instance.emitEvent("onActiveActionChange", this.activeAction);
|
|
9641
9681
|
}
|
|
9642
|
-
cancelActionCallback(actionName) {
|
|
9643
|
-
return () => {
|
|
9644
|
-
this.cancelAction(actionName);
|
|
9645
|
-
};
|
|
9646
|
-
}
|
|
9647
|
-
};
|
|
9648
|
-
|
|
9649
|
-
//#endregion
|
|
9650
|
-
//#region src/managers/store.ts
|
|
9651
|
-
var WeaveStoreManager = class {
|
|
9652
|
-
constructor(instance) {
|
|
9653
|
-
this.instance = instance;
|
|
9654
|
-
this.logger = this.instance.getChildLogger("store-manager");
|
|
9655
|
-
this.logger.debug("Store manager created");
|
|
9656
|
-
}
|
|
9657
|
-
getStore() {
|
|
9658
|
-
return this.store;
|
|
9659
|
-
}
|
|
9660
|
-
registerStore(store) {
|
|
9661
|
-
if (typeof this.store !== "undefined") {
|
|
9662
|
-
const msg = `Store already registered`;
|
|
9663
|
-
this.logger.error(msg);
|
|
9664
|
-
throw new Error(msg);
|
|
9665
|
-
}
|
|
9666
|
-
const storeInstance = store.register(this.instance);
|
|
9667
|
-
this.store = storeInstance;
|
|
9668
|
-
}
|
|
9669
|
-
};
|
|
9670
|
-
|
|
9671
|
-
//#endregion
|
|
9672
|
-
//#region ../../node_modules/lodash/_baseFilter.js
|
|
9673
|
-
var require__baseFilter = __commonJS({ "../../node_modules/lodash/_baseFilter.js"(exports, module) {
|
|
9674
|
-
var baseEach = require__baseEach();
|
|
9675
|
-
/**
|
|
9676
|
-
* The base implementation of `_.filter` without support for iteratee shorthands.
|
|
9677
|
-
*
|
|
9678
|
-
* @private
|
|
9679
|
-
* @param {Array|Object} collection The collection to iterate over.
|
|
9680
|
-
* @param {Function} predicate The function invoked per iteration.
|
|
9681
|
-
* @returns {Array} Returns the new filtered array.
|
|
9682
|
-
*/
|
|
9683
|
-
function baseFilter$1(collection, predicate) {
|
|
9684
|
-
var result = [];
|
|
9685
|
-
baseEach(collection, function(value, index, collection$1) {
|
|
9686
|
-
if (predicate(value, index, collection$1)) result.push(value);
|
|
9687
|
-
});
|
|
9688
|
-
return result;
|
|
9689
|
-
}
|
|
9690
|
-
module.exports = baseFilter$1;
|
|
9691
|
-
} });
|
|
9692
|
-
|
|
9693
|
-
//#endregion
|
|
9694
|
-
//#region ../../node_modules/lodash/negate.js
|
|
9695
|
-
var require_negate = __commonJS({ "../../node_modules/lodash/negate.js"(exports, module) {
|
|
9696
|
-
/** Error message constants. */
|
|
9697
|
-
var FUNC_ERROR_TEXT = "Expected a function";
|
|
9698
|
-
/**
|
|
9699
|
-
* Creates a function that negates the result of the predicate `func`. The
|
|
9700
|
-
* `func` predicate is invoked with the `this` binding and arguments of the
|
|
9701
|
-
* created function.
|
|
9702
|
-
*
|
|
9703
|
-
* @static
|
|
9704
|
-
* @memberOf _
|
|
9705
|
-
* @since 3.0.0
|
|
9706
|
-
* @category Function
|
|
9707
|
-
* @param {Function} predicate The predicate to negate.
|
|
9708
|
-
* @returns {Function} Returns the new negated function.
|
|
9709
|
-
* @example
|
|
9710
|
-
*
|
|
9711
|
-
* function isEven(n) {
|
|
9712
|
-
* return n % 2 == 0;
|
|
9713
|
-
* }
|
|
9714
|
-
*
|
|
9715
|
-
* _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
|
|
9716
|
-
* // => [1, 3, 5]
|
|
9717
|
-
*/
|
|
9718
|
-
function negate$1(predicate) {
|
|
9719
|
-
if (typeof predicate != "function") throw new TypeError(FUNC_ERROR_TEXT);
|
|
9720
|
-
return function() {
|
|
9721
|
-
var args = arguments;
|
|
9722
|
-
switch (args.length) {
|
|
9723
|
-
case 0: return !predicate.call(this);
|
|
9724
|
-
case 1: return !predicate.call(this, args[0]);
|
|
9725
|
-
case 2: return !predicate.call(this, args[0], args[1]);
|
|
9726
|
-
case 3: return !predicate.call(this, args[0], args[1], args[2]);
|
|
9727
|
-
}
|
|
9728
|
-
return !predicate.apply(this, args);
|
|
9729
|
-
};
|
|
9730
|
-
}
|
|
9731
|
-
module.exports = negate$1;
|
|
9732
|
-
} });
|
|
9733
|
-
|
|
9734
|
-
//#endregion
|
|
9735
|
-
//#region ../../node_modules/lodash/reject.js
|
|
9736
|
-
var require_reject = __commonJS({ "../../node_modules/lodash/reject.js"(exports, module) {
|
|
9737
|
-
var arrayFilter = require__arrayFilter(), baseFilter = require__baseFilter(), baseIteratee = require__baseIteratee(), isArray$1 = require_isArray(), negate = require_negate();
|
|
9738
|
-
/**
|
|
9739
|
-
* The opposite of `_.filter`; this method returns the elements of `collection`
|
|
9740
|
-
* that `predicate` does **not** return truthy for.
|
|
9741
|
-
*
|
|
9742
|
-
* @static
|
|
9743
|
-
* @memberOf _
|
|
9744
|
-
* @since 0.1.0
|
|
9745
|
-
* @category Collection
|
|
9746
|
-
* @param {Array|Object} collection The collection to iterate over.
|
|
9747
|
-
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
|
9748
|
-
* @returns {Array} Returns the new filtered array.
|
|
9749
|
-
* @see _.filter
|
|
9750
|
-
* @example
|
|
9751
|
-
*
|
|
9752
|
-
* var users = [
|
|
9753
|
-
* { 'user': 'barney', 'age': 36, 'active': false },
|
|
9754
|
-
* { 'user': 'fred', 'age': 40, 'active': true }
|
|
9755
|
-
* ];
|
|
9756
|
-
*
|
|
9757
|
-
* _.reject(users, function(o) { return !o.active; });
|
|
9758
|
-
* // => objects for ['fred']
|
|
9759
|
-
*
|
|
9760
|
-
* // The `_.matches` iteratee shorthand.
|
|
9761
|
-
* _.reject(users, { 'age': 40, 'active': true });
|
|
9762
|
-
* // => objects for ['barney']
|
|
9763
|
-
*
|
|
9764
|
-
* // The `_.matchesProperty` iteratee shorthand.
|
|
9765
|
-
* _.reject(users, ['active', false]);
|
|
9766
|
-
* // => objects for ['fred']
|
|
9767
|
-
*
|
|
9768
|
-
* // The `_.property` iteratee shorthand.
|
|
9769
|
-
* _.reject(users, 'active');
|
|
9770
|
-
* // => objects for ['barney']
|
|
9771
|
-
*/
|
|
9772
|
-
function reject(collection, predicate) {
|
|
9773
|
-
var func = isArray$1(collection) ? arrayFilter : baseFilter;
|
|
9774
|
-
return func(collection, negate(baseIteratee(predicate, 3)));
|
|
9775
|
-
}
|
|
9776
|
-
module.exports = reject;
|
|
9777
|
-
} });
|
|
9778
|
-
var import_reject = __toESM(require_reject(), 1);
|
|
9682
|
+
cancelActionCallback(actionName) {
|
|
9683
|
+
return () => {
|
|
9684
|
+
this.cancelAction(actionName);
|
|
9685
|
+
};
|
|
9686
|
+
}
|
|
9687
|
+
};
|
|
9688
|
+
|
|
9689
|
+
//#endregion
|
|
9690
|
+
//#region src/managers/store.ts
|
|
9691
|
+
var WeaveStoreManager = class {
|
|
9692
|
+
constructor(instance) {
|
|
9693
|
+
this.instance = instance;
|
|
9694
|
+
this.logger = this.instance.getChildLogger("store-manager");
|
|
9695
|
+
this.logger.debug("Store manager created");
|
|
9696
|
+
}
|
|
9697
|
+
getStore() {
|
|
9698
|
+
return this.store;
|
|
9699
|
+
}
|
|
9700
|
+
registerStore(store) {
|
|
9701
|
+
if (typeof this.store !== "undefined") {
|
|
9702
|
+
const msg = `Store already registered`;
|
|
9703
|
+
this.logger.error(msg);
|
|
9704
|
+
throw new Error(msg);
|
|
9705
|
+
}
|
|
9706
|
+
const storeInstance = store.register(this.instance);
|
|
9707
|
+
this.store = storeInstance;
|
|
9708
|
+
}
|
|
9709
|
+
};
|
|
9779
9710
|
|
|
9780
9711
|
//#endregion
|
|
9781
9712
|
//#region src/managers/export/export.ts
|
|
@@ -9785,6 +9716,155 @@ var WeaveExportManager = class {
|
|
|
9785
9716
|
this.logger = this.instance.getChildLogger("export-manager");
|
|
9786
9717
|
this.logger.debug("Export manager created");
|
|
9787
9718
|
}
|
|
9719
|
+
parseExportOptions(options) {
|
|
9720
|
+
return {
|
|
9721
|
+
format: options.format ?? WEAVE_EXPORT_FORMATS.PNG,
|
|
9722
|
+
padding: options.padding ?? 0,
|
|
9723
|
+
pixelRatio: options.pixelRatio ?? 1,
|
|
9724
|
+
backgroundColor: options.backgroundColor ?? WEAVE_EXPORT_BACKGROUND_COLOR
|
|
9725
|
+
};
|
|
9726
|
+
}
|
|
9727
|
+
saveAndDisablePlugins() {
|
|
9728
|
+
const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
|
|
9729
|
+
const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
|
|
9730
|
+
this.getNodesSelectionPlugin()?.disable();
|
|
9731
|
+
this.getStageGridPlugin()?.disable();
|
|
9732
|
+
return {
|
|
9733
|
+
nodesSelectionPluginPrev,
|
|
9734
|
+
nodesStageGridPluginPrev
|
|
9735
|
+
};
|
|
9736
|
+
}
|
|
9737
|
+
restorePlugins(nodesSelectionPluginPrev, nodesStageGridPluginPrev) {
|
|
9738
|
+
if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
|
|
9739
|
+
if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
|
|
9740
|
+
}
|
|
9741
|
+
saveAndResetStage(resetPosition = false) {
|
|
9742
|
+
const stage = this.instance.getStage();
|
|
9743
|
+
const originalPosition = {
|
|
9744
|
+
x: stage.x(),
|
|
9745
|
+
y: stage.y()
|
|
9746
|
+
};
|
|
9747
|
+
const originalScale = {
|
|
9748
|
+
x: stage.scaleX(),
|
|
9749
|
+
y: stage.scaleY()
|
|
9750
|
+
};
|
|
9751
|
+
stage.scale({
|
|
9752
|
+
x: 1,
|
|
9753
|
+
y: 1
|
|
9754
|
+
});
|
|
9755
|
+
if (resetPosition) stage.position({
|
|
9756
|
+
x: 0,
|
|
9757
|
+
y: 0
|
|
9758
|
+
});
|
|
9759
|
+
return {
|
|
9760
|
+
stage,
|
|
9761
|
+
originalPosition,
|
|
9762
|
+
originalScale
|
|
9763
|
+
};
|
|
9764
|
+
}
|
|
9765
|
+
restoreStage(stage, originalPosition, originalScale) {
|
|
9766
|
+
stage.position(originalPosition);
|
|
9767
|
+
stage.scale(originalScale);
|
|
9768
|
+
stage.batchDraw();
|
|
9769
|
+
}
|
|
9770
|
+
buildNodesExportGroup(nodes, boundingNodes, stage, mainLayer, padding, backgroundColor) {
|
|
9771
|
+
const bounds = getExportBoundingBox(boundingNodes(nodes));
|
|
9772
|
+
const scaleX = stage.scaleX();
|
|
9773
|
+
const scaleY = stage.scaleY();
|
|
9774
|
+
const unscaledBounds = {
|
|
9775
|
+
x: bounds.x / scaleX,
|
|
9776
|
+
y: bounds.y / scaleY,
|
|
9777
|
+
width: bounds.width / scaleX,
|
|
9778
|
+
height: bounds.height / scaleY
|
|
9779
|
+
};
|
|
9780
|
+
const exportGroup = new Konva.Group();
|
|
9781
|
+
const background = new Konva.Rect({
|
|
9782
|
+
x: unscaledBounds.x - padding,
|
|
9783
|
+
y: unscaledBounds.y - padding,
|
|
9784
|
+
width: unscaledBounds.width + 2 * padding,
|
|
9785
|
+
height: unscaledBounds.height + 2 * padding,
|
|
9786
|
+
strokeWidth: 0,
|
|
9787
|
+
fill: backgroundColor
|
|
9788
|
+
});
|
|
9789
|
+
exportGroup.add(background);
|
|
9790
|
+
for (const node of nodes) {
|
|
9791
|
+
const clonedNode = node.clone({ id: v4_default() });
|
|
9792
|
+
const absPos = node.getAbsolutePosition();
|
|
9793
|
+
clonedNode.absolutePosition({
|
|
9794
|
+
x: absPos.x / scaleX,
|
|
9795
|
+
y: absPos.y / scaleY
|
|
9796
|
+
});
|
|
9797
|
+
exportGroup.add(clonedNode);
|
|
9798
|
+
}
|
|
9799
|
+
mainLayer.add(exportGroup);
|
|
9800
|
+
const backgroundRect = background.getClientRect();
|
|
9801
|
+
stage.batchDraw();
|
|
9802
|
+
return {
|
|
9803
|
+
exportGroup,
|
|
9804
|
+
background,
|
|
9805
|
+
backgroundRect
|
|
9806
|
+
};
|
|
9807
|
+
}
|
|
9808
|
+
buildAreaBackground(area, stage, mainLayer, padding, backgroundColor, relativeToStage = false) {
|
|
9809
|
+
const bounds = area;
|
|
9810
|
+
const scaleX = stage.scaleX();
|
|
9811
|
+
const scaleY = stage.scaleY();
|
|
9812
|
+
const unscaledBounds = {
|
|
9813
|
+
x: bounds.x / scaleX,
|
|
9814
|
+
y: bounds.y / scaleY,
|
|
9815
|
+
width: bounds.width / scaleX,
|
|
9816
|
+
height: bounds.height / scaleY
|
|
9817
|
+
};
|
|
9818
|
+
const background = new Konva.Rect({
|
|
9819
|
+
x: unscaledBounds.x - padding,
|
|
9820
|
+
y: unscaledBounds.y - padding,
|
|
9821
|
+
width: unscaledBounds.width + 2 * padding,
|
|
9822
|
+
height: unscaledBounds.height + 2 * padding,
|
|
9823
|
+
strokeWidth: 0,
|
|
9824
|
+
fill: backgroundColor
|
|
9825
|
+
});
|
|
9826
|
+
mainLayer.add(background);
|
|
9827
|
+
background.moveToBottom();
|
|
9828
|
+
stage.batchDraw();
|
|
9829
|
+
const backgroundRect = relativeToStage ? background.getClientRect({ relativeTo: stage }) : background.getClientRect();
|
|
9830
|
+
return {
|
|
9831
|
+
background,
|
|
9832
|
+
backgroundRect
|
|
9833
|
+
};
|
|
9834
|
+
}
|
|
9835
|
+
async renderTiles(source, backgroundRect, format, pixelRatio, quality) {
|
|
9836
|
+
const composites = [];
|
|
9837
|
+
const imageWidth = Math.round(backgroundRect.width);
|
|
9838
|
+
const imageHeight = Math.round(backgroundRect.height);
|
|
9839
|
+
const maxRenderSize = 1920;
|
|
9840
|
+
const cols = Math.ceil(imageWidth / maxRenderSize);
|
|
9841
|
+
const rows = Math.ceil(imageHeight / maxRenderSize);
|
|
9842
|
+
const tileWidth = Math.floor(imageWidth / cols);
|
|
9843
|
+
const tileHeight = Math.floor(imageHeight / rows);
|
|
9844
|
+
for (let y = 0; y < imageHeight; y += tileHeight) for (let x = 0; x < imageWidth; x += tileWidth) {
|
|
9845
|
+
const width = Math.min(tileWidth, imageWidth - x);
|
|
9846
|
+
const height = Math.min(tileHeight, imageHeight - y);
|
|
9847
|
+
const canvas = await source.toCanvas({
|
|
9848
|
+
x: Math.round(backgroundRect.x) + x,
|
|
9849
|
+
y: Math.round(backgroundRect.y) + y,
|
|
9850
|
+
width,
|
|
9851
|
+
height,
|
|
9852
|
+
mimeType: format,
|
|
9853
|
+
pixelRatio,
|
|
9854
|
+
quality
|
|
9855
|
+
});
|
|
9856
|
+
let buffer = null;
|
|
9857
|
+
if (globalThis._weave_serverSideBackend === WEAVE_KONVA_BACKEND.CANVAS) buffer = canvas.toBuffer();
|
|
9858
|
+
if (globalThis._weave_serverSideBackend === WEAVE_KONVA_BACKEND.SKIA) buffer = await canvas.toBuffer();
|
|
9859
|
+
if (!buffer) throw new Error("Failed to generate image buffer");
|
|
9860
|
+
composites.push({
|
|
9861
|
+
top: y * pixelRatio,
|
|
9862
|
+
left: x * pixelRatio,
|
|
9863
|
+
input: buffer
|
|
9864
|
+
});
|
|
9865
|
+
}
|
|
9866
|
+
return { composites };
|
|
9867
|
+
}
|
|
9788
9868
|
fitKonvaPixelRatio(sw, sh, targetPR = 1, maxArea = 16777216) {
|
|
9789
9869
|
if (sw <= 0 || sh <= 0) return {
|
|
9790
9870
|
pixelRatio: 0,
|
|
@@ -9894,7 +9974,7 @@ var WeaveExportManager = class {
|
|
|
9894
9974
|
});
|
|
9895
9975
|
}
|
|
9896
9976
|
exportNodesAsBlob(nodes, boundingNodes, options) {
|
|
9897
|
-
return new Promise((resolve) => {
|
|
9977
|
+
return new Promise((resolve, reject) => {
|
|
9898
9978
|
const { format = WEAVE_EXPORT_FORMATS.PNG } = options;
|
|
9899
9979
|
const { stage, mainLayer, originalScale: { scaleX, scaleY } } = this.cloneStageForExport();
|
|
9900
9980
|
if (mainLayer) {
|
|
@@ -9920,7 +10000,7 @@ var WeaveExportManager = class {
|
|
|
9920
10000
|
exportGroup.destroy();
|
|
9921
10001
|
stage.destroy();
|
|
9922
10002
|
if (!blob) {
|
|
9923
|
-
(
|
|
10003
|
+
reject(new Error("Failed to generate image blob"));
|
|
9924
10004
|
return;
|
|
9925
10005
|
}
|
|
9926
10006
|
resolve(blob);
|
|
@@ -9993,7 +10073,7 @@ var WeaveExportManager = class {
|
|
|
9993
10073
|
});
|
|
9994
10074
|
}
|
|
9995
10075
|
exportAreaAsBlob(area, options) {
|
|
9996
|
-
return new Promise((resolve) => {
|
|
10076
|
+
return new Promise((resolve, reject) => {
|
|
9997
10077
|
const { format = WEAVE_EXPORT_FORMATS.PNG } = options;
|
|
9998
10078
|
const { stage, mainLayer, originalScale: { scaleX, scaleY } } = this.cloneStageForExport();
|
|
9999
10079
|
if (mainLayer) {
|
|
@@ -10018,7 +10098,7 @@ var WeaveExportManager = class {
|
|
|
10018
10098
|
callback: (blob) => {
|
|
10019
10099
|
stage.destroy();
|
|
10020
10100
|
if (!blob) {
|
|
10021
|
-
(
|
|
10101
|
+
reject(new Error("Failed to generate image blob"));
|
|
10022
10102
|
return;
|
|
10023
10103
|
}
|
|
10024
10104
|
resolve(blob);
|
|
@@ -10059,24 +10139,11 @@ var WeaveExportManager = class {
|
|
|
10059
10139
|
});
|
|
10060
10140
|
}
|
|
10061
10141
|
async exportNodesServerSide(nodes, boundingNodes, options) {
|
|
10062
|
-
const { format
|
|
10063
|
-
this.
|
|
10064
|
-
this.
|
|
10065
|
-
const stage = this.instance.getStage();
|
|
10142
|
+
const { format, padding, pixelRatio, backgroundColor } = this.parseExportOptions(options);
|
|
10143
|
+
const { nodesSelectionPluginPrev, nodesStageGridPluginPrev } = this.saveAndDisablePlugins();
|
|
10144
|
+
const { stage, originalPosition, originalScale } = this.saveAndResetStage();
|
|
10066
10145
|
const mainLayer = this.instance.getMainLayer();
|
|
10067
10146
|
if (!mainLayer) throw new Error("Main layer not found");
|
|
10068
|
-
const originalPosition = {
|
|
10069
|
-
x: stage.x(),
|
|
10070
|
-
y: stage.y()
|
|
10071
|
-
};
|
|
10072
|
-
const originalScale = {
|
|
10073
|
-
x: stage.scaleX(),
|
|
10074
|
-
y: stage.scaleY()
|
|
10075
|
-
};
|
|
10076
|
-
stage.scale({
|
|
10077
|
-
x: 1,
|
|
10078
|
-
y: 1
|
|
10079
|
-
});
|
|
10080
10147
|
let realNodes = [...nodes];
|
|
10081
10148
|
if (nodes.length === 0) realNodes = mainLayer.getChildren().map((node) => node.getAttrs().id ?? "") ?? [];
|
|
10082
10149
|
const konvaNodes = [];
|
|
@@ -10084,153 +10151,32 @@ var WeaveExportManager = class {
|
|
|
10084
10151
|
const node = stage.findOne(`#${nodeId}`);
|
|
10085
10152
|
if (node) konvaNodes.push(node);
|
|
10086
10153
|
}
|
|
10087
|
-
const
|
|
10088
|
-
const
|
|
10089
|
-
const scaleY = stage.scaleY();
|
|
10090
|
-
const unscaledBounds = {
|
|
10091
|
-
x: bounds.x / scaleX,
|
|
10092
|
-
y: bounds.y / scaleY,
|
|
10093
|
-
width: bounds.width / scaleX,
|
|
10094
|
-
height: bounds.height / scaleY
|
|
10095
|
-
};
|
|
10096
|
-
const exportGroup = new Konva.Group();
|
|
10097
|
-
const background = new Konva.Rect({
|
|
10098
|
-
x: unscaledBounds.x - padding,
|
|
10099
|
-
y: unscaledBounds.y - padding,
|
|
10100
|
-
width: unscaledBounds.width + 2 * padding,
|
|
10101
|
-
height: unscaledBounds.height + 2 * padding,
|
|
10102
|
-
strokeWidth: 0,
|
|
10103
|
-
fill: backgroundColor
|
|
10104
|
-
});
|
|
10105
|
-
exportGroup.add(background);
|
|
10106
|
-
for (const node of konvaNodes) {
|
|
10107
|
-
const clonedNode = node.clone({ id: v4_default() });
|
|
10108
|
-
const absPos = node.getAbsolutePosition();
|
|
10109
|
-
clonedNode.absolutePosition({
|
|
10110
|
-
x: absPos.x / scaleX,
|
|
10111
|
-
y: absPos.y / scaleY
|
|
10112
|
-
});
|
|
10113
|
-
exportGroup.add(clonedNode);
|
|
10114
|
-
}
|
|
10115
|
-
mainLayer.add(exportGroup);
|
|
10116
|
-
const backgroundRect = background.getClientRect();
|
|
10117
|
-
const composites = [];
|
|
10154
|
+
const { exportGroup, backgroundRect } = this.buildNodesExportGroup(konvaNodes, boundingNodes, stage, mainLayer, padding, backgroundColor);
|
|
10155
|
+
const { composites } = await this.renderTiles(exportGroup, backgroundRect, format, pixelRatio, options.quality ?? 1);
|
|
10118
10156
|
const imageWidth = Math.round(backgroundRect.width);
|
|
10119
10157
|
const imageHeight = Math.round(backgroundRect.height);
|
|
10120
|
-
const maxRenderSize = 1920;
|
|
10121
|
-
const cols = Math.ceil(imageWidth / maxRenderSize);
|
|
10122
|
-
const rows = Math.ceil(imageHeight / maxRenderSize);
|
|
10123
|
-
const tileWidth = Math.floor(imageWidth / cols);
|
|
10124
|
-
const tileHeight = Math.floor(imageHeight / rows);
|
|
10125
|
-
for (let y = 0; y < imageHeight; y += tileHeight) for (let x = 0; x < imageWidth; x += tileWidth) {
|
|
10126
|
-
const width = Math.min(tileWidth, imageWidth - x);
|
|
10127
|
-
const height = Math.min(tileHeight, imageHeight - y);
|
|
10128
|
-
const canvas = await exportGroup.toCanvas({
|
|
10129
|
-
x: Math.round(backgroundRect.x) + x,
|
|
10130
|
-
y: Math.round(backgroundRect.y) + y,
|
|
10131
|
-
width,
|
|
10132
|
-
height,
|
|
10133
|
-
mimeType: format,
|
|
10134
|
-
pixelRatio,
|
|
10135
|
-
quality: options.quality ?? 1
|
|
10136
|
-
});
|
|
10137
|
-
let buffer = null;
|
|
10138
|
-
if (globalThis._weave_serverSideBackend === WEAVE_KONVA_BACKEND.CANVAS) buffer = canvas.toBuffer();
|
|
10139
|
-
if (globalThis._weave_serverSideBackend === WEAVE_KONVA_BACKEND.SKIA) buffer = await canvas.toBuffer();
|
|
10140
|
-
if (!buffer) throw new Error("Failed to generate image buffer");
|
|
10141
|
-
composites.push({
|
|
10142
|
-
top: y * pixelRatio,
|
|
10143
|
-
left: x * pixelRatio,
|
|
10144
|
-
input: buffer
|
|
10145
|
-
});
|
|
10146
|
-
}
|
|
10147
10158
|
exportGroup.destroy();
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
|
|
10154
|
-
composites,
|
|
10155
|
-
width: imageWidth * pixelRatio,
|
|
10156
|
-
height: imageHeight * pixelRatio
|
|
10157
|
-
};
|
|
10158
|
-
}
|
|
10159
|
-
async exportAreaServerSide(area, options) {
|
|
10160
|
-
const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
|
|
10161
|
-
this.getNodesSelectionPlugin()?.disable();
|
|
10162
|
-
this.getStageGridPlugin()?.disable();
|
|
10163
|
-
const stage = this.instance.getStage();
|
|
10164
|
-
const mainLayer = this.instance.getMainLayer();
|
|
10165
|
-
if (!mainLayer) throw new Error("Main layer not found");
|
|
10166
|
-
const originalPosition = {
|
|
10167
|
-
x: stage.x(),
|
|
10168
|
-
y: stage.y()
|
|
10169
|
-
};
|
|
10170
|
-
const originalScale = {
|
|
10171
|
-
x: stage.scaleX(),
|
|
10172
|
-
y: stage.scaleY()
|
|
10173
|
-
};
|
|
10174
|
-
stage.scale({
|
|
10175
|
-
x: 1,
|
|
10176
|
-
y: 1
|
|
10177
|
-
});
|
|
10178
|
-
const bounds = area;
|
|
10179
|
-
const scaleX = stage.scaleX();
|
|
10180
|
-
const scaleY = stage.scaleY();
|
|
10181
|
-
const unscaledBounds = {
|
|
10182
|
-
x: bounds.x / scaleX,
|
|
10183
|
-
y: bounds.y / scaleY,
|
|
10184
|
-
width: bounds.width / scaleX,
|
|
10185
|
-
height: bounds.height / scaleY
|
|
10159
|
+
this.restoreStage(stage, originalPosition, originalScale);
|
|
10160
|
+
this.restorePlugins(nodesSelectionPluginPrev, nodesStageGridPluginPrev);
|
|
10161
|
+
return {
|
|
10162
|
+
composites,
|
|
10163
|
+
width: imageWidth * pixelRatio,
|
|
10164
|
+
height: imageHeight * pixelRatio
|
|
10186
10165
|
};
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10191
|
-
|
|
10192
|
-
|
|
10193
|
-
|
|
10194
|
-
});
|
|
10195
|
-
mainLayer.
|
|
10196
|
-
background.moveToBottom();
|
|
10197
|
-
const backgroundRect = background.getClientRect({ relativeTo: stage });
|
|
10198
|
-
const composites = [];
|
|
10166
|
+
}
|
|
10167
|
+
async exportAreaServerSide(area, options) {
|
|
10168
|
+
const { format, padding, pixelRatio, backgroundColor } = this.parseExportOptions(options);
|
|
10169
|
+
const { nodesSelectionPluginPrev, nodesStageGridPluginPrev } = this.saveAndDisablePlugins();
|
|
10170
|
+
const { stage, originalPosition, originalScale } = this.saveAndResetStage();
|
|
10171
|
+
const mainLayer = this.instance.getMainLayer();
|
|
10172
|
+
if (!mainLayer) throw new Error("Main layer not found");
|
|
10173
|
+
const { background, backgroundRect } = this.buildAreaBackground(area, stage, mainLayer, padding, backgroundColor, true);
|
|
10174
|
+
const { composites } = await this.renderTiles(mainLayer, backgroundRect, format, pixelRatio, options.quality ?? 1);
|
|
10199
10175
|
const imageWidth = Math.round(backgroundRect.width);
|
|
10200
10176
|
const imageHeight = Math.round(backgroundRect.height);
|
|
10201
|
-
const maxRenderSize = 1920;
|
|
10202
|
-
const cols = Math.ceil(imageWidth / maxRenderSize);
|
|
10203
|
-
const rows = Math.ceil(imageHeight / maxRenderSize);
|
|
10204
|
-
const tileWidth = Math.floor(imageWidth / cols);
|
|
10205
|
-
const tileHeight = Math.floor(imageHeight / rows);
|
|
10206
|
-
for (let y = 0; y < imageHeight; y += tileHeight) for (let x = 0; x < imageWidth; x += tileWidth) {
|
|
10207
|
-
const width = Math.min(tileWidth, imageWidth - x);
|
|
10208
|
-
const height = Math.min(tileHeight, imageHeight - y);
|
|
10209
|
-
const canvas = await mainLayer.toCanvas({
|
|
10210
|
-
x: Math.round(backgroundRect.x) + x,
|
|
10211
|
-
y: Math.round(backgroundRect.y) + y,
|
|
10212
|
-
width,
|
|
10213
|
-
height,
|
|
10214
|
-
mimeType: format,
|
|
10215
|
-
pixelRatio,
|
|
10216
|
-
quality: options.quality ?? 1
|
|
10217
|
-
});
|
|
10218
|
-
let buffer = null;
|
|
10219
|
-
if (globalThis._weave_serverSideBackend === WEAVE_KONVA_BACKEND.CANVAS) buffer = canvas.toBuffer();
|
|
10220
|
-
if (globalThis._weave_serverSideBackend === WEAVE_KONVA_BACKEND.SKIA) buffer = await canvas.toBuffer();
|
|
10221
|
-
if (!buffer) throw new Error("Failed to generate image buffer");
|
|
10222
|
-
composites.push({
|
|
10223
|
-
top: y * pixelRatio,
|
|
10224
|
-
left: x * pixelRatio,
|
|
10225
|
-
input: buffer
|
|
10226
|
-
});
|
|
10227
|
-
}
|
|
10228
10177
|
background.destroy();
|
|
10229
|
-
|
|
10230
|
-
|
|
10231
|
-
stage.batchDraw();
|
|
10232
|
-
this.getNodesSelectionPlugin()?.enable();
|
|
10233
|
-
this.getStageGridPlugin()?.enable();
|
|
10178
|
+
this.restoreStage(stage, originalPosition, originalScale);
|
|
10179
|
+
this.restorePlugins(nodesSelectionPluginPrev, nodesStageGridPluginPrev);
|
|
10234
10180
|
return {
|
|
10235
10181
|
composites,
|
|
10236
10182
|
width: imageWidth * pixelRatio,
|
|
@@ -10258,10 +10204,10 @@ var WeaveExportManager = class {
|
|
|
10258
10204
|
return gridPlugin;
|
|
10259
10205
|
}
|
|
10260
10206
|
blobToDataURL(blob) {
|
|
10261
|
-
return new Promise((resolve, reject
|
|
10207
|
+
return new Promise((resolve, reject) => {
|
|
10262
10208
|
const reader = new FileReader();
|
|
10263
10209
|
reader.onloadend = () => resolve(reader.result);
|
|
10264
|
-
reader.onerror = () => reject
|
|
10210
|
+
reader.onerror = () => reject(new Error("Failed to convert blob to data URL"));
|
|
10265
10211
|
reader.readAsDataURL(blob);
|
|
10266
10212
|
});
|
|
10267
10213
|
}
|
|
@@ -11508,6 +11454,7 @@ var Weave = class {
|
|
|
11508
11454
|
return this.dragAndDropManager.getDragProperties();
|
|
11509
11455
|
}
|
|
11510
11456
|
getEventsController() {
|
|
11457
|
+
if (!this.eventsController) throw new Error("Events controller not initialized");
|
|
11511
11458
|
return this.eventsController;
|
|
11512
11459
|
}
|
|
11513
11460
|
getHooks() {
|
|
@@ -11526,14 +11473,14 @@ var Weave = class {
|
|
|
11526
11473
|
//#endregion
|
|
11527
11474
|
//#region src/utils/image.ts
|
|
11528
11475
|
function loadImageSource(image, options) {
|
|
11529
|
-
return new Promise((resolve, reject
|
|
11476
|
+
return new Promise((resolve, reject) => {
|
|
11530
11477
|
const { crossOrigin } = mergeExceptArrays({ crossOrigin: "anonymous" }, options);
|
|
11531
11478
|
const reader = new FileReader();
|
|
11532
11479
|
reader.onloadend = () => {
|
|
11533
11480
|
const imageSource = Konva.Util.createImageElement();
|
|
11534
11481
|
imageSource.crossOrigin = crossOrigin;
|
|
11535
11482
|
imageSource.onerror = () => {
|
|
11536
|
-
reject
|
|
11483
|
+
reject(new Error("Failed to load image source"));
|
|
11537
11484
|
};
|
|
11538
11485
|
imageSource.onload = async () => {
|
|
11539
11486
|
resolve(imageSource);
|
|
@@ -11541,7 +11488,7 @@ function loadImageSource(image, options) {
|
|
|
11541
11488
|
imageSource.src = reader.result;
|
|
11542
11489
|
};
|
|
11543
11490
|
reader.onerror = () => {
|
|
11544
|
-
reject
|
|
11491
|
+
reject(new Error("Failed to read image file"));
|
|
11545
11492
|
};
|
|
11546
11493
|
reader.readAsDataURL(image);
|
|
11547
11494
|
});
|
|
@@ -11562,12 +11509,12 @@ async function downscaleImageFile(file, ratio) {
|
|
|
11562
11509
|
});
|
|
11563
11510
|
}
|
|
11564
11511
|
function getImageSizeFromFile(file) {
|
|
11565
|
-
return new Promise((resolve, reject
|
|
11512
|
+
return new Promise((resolve, reject) => {
|
|
11566
11513
|
const img = new Image();
|
|
11567
11514
|
const url = URL.createObjectURL(file);
|
|
11568
11515
|
img.onload = () => {
|
|
11569
11516
|
if (img.naturalWidth === 0) {
|
|
11570
|
-
reject
|
|
11517
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
11571
11518
|
return;
|
|
11572
11519
|
}
|
|
11573
11520
|
resolve({
|
|
@@ -11577,7 +11524,7 @@ function getImageSizeFromFile(file) {
|
|
|
11577
11524
|
URL.revokeObjectURL(url);
|
|
11578
11525
|
};
|
|
11579
11526
|
img.onerror = () => {
|
|
11580
|
-
reject
|
|
11527
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
11581
11528
|
};
|
|
11582
11529
|
img.src = url;
|
|
11583
11530
|
});
|
|
@@ -11592,7 +11539,7 @@ function getDownscaleRatio(width, height, options) {
|
|
|
11592
11539
|
return Math.min(widthRatio, heightRatio, 1);
|
|
11593
11540
|
}
|
|
11594
11541
|
const downscaleImageFromURL = (url, options) => {
|
|
11595
|
-
return new Promise((resolve, reject
|
|
11542
|
+
return new Promise((resolve, reject) => {
|
|
11596
11543
|
const { type, crossOrigin, maxWidth, maxHeight } = mergeExceptArrays({
|
|
11597
11544
|
type: "image/png",
|
|
11598
11545
|
crossOrigin: "anonymous",
|
|
@@ -11603,7 +11550,7 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
11603
11550
|
img.crossOrigin = crossOrigin;
|
|
11604
11551
|
img.onload = () => {
|
|
11605
11552
|
if (img.naturalWidth === 0) {
|
|
11606
|
-
reject
|
|
11553
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
11607
11554
|
return;
|
|
11608
11555
|
}
|
|
11609
11556
|
const ratio = Math.min(maxWidth / img.width, maxHeight / img.height, 1);
|
|
@@ -11619,7 +11566,7 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
11619
11566
|
resolve(dataURL);
|
|
11620
11567
|
};
|
|
11621
11568
|
img.onerror = () => {
|
|
11622
|
-
reject
|
|
11569
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
11623
11570
|
};
|
|
11624
11571
|
img.src = url;
|
|
11625
11572
|
});
|
|
@@ -11736,10 +11683,10 @@ var WeaveStageNode = class extends WeaveNode {
|
|
|
11736
11683
|
container.setAttribute("tabindex", "0");
|
|
11737
11684
|
stage.container().addEventListener("focus", () => {
|
|
11738
11685
|
this.stageFocused = true;
|
|
11739
|
-
}, { signal: this.instance.getEventsController()
|
|
11686
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
11740
11687
|
stage.container().addEventListener("blur", () => {
|
|
11741
11688
|
this.stageFocused = false;
|
|
11742
|
-
}, { signal: this.instance.getEventsController()
|
|
11689
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
11743
11690
|
}
|
|
11744
11691
|
Konva.Stage.prototype.mode = function(mode) {
|
|
11745
11692
|
if (typeof mode !== "undefined") this._mode = mode;
|
|
@@ -11806,7 +11753,7 @@ var WeaveStageNode = class extends WeaveNode {
|
|
|
11806
11753
|
const selectedNode = transformer.nodes()[0];
|
|
11807
11754
|
selectedNode.fire("onCmdCtrlPressed");
|
|
11808
11755
|
}
|
|
11809
|
-
}, { signal: this.instance.getEventsController()
|
|
11756
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
11810
11757
|
window.addEventListener("keyup", (e) => {
|
|
11811
11758
|
if (!(e.ctrlKey || e.metaKey)) {
|
|
11812
11759
|
this.instance.getStage().container().style.cursor = "default";
|
|
@@ -11816,7 +11763,7 @@ var WeaveStageNode = class extends WeaveNode {
|
|
|
11816
11763
|
const selectedNode = transformer.nodes()[0];
|
|
11817
11764
|
selectedNode.fire("onCmdCtrlReleased");
|
|
11818
11765
|
}
|
|
11819
|
-
}, { signal: this.instance.getEventsController()
|
|
11766
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
11820
11767
|
this.globalEventsInitialized = true;
|
|
11821
11768
|
}
|
|
11822
11769
|
isOnlyCtrlOrMeta(event) {
|
|
@@ -12782,7 +12729,7 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
12782
12729
|
onAdd() {
|
|
12783
12730
|
if (!this.instance.isServerSide() && !this.keyPressHandler) {
|
|
12784
12731
|
this.keyPressHandler = this.handleKeyPress.bind(this);
|
|
12785
|
-
window.addEventListener("keypress", this.keyPressHandler, { signal: this.instance.getEventsController()
|
|
12732
|
+
window.addEventListener("keypress", this.keyPressHandler, { signal: this.instance.getEventsController().signal });
|
|
12786
12733
|
}
|
|
12787
12734
|
}
|
|
12788
12735
|
onRender(props) {
|
|
@@ -12941,7 +12888,7 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
12941
12888
|
});
|
|
12942
12889
|
if (!this.instance.isServerSide() && !this.keyPressHandler) {
|
|
12943
12890
|
this.keyPressHandler = this.handleKeyPress.bind(this);
|
|
12944
|
-
window.addEventListener("keypress", this.keyPressHandler, { signal: this.instance.getEventsController()
|
|
12891
|
+
window.addEventListener("keypress", this.keyPressHandler, { signal: this.instance.getEventsController().signal });
|
|
12945
12892
|
}
|
|
12946
12893
|
return text;
|
|
12947
12894
|
}
|
|
@@ -13189,17 +13136,17 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13189
13136
|
this.textAreaSuperContainer.scrollTop = 0;
|
|
13190
13137
|
this.textAreaSuperContainer.scrollLeft = 0;
|
|
13191
13138
|
}
|
|
13192
|
-
}, { signal: this.instance.getEventsController()
|
|
13139
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
13193
13140
|
this.textAreaContainer.addEventListener("scroll", () => {
|
|
13194
13141
|
if (!this.textAreaContainer) return;
|
|
13195
13142
|
this.textAreaContainer.scrollTop = 0;
|
|
13196
13143
|
this.textAreaContainer.scrollLeft = 0;
|
|
13197
|
-
}, { signal: this.instance.getEventsController()
|
|
13144
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
13198
13145
|
this.textArea.addEventListener("scroll", () => {
|
|
13199
13146
|
if (!this.textArea) return;
|
|
13200
13147
|
this.textArea.scrollTop = 0;
|
|
13201
13148
|
this.textArea.scrollLeft = 0;
|
|
13202
|
-
}, { signal: this.instance.getEventsController()
|
|
13149
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
13203
13150
|
const rotation = textNode.getAbsoluteRotation();
|
|
13204
13151
|
if (rotation) {
|
|
13205
13152
|
const transform = "rotate(" + rotation + "deg)";
|
|
@@ -13249,8 +13196,8 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13249
13196
|
this.textAreaDomResize(textNode);
|
|
13250
13197
|
}
|
|
13251
13198
|
};
|
|
13252
|
-
this.textArea.addEventListener("keydown", handleKeyDown, { signal: this.instance.getEventsController()
|
|
13253
|
-
this.textArea.addEventListener("keyup", handleKeyUp, { signal: this.instance.getEventsController()
|
|
13199
|
+
this.textArea.addEventListener("keydown", handleKeyDown, { signal: this.instance.getEventsController().signal });
|
|
13200
|
+
this.textArea.addEventListener("keyup", handleKeyUp, { signal: this.instance.getEventsController().signal });
|
|
13254
13201
|
this.textArea.tabIndex = 1;
|
|
13255
13202
|
this.textArea.focus();
|
|
13256
13203
|
const handleOutsideClick = (e) => {
|
|
@@ -13276,7 +13223,7 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13276
13223
|
}
|
|
13277
13224
|
};
|
|
13278
13225
|
setTimeout(() => {
|
|
13279
|
-
window.addEventListener("pointerup", handleOutsideClick, { signal: this.instance.getEventsController()
|
|
13226
|
+
window.addEventListener("pointerup", handleOutsideClick, { signal: this.instance.getEventsController().signal });
|
|
13280
13227
|
}, 0);
|
|
13281
13228
|
this.instance.getStage().mode(WEAVE_STAGE_TEXT_EDITION_MODE);
|
|
13282
13229
|
this.editing = true;
|
|
@@ -13736,7 +13683,7 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
13736
13683
|
utilityLayer?.add(this.transformer);
|
|
13737
13684
|
this.transformer?.forceUpdate();
|
|
13738
13685
|
this.cropGroup.show();
|
|
13739
|
-
window.addEventListener("keydown", this.handleHide, { signal: this.instance.getEventsController()
|
|
13686
|
+
if (!this.instance.isServerSide()) window.addEventListener("keydown", this.handleHide, { signal: this.instance.getEventsController().signal });
|
|
13740
13687
|
if (options.cmdCtrl.triggered) {
|
|
13741
13688
|
utilityLayer?.hide();
|
|
13742
13689
|
const stage = this.instance.getStage();
|
|
@@ -16838,10 +16785,10 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
16838
16785
|
if (this.eventsInitialized) return;
|
|
16839
16786
|
window.addEventListener("keydown", (e) => {
|
|
16840
16787
|
if (e.key === "Shift") this.shiftPressed = true;
|
|
16841
|
-
}, { signal: this.instance.getEventsController()
|
|
16788
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
16842
16789
|
window.addEventListener("keyup", (e) => {
|
|
16843
16790
|
if (e.key === "Shift") this.shiftPressed = false;
|
|
16844
|
-
}, { signal: this.instance.getEventsController()
|
|
16791
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
16845
16792
|
this.eventsInitialized = true;
|
|
16846
16793
|
}
|
|
16847
16794
|
onRender(props) {
|
|
@@ -20928,7 +20875,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
20928
20875
|
}
|
|
20929
20876
|
}, {
|
|
20930
20877
|
passive: false,
|
|
20931
|
-
signal: this.instance.getEventsController()
|
|
20878
|
+
signal: this.instance.getEventsController().signal
|
|
20932
20879
|
});
|
|
20933
20880
|
stage.getContent().addEventListener("touchmove", (e) => {
|
|
20934
20881
|
e.preventDefault();
|
|
@@ -20971,7 +20918,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
20971
20918
|
}
|
|
20972
20919
|
}, {
|
|
20973
20920
|
passive: false,
|
|
20974
|
-
signal: this.instance.getEventsController()
|
|
20921
|
+
signal: this.instance.getEventsController().signal
|
|
20975
20922
|
});
|
|
20976
20923
|
stage.getContent().addEventListener("touchend", () => {
|
|
20977
20924
|
this.pinching = false;
|
|
@@ -20979,7 +20926,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
20979
20926
|
lastCenter = null;
|
|
20980
20927
|
}, {
|
|
20981
20928
|
passive: false,
|
|
20982
|
-
signal: this.instance.getEventsController()
|
|
20929
|
+
signal: this.instance.getEventsController().signal
|
|
20983
20930
|
});
|
|
20984
20931
|
let doZoom = false;
|
|
20985
20932
|
const handleWheelImmediate = (e) => {
|
|
@@ -21000,7 +20947,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
21000
20947
|
doZoom = true;
|
|
21001
20948
|
};
|
|
21002
20949
|
window.addEventListener("wheel", handleWheelImmediate, {
|
|
21003
|
-
signal: this.instance.getEventsController()
|
|
20950
|
+
signal: this.instance.getEventsController().signal,
|
|
21004
20951
|
passive: false
|
|
21005
20952
|
});
|
|
21006
20953
|
const handleWheel = (e) => {
|
|
@@ -21016,7 +20963,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
21016
20963
|
};
|
|
21017
20964
|
const throttledHandleWheel = (0, import_throttle.default)(handleWheel, DEFAULT_THROTTLE_MS);
|
|
21018
20965
|
window.addEventListener("wheel", throttledHandleWheel, {
|
|
21019
|
-
signal: this.instance.getEventsController()
|
|
20966
|
+
signal: this.instance.getEventsController().signal,
|
|
21020
20967
|
passive: true
|
|
21021
20968
|
});
|
|
21022
20969
|
}
|
|
@@ -21244,7 +21191,7 @@ var WeaveMoveToolAction = class extends WeaveAction {
|
|
|
21244
21191
|
this.cancelAction();
|
|
21245
21192
|
return;
|
|
21246
21193
|
}
|
|
21247
|
-
}, { signal: this.instance.getEventsController()
|
|
21194
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
21248
21195
|
stage.on("pointerdown", () => {
|
|
21249
21196
|
if ([MOVE_TOOL_ACTION_NAME].includes(this.instance.getActiveAction() ?? "")) stage.container().style.cursor = "grabbing";
|
|
21250
21197
|
});
|
|
@@ -21405,7 +21352,7 @@ var WeaveEraserToolAction = class extends WeaveAction {
|
|
|
21405
21352
|
this.cancelAction();
|
|
21406
21353
|
return;
|
|
21407
21354
|
}
|
|
21408
|
-
}, { signal: this.instance.getEventsController()
|
|
21355
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
21409
21356
|
this.initialized = true;
|
|
21410
21357
|
}
|
|
21411
21358
|
setState(state) {
|
|
@@ -21510,7 +21457,7 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
21510
21457
|
this.cancelAction();
|
|
21511
21458
|
return;
|
|
21512
21459
|
}
|
|
21513
|
-
}, { signal: this.instance.getEventsController()
|
|
21460
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
21514
21461
|
stage.on("pointermove", () => {
|
|
21515
21462
|
if (this.state === RECTANGLE_TOOL_STATE.IDLE) return;
|
|
21516
21463
|
this.setCursor();
|
|
@@ -21731,7 +21678,7 @@ var WeaveEllipseToolAction = class extends WeaveAction {
|
|
|
21731
21678
|
this.cancelAction();
|
|
21732
21679
|
return;
|
|
21733
21680
|
}
|
|
21734
|
-
}, { signal: this.instance.getEventsController()
|
|
21681
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
21735
21682
|
stage.on("pointerdown", (e) => {
|
|
21736
21683
|
this.setTapStart(e);
|
|
21737
21684
|
this.pointers.set(e.evt.pointerId, {
|
|
@@ -21950,7 +21897,7 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
21950
21897
|
this.cancelAction();
|
|
21951
21898
|
return;
|
|
21952
21899
|
}
|
|
21953
|
-
}, { signal: this.instance.getEventsController()
|
|
21900
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
21954
21901
|
stage.on("pointerdown", (e) => {
|
|
21955
21902
|
this.setTapStart(e);
|
|
21956
21903
|
this.pointers.set(e.evt.pointerId, {
|
|
@@ -22234,13 +22181,13 @@ var WeaveLineToolAction = class extends WeaveAction {
|
|
|
22234
22181
|
this.snappedAngle = null;
|
|
22235
22182
|
this.shiftPressed = true;
|
|
22236
22183
|
}
|
|
22237
|
-
}, { signal: this.instance.getEventsController()
|
|
22184
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
22238
22185
|
window.addEventListener("keyup", (e) => {
|
|
22239
22186
|
if (e.key === "Shift" && this.instance.getActiveAction() === LINE_TOOL_ACTION_NAME) {
|
|
22240
22187
|
this.snappedAngle = null;
|
|
22241
22188
|
this.shiftPressed = false;
|
|
22242
22189
|
}
|
|
22243
|
-
}, { signal: this.instance.getEventsController()
|
|
22190
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
22244
22191
|
stage.on("pointerdown", (e) => {
|
|
22245
22192
|
this.setTapStart(e);
|
|
22246
22193
|
this.pointers.set(e.evt.pointerId, {
|
|
@@ -22509,7 +22456,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
22509
22456
|
stage.container().style.touchAction = "none";
|
|
22510
22457
|
window.addEventListener("keyup", (e) => {
|
|
22511
22458
|
if (e.code === "Space" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) this.isSpacePressed = false;
|
|
22512
|
-
}, { signal: this.instance.getEventsController()
|
|
22459
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
22513
22460
|
window.addEventListener("keydown", (e) => {
|
|
22514
22461
|
if (e.code === "Enter" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) {
|
|
22515
22462
|
e.stopPropagation();
|
|
@@ -22525,8 +22472,8 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
22525
22472
|
e.stopPropagation();
|
|
22526
22473
|
this.cancelAction();
|
|
22527
22474
|
}
|
|
22528
|
-
}, { signal: this.instance.getEventsController()
|
|
22529
|
-
const handlePointerDown = (e) => {
|
|
22475
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
22476
|
+
const handlePointerDown$1 = (e) => {
|
|
22530
22477
|
if (this.state === BRUSH_TOOL_STATE.INACTIVE) return;
|
|
22531
22478
|
if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
|
|
22532
22479
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
@@ -22538,8 +22485,8 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
22538
22485
|
this.handleStartStroke(pointPressure);
|
|
22539
22486
|
e.evt.stopPropagation();
|
|
22540
22487
|
};
|
|
22541
|
-
stage.on("pointerdown", handlePointerDown);
|
|
22542
|
-
const handlePointerMove = (e) => {
|
|
22488
|
+
stage.on("pointerdown", handlePointerDown$1);
|
|
22489
|
+
const handlePointerMove$1 = (e) => {
|
|
22543
22490
|
if (this.state === BRUSH_TOOL_STATE.INACTIVE) return;
|
|
22544
22491
|
this.setCursor();
|
|
22545
22492
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
@@ -22562,15 +22509,15 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
22562
22509
|
}
|
|
22563
22510
|
e.evt.stopPropagation();
|
|
22564
22511
|
};
|
|
22565
|
-
stage.on("pointermove", handlePointerMove);
|
|
22566
|
-
const handlePointerUp = (e) => {
|
|
22512
|
+
stage.on("pointermove", handlePointerMove$1);
|
|
22513
|
+
const handlePointerUp$1 = (e) => {
|
|
22567
22514
|
this.penActive = false;
|
|
22568
22515
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
22569
22516
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
22570
22517
|
this.handleEndStroke();
|
|
22571
22518
|
e.evt.stopPropagation();
|
|
22572
22519
|
};
|
|
22573
|
-
stage.on("pointerup", handlePointerUp);
|
|
22520
|
+
stage.on("pointerup", handlePointerUp$1);
|
|
22574
22521
|
this.initialized = true;
|
|
22575
22522
|
}
|
|
22576
22523
|
setState(state) {
|
|
@@ -22802,7 +22749,7 @@ var WeaveTextToolAction = class extends WeaveAction {
|
|
|
22802
22749
|
this.cancelAction();
|
|
22803
22750
|
return;
|
|
22804
22751
|
}
|
|
22805
|
-
}, { signal: this.instance.getEventsController()
|
|
22752
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
22806
22753
|
stage.on("pointermove", () => {
|
|
22807
22754
|
if (this.state === TEXT_TOOL_STATE.IDLE) return;
|
|
22808
22755
|
this.setCursor();
|
|
@@ -22978,7 +22925,7 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
22978
22925
|
this.cancelAction();
|
|
22979
22926
|
return;
|
|
22980
22927
|
}
|
|
22981
|
-
}, { signal: this.instance.getEventsController()
|
|
22928
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
22982
22929
|
stage.on("pointerdown", (e) => {
|
|
22983
22930
|
this.setTapStart(e);
|
|
22984
22931
|
if (this.ignorePointerEvents) return;
|
|
@@ -23301,10 +23248,10 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
23301
23248
|
return this.state;
|
|
23302
23249
|
}
|
|
23303
23250
|
loadImageDataURL(imageDataURL) {
|
|
23304
|
-
return new Promise((resolve, reject
|
|
23251
|
+
return new Promise((resolve, reject) => {
|
|
23305
23252
|
const imageEle = Konva.Util.createImageElement();
|
|
23306
23253
|
imageEle.onerror = (error) => {
|
|
23307
|
-
reject
|
|
23254
|
+
reject(error);
|
|
23308
23255
|
};
|
|
23309
23256
|
imageEle.onload = async () => {
|
|
23310
23257
|
resolve(imageEle);
|
|
@@ -23313,13 +23260,13 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
23313
23260
|
});
|
|
23314
23261
|
}
|
|
23315
23262
|
getDataURL(blob) {
|
|
23316
|
-
return new Promise((resolve, reject
|
|
23263
|
+
return new Promise((resolve, reject) => {
|
|
23317
23264
|
const reader = new FileReader();
|
|
23318
23265
|
reader.onloadend = () => {
|
|
23319
23266
|
resolve(reader.result);
|
|
23320
23267
|
};
|
|
23321
23268
|
reader.onerror = () => {
|
|
23322
|
-
reject
|
|
23269
|
+
reject(new Error("Failed to generate dataURL from file"));
|
|
23323
23270
|
};
|
|
23324
23271
|
reader.readAsDataURL(blob);
|
|
23325
23272
|
});
|
|
@@ -23438,7 +23385,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
23438
23385
|
const stage = this.instance.getStage();
|
|
23439
23386
|
stage.container().addEventListener("keydown", (e) => {
|
|
23440
23387
|
if (e.key === "Escape" && this.instance.getActiveAction() === WEAVE_IMAGES_TOOL_ACTION_NAME) this.cancelAction();
|
|
23441
|
-
}, { signal: this.instance.getEventsController()
|
|
23388
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
23442
23389
|
stage.on("pointerdown", (e) => {
|
|
23443
23390
|
this.setTapStart(e);
|
|
23444
23391
|
this.pointers.set(e.evt.pointerId, {
|
|
@@ -23856,7 +23803,7 @@ var WeaveStarToolAction = class extends WeaveAction {
|
|
|
23856
23803
|
this.cancelAction();
|
|
23857
23804
|
return;
|
|
23858
23805
|
}
|
|
23859
|
-
}, { signal: this.instance.getEventsController()
|
|
23806
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
23860
23807
|
stage.on("pointerdown", (e) => {
|
|
23861
23808
|
this.setTapStart(e);
|
|
23862
23809
|
this.pointers.set(e.evt.pointerId, {
|
|
@@ -24079,7 +24026,7 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
24079
24026
|
return;
|
|
24080
24027
|
}
|
|
24081
24028
|
if (e.code === "Escape" && this.instance.getActiveAction() === WEAVE_ARROW_TOOL_ACTION_NAME) this.cancelAction();
|
|
24082
|
-
}, { signal: this.instance.getEventsController()
|
|
24029
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
24083
24030
|
stage.on("pointerdown", (e) => {
|
|
24084
24031
|
this.setTapStart(e);
|
|
24085
24032
|
this.pointers.set(e.evt.pointerId, {
|
|
@@ -24370,10 +24317,10 @@ var WeaveStrokeToolAction = class extends WeaveAction {
|
|
|
24370
24317
|
return;
|
|
24371
24318
|
}
|
|
24372
24319
|
if (e.key === "Shift" && this.getNames().includes(this.instance.getActiveAction() ?? "")) this.shiftPressed = true;
|
|
24373
|
-
}, { signal: this.instance.getEventsController()
|
|
24320
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
24374
24321
|
window.addEventListener("keyup", (e) => {
|
|
24375
24322
|
if (e.key === "Shift" && this.getNames().includes(this.instance.getActiveAction() ?? "")) this.shiftPressed = false;
|
|
24376
|
-
}, { signal: this.instance.getEventsController()
|
|
24323
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
24377
24324
|
stage.on("pointerdown", (e) => {
|
|
24378
24325
|
this.setTapStart(e);
|
|
24379
24326
|
this.pointers.set(e.evt.pointerId, {
|
|
@@ -24603,7 +24550,7 @@ var WeaveRegularPolygonToolAction = class extends WeaveAction {
|
|
|
24603
24550
|
this.cancelAction();
|
|
24604
24551
|
return;
|
|
24605
24552
|
}
|
|
24606
|
-
}, { signal: this.instance.getEventsController()
|
|
24553
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
24607
24554
|
stage.on("pointerdown", (e) => {
|
|
24608
24555
|
this.setTapStart(e);
|
|
24609
24556
|
this.pointers.set(e.evt.pointerId, {
|
|
@@ -24807,7 +24754,7 @@ var WeaveFrameToolAction = class extends WeaveAction {
|
|
|
24807
24754
|
this.cancelAction();
|
|
24808
24755
|
return;
|
|
24809
24756
|
}
|
|
24810
|
-
}, { signal: this.instance.getEventsController()
|
|
24757
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
24811
24758
|
stage.on("pointermove", () => {
|
|
24812
24759
|
if (this.state === FRAME_TOOL_STATE.IDLE) return;
|
|
24813
24760
|
this.setCursor();
|
|
@@ -25348,7 +25295,7 @@ var WeaveCommentToolAction = class extends WeaveAction {
|
|
|
25348
25295
|
return;
|
|
25349
25296
|
}
|
|
25350
25297
|
if (e.code === "Escape" && this.state === WEAVE_COMMENT_TOOL_STATE.CREATING_COMMENT) this.setState(WEAVE_COMMENT_TOOL_STATE.ADDING);
|
|
25351
|
-
}, { signal: this.instance.getEventsController()
|
|
25298
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
25352
25299
|
stage.on("pointermove", (e) => {
|
|
25353
25300
|
if (this.state === WEAVE_COMMENT_TOOL_STATE.IDLE) return;
|
|
25354
25301
|
if (commentNodeHandler?.isCommentViewing()) {
|
|
@@ -25550,7 +25497,7 @@ var WeaveVideoToolAction = class extends WeaveAction {
|
|
|
25550
25497
|
this.cancelAction();
|
|
25551
25498
|
return;
|
|
25552
25499
|
}
|
|
25553
|
-
}, { signal: this.instance.getEventsController()
|
|
25500
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
25554
25501
|
stage.on("pointerdown", (e) => {
|
|
25555
25502
|
this.setTapStart(e);
|
|
25556
25503
|
this.pointers.set(e.evt.pointerId, {
|
|
@@ -25713,7 +25660,7 @@ var WeaveMeasureToolAction = class extends WeaveAction {
|
|
|
25713
25660
|
const stage = this.instance.getStage();
|
|
25714
25661
|
window.addEventListener("keydown", (e) => {
|
|
25715
25662
|
if (e.code === "Escape" && this.instance.getActiveAction() === MEASURE_TOOL_ACTION_NAME) this.cancelAction();
|
|
25716
|
-
}, { signal: this.instance.getEventsController()
|
|
25663
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
25717
25664
|
stage.on("pointermove", () => {
|
|
25718
25665
|
if (this.state === MEASURE_TOOL_STATE.IDLE) return;
|
|
25719
25666
|
if (this.state === MEASURE_TOOL_STATE.SET_TO) {
|
|
@@ -26024,7 +25971,7 @@ var WeaveConnectorToolAction = class extends WeaveAction {
|
|
|
26024
25971
|
return;
|
|
26025
25972
|
}
|
|
26026
25973
|
if (e.code === "Escape" && this.instance.getActiveAction() === CONNECTOR_TOOL_ACTION_NAME) this.cancelAction();
|
|
26027
|
-
}, { signal: this.instance.getEventsController()
|
|
25974
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
26028
25975
|
let nodeHovered = void 0;
|
|
26029
25976
|
stage.on("pointermove", () => {
|
|
26030
25977
|
if (!(this.state === CONNECTOR_TOOL_STATE.SELECTING_INITIAL || this.state === CONNECTOR_TOOL_STATE.SELECTING_FINAL)) return;
|
|
@@ -26840,7 +26787,7 @@ var WeaveGuideToolAction = class extends WeaveAction {
|
|
|
26840
26787
|
window.addEventListener("keyup", (e) => {
|
|
26841
26788
|
const isOptionAltPressed = e.key === "Alt" || e.key === "Option";
|
|
26842
26789
|
if (isOptionAltPressed) this.guideDistanceToTargetInfo.cleanup();
|
|
26843
|
-
}, { signal: this.instance.getEventsController()
|
|
26790
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
26844
26791
|
window.addEventListener("keydown", (e) => {
|
|
26845
26792
|
const isOptionAltPressed = e.key === "Alt" || e.key === "Option";
|
|
26846
26793
|
if (isOptionAltPressed && this.instance.getActiveAction() === GUIDE_TOOL_ACTION_NAME && this.state === GUIDE_TOOL_STATE.ADDING) this.moveGuide(true);
|
|
@@ -26860,7 +26807,7 @@ var WeaveGuideToolAction = class extends WeaveAction {
|
|
|
26860
26807
|
this.cancelAction();
|
|
26861
26808
|
}
|
|
26862
26809
|
}
|
|
26863
|
-
}, { signal: this.instance.getEventsController()
|
|
26810
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
26864
26811
|
stage.on("pointermove", (e) => {
|
|
26865
26812
|
if (this.state === GUIDE_TOOL_STATE.IDLE) return;
|
|
26866
26813
|
this.setCursor();
|
|
@@ -27132,10 +27079,10 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
|
|
|
27132
27079
|
const stage = this.instance.getStage();
|
|
27133
27080
|
window.addEventListener("keydown", (e) => {
|
|
27134
27081
|
if (e.code === "Space") this.isSpaceKeyPressed = true;
|
|
27135
|
-
}, { signal: this.instance.getEventsController()
|
|
27082
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
27136
27083
|
window.addEventListener("keyup", (e) => {
|
|
27137
27084
|
if (e.code === "Space") this.isSpaceKeyPressed = false;
|
|
27138
|
-
}, { signal: this.instance.getEventsController()
|
|
27085
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
27139
27086
|
this.instance.addEventListener("onStageMove", () => {
|
|
27140
27087
|
this.onRender();
|
|
27141
27088
|
});
|
|
@@ -27452,7 +27399,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
27452
27399
|
this.isSpaceKeyPressed = true;
|
|
27453
27400
|
this.setCursor();
|
|
27454
27401
|
}
|
|
27455
|
-
}, { signal: this.instance.getEventsController()
|
|
27402
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
27456
27403
|
window.addEventListener("keyup", (e) => {
|
|
27457
27404
|
if (e.code === "Space") {
|
|
27458
27405
|
this.getContextMenuPlugin()?.enable();
|
|
@@ -27460,7 +27407,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
27460
27407
|
this.isSpaceKeyPressed = false;
|
|
27461
27408
|
this.disableMove();
|
|
27462
27409
|
}
|
|
27463
|
-
}, { signal: this.instance.getEventsController()
|
|
27410
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
27464
27411
|
let lastPos = null;
|
|
27465
27412
|
stage.on("pointerdown", (e) => {
|
|
27466
27413
|
this.pointers.set(e.evt.pointerId, {
|
|
@@ -27536,7 +27483,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
27536
27483
|
const handleWheelThrottled = (0, import_throttle.default)(handleWheel, WEAVE_STAGE_PANNING_THROTTLE_MS);
|
|
27537
27484
|
window.addEventListener("wheel", handleWheelThrottled, {
|
|
27538
27485
|
passive: true,
|
|
27539
|
-
signal: this.instance.getEventsController()
|
|
27486
|
+
signal: this.instance.getEventsController().signal
|
|
27540
27487
|
});
|
|
27541
27488
|
stage.on("dragstart", (e) => {
|
|
27542
27489
|
const duration = 1e3 / 60;
|
|
@@ -27588,7 +27535,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
27588
27535
|
e.preventDefault();
|
|
27589
27536
|
}, {
|
|
27590
27537
|
passive: false,
|
|
27591
|
-
signal: this.instance.getEventsController()
|
|
27538
|
+
signal: this.instance.getEventsController().signal
|
|
27592
27539
|
});
|
|
27593
27540
|
}
|
|
27594
27541
|
isPanning() {
|
|
@@ -27874,7 +27821,7 @@ var WeaveStageResizePlugin = class extends WeavePlugin {
|
|
|
27874
27821
|
}, DEFAULT_THROTTLE_MS);
|
|
27875
27822
|
window.addEventListener("resize", () => {
|
|
27876
27823
|
throttledResize();
|
|
27877
|
-
}, { signal: this.instance.getEventsController()
|
|
27824
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
27878
27825
|
const resizeObserver = new ResizeObserver(() => {
|
|
27879
27826
|
throttledResize();
|
|
27880
27827
|
});
|
|
@@ -28598,6 +28545,215 @@ var WeaveUsersPresencePlugin = class extends WeavePlugin {
|
|
|
28598
28545
|
}
|
|
28599
28546
|
};
|
|
28600
28547
|
|
|
28548
|
+
//#endregion
|
|
28549
|
+
//#region src/plugins/context-menu/context-menu.ts
|
|
28550
|
+
var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
28551
|
+
getLayerName = void 0;
|
|
28552
|
+
initLayer = void 0;
|
|
28553
|
+
constructor(params) {
|
|
28554
|
+
super();
|
|
28555
|
+
const { config } = params ?? {};
|
|
28556
|
+
this.config = {
|
|
28557
|
+
xOffset: WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT,
|
|
28558
|
+
yOffset: WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT,
|
|
28559
|
+
...config
|
|
28560
|
+
};
|
|
28561
|
+
this.initialize();
|
|
28562
|
+
}
|
|
28563
|
+
initialize() {
|
|
28564
|
+
this.timer = null;
|
|
28565
|
+
this.tapHold = false;
|
|
28566
|
+
this.contextMenuVisible = false;
|
|
28567
|
+
this.tapStart = {
|
|
28568
|
+
x: 0,
|
|
28569
|
+
y: 0,
|
|
28570
|
+
time: 0
|
|
28571
|
+
};
|
|
28572
|
+
this.tapHoldTimeout = WEAVE_CONTEXT_MENU_TAP_HOLD_TIMEOUT;
|
|
28573
|
+
this.pointers = {};
|
|
28574
|
+
}
|
|
28575
|
+
getName() {
|
|
28576
|
+
return WEAVE_CONTEXT_MENU_PLUGIN_KEY;
|
|
28577
|
+
}
|
|
28578
|
+
onInit() {
|
|
28579
|
+
this.initEvents();
|
|
28580
|
+
}
|
|
28581
|
+
isPressed(e) {
|
|
28582
|
+
return e.evt.buttons > 0;
|
|
28583
|
+
}
|
|
28584
|
+
setTapStart(e) {
|
|
28585
|
+
this.tapStart = {
|
|
28586
|
+
x: e.evt.clientX,
|
|
28587
|
+
y: e.evt.clientY,
|
|
28588
|
+
time: performance.now()
|
|
28589
|
+
};
|
|
28590
|
+
}
|
|
28591
|
+
triggerContextMenu(eventTarget, target) {
|
|
28592
|
+
const stage = this.instance.getStage();
|
|
28593
|
+
const selectionPlugin = this.getSelectionPlugin();
|
|
28594
|
+
let nodes = [];
|
|
28595
|
+
if (target && target !== stage) {
|
|
28596
|
+
const nodeHandler = this.instance.getNodeHandler(target.getAttrs().nodeType);
|
|
28597
|
+
nodes = [{
|
|
28598
|
+
instance: target,
|
|
28599
|
+
node: nodeHandler?.serialize(target)
|
|
28600
|
+
}];
|
|
28601
|
+
}
|
|
28602
|
+
const eventTargetParent = eventTarget.getParent();
|
|
28603
|
+
if (eventTargetParent instanceof Konva.Transformer) nodes = eventTargetParent.nodes().map((node) => {
|
|
28604
|
+
const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
|
|
28605
|
+
return {
|
|
28606
|
+
instance: node,
|
|
28607
|
+
node: nodeHandler?.serialize(node)
|
|
28608
|
+
};
|
|
28609
|
+
});
|
|
28610
|
+
if (this.contextMenuVisible) this.closeContextMenu();
|
|
28611
|
+
let allNodesMutexUnlocked = true;
|
|
28612
|
+
let allNodesUnlocked = true;
|
|
28613
|
+
const actUser = this.instance.getStore().getUser();
|
|
28614
|
+
for (const node of nodes) {
|
|
28615
|
+
const locked = node.instance.getAttrs().locked;
|
|
28616
|
+
const mutexInfo = this.instance.getNodeMutexLock(node.node?.key ?? "");
|
|
28617
|
+
if (locked) {
|
|
28618
|
+
allNodesUnlocked = false;
|
|
28619
|
+
break;
|
|
28620
|
+
}
|
|
28621
|
+
if (mutexInfo && mutexInfo.user.id !== actUser.id) {
|
|
28622
|
+
allNodesMutexUnlocked = false;
|
|
28623
|
+
break;
|
|
28624
|
+
}
|
|
28625
|
+
}
|
|
28626
|
+
if (!allNodesMutexUnlocked || !allNodesUnlocked) return;
|
|
28627
|
+
if (selectionPlugin && !(eventTarget.getParent() instanceof Konva.Transformer && selectionPlugin.getSelectedNodes().length > 0)) {
|
|
28628
|
+
selectionPlugin.setSelectedNodes([...nodes.map((node) => node.instance)]);
|
|
28629
|
+
selectionPlugin.getHoverTransformer().nodes([]);
|
|
28630
|
+
}
|
|
28631
|
+
const containerRect = stage.container().getBoundingClientRect();
|
|
28632
|
+
const pointerPos = stage.getPointerPosition();
|
|
28633
|
+
const relativeClickPoint = stage.getRelativePointerPosition();
|
|
28634
|
+
if (containerRect && pointerPos && relativeClickPoint && allNodesUnlocked) {
|
|
28635
|
+
const contextMenuPoint = {
|
|
28636
|
+
x: containerRect.left + pointerPos.x + (this.config.xOffset ?? 4),
|
|
28637
|
+
y: containerRect.top + pointerPos.y + (this.config.yOffset ?? 4)
|
|
28638
|
+
};
|
|
28639
|
+
const stageClickPoint = this.getStageClickPoint(pointerPos);
|
|
28640
|
+
this.contextMenuVisible = true;
|
|
28641
|
+
this.instance.emitEvent("onNodeContextMenu", {
|
|
28642
|
+
selection: nodes,
|
|
28643
|
+
contextMenuPoint,
|
|
28644
|
+
clickPoint: pointerPos,
|
|
28645
|
+
stageClickPoint,
|
|
28646
|
+
visible: true
|
|
28647
|
+
});
|
|
28648
|
+
}
|
|
28649
|
+
}
|
|
28650
|
+
closeContextMenu() {
|
|
28651
|
+
this.contextMenuVisible = false;
|
|
28652
|
+
this.instance.emitEvent("onNodeContextMenu", {
|
|
28653
|
+
selection: [],
|
|
28654
|
+
contextMenuPoint: {
|
|
28655
|
+
x: 0,
|
|
28656
|
+
y: 0
|
|
28657
|
+
},
|
|
28658
|
+
clickPoint: {
|
|
28659
|
+
x: 0,
|
|
28660
|
+
y: 0
|
|
28661
|
+
},
|
|
28662
|
+
stageClickPoint: {
|
|
28663
|
+
x: 0,
|
|
28664
|
+
y: 0
|
|
28665
|
+
},
|
|
28666
|
+
visible: false
|
|
28667
|
+
});
|
|
28668
|
+
}
|
|
28669
|
+
getSelectionPlugin() {
|
|
28670
|
+
const selectionPlugin = this.instance.getPlugin(WEAVE_NODES_SELECTION_KEY);
|
|
28671
|
+
return selectionPlugin;
|
|
28672
|
+
}
|
|
28673
|
+
cancelLongPressTimer() {
|
|
28674
|
+
if (this.timer) {
|
|
28675
|
+
clearTimeout(this.timer);
|
|
28676
|
+
this.timer = null;
|
|
28677
|
+
}
|
|
28678
|
+
}
|
|
28679
|
+
initEvents() {
|
|
28680
|
+
const stage = this.instance.getStage();
|
|
28681
|
+
stage.on("pointerdown", (e) => {
|
|
28682
|
+
this.setTapStart(e);
|
|
28683
|
+
this.pointers[e.evt.pointerId] = e.evt;
|
|
28684
|
+
if (e.evt.buttons === 0) return;
|
|
28685
|
+
if (e.evt.pointerType === "mouse") return;
|
|
28686
|
+
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
|
|
28687
|
+
if (this.timer) return;
|
|
28688
|
+
this.timer = setTimeout(() => {
|
|
28689
|
+
this.tapHold = true;
|
|
28690
|
+
const actualActions = this.instance.getActiveAction();
|
|
28691
|
+
if (actualActions !== SELECTION_TOOL_ACTION_NAME) return;
|
|
28692
|
+
delete this.pointers[e.evt.pointerId];
|
|
28693
|
+
const selectedGroup = getTargetedNode(this.instance);
|
|
28694
|
+
this.triggerContextMenu(e.target, selectedGroup);
|
|
28695
|
+
}, this.tapHoldTimeout);
|
|
28696
|
+
});
|
|
28697
|
+
stage.on("pointerup", (e) => {
|
|
28698
|
+
delete this.pointers[e.evt.pointerId];
|
|
28699
|
+
if (e.evt.pointerType === "mouse") return;
|
|
28700
|
+
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length + 1 > 1) return;
|
|
28701
|
+
if (this.timer) {
|
|
28702
|
+
clearTimeout(this.timer);
|
|
28703
|
+
this.timer = null;
|
|
28704
|
+
this.tapHold = false;
|
|
28705
|
+
}
|
|
28706
|
+
});
|
|
28707
|
+
stage.on("contextmenu", (e) => {
|
|
28708
|
+
e.evt.preventDefault();
|
|
28709
|
+
if (!this.enabled) return;
|
|
28710
|
+
const selectedGroup = getTargetedNode(this.instance);
|
|
28711
|
+
this.triggerContextMenu(e.target, selectedGroup);
|
|
28712
|
+
});
|
|
28713
|
+
this.instance.addEventListener("onStageSelection", () => {
|
|
28714
|
+
if (this.tapHold) return;
|
|
28715
|
+
const containerRect = stage.container().getBoundingClientRect();
|
|
28716
|
+
const pointerPos = stage.getPointerPosition();
|
|
28717
|
+
if (containerRect && pointerPos) {
|
|
28718
|
+
const contextMenuPoint = {
|
|
28719
|
+
x: containerRect.left + pointerPos.x + (this.config.xOffset ?? 4),
|
|
28720
|
+
y: containerRect.top + pointerPos.y + (this.config.yOffset ?? 4)
|
|
28721
|
+
};
|
|
28722
|
+
const stageClickPoint = this.getStageClickPoint(pointerPos);
|
|
28723
|
+
this.instance.emitEvent("onNodeContextMenu", {
|
|
28724
|
+
selection: [],
|
|
28725
|
+
contextMenuPoint,
|
|
28726
|
+
clickPoint: pointerPos,
|
|
28727
|
+
stageClickPoint,
|
|
28728
|
+
visible: false
|
|
28729
|
+
});
|
|
28730
|
+
}
|
|
28731
|
+
});
|
|
28732
|
+
}
|
|
28733
|
+
getStageClickPoint(pointerPos) {
|
|
28734
|
+
const stage = this.instance.getStage();
|
|
28735
|
+
const scale = stage.scale();
|
|
28736
|
+
const position = stage.position();
|
|
28737
|
+
const stageClickPoint = {
|
|
28738
|
+
x: (pointerPos.x - position.x) / scale.x,
|
|
28739
|
+
y: (pointerPos.y - position.y) / scale.y
|
|
28740
|
+
};
|
|
28741
|
+
return stageClickPoint;
|
|
28742
|
+
}
|
|
28743
|
+
isContextMenuVisible() {
|
|
28744
|
+
return this.contextMenuVisible;
|
|
28745
|
+
}
|
|
28746
|
+
isTapHold() {
|
|
28747
|
+
return this.tapHold;
|
|
28748
|
+
}
|
|
28749
|
+
enable() {
|
|
28750
|
+
this.enabled = true;
|
|
28751
|
+
}
|
|
28752
|
+
disable() {
|
|
28753
|
+
this.enabled = false;
|
|
28754
|
+
}
|
|
28755
|
+
};
|
|
28756
|
+
|
|
28601
28757
|
//#endregion
|
|
28602
28758
|
//#region src/plugins/stage-drop-area/constants.ts
|
|
28603
28759
|
const WEAVE_STAGE_DROP_AREA_KEY = "stageDropArea";
|
|
@@ -28625,18 +28781,18 @@ var WeaveStageDropAreaPlugin = class extends WeavePlugin {
|
|
|
28625
28781
|
stage.container().addEventListener("dragover", (e) => {
|
|
28626
28782
|
e.preventDefault();
|
|
28627
28783
|
e.stopPropagation();
|
|
28628
|
-
}, { signal: this.instance.getEventsController()
|
|
28784
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
28629
28785
|
stage.container().addEventListener("drop", (e) => {
|
|
28630
28786
|
e.preventDefault();
|
|
28631
28787
|
e.stopPropagation();
|
|
28632
28788
|
this.instance.emitEvent("onStageDrop", e);
|
|
28633
|
-
}, { signal: this.instance.getEventsController()
|
|
28789
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
28634
28790
|
window.addEventListener("dragover", (e) => e.preventDefault(), {
|
|
28635
|
-
signal: this.instance.getEventsController()
|
|
28791
|
+
signal: this.instance.getEventsController().signal,
|
|
28636
28792
|
passive: false
|
|
28637
28793
|
});
|
|
28638
28794
|
window.addEventListener("drop", (e) => e.preventDefault(), {
|
|
28639
|
-
signal: this.instance.getEventsController()
|
|
28795
|
+
signal: this.instance.getEventsController().signal,
|
|
28640
28796
|
passive: false
|
|
28641
28797
|
});
|
|
28642
28798
|
}
|
|
@@ -28804,7 +28960,7 @@ var WeaveStageKeyboardMovePlugin = class extends WeavePlugin {
|
|
|
28804
28960
|
if (e.code === "ArrowLeft") this.handleNodesMovement(WEAVE_STAGE_KEYBOARD_MOVE_ORIENTATION.LEFT, { isShiftPressed });
|
|
28805
28961
|
if (e.code === "ArrowRight") this.handleNodesMovement(WEAVE_STAGE_KEYBOARD_MOVE_ORIENTATION.RIGHT, { isShiftPressed });
|
|
28806
28962
|
if (e.code === "ArrowDown") this.handleNodesMovement(WEAVE_STAGE_KEYBOARD_MOVE_ORIENTATION.DOWN, { isShiftPressed });
|
|
28807
|
-
}, { signal: this.instance.getEventsController()
|
|
28963
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
28808
28964
|
}
|
|
28809
28965
|
enable() {
|
|
28810
28966
|
this.enabled = true;
|
|
@@ -28872,18 +29028,18 @@ var WeaveNodesSnappingCustomGuides = class {
|
|
|
28872
29028
|
const isOptionAltPressed = e.altKey;
|
|
28873
29029
|
this.cleanupDistanceGuide();
|
|
28874
29030
|
if (isOptionAltPressed && this.isDragging) this.handleDistanceGuide(isOptionAltPressed);
|
|
28875
|
-
}, { signal: this.instance.getEventsController()
|
|
29031
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
28876
29032
|
window.addEventListener("keyup", (e) => {
|
|
28877
29033
|
const isOptionAltPressed = e.key === "Alt" || e.key === "Option";
|
|
28878
29034
|
if (isOptionAltPressed) this.cleanupDistanceGuide();
|
|
28879
|
-
}, { signal: this.instance.getEventsController()
|
|
29035
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
28880
29036
|
window.addEventListener("keydown", (e) => {
|
|
28881
29037
|
const isOptionAltPressed = e.key === "Alt" || e.key === "Option";
|
|
28882
29038
|
if (isOptionAltPressed && this.isDragging) {
|
|
28883
29039
|
this.cleanupDistanceGuide();
|
|
28884
29040
|
this.handleDistanceGuide(isOptionAltPressed);
|
|
28885
29041
|
}
|
|
28886
|
-
}, { signal: this.instance.getEventsController()
|
|
29042
|
+
}, { signal: this.instance.getEventsController().signal });
|
|
28887
29043
|
}
|
|
28888
29044
|
getAllCustomGuides() {
|
|
28889
29045
|
return this.customGuides;
|
|
@@ -28914,6 +29070,7 @@ var WeaveNodesSnappingCustomGuides = class {
|
|
|
28914
29070
|
}
|
|
28915
29071
|
saveCustomGuide(guide) {
|
|
28916
29072
|
const containerId = guide.containerId;
|
|
29073
|
+
if (!this.customGuides) this.customGuides = {};
|
|
28917
29074
|
if (!this.customGuides[containerId]) this.customGuides[containerId] = [];
|
|
28918
29075
|
this.customGuides[containerId].push(guide);
|
|
28919
29076
|
this.instance.emitEvent("snappingManager:onCustomGuidesChange", { guides: this.customGuides });
|
|
@@ -29081,7 +29238,7 @@ var WeaveNodesSnappingCustomGuides = class {
|
|
|
29081
29238
|
this.setupEvents = false;
|
|
29082
29239
|
}
|
|
29083
29240
|
if (!this.noGuidesVisible() && !this.setupEvents) {
|
|
29084
|
-
stage.container().addEventListener("keydown", this.handleArrowKeys, { signal: this.instance.getEventsController()
|
|
29241
|
+
stage.container().addEventListener("keydown", this.handleArrowKeys, { signal: this.instance.getEventsController().signal });
|
|
29085
29242
|
stage.on("pointerclick", this.handlePointerClick);
|
|
29086
29243
|
this.instance.addEventListener("onNodesChange", this.handleOnNodesSelectedChange);
|
|
29087
29244
|
this.instance.addEventListener("onStageMove", this.handleStagePanChange);
|