@appquality/unguess-design-system 3.1.91-highlight-1 → 3.1.91-highlight-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/build/index.js CHANGED
@@ -7519,7 +7519,8 @@ const Observation = core.Node.create({
7519
7519
  if (node.type.name === "Word") {
7520
7520
  // Crea il nodo "active"
7521
7521
  const annotationNode = state.schema.nodes.Observation.create({
7522
- title: "Ciao",
7522
+ title,
7523
+ type,
7523
7524
  }, node.content);
7524
7525
  // Crea il nodo "word" aggiornato con "active" come figlio
7525
7526
  const updatedNode = node.copy(model.Fragment.from(annotationNode));
@@ -7636,7 +7637,7 @@ const Word = core.Node.create({
7636
7637
  },
7637
7638
  });
7638
7639
 
7639
- const useEditor = ({ content, currentTime, onSetCurrentTime, }, deps) => {
7640
+ const useEditor = ({ content, observations, currentTime, onSetCurrentTime, }, deps) => {
7640
7641
  const ed = react.useEditor({
7641
7642
  extensions: [
7642
7643
  Document__default["default"],
@@ -7692,6 +7693,24 @@ const useEditor = ({ content, currentTime, onSetCurrentTime, }, deps) => {
7692
7693
  return;
7693
7694
  ed.commands.updateCurrentActive({ currentWord });
7694
7695
  }, [currentTime, content, ed]);
7696
+ React.useEffect(() => {
7697
+ if (!observations)
7698
+ return;
7699
+ if (!ed)
7700
+ return;
7701
+ const selection = ed.state.selection;
7702
+ observations.forEach((observation) => {
7703
+ const startWord = ed.$node("Word", { "data-start": observation.start });
7704
+ const endWord = ed.$node("Word", { "data-end": observation.end });
7705
+ if (!startWord || !endWord)
7706
+ return;
7707
+ ed.chain()
7708
+ .setTextSelection({ from: startWord.pos, to: endWord.pos })
7709
+ .addObservation(observation.type, observation.text)
7710
+ .setTextSelection(selection.from)
7711
+ .run();
7712
+ });
7713
+ }, [observations, ed]);
7695
7714
  return ed;
7696
7715
  };
7697
7716
 
@@ -7719,6 +7738,7 @@ const EditorWithHighlight = ({ editor }) => {
7719
7738
  return null;
7720
7739
  return (jsxRuntime.jsx(EditorWrapper, { children: jsxRuntime.jsx(react.EditorContent, { ref: ref, editor: editor }) }));
7721
7740
  };
7741
+ // rebuild the EditorWithHighlight component
7722
7742
  EditorWithHighlight.useEditor = useEditor;
7723
7743
  EditorWithHighlight.Search = Search;
7724
7744
  EditorWithHighlight.FloatingMenu = FloatingMenu;
@@ -4,7 +4,7 @@ declare const EditorWithHighlight: {
4
4
  ({ editor }: {
5
5
  editor: Editor;
6
6
  }): import("react/jsx-runtime").JSX.Element | null;
7
- useEditor: ({ content, currentTime, onSetCurrentTime, }: {
7
+ useEditor: ({ content, observations, currentTime, onSetCurrentTime, }: {
8
8
  content?: {
9
9
  start: number;
10
10
  end: number;
@@ -15,6 +15,13 @@ declare const EditorWithHighlight: {
15
15
  word: string;
16
16
  }[];
17
17
  }[] | undefined;
18
+ observations?: {
19
+ id: number;
20
+ type: string;
21
+ start: number;
22
+ end: number;
23
+ text: string;
24
+ }[] | undefined;
18
25
  currentTime?: number | undefined;
19
26
  onSetCurrentTime?: ((time: number) => void) | undefined;
20
27
  }, deps?: import("react").DependencyList | undefined) => Editor | null;
@@ -26,7 +33,10 @@ declare const EditorWithHighlight: {
26
33
  };
27
34
  FloatingMenu: (props: {
28
35
  editor: Editor;
29
- onClick: (editor: Editor) => void;
36
+ onClick: (editor: Editor, words: {
37
+ start: number;
38
+ end: number;
39
+ }) => void;
30
40
  }) => import("react/jsx-runtime").JSX.Element | null;
31
41
  };
32
42
  export { EditorWithHighlight };
@@ -1,4 +1,4 @@
1
- export declare const useEditor: ({ content, currentTime, onSetCurrentTime, }: {
1
+ export declare const useEditor: ({ content, observations, currentTime, onSetCurrentTime, }: {
2
2
  content?: {
3
3
  start: number;
4
4
  end: number;
@@ -9,6 +9,13 @@ export declare const useEditor: ({ content, currentTime, onSetCurrentTime, }: {
9
9
  word: string;
10
10
  }[];
11
11
  }[] | undefined;
12
+ observations?: {
13
+ id: number;
14
+ type: string;
15
+ start: number;
16
+ end: number;
17
+ text: string;
18
+ }[] | undefined;
12
19
  currentTime?: number | undefined;
13
20
  onSetCurrentTime?: ((time: number) => void) | undefined;
14
21
  }, deps?: React.DependencyList) => import("@tiptap/react").Editor | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appquality/unguess-design-system",
3
- "version": "3.1.91-highlight-1",
3
+ "version": "3.1.91-highlight-3",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",