@pushwoosh/dumb-components 4.12.2 → 4.12.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.
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Transforms } from 'slate';
2
+ import { Node as SlateNode, Transforms } from 'slate';
3
3
  import { useSelected, useSlateStatic } from 'slate-react';
4
- import { findPath } from './helpers';
5
4
  import { Chip } from '../../Chip';
6
5
  import { isResolvableDc } from '../../shared/dynamicContent';
7
6
  const DynamicContentElementComponent = ({
@@ -25,7 +24,9 @@ const DynamicContentElementComponent = ({
25
24
  "$onClose": event => {
26
25
  event.preventDefault();
27
26
  event.stopPropagation();
28
- const [paragraphIndex, elementIndex] = findPath(editor.children, element);
27
+ const path = SlateNode.findPath(editor, element);
28
+ if (!path) return;
29
+ const [paragraphIndex, elementIndex] = path;
29
30
  Transforms.delete(editor, {
30
31
  at: [paragraphIndex, elementIndex]
31
32
  });
@@ -20,14 +20,6 @@ export declare function getDcByPath(value: SlateEditorContent, path: number[]):
20
20
  * @returns Array of all dynamic content elements
21
21
  */
22
22
  export declare function findAllDc(value: SlateEditorContent): DynamicContentElement[];
23
- /**
24
- * Finds the path to a specific element in the Slate document
25
- * @param value - The Slate editor content
26
- * @param elToFind - The element to find
27
- * @returns Array of indices representing the path to the element, empty if not found
28
- * TODO: slate 0.146+ ships `Node.findPath(root, node)` (returns `undefined` when absent) — replace this walk with it.
29
- */
30
- export declare function findPath(value: SlateEditorContent, elToFind: Descendant): number[];
31
23
  export { parseDc, stringifyDc };
32
24
  /**
33
25
  * Converts a string to Slate editor content, parsing dynamic content tags
@@ -48,28 +48,6 @@ export function findAllDc(value) {
48
48
  walkDeep(value);
49
49
  return dces;
50
50
  }
51
- /**
52
- * Finds the path to a specific element in the Slate document
53
- * @param value - The Slate editor content
54
- * @param elToFind - The element to find
55
- * @returns Array of indices representing the path to the element, empty if not found
56
- * TODO: slate 0.146+ ships `Node.findPath(root, node)` (returns `undefined` when absent) — replace this walk with it.
57
- */
58
- export function findPath(value, elToFind) {
59
- for (let i = 0; i < value.length; i++) {
60
- const el = value[i];
61
- if (el === elToFind) {
62
- return [i];
63
- }
64
- if (isElement(el)) {
65
- const path = findPath(el.children, elToFind);
66
- if (path.length > 0) {
67
- return [i, ...path];
68
- }
69
- }
70
- }
71
- return [];
72
- }
73
51
  // Re-exported so existing import paths keep working; the token format itself
74
52
  // now lives in shared/dynamicContent, shared with the read-only renderers.
75
53
  export { parseDc, stringifyDc };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "4.12.2",
3
+ "version": "4.12.3",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",