@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.
Files changed (65) hide show
  1. package/dist/AlertQuoteEditNode-C55sxsR3.js +267 -0
  2. package/dist/KaTeXRenderer-CQQT3BMw.js +215 -0
  3. package/dist/LinkCardRenderer-CigqFwCv.js +45 -0
  4. package/dist/MermaidPlugin-BrOr-wQi.js +67 -0
  5. package/dist/RubyRenderer-jOkydJHg.js +15 -0
  6. package/dist/SubmitShortcutPlugin-DhyVFzoj.js +2186 -0
  7. package/dist/commands-entry.mjs +54 -74
  8. package/dist/components/decorators/PollEditDecorator.d.ts +13 -0
  9. package/dist/components/decorators/PollEditDecorator.d.ts.map +1 -0
  10. package/dist/components/renderers/PollRenderer.d.ts +3 -0
  11. package/dist/components/renderers/PollRenderer.d.ts.map +1 -0
  12. package/dist/config-B5BuLljq.js +1633 -0
  13. package/dist/config-edit.d.ts.map +1 -1
  14. package/dist/config.d.ts.map +1 -1
  15. package/dist/context/PollDataContext.d.ts +11 -0
  16. package/dist/context/PollDataContext.d.ts.map +1 -0
  17. package/dist/extractPolls-DO31LNrp.js +116 -0
  18. package/dist/grid.css-CJCkLTZc.js +44 -0
  19. package/dist/index.d.ts +5 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.mjs +121 -180
  22. package/dist/katex.css-CIOEOXyd.js +145 -0
  23. package/dist/node-registry-Dz5OTkh4.js +946 -0
  24. package/dist/nodes/PollEditNode.d.ts +14 -0
  25. package/dist/nodes/PollEditNode.d.ts.map +1 -0
  26. package/dist/nodes/PollNode.d.ts +52 -0
  27. package/dist/nodes/PollNode.d.ts.map +1 -0
  28. package/dist/nodes-entry.d.ts +3 -0
  29. package/dist/nodes-entry.d.ts.map +1 -1
  30. package/dist/nodes-entry.mjs +5 -50
  31. package/dist/normalizeSerializedEditorState-B-1wmGzd.js +78 -0
  32. package/dist/plugins-entry.mjs +3 -28
  33. package/dist/renderers-entry.mjs +41 -61
  34. package/dist/rich-editor.css +2 -1
  35. package/dist/static-entry.d.ts +5 -0
  36. package/dist/static-entry.d.ts.map +1 -1
  37. package/dist/static-entry.mjs +16 -66
  38. package/dist/styles/index.d.ts +2 -0
  39. package/dist/styles/index.d.ts.map +1 -1
  40. package/dist/styles/poll-edit.css.d.ts +35 -0
  41. package/dist/styles/poll-edit.css.d.ts.map +1 -0
  42. package/dist/styles/poll.css.d.ts +43 -0
  43. package/dist/styles/poll.css.d.ts.map +1 -0
  44. package/dist/styles-entry.mjs +3 -21
  45. package/dist/theme-B5B2EOWM.js +1099 -0
  46. package/dist/types/poll.d.ts +36 -0
  47. package/dist/types/poll.d.ts.map +1 -0
  48. package/dist/types/renderer-config.d.ts +3 -0
  49. package/dist/types/renderer-config.d.ts.map +1 -1
  50. package/dist/utils/extractPolls.d.ts +4 -0
  51. package/dist/utils/extractPolls.d.ts.map +1 -0
  52. package/package.json +30 -30
  53. package/dist/AlertQuoteEditNode-sPNf3_7P.js +0 -293
  54. package/dist/KaTeXRenderer-CQyQzNTJ.js +0 -218
  55. package/dist/LinkCardRenderer-QmkOlyXb.js +0 -36
  56. package/dist/MermaidPlugin-DKuGUcCG.js +0 -101
  57. package/dist/PresentDialogContext-DRroMIoK.js +0 -71
  58. package/dist/RubyRenderer-CJQmODir.js +0 -14
  59. package/dist/SubmitShortcutPlugin-D9uKYHda.js +0 -2427
  60. package/dist/config-Dl3ZkytB.js +0 -1362
  61. package/dist/grid.css-Md5-Cfx_.js +0 -11
  62. package/dist/katex.css-Csc-7N7u.js +0 -28
  63. package/dist/node-registry-CovhHUB6.js +0 -824
  64. package/dist/normalizeSerializedEditorState-k5G4xSi9.js +0 -85
  65. package/dist/theme-lEwScxEX.js +0 -1113
@@ -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,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"}
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;AAuBlD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAoBrD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAyC,CAAC"}
@@ -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,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"}
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;AAsBlD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAYlD,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAoBjD,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAqC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ import { PollDataAdapter, PollState } from '../types/poll';
3
+ export interface PollDataProviderProps {
4
+ adapter: PollDataAdapter;
5
+ children: ReactNode;
6
+ initialStates?: Record<string, PollState>;
7
+ }
8
+ export declare function PollDataProvider({ adapter, initialStates, children }: PollDataProviderProps): import("react").JSX.Element;
9
+ export declare function usePollDataAdapter(): PollDataAdapter | null;
10
+ export declare function useInitialPollState(pollId: string): PollState | undefined;
11
+ //# sourceMappingURL=PollDataContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PollDataContext.d.ts","sourceRoot":"","sources":["../../src/context/PollDataContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAYhE,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CAC3C;AAED,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE,qBAAqB,+BAM3F;AAED,wBAAgB,kBAAkB,IAAI,eAAe,GAAG,IAAI,CAE3D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAEzE"}
@@ -0,0 +1,116 @@
1
+ import { l as semanticClassNames, r as clsx, u as sharedStyles } from "./katex.css-CIOEOXyd.js";
2
+ import { n as getHostname, r as probeFavicon } from "./normalizeSerializedEditorState-B-1wmGzd.js";
3
+ import { createContext, use, useEffect, useMemo, useState } from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { Globe, Mail } from "lucide-react";
6
+ //#region src/components/LinkFavicon.tsx
7
+ function LinkFavicon({ href, source, noIcon = false, className, platformIconMap, getPlatformFromUrl }) {
8
+ const faviconClassName = clsx(semanticClassNames.linkFavicon, sharedStyles.linkFavicon, className);
9
+ const [faviconUrl, setFaviconUrl] = useState(null);
10
+ useEffect(() => {
11
+ if (!href) return;
12
+ const hostname = getHostname(href);
13
+ if (!hostname) return;
14
+ let cancelled = false;
15
+ probeFavicon(hostname).then((url) => {
16
+ if (!cancelled) setFaviconUrl(url);
17
+ });
18
+ return () => {
19
+ cancelled = true;
20
+ };
21
+ }, [href]);
22
+ if (noIcon || !href && !source) return null;
23
+ let platformType = source;
24
+ if (!platformType && href && getPlatformFromUrl) try {
25
+ platformType = getPlatformFromUrl(new URL(href)) ?? void 0;
26
+ } catch {}
27
+ if (platformType && platformIconMap?.[platformType]) return /* @__PURE__ */ jsx("span", {
28
+ className: faviconClassName,
29
+ children: platformIconMap[platformType]
30
+ });
31
+ if (faviconUrl) return /* @__PURE__ */ jsx("span", {
32
+ className: faviconClassName,
33
+ children: /* @__PURE__ */ jsx("img", {
34
+ alt: "",
35
+ "aria-hidden": "true",
36
+ height: 14,
37
+ src: faviconUrl,
38
+ width: 14
39
+ })
40
+ });
41
+ const isMailto = href?.toLowerCase().startsWith("mailto:");
42
+ return /* @__PURE__ */ jsx("span", {
43
+ className: faviconClassName,
44
+ children: isMailto ? /* @__PURE__ */ jsx(Mail, {
45
+ "aria-hidden": true,
46
+ size: 14
47
+ }) : /* @__PURE__ */ jsx(Globe, {
48
+ "aria-hidden": true,
49
+ size: 14
50
+ })
51
+ });
52
+ }
53
+ //#endregion
54
+ //#region src/context/ExtraNodesContext.tsx
55
+ var ExtraNodesContext = createContext(void 0);
56
+ function ExtraNodesProvider({ children, extraNodes }) {
57
+ const value = useMemo(() => extraNodes, [extraNodes]);
58
+ return /* @__PURE__ */ jsx(ExtraNodesContext.Provider, {
59
+ value,
60
+ children
61
+ });
62
+ }
63
+ function useExtraNodes() {
64
+ return use(ExtraNodesContext);
65
+ }
66
+ //#endregion
67
+ //#region src/context/PresentDialogContext.tsx
68
+ var PresentDialogContext = createContext(null);
69
+ var PresentDialogProvider = PresentDialogContext.Provider;
70
+ function usePresentDialog() {
71
+ return use(PresentDialogContext);
72
+ }
73
+ //#endregion
74
+ //#region src/utils/extractPolls.ts
75
+ function isPollNode(node) {
76
+ return node.type === "poll";
77
+ }
78
+ function coercePollMetadata(node) {
79
+ if (typeof node.pollId !== "string" || typeof node.question !== "string") return null;
80
+ if (!Array.isArray(node.options)) return null;
81
+ if (node.mode !== "single" && node.mode !== "multiple") return null;
82
+ const options = node.options.filter((option) => !!option && typeof option === "object" && typeof option.id === "string" && typeof option.label === "string").map((option) => ({
83
+ id: option.id,
84
+ label: option.label
85
+ }));
86
+ return {
87
+ pollId: node.pollId,
88
+ question: node.question,
89
+ options,
90
+ mode: node.mode,
91
+ ...typeof node.closeAt === "string" ? { closeAt: node.closeAt } : {},
92
+ ...node.showResults === "always" || node.showResults === "after-vote" || node.showResults === "after-close" ? { showResults: node.showResults } : {}
93
+ };
94
+ }
95
+ function walk(node, out) {
96
+ if (isPollNode(node)) {
97
+ const meta = coercePollMetadata(node);
98
+ if (meta) out.push(meta);
99
+ return;
100
+ }
101
+ const maybe = node;
102
+ if (Array.isArray(maybe.children)) for (const child of maybe.children) walk(child, out);
103
+ if (maybe.content && typeof maybe.content === "object") walkSerializedState(maybe.content, out);
104
+ }
105
+ function walkSerializedState(state, out) {
106
+ const root = state.root;
107
+ if (!root || !Array.isArray(root.children)) return;
108
+ for (const child of root.children) walk(child, out);
109
+ }
110
+ function extractPolls(state) {
111
+ const out = [];
112
+ walkSerializedState(state, out);
113
+ return out;
114
+ }
115
+ //#endregion
116
+ export { useExtraNodes as a, ExtraNodesProvider as i, PresentDialogProvider as n, LinkFavicon as o, usePresentDialog as r, extractPolls as t };
@@ -0,0 +1,44 @@
1
+ import "./katex.css-CIOEOXyd.js";
2
+ //#region src/styles/details.css.ts
3
+ var detailsClassNames = {
4
+ details: "rich-details",
5
+ summary: "rich-details-summary",
6
+ summaryText: "rich-details-summary-text",
7
+ chevron: "rich-details-chevron",
8
+ content: "rich-details-content"
9
+ };
10
+ var detailsStyles = {
11
+ details: "_1o2d5g50",
12
+ summary: "_1o2d5g51",
13
+ summaryText: "_1o2d5g52",
14
+ chevron: "_1o2d5g53",
15
+ content: "_1o2d5g54"
16
+ };
17
+ //#endregion
18
+ //#region src/styles/grid.css.ts
19
+ var gridClassNames = {
20
+ container: "rich-grid-container",
21
+ toolbar: "rich-grid-toolbar",
22
+ toolbarIcon: "rich-grid-toolbar-icon",
23
+ colButton: "rich-grid-col-btn",
24
+ colButtonActive: "rich-grid-col-btn-active",
25
+ toolbarDivider: "rich-grid-toolbar-divider",
26
+ actionButton: "rich-grid-action-btn",
27
+ inner: "rich-grid-inner",
28
+ cell: "rich-grid-cell",
29
+ cellEditable: "rich-grid-cell-editable"
30
+ };
31
+ var gridStyles = {
32
+ container: "_17ihk870",
33
+ toolbar: "_17ihk871",
34
+ toolbarIcon: "_17ihk872",
35
+ colButton: "_17ihk873",
36
+ colButtonActive: "_17ihk874",
37
+ toolbarDivider: "_17ihk875",
38
+ actionButton: "_17ihk876",
39
+ inner: "_17ihk877",
40
+ cell: "_17ihk878",
41
+ cellEditable: "_17ihk879"
42
+ };
43
+ //#endregion
44
+ export { detailsStyles as i, gridStyles as n, detailsClassNames as r, gridClassNames as t };
package/dist/index.d.ts CHANGED
@@ -12,6 +12,8 @@ export type { FootnoteDefinitionsContextValue } from './context/FootnoteDefiniti
12
12
  export { FootnoteDefinitionsProvider, useFootnoteContent, useFootnoteDefinitions, useFootnoteDisplayNumber, } from './context/FootnoteDefinitionsContext';
13
13
  export type { RenderEditorStateFn } from './context/NestedContentRendererContext';
14
14
  export { NestedContentRendererProvider, useNestedContentRenderer, useOptionalNestedContentRenderer, } from './context/NestedContentRendererContext';
15
+ export type { PollDataProviderProps } from './context/PollDataContext';
16
+ export { PollDataProvider, useInitialPollState, usePollDataAdapter, } from './context/PollDataContext';
15
17
  export type { PresentDialogFn, PresentDialogProps } from './context/PresentDialogContext';
16
18
  export { PresentDialogProvider, usePresentDialog } from './context/PresentDialogContext';
17
19
  export type { RendererMode } from './context/RendererConfigContext';
@@ -21,10 +23,12 @@ export { createTextSelectionStore, TextSelectionStoreProvider, useTextSelectionS
21
23
  export { blockIdState } from './plugins/BlockIdPlugin';
22
24
  export * from './styles';
23
25
  export type { RichEditorProps, RichEditorVariant } from './types';
26
+ export type { PollDataAdapter, PollMetadata, PollMode, PollOption, PollRendererProps, PollShowResults, PollState, } from './types/poll';
24
27
  export type { RendererConfig } from './types/renderer-config';
25
28
  export type { AnchorError, AnchorResult, BlockAnchor, CommentAnchor, RangeAnchor, } from './utils/comment-anchor';
26
29
  export { $getRootBlock, $getTextOffsetInBlock, $resolveSelectionPoint, buildBlockAnchor, buildRangeAnchor, } from './utils/comment-anchor';
30
+ export { extractPolls } from './utils/extractPolls';
27
31
  export type { DOMSelectionTarget, TextSelectionSnapshot } from './utils/text-selection';
28
- export { TEXT_SELECTION_HIGHLIGHT_NAME } from './utils/text-selection-constants';
29
32
  export { $captureTextSelection, $captureTextSelectionFromRangeSelection, $restoreTextSelection, createDOMRangeFromTextSelection, findDOMPointByTextOffset, getBlockElementById, getDOMRectFromTextSelection, getTextOffsetFromDOMPoint, } from './utils/text-selection';
33
+ export { TEXT_SELECTION_HIGHLIGHT_NAME } from './utils/text-selection-constants';
30
34
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,YAAY,EAAE,oBAAoB,EAAE,MA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AsB,CAAC;AACpD,YAAY,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,EACL,qBAAqB,EACrB,uCAAuC,EACvC,qBAAqB,EACrB,+BAA+B,EAC/B,wBAAwB,EACxB,mBAAmB,EACnB,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC"}
package/dist/index.mjs CHANGED
@@ -1,192 +1,133 @@
1
- import { h as TextSelectionStoreProvider, 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, T as TextSelectionPlugin } from "./SubmitShortcutPlugin-D9uKYHda.js";
2
- import { $, i, j, k, l, m, n, f, o, p, q, r, s, t, v, w, x, y } from "./SubmitShortcutPlugin-D9uKYHda.js";
3
- import { E as ExtraNodesProvider } from "./PresentDialogContext-DRroMIoK.js";
4
- import { L, P, u, a } from "./PresentDialogContext-DRroMIoK.js";
1
+ import { A as ImageUploadProvider, C as useTextSelectionSnapshot, D as defaultImageUpload, E as ImageUploadPlugin, M as CorePlugins, O as BlockIdPlugin, S as createTextSelectionStore, T as LinkFaviconPlugin, _ as $getTextOffsetInBlock, a as AutoFocusPlugin, b as buildRangeAnchor, c as $captureTextSelectionFromRangeSelection, d as findDOMPointByTextOffset, f as getBlockElementById, g as $getRootBlock, h as TEXT_SELECTION_HIGHLIGHT_NAME, i as EditorRefPlugin, k as blockIdState, l as $restoreTextSelection, m as getTextOffsetFromDOMPoint, n as OnChangePlugin, o as TextSelectionPlugin, p as getDOMRectFromTextSelection, r as FootnotePlugin, s as $captureTextSelection, t as SubmitShortcutPlugin, u as createDOMRangeFromTextSelection, v as $resolveSelectionPoint, w as useTextSelectionStore, x as TextSelectionStoreProvider, y as buildBlockAnchor } from "./SubmitShortcutPlugin-DhyVFzoj.js";
2
+ import { n as setResolvedEditNodes, r as allEditNodes, s as pollEditClasses } from "./node-registry-Dz5OTkh4.js";
3
+ import { F as useNestedContentRenderer, I as useOptionalNestedContentRenderer, P as NestedContentRendererProvider, t as editorTheme } from "./theme-B5B2EOWM.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-CQQT3BMw.js";
5
+ import { a as noteVariant, c as richContent, i as getVariantClass, l as semanticClassNames, n as katexStyles, o as commentVariant, r as clsx, s as articleVariant, t as katexClassNames, u as sharedStyles } from "./katex.css-CIOEOXyd.js";
6
+ import { I as ColorSchemeProvider, L as useColorScheme, _ as usePollDataAdapter, g as useInitialPollState, h as PollDataProvider, m as pollClasses } from "./config-B5BuLljq.js";
7
+ import { i as detailsStyles, n as gridStyles, r as detailsClassNames, t as gridClassNames } from "./grid.css-CJCkLTZc.js";
8
+ import { a as useExtraNodes, i as ExtraNodesProvider, n as PresentDialogProvider, o as LinkFavicon, r as usePresentDialog, t as extractPolls } from "./extractPolls-DO31LNrp.js";
9
+ import { a as KaTeXPlugin, c as AlertPlugin, n as MermaidPlugin, s as ImagePlugin } from "./MermaidPlugin-BrOr-wQi.js";
5
10
  import { jsx, jsxs } from "react/jsx-runtime";
6
- import { s as setResolvedEditNodes, a as allEditNodes } from "./node-registry-CovhHUB6.js";
7
- import { I as ImagePlugin, K as KaTeXPlugin, A as AlertPlugin, M as MermaidPlugin } from "./MermaidPlugin-DKuGUcCG.js";
11
+ import { ContentEditable } from "@lexical/react/LexicalContentEditable";
12
+ import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
13
+ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
8
14
  import { PortalThemeProvider } from "@haklex/rich-style-token";
9
15
  import { LexicalComposer } from "@lexical/react/LexicalComposer";
10
- import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
11
16
  import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
12
- import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
13
- import { n as ColorSchemeProvider } from "./config-Dl3ZkytB.js";
14
- import { u as u2 } from "./config-Dl3ZkytB.js";
15
- import { R as RendererConfigProvider } from "./KaTeXRenderer-CQyQzNTJ.js";
16
- import { F, u as u3, b, d, e, f as f2, g } from "./KaTeXRenderer-CQyQzNTJ.js";
17
- import { n as editorTheme } from "./theme-lEwScxEX.js";
18
- import { N, u as u4, p as p2 } from "./theme-lEwScxEX.js";
19
- import { ContentEditable as ContentEditable$1 } from "@lexical/react/LexicalContentEditable";
20
- import { e as clsx, g as getVariantClass } from "./katex.css-Csc-7N7u.js";
21
- import { a as a2, c, k as k2, b as b2, n as n2, r as r2, s as s2, d as d2 } from "./katex.css-Csc-7N7u.js";
22
- import { d as d3, a as a3, g as g2, b as b3 } from "./grid.css-Md5-Cfx_.js";
23
17
  import { articleTheme, commentTheme, noteTheme, vars } from "@haklex/rich-style-token/styles";
18
+ //#region src/components/ContentEditable.css.ts
24
19
  var contentWrapper = "b94s950";
25
20
  var content = "b94s951";
26
21
  var placeholder = "b94s952";
27
- function ContentEditable({ className, placeholder: placeholder$1, hasHeader }) {
28
- const paddingTop = hasHeader ? 40 : 12;
29
- return /* @__PURE__ */ jsx(
30
- "div",
31
- {
32
- className: clsx("rich-editor__content-wrapper", contentWrapper),
33
- style: { "--ce-padding-top": `${paddingTop}px` },
34
- children: /* @__PURE__ */ jsx(
35
- ContentEditable$1,
36
- {
37
- "aria-placeholder": placeholder$1 ?? "",
38
- className: clsx("rich-editor__content", content, className),
39
- placeholder: /* @__PURE__ */ jsx(
40
- "div",
41
- {
42
- className: clsx("rich-editor__placeholder", placeholder),
43
- style: { display: placeholder$1 ? void 0 : "none" },
44
- children: placeholder$1
45
- }
46
- )
47
- }
48
- )
49
- }
50
- );
22
+ //#endregion
23
+ //#region src/components/ContentEditable.tsx
24
+ function ContentEditable$1({ className, placeholder: placeholder$1, hasHeader }) {
25
+ const paddingTop = hasHeader ? 40 : 12;
26
+ return /* @__PURE__ */ jsx("div", {
27
+ className: clsx("rich-editor__content-wrapper", contentWrapper),
28
+ style: { "--ce-padding-top": `${paddingTop}px` },
29
+ children: /* @__PURE__ */ jsx(ContentEditable, {
30
+ "aria-placeholder": placeholder$1 ?? "",
31
+ className: clsx("rich-editor__content", content, className),
32
+ placeholder: /* @__PURE__ */ jsx("div", {
33
+ className: clsx("rich-editor__placeholder", placeholder),
34
+ style: { display: placeholder$1 ? void 0 : "none" },
35
+ children: placeholder$1
36
+ })
37
+ })
38
+ });
51
39
  }
52
- function RichEditorShell({
53
- nodes,
54
- initialValue,
55
- onChange,
56
- variant = "article",
57
- theme = "light",
58
- placeholder: placeholder2 = "Write something...",
59
- onSubmit,
60
- autoFocus = false,
61
- className,
62
- contentClassName,
63
- style,
64
- actions,
65
- header,
66
- onEditorReady,
67
- rendererConfig,
68
- debounceMs,
69
- children
70
- }) {
71
- setResolvedEditNodes(nodes);
72
- const initialConfig = {
73
- namespace: "RichEditor",
74
- theme: editorTheme,
75
- nodes,
76
- editable: true,
77
- onError: (error) => {
78
- console.error("[RichEditor]", error);
79
- },
80
- ...initialValue ? { editorState: JSON.stringify(initialValue) } : {}
81
- };
82
- const variantClass = getVariantClass(variant);
83
- 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(TextSelectionStoreProvider, { children: /* @__PURE__ */ jsx(FootnotePlugin, { children: /* @__PURE__ */ jsxs(
84
- "div",
85
- {
86
- suppressHydrationWarning: true,
87
- className: clsx("rich-editor", variantClass, className),
88
- "data-theme": theme,
89
- style: { ...style, maxWidth: "none" },
90
- children: [
91
- header,
92
- /* @__PURE__ */ jsx(
93
- RichTextPlugin,
94
- {
95
- ErrorBoundary: LexicalErrorBoundary,
96
- contentEditable: /* @__PURE__ */ jsx(
97
- ContentEditable,
98
- {
99
- className: contentClassName,
100
- hasHeader: !!header,
101
- placeholder: placeholder2
102
- }
103
- )
104
- }
105
- ),
106
- /* @__PURE__ */ jsx(HistoryPlugin, {}),
107
- /* @__PURE__ */ jsx(OnChangePlugin, { debounceMs, onChange }),
108
- /* @__PURE__ */ jsx(SubmitShortcutPlugin, { onSubmit }),
109
- /* @__PURE__ */ jsx(EditorRefPlugin, { onEditorReady }),
110
- autoFocus && /* @__PURE__ */ jsx(AutoFocusPlugin, {}),
111
- children,
112
- actions && /* @__PURE__ */ jsx("div", { className: "rich-editor__actions", children: actions })
113
- ]
114
- }
115
- ) }) }) }) }) }) });
40
+ //#endregion
41
+ //#region src/components/RichEditorShell.tsx
42
+ function RichEditorShell({ nodes, initialValue, onChange, variant = "article", theme = "light", placeholder = "Write something...", onSubmit, autoFocus = false, className, contentClassName, style, actions, header, onEditorReady, rendererConfig, debounceMs, children }) {
43
+ setResolvedEditNodes(nodes);
44
+ const initialConfig = {
45
+ namespace: "RichEditor",
46
+ theme: editorTheme,
47
+ nodes,
48
+ editable: true,
49
+ onError: (error) => {
50
+ console.error("[RichEditor]", error);
51
+ },
52
+ ...initialValue ? { editorState: JSON.stringify(initialValue) } : {}
53
+ };
54
+ const variantClass = getVariantClass(variant);
55
+ return /* @__PURE__ */ jsx(PortalThemeProvider, {
56
+ className: variantClass,
57
+ theme,
58
+ children: /* @__PURE__ */ jsx(ColorSchemeProvider, {
59
+ colorScheme: theme,
60
+ children: /* @__PURE__ */ jsx(RendererConfigProvider, {
61
+ config: rendererConfig,
62
+ mode: "editor",
63
+ variant,
64
+ children: /* @__PURE__ */ jsx(LexicalComposer, {
65
+ initialConfig,
66
+ children: /* @__PURE__ */ jsx(TextSelectionStoreProvider, { children: /* @__PURE__ */ jsx(FootnotePlugin, { children: /* @__PURE__ */ jsxs("div", {
67
+ suppressHydrationWarning: true,
68
+ className: clsx("rich-editor", variantClass, className),
69
+ "data-theme": theme,
70
+ style: {
71
+ ...style,
72
+ maxWidth: "none"
73
+ },
74
+ children: [
75
+ header,
76
+ /* @__PURE__ */ jsx(RichTextPlugin, {
77
+ ErrorBoundary: LexicalErrorBoundary,
78
+ contentEditable: /* @__PURE__ */ jsx(ContentEditable$1, {
79
+ className: contentClassName,
80
+ hasHeader: !!header,
81
+ placeholder
82
+ })
83
+ }),
84
+ /* @__PURE__ */ jsx(HistoryPlugin, {}),
85
+ /* @__PURE__ */ jsx(OnChangePlugin, {
86
+ debounceMs,
87
+ onChange
88
+ }),
89
+ /* @__PURE__ */ jsx(SubmitShortcutPlugin, { onSubmit }),
90
+ /* @__PURE__ */ jsx(EditorRefPlugin, { onEditorReady }),
91
+ autoFocus && /* @__PURE__ */ jsx(AutoFocusPlugin, {}),
92
+ children,
93
+ actions && /* @__PURE__ */ jsx("div", {
94
+ className: "rich-editor__actions",
95
+ children: actions
96
+ })
97
+ ]
98
+ }) }) })
99
+ })
100
+ })
101
+ })
102
+ });
116
103
  }
104
+ //#endregion
105
+ //#region src/components/RichEditor.tsx
117
106
  function RichEditor({ extraNodes, imageUpload, children, ...shellProps }) {
118
- const nodes = extraNodes ? [...allEditNodes, ...extraNodes] : allEditNodes;
119
- const resolvedImageUpload = imageUpload ?? defaultImageUpload;
120
- return /* @__PURE__ */ jsx(ImageUploadProvider, { upload: resolvedImageUpload, children: /* @__PURE__ */ jsx(ExtraNodesProvider, { extraNodes, children: /* @__PURE__ */ jsxs(RichEditorShell, { nodes, ...shellProps, children: [
121
- /* @__PURE__ */ jsx(CorePlugins, {}),
122
- /* @__PURE__ */ jsx(ImagePlugin, {}),
123
- /* @__PURE__ */ jsx(ImageUploadPlugin, { onUpload: resolvedImageUpload }),
124
- /* @__PURE__ */ jsx(KaTeXPlugin, {}),
125
- /* @__PURE__ */ jsx(AlertPlugin, {}),
126
- /* @__PURE__ */ jsx(MermaidPlugin, {}),
127
- /* @__PURE__ */ jsx(LinkFaviconPlugin, {}),
128
- /* @__PURE__ */ jsx(BlockIdPlugin, {}),
129
- /* @__PURE__ */ jsx(TextSelectionPlugin, {}),
130
- children
131
- ] }) }) });
107
+ const nodes = extraNodes ? [...allEditNodes, ...extraNodes] : allEditNodes;
108
+ const resolvedImageUpload = imageUpload ?? defaultImageUpload;
109
+ return /* @__PURE__ */ jsx(ImageUploadProvider, {
110
+ upload: resolvedImageUpload,
111
+ children: /* @__PURE__ */ jsx(ExtraNodesProvider, {
112
+ extraNodes,
113
+ children: /* @__PURE__ */ jsxs(RichEditorShell, {
114
+ nodes,
115
+ ...shellProps,
116
+ children: [
117
+ /* @__PURE__ */ jsx(CorePlugins, {}),
118
+ /* @__PURE__ */ jsx(ImagePlugin, {}),
119
+ /* @__PURE__ */ jsx(ImageUploadPlugin, { onUpload: resolvedImageUpload }),
120
+ /* @__PURE__ */ jsx(KaTeXPlugin, {}),
121
+ /* @__PURE__ */ jsx(AlertPlugin, {}),
122
+ /* @__PURE__ */ jsx(MermaidPlugin, {}),
123
+ /* @__PURE__ */ jsx(LinkFaviconPlugin, {}),
124
+ /* @__PURE__ */ jsx(BlockIdPlugin, {}),
125
+ /* @__PURE__ */ jsx(TextSelectionPlugin, {}),
126
+ children
127
+ ]
128
+ })
129
+ })
130
+ });
132
131
  }
133
- export {
134
- $ as $captureTextSelection,
135
- i as $captureTextSelectionFromRangeSelection,
136
- j as $getRootBlock,
137
- k as $getTextOffsetInBlock,
138
- l as $resolveSelectionPoint,
139
- m as $restoreTextSelection,
140
- ColorSchemeProvider,
141
- CorePlugins,
142
- ExtraNodesProvider,
143
- F as FootnoteDefinitionsProvider,
144
- L as LinkFavicon,
145
- N as NestedContentRendererProvider,
146
- P as PresentDialogProvider,
147
- RendererConfigProvider,
148
- RichEditor,
149
- RichEditorShell,
150
- n as TEXT_SELECTION_HIGHLIGHT_NAME,
151
- TextSelectionStoreProvider,
152
- articleTheme,
153
- a2 as articleVariant,
154
- f as blockIdState,
155
- o as buildBlockAnchor,
156
- p as buildRangeAnchor,
157
- commentTheme,
158
- c as commentVariant,
159
- q as createDOMRangeFromTextSelection,
160
- r as createTextSelectionStore,
161
- d3 as detailsClassNames,
162
- a3 as detailsStyles,
163
- editorTheme,
164
- s as findDOMPointByTextOffset,
165
- t as getBlockElementById,
166
- v as getDOMRectFromTextSelection,
167
- w as getTextOffsetFromDOMPoint,
168
- getVariantClass,
169
- g2 as gridClassNames,
170
- b3 as gridStyles,
171
- k2 as katexClassNames,
172
- b2 as katexStyles,
173
- noteTheme,
174
- n2 as noteVariant,
175
- r2 as richContent,
176
- s2 as semanticClassNames,
177
- d2 as sharedStyles,
178
- u2 as useColorScheme,
179
- u as useExtraNodes,
180
- u3 as useFootnoteContent,
181
- b as useFootnoteDefinitions,
182
- d as useFootnoteDisplayNumber,
183
- u4 as useNestedContentRenderer,
184
- p2 as useOptionalNestedContentRenderer,
185
- a as usePresentDialog,
186
- e as useRendererConfig,
187
- f2 as useRendererMode,
188
- x as useTextSelectionSnapshot,
189
- y as useTextSelectionStore,
190
- g as useVariant,
191
- vars
192
- };
132
+ //#endregion
133
+ export { $captureTextSelection, $captureTextSelectionFromRangeSelection, $getRootBlock, $getTextOffsetInBlock, $resolveSelectionPoint, $restoreTextSelection, ColorSchemeProvider, CorePlugins, ExtraNodesProvider, FootnoteDefinitionsProvider, LinkFavicon, NestedContentRendererProvider, PollDataProvider, PresentDialogProvider, RendererConfigProvider, RichEditor, RichEditorShell, TEXT_SELECTION_HIGHLIGHT_NAME, TextSelectionStoreProvider, articleTheme, articleVariant, blockIdState, buildBlockAnchor, buildRangeAnchor, commentTheme, commentVariant, createDOMRangeFromTextSelection, createTextSelectionStore, detailsClassNames, detailsStyles, editorTheme, extractPolls, findDOMPointByTextOffset, getBlockElementById, getDOMRectFromTextSelection, getTextOffsetFromDOMPoint, getVariantClass, gridClassNames, gridStyles, katexClassNames, katexStyles, noteTheme, noteVariant, pollClasses, pollEditClasses, richContent, semanticClassNames, sharedStyles, useColorScheme, useExtraNodes, useFootnoteContent, useFootnoteDefinitions, useFootnoteDisplayNumber, useInitialPollState, useNestedContentRenderer, useOptionalNestedContentRenderer, usePollDataAdapter, usePresentDialog, useRendererConfig, useRendererMode, useTextSelectionSnapshot, useTextSelectionStore, useVariant, vars };