@inditextech/weave-sdk 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sdk.cjs CHANGED
@@ -15761,7 +15761,7 @@ function clearContainerTargets(instance) {
15761
15761
  for (const container of getContainers) container.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, { bubbles: true });
15762
15762
  }
15763
15763
  function checkIfOverContainer(instance, node) {
15764
- const nodesIntersected = instance.pointIntersectsContainerElement();
15764
+ const nodesIntersected = instance.pointIntersectsContainerElement(node.getParent());
15765
15765
  let nodeActualContainer = node.getParent();
15766
15766
  if (nodeActualContainer?.getAttrs().nodeId) nodeActualContainer = instance.getStage().findOne(`#${nodeActualContainer.getAttrs().nodeId}`);
15767
15767
  let layerToMove = void 0;
@@ -15791,6 +15791,12 @@ function moveNodeToContainer(instance, node) {
15791
15791
  return layerToMove;
15792
15792
  }
15793
15793
 
15794
+ //#endregion
15795
+ //#region src/plugins/users-selection/constants.ts
15796
+ const WEAVE_USERS_SELECTION_KEY = "usersSelection";
15797
+ const WEAVE_USERS_SELECTION_LAYER_ID = "usersPointersLayer";
15798
+ const WEAVE_USER_SELECTION_KEY = "userSelection";
15799
+
15794
15800
  //#endregion
15795
15801
  //#region src/plugins/nodes-selection/nodes-selection.ts
15796
15802
  var WeaveNodesSelectionPlugin = class extends WeavePlugin {
@@ -15955,6 +15961,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
15955
15961
  node: nodeHandler.serialize(node)
15956
15962
  };
15957
15963
  });
15964
+ const usersSelectionPlugin = this.instance.getPlugin(WEAVE_USERS_SELECTION_KEY);
15965
+ if (usersSelectionPlugin) usersSelectionPlugin.sendSelectionAwarenessInfo(this.tr);
15958
15966
  this.instance.emitEvent("onNodesChange", selectedNodes);
15959
15967
  }
15960
15968
  removeSelectedNodes() {
@@ -17131,7 +17139,7 @@ var WeaveTargetingManager = class {
17131
17139
  this.logger = this.instance.getChildLogger("targeting-manager");
17132
17140
  this.logger.debug("Targeting manager created");
17133
17141
  }
17134
- pointIntersectsContainerElement(point) {
17142
+ pointIntersectsContainerElement(actualLayer, point) {
17135
17143
  const stage = this.instance.getStage();
17136
17144
  const relativeMousePointer = point ? point : stage.getPointerPosition() ?? {
17137
17145
  x: 0,
@@ -17143,11 +17151,11 @@ var WeaveTargetingManager = class {
17143
17151
  if (node.getAttrs().nodeId) {
17144
17152
  const parent = stage.findOne(`#${node.getAttrs().nodeId}`);
17145
17153
  intersectedNode = parent;
17146
- break;
17154
+ continue;
17147
17155
  }
17148
- if (node.getAttrs().containerId) {
17156
+ if (node.getAttrs().containerId && node.getAttrs().id !== actualLayer?.getAttrs().id) {
17149
17157
  intersectedNode = node;
17150
- break;
17158
+ continue;
17151
17159
  }
17152
17160
  }
17153
17161
  return intersectedNode;
@@ -17912,7 +17920,7 @@ var WeaveRegisterManager = class {
17912
17920
 
17913
17921
  //#endregion
17914
17922
  //#region package.json
17915
- var version = "0.15.0";
17923
+ var version = "0.16.0";
17916
17924
 
17917
17925
  //#endregion
17918
17926
  //#region src/managers/setup.ts
@@ -18518,8 +18526,8 @@ var Weave = class extends Emittery {
18518
18526
  unGroup(group) {
18519
18527
  this.groupsManager.unGroup(group);
18520
18528
  }
18521
- pointIntersectsContainerElement(point) {
18522
- return this.targetingManager.pointIntersectsContainerElement(point);
18529
+ pointIntersectsContainerElement(actualLayer, point) {
18530
+ return this.targetingManager.pointIntersectsContainerElement(actualLayer, point);
18523
18531
  }
18524
18532
  getMousePointer(point) {
18525
18533
  return this.targetingManager.getMousePointer(point);
@@ -21615,27 +21623,223 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
21615
21623
  }
21616
21624
  };
21617
21625
 
21626
+ //#endregion
21627
+ //#region src/plugins/users-selection/users-selection.ts
21628
+ var WeaveUsersSelectionPlugin = class extends WeavePlugin {
21629
+ constructor(params) {
21630
+ super();
21631
+ const { config } = params;
21632
+ this.config = config;
21633
+ this.usersSelection = {};
21634
+ }
21635
+ getName() {
21636
+ return WEAVE_USERS_SELECTION_KEY;
21637
+ }
21638
+ getLayerName() {
21639
+ return WEAVE_USERS_SELECTION_LAYER_ID;
21640
+ }
21641
+ initLayer() {
21642
+ const stage = this.instance.getStage();
21643
+ const layer = new konva.default.Layer({
21644
+ id: this.getLayerName(),
21645
+ listening: false
21646
+ });
21647
+ stage.add(layer);
21648
+ }
21649
+ onRender() {
21650
+ this.renderSelectors();
21651
+ }
21652
+ getLayer() {
21653
+ const stage = this.instance.getStage();
21654
+ return stage.findOne(`#${WEAVE_USERS_SELECTION_LAYER_ID}`);
21655
+ }
21656
+ onInit() {
21657
+ this.instance.addEventListener("onAwarenessChange", (changes) => {
21658
+ const selfUser = this.config.getUser();
21659
+ const allActiveUsers = [];
21660
+ for (const change of changes) {
21661
+ if (!change[WEAVE_USER_SELECTION_KEY]) continue;
21662
+ if (change[WEAVE_USER_SELECTION_KEY] && selfUser.name !== change[WEAVE_USER_SELECTION_KEY].user) {
21663
+ const userSelection = change[WEAVE_USER_SELECTION_KEY];
21664
+ allActiveUsers.push(userSelection.user);
21665
+ this.usersSelection[userSelection.user] = {
21666
+ oldNodes: this.usersSelection[userSelection.user]?.actualNodes ?? {
21667
+ user: userSelection.user,
21668
+ nodes: []
21669
+ },
21670
+ actualNodes: userSelection
21671
+ };
21672
+ }
21673
+ }
21674
+ const allActiveUsersSelections = Object.keys(this.usersSelection).map((userSelectionKey) => {
21675
+ const selectionInfo = this.usersSelection[userSelectionKey];
21676
+ return selectionInfo.actualNodes.user;
21677
+ });
21678
+ const inactiveSelections = import_lodash.default.differenceWith(allActiveUsersSelections, allActiveUsers, import_lodash.default.isEqual);
21679
+ const selectionsLayer = this.getLayer();
21680
+ for (const inactiveSelection of inactiveSelections) {
21681
+ const userPointerNode = selectionsLayer?.findOne(`#${inactiveSelection}`);
21682
+ if (userPointerNode) userPointerNode.destroy();
21683
+ delete this.usersSelection[inactiveSelection];
21684
+ }
21685
+ this.renderSelectors();
21686
+ });
21687
+ this.renderSelectors();
21688
+ }
21689
+ sendSelectionAwarenessInfo(tr) {
21690
+ const userInfo = this.config.getUser();
21691
+ const store = this.instance.getStore();
21692
+ store.setAwarenessInfo(WEAVE_USER_SELECTION_KEY, {
21693
+ user: userInfo.name,
21694
+ nodes: tr.nodes().map((node) => node.getAttrs().id)
21695
+ });
21696
+ }
21697
+ removeSelectionAwarenessInfo() {
21698
+ const store = this.instance.getStore();
21699
+ store.setAwarenessInfo(WEAVE_USER_SELECTION_KEY, void 0);
21700
+ }
21701
+ stringToColor(str) {
21702
+ let hash = 0;
21703
+ str.split("").forEach((char) => {
21704
+ hash = char.charCodeAt(0) + ((hash << 5) - hash);
21705
+ });
21706
+ let color = "#";
21707
+ for (let i = 0; i < 3; i++) {
21708
+ const value = hash >> i * 8 & 255;
21709
+ color += value.toString(16).padStart(2, "0");
21710
+ }
21711
+ return color;
21712
+ }
21713
+ getSelectedNodesRect(nodes) {
21714
+ const stage = this.instance.getStage();
21715
+ const maxPoint = {
21716
+ x: -Infinity,
21717
+ y: -Infinity
21718
+ };
21719
+ const minPoint = {
21720
+ x: Infinity,
21721
+ y: Infinity
21722
+ };
21723
+ for (const nodeId of nodes) {
21724
+ const node = stage.findOne(`#${nodeId}`);
21725
+ if (node) {
21726
+ const nodeRect = node.getClientRect({
21727
+ relativeTo: stage,
21728
+ skipStroke: true
21729
+ });
21730
+ if (nodeRect.x < minPoint.x) minPoint.x = nodeRect.x;
21731
+ if (nodeRect.y < minPoint.y) minPoint.y = nodeRect.y;
21732
+ if (nodeRect.x + nodeRect.width > maxPoint.x) maxPoint.x = nodeRect.x + nodeRect.width;
21733
+ if (nodeRect.y + nodeRect.height > maxPoint.y) maxPoint.y = nodeRect.y + nodeRect.height;
21734
+ }
21735
+ }
21736
+ return {
21737
+ x: minPoint.x,
21738
+ y: minPoint.y,
21739
+ width: Math.abs(maxPoint.x - minPoint.x) * stage.scaleX(),
21740
+ height: Math.abs(maxPoint.y - minPoint.y) * stage.scaleY()
21741
+ };
21742
+ }
21743
+ renderSelectors() {
21744
+ const stage = this.instance.getStage();
21745
+ const selectorsLayer = this.getLayer();
21746
+ if (!this.enabled) return;
21747
+ const selectors = selectorsLayer?.find(".selector") ?? [];
21748
+ for (const selector of selectors) selector.destroy();
21749
+ for (const userPointerKey of Object.keys(this.usersSelection)) {
21750
+ const userSelector = this.usersSelection[userPointerKey];
21751
+ const userSelectorNode = selectorsLayer?.findOne(`#selector_${userSelector.actualNodes.user}`);
21752
+ if (!userSelectorNode) {
21753
+ const selectionRect = this.getSelectedNodesRect(userSelector.actualNodes.nodes);
21754
+ const userSelectorNode$1 = new konva.default.Group({
21755
+ name: "selector",
21756
+ id: `selector_${userSelector.actualNodes.user}`,
21757
+ x: selectionRect.x,
21758
+ y: selectionRect.y,
21759
+ width: selectionRect.width / stage.scaleX(),
21760
+ height: selectionRect.height / stage.scaleY(),
21761
+ listening: false
21762
+ });
21763
+ const userSelectorRect$1 = new konva.default.Rect({
21764
+ x: 0,
21765
+ y: 0,
21766
+ id: `selector_${userSelector.actualNodes.user}_rect`,
21767
+ width: selectionRect.width / stage.scaleX(),
21768
+ height: selectionRect.height / stage.scaleY(),
21769
+ fill: "transparent",
21770
+ stroke: this.stringToColor(userSelector.actualNodes.user),
21771
+ strokeWidth: 3,
21772
+ strokeScaleEnabled: false
21773
+ });
21774
+ userSelectorNode$1.add(userSelectorRect$1);
21775
+ selectorsLayer?.add(userSelectorNode$1);
21776
+ continue;
21777
+ }
21778
+ const userSelectorRect = selectorsLayer?.findOne(`#selector_${userSelector.actualNodes.user}_rect`);
21779
+ if (userSelectorRect) {
21780
+ const selectionRect = this.getSelectedNodesRect(userSelector.actualNodes.nodes);
21781
+ userSelectorNode.setAttrs({
21782
+ x: selectionRect.x,
21783
+ y: selectionRect.y,
21784
+ width: selectionRect.width,
21785
+ height: selectionRect.height,
21786
+ scale: 1
21787
+ });
21788
+ userSelectorRect.setAttrs({
21789
+ x: 0,
21790
+ y: 0,
21791
+ width: selectionRect.width,
21792
+ height: selectionRect.height
21793
+ });
21794
+ }
21795
+ }
21796
+ }
21797
+ enable() {
21798
+ this.getLayer()?.show();
21799
+ this.enabled = true;
21800
+ }
21801
+ disable() {
21802
+ this.getLayer()?.hide();
21803
+ this.enabled = false;
21804
+ }
21805
+ };
21806
+
21618
21807
  //#endregion
21619
21808
  //#region src/plugins/users-pointers/constants.ts
21620
21809
  const WEAVE_USERS_POINTERS_KEY = "usersPointers";
21621
21810
  const WEAVE_USERS_POINTERS_LAYER_ID = "usersPointersLayer";
21622
21811
  const WEAVE_USER_POINTER_KEY = "userPointer";
21812
+ const WEAVE_DEFAULT_USER_INFO_FUNCTION = () => ({
21813
+ name: "Unknown",
21814
+ email: "unknown@domain.com"
21815
+ });
21816
+ const WEAVE_USER_POINTERS_DEFAULT_PROPS = {
21817
+ separation: 8,
21818
+ pointer: {
21819
+ circleRadius: 4,
21820
+ circleStrokeWidth: 0
21821
+ },
21822
+ name: {
21823
+ fontFamily: "Arial",
21824
+ fontSize: 10,
21825
+ backgroundCornerRadius: 0,
21826
+ backgroundPaddingX: 8,
21827
+ backgroundPaddingY: 4
21828
+ }
21829
+ };
21623
21830
 
21624
21831
  //#endregion
21625
21832
  //#region src/plugins/users-pointers/users-pointers.ts
21626
21833
  var WeaveUsersPointersPlugin = class extends WeavePlugin {
21627
- userPointerCircleRadius = 4;
21628
- userPointerSeparation = 8;
21629
- userPointerCircleStrokeWidth = 1;
21630
- userPointerNameFontSize = 10;
21631
- userPointerBackgroundCornerRadius = 4;
21632
- userPointerBackgroundPaddingX = 4;
21633
- userPointerBackgroundPaddingY = 8;
21634
21834
  constructor(params) {
21635
21835
  super();
21636
21836
  const { config } = params;
21637
- this.usersPointers = {};
21638
21837
  this.config = config;
21838
+ this.uiConfig = {
21839
+ ...WEAVE_USER_POINTERS_DEFAULT_PROPS,
21840
+ ...this.config.ui
21841
+ };
21842
+ this.usersPointers = {};
21639
21843
  }
21640
21844
  getName() {
21641
21845
  return WEAVE_USERS_POINTERS_KEY;
@@ -21686,7 +21890,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
21686
21890
  const inactivePointers = import_lodash.default.differenceWith(allActiveUsersPointers, allActiveUsers, import_lodash.default.isEqual);
21687
21891
  const pointersLayer = this.getLayer();
21688
21892
  for (const inactivePointer of inactivePointers) {
21689
- const userPointerNode = pointersLayer?.findOne(`#${inactivePointer}`);
21893
+ const userPointerNode = pointersLayer?.findOne(`#pointer_${inactivePointer}`);
21690
21894
  if (userPointerNode) userPointerNode.destroy();
21691
21895
  delete this.usersPointers[inactivePointer];
21692
21896
  }
@@ -21714,17 +21918,25 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
21714
21918
  });
21715
21919
  this.renderPointers();
21716
21920
  }
21717
- stringToColour(str) {
21921
+ getContrastTextColor(hex) {
21922
+ const cleaned = hex.replace(/^#/, "");
21923
+ const r = parseInt(cleaned.slice(0, 2), 16);
21924
+ const g = parseInt(cleaned.slice(2, 4), 16);
21925
+ const b = parseInt(cleaned.slice(4, 6), 16);
21926
+ const luminance = (.299 * r + .587 * g + .114 * b) / 255;
21927
+ return luminance > .5 ? "black" : "white";
21928
+ }
21929
+ stringToColor(str) {
21718
21930
  let hash = 0;
21719
21931
  str.split("").forEach((char) => {
21720
21932
  hash = char.charCodeAt(0) + ((hash << 5) - hash);
21721
21933
  });
21722
- let colour = "#";
21934
+ let color = "#";
21723
21935
  for (let i = 0; i < 3; i++) {
21724
21936
  const value = hash >> i * 8 & 255;
21725
- colour += value.toString(16).padStart(2, "0");
21937
+ color += value.toString(16).padStart(2, "0");
21726
21938
  }
21727
- return colour;
21939
+ return color;
21728
21940
  }
21729
21941
  renderPointers() {
21730
21942
  const stage = this.instance.getStage();
@@ -21732,52 +21944,61 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
21732
21944
  if (!this.enabled) return;
21733
21945
  for (const userPointerKey of Object.keys(this.usersPointers)) {
21734
21946
  const userPointer = this.usersPointers[userPointerKey];
21735
- const userPointerNode = pointersLayer?.findOne(`#${userPointer.actualPos.user}`);
21947
+ const userPointerNode = pointersLayer?.findOne(`#pointer_${userPointer.actualPos.user}`);
21736
21948
  if (!userPointerNode) {
21737
21949
  const userPointerNode$1 = new konva.default.Group({
21738
21950
  name: "pointer",
21739
- id: userPointer.actualPos.user,
21951
+ id: `pointer_${userPointer.actualPos.user}`,
21740
21952
  x: userPointer.actualPos.x,
21741
21953
  y: userPointer.actualPos.y,
21742
21954
  opacity: 1,
21743
21955
  listening: false
21744
21956
  });
21745
- const userPointNode$1 = new konva.default.Circle({
21746
- id: "userPoint",
21957
+ const { separation, pointer: { circleRadius, circleStrokeWidth }, name: { fontFamily, fontSize, backgroundCornerRadius, backgroundPaddingX, backgroundPaddingY } } = this.uiConfig;
21958
+ const userColor = this.stringToColor(userPointer.actualPos.user);
21959
+ const userContrastColor = this.getContrastTextColor(userColor);
21960
+ const userPointNode = new konva.default.Circle({
21961
+ id: `pointer_${userPointer.actualPos.user}_userPoint`,
21747
21962
  x: 0,
21748
21963
  y: 0,
21749
- radius: this.userPointerCircleRadius / stage.scaleX(),
21750
- fill: this.stringToColour(userPointer.actualPos.user),
21964
+ radius: circleRadius,
21965
+ fill: userColor,
21751
21966
  stroke: "black",
21752
- strokeWidth: this.userPointerCircleStrokeWidth / stage.scaleX(),
21967
+ strokeWidth: circleStrokeWidth,
21968
+ strokeScaleEnabled: false,
21753
21969
  listening: false
21754
21970
  });
21755
21971
  const userNameNode = new konva.default.Text({
21756
- id: "userPointName",
21757
- x: (this.userPointerSeparation + this.userPointerBackgroundPaddingX) / stage.scaleX(),
21758
- y: 0 / stage.scaleX(),
21759
- height: userPointNode$1.height() * 2 / stage.scaleX(),
21760
- text: userPointer.actualPos.user,
21761
- fontSize: this.userPointerNameFontSize / stage.scaleX(),
21762
- fontFamily: "NotoSansMono, monospace",
21763
- fill: "black",
21764
- align: "left",
21972
+ id: `pointer_${userPointer.actualPos.user}_userPointName`,
21973
+ x: separation,
21974
+ y: -circleRadius * 2 + backgroundPaddingY,
21975
+ text: userPointer.actualPos.user.trim(),
21976
+ fontSize,
21977
+ fontFamily,
21978
+ lineHeight: .9,
21979
+ fill: userContrastColor,
21980
+ align: "center",
21765
21981
  verticalAlign: "middle",
21766
- listening: false
21982
+ listening: false,
21983
+ strokeScaleEnabled: false,
21984
+ ellipsis: true
21767
21985
  });
21986
+ const textWidth = userNameNode.getTextWidth();
21987
+ const textHeight = userNameNode.getTextHeight();
21988
+ userNameNode.width(textWidth + backgroundPaddingX * 2);
21989
+ userNameNode.height(textHeight + backgroundPaddingY * 2);
21768
21990
  const userNameBackground = new konva.default.Rect({
21769
- id: "userPointRect",
21770
- x: this.userPointerSeparation / stage.scaleX(),
21771
- y: -this.userPointerBackgroundPaddingY / stage.scaleX(),
21772
- width: (userNameNode.width() + this.userPointerBackgroundPaddingX * 2) / stage.scaleX(),
21773
- height: (userNameNode.height() + this.userPointerBackgroundPaddingY * 2) / stage.scaleX(),
21774
- cornerRadius: this.userPointerBackgroundCornerRadius / stage.scaleX(),
21775
- fill: "rgba(0,0,0,0.2)",
21776
- strokeWidth: 0,
21991
+ id: `pointer_${userPointer.actualPos.user}_userPointRect`,
21992
+ x: separation,
21993
+ y: -backgroundPaddingY,
21994
+ width: textWidth + backgroundPaddingX * 2,
21995
+ height: textHeight + backgroundPaddingY * 2,
21996
+ cornerRadius: backgroundCornerRadius,
21997
+ fill: userColor,
21777
21998
  listening: false
21778
21999
  });
21779
- userPointNode$1.setAttrs({ y: userNameBackground.y() + userNameBackground.height() / 2 });
21780
- userPointerNode$1.add(userPointNode$1);
22000
+ userPointNode.setAttrs({ y: userNameBackground.y() + userNameBackground.height() / 2 });
22001
+ userPointerNode$1.add(userPointNode);
21781
22002
  userPointerNode$1.add(userNameBackground);
21782
22003
  userPointerNode$1.add(userNameNode);
21783
22004
  pointersLayer?.add(userPointerNode$1);
@@ -21792,27 +22013,8 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
21792
22013
  y: userPointer.actualPos.y
21793
22014
  };
21794
22015
  const hasChanged = !import_lodash.default.isEqual(actualPos, oldPos);
21795
- const userPointNode = userPointerNode.getChildren((node) => node.getAttrs().id === "userPoint");
21796
- userPointNode[0]?.setAttrs({
21797
- radius: this.userPointerCircleRadius / stage.scaleX(),
21798
- strokeWidth: this.userPointerCircleStrokeWidth / stage.scaleX()
21799
- });
21800
- const userPointNodeText = userPointerNode.getChildren((node) => node.getAttrs().id === "userPointName");
21801
- userPointNodeText[0]?.setAttrs({
21802
- x: (this.userPointerSeparation + this.userPointerBackgroundPaddingX) / stage.scaleX(),
21803
- y: 0 / stage.scaleX(),
21804
- height: userPointNode[0]?.height(),
21805
- fontSize: this.userPointerNameFontSize / stage.scaleX()
21806
- });
21807
- const userPointNodeBackground = userPointerNode.getChildren((node) => node.getAttrs().id === "userPointRect");
21808
- userPointNodeBackground[0]?.setAttrs({
21809
- x: this.userPointerSeparation / stage.scaleX(),
21810
- y: -this.userPointerBackgroundPaddingY / stage.scaleX(),
21811
- cornerRadius: this.userPointerBackgroundCornerRadius / stage.scaleX(),
21812
- width: userPointNodeText[0]?.width() + this.userPointerBackgroundPaddingX * 2,
21813
- height: userPointNodeText[0]?.height() + this.userPointerBackgroundPaddingY * 2
21814
- });
21815
- userPointNode[0]?.setAttrs({ y: userPointNodeBackground[0]?.y() + userPointNodeBackground[0]?.height() / 2 });
22016
+ userPointerNode.scaleX(1 / stage.scaleX());
22017
+ userPointerNode.scaleY(1 / stage.scaleY());
21816
22018
  if (hasChanged) userPointerNode.setAttrs({
21817
22019
  x: userPointer.actualPos.x,
21818
22020
  y: userPointer.actualPos.y,
@@ -22248,6 +22450,7 @@ exports.SELECTION_TOOL_STATE = SELECTION_TOOL_STATE
22248
22450
  exports.TEXT_TOOL_ACTION_NAME = TEXT_TOOL_ACTION_NAME
22249
22451
  exports.TEXT_TOOL_STATE = TEXT_TOOL_STATE
22250
22452
  exports.WEAVE_COPY_PASTE_NODES_KEY = WEAVE_COPY_PASTE_NODES_KEY
22453
+ exports.WEAVE_DEFAULT_USER_INFO_FUNCTION = WEAVE_DEFAULT_USER_INFO_FUNCTION
22251
22454
  exports.WEAVE_FRAME_NODE_DEFAULT_CONFIG = WEAVE_FRAME_NODE_DEFAULT_CONFIG
22252
22455
  exports.WEAVE_FRAME_NODE_DEFAULT_PROPS = WEAVE_FRAME_NODE_DEFAULT_PROPS
22253
22456
  exports.WEAVE_FRAME_NODE_SIZES = WEAVE_FRAME_NODE_SIZES
@@ -22265,6 +22468,13 @@ exports.WEAVE_NODES_SELECTION_KEY = WEAVE_NODES_SELECTION_KEY
22265
22468
  exports.WEAVE_NODES_SELECTION_LAYER_ID = WEAVE_NODES_SELECTION_LAYER_ID
22266
22469
  exports.WEAVE_NODES_SNAPPING_KEY = WEAVE_NODES_SNAPPING_KEY
22267
22470
  exports.WEAVE_STAGE_GRID_KEY = WEAVE_STAGE_GRID_KEY
22471
+ exports.WEAVE_USERS_POINTERS_KEY = WEAVE_USERS_POINTERS_KEY
22472
+ exports.WEAVE_USERS_POINTERS_LAYER_ID = WEAVE_USERS_POINTERS_LAYER_ID
22473
+ exports.WEAVE_USERS_SELECTION_KEY = WEAVE_USERS_SELECTION_KEY
22474
+ exports.WEAVE_USERS_SELECTION_LAYER_ID = WEAVE_USERS_SELECTION_LAYER_ID
22475
+ exports.WEAVE_USER_POINTERS_DEFAULT_PROPS = WEAVE_USER_POINTERS_DEFAULT_PROPS
22476
+ exports.WEAVE_USER_POINTER_KEY = WEAVE_USER_POINTER_KEY
22477
+ exports.WEAVE_USER_SELECTION_KEY = WEAVE_USER_SELECTION_KEY
22268
22478
  exports.Weave = Weave
22269
22479
  exports.WeaveAction = WeaveAction
22270
22480
  exports.WeaveBrushToolAction = WeaveBrushToolAction
@@ -22301,6 +22511,7 @@ exports.WeaveStore = WeaveStore
22301
22511
  exports.WeaveTextNode = WeaveTextNode
22302
22512
  exports.WeaveTextToolAction = WeaveTextToolAction
22303
22513
  exports.WeaveUsersPointersPlugin = WeaveUsersPointersPlugin
22514
+ exports.WeaveUsersSelectionPlugin = WeaveUsersSelectionPlugin
22304
22515
  exports.WeaveZoomInToolAction = WeaveZoomInToolAction
22305
22516
  exports.WeaveZoomOutToolAction = WeaveZoomOutToolAction
22306
22517
  exports.checkIfOverContainer = checkIfOverContainer
package/dist/sdk.d.cts CHANGED
@@ -436,7 +436,7 @@ declare class Weave extends Emittery {
436
436
  bringToFront(node: WeaveElementInstance): void;
437
437
  group(nodes: WeaveStateElement[]): void;
438
438
  unGroup(group: WeaveStateElement): void;
439
- pointIntersectsContainerElement(point?: Vector2d): Konva.Node | undefined;
439
+ pointIntersectsContainerElement(actualLayer?: Konva.Layer | Konva.Group, point?: Vector2d): Konva.Node | undefined;
440
440
  getMousePointer(point?: Vector2d): WeaveMousePointInfo;
441
441
  getMousePointerRelativeToContainer(container: Konva.Group | Konva.Layer): WeaveMousePointInfoSimple;
442
442
  selectNodesByKey(nodesIds: string[]): void;
@@ -1278,14 +1278,90 @@ declare class WeaveConnectedUsersPlugin extends WeavePlugin {
1278
1278
  disable(): void;
1279
1279
  }
1280
1280
 
1281
+ //#endregion
1282
+ //#region src/plugins/users-selection/constants.d.ts
1283
+ declare const WEAVE_USERS_SELECTION_KEY = "usersSelection";
1284
+ declare const WEAVE_USERS_SELECTION_LAYER_ID = "usersPointersLayer";
1285
+ declare const WEAVE_USER_SELECTION_KEY = "userSelection";
1286
+
1287
+ //#endregion
1288
+ //#region src/plugins/users-selection/types.d.ts
1289
+ type WeaveUsersSelectionPluginConfig = {
1290
+ getUser: () => WeaveUser;
1291
+ };
1292
+ type WeaveUsersSelectionPluginParams = {
1293
+ config: WeaveUsersSelectionPluginConfig;
1294
+ };
1295
+ type WeaveUserSelectionInfo = {
1296
+ user: string;
1297
+ nodes: string[];
1298
+ };
1299
+ type WeaveUserSelectionKey = typeof WEAVE_USER_SELECTION_KEY;
1300
+
1301
+ //#endregion
1302
+ //#region src/plugins/users-selection/users-selection.d.ts
1303
+ declare class WeaveUsersSelectionPlugin extends WeavePlugin {
1304
+ private usersSelection;
1305
+ private config;
1306
+ constructor(params: WeaveUsersSelectionPluginParams);
1307
+ getName(): string;
1308
+ getLayerName(): string;
1309
+ initLayer(): void;
1310
+ onRender(): void;
1311
+ getLayer(): Konva.Layer | undefined;
1312
+ onInit(): void;
1313
+ sendSelectionAwarenessInfo(tr: Konva.Transformer): void;
1314
+ removeSelectionAwarenessInfo(): void;
1315
+ private stringToColor;
1316
+ private getSelectedNodesRect;
1317
+ private renderSelectors;
1318
+ enable(): void;
1319
+ disable(): void;
1320
+ }
1321
+
1281
1322
  //#endregion
1282
1323
  //#region src/plugins/users-pointers/constants.d.ts
1324
+ declare const WEAVE_USERS_POINTERS_KEY = "usersPointers";
1325
+ declare const WEAVE_USERS_POINTERS_LAYER_ID = "usersPointersLayer";
1283
1326
  declare const WEAVE_USER_POINTER_KEY = "userPointer";
1327
+ declare const WEAVE_DEFAULT_USER_INFO_FUNCTION: () => {
1328
+ name: string;
1329
+ email: string;
1330
+ };
1331
+ declare const WEAVE_USER_POINTERS_DEFAULT_PROPS: {
1332
+ separation: number;
1333
+ pointer: {
1334
+ circleRadius: number;
1335
+ circleStrokeWidth: number;
1336
+ };
1337
+ name: {
1338
+ fontFamily: string;
1339
+ fontSize: number;
1340
+ backgroundCornerRadius: number;
1341
+ backgroundPaddingX: number;
1342
+ backgroundPaddingY: number;
1343
+ };
1344
+ };
1284
1345
 
1285
1346
  //#endregion
1286
1347
  //#region src/plugins/users-pointers/types.d.ts
1348
+ type WeaveUserPointersUIProperties = {
1349
+ separation: number;
1350
+ pointer: {
1351
+ circleRadius: number;
1352
+ circleStrokeWidth: number;
1353
+ };
1354
+ name: {
1355
+ fontFamily: string;
1356
+ fontSize: number;
1357
+ backgroundCornerRadius: number;
1358
+ backgroundPaddingX: number;
1359
+ backgroundPaddingY: number;
1360
+ };
1361
+ };
1287
1362
  type WeaveUsersPointersPluginConfig = {
1288
1363
  getUser: () => WeaveUser;
1364
+ ui?: WeaveUserPointersUIProperties;
1289
1365
  };
1290
1366
  type WeaveUsersPointersPluginParams = {
1291
1367
  config: WeaveUsersPointersPluginConfig;
@@ -1302,13 +1378,7 @@ type WeaveUserPointerKey = typeof WEAVE_USER_POINTER_KEY;
1302
1378
  declare class WeaveUsersPointersPlugin extends WeavePlugin {
1303
1379
  private usersPointers;
1304
1380
  private config;
1305
- private userPointerCircleRadius;
1306
- private userPointerSeparation;
1307
- private userPointerCircleStrokeWidth;
1308
- private userPointerNameFontSize;
1309
- private userPointerBackgroundCornerRadius;
1310
- private userPointerBackgroundPaddingX;
1311
- private userPointerBackgroundPaddingY;
1381
+ private uiConfig;
1312
1382
  constructor(params: WeaveUsersPointersPluginParams);
1313
1383
  getName(): string;
1314
1384
  getLayerName(): string;
@@ -1316,7 +1386,8 @@ declare class WeaveUsersPointersPlugin extends WeavePlugin {
1316
1386
  onRender(): void;
1317
1387
  getLayer(): Konva.Layer | undefined;
1318
1388
  onInit(): void;
1319
- private stringToColour;
1389
+ private getContrastTextColor;
1390
+ private stringToColor;
1320
1391
  private renderPointers;
1321
1392
  enable(): void;
1322
1393
  disable(): void;
@@ -1514,4 +1585,4 @@ declare class WeaveNodesSnappingPlugin extends WeavePlugin {
1514
1585
  }
1515
1586
 
1516
1587
  //#endregion
1517
- export { BRUSH_TOOL_ACTION_NAME, BRUSH_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_LINE_DEFAULT_CONFIG, GUIDE_LINE_DRAG_SNAPPING_THRESHOLD, GUIDE_LINE_NAME, GUIDE_LINE_TRANSFORM_SNAPPING_THRESHOLD, GUIDE_ORIENTATION, Guide, GuideOrientation, GuideOrientationKeys, IMAGE_TOOL_ACTION_NAME, IMAGE_TOOL_STATE, ImageProps, LineGuide, LineGuideStop, MOVE_TOOL_ACTION_NAME, MOVE_TOOL_STATE, NODE_SNAP, NodeSnap, NodeSnapKeys, NodeSnappingEdge, NodeSnappingEdges, PEN_TOOL_ACTION_NAME, PEN_TOOL_STATE, RECTANGLE_TOOL_ACTION_NAME, RECTANGLE_TOOL_STATE, SELECTION_TOOL_ACTION_NAME, SELECTION_TOOL_STATE, TEXT_TOOL_ACTION_NAME, TEXT_TOOL_STATE, TextSerializable, WEAVE_COPY_PASTE_NODES_KEY, WEAVE_FRAME_NODE_DEFAULT_CONFIG, WEAVE_FRAME_NODE_DEFAULT_PROPS, WEAVE_FRAME_NODE_SIZES, WEAVE_FRAME_NODE_SIZES_MULTIPLIER, WEAVE_FRAME_NODE_SIZES_ORIENTATION, WEAVE_FRAME_NODE_SIZES_TYPES, WEAVE_FRAME_NODE_TYPE, WEAVE_GRID_DEFAULT_COLOR, WEAVE_GRID_DEFAULT_ORIGIN_COLOR, WEAVE_GRID_DEFAULT_SIZE, WEAVE_GRID_DEFAULT_TYPE, WEAVE_GRID_LAYER_ID, WEAVE_GRID_TYPES, WEAVE_NODES_SELECTION_KEY, WEAVE_NODES_SELECTION_LAYER_ID, WEAVE_NODES_SNAPPING_KEY, WEAVE_STAGE_GRID_KEY, Weave, WeaveAction, WeaveActionPropsChangeEvent, WeaveBrushToolAction, WeaveBrushToolActionState, WeaveBrushToolActionStateKeys, WeaveConnectedUserInfoKey, WeaveConnectedUsers, WeaveConnectedUsersChangeEvent, WeaveConnectedUsersPlugin, WeaveConnectedUsersPluginConfig, WeaveConnectedUsersPluginParams, WeaveContextMenuPlugin, WeaveCopyPasteNodesPlugin, WeaveCopyPasteNodesPluginOnCopyEvent, WeaveCopyPasteNodesPluginOnPasteEvent, WeaveCopyPasteNodesPluginOnPasteExternalEvent, WeaveCopyPasteNodesPluginState, WeaveCopyPasteNodesPluginStateKeys, WeaveExportNodeActionParams, WeaveExportNodeToolAction, WeaveExportStageActionParams, WeaveExportStageToolAction, WeaveFitToScreenToolAction, WeaveFitToScreenToolActionParams, WeaveFitToSelectionToolAction, WeaveFitToSelectionToolActionParams, WeaveFrameAttributes, WeaveFrameNode, WeaveFrameNodeParams, WeaveFrameNodeSizes, WeaveFrameNodeSizesInfo, WeaveFrameNodeSizesKeys, WeaveFrameNodeSizesOrientation, WeaveFrameNodeSizesOrientationKeys, WeaveFrameProperties, WeaveFrameToolAction, WeaveFrameToolActionState, WeaveFrameToolActionStateKeys, WeaveFrameToolActionTriggerParams, WeaveFrameToolProps, WeaveGroupNode, WeaveImageNode, WeaveImageToolAction, WeaveImageToolActionOnEndLoadImageEvent, WeaveImageToolActionOnStartLoadImageEvent, WeaveImageToolActionState, WeaveImageToolActionStateKeys, WeaveImageToolActionTriggerParams, WeaveImageToolActionTriggerReturn, WeaveLayerNode, WeaveLineNode, WeaveMoveToolAction, WeaveMoveToolActionState, WeaveMoveToolActionStateKeys, WeaveNode, WeaveNodesSelectionPlugin, WeaveNodesSelectionPluginConfig, WeaveNodesSelectionPluginOnNodesChangeEvent, WeaveNodesSelectionPluginOnSelectionStateEvent, WeaveNodesSelectionPluginOnStageSelectionEvent, WeaveNodesSelectionPluginParams, WeaveNodesSnappingPlugin, WeaveNodesSnappingPluginConfig, WeaveNodesSnappingPluginParams, WeavePasteModel, WeavePenToolAction, WeavePenToolActionState, WeavePenToolActionStateKeys, WeavePlugin, WeaveRectangleNode, WeaveRectangleToolAction, WeaveRectangleToolActionState, WeaveRectangleToolActionStateKeys, WeaveSelectionToolAction, WeaveSelectionToolActionState, WeaveSelectionToolActionStateKeys, WeaveStageContextMenuPluginConfig, WeaveStageContextMenuPluginOnNodeContextMenuEvent, WeaveStageContextMenuPluginParams, WeaveStageDropAreaPlugin, WeaveStageDropPluginOnStageDropEvent, WeaveStageGridPlugin, WeaveStageGridPluginConfig, WeaveStageGridPluginParams, WeaveStageGridType, WeaveStageGridTypeKeys, WeaveStageNode, WeaveStagePanningPlugin, WeaveStageResizePlugin, WeaveStageZoomChanged, WeaveStageZoomPlugin, WeaveStageZoomPluginConfig, WeaveStageZoomPluginOnZoomChangeEvent, WeaveStageZoomPluginParams, WeaveStore, WeaveTextNode, WeaveTextToolAction, WeaveTextToolActionState, WeaveTextToolActionStateKeys, WeaveToPasteNode, WeaveUserPointer, WeaveUserPointerKey, WeaveUsersPointersPlugin, WeaveUsersPointersPluginConfig, WeaveUsersPointersPluginParams, WeaveZoomInToolAction, WeaveZoomInToolActionParams, WeaveZoomOutToolAction, WeaveZoomOutToolActionParams, checkIfOverContainer, clearContainerTargets, moveNodeToContainer, resetScale };
1588
+ export { BRUSH_TOOL_ACTION_NAME, BRUSH_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_LINE_DEFAULT_CONFIG, GUIDE_LINE_DRAG_SNAPPING_THRESHOLD, GUIDE_LINE_NAME, GUIDE_LINE_TRANSFORM_SNAPPING_THRESHOLD, GUIDE_ORIENTATION, Guide, GuideOrientation, GuideOrientationKeys, IMAGE_TOOL_ACTION_NAME, IMAGE_TOOL_STATE, ImageProps, LineGuide, LineGuideStop, MOVE_TOOL_ACTION_NAME, MOVE_TOOL_STATE, NODE_SNAP, NodeSnap, NodeSnapKeys, NodeSnappingEdge, NodeSnappingEdges, PEN_TOOL_ACTION_NAME, PEN_TOOL_STATE, RECTANGLE_TOOL_ACTION_NAME, RECTANGLE_TOOL_STATE, SELECTION_TOOL_ACTION_NAME, SELECTION_TOOL_STATE, TEXT_TOOL_ACTION_NAME, TEXT_TOOL_STATE, TextSerializable, WEAVE_COPY_PASTE_NODES_KEY, WEAVE_DEFAULT_USER_INFO_FUNCTION, WEAVE_FRAME_NODE_DEFAULT_CONFIG, WEAVE_FRAME_NODE_DEFAULT_PROPS, WEAVE_FRAME_NODE_SIZES, WEAVE_FRAME_NODE_SIZES_MULTIPLIER, WEAVE_FRAME_NODE_SIZES_ORIENTATION, WEAVE_FRAME_NODE_SIZES_TYPES, WEAVE_FRAME_NODE_TYPE, WEAVE_GRID_DEFAULT_COLOR, WEAVE_GRID_DEFAULT_ORIGIN_COLOR, WEAVE_GRID_DEFAULT_SIZE, WEAVE_GRID_DEFAULT_TYPE, WEAVE_GRID_LAYER_ID, WEAVE_GRID_TYPES, WEAVE_NODES_SELECTION_KEY, WEAVE_NODES_SELECTION_LAYER_ID, WEAVE_NODES_SNAPPING_KEY, WEAVE_STAGE_GRID_KEY, WEAVE_USERS_POINTERS_KEY, WEAVE_USERS_POINTERS_LAYER_ID, WEAVE_USERS_SELECTION_KEY, WEAVE_USERS_SELECTION_LAYER_ID, WEAVE_USER_POINTERS_DEFAULT_PROPS, WEAVE_USER_POINTER_KEY, WEAVE_USER_SELECTION_KEY, Weave, WeaveAction, WeaveActionPropsChangeEvent, WeaveBrushToolAction, WeaveBrushToolActionState, WeaveBrushToolActionStateKeys, WeaveConnectedUserInfoKey, WeaveConnectedUsers, WeaveConnectedUsersChangeEvent, WeaveConnectedUsersPlugin, WeaveConnectedUsersPluginConfig, WeaveConnectedUsersPluginParams, WeaveContextMenuPlugin, WeaveCopyPasteNodesPlugin, WeaveCopyPasteNodesPluginOnCopyEvent, WeaveCopyPasteNodesPluginOnPasteEvent, WeaveCopyPasteNodesPluginOnPasteExternalEvent, WeaveCopyPasteNodesPluginState, WeaveCopyPasteNodesPluginStateKeys, WeaveExportNodeActionParams, WeaveExportNodeToolAction, WeaveExportStageActionParams, WeaveExportStageToolAction, WeaveFitToScreenToolAction, WeaveFitToScreenToolActionParams, WeaveFitToSelectionToolAction, WeaveFitToSelectionToolActionParams, WeaveFrameAttributes, WeaveFrameNode, WeaveFrameNodeParams, WeaveFrameNodeSizes, WeaveFrameNodeSizesInfo, WeaveFrameNodeSizesKeys, WeaveFrameNodeSizesOrientation, WeaveFrameNodeSizesOrientationKeys, WeaveFrameProperties, WeaveFrameToolAction, WeaveFrameToolActionState, WeaveFrameToolActionStateKeys, WeaveFrameToolActionTriggerParams, WeaveFrameToolProps, WeaveGroupNode, WeaveImageNode, WeaveImageToolAction, WeaveImageToolActionOnEndLoadImageEvent, WeaveImageToolActionOnStartLoadImageEvent, WeaveImageToolActionState, WeaveImageToolActionStateKeys, WeaveImageToolActionTriggerParams, WeaveImageToolActionTriggerReturn, WeaveLayerNode, WeaveLineNode, WeaveMoveToolAction, WeaveMoveToolActionState, WeaveMoveToolActionStateKeys, WeaveNode, WeaveNodesSelectionPlugin, WeaveNodesSelectionPluginConfig, WeaveNodesSelectionPluginOnNodesChangeEvent, WeaveNodesSelectionPluginOnSelectionStateEvent, WeaveNodesSelectionPluginOnStageSelectionEvent, WeaveNodesSelectionPluginParams, WeaveNodesSnappingPlugin, WeaveNodesSnappingPluginConfig, WeaveNodesSnappingPluginParams, WeavePasteModel, WeavePenToolAction, WeavePenToolActionState, WeavePenToolActionStateKeys, WeavePlugin, WeaveRectangleNode, WeaveRectangleToolAction, WeaveRectangleToolActionState, WeaveRectangleToolActionStateKeys, WeaveSelectionToolAction, WeaveSelectionToolActionState, WeaveSelectionToolActionStateKeys, WeaveStageContextMenuPluginConfig, WeaveStageContextMenuPluginOnNodeContextMenuEvent, WeaveStageContextMenuPluginParams, WeaveStageDropAreaPlugin, WeaveStageDropPluginOnStageDropEvent, WeaveStageGridPlugin, WeaveStageGridPluginConfig, WeaveStageGridPluginParams, WeaveStageGridType, WeaveStageGridTypeKeys, WeaveStageNode, WeaveStagePanningPlugin, WeaveStageResizePlugin, WeaveStageZoomChanged, WeaveStageZoomPlugin, WeaveStageZoomPluginConfig, WeaveStageZoomPluginOnZoomChangeEvent, WeaveStageZoomPluginParams, WeaveStore, WeaveTextNode, WeaveTextToolAction, WeaveTextToolActionState, WeaveTextToolActionStateKeys, WeaveToPasteNode, WeaveUserPointer, WeaveUserPointerKey, WeaveUserPointersUIProperties, WeaveUserSelectionInfo, WeaveUserSelectionKey, WeaveUsersPointersPlugin, WeaveUsersPointersPluginConfig, WeaveUsersPointersPluginParams, WeaveUsersSelectionPlugin, WeaveUsersSelectionPluginConfig, WeaveUsersSelectionPluginParams, WeaveZoomInToolAction, WeaveZoomInToolActionParams, WeaveZoomOutToolAction, WeaveZoomOutToolActionParams, checkIfOverContainer, clearContainerTargets, moveNodeToContainer, resetScale };
package/dist/sdk.d.ts CHANGED
@@ -436,7 +436,7 @@ declare class Weave extends Emittery {
436
436
  bringToFront(node: WeaveElementInstance): void;
437
437
  group(nodes: WeaveStateElement[]): void;
438
438
  unGroup(group: WeaveStateElement): void;
439
- pointIntersectsContainerElement(point?: Vector2d): Konva.Node | undefined;
439
+ pointIntersectsContainerElement(actualLayer?: Konva.Layer | Konva.Group, point?: Vector2d): Konva.Node | undefined;
440
440
  getMousePointer(point?: Vector2d): WeaveMousePointInfo;
441
441
  getMousePointerRelativeToContainer(container: Konva.Group | Konva.Layer): WeaveMousePointInfoSimple;
442
442
  selectNodesByKey(nodesIds: string[]): void;
@@ -1278,14 +1278,90 @@ declare class WeaveConnectedUsersPlugin extends WeavePlugin {
1278
1278
  disable(): void;
1279
1279
  }
1280
1280
 
1281
+ //#endregion
1282
+ //#region src/plugins/users-selection/constants.d.ts
1283
+ declare const WEAVE_USERS_SELECTION_KEY = "usersSelection";
1284
+ declare const WEAVE_USERS_SELECTION_LAYER_ID = "usersPointersLayer";
1285
+ declare const WEAVE_USER_SELECTION_KEY = "userSelection";
1286
+
1287
+ //#endregion
1288
+ //#region src/plugins/users-selection/types.d.ts
1289
+ type WeaveUsersSelectionPluginConfig = {
1290
+ getUser: () => WeaveUser;
1291
+ };
1292
+ type WeaveUsersSelectionPluginParams = {
1293
+ config: WeaveUsersSelectionPluginConfig;
1294
+ };
1295
+ type WeaveUserSelectionInfo = {
1296
+ user: string;
1297
+ nodes: string[];
1298
+ };
1299
+ type WeaveUserSelectionKey = typeof WEAVE_USER_SELECTION_KEY;
1300
+
1301
+ //#endregion
1302
+ //#region src/plugins/users-selection/users-selection.d.ts
1303
+ declare class WeaveUsersSelectionPlugin extends WeavePlugin {
1304
+ private usersSelection;
1305
+ private config;
1306
+ constructor(params: WeaveUsersSelectionPluginParams);
1307
+ getName(): string;
1308
+ getLayerName(): string;
1309
+ initLayer(): void;
1310
+ onRender(): void;
1311
+ getLayer(): Konva.Layer | undefined;
1312
+ onInit(): void;
1313
+ sendSelectionAwarenessInfo(tr: Konva.Transformer): void;
1314
+ removeSelectionAwarenessInfo(): void;
1315
+ private stringToColor;
1316
+ private getSelectedNodesRect;
1317
+ private renderSelectors;
1318
+ enable(): void;
1319
+ disable(): void;
1320
+ }
1321
+
1281
1322
  //#endregion
1282
1323
  //#region src/plugins/users-pointers/constants.d.ts
1324
+ declare const WEAVE_USERS_POINTERS_KEY = "usersPointers";
1325
+ declare const WEAVE_USERS_POINTERS_LAYER_ID = "usersPointersLayer";
1283
1326
  declare const WEAVE_USER_POINTER_KEY = "userPointer";
1327
+ declare const WEAVE_DEFAULT_USER_INFO_FUNCTION: () => {
1328
+ name: string;
1329
+ email: string;
1330
+ };
1331
+ declare const WEAVE_USER_POINTERS_DEFAULT_PROPS: {
1332
+ separation: number;
1333
+ pointer: {
1334
+ circleRadius: number;
1335
+ circleStrokeWidth: number;
1336
+ };
1337
+ name: {
1338
+ fontFamily: string;
1339
+ fontSize: number;
1340
+ backgroundCornerRadius: number;
1341
+ backgroundPaddingX: number;
1342
+ backgroundPaddingY: number;
1343
+ };
1344
+ };
1284
1345
 
1285
1346
  //#endregion
1286
1347
  //#region src/plugins/users-pointers/types.d.ts
1348
+ type WeaveUserPointersUIProperties = {
1349
+ separation: number;
1350
+ pointer: {
1351
+ circleRadius: number;
1352
+ circleStrokeWidth: number;
1353
+ };
1354
+ name: {
1355
+ fontFamily: string;
1356
+ fontSize: number;
1357
+ backgroundCornerRadius: number;
1358
+ backgroundPaddingX: number;
1359
+ backgroundPaddingY: number;
1360
+ };
1361
+ };
1287
1362
  type WeaveUsersPointersPluginConfig = {
1288
1363
  getUser: () => WeaveUser;
1364
+ ui?: WeaveUserPointersUIProperties;
1289
1365
  };
1290
1366
  type WeaveUsersPointersPluginParams = {
1291
1367
  config: WeaveUsersPointersPluginConfig;
@@ -1302,13 +1378,7 @@ type WeaveUserPointerKey = typeof WEAVE_USER_POINTER_KEY;
1302
1378
  declare class WeaveUsersPointersPlugin extends WeavePlugin {
1303
1379
  private usersPointers;
1304
1380
  private config;
1305
- private userPointerCircleRadius;
1306
- private userPointerSeparation;
1307
- private userPointerCircleStrokeWidth;
1308
- private userPointerNameFontSize;
1309
- private userPointerBackgroundCornerRadius;
1310
- private userPointerBackgroundPaddingX;
1311
- private userPointerBackgroundPaddingY;
1381
+ private uiConfig;
1312
1382
  constructor(params: WeaveUsersPointersPluginParams);
1313
1383
  getName(): string;
1314
1384
  getLayerName(): string;
@@ -1316,7 +1386,8 @@ declare class WeaveUsersPointersPlugin extends WeavePlugin {
1316
1386
  onRender(): void;
1317
1387
  getLayer(): Konva.Layer | undefined;
1318
1388
  onInit(): void;
1319
- private stringToColour;
1389
+ private getContrastTextColor;
1390
+ private stringToColor;
1320
1391
  private renderPointers;
1321
1392
  enable(): void;
1322
1393
  disable(): void;
@@ -1514,4 +1585,4 @@ declare class WeaveNodesSnappingPlugin extends WeavePlugin {
1514
1585
  }
1515
1586
 
1516
1587
  //#endregion
1517
- export { BRUSH_TOOL_ACTION_NAME, BRUSH_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_LINE_DEFAULT_CONFIG, GUIDE_LINE_DRAG_SNAPPING_THRESHOLD, GUIDE_LINE_NAME, GUIDE_LINE_TRANSFORM_SNAPPING_THRESHOLD, GUIDE_ORIENTATION, Guide, GuideOrientation, GuideOrientationKeys, IMAGE_TOOL_ACTION_NAME, IMAGE_TOOL_STATE, ImageProps, LineGuide, LineGuideStop, MOVE_TOOL_ACTION_NAME, MOVE_TOOL_STATE, NODE_SNAP, NodeSnap, NodeSnapKeys, NodeSnappingEdge, NodeSnappingEdges, PEN_TOOL_ACTION_NAME, PEN_TOOL_STATE, RECTANGLE_TOOL_ACTION_NAME, RECTANGLE_TOOL_STATE, SELECTION_TOOL_ACTION_NAME, SELECTION_TOOL_STATE, TEXT_TOOL_ACTION_NAME, TEXT_TOOL_STATE, TextSerializable, WEAVE_COPY_PASTE_NODES_KEY, WEAVE_FRAME_NODE_DEFAULT_CONFIG, WEAVE_FRAME_NODE_DEFAULT_PROPS, WEAVE_FRAME_NODE_SIZES, WEAVE_FRAME_NODE_SIZES_MULTIPLIER, WEAVE_FRAME_NODE_SIZES_ORIENTATION, WEAVE_FRAME_NODE_SIZES_TYPES, WEAVE_FRAME_NODE_TYPE, WEAVE_GRID_DEFAULT_COLOR, WEAVE_GRID_DEFAULT_ORIGIN_COLOR, WEAVE_GRID_DEFAULT_SIZE, WEAVE_GRID_DEFAULT_TYPE, WEAVE_GRID_LAYER_ID, WEAVE_GRID_TYPES, WEAVE_NODES_SELECTION_KEY, WEAVE_NODES_SELECTION_LAYER_ID, WEAVE_NODES_SNAPPING_KEY, WEAVE_STAGE_GRID_KEY, Weave, WeaveAction, WeaveActionPropsChangeEvent, WeaveBrushToolAction, WeaveBrushToolActionState, WeaveBrushToolActionStateKeys, WeaveConnectedUserInfoKey, WeaveConnectedUsers, WeaveConnectedUsersChangeEvent, WeaveConnectedUsersPlugin, WeaveConnectedUsersPluginConfig, WeaveConnectedUsersPluginParams, WeaveContextMenuPlugin, WeaveCopyPasteNodesPlugin, WeaveCopyPasteNodesPluginOnCopyEvent, WeaveCopyPasteNodesPluginOnPasteEvent, WeaveCopyPasteNodesPluginOnPasteExternalEvent, WeaveCopyPasteNodesPluginState, WeaveCopyPasteNodesPluginStateKeys, WeaveExportNodeActionParams, WeaveExportNodeToolAction, WeaveExportStageActionParams, WeaveExportStageToolAction, WeaveFitToScreenToolAction, WeaveFitToScreenToolActionParams, WeaveFitToSelectionToolAction, WeaveFitToSelectionToolActionParams, WeaveFrameAttributes, WeaveFrameNode, WeaveFrameNodeParams, WeaveFrameNodeSizes, WeaveFrameNodeSizesInfo, WeaveFrameNodeSizesKeys, WeaveFrameNodeSizesOrientation, WeaveFrameNodeSizesOrientationKeys, WeaveFrameProperties, WeaveFrameToolAction, WeaveFrameToolActionState, WeaveFrameToolActionStateKeys, WeaveFrameToolActionTriggerParams, WeaveFrameToolProps, WeaveGroupNode, WeaveImageNode, WeaveImageToolAction, WeaveImageToolActionOnEndLoadImageEvent, WeaveImageToolActionOnStartLoadImageEvent, WeaveImageToolActionState, WeaveImageToolActionStateKeys, WeaveImageToolActionTriggerParams, WeaveImageToolActionTriggerReturn, WeaveLayerNode, WeaveLineNode, WeaveMoveToolAction, WeaveMoveToolActionState, WeaveMoveToolActionStateKeys, WeaveNode, WeaveNodesSelectionPlugin, WeaveNodesSelectionPluginConfig, WeaveNodesSelectionPluginOnNodesChangeEvent, WeaveNodesSelectionPluginOnSelectionStateEvent, WeaveNodesSelectionPluginOnStageSelectionEvent, WeaveNodesSelectionPluginParams, WeaveNodesSnappingPlugin, WeaveNodesSnappingPluginConfig, WeaveNodesSnappingPluginParams, WeavePasteModel, WeavePenToolAction, WeavePenToolActionState, WeavePenToolActionStateKeys, WeavePlugin, WeaveRectangleNode, WeaveRectangleToolAction, WeaveRectangleToolActionState, WeaveRectangleToolActionStateKeys, WeaveSelectionToolAction, WeaveSelectionToolActionState, WeaveSelectionToolActionStateKeys, WeaveStageContextMenuPluginConfig, WeaveStageContextMenuPluginOnNodeContextMenuEvent, WeaveStageContextMenuPluginParams, WeaveStageDropAreaPlugin, WeaveStageDropPluginOnStageDropEvent, WeaveStageGridPlugin, WeaveStageGridPluginConfig, WeaveStageGridPluginParams, WeaveStageGridType, WeaveStageGridTypeKeys, WeaveStageNode, WeaveStagePanningPlugin, WeaveStageResizePlugin, WeaveStageZoomChanged, WeaveStageZoomPlugin, WeaveStageZoomPluginConfig, WeaveStageZoomPluginOnZoomChangeEvent, WeaveStageZoomPluginParams, WeaveStore, WeaveTextNode, WeaveTextToolAction, WeaveTextToolActionState, WeaveTextToolActionStateKeys, WeaveToPasteNode, WeaveUserPointer, WeaveUserPointerKey, WeaveUsersPointersPlugin, WeaveUsersPointersPluginConfig, WeaveUsersPointersPluginParams, WeaveZoomInToolAction, WeaveZoomInToolActionParams, WeaveZoomOutToolAction, WeaveZoomOutToolActionParams, checkIfOverContainer, clearContainerTargets, moveNodeToContainer, resetScale };
1588
+ export { BRUSH_TOOL_ACTION_NAME, BRUSH_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_LINE_DEFAULT_CONFIG, GUIDE_LINE_DRAG_SNAPPING_THRESHOLD, GUIDE_LINE_NAME, GUIDE_LINE_TRANSFORM_SNAPPING_THRESHOLD, GUIDE_ORIENTATION, Guide, GuideOrientation, GuideOrientationKeys, IMAGE_TOOL_ACTION_NAME, IMAGE_TOOL_STATE, ImageProps, LineGuide, LineGuideStop, MOVE_TOOL_ACTION_NAME, MOVE_TOOL_STATE, NODE_SNAP, NodeSnap, NodeSnapKeys, NodeSnappingEdge, NodeSnappingEdges, PEN_TOOL_ACTION_NAME, PEN_TOOL_STATE, RECTANGLE_TOOL_ACTION_NAME, RECTANGLE_TOOL_STATE, SELECTION_TOOL_ACTION_NAME, SELECTION_TOOL_STATE, TEXT_TOOL_ACTION_NAME, TEXT_TOOL_STATE, TextSerializable, WEAVE_COPY_PASTE_NODES_KEY, WEAVE_DEFAULT_USER_INFO_FUNCTION, WEAVE_FRAME_NODE_DEFAULT_CONFIG, WEAVE_FRAME_NODE_DEFAULT_PROPS, WEAVE_FRAME_NODE_SIZES, WEAVE_FRAME_NODE_SIZES_MULTIPLIER, WEAVE_FRAME_NODE_SIZES_ORIENTATION, WEAVE_FRAME_NODE_SIZES_TYPES, WEAVE_FRAME_NODE_TYPE, WEAVE_GRID_DEFAULT_COLOR, WEAVE_GRID_DEFAULT_ORIGIN_COLOR, WEAVE_GRID_DEFAULT_SIZE, WEAVE_GRID_DEFAULT_TYPE, WEAVE_GRID_LAYER_ID, WEAVE_GRID_TYPES, WEAVE_NODES_SELECTION_KEY, WEAVE_NODES_SELECTION_LAYER_ID, WEAVE_NODES_SNAPPING_KEY, WEAVE_STAGE_GRID_KEY, WEAVE_USERS_POINTERS_KEY, WEAVE_USERS_POINTERS_LAYER_ID, WEAVE_USERS_SELECTION_KEY, WEAVE_USERS_SELECTION_LAYER_ID, WEAVE_USER_POINTERS_DEFAULT_PROPS, WEAVE_USER_POINTER_KEY, WEAVE_USER_SELECTION_KEY, Weave, WeaveAction, WeaveActionPropsChangeEvent, WeaveBrushToolAction, WeaveBrushToolActionState, WeaveBrushToolActionStateKeys, WeaveConnectedUserInfoKey, WeaveConnectedUsers, WeaveConnectedUsersChangeEvent, WeaveConnectedUsersPlugin, WeaveConnectedUsersPluginConfig, WeaveConnectedUsersPluginParams, WeaveContextMenuPlugin, WeaveCopyPasteNodesPlugin, WeaveCopyPasteNodesPluginOnCopyEvent, WeaveCopyPasteNodesPluginOnPasteEvent, WeaveCopyPasteNodesPluginOnPasteExternalEvent, WeaveCopyPasteNodesPluginState, WeaveCopyPasteNodesPluginStateKeys, WeaveExportNodeActionParams, WeaveExportNodeToolAction, WeaveExportStageActionParams, WeaveExportStageToolAction, WeaveFitToScreenToolAction, WeaveFitToScreenToolActionParams, WeaveFitToSelectionToolAction, WeaveFitToSelectionToolActionParams, WeaveFrameAttributes, WeaveFrameNode, WeaveFrameNodeParams, WeaveFrameNodeSizes, WeaveFrameNodeSizesInfo, WeaveFrameNodeSizesKeys, WeaveFrameNodeSizesOrientation, WeaveFrameNodeSizesOrientationKeys, WeaveFrameProperties, WeaveFrameToolAction, WeaveFrameToolActionState, WeaveFrameToolActionStateKeys, WeaveFrameToolActionTriggerParams, WeaveFrameToolProps, WeaveGroupNode, WeaveImageNode, WeaveImageToolAction, WeaveImageToolActionOnEndLoadImageEvent, WeaveImageToolActionOnStartLoadImageEvent, WeaveImageToolActionState, WeaveImageToolActionStateKeys, WeaveImageToolActionTriggerParams, WeaveImageToolActionTriggerReturn, WeaveLayerNode, WeaveLineNode, WeaveMoveToolAction, WeaveMoveToolActionState, WeaveMoveToolActionStateKeys, WeaveNode, WeaveNodesSelectionPlugin, WeaveNodesSelectionPluginConfig, WeaveNodesSelectionPluginOnNodesChangeEvent, WeaveNodesSelectionPluginOnSelectionStateEvent, WeaveNodesSelectionPluginOnStageSelectionEvent, WeaveNodesSelectionPluginParams, WeaveNodesSnappingPlugin, WeaveNodesSnappingPluginConfig, WeaveNodesSnappingPluginParams, WeavePasteModel, WeavePenToolAction, WeavePenToolActionState, WeavePenToolActionStateKeys, WeavePlugin, WeaveRectangleNode, WeaveRectangleToolAction, WeaveRectangleToolActionState, WeaveRectangleToolActionStateKeys, WeaveSelectionToolAction, WeaveSelectionToolActionState, WeaveSelectionToolActionStateKeys, WeaveStageContextMenuPluginConfig, WeaveStageContextMenuPluginOnNodeContextMenuEvent, WeaveStageContextMenuPluginParams, WeaveStageDropAreaPlugin, WeaveStageDropPluginOnStageDropEvent, WeaveStageGridPlugin, WeaveStageGridPluginConfig, WeaveStageGridPluginParams, WeaveStageGridType, WeaveStageGridTypeKeys, WeaveStageNode, WeaveStagePanningPlugin, WeaveStageResizePlugin, WeaveStageZoomChanged, WeaveStageZoomPlugin, WeaveStageZoomPluginConfig, WeaveStageZoomPluginOnZoomChangeEvent, WeaveStageZoomPluginParams, WeaveStore, WeaveTextNode, WeaveTextToolAction, WeaveTextToolActionState, WeaveTextToolActionStateKeys, WeaveToPasteNode, WeaveUserPointer, WeaveUserPointerKey, WeaveUserPointersUIProperties, WeaveUserSelectionInfo, WeaveUserSelectionKey, WeaveUsersPointersPlugin, WeaveUsersPointersPluginConfig, WeaveUsersPointersPluginParams, WeaveUsersSelectionPlugin, WeaveUsersSelectionPluginConfig, WeaveUsersSelectionPluginParams, WeaveZoomInToolAction, WeaveZoomInToolActionParams, WeaveZoomOutToolAction, WeaveZoomOutToolActionParams, checkIfOverContainer, clearContainerTargets, moveNodeToContainer, resetScale };
package/dist/sdk.js CHANGED
@@ -15761,7 +15761,7 @@ function clearContainerTargets(instance) {
15761
15761
  for (const container of getContainers) container.fire(WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, { bubbles: true });
15762
15762
  }
15763
15763
  function checkIfOverContainer(instance, node) {
15764
- const nodesIntersected = instance.pointIntersectsContainerElement();
15764
+ const nodesIntersected = instance.pointIntersectsContainerElement(node.getParent());
15765
15765
  let nodeActualContainer = node.getParent();
15766
15766
  if (nodeActualContainer?.getAttrs().nodeId) nodeActualContainer = instance.getStage().findOne(`#${nodeActualContainer.getAttrs().nodeId}`);
15767
15767
  let layerToMove = void 0;
@@ -15791,6 +15791,12 @@ function moveNodeToContainer(instance, node) {
15791
15791
  return layerToMove;
15792
15792
  }
15793
15793
 
15794
+ //#endregion
15795
+ //#region src/plugins/users-selection/constants.ts
15796
+ const WEAVE_USERS_SELECTION_KEY = "usersSelection";
15797
+ const WEAVE_USERS_SELECTION_LAYER_ID = "usersPointersLayer";
15798
+ const WEAVE_USER_SELECTION_KEY = "userSelection";
15799
+
15794
15800
  //#endregion
15795
15801
  //#region src/plugins/nodes-selection/nodes-selection.ts
15796
15802
  var WeaveNodesSelectionPlugin = class extends WeavePlugin {
@@ -15955,6 +15961,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
15955
15961
  node: nodeHandler.serialize(node)
15956
15962
  };
15957
15963
  });
15964
+ const usersSelectionPlugin = this.instance.getPlugin(WEAVE_USERS_SELECTION_KEY);
15965
+ if (usersSelectionPlugin) usersSelectionPlugin.sendSelectionAwarenessInfo(this.tr);
15958
15966
  this.instance.emitEvent("onNodesChange", selectedNodes);
15959
15967
  }
15960
15968
  removeSelectedNodes() {
@@ -17131,7 +17139,7 @@ var WeaveTargetingManager = class {
17131
17139
  this.logger = this.instance.getChildLogger("targeting-manager");
17132
17140
  this.logger.debug("Targeting manager created");
17133
17141
  }
17134
- pointIntersectsContainerElement(point) {
17142
+ pointIntersectsContainerElement(actualLayer, point) {
17135
17143
  const stage = this.instance.getStage();
17136
17144
  const relativeMousePointer = point ? point : stage.getPointerPosition() ?? {
17137
17145
  x: 0,
@@ -17143,11 +17151,11 @@ var WeaveTargetingManager = class {
17143
17151
  if (node.getAttrs().nodeId) {
17144
17152
  const parent = stage.findOne(`#${node.getAttrs().nodeId}`);
17145
17153
  intersectedNode = parent;
17146
- break;
17154
+ continue;
17147
17155
  }
17148
- if (node.getAttrs().containerId) {
17156
+ if (node.getAttrs().containerId && node.getAttrs().id !== actualLayer?.getAttrs().id) {
17149
17157
  intersectedNode = node;
17150
- break;
17158
+ continue;
17151
17159
  }
17152
17160
  }
17153
17161
  return intersectedNode;
@@ -17912,7 +17920,7 @@ var WeaveRegisterManager = class {
17912
17920
 
17913
17921
  //#endregion
17914
17922
  //#region package.json
17915
- var version = "0.15.0";
17923
+ var version = "0.16.0";
17916
17924
 
17917
17925
  //#endregion
17918
17926
  //#region src/managers/setup.ts
@@ -18518,8 +18526,8 @@ var Weave = class extends Emittery {
18518
18526
  unGroup(group) {
18519
18527
  this.groupsManager.unGroup(group);
18520
18528
  }
18521
- pointIntersectsContainerElement(point) {
18522
- return this.targetingManager.pointIntersectsContainerElement(point);
18529
+ pointIntersectsContainerElement(actualLayer, point) {
18530
+ return this.targetingManager.pointIntersectsContainerElement(actualLayer, point);
18523
18531
  }
18524
18532
  getMousePointer(point) {
18525
18533
  return this.targetingManager.getMousePointer(point);
@@ -21615,27 +21623,223 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
21615
21623
  }
21616
21624
  };
21617
21625
 
21626
+ //#endregion
21627
+ //#region src/plugins/users-selection/users-selection.ts
21628
+ var WeaveUsersSelectionPlugin = class extends WeavePlugin {
21629
+ constructor(params) {
21630
+ super();
21631
+ const { config } = params;
21632
+ this.config = config;
21633
+ this.usersSelection = {};
21634
+ }
21635
+ getName() {
21636
+ return WEAVE_USERS_SELECTION_KEY;
21637
+ }
21638
+ getLayerName() {
21639
+ return WEAVE_USERS_SELECTION_LAYER_ID;
21640
+ }
21641
+ initLayer() {
21642
+ const stage = this.instance.getStage();
21643
+ const layer = new Konva.Layer({
21644
+ id: this.getLayerName(),
21645
+ listening: false
21646
+ });
21647
+ stage.add(layer);
21648
+ }
21649
+ onRender() {
21650
+ this.renderSelectors();
21651
+ }
21652
+ getLayer() {
21653
+ const stage = this.instance.getStage();
21654
+ return stage.findOne(`#${WEAVE_USERS_SELECTION_LAYER_ID}`);
21655
+ }
21656
+ onInit() {
21657
+ this.instance.addEventListener("onAwarenessChange", (changes) => {
21658
+ const selfUser = this.config.getUser();
21659
+ const allActiveUsers = [];
21660
+ for (const change of changes) {
21661
+ if (!change[WEAVE_USER_SELECTION_KEY]) continue;
21662
+ if (change[WEAVE_USER_SELECTION_KEY] && selfUser.name !== change[WEAVE_USER_SELECTION_KEY].user) {
21663
+ const userSelection = change[WEAVE_USER_SELECTION_KEY];
21664
+ allActiveUsers.push(userSelection.user);
21665
+ this.usersSelection[userSelection.user] = {
21666
+ oldNodes: this.usersSelection[userSelection.user]?.actualNodes ?? {
21667
+ user: userSelection.user,
21668
+ nodes: []
21669
+ },
21670
+ actualNodes: userSelection
21671
+ };
21672
+ }
21673
+ }
21674
+ const allActiveUsersSelections = Object.keys(this.usersSelection).map((userSelectionKey) => {
21675
+ const selectionInfo = this.usersSelection[userSelectionKey];
21676
+ return selectionInfo.actualNodes.user;
21677
+ });
21678
+ const inactiveSelections = import_lodash.default.differenceWith(allActiveUsersSelections, allActiveUsers, import_lodash.default.isEqual);
21679
+ const selectionsLayer = this.getLayer();
21680
+ for (const inactiveSelection of inactiveSelections) {
21681
+ const userPointerNode = selectionsLayer?.findOne(`#${inactiveSelection}`);
21682
+ if (userPointerNode) userPointerNode.destroy();
21683
+ delete this.usersSelection[inactiveSelection];
21684
+ }
21685
+ this.renderSelectors();
21686
+ });
21687
+ this.renderSelectors();
21688
+ }
21689
+ sendSelectionAwarenessInfo(tr) {
21690
+ const userInfo = this.config.getUser();
21691
+ const store = this.instance.getStore();
21692
+ store.setAwarenessInfo(WEAVE_USER_SELECTION_KEY, {
21693
+ user: userInfo.name,
21694
+ nodes: tr.nodes().map((node) => node.getAttrs().id)
21695
+ });
21696
+ }
21697
+ removeSelectionAwarenessInfo() {
21698
+ const store = this.instance.getStore();
21699
+ store.setAwarenessInfo(WEAVE_USER_SELECTION_KEY, void 0);
21700
+ }
21701
+ stringToColor(str) {
21702
+ let hash = 0;
21703
+ str.split("").forEach((char) => {
21704
+ hash = char.charCodeAt(0) + ((hash << 5) - hash);
21705
+ });
21706
+ let color = "#";
21707
+ for (let i = 0; i < 3; i++) {
21708
+ const value = hash >> i * 8 & 255;
21709
+ color += value.toString(16).padStart(2, "0");
21710
+ }
21711
+ return color;
21712
+ }
21713
+ getSelectedNodesRect(nodes) {
21714
+ const stage = this.instance.getStage();
21715
+ const maxPoint = {
21716
+ x: -Infinity,
21717
+ y: -Infinity
21718
+ };
21719
+ const minPoint = {
21720
+ x: Infinity,
21721
+ y: Infinity
21722
+ };
21723
+ for (const nodeId of nodes) {
21724
+ const node = stage.findOne(`#${nodeId}`);
21725
+ if (node) {
21726
+ const nodeRect = node.getClientRect({
21727
+ relativeTo: stage,
21728
+ skipStroke: true
21729
+ });
21730
+ if (nodeRect.x < minPoint.x) minPoint.x = nodeRect.x;
21731
+ if (nodeRect.y < minPoint.y) minPoint.y = nodeRect.y;
21732
+ if (nodeRect.x + nodeRect.width > maxPoint.x) maxPoint.x = nodeRect.x + nodeRect.width;
21733
+ if (nodeRect.y + nodeRect.height > maxPoint.y) maxPoint.y = nodeRect.y + nodeRect.height;
21734
+ }
21735
+ }
21736
+ return {
21737
+ x: minPoint.x,
21738
+ y: minPoint.y,
21739
+ width: Math.abs(maxPoint.x - minPoint.x) * stage.scaleX(),
21740
+ height: Math.abs(maxPoint.y - minPoint.y) * stage.scaleY()
21741
+ };
21742
+ }
21743
+ renderSelectors() {
21744
+ const stage = this.instance.getStage();
21745
+ const selectorsLayer = this.getLayer();
21746
+ if (!this.enabled) return;
21747
+ const selectors = selectorsLayer?.find(".selector") ?? [];
21748
+ for (const selector of selectors) selector.destroy();
21749
+ for (const userPointerKey of Object.keys(this.usersSelection)) {
21750
+ const userSelector = this.usersSelection[userPointerKey];
21751
+ const userSelectorNode = selectorsLayer?.findOne(`#selector_${userSelector.actualNodes.user}`);
21752
+ if (!userSelectorNode) {
21753
+ const selectionRect = this.getSelectedNodesRect(userSelector.actualNodes.nodes);
21754
+ const userSelectorNode$1 = new Konva.Group({
21755
+ name: "selector",
21756
+ id: `selector_${userSelector.actualNodes.user}`,
21757
+ x: selectionRect.x,
21758
+ y: selectionRect.y,
21759
+ width: selectionRect.width / stage.scaleX(),
21760
+ height: selectionRect.height / stage.scaleY(),
21761
+ listening: false
21762
+ });
21763
+ const userSelectorRect$1 = new Konva.Rect({
21764
+ x: 0,
21765
+ y: 0,
21766
+ id: `selector_${userSelector.actualNodes.user}_rect`,
21767
+ width: selectionRect.width / stage.scaleX(),
21768
+ height: selectionRect.height / stage.scaleY(),
21769
+ fill: "transparent",
21770
+ stroke: this.stringToColor(userSelector.actualNodes.user),
21771
+ strokeWidth: 3,
21772
+ strokeScaleEnabled: false
21773
+ });
21774
+ userSelectorNode$1.add(userSelectorRect$1);
21775
+ selectorsLayer?.add(userSelectorNode$1);
21776
+ continue;
21777
+ }
21778
+ const userSelectorRect = selectorsLayer?.findOne(`#selector_${userSelector.actualNodes.user}_rect`);
21779
+ if (userSelectorRect) {
21780
+ const selectionRect = this.getSelectedNodesRect(userSelector.actualNodes.nodes);
21781
+ userSelectorNode.setAttrs({
21782
+ x: selectionRect.x,
21783
+ y: selectionRect.y,
21784
+ width: selectionRect.width,
21785
+ height: selectionRect.height,
21786
+ scale: 1
21787
+ });
21788
+ userSelectorRect.setAttrs({
21789
+ x: 0,
21790
+ y: 0,
21791
+ width: selectionRect.width,
21792
+ height: selectionRect.height
21793
+ });
21794
+ }
21795
+ }
21796
+ }
21797
+ enable() {
21798
+ this.getLayer()?.show();
21799
+ this.enabled = true;
21800
+ }
21801
+ disable() {
21802
+ this.getLayer()?.hide();
21803
+ this.enabled = false;
21804
+ }
21805
+ };
21806
+
21618
21807
  //#endregion
21619
21808
  //#region src/plugins/users-pointers/constants.ts
21620
21809
  const WEAVE_USERS_POINTERS_KEY = "usersPointers";
21621
21810
  const WEAVE_USERS_POINTERS_LAYER_ID = "usersPointersLayer";
21622
21811
  const WEAVE_USER_POINTER_KEY = "userPointer";
21812
+ const WEAVE_DEFAULT_USER_INFO_FUNCTION = () => ({
21813
+ name: "Unknown",
21814
+ email: "unknown@domain.com"
21815
+ });
21816
+ const WEAVE_USER_POINTERS_DEFAULT_PROPS = {
21817
+ separation: 8,
21818
+ pointer: {
21819
+ circleRadius: 4,
21820
+ circleStrokeWidth: 0
21821
+ },
21822
+ name: {
21823
+ fontFamily: "Arial",
21824
+ fontSize: 10,
21825
+ backgroundCornerRadius: 0,
21826
+ backgroundPaddingX: 8,
21827
+ backgroundPaddingY: 4
21828
+ }
21829
+ };
21623
21830
 
21624
21831
  //#endregion
21625
21832
  //#region src/plugins/users-pointers/users-pointers.ts
21626
21833
  var WeaveUsersPointersPlugin = class extends WeavePlugin {
21627
- userPointerCircleRadius = 4;
21628
- userPointerSeparation = 8;
21629
- userPointerCircleStrokeWidth = 1;
21630
- userPointerNameFontSize = 10;
21631
- userPointerBackgroundCornerRadius = 4;
21632
- userPointerBackgroundPaddingX = 4;
21633
- userPointerBackgroundPaddingY = 8;
21634
21834
  constructor(params) {
21635
21835
  super();
21636
21836
  const { config } = params;
21637
- this.usersPointers = {};
21638
21837
  this.config = config;
21838
+ this.uiConfig = {
21839
+ ...WEAVE_USER_POINTERS_DEFAULT_PROPS,
21840
+ ...this.config.ui
21841
+ };
21842
+ this.usersPointers = {};
21639
21843
  }
21640
21844
  getName() {
21641
21845
  return WEAVE_USERS_POINTERS_KEY;
@@ -21686,7 +21890,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
21686
21890
  const inactivePointers = import_lodash.default.differenceWith(allActiveUsersPointers, allActiveUsers, import_lodash.default.isEqual);
21687
21891
  const pointersLayer = this.getLayer();
21688
21892
  for (const inactivePointer of inactivePointers) {
21689
- const userPointerNode = pointersLayer?.findOne(`#${inactivePointer}`);
21893
+ const userPointerNode = pointersLayer?.findOne(`#pointer_${inactivePointer}`);
21690
21894
  if (userPointerNode) userPointerNode.destroy();
21691
21895
  delete this.usersPointers[inactivePointer];
21692
21896
  }
@@ -21714,17 +21918,25 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
21714
21918
  });
21715
21919
  this.renderPointers();
21716
21920
  }
21717
- stringToColour(str) {
21921
+ getContrastTextColor(hex) {
21922
+ const cleaned = hex.replace(/^#/, "");
21923
+ const r = parseInt(cleaned.slice(0, 2), 16);
21924
+ const g = parseInt(cleaned.slice(2, 4), 16);
21925
+ const b = parseInt(cleaned.slice(4, 6), 16);
21926
+ const luminance = (.299 * r + .587 * g + .114 * b) / 255;
21927
+ return luminance > .5 ? "black" : "white";
21928
+ }
21929
+ stringToColor(str) {
21718
21930
  let hash = 0;
21719
21931
  str.split("").forEach((char) => {
21720
21932
  hash = char.charCodeAt(0) + ((hash << 5) - hash);
21721
21933
  });
21722
- let colour = "#";
21934
+ let color = "#";
21723
21935
  for (let i = 0; i < 3; i++) {
21724
21936
  const value = hash >> i * 8 & 255;
21725
- colour += value.toString(16).padStart(2, "0");
21937
+ color += value.toString(16).padStart(2, "0");
21726
21938
  }
21727
- return colour;
21939
+ return color;
21728
21940
  }
21729
21941
  renderPointers() {
21730
21942
  const stage = this.instance.getStage();
@@ -21732,52 +21944,61 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
21732
21944
  if (!this.enabled) return;
21733
21945
  for (const userPointerKey of Object.keys(this.usersPointers)) {
21734
21946
  const userPointer = this.usersPointers[userPointerKey];
21735
- const userPointerNode = pointersLayer?.findOne(`#${userPointer.actualPos.user}`);
21947
+ const userPointerNode = pointersLayer?.findOne(`#pointer_${userPointer.actualPos.user}`);
21736
21948
  if (!userPointerNode) {
21737
21949
  const userPointerNode$1 = new Konva.Group({
21738
21950
  name: "pointer",
21739
- id: userPointer.actualPos.user,
21951
+ id: `pointer_${userPointer.actualPos.user}`,
21740
21952
  x: userPointer.actualPos.x,
21741
21953
  y: userPointer.actualPos.y,
21742
21954
  opacity: 1,
21743
21955
  listening: false
21744
21956
  });
21745
- const userPointNode$1 = new Konva.Circle({
21746
- id: "userPoint",
21957
+ const { separation, pointer: { circleRadius, circleStrokeWidth }, name: { fontFamily, fontSize, backgroundCornerRadius, backgroundPaddingX, backgroundPaddingY } } = this.uiConfig;
21958
+ const userColor = this.stringToColor(userPointer.actualPos.user);
21959
+ const userContrastColor = this.getContrastTextColor(userColor);
21960
+ const userPointNode = new Konva.Circle({
21961
+ id: `pointer_${userPointer.actualPos.user}_userPoint`,
21747
21962
  x: 0,
21748
21963
  y: 0,
21749
- radius: this.userPointerCircleRadius / stage.scaleX(),
21750
- fill: this.stringToColour(userPointer.actualPos.user),
21964
+ radius: circleRadius,
21965
+ fill: userColor,
21751
21966
  stroke: "black",
21752
- strokeWidth: this.userPointerCircleStrokeWidth / stage.scaleX(),
21967
+ strokeWidth: circleStrokeWidth,
21968
+ strokeScaleEnabled: false,
21753
21969
  listening: false
21754
21970
  });
21755
21971
  const userNameNode = new Konva.Text({
21756
- id: "userPointName",
21757
- x: (this.userPointerSeparation + this.userPointerBackgroundPaddingX) / stage.scaleX(),
21758
- y: 0 / stage.scaleX(),
21759
- height: userPointNode$1.height() * 2 / stage.scaleX(),
21760
- text: userPointer.actualPos.user,
21761
- fontSize: this.userPointerNameFontSize / stage.scaleX(),
21762
- fontFamily: "NotoSansMono, monospace",
21763
- fill: "black",
21764
- align: "left",
21972
+ id: `pointer_${userPointer.actualPos.user}_userPointName`,
21973
+ x: separation,
21974
+ y: -circleRadius * 2 + backgroundPaddingY,
21975
+ text: userPointer.actualPos.user.trim(),
21976
+ fontSize,
21977
+ fontFamily,
21978
+ lineHeight: .9,
21979
+ fill: userContrastColor,
21980
+ align: "center",
21765
21981
  verticalAlign: "middle",
21766
- listening: false
21982
+ listening: false,
21983
+ strokeScaleEnabled: false,
21984
+ ellipsis: true
21767
21985
  });
21986
+ const textWidth = userNameNode.getTextWidth();
21987
+ const textHeight = userNameNode.getTextHeight();
21988
+ userNameNode.width(textWidth + backgroundPaddingX * 2);
21989
+ userNameNode.height(textHeight + backgroundPaddingY * 2);
21768
21990
  const userNameBackground = new Konva.Rect({
21769
- id: "userPointRect",
21770
- x: this.userPointerSeparation / stage.scaleX(),
21771
- y: -this.userPointerBackgroundPaddingY / stage.scaleX(),
21772
- width: (userNameNode.width() + this.userPointerBackgroundPaddingX * 2) / stage.scaleX(),
21773
- height: (userNameNode.height() + this.userPointerBackgroundPaddingY * 2) / stage.scaleX(),
21774
- cornerRadius: this.userPointerBackgroundCornerRadius / stage.scaleX(),
21775
- fill: "rgba(0,0,0,0.2)",
21776
- strokeWidth: 0,
21991
+ id: `pointer_${userPointer.actualPos.user}_userPointRect`,
21992
+ x: separation,
21993
+ y: -backgroundPaddingY,
21994
+ width: textWidth + backgroundPaddingX * 2,
21995
+ height: textHeight + backgroundPaddingY * 2,
21996
+ cornerRadius: backgroundCornerRadius,
21997
+ fill: userColor,
21777
21998
  listening: false
21778
21999
  });
21779
- userPointNode$1.setAttrs({ y: userNameBackground.y() + userNameBackground.height() / 2 });
21780
- userPointerNode$1.add(userPointNode$1);
22000
+ userPointNode.setAttrs({ y: userNameBackground.y() + userNameBackground.height() / 2 });
22001
+ userPointerNode$1.add(userPointNode);
21781
22002
  userPointerNode$1.add(userNameBackground);
21782
22003
  userPointerNode$1.add(userNameNode);
21783
22004
  pointersLayer?.add(userPointerNode$1);
@@ -21792,27 +22013,8 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
21792
22013
  y: userPointer.actualPos.y
21793
22014
  };
21794
22015
  const hasChanged = !import_lodash.default.isEqual(actualPos, oldPos);
21795
- const userPointNode = userPointerNode.getChildren((node) => node.getAttrs().id === "userPoint");
21796
- userPointNode[0]?.setAttrs({
21797
- radius: this.userPointerCircleRadius / stage.scaleX(),
21798
- strokeWidth: this.userPointerCircleStrokeWidth / stage.scaleX()
21799
- });
21800
- const userPointNodeText = userPointerNode.getChildren((node) => node.getAttrs().id === "userPointName");
21801
- userPointNodeText[0]?.setAttrs({
21802
- x: (this.userPointerSeparation + this.userPointerBackgroundPaddingX) / stage.scaleX(),
21803
- y: 0 / stage.scaleX(),
21804
- height: userPointNode[0]?.height(),
21805
- fontSize: this.userPointerNameFontSize / stage.scaleX()
21806
- });
21807
- const userPointNodeBackground = userPointerNode.getChildren((node) => node.getAttrs().id === "userPointRect");
21808
- userPointNodeBackground[0]?.setAttrs({
21809
- x: this.userPointerSeparation / stage.scaleX(),
21810
- y: -this.userPointerBackgroundPaddingY / stage.scaleX(),
21811
- cornerRadius: this.userPointerBackgroundCornerRadius / stage.scaleX(),
21812
- width: userPointNodeText[0]?.width() + this.userPointerBackgroundPaddingX * 2,
21813
- height: userPointNodeText[0]?.height() + this.userPointerBackgroundPaddingY * 2
21814
- });
21815
- userPointNode[0]?.setAttrs({ y: userPointNodeBackground[0]?.y() + userPointNodeBackground[0]?.height() / 2 });
22016
+ userPointerNode.scaleX(1 / stage.scaleX());
22017
+ userPointerNode.scaleY(1 / stage.scaleY());
21816
22018
  if (hasChanged) userPointerNode.setAttrs({
21817
22019
  x: userPointer.actualPos.x,
21818
22020
  y: userPointer.actualPos.y,
@@ -22224,4 +22426,4 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
22224
22426
  };
22225
22427
 
22226
22428
  //#endregion
22227
- export { BRUSH_TOOL_ACTION_NAME, BRUSH_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_LINE_DEFAULT_CONFIG, GUIDE_LINE_DRAG_SNAPPING_THRESHOLD, GUIDE_LINE_NAME, GUIDE_LINE_TRANSFORM_SNAPPING_THRESHOLD, GUIDE_ORIENTATION, IMAGE_TOOL_ACTION_NAME, IMAGE_TOOL_STATE, MOVE_TOOL_ACTION_NAME, MOVE_TOOL_STATE, NODE_SNAP, PEN_TOOL_ACTION_NAME, PEN_TOOL_STATE, RECTANGLE_TOOL_ACTION_NAME, RECTANGLE_TOOL_STATE, SELECTION_TOOL_ACTION_NAME, SELECTION_TOOL_STATE, TEXT_TOOL_ACTION_NAME, TEXT_TOOL_STATE, WEAVE_COPY_PASTE_NODES_KEY, WEAVE_FRAME_NODE_DEFAULT_CONFIG, WEAVE_FRAME_NODE_DEFAULT_PROPS, WEAVE_FRAME_NODE_SIZES, WEAVE_FRAME_NODE_SIZES_MULTIPLIER, WEAVE_FRAME_NODE_SIZES_ORIENTATION, WEAVE_FRAME_NODE_SIZES_TYPES, WEAVE_FRAME_NODE_TYPE, WEAVE_GRID_DEFAULT_COLOR, WEAVE_GRID_DEFAULT_ORIGIN_COLOR, WEAVE_GRID_DEFAULT_SIZE, WEAVE_GRID_DEFAULT_TYPE, WEAVE_GRID_LAYER_ID, WEAVE_GRID_TYPES, WEAVE_NODES_SELECTION_KEY, WEAVE_NODES_SELECTION_LAYER_ID, WEAVE_NODES_SNAPPING_KEY, WEAVE_STAGE_GRID_KEY, Weave, WeaveAction, WeaveBrushToolAction, WeaveConnectedUsersPlugin, WeaveContextMenuPlugin, WeaveCopyPasteNodesPlugin, WeaveExportNodeToolAction, WeaveExportStageToolAction, WeaveFitToScreenToolAction, WeaveFitToSelectionToolAction, WeaveFrameNode, WeaveFrameToolAction, WeaveGroupNode, WeaveImageNode, WeaveImageToolAction, WeaveLayerNode, WeaveLineNode, WeaveMoveToolAction, WeaveNode, WeaveNodesSelectionPlugin, WeaveNodesSnappingPlugin, WeavePenToolAction, WeavePlugin, WeaveRectangleNode, WeaveRectangleToolAction, WeaveSelectionToolAction, WeaveStageDropAreaPlugin, WeaveStageGridPlugin, WeaveStageNode, WeaveStagePanningPlugin, WeaveStageResizePlugin, WeaveStageZoomPlugin, WeaveStore, WeaveTextNode, WeaveTextToolAction, WeaveUsersPointersPlugin, WeaveZoomInToolAction, WeaveZoomOutToolAction, checkIfOverContainer, clearContainerTargets, moveNodeToContainer, resetScale };
22429
+ export { BRUSH_TOOL_ACTION_NAME, BRUSH_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_LINE_DEFAULT_CONFIG, GUIDE_LINE_DRAG_SNAPPING_THRESHOLD, GUIDE_LINE_NAME, GUIDE_LINE_TRANSFORM_SNAPPING_THRESHOLD, GUIDE_ORIENTATION, IMAGE_TOOL_ACTION_NAME, IMAGE_TOOL_STATE, MOVE_TOOL_ACTION_NAME, MOVE_TOOL_STATE, NODE_SNAP, PEN_TOOL_ACTION_NAME, PEN_TOOL_STATE, RECTANGLE_TOOL_ACTION_NAME, RECTANGLE_TOOL_STATE, SELECTION_TOOL_ACTION_NAME, SELECTION_TOOL_STATE, TEXT_TOOL_ACTION_NAME, TEXT_TOOL_STATE, WEAVE_COPY_PASTE_NODES_KEY, WEAVE_DEFAULT_USER_INFO_FUNCTION, WEAVE_FRAME_NODE_DEFAULT_CONFIG, WEAVE_FRAME_NODE_DEFAULT_PROPS, WEAVE_FRAME_NODE_SIZES, WEAVE_FRAME_NODE_SIZES_MULTIPLIER, WEAVE_FRAME_NODE_SIZES_ORIENTATION, WEAVE_FRAME_NODE_SIZES_TYPES, WEAVE_FRAME_NODE_TYPE, WEAVE_GRID_DEFAULT_COLOR, WEAVE_GRID_DEFAULT_ORIGIN_COLOR, WEAVE_GRID_DEFAULT_SIZE, WEAVE_GRID_DEFAULT_TYPE, WEAVE_GRID_LAYER_ID, WEAVE_GRID_TYPES, WEAVE_NODES_SELECTION_KEY, WEAVE_NODES_SELECTION_LAYER_ID, WEAVE_NODES_SNAPPING_KEY, WEAVE_STAGE_GRID_KEY, WEAVE_USERS_POINTERS_KEY, WEAVE_USERS_POINTERS_LAYER_ID, WEAVE_USERS_SELECTION_KEY, WEAVE_USERS_SELECTION_LAYER_ID, WEAVE_USER_POINTERS_DEFAULT_PROPS, WEAVE_USER_POINTER_KEY, WEAVE_USER_SELECTION_KEY, Weave, WeaveAction, WeaveBrushToolAction, WeaveConnectedUsersPlugin, WeaveContextMenuPlugin, WeaveCopyPasteNodesPlugin, WeaveExportNodeToolAction, WeaveExportStageToolAction, WeaveFitToScreenToolAction, WeaveFitToSelectionToolAction, WeaveFrameNode, WeaveFrameToolAction, WeaveGroupNode, WeaveImageNode, WeaveImageToolAction, WeaveLayerNode, WeaveLineNode, WeaveMoveToolAction, WeaveNode, WeaveNodesSelectionPlugin, WeaveNodesSnappingPlugin, WeavePenToolAction, WeavePlugin, WeaveRectangleNode, WeaveRectangleToolAction, WeaveSelectionToolAction, WeaveStageDropAreaPlugin, WeaveStageGridPlugin, WeaveStageNode, WeaveStagePanningPlugin, WeaveStageResizePlugin, WeaveStageZoomPlugin, WeaveStore, WeaveTextNode, WeaveTextToolAction, WeaveUsersPointersPlugin, WeaveUsersSelectionPlugin, WeaveZoomInToolAction, WeaveZoomOutToolAction, checkIfOverContainer, clearContainerTargets, moveNodeToContainer, resetScale };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inditextech/weave-sdk",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>",
@@ -43,7 +43,7 @@
43
43
  "version:release": "npm version $RELEASE_VERSION -m \"[npm-scripts] prepare release $RELEASE_VERSION\" --tag-version-prefix \"\""
44
44
  },
45
45
  "dependencies": {
46
- "@inditextech/weave-types": "0.15.0",
46
+ "@inditextech/weave-types": "0.16.0",
47
47
  "@syncedstore/core": "0.6.0",
48
48
  "canvas": "3.1.0",
49
49
  "konva": "9.3.20",