@saltcorn/builder 1.1.4-beta.2 → 1.1.4-beta.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/builder",
3
- "version": "1.1.4-beta.2",
3
+ "version": "1.1.4-beta.3",
4
4
  "description": "Drag and drop view builder for Saltcorn, open-source no-code platform",
5
5
  "main": "index.js",
6
6
  "homepage": "https://saltcorn.com",
@@ -20,7 +20,7 @@
20
20
  "@babel/preset-react": "7.24.7",
21
21
  "@craftjs/core": "0.1.0-beta.20",
22
22
  "@craftjs/utils": "0.1.0-beta.20",
23
- "@saltcorn/common-code": "1.1.4-beta.2",
23
+ "@saltcorn/common-code": "1.1.4-beta.3",
24
24
  "saltcorn-craft-layers-noeye": "0.1.0-beta.22",
25
25
  "@fonticonpicker/react-fonticonpicker": "1.2.0",
26
26
  "@fortawesome/fontawesome-svg-core": "1.2.34",
@@ -45,6 +45,17 @@ const fields = (mode) => {
45
45
  name: "text",
46
46
  type: "textarea",
47
47
  segment_name: "contents",
48
+ onSave: (segment, node_props) => {
49
+ const div = document.createElement("div");
50
+ div.innerHTML = (node_props.text || "").trim();
51
+ const children = []; // Type: Node[]
52
+ const walker = document.createTreeWalker(div, NodeFilter.SHOW_TEXT);
53
+ while (walker.nextNode()) {
54
+ const s = walker.currentNode.data?.trim?.();
55
+ if (s && !(s.startsWith("{{") && s.endsWith("}}"))) children.push(s);
56
+ }
57
+ segment.text_strings = [...new Set(children.sort())];
58
+ },
48
59
  sublabel:
49
60
  mode === "show" || mode === "list"
50
61
  ? "Access fields with <code>{{ var_name }}</code>"
@@ -483,6 +483,7 @@ const craftToSaltcorn = (nodes, startFrom = "ROOT", options) => {
483
483
  nodes[node.linkedNodes[f.nodeID]]
484
484
  );
485
485
  } else s[f.segment_name || f.name || f] = node.props[f.name || f];
486
+ if(f.onSave) f.onSave(s, node.props)
486
487
  });
487
488
  if (related.fields.some((f) => f.canBeFormula))
488
489
  s.isFormula = node.props.isFormula;