@appquality/unguess-design-system 3.1.91-highlight-3 → 3.1.91-highlight-4

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.
Files changed (2) hide show
  1. package/build/index.js +56 -27
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -7638,6 +7638,61 @@ const Word = core.Node.create({
7638
7638
  });
7639
7639
 
7640
7640
  const useEditor = ({ content, observations, currentTime, onSetCurrentTime, }, deps) => {
7641
+ function getParsedContent() {
7642
+ if (!content)
7643
+ return undefined;
7644
+ const result = {
7645
+ type: "doc",
7646
+ content: content.map((paragraph) => {
7647
+ function getWords() {
7648
+ return paragraph.words.map((word) => {
7649
+ const observationsInThisWord = observations === null || observations === void 0 ? void 0 : observations.filter((observation) => observation.start >= word.start && observation.end <= word.end);
7650
+ function getWordContent() {
7651
+ const textContent = [
7652
+ {
7653
+ type: "text",
7654
+ text: `${word.word} `,
7655
+ },
7656
+ ];
7657
+ if (!observationsInThisWord ||
7658
+ observationsInThisWord.length === 0)
7659
+ return textContent;
7660
+ return observationsInThisWord.reduce((acc, observation) => {
7661
+ return [
7662
+ {
7663
+ type: "Observation",
7664
+ attrs: {
7665
+ type: observation.type,
7666
+ title: observation.text,
7667
+ },
7668
+ content: acc,
7669
+ },
7670
+ ];
7671
+ }, textContent);
7672
+ }
7673
+ return {
7674
+ type: "Word",
7675
+ attrs: {
7676
+ "data-start": word.start,
7677
+ "data-end": word.end,
7678
+ },
7679
+ content: getWordContent(),
7680
+ };
7681
+ });
7682
+ }
7683
+ return {
7684
+ type: "Paragraph",
7685
+ attrs: {
7686
+ speakername: `Speaker ${paragraph.speaker}`,
7687
+ start: paragraph.start,
7688
+ end: paragraph.end,
7689
+ },
7690
+ content: getWords(),
7691
+ };
7692
+ }),
7693
+ };
7694
+ return result;
7695
+ }
7641
7696
  const ed = react.useEditor({
7642
7697
  extensions: [
7643
7698
  Document__default["default"],
@@ -7653,32 +7708,7 @@ const useEditor = ({ content, observations, currentTime, onSetCurrentTime, }, de
7653
7708
  editorProps: {
7654
7709
  handlePaste: () => true,
7655
7710
  },
7656
- content: {
7657
- type: "doc",
7658
- content: content
7659
- ? content.map((paragraph) => ({
7660
- type: "Paragraph",
7661
- attrs: {
7662
- speakername: `Speaker ${paragraph.speaker}`,
7663
- start: paragraph.start,
7664
- end: paragraph.end,
7665
- },
7666
- content: paragraph.words.map((word) => ({
7667
- type: "Word",
7668
- attrs: {
7669
- "data-start": word.start,
7670
- "data-end": word.end,
7671
- },
7672
- content: [
7673
- {
7674
- type: "text",
7675
- text: `${word.word} `,
7676
- },
7677
- ],
7678
- })),
7679
- }))
7680
- : undefined,
7681
- },
7711
+ content: getParsedContent(),
7682
7712
  }, deps);
7683
7713
  React.useEffect(() => {
7684
7714
  if (!currentTime)
@@ -7738,7 +7768,6 @@ const EditorWithHighlight = ({ editor }) => {
7738
7768
  return null;
7739
7769
  return (jsxRuntime.jsx(EditorWrapper, { children: jsxRuntime.jsx(react.EditorContent, { ref: ref, editor: editor }) }));
7740
7770
  };
7741
- // rebuild the EditorWithHighlight component
7742
7771
  EditorWithHighlight.useEditor = useEditor;
7743
7772
  EditorWithHighlight.Search = Search;
7744
7773
  EditorWithHighlight.FloatingMenu = FloatingMenu;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appquality/unguess-design-system",
3
- "version": "3.1.91-highlight-3",
3
+ "version": "3.1.91-highlight-4",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",