@collabchron/notiq 1.1.11 → 1.1.12
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/dist/{AIDialog-2WZUFWSC.mjs → AIDialog-RHRYHSVN.mjs} +5 -5
- package/dist/{CodeActionMenuPlugin-MRKY67ED.mjs → CodeActionMenuPlugin-FGH6HZLL.mjs} +2 -2
- package/dist/{CollaboratorsBar-TMKBOBJI.mjs → CollaboratorsBar-AMPIAUOY.mjs} +2 -2
- package/dist/{CommentsPlugin-5M4RD6YO.mjs → CommentsPlugin-SDJJTUGK.mjs} +2 -2
- package/dist/{ExcalidrawComponent-SIMURTCA.mjs → ExcalidrawComponent-BMSYIPP6.mjs} +2 -2
- package/dist/{ExcalidrawPlugin-2SGPIQ6U.mjs → ExcalidrawPlugin-QLPGJPSX.mjs} +2 -2
- package/dist/{ExportPlugin-OKZOLBGS.mjs → ExportPlugin-MJHYKQZJ.mjs} +7 -6
- package/dist/{FloatingTextFormatToolbarPlugin-SO5VON7Q.mjs → FloatingTextFormatToolbarPlugin-BXCPN3KD.mjs} +19 -19
- package/dist/{MobileToolbar-JKP2MLQJ.mjs → MobileToolbar-KV5DX4ED.mjs} +15 -17
- package/dist/{SlashCommand-2TNOOUBM.mjs → SlashCommand-SPR7G5EI.mjs} +13 -13
- package/dist/{StoryBuilderComponent-WQSNFPMM.mjs → StoryBuilderComponent-JN4ZPZOW.mjs} +8 -8
- package/dist/{chunk-PHRVYPVM.mjs → ToolbarPlugin-F52PVNXU.mjs} +33 -18
- package/dist/{block-format-MTSIXWID.mjs → block-format-TODFREE2.mjs} +2 -2
- package/dist/{chunk-FYLRS4BG.mjs → chunk-22ZIL6NH.mjs} +1 -1
- package/dist/{chunk-Z6JAFF55.mjs → chunk-2LNT36RL.mjs} +2 -2
- package/dist/chunk-37LC44W3.mjs +2677 -0
- package/dist/chunk-5D4JF3ZZ.mjs +624 -0
- package/dist/{chunk-MPTE332I.mjs → chunk-6FQFPPLG.mjs} +18 -20
- package/dist/{chunk-GYYLZ3MQ.mjs → chunk-ELBTVBTS.mjs} +1 -1
- package/dist/{chunk-XYDBUQ6Z.mjs → chunk-ENH2IOHI.mjs} +15 -165
- package/dist/{chunk-MW6MAUY3.mjs → chunk-FO7M3X2B.mjs} +1 -1
- package/dist/{chunk-YDDBQZ77.mjs → chunk-LBGM4VVZ.mjs} +8 -8
- package/dist/{chunk-2KESP7OU.mjs → chunk-LLGVCM7M.mjs} +3 -3
- package/dist/chunk-LVRJM45C.mjs +171 -0
- package/dist/{chunk-XZXGYNTY.mjs → chunk-QNIY45SF.mjs} +1 -1
- package/dist/{chunk-YTLUQJE2.mjs → chunk-T2UBAZ66.mjs} +1 -1
- package/dist/{chunk-3AHNLIME.mjs → chunk-XNJNT6PC.mjs} +21 -21
- package/dist/{chunk-LLCP7NVE.mjs → chunk-XYLTLGY5.mjs} +355 -29
- package/dist/{chunk-XAVQAXOJ.mjs → chunk-ZYJ7KABY.mjs} +1 -1
- package/dist/{color-23323E3B.mjs → color-S55XFDYQ.mjs} +2 -2
- package/dist/components/editor/Core.d.ts +15 -2
- package/dist/components/editor/index.d.ts +15 -4
- package/dist/core/index.d.ts +2 -1
- package/dist/core/react/NotiqEditor.d.ts +8 -8
- package/dist/core/types.d.ts +1 -0
- package/dist/core.js +8946 -2207
- package/dist/core.mjs +32 -26
- package/dist/{font-size-GTL6UVQL.mjs → font-size-3HMJHKO2.mjs} +2 -2
- package/dist/{image-TPW7PZZK.mjs → image-QPB2CVXP.mjs} +6 -6
- package/dist/index.js +4372 -4382
- package/dist/index.mjs +87 -1611
- package/dist/{insert-image-CZV6HWQZ.mjs → insert-image-PLBZELHK.mjs} +4 -4
- package/dist/{insert-node-MA3FXEYN.mjs → insert-node-DGCZBGKG.mjs} +14 -16
- package/dist/react.js +10189 -3980
- package/dist/react.mjs +21 -16
- package/dist/{stepper-4AO5XMO7.mjs → stepper-KNITDVLG.mjs} +31 -31
- package/dist/styles/notiq.css +1 -1
- package/dist/{text-format-6L5N3CHZ.mjs → text-format-T3IY7FBI.mjs} +3 -3
- package/package.json +1 -1
- package/dist/ToolbarPlugin-IIAOU4P5.mjs +0 -35
- package/dist/chunk-AYNKORDO.mjs +0 -6
- package/dist/chunk-IU2N42JJ.mjs +0 -1763
- package/dist/chunk-W6GAJXUS.mjs +0 -334
- package/dist/{VersionHistoryPlugin-23MAZB4G.mjs → VersionHistoryPlugin-YWGCREKA.mjs} +3 -3
- package/dist/{background-color-OZJCBYCT.mjs → background-color-RW5JYLMG.mjs} +3 -3
- package/dist/{chunk-YE7M2VKR.mjs → chunk-C4JWLBYN.mjs} +3 -3
- package/dist/{chunk-KDA7ZYMJ.mjs → chunk-CLRSETYQ.mjs} +3 -3
- package/dist/{chunk-FMJ7DGWP.mjs → chunk-MSAO3YFB.mjs} +3 -3
- package/dist/{chunk-XYT6XM5S.mjs → chunk-N3KDPSRI.mjs} +3 -3
- package/dist/{chunk-MTQZWJHR.mjs → chunk-SYUCM5G5.mjs} +4 -4
- package/dist/{chunk-6SRMKQSD.mjs → chunk-VNDDDXGH.mjs} +3 -3
- package/dist/{chunk-LAUAYRPC.mjs → chunk-WUVIQCX7.mjs} +5 -5
- package/dist/{insert-audio-C66RZRKY.mjs → insert-audio-I3PD6JFS.mjs} +6 -6
- package/dist/{insert-file-3DTGRO7W.mjs → insert-file-PHR7XL4V.mjs} +6 -6
- package/dist/{insert-gif-FIMCCBAI.mjs → insert-gif-R5ZO4JHC.mjs} +3 -3
- package/dist/{text-align-CSDLJUDA.mjs → text-align-TEB4S52S.mjs} +3 -3
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
NOTIQ_TRANSFORMERS
|
|
3
|
-
} from "./chunk-2KESP7OU.mjs";
|
|
4
1
|
import {
|
|
5
2
|
Tabs,
|
|
6
3
|
TabsList,
|
|
7
4
|
TabsTrigger
|
|
8
5
|
} from "./chunk-6UVNHT3T.mjs";
|
|
6
|
+
import {
|
|
7
|
+
detectContentFormat,
|
|
8
|
+
importContentToEditor,
|
|
9
|
+
importHTMLToEditor,
|
|
10
|
+
importJSONToEditor,
|
|
11
|
+
importMarkdownToEditor,
|
|
12
|
+
importPlainTextToEditor
|
|
13
|
+
} from "./chunk-LVRJM45C.mjs";
|
|
14
|
+
import {
|
|
15
|
+
NOTIQ_TRANSFORMERS
|
|
16
|
+
} from "./chunk-LLGVCM7M.mjs";
|
|
9
17
|
import {
|
|
10
18
|
Button
|
|
11
19
|
} from "./chunk-OE5JRLCN.mjs";
|
|
@@ -20,7 +28,7 @@ import {
|
|
|
20
28
|
init_react_shim();
|
|
21
29
|
import { useLexicalComposerContext as useLexicalComposerContext2 } from "@lexical/react/LexicalComposerContext";
|
|
22
30
|
import { $convertToMarkdownString as $convertToMarkdownString2 } from "@lexical/markdown";
|
|
23
|
-
import { $getRoot as $
|
|
31
|
+
import { $getRoot as $getRoot3, COMMAND_PRIORITY_LOW, createCommand } from "lexical";
|
|
24
32
|
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
25
33
|
import { toCanvas } from "html-to-image";
|
|
26
34
|
import jsPDF from "jspdf";
|
|
@@ -568,168 +576,12 @@ function downloadHTML(htmlContent, filename = "document.html") {
|
|
|
568
576
|
URL.revokeObjectURL(url);
|
|
569
577
|
}
|
|
570
578
|
|
|
571
|
-
// src/components/editor/utils/importUtils.ts
|
|
572
|
-
init_react_shim();
|
|
573
|
-
import {
|
|
574
|
-
$getRoot as $getRoot2,
|
|
575
|
-
$getSelection,
|
|
576
|
-
$isRangeSelection,
|
|
577
|
-
$createParagraphNode,
|
|
578
|
-
$createTextNode,
|
|
579
|
-
$createLineBreakNode
|
|
580
|
-
} from "lexical";
|
|
581
|
-
import { $convertFromMarkdownString } from "@lexical/markdown";
|
|
582
|
-
import { $generateNodesFromDOM } from "@lexical/html";
|
|
583
|
-
function detectContentFormat(content, filename) {
|
|
584
|
-
if (filename) {
|
|
585
|
-
const ext = filename.toLowerCase().split(".").pop();
|
|
586
|
-
if (ext === "md" || ext === "markdown") return "markdown";
|
|
587
|
-
if (ext === "json" || ext === "lexical") return "json";
|
|
588
|
-
if (ext === "html" || ext === "htm") return "html";
|
|
589
|
-
if (ext === "txt") return "text";
|
|
590
|
-
}
|
|
591
|
-
const trimmed = content.trim();
|
|
592
|
-
if (trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]")) {
|
|
593
|
-
try {
|
|
594
|
-
const parsed = JSON.parse(trimmed);
|
|
595
|
-
if (parsed && (parsed.root || parsed.editorState || Array.isArray(parsed))) {
|
|
596
|
-
return "json";
|
|
597
|
-
}
|
|
598
|
-
} catch (e) {
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
if (/<!doctype html>/i.test(trimmed) || /<\/?[a-z][\s\S]*>/i.test(trimmed) && (trimmed.includes("<p>") || trimmed.includes("<div") || trimmed.includes("<h1") || trimmed.includes("<html") || trimmed.includes("<body"))) {
|
|
602
|
-
return "html";
|
|
603
|
-
}
|
|
604
|
-
if (/(^|\n)(#{1,6}\s|>\s|[-*+]\s|\d+\.\s|```|\|.*\|)/.test(trimmed) || /\[.*?\]\(.*?\)/.test(trimmed) || /\*\*.*?\*\*/.test(trimmed) || /_{2}.*?_{2}/.test(trimmed)) {
|
|
605
|
-
return "markdown";
|
|
606
|
-
}
|
|
607
|
-
return "text";
|
|
608
|
-
}
|
|
609
|
-
function importMarkdownToEditor(editor, markdown, mode = "replace") {
|
|
610
|
-
editor.update(
|
|
611
|
-
() => {
|
|
612
|
-
if (mode === "replace") {
|
|
613
|
-
const root = $getRoot2();
|
|
614
|
-
root.clear();
|
|
615
|
-
$convertFromMarkdownString(markdown, NOTIQ_TRANSFORMERS, root, true);
|
|
616
|
-
} else if (mode === "append") {
|
|
617
|
-
const root = $getRoot2();
|
|
618
|
-
$convertFromMarkdownString(markdown, NOTIQ_TRANSFORMERS, root, true);
|
|
619
|
-
} else {
|
|
620
|
-
const selection = $getSelection();
|
|
621
|
-
if ($isRangeSelection(selection)) {
|
|
622
|
-
const tempP = $createParagraphNode();
|
|
623
|
-
$convertFromMarkdownString(markdown, NOTIQ_TRANSFORMERS, tempP, true);
|
|
624
|
-
const children = tempP.getChildren();
|
|
625
|
-
if (children.length > 0) {
|
|
626
|
-
selection.insertNodes(children);
|
|
627
|
-
} else {
|
|
628
|
-
selection.insertText(markdown);
|
|
629
|
-
}
|
|
630
|
-
} else {
|
|
631
|
-
const root = $getRoot2();
|
|
632
|
-
$convertFromMarkdownString(markdown, NOTIQ_TRANSFORMERS, root, true);
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
},
|
|
636
|
-
{ discrete: true }
|
|
637
|
-
);
|
|
638
|
-
}
|
|
639
|
-
function importJSONToEditor(editor, jsonString) {
|
|
640
|
-
try {
|
|
641
|
-
const parsed = typeof jsonString === "string" ? JSON.parse(jsonString) : jsonString;
|
|
642
|
-
const stateData = parsed.editorState || parsed;
|
|
643
|
-
const editorState = editor.parseEditorState(stateData);
|
|
644
|
-
editor.setEditorState(editorState);
|
|
645
|
-
return true;
|
|
646
|
-
} catch (err) {
|
|
647
|
-
console.error("[Notiq Import JSON Error]:", err);
|
|
648
|
-
throw err;
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
function importHTMLToEditor(editor, html, mode = "replace") {
|
|
652
|
-
editor.update(
|
|
653
|
-
() => {
|
|
654
|
-
const parser = new DOMParser();
|
|
655
|
-
const cleanHtml = html.replace(/<!DOCTYPE html>/i, "").trim();
|
|
656
|
-
const dom = parser.parseFromString(cleanHtml, "text/html");
|
|
657
|
-
const nodes = $generateNodesFromDOM(editor, dom);
|
|
658
|
-
if (nodes.length === 0) return;
|
|
659
|
-
if (mode === "replace") {
|
|
660
|
-
const root = $getRoot2();
|
|
661
|
-
root.clear();
|
|
662
|
-
root.append(...nodes);
|
|
663
|
-
} else if (mode === "append") {
|
|
664
|
-
const root = $getRoot2();
|
|
665
|
-
root.append(...nodes);
|
|
666
|
-
} else {
|
|
667
|
-
const selection = $getSelection();
|
|
668
|
-
if ($isRangeSelection(selection)) {
|
|
669
|
-
selection.insertNodes(nodes);
|
|
670
|
-
} else {
|
|
671
|
-
$getRoot2().append(...nodes);
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
},
|
|
675
|
-
{ discrete: true }
|
|
676
|
-
);
|
|
677
|
-
}
|
|
678
|
-
function importPlainTextToEditor(editor, text, mode = "replace") {
|
|
679
|
-
editor.update(
|
|
680
|
-
() => {
|
|
681
|
-
const blocks = text.split(/\r?\n\r?\n/);
|
|
682
|
-
const nodes = blocks.map((block) => {
|
|
683
|
-
const p = $createParagraphNode();
|
|
684
|
-
const lines = block.split(/\r?\n/);
|
|
685
|
-
lines.forEach((line, idx) => {
|
|
686
|
-
if (idx > 0) p.append($createLineBreakNode());
|
|
687
|
-
p.append($createTextNode(line));
|
|
688
|
-
});
|
|
689
|
-
return p;
|
|
690
|
-
});
|
|
691
|
-
if (mode === "replace") {
|
|
692
|
-
const root = $getRoot2();
|
|
693
|
-
root.clear();
|
|
694
|
-
root.append(...nodes);
|
|
695
|
-
} else if (mode === "append") {
|
|
696
|
-
$getRoot2().append(...nodes);
|
|
697
|
-
} else {
|
|
698
|
-
const selection = $getSelection();
|
|
699
|
-
if ($isRangeSelection(selection)) {
|
|
700
|
-
selection.insertNodes(nodes);
|
|
701
|
-
} else {
|
|
702
|
-
$getRoot2().append(...nodes);
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
},
|
|
706
|
-
{ discrete: true }
|
|
707
|
-
);
|
|
708
|
-
}
|
|
709
|
-
function importContentToEditor(editor, content, format, mode = "replace") {
|
|
710
|
-
switch (format) {
|
|
711
|
-
case "json":
|
|
712
|
-
importJSONToEditor(editor, content);
|
|
713
|
-
break;
|
|
714
|
-
case "html":
|
|
715
|
-
importHTMLToEditor(editor, content, mode);
|
|
716
|
-
break;
|
|
717
|
-
case "markdown":
|
|
718
|
-
importMarkdownToEditor(editor, content, mode);
|
|
719
|
-
break;
|
|
720
|
-
case "text":
|
|
721
|
-
default:
|
|
722
|
-
importPlainTextToEditor(editor, content, mode);
|
|
723
|
-
break;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
|
|
727
579
|
// src/components/editor/plugins/ExportPlugin/ImportExportModal.tsx
|
|
728
580
|
init_react_shim();
|
|
729
581
|
import { useState, useEffect, useRef } from "react";
|
|
730
582
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
731
583
|
import { $convertToMarkdownString } from "@lexical/markdown";
|
|
732
|
-
import { $getRoot as $
|
|
584
|
+
import { $getRoot as $getRoot2 } from "lexical";
|
|
733
585
|
import {
|
|
734
586
|
FileText,
|
|
735
587
|
FileCode2,
|
|
@@ -849,7 +701,7 @@ function ImportExportModal({
|
|
|
849
701
|
};
|
|
850
702
|
const getDocumentText = () => {
|
|
851
703
|
return editor.getEditorState().read(() => {
|
|
852
|
-
return $
|
|
704
|
+
return $getRoot2().getTextContent();
|
|
853
705
|
});
|
|
854
706
|
};
|
|
855
707
|
const handleCopy = (format, getter) => {
|
|
@@ -1861,7 +1713,7 @@ function ExportPlugin() {
|
|
|
1861
1713
|
() => {
|
|
1862
1714
|
try {
|
|
1863
1715
|
editor.getEditorState().read(() => {
|
|
1864
|
-
const text = $
|
|
1716
|
+
const text = $getRoot3().getTextContent();
|
|
1865
1717
|
const blob = new Blob([text], { type: "text/plain;charset=utf-8" });
|
|
1866
1718
|
const url = URL.createObjectURL(blob);
|
|
1867
1719
|
const link = document.createElement("a");
|
|
@@ -1962,8 +1814,6 @@ function ExportPlugin() {
|
|
|
1962
1814
|
export {
|
|
1963
1815
|
exportEditorToHTML,
|
|
1964
1816
|
downloadHTML,
|
|
1965
|
-
detectContentFormat,
|
|
1966
|
-
importContentToEditor,
|
|
1967
1817
|
EXPORT_MARKDOWN_COMMAND,
|
|
1968
1818
|
EXPORT_PDF_COMMAND,
|
|
1969
1819
|
EXPORT_HTML_COMMAND,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LayoutContainerNode,
|
|
3
|
+
LayoutItemNode
|
|
4
|
+
} from "./chunk-XYLTLGY5.mjs";
|
|
1
5
|
import {
|
|
2
6
|
CollapsibleContainerNode,
|
|
3
7
|
CollapsibleContentNode,
|
|
4
8
|
CollapsibleTitleNode
|
|
5
9
|
} from "./chunk-4DVIYZVB.mjs";
|
|
6
|
-
import {
|
|
7
|
-
LayoutContainerNode,
|
|
8
|
-
LayoutItemNode
|
|
9
|
-
} from "./chunk-W6GAJXUS.mjs";
|
|
10
10
|
import {
|
|
11
11
|
InlineImageNode,
|
|
12
12
|
StepperNode
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-LLGVCM7M.mjs";
|
|
14
14
|
import {
|
|
15
15
|
FigmaNode,
|
|
16
16
|
TweetNode,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from "./chunk-N6ILV6NF.mjs";
|
|
22
22
|
import {
|
|
23
23
|
StoryBuilderNode
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-T2UBAZ66.mjs";
|
|
25
25
|
import {
|
|
26
26
|
DynamicBlockNode
|
|
27
27
|
} from "./chunk-43Z4Z2KD.mjs";
|
|
@@ -33,10 +33,10 @@ import {
|
|
|
33
33
|
} from "./chunk-ZFV2HGD3.mjs";
|
|
34
34
|
import {
|
|
35
35
|
ImageNode
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-ELBTVBTS.mjs";
|
|
37
37
|
import {
|
|
38
38
|
ExcalidrawNode
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-QNIY45SF.mjs";
|
|
40
40
|
import {
|
|
41
41
|
EquationNode
|
|
42
42
|
} from "./chunk-KNW2CGIP.mjs";
|
|
@@ -27,11 +27,11 @@ import {
|
|
|
27
27
|
$createImageNode,
|
|
28
28
|
$isImageNode,
|
|
29
29
|
ImageNode
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-ELBTVBTS.mjs";
|
|
31
31
|
import {
|
|
32
32
|
$isExcalidrawNode,
|
|
33
33
|
ExcalidrawNode
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-QNIY45SF.mjs";
|
|
35
35
|
import {
|
|
36
36
|
$isEquationNode,
|
|
37
37
|
EquationNode
|
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
import React, { Suspense, useEffect } from "react";
|
|
61
61
|
import { jsx } from "react/jsx-runtime";
|
|
62
62
|
var StepperComponent = React.lazy(
|
|
63
|
-
() => import("./stepper-
|
|
63
|
+
() => import("./stepper-KNITDVLG.mjs")
|
|
64
64
|
);
|
|
65
65
|
var initialEditorState = {
|
|
66
66
|
root: {
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NOTIQ_TRANSFORMERS
|
|
3
|
+
} from "./chunk-LLGVCM7M.mjs";
|
|
4
|
+
import {
|
|
5
|
+
init_react_shim
|
|
6
|
+
} from "./chunk-WYCFGRFJ.mjs";
|
|
7
|
+
|
|
8
|
+
// src/components/editor/utils/importUtils.ts
|
|
9
|
+
init_react_shim();
|
|
10
|
+
import {
|
|
11
|
+
$getRoot,
|
|
12
|
+
$getSelection,
|
|
13
|
+
$isRangeSelection,
|
|
14
|
+
$createParagraphNode,
|
|
15
|
+
$createTextNode,
|
|
16
|
+
$createLineBreakNode
|
|
17
|
+
} from "lexical";
|
|
18
|
+
import { $convertFromMarkdownString } from "@lexical/markdown";
|
|
19
|
+
import { $generateNodesFromDOM } from "@lexical/html";
|
|
20
|
+
function detectContentFormat(content, filename) {
|
|
21
|
+
if (filename) {
|
|
22
|
+
const ext = filename.toLowerCase().split(".").pop();
|
|
23
|
+
if (ext === "md" || ext === "markdown") return "markdown";
|
|
24
|
+
if (ext === "json" || ext === "lexical") return "json";
|
|
25
|
+
if (ext === "html" || ext === "htm") return "html";
|
|
26
|
+
if (ext === "txt") return "text";
|
|
27
|
+
}
|
|
28
|
+
const trimmed = content.trim();
|
|
29
|
+
if (trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]")) {
|
|
30
|
+
try {
|
|
31
|
+
const parsed = JSON.parse(trimmed);
|
|
32
|
+
if (parsed && (parsed.root || parsed.editorState || Array.isArray(parsed))) {
|
|
33
|
+
return "json";
|
|
34
|
+
}
|
|
35
|
+
} catch (e) {
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (/<!doctype html>/i.test(trimmed) || /<\/?[a-z][\s\S]*>/i.test(trimmed) && (trimmed.includes("<p>") || trimmed.includes("<div") || trimmed.includes("<h1") || trimmed.includes("<html") || trimmed.includes("<body"))) {
|
|
39
|
+
return "html";
|
|
40
|
+
}
|
|
41
|
+
if (/(^|\n)(#{1,6}\s|>\s|[-*+]\s|\d+\.\s|```|\|.*\|)/.test(trimmed) || /\[.*?\]\(.*?\)/.test(trimmed) || /\*\*.*?\*\*/.test(trimmed) || /_{2}.*?_{2}/.test(trimmed)) {
|
|
42
|
+
return "markdown";
|
|
43
|
+
}
|
|
44
|
+
return "text";
|
|
45
|
+
}
|
|
46
|
+
function importMarkdownToEditor(editor, markdown, mode = "replace") {
|
|
47
|
+
editor.update(
|
|
48
|
+
() => {
|
|
49
|
+
if (mode === "replace") {
|
|
50
|
+
const root = $getRoot();
|
|
51
|
+
root.clear();
|
|
52
|
+
$convertFromMarkdownString(markdown, NOTIQ_TRANSFORMERS, root, true);
|
|
53
|
+
} else if (mode === "append") {
|
|
54
|
+
const root = $getRoot();
|
|
55
|
+
$convertFromMarkdownString(markdown, NOTIQ_TRANSFORMERS, root, true);
|
|
56
|
+
} else {
|
|
57
|
+
const selection = $getSelection();
|
|
58
|
+
if ($isRangeSelection(selection)) {
|
|
59
|
+
const tempP = $createParagraphNode();
|
|
60
|
+
$convertFromMarkdownString(markdown, NOTIQ_TRANSFORMERS, tempP, true);
|
|
61
|
+
const children = tempP.getChildren();
|
|
62
|
+
if (children.length > 0) {
|
|
63
|
+
selection.insertNodes(children);
|
|
64
|
+
} else {
|
|
65
|
+
selection.insertText(markdown);
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
const root = $getRoot();
|
|
69
|
+
$convertFromMarkdownString(markdown, NOTIQ_TRANSFORMERS, root, true);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{ discrete: true }
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
function importJSONToEditor(editor, jsonString) {
|
|
77
|
+
try {
|
|
78
|
+
const parsed = typeof jsonString === "string" ? JSON.parse(jsonString) : jsonString;
|
|
79
|
+
const stateData = parsed.editorState || parsed;
|
|
80
|
+
const editorState = editor.parseEditorState(stateData);
|
|
81
|
+
editor.setEditorState(editorState);
|
|
82
|
+
return true;
|
|
83
|
+
} catch (err) {
|
|
84
|
+
console.error("[Notiq Import JSON Error]:", err);
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function importHTMLToEditor(editor, html, mode = "replace") {
|
|
89
|
+
editor.update(
|
|
90
|
+
() => {
|
|
91
|
+
const parser = new DOMParser();
|
|
92
|
+
const cleanHtml = html.replace(/<!DOCTYPE html>/i, "").trim();
|
|
93
|
+
const dom = parser.parseFromString(cleanHtml, "text/html");
|
|
94
|
+
const nodes = $generateNodesFromDOM(editor, dom);
|
|
95
|
+
if (nodes.length === 0) return;
|
|
96
|
+
if (mode === "replace") {
|
|
97
|
+
const root = $getRoot();
|
|
98
|
+
root.clear();
|
|
99
|
+
root.append(...nodes);
|
|
100
|
+
} else if (mode === "append") {
|
|
101
|
+
const root = $getRoot();
|
|
102
|
+
root.append(...nodes);
|
|
103
|
+
} else {
|
|
104
|
+
const selection = $getSelection();
|
|
105
|
+
if ($isRangeSelection(selection)) {
|
|
106
|
+
selection.insertNodes(nodes);
|
|
107
|
+
} else {
|
|
108
|
+
$getRoot().append(...nodes);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
{ discrete: true }
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
function importPlainTextToEditor(editor, text, mode = "replace") {
|
|
116
|
+
editor.update(
|
|
117
|
+
() => {
|
|
118
|
+
const blocks = text.split(/\r?\n\r?\n/);
|
|
119
|
+
const nodes = blocks.map((block) => {
|
|
120
|
+
const p = $createParagraphNode();
|
|
121
|
+
const lines = block.split(/\r?\n/);
|
|
122
|
+
lines.forEach((line, idx) => {
|
|
123
|
+
if (idx > 0) p.append($createLineBreakNode());
|
|
124
|
+
p.append($createTextNode(line));
|
|
125
|
+
});
|
|
126
|
+
return p;
|
|
127
|
+
});
|
|
128
|
+
if (mode === "replace") {
|
|
129
|
+
const root = $getRoot();
|
|
130
|
+
root.clear();
|
|
131
|
+
root.append(...nodes);
|
|
132
|
+
} else if (mode === "append") {
|
|
133
|
+
$getRoot().append(...nodes);
|
|
134
|
+
} else {
|
|
135
|
+
const selection = $getSelection();
|
|
136
|
+
if ($isRangeSelection(selection)) {
|
|
137
|
+
selection.insertNodes(nodes);
|
|
138
|
+
} else {
|
|
139
|
+
$getRoot().append(...nodes);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{ discrete: true }
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
function importContentToEditor(editor, content, format, mode = "replace") {
|
|
147
|
+
switch (format) {
|
|
148
|
+
case "json":
|
|
149
|
+
importJSONToEditor(editor, content);
|
|
150
|
+
break;
|
|
151
|
+
case "html":
|
|
152
|
+
importHTMLToEditor(editor, content, mode);
|
|
153
|
+
break;
|
|
154
|
+
case "markdown":
|
|
155
|
+
importMarkdownToEditor(editor, content, mode);
|
|
156
|
+
break;
|
|
157
|
+
case "text":
|
|
158
|
+
default:
|
|
159
|
+
importPlainTextToEditor(editor, content, mode);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export {
|
|
165
|
+
detectContentFormat,
|
|
166
|
+
importMarkdownToEditor,
|
|
167
|
+
importJSONToEditor,
|
|
168
|
+
importHTMLToEditor,
|
|
169
|
+
importPlainTextToEditor,
|
|
170
|
+
importContentToEditor
|
|
171
|
+
};
|
|
@@ -9,7 +9,7 @@ init_react_shim();
|
|
|
9
9
|
import { DecoratorNode } from "lexical";
|
|
10
10
|
import * as React from "react";
|
|
11
11
|
import { jsx } from "react/jsx-runtime";
|
|
12
|
-
var ExcalidrawComponent = React.lazy(() => import("./ExcalidrawComponent-
|
|
12
|
+
var ExcalidrawComponent = React.lazy(() => import("./ExcalidrawComponent-BMSYIPP6.mjs"));
|
|
13
13
|
function $convertExcalidrawElement(domNode) {
|
|
14
14
|
const excalidrawData = domNode.getAttribute("data-lexical-excalidraw-json");
|
|
15
15
|
const styleAttributes = window.getComputedStyle(domNode);
|
|
@@ -8,7 +8,7 @@ import { $applyNodeReplacement, DecoratorNode } from "lexical";
|
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import { Suspense } from "react";
|
|
10
10
|
import { jsx } from "react/jsx-runtime";
|
|
11
|
-
var StoryBuilderComponent = React.lazy(() => import("./StoryBuilderComponent-
|
|
11
|
+
var StoryBuilderComponent = React.lazy(() => import("./StoryBuilderComponent-JN4ZPZOW.mjs"));
|
|
12
12
|
function convertStoryBuilderElement(domNode) {
|
|
13
13
|
const textContent = domNode.textContent;
|
|
14
14
|
if (textContent) {
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Toggle
|
|
3
|
+
} from "./chunk-PD5K4AGP.mjs";
|
|
4
|
+
import {
|
|
5
|
+
getSelectedNode
|
|
6
|
+
} from "./chunk-KXRLARGI.mjs";
|
|
1
7
|
import {
|
|
2
8
|
TextFormat
|
|
3
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-SYUCM5G5.mjs";
|
|
4
10
|
import {
|
|
5
11
|
Font
|
|
6
12
|
} from "./chunk-SAOJHVPE.mjs";
|
|
7
13
|
import {
|
|
8
14
|
FontSize
|
|
9
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-C4JWLBYN.mjs";
|
|
10
16
|
import {
|
|
11
17
|
ExtractData,
|
|
12
18
|
getSelectedText,
|
|
13
19
|
insertText,
|
|
14
20
|
insertTextUnderSelected,
|
|
15
21
|
replaceSelectedText
|
|
16
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-ZYJ7KABY.mjs";
|
|
17
23
|
import {
|
|
18
24
|
BlockFormatDropDown
|
|
19
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-MSAO3YFB.mjs";
|
|
26
|
+
import {
|
|
27
|
+
Command,
|
|
28
|
+
CommandEmpty,
|
|
29
|
+
CommandGroup,
|
|
30
|
+
CommandInput,
|
|
31
|
+
CommandItem,
|
|
32
|
+
CommandList,
|
|
33
|
+
CommandSeparator
|
|
34
|
+
} from "./chunk-LU2XWLOE.mjs";
|
|
20
35
|
import {
|
|
21
36
|
INSERT_COMMENT_COMMAND
|
|
22
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-WUVIQCX7.mjs";
|
|
23
38
|
import {
|
|
24
39
|
Color
|
|
25
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-CLRSETYQ.mjs";
|
|
26
41
|
import {
|
|
27
42
|
useAI
|
|
28
43
|
} from "./chunk-BGV62GC2.mjs";
|
|
29
|
-
import {
|
|
30
|
-
Toggle
|
|
31
|
-
} from "./chunk-PD5K4AGP.mjs";
|
|
32
|
-
import {
|
|
33
|
-
getSelectedNode
|
|
34
|
-
} from "./chunk-KXRLARGI.mjs";
|
|
35
44
|
import {
|
|
36
45
|
SHORTCUTS
|
|
37
46
|
} from "./chunk-K5OAFEVY.mjs";
|
|
38
|
-
import {
|
|
39
|
-
Command,
|
|
40
|
-
CommandEmpty,
|
|
41
|
-
CommandGroup,
|
|
42
|
-
CommandInput,
|
|
43
|
-
CommandItem,
|
|
44
|
-
CommandList,
|
|
45
|
-
CommandSeparator
|
|
46
|
-
} from "./chunk-LU2XWLOE.mjs";
|
|
47
47
|
import {
|
|
48
48
|
Separator
|
|
49
49
|
} from "./chunk-CDAMHK63.mjs";
|