@haklex/rich-editor 0.0.82 → 0.0.84
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/AlertQuoteEditNode-CB8C24Xf.js +293 -0
- package/dist/KaTeXRenderer-CQyQzNTJ.js +218 -0
- package/dist/LinkCardRenderer-QmkOlyXb.js +36 -0
- package/dist/MermaidPlugin-DfIhGe-1.js +97 -0
- package/dist/PresentDialogContext-B4E78UB5.js +58 -0
- package/dist/RubyRenderer-CJQmODir.js +14 -0
- package/dist/SubmitShortcutPlugin-CkuM_8Wk.js +1650 -0
- package/dist/commands-entry.mjs +23 -14
- package/dist/components/LinkFavicon.d.ts.map +1 -1
- package/dist/components/decorators/GridEditDecorator.d.ts.map +1 -1
- package/dist/components/renderers/FootnoteRenderer.d.ts.map +1 -1
- package/dist/components/renderers/FootnoteSectionEditRenderer.d.ts.map +1 -1
- package/dist/components/renderers/FootnoteSectionRenderer.d.ts.map +1 -1
- package/dist/components/renderers/FootnoteStaticRenderer.d.ts.map +1 -1
- package/dist/components/renderers/GridStaticDecorator.d.ts.map +1 -1
- package/dist/components/renderers/KaTeXRenderer.d.ts.map +1 -1
- package/dist/components/renderers/RubyRenderer.d.ts.map +1 -1
- package/dist/components/renderers/TagRenderer.d.ts.map +1 -1
- package/dist/config-BulxE6hd.js +1362 -0
- package/dist/config-edit.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/favicon-BQgbXF_a.js +43 -0
- package/dist/grid.css-Md5-Cfx_.js +11 -0
- package/dist/index.mjs +292 -259
- package/dist/katex.css-Csc-7N7u.js +28 -0
- package/dist/node-registry-eMijRh3N.js +824 -0
- package/dist/nodes/AlertQuoteNode.d.ts.map +1 -1
- package/dist/nodes/CommentNode.d.ts +21 -0
- package/dist/nodes/CommentNode.d.ts.map +1 -0
- package/dist/nodes/DetailsNode.d.ts.map +1 -1
- package/dist/nodes/FootnoteNode.d.ts.map +1 -1
- package/dist/nodes/FootnoteSectionNode.d.ts.map +1 -1
- package/dist/nodes/GridContainerNode.d.ts.map +1 -1
- package/dist/nodes/RubyNode.d.ts.map +1 -1
- package/dist/nodes/SpoilerNode.d.ts.map +1 -1
- package/dist/nodes/TagNode.d.ts.map +1 -1
- package/dist/nodes-entry.d.ts +2 -0
- package/dist/nodes-entry.d.ts.map +1 -1
- package/dist/nodes-entry.mjs +50 -7
- package/dist/plugins/MarkdownPastePlugin.d.ts.map +1 -1
- package/dist/plugins-entry.mjs +27 -10
- package/dist/renderers-entry.mjs +61 -40
- package/dist/rich-editor.css +1 -2
- package/dist/static-entry.d.ts +4 -1
- package/dist/static-entry.d.ts.map +1 -1
- package/dist/static-entry.mjs +62 -16
- package/dist/styles/article.css.d.ts.map +1 -1
- package/dist/styles/comment.css.d.ts.map +1 -1
- package/dist/styles/details.css.d.ts +19 -1
- package/dist/styles/details.css.d.ts.map +1 -1
- package/dist/styles/grid.css.d.ts +34 -1
- package/dist/styles/grid.css.d.ts.map +1 -1
- package/dist/styles/index.d.ts +5 -2
- package/dist/styles/index.d.ts.map +1 -1
- package/dist/styles/katex.css.d.ts +13 -1
- package/dist/styles/katex.css.d.ts.map +1 -1
- package/dist/styles/note.css.d.ts.map +1 -1
- package/dist/styles/shared.css.d.ts +164 -0
- package/dist/styles/shared.css.d.ts.map +1 -1
- package/dist/styles/theme.d.ts.map +1 -1
- package/dist/styles-entry.d.ts +5 -2
- package/dist/styles-entry.d.ts.map +1 -1
- package/dist/styles-entry.mjs +21 -3
- package/dist/theme-D_efLk4K.js +1034 -0
- package/dist/transformers/comment.d.ts +4 -0
- package/dist/transformers/comment.d.ts.map +1 -0
- package/dist/transformers/index.d.ts +1 -0
- package/dist/transformers/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/AlertQuoteEditNode-BDoonB4u.js +0 -267
- package/dist/KaTeXRenderer-BsyRH5_t.js +0 -214
- package/dist/LinkCardRenderer-OEMBDUhD.js +0 -45
- package/dist/MermaidPlugin-Df2Cm2yX.js +0 -67
- package/dist/PresentDialogContext-DQw6MrNh.js +0 -59
- package/dist/RubyRenderer-BpDb_amz.js +0 -14
- package/dist/SubmitShortcutPlugin-6IvsbZD-.js +0 -1463
- package/dist/config-tfg1FWhG.js +0 -1149
- package/dist/favicon-DIWusrrw.js +0 -41
- package/dist/node-registry-CeVi2y9f.js +0 -666
- package/dist/shared.css-wgGgtK_e.js +0 -23
- package/dist/theme-DHOUKKSr.js +0 -1034
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-edit.d.ts","sourceRoot":"","sources":["../src/config-edit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"config-edit.d.ts","sourceRoot":"","sources":["../src/config-edit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAsBlD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAmBrD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAyC,CAAC"}
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAqBlD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAYlD,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAmBjD,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAqC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const FAVICON_VARIANTS = [
|
|
2
|
+
"/favicon.ico",
|
|
3
|
+
"/favicon.png",
|
|
4
|
+
"/favicon.svg",
|
|
5
|
+
"/apple-touch-icon.png",
|
|
6
|
+
"/apple-touch-icon-precomposed.png"
|
|
7
|
+
];
|
|
8
|
+
const faviconCache = /* @__PURE__ */ new Map();
|
|
9
|
+
function getHostname(href) {
|
|
10
|
+
try {
|
|
11
|
+
const url = new URL(href);
|
|
12
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return null;
|
|
13
|
+
return url.hostname;
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function probeImage(url) {
|
|
19
|
+
return new Promise((resolve) => {
|
|
20
|
+
const img = new Image();
|
|
21
|
+
img.onload = () => resolve(url);
|
|
22
|
+
img.onerror = () => resolve(null);
|
|
23
|
+
img.src = url;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async function probeFavicon(hostname) {
|
|
27
|
+
const cached = faviconCache.get(hostname);
|
|
28
|
+
if (cached !== void 0) return cached;
|
|
29
|
+
for (const variant of FAVICON_VARIANTS) {
|
|
30
|
+
const url = `https://${hostname}${variant}`;
|
|
31
|
+
const result = await probeImage(url);
|
|
32
|
+
if (result) {
|
|
33
|
+
faviconCache.set(hostname, result);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
faviconCache.set(hostname, null);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
getHostname as g,
|
|
42
|
+
probeFavicon as p
|
|
43
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "./katex.css-Csc-7N7u.js";
|
|
2
|
+
var detailsClassNames = { details: "rich-details", summary: "rich-details-summary", summaryText: "rich-details-summary-text", chevron: "rich-details-chevron", content: "rich-details-content" };
|
|
3
|
+
var detailsStyles = { details: "_1o2d5g50", summary: "_1o2d5g51", summaryText: "_1o2d5g52", chevron: "_1o2d5g53", content: "_1o2d5g54" };
|
|
4
|
+
var gridClassNames = { container: "rich-grid-container", toolbar: "rich-grid-toolbar", toolbarIcon: "rich-grid-toolbar-icon", colButton: "rich-grid-col-btn", colButtonActive: "rich-grid-col-btn-active", toolbarDivider: "rich-grid-toolbar-divider", actionButton: "rich-grid-action-btn", inner: "rich-grid-inner", cell: "rich-grid-cell", cellEditable: "rich-grid-cell-editable" };
|
|
5
|
+
var gridStyles = { container: "_17ihk870", toolbar: "_17ihk871", toolbarIcon: "_17ihk872", colButton: "_17ihk873", colButtonActive: "_17ihk874", toolbarDivider: "_17ihk875", actionButton: "_17ihk876", inner: "_17ihk877", cell: "_17ihk878", cellEditable: "_17ihk879" };
|
|
6
|
+
export {
|
|
7
|
+
detailsStyles as a,
|
|
8
|
+
gridStyles as b,
|
|
9
|
+
detailsClassNames as d,
|
|
10
|
+
gridClassNames as g
|
|
11
|
+
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,285 +1,318 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { F as useOptionalNestedContentRenderer, N as NestedContentRendererProvider, P as useNestedContentRenderer, t as editorTheme } from "./theme-DHOUKKSr.js";
|
|
4
|
-
import { a as FootnoteDefinitionsProvider, c as useFootnoteDisplayNumber, d as RendererConfigProvider, f as useRendererConfig, m as useVariant, o as useFootnoteContent, p as useRendererMode, s as useFootnoteDefinitions } from "./KaTeXRenderer-BsyRH5_t.js";
|
|
5
|
-
import { C as useColorScheme, S as ColorSchemeProvider } from "./config-tfg1FWhG.js";
|
|
6
|
-
import "./LinkCardRenderer-OEMBDUhD.js";
|
|
7
|
-
import "./AlertQuoteEditNode-BDoonB4u.js";
|
|
8
|
-
import { n as usePresentDialog, r as LinkFavicon, t as PresentDialogProvider } from "./PresentDialogContext-DQw6MrNh.js";
|
|
9
|
-
import { a as KaTeXPlugin, c as AlertPlugin, n as MermaidPlugin, s as ImagePlugin } from "./MermaidPlugin-Df2Cm2yX.js";
|
|
10
|
-
/* empty css */
|
|
11
|
-
import { a as commentVariant, i as noteVariant, n as clsx, o as articleVariant, r as getVariantClass, t as richContent } from "./shared.css-wgGgtK_e.js";
|
|
12
|
-
import { $getRoot, $getSelection, $getState, $isElementNode, $isLineBreakNode, $isRangeSelection, $isTextNode } from "lexical";
|
|
1
|
+
import { F as FootnotePlugin, O as OnChangePlugin, S as SubmitShortcutPlugin, E as EditorRefPlugin, a as AutoFocusPlugin, d as ImageUploadProvider, g as defaultImageUpload, C as CorePlugins, I as ImageUploadPlugin, L as LinkFaviconPlugin, c as BlockIdPlugin, f as blockIdState } from "./SubmitShortcutPlugin-CkuM_8Wk.js";
|
|
2
|
+
import { L, P, u } from "./PresentDialogContext-B4E78UB5.js";
|
|
13
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
4
|
+
import { s as setResolvedEditNodes, a as allEditNodes } from "./node-registry-eMijRh3N.js";
|
|
5
|
+
import { I as ImagePlugin, K as KaTeXPlugin, A as AlertPlugin, M as MermaidPlugin } from "./MermaidPlugin-DfIhGe-1.js";
|
|
17
6
|
import { PortalThemeProvider } from "@haklex/rich-style-token";
|
|
18
7
|
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
8
|
+
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
19
9
|
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
10
|
+
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
11
|
+
import { n as ColorSchemeProvider } from "./config-BulxE6hd.js";
|
|
12
|
+
import { u as u2 } from "./config-BulxE6hd.js";
|
|
13
|
+
import { R as RendererConfigProvider } from "./KaTeXRenderer-CQyQzNTJ.js";
|
|
14
|
+
import { F, u as u3, b, d, e, f, g } from "./KaTeXRenderer-CQyQzNTJ.js";
|
|
15
|
+
import { n as editorTheme } from "./theme-D_efLk4K.js";
|
|
16
|
+
import { N, u as u4, p } from "./theme-D_efLk4K.js";
|
|
17
|
+
import { ContentEditable as ContentEditable$1 } from "@lexical/react/LexicalContentEditable";
|
|
18
|
+
import { e as clsx, g as getVariantClass } from "./katex.css-Csc-7N7u.js";
|
|
19
|
+
import { a, c, k, b as b2, n, r, s, d as d2 } from "./katex.css-Csc-7N7u.js";
|
|
20
|
+
import { d as d3, a as a2, g as g2, b as b3 } from "./grid.css-Md5-Cfx_.js";
|
|
20
21
|
import { articleTheme, commentTheme, noteTheme, vars } from "@haklex/rich-style-token/styles";
|
|
21
|
-
|
|
22
|
+
import { $getRoot, $getSelection, $isRangeSelection, $getState, $isElementNode, $isTextNode, $isLineBreakNode } from "lexical";
|
|
22
23
|
var contentWrapper = "b94s950";
|
|
23
24
|
var content = "b94s951";
|
|
24
25
|
var placeholder = "b94s952";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
function ContentEditable({ className, placeholder: placeholder$1, hasHeader }) {
|
|
27
|
+
const paddingTop = hasHeader ? 40 : 12;
|
|
28
|
+
return /* @__PURE__ */ jsx(
|
|
29
|
+
"div",
|
|
30
|
+
{
|
|
31
|
+
className: clsx("rich-editor__content-wrapper", contentWrapper),
|
|
32
|
+
style: { "--ce-padding-top": `${paddingTop}px` },
|
|
33
|
+
children: /* @__PURE__ */ jsx(
|
|
34
|
+
ContentEditable$1,
|
|
35
|
+
{
|
|
36
|
+
"aria-placeholder": placeholder$1 ?? "",
|
|
37
|
+
className: clsx("rich-editor__content", content, className),
|
|
38
|
+
placeholder: /* @__PURE__ */ jsx(
|
|
39
|
+
"div",
|
|
40
|
+
{
|
|
41
|
+
className: clsx("rich-editor__placeholder", placeholder),
|
|
42
|
+
style: { display: placeholder$1 ? void 0 : "none" },
|
|
43
|
+
children: placeholder$1
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
);
|
|
42
50
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
51
|
+
function RichEditorShell({
|
|
52
|
+
nodes,
|
|
53
|
+
initialValue,
|
|
54
|
+
onChange,
|
|
55
|
+
variant = "article",
|
|
56
|
+
theme = "light",
|
|
57
|
+
placeholder: placeholder2 = "Write something...",
|
|
58
|
+
onSubmit,
|
|
59
|
+
autoFocus = false,
|
|
60
|
+
className,
|
|
61
|
+
contentClassName,
|
|
62
|
+
style,
|
|
63
|
+
actions,
|
|
64
|
+
header,
|
|
65
|
+
onEditorReady,
|
|
66
|
+
rendererConfig,
|
|
67
|
+
debounceMs,
|
|
68
|
+
children
|
|
69
|
+
}) {
|
|
70
|
+
setResolvedEditNodes(nodes);
|
|
71
|
+
const initialConfig = {
|
|
72
|
+
namespace: "RichEditor",
|
|
73
|
+
theme: editorTheme,
|
|
74
|
+
nodes,
|
|
75
|
+
editable: true,
|
|
76
|
+
onError: (error) => {
|
|
77
|
+
console.error("[RichEditor]", error);
|
|
78
|
+
},
|
|
79
|
+
...initialValue ? { editorState: JSON.stringify(initialValue) } : {}
|
|
80
|
+
};
|
|
81
|
+
const variantClass = getVariantClass(variant);
|
|
82
|
+
return /* @__PURE__ */ jsx(PortalThemeProvider, { className: variantClass, theme, children: /* @__PURE__ */ jsx(ColorSchemeProvider, { colorScheme: theme, children: /* @__PURE__ */ jsx(RendererConfigProvider, { config: rendererConfig, mode: "editor", variant, children: /* @__PURE__ */ jsx(LexicalComposer, { initialConfig, children: /* @__PURE__ */ jsx(FootnotePlugin, { children: /* @__PURE__ */ jsxs(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
suppressHydrationWarning: true,
|
|
86
|
+
className: clsx("rich-editor", variantClass, className),
|
|
87
|
+
"data-theme": theme,
|
|
88
|
+
style: { ...style, maxWidth: "none" },
|
|
89
|
+
children: [
|
|
90
|
+
header,
|
|
91
|
+
/* @__PURE__ */ jsx(
|
|
92
|
+
RichTextPlugin,
|
|
93
|
+
{
|
|
94
|
+
ErrorBoundary: LexicalErrorBoundary,
|
|
95
|
+
contentEditable: /* @__PURE__ */ jsx(
|
|
96
|
+
ContentEditable,
|
|
97
|
+
{
|
|
98
|
+
className: contentClassName,
|
|
99
|
+
hasHeader: !!header,
|
|
100
|
+
placeholder: placeholder2
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ jsx(HistoryPlugin, {}),
|
|
106
|
+
/* @__PURE__ */ jsx(OnChangePlugin, { debounceMs, onChange }),
|
|
107
|
+
/* @__PURE__ */ jsx(SubmitShortcutPlugin, { onSubmit }),
|
|
108
|
+
/* @__PURE__ */ jsx(EditorRefPlugin, { onEditorReady }),
|
|
109
|
+
autoFocus && /* @__PURE__ */ jsx(AutoFocusPlugin, {}),
|
|
110
|
+
children,
|
|
111
|
+
actions && /* @__PURE__ */ jsx("div", { className: "rich-editor__actions", children: actions })
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
) }) }) }) }) });
|
|
106
115
|
}
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region src/components/RichEditor.tsx
|
|
109
116
|
function RichEditor({ extraNodes, imageUpload, children, ...shellProps }) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
/* @__PURE__ */ jsx(MermaidPlugin, {}),
|
|
124
|
-
/* @__PURE__ */ jsx(LinkFaviconPlugin, {}),
|
|
125
|
-
/* @__PURE__ */ jsx(BlockIdPlugin, {}),
|
|
126
|
-
children
|
|
127
|
-
]
|
|
128
|
-
})
|
|
129
|
-
});
|
|
117
|
+
const nodes = extraNodes ? [...allEditNodes, ...extraNodes] : allEditNodes;
|
|
118
|
+
const resolvedImageUpload = imageUpload ?? defaultImageUpload;
|
|
119
|
+
return /* @__PURE__ */ jsx(ImageUploadProvider, { upload: resolvedImageUpload, children: /* @__PURE__ */ jsxs(RichEditorShell, { nodes, ...shellProps, children: [
|
|
120
|
+
/* @__PURE__ */ jsx(CorePlugins, {}),
|
|
121
|
+
/* @__PURE__ */ jsx(ImagePlugin, {}),
|
|
122
|
+
/* @__PURE__ */ jsx(ImageUploadPlugin, { onUpload: resolvedImageUpload }),
|
|
123
|
+
/* @__PURE__ */ jsx(KaTeXPlugin, {}),
|
|
124
|
+
/* @__PURE__ */ jsx(AlertPlugin, {}),
|
|
125
|
+
/* @__PURE__ */ jsx(MermaidPlugin, {}),
|
|
126
|
+
/* @__PURE__ */ jsx(LinkFaviconPlugin, {}),
|
|
127
|
+
/* @__PURE__ */ jsx(BlockIdPlugin, {}),
|
|
128
|
+
children
|
|
129
|
+
] }) });
|
|
130
130
|
}
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region src/utils/comment-anchor.ts
|
|
133
131
|
function computeBlockFingerprint(block) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
132
|
+
const text = block.getTextContent();
|
|
133
|
+
const input = text.slice(0, 200) + String(text.length);
|
|
134
|
+
let hash = 5381;
|
|
135
|
+
for (let i = 0; i < input.length; i++) {
|
|
136
|
+
hash = (hash << 5) + hash + (input.codePointAt(i) ?? 0) | 0;
|
|
137
|
+
}
|
|
138
|
+
return (hash >>> 0).toString(16);
|
|
139
139
|
}
|
|
140
140
|
function $getRootBlock(node) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
141
|
+
const root = $getRoot();
|
|
142
|
+
let current = node;
|
|
143
|
+
while (current) {
|
|
144
|
+
const parent = current.getParent();
|
|
145
|
+
if (parent === root && "getChildren" in current) {
|
|
146
|
+
return current;
|
|
147
|
+
}
|
|
148
|
+
current = parent;
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
149
151
|
}
|
|
150
152
|
function $resolveSelectionPoint(selection, which) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
node,
|
|
166
|
-
offset: 0
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
return {
|
|
170
|
-
node,
|
|
171
|
-
offset: point.offset
|
|
172
|
-
};
|
|
153
|
+
const point = selection[which];
|
|
154
|
+
const node = point.getNode();
|
|
155
|
+
if ($isElementNode(node)) {
|
|
156
|
+
const children = node.getChildren();
|
|
157
|
+
if (point.offset < children.length) {
|
|
158
|
+
return { node: children[point.offset], offset: 0 };
|
|
159
|
+
}
|
|
160
|
+
const last = children.at(-1);
|
|
161
|
+
if (last && $isTextNode(last)) {
|
|
162
|
+
return { node: last, offset: last.getTextContentSize() };
|
|
163
|
+
}
|
|
164
|
+
return { node, offset: 0 };
|
|
165
|
+
}
|
|
166
|
+
return { node, offset: point.offset };
|
|
173
167
|
}
|
|
174
168
|
function $getTextOffsetInBlock(block, targetNode, targetOffset) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
169
|
+
let offset = 0;
|
|
170
|
+
function walk(node) {
|
|
171
|
+
if (node.is(targetNode)) {
|
|
172
|
+
offset += targetOffset;
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
if ($isTextNode(node)) {
|
|
176
|
+
offset += node.getTextContentSize();
|
|
177
|
+
} else if ($isLineBreakNode(node)) {
|
|
178
|
+
offset += 1;
|
|
179
|
+
} else if ($isElementNode(node)) {
|
|
180
|
+
for (const child of node.getChildren()) {
|
|
181
|
+
if (walk(child)) return true;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
for (const child of block.getChildren()) {
|
|
187
|
+
if (walk(child)) break;
|
|
188
|
+
}
|
|
189
|
+
return offset;
|
|
190
190
|
}
|
|
191
191
|
function $buildBlockAnchorData(block) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
};
|
|
192
|
+
const blockId = $getState(block, blockIdState);
|
|
193
|
+
if (!blockId) {
|
|
194
|
+
return { ok: false, error: "no-block-id" };
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
ok: true,
|
|
198
|
+
anchor: {
|
|
199
|
+
mode: "block",
|
|
200
|
+
blockId,
|
|
201
|
+
blockType: block.getType(),
|
|
202
|
+
blockFingerprint: computeBlockFingerprint(block),
|
|
203
|
+
snapshotText: block.getTextContent().slice(0, 300)
|
|
204
|
+
}
|
|
205
|
+
};
|
|
207
206
|
}
|
|
208
207
|
function buildBlockAnchor(editor, blockKey) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return $buildBlockAnchorData(block);
|
|
229
|
-
});
|
|
208
|
+
return editor.read(() => {
|
|
209
|
+
if (blockKey) {
|
|
210
|
+
const node = $getRoot().getChildren().find((c2) => c2.getKey() === blockKey);
|
|
211
|
+
if (!node || !("getChildren" in node)) {
|
|
212
|
+
return { ok: false, error: "not-root-block" };
|
|
213
|
+
}
|
|
214
|
+
return $buildBlockAnchorData(node);
|
|
215
|
+
}
|
|
216
|
+
const selection = $getSelection();
|
|
217
|
+
if (!$isRangeSelection(selection)) {
|
|
218
|
+
return { ok: false, error: "no-selection" };
|
|
219
|
+
}
|
|
220
|
+
const anchorNode = selection.anchor.getNode();
|
|
221
|
+
const block = $getRootBlock(anchorNode);
|
|
222
|
+
if (!block) {
|
|
223
|
+
return { ok: false, error: "not-root-block" };
|
|
224
|
+
}
|
|
225
|
+
return $buildBlockAnchorData(block);
|
|
226
|
+
});
|
|
230
227
|
}
|
|
231
228
|
function buildRangeAnchor(editor) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
});
|
|
229
|
+
return editor.read(() => {
|
|
230
|
+
const selection = $getSelection();
|
|
231
|
+
if (!$isRangeSelection(selection)) {
|
|
232
|
+
return { ok: false, error: "no-selection" };
|
|
233
|
+
}
|
|
234
|
+
if (selection.isCollapsed()) {
|
|
235
|
+
return { ok: false, error: "collapsed" };
|
|
236
|
+
}
|
|
237
|
+
const anchorBlock = $getRootBlock(selection.anchor.getNode());
|
|
238
|
+
const focusBlock = $getRootBlock(selection.focus.getNode());
|
|
239
|
+
if (!anchorBlock || !focusBlock) {
|
|
240
|
+
return { ok: false, error: "not-root-block" };
|
|
241
|
+
}
|
|
242
|
+
if (anchorBlock !== focusBlock) {
|
|
243
|
+
return { ok: false, error: "cross-block" };
|
|
244
|
+
}
|
|
245
|
+
const block = anchorBlock;
|
|
246
|
+
const blockId = $getState(block, blockIdState);
|
|
247
|
+
if (!blockId) {
|
|
248
|
+
return { ok: false, error: "no-block-id" };
|
|
249
|
+
}
|
|
250
|
+
const anchorPoint = $resolveSelectionPoint(selection, "anchor");
|
|
251
|
+
const focusPoint = $resolveSelectionPoint(selection, "focus");
|
|
252
|
+
let startOffset = $getTextOffsetInBlock(block, anchorPoint.node, anchorPoint.offset);
|
|
253
|
+
let endOffset = $getTextOffsetInBlock(block, focusPoint.node, focusPoint.offset);
|
|
254
|
+
if (startOffset > endOffset) {
|
|
255
|
+
[startOffset, endOffset] = [endOffset, startOffset];
|
|
256
|
+
}
|
|
257
|
+
const text = block.getTextContent();
|
|
258
|
+
const quote = text.slice(startOffset, endOffset);
|
|
259
|
+
const prefix = text.slice(Math.max(0, startOffset - 50), startOffset);
|
|
260
|
+
const suffix = text.slice(endOffset, endOffset + 50);
|
|
261
|
+
return {
|
|
262
|
+
ok: true,
|
|
263
|
+
anchor: {
|
|
264
|
+
mode: "range",
|
|
265
|
+
blockId,
|
|
266
|
+
blockType: block.getType(),
|
|
267
|
+
blockFingerprint: computeBlockFingerprint(block),
|
|
268
|
+
snapshotText: text.slice(0, 300),
|
|
269
|
+
quote,
|
|
270
|
+
prefix,
|
|
271
|
+
suffix,
|
|
272
|
+
startOffset,
|
|
273
|
+
endOffset
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
});
|
|
283
277
|
}
|
|
284
|
-
|
|
285
|
-
|
|
278
|
+
export {
|
|
279
|
+
ColorSchemeProvider,
|
|
280
|
+
CorePlugins,
|
|
281
|
+
F as FootnoteDefinitionsProvider,
|
|
282
|
+
L as LinkFavicon,
|
|
283
|
+
N as NestedContentRendererProvider,
|
|
284
|
+
P as PresentDialogProvider,
|
|
285
|
+
RendererConfigProvider,
|
|
286
|
+
RichEditor,
|
|
287
|
+
RichEditorShell,
|
|
288
|
+
articleTheme,
|
|
289
|
+
a as articleVariant,
|
|
290
|
+
buildBlockAnchor,
|
|
291
|
+
buildRangeAnchor,
|
|
292
|
+
commentTheme,
|
|
293
|
+
c as commentVariant,
|
|
294
|
+
d3 as detailsClassNames,
|
|
295
|
+
a2 as detailsStyles,
|
|
296
|
+
editorTheme,
|
|
297
|
+
getVariantClass,
|
|
298
|
+
g2 as gridClassNames,
|
|
299
|
+
b3 as gridStyles,
|
|
300
|
+
k as katexClassNames,
|
|
301
|
+
b2 as katexStyles,
|
|
302
|
+
noteTheme,
|
|
303
|
+
n as noteVariant,
|
|
304
|
+
r as richContent,
|
|
305
|
+
s as semanticClassNames,
|
|
306
|
+
d2 as sharedStyles,
|
|
307
|
+
u2 as useColorScheme,
|
|
308
|
+
u3 as useFootnoteContent,
|
|
309
|
+
b as useFootnoteDefinitions,
|
|
310
|
+
d as useFootnoteDisplayNumber,
|
|
311
|
+
u4 as useNestedContentRenderer,
|
|
312
|
+
p as useOptionalNestedContentRenderer,
|
|
313
|
+
u as usePresentDialog,
|
|
314
|
+
e as useRendererConfig,
|
|
315
|
+
f as useRendererMode,
|
|
316
|
+
g as useVariant,
|
|
317
|
+
vars
|
|
318
|
+
};
|