charon-conversation-editor 0.0.20 → 0.0.24

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/assets/index.css CHANGED
@@ -628,6 +628,7 @@ svg.react-flow__connectionline {
628
628
  flex-direction: row;
629
629
  position: relative;
630
630
 
631
+ --ext-node-select-color: var(--app-color-primary, blue);
631
632
  --ext-panel-background-color: var(--app-white-background, white);
632
633
  --ext-node-edge-color: hsl(from var(--app-color-gray, gray) h s calc(l * 1.2));
633
634
  --ext-node-border-color: hsl(from var(--app-color-gray, gray) h s calc(l * 1.2));
package/index.js CHANGED
@@ -21347,9 +21347,7 @@ function bindInstanceMethods(instance) {
21347
21347
  const noChanges = [];
21348
21348
  class ConversationState {
21349
21349
  constructor(conversationTreeControl) {
21350
- __publicField(this, "originalIdToControlMap");
21351
21350
  this.conversationTreeControl = conversationTreeControl;
21352
- this.originalIdToControlMap = /* @__PURE__ */ new Map();
21353
21351
  bindInstanceMethods(this);
21354
21352
  }
21355
21353
  getConversationNodeChanges(nodes) {
@@ -21363,8 +21361,8 @@ class ConversationState {
21363
21361
  const existingNode = nodesById.get(dialogFlowNodeId);
21364
21362
  const specification = new URLSearchParams(String(Specification || ""));
21365
21363
  const position = getPosition(specification);
21366
- nodesById.delete(dialogFlowNodeId);
21367
21364
  if (existingNode && Object.is(existingNode.data.valueControl, dialogNodeControl)) {
21365
+ nodesById.delete(existingNode.id);
21368
21366
  if (position && !arePositionsEquals(position, existingNode.position)) {
21369
21367
  changes.push({
21370
21368
  id: existingNode.id,
@@ -21395,8 +21393,8 @@ class ConversationState {
21395
21393
  const existingRootNode = nodesById.get(rootFlowNodeId);
21396
21394
  const rootNodeSpecification = new URLSearchParams(String(((_a = this.conversationTreeControl.controls.Specification) == null ? void 0 : _a.value) || ""));
21397
21395
  const rootPosition = getPosition(rootNodeSpecification);
21398
- nodesById.delete(rootFlowNodeId);
21399
21396
  if (existingRootNode && Object.is(existingRootNode.data.valueControl, this.conversationTreeControl)) {
21397
+ nodesById.delete(existingRootNode.id);
21400
21398
  if (rootPosition && !arePositionsEquals(rootPosition, existingRootNode.position)) {
21401
21399
  changes.push({
21402
21400
  id: existingRootNode.id,
@@ -21493,14 +21491,13 @@ class ConversationState {
21493
21491
  const nodesControl = this.conversationTreeControl.controls.Nodes;
21494
21492
  const newDialogNodeId = generateDialogNodeIdPlaceholder();
21495
21493
  const specification = setPosition("", position);
21496
- const newDialogNodeControl = nodesControl.append({
21494
+ nodesControl.append({
21497
21495
  Id: newDialogNodeId,
21498
21496
  Text: "<EMPTY>",
21499
21497
  NextNode: null,
21500
21498
  Responses: [],
21501
21499
  Specification: specification.toString()
21502
21500
  }, opts);
21503
- this.originalIdToControlMap.set(newDialogNodeId, new WeakRef(newDialogNodeControl));
21504
21501
  const { id: sourceDialogNodeId } = parseHandleOrFlowNodeId(source);
21505
21502
  const { id: sourceDialogNodeOrResponseId, type: handleType } = parseHandleOrFlowNodeId(sourceHandleId);
21506
21503
  switch (handleType) {
@@ -21519,7 +21516,7 @@ class ConversationState {
21519
21516
  const nodesControl = this.conversationTreeControl.controls.Nodes;
21520
21517
  const specification = setPosition((initialData == null ? void 0 : initialData.Specification) ?? "", position);
21521
21518
  const newDialogNodeId = initialData.Id || generateDialogNodeIdPlaceholder();
21522
- const newDialogNodeControl = nodesControl.append({
21519
+ nodesControl.append({
21523
21520
  ...initialData,
21524
21521
  Id: newDialogNodeId,
21525
21522
  Text: initialData.Text ?? "<EMPTY>",
@@ -21527,9 +21524,6 @@ class ConversationState {
21527
21524
  Responses: (initialData.Responses ?? []).map(mapResponse),
21528
21525
  Specification: specification.toString()
21529
21526
  }, opts);
21530
- if (typeof newDialogNodeId === "string" && newDialogNodeId.startsWith("_ID_")) {
21531
- this.originalIdToControlMap.set(newDialogNodeId, new WeakRef(newDialogNodeControl));
21532
- }
21533
21527
  function mapResponse(responseData) {
21534
21528
  return {
21535
21529
  ...responseData,
@@ -21608,16 +21602,14 @@ class ConversationState {
21608
21602
  }
21609
21603
  const newDialogResponseId = generateDialogNodeResponseIdPlaceholder();
21610
21604
  const responsesControl = dialogNodeControl.controls.Responses;
21611
- const newDialogResponseControl = responsesControl.append({
21605
+ responsesControl.append({
21612
21606
  Id: newDialogResponseId,
21613
21607
  Text: text,
21614
21608
  NextNode: null,
21615
21609
  Specification: ""
21616
21610
  }, opts);
21617
- this.originalIdToControlMap.set(newDialogResponseId, new WeakRef(newDialogResponseControl));
21618
21611
  }
21619
21612
  removeDialogResponse(dialogNodeId, dialogResponseId, opts) {
21620
- dialogResponseId = this.actualizeId(dialogResponseId);
21621
21613
  const dialogNodeControl = this.findDialogNode(dialogNodeId);
21622
21614
  if (!dialogNodeControl) {
21623
21615
  return;
@@ -21632,7 +21624,6 @@ class ConversationState {
21632
21624
  }
21633
21625
  removeDialogNode(dialogNodeId, opts) {
21634
21626
  var _a;
21635
- dialogNodeId = this.actualizeId(dialogNodeId);
21636
21627
  const nodesControl = this.conversationTreeControl.controls.Nodes;
21637
21628
  const dialogNodeIndex = nodesControl.value.findIndex((node) => node.Id == dialogNodeId);
21638
21629
  if (dialogNodeIndex < 0) {
@@ -21660,7 +21651,6 @@ class ConversationState {
21660
21651
  return true;
21661
21652
  }
21662
21653
  findDialogNode(dialogNodeId) {
21663
- dialogNodeId = this.actualizeId(dialogNodeId);
21664
21654
  if (!dialogNodeId) {
21665
21655
  return;
21666
21656
  }
@@ -21672,8 +21662,6 @@ class ConversationState {
21672
21662
  return nodesControl.controls[dialogNodeIndex];
21673
21663
  }
21674
21664
  findDialogResponse(dialogNodeId, dialogResponseId) {
21675
- dialogNodeId = this.actualizeId(dialogNodeId);
21676
- dialogResponseId = this.actualizeId(dialogResponseId);
21677
21665
  if (!dialogNodeId || !dialogResponseId) {
21678
21666
  return;
21679
21667
  }
@@ -21689,17 +21677,6 @@ class ConversationState {
21689
21677
  }
21690
21678
  }
21691
21679
  }
21692
- actualizeId(dialogNodeOrResponseId) {
21693
- var _a;
21694
- if (!dialogNodeOrResponseId) {
21695
- return null;
21696
- }
21697
- const control = (_a = this.originalIdToControlMap.get(dialogNodeOrResponseId)) == null ? void 0 : _a.deref();
21698
- if (control) {
21699
- return getDocumentIdAsString(control);
21700
- }
21701
- return dialogNodeOrResponseId;
21702
- }
21703
21680
  getEdgeChange(edges, source, target, sourceHandle) {
21704
21681
  const newEdge = this.createEdge(source, target, sourceHandle, void 0);
21705
21682
  const existingEdge = edges.get(newEdge.id);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/gamedevware/charon-extensions/refs/heads/main/package.json.schema.json",
3
3
  "name": "charon-conversation-editor",
4
- "version": "0.0.20",
4
+ "version": "0.0.24",
5
5
  "description": "",
6
6
  "keywords": [
7
7
  "charon",