@haklex/rich-editor 0.1.1 → 0.3.0
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-C55sxsR3.js +267 -0
- package/dist/KaTeXRenderer-CQQT3BMw.js +215 -0
- package/dist/LinkCardRenderer-CigqFwCv.js +45 -0
- package/dist/MermaidPlugin-BrOr-wQi.js +67 -0
- package/dist/RubyRenderer-jOkydJHg.js +15 -0
- package/dist/SubmitShortcutPlugin-DhyVFzoj.js +2186 -0
- package/dist/commands-entry.mjs +54 -74
- package/dist/components/decorators/PollEditDecorator.d.ts +13 -0
- package/dist/components/decorators/PollEditDecorator.d.ts.map +1 -0
- package/dist/components/renderers/PollRenderer.d.ts +3 -0
- package/dist/components/renderers/PollRenderer.d.ts.map +1 -0
- package/dist/config-B5BuLljq.js +1633 -0
- package/dist/config-edit.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/context/PollDataContext.d.ts +11 -0
- package/dist/context/PollDataContext.d.ts.map +1 -0
- package/dist/extractPolls-DO31LNrp.js +116 -0
- package/dist/grid.css-CJCkLTZc.js +44 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +121 -180
- package/dist/katex.css-CIOEOXyd.js +145 -0
- package/dist/node-registry-Dz5OTkh4.js +946 -0
- package/dist/nodes/PollEditNode.d.ts +14 -0
- package/dist/nodes/PollEditNode.d.ts.map +1 -0
- package/dist/nodes/PollNode.d.ts +52 -0
- package/dist/nodes/PollNode.d.ts.map +1 -0
- package/dist/nodes-entry.d.ts +3 -0
- package/dist/nodes-entry.d.ts.map +1 -1
- package/dist/nodes-entry.mjs +5 -50
- package/dist/normalizeSerializedEditorState-B-1wmGzd.js +78 -0
- package/dist/plugins-entry.mjs +3 -28
- package/dist/renderers-entry.mjs +41 -61
- package/dist/rich-editor.css +2 -1
- package/dist/static-entry.d.ts +5 -0
- package/dist/static-entry.d.ts.map +1 -1
- package/dist/static-entry.mjs +16 -66
- package/dist/styles/index.d.ts +2 -0
- package/dist/styles/index.d.ts.map +1 -1
- package/dist/styles/poll-edit.css.d.ts +35 -0
- package/dist/styles/poll-edit.css.d.ts.map +1 -0
- package/dist/styles/poll.css.d.ts +43 -0
- package/dist/styles/poll.css.d.ts.map +1 -0
- package/dist/styles-entry.mjs +3 -21
- package/dist/theme-B5B2EOWM.js +1099 -0
- package/dist/types/poll.d.ts +36 -0
- package/dist/types/poll.d.ts.map +1 -0
- package/dist/types/renderer-config.d.ts +3 -0
- package/dist/types/renderer-config.d.ts.map +1 -1
- package/dist/utils/extractPolls.d.ts +4 -0
- package/dist/utils/extractPolls.d.ts.map +1 -0
- package/package.json +30 -30
- package/dist/AlertQuoteEditNode-sPNf3_7P.js +0 -293
- package/dist/KaTeXRenderer-CQyQzNTJ.js +0 -218
- package/dist/LinkCardRenderer-QmkOlyXb.js +0 -36
- package/dist/MermaidPlugin-DKuGUcCG.js +0 -101
- package/dist/PresentDialogContext-DRroMIoK.js +0 -71
- package/dist/RubyRenderer-CJQmODir.js +0 -14
- package/dist/SubmitShortcutPlugin-D9uKYHda.js +0 -2427
- package/dist/config-Dl3ZkytB.js +0 -1362
- package/dist/grid.css-Md5-Cfx_.js +0 -11
- package/dist/katex.css-Csc-7N7u.js +0 -28
- package/dist/node-registry-CovhHUB6.js +0 -824
- package/dist/normalizeSerializedEditorState-k5G4xSi9.js +0 -85
- package/dist/theme-lEwScxEX.js +0 -1113
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
function LinkCardRenderer({
|
|
3
|
-
url,
|
|
4
|
-
title,
|
|
5
|
-
description,
|
|
6
|
-
favicon,
|
|
7
|
-
image
|
|
8
|
-
}) {
|
|
9
|
-
const displayTitle = title || url;
|
|
10
|
-
return /* @__PURE__ */ jsxs("a", { className: "rich-link-card", href: url, rel: "noopener noreferrer", target: "_blank", children: [
|
|
11
|
-
image && /* @__PURE__ */ jsx("span", { className: "rich-link-card-image", children: /* @__PURE__ */ jsx("img", { alt: "", loading: "lazy", src: image }) }),
|
|
12
|
-
/* @__PURE__ */ jsxs("span", { className: "rich-link-card-content", children: [
|
|
13
|
-
/* @__PURE__ */ jsxs("span", { className: "rich-link-card-title", children: [
|
|
14
|
-
favicon && /* @__PURE__ */ jsx(
|
|
15
|
-
"img",
|
|
16
|
-
{
|
|
17
|
-
alt: "",
|
|
18
|
-
className: "rich-link-card-favicon",
|
|
19
|
-
height: 16,
|
|
20
|
-
src: favicon,
|
|
21
|
-
width: 16,
|
|
22
|
-
onError: (e) => {
|
|
23
|
-
e.target.style.display = "none";
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
),
|
|
27
|
-
displayTitle
|
|
28
|
-
] }),
|
|
29
|
-
description && /* @__PURE__ */ jsx("span", { className: "rich-link-card-description", children: description }),
|
|
30
|
-
/* @__PURE__ */ jsx("span", { className: "rich-link-card-url", children: url })
|
|
31
|
-
] })
|
|
32
|
-
] });
|
|
33
|
-
}
|
|
34
|
-
export {
|
|
35
|
-
LinkCardRenderer as L
|
|
36
|
-
};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
2
|
-
import { createCommand, $insertNodes, COMMAND_PRIORITY_EDITOR } from "lexical";
|
|
3
|
-
import { useEffect } from "react";
|
|
4
|
-
import { $ as $createAlertQuoteEditNode } from "./AlertQuoteEditNode-sPNf3_7P.js";
|
|
5
|
-
import { $ as $createImageNode, w as $createKaTeXInlineNode, x as $createKaTeXBlockNode, b as $createMermaidNode } from "./theme-lEwScxEX.js";
|
|
6
|
-
const INSERT_ALERT_COMMAND = createCommand("INSERT_ALERT");
|
|
7
|
-
function AlertPlugin() {
|
|
8
|
-
const [editor] = useLexicalComposerContext();
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
return editor.registerCommand(
|
|
11
|
-
INSERT_ALERT_COMMAND,
|
|
12
|
-
(alertType) => {
|
|
13
|
-
$insertNodes([$createAlertQuoteEditNode(alertType)]);
|
|
14
|
-
return true;
|
|
15
|
-
},
|
|
16
|
-
COMMAND_PRIORITY_EDITOR
|
|
17
|
-
);
|
|
18
|
-
}, [editor]);
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
const INSERT_IMAGE_COMMAND = createCommand(
|
|
22
|
-
"INSERT_IMAGE_COMMAND"
|
|
23
|
-
);
|
|
24
|
-
function ImagePlugin() {
|
|
25
|
-
const [editor] = useLexicalComposerContext();
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
return editor.registerCommand(
|
|
28
|
-
INSERT_IMAGE_COMMAND,
|
|
29
|
-
(payload) => {
|
|
30
|
-
const imageNode = $createImageNode(payload);
|
|
31
|
-
$insertNodes([imageNode]);
|
|
32
|
-
return true;
|
|
33
|
-
},
|
|
34
|
-
COMMAND_PRIORITY_EDITOR
|
|
35
|
-
);
|
|
36
|
-
}, [editor]);
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
const INSERT_KATEX_INLINE_COMMAND = createCommand(
|
|
40
|
-
"INSERT_KATEX_INLINE"
|
|
41
|
-
);
|
|
42
|
-
const INSERT_KATEX_BLOCK_COMMAND = createCommand("INSERT_KATEX_BLOCK");
|
|
43
|
-
function KaTeXPlugin() {
|
|
44
|
-
const [editor] = useLexicalComposerContext();
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
const unregisterInline = editor.registerCommand(
|
|
47
|
-
INSERT_KATEX_INLINE_COMMAND,
|
|
48
|
-
(equation) => {
|
|
49
|
-
const node = $createKaTeXInlineNode(equation, {
|
|
50
|
-
autoOpenOnMount: !equation.trim()
|
|
51
|
-
});
|
|
52
|
-
$insertNodes([node]);
|
|
53
|
-
return true;
|
|
54
|
-
},
|
|
55
|
-
COMMAND_PRIORITY_EDITOR
|
|
56
|
-
);
|
|
57
|
-
const unregisterBlock = editor.registerCommand(
|
|
58
|
-
INSERT_KATEX_BLOCK_COMMAND,
|
|
59
|
-
(equation) => {
|
|
60
|
-
const node = $createKaTeXBlockNode(equation, {
|
|
61
|
-
autoOpenOnMount: !equation.trim()
|
|
62
|
-
});
|
|
63
|
-
$insertNodes([node]);
|
|
64
|
-
return true;
|
|
65
|
-
},
|
|
66
|
-
COMMAND_PRIORITY_EDITOR
|
|
67
|
-
);
|
|
68
|
-
return () => {
|
|
69
|
-
unregisterInline();
|
|
70
|
-
unregisterBlock();
|
|
71
|
-
};
|
|
72
|
-
}, [editor]);
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
const INSERT_MERMAID_COMMAND = createCommand("INSERT_MERMAID");
|
|
76
|
-
function MermaidPlugin() {
|
|
77
|
-
const [editor] = useLexicalComposerContext();
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
return editor.registerCommand(
|
|
80
|
-
INSERT_MERMAID_COMMAND,
|
|
81
|
-
(diagram) => {
|
|
82
|
-
const node = $createMermaidNode(diagram);
|
|
83
|
-
$insertNodes([node]);
|
|
84
|
-
return true;
|
|
85
|
-
},
|
|
86
|
-
COMMAND_PRIORITY_EDITOR
|
|
87
|
-
);
|
|
88
|
-
}, [editor]);
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
export {
|
|
92
|
-
AlertPlugin as A,
|
|
93
|
-
ImagePlugin as I,
|
|
94
|
-
KaTeXPlugin as K,
|
|
95
|
-
MermaidPlugin as M,
|
|
96
|
-
INSERT_ALERT_COMMAND as a,
|
|
97
|
-
INSERT_IMAGE_COMMAND as b,
|
|
98
|
-
INSERT_KATEX_BLOCK_COMMAND as c,
|
|
99
|
-
INSERT_KATEX_INLINE_COMMAND as d,
|
|
100
|
-
INSERT_MERMAID_COMMAND as e
|
|
101
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Mail, Globe } from "lucide-react";
|
|
3
|
-
import { useState, useEffect, createContext, useMemo, use } from "react";
|
|
4
|
-
import { e as clsx, d as sharedStyles, s as semanticClassNames } from "./katex.css-Csc-7N7u.js";
|
|
5
|
-
import { g as getHostname, p as probeFavicon } from "./normalizeSerializedEditorState-k5G4xSi9.js";
|
|
6
|
-
function LinkFavicon({
|
|
7
|
-
href,
|
|
8
|
-
source,
|
|
9
|
-
noIcon = false,
|
|
10
|
-
className,
|
|
11
|
-
platformIconMap,
|
|
12
|
-
getPlatformFromUrl
|
|
13
|
-
}) {
|
|
14
|
-
const faviconClassName = clsx(
|
|
15
|
-
semanticClassNames.linkFavicon,
|
|
16
|
-
sharedStyles.linkFavicon,
|
|
17
|
-
className
|
|
18
|
-
);
|
|
19
|
-
const [faviconUrl, setFaviconUrl] = useState(null);
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (!href) return;
|
|
22
|
-
const hostname = getHostname(href);
|
|
23
|
-
if (!hostname) return;
|
|
24
|
-
let cancelled = false;
|
|
25
|
-
probeFavicon(hostname).then((url) => {
|
|
26
|
-
if (!cancelled) setFaviconUrl(url);
|
|
27
|
-
});
|
|
28
|
-
return () => {
|
|
29
|
-
cancelled = true;
|
|
30
|
-
};
|
|
31
|
-
}, [href]);
|
|
32
|
-
if (noIcon || !href && !source) return null;
|
|
33
|
-
let platformType = source;
|
|
34
|
-
if (!platformType && href && getPlatformFromUrl) {
|
|
35
|
-
try {
|
|
36
|
-
platformType = getPlatformFromUrl(new URL(href)) ?? void 0;
|
|
37
|
-
} catch {
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (platformType && platformIconMap?.[platformType]) {
|
|
41
|
-
return /* @__PURE__ */ jsx("span", { className: faviconClassName, children: platformIconMap[platformType] });
|
|
42
|
-
}
|
|
43
|
-
if (faviconUrl) {
|
|
44
|
-
return /* @__PURE__ */ jsx("span", { className: faviconClassName, children: /* @__PURE__ */ jsx("img", { alt: "", "aria-hidden": "true", height: 14, src: faviconUrl, width: 14 }) });
|
|
45
|
-
}
|
|
46
|
-
const isMailto = href?.toLowerCase().startsWith("mailto:");
|
|
47
|
-
return /* @__PURE__ */ jsx("span", { className: faviconClassName, children: isMailto ? /* @__PURE__ */ jsx(Mail, { "aria-hidden": true, size: 14 }) : /* @__PURE__ */ jsx(Globe, { "aria-hidden": true, size: 14 }) });
|
|
48
|
-
}
|
|
49
|
-
const ExtraNodesContext = createContext(void 0);
|
|
50
|
-
function ExtraNodesProvider({
|
|
51
|
-
children,
|
|
52
|
-
extraNodes
|
|
53
|
-
}) {
|
|
54
|
-
const value = useMemo(() => extraNodes, [extraNodes]);
|
|
55
|
-
return /* @__PURE__ */ jsx(ExtraNodesContext.Provider, { value, children });
|
|
56
|
-
}
|
|
57
|
-
function useExtraNodes() {
|
|
58
|
-
return use(ExtraNodesContext);
|
|
59
|
-
}
|
|
60
|
-
const PresentDialogContext = createContext(null);
|
|
61
|
-
const PresentDialogProvider = PresentDialogContext.Provider;
|
|
62
|
-
function usePresentDialog() {
|
|
63
|
-
return use(PresentDialogContext);
|
|
64
|
-
}
|
|
65
|
-
export {
|
|
66
|
-
ExtraNodesProvider as E,
|
|
67
|
-
LinkFavicon as L,
|
|
68
|
-
PresentDialogProvider as P,
|
|
69
|
-
usePresentDialog as a,
|
|
70
|
-
useExtraNodes as u
|
|
71
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { e as clsx, d as sharedStyles, s as semanticClassNames } from "./katex.css-Csc-7N7u.js";
|
|
3
|
-
function RubyRenderer({ reading, children }) {
|
|
4
|
-
if (!reading) {
|
|
5
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
6
|
-
}
|
|
7
|
-
return /* @__PURE__ */ jsxs("ruby", { className: clsx(semanticClassNames.ruby, sharedStyles.ruby), children: [
|
|
8
|
-
children,
|
|
9
|
-
/* @__PURE__ */ jsx("rt", { className: clsx(semanticClassNames.rubyRt, sharedStyles.rubyRt), children: reading })
|
|
10
|
-
] });
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
RubyRenderer as R
|
|
14
|
-
};
|