@haklex/rich-editor 0.0.65 → 0.0.66
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/README.md +107 -300
- package/dist/AlertQuoteEditNode-AgVEMFEi.js +292 -0
- package/dist/KaTeXRenderer-C8jv_5xr.js +214 -0
- package/dist/LinkCardRenderer-QmkOlyXb.js +36 -0
- package/dist/{LinkFavicon-DpURZdO_.js → LinkFavicon-B9SOaYCR.js} +5 -24
- package/dist/MermaidPlugin-CIQbyjXF.js +97 -0
- package/dist/RubyRenderer-DbeobSoH.js +13 -0
- package/dist/SubmitShortcutPlugin-WQpet-vq.js +1512 -0
- package/dist/commands-entry.d.ts +9 -0
- package/dist/commands-entry.d.ts.map +1 -0
- package/dist/commands-entry.mjs +25 -0
- package/dist/components/ContentEditable.d.ts +2 -2
- package/dist/components/ContentEditable.d.ts.map +1 -1
- package/dist/components/CorePlugins.d.ts +2 -0
- package/dist/components/CorePlugins.d.ts.map +1 -0
- package/dist/components/LinkFavicon.d.ts.map +1 -1
- package/dist/components/RichEditor.d.ts +1 -1
- package/dist/components/RichEditor.d.ts.map +1 -1
- package/dist/components/RichEditorShell.d.ts +26 -0
- package/dist/components/RichEditorShell.d.ts.map +1 -0
- package/dist/components/decorators/AlertEditDecorator.d.ts +2 -2
- package/dist/components/decorators/AlertEditDecorator.d.ts.map +1 -1
- package/dist/components/decorators/BannerEditDecorator.d.ts +1 -1
- package/dist/components/decorators/BannerEditDecorator.d.ts.map +1 -1
- package/dist/components/decorators/CodeBlockEditDecorator.d.ts +2 -2
- package/dist/components/decorators/CodeBlockEditDecorator.d.ts.map +1 -1
- package/dist/components/decorators/GridEditDecorator.d.ts +2 -2
- package/dist/components/decorators/GridEditDecorator.d.ts.map +1 -1
- package/dist/components/renderers/AlertRenderer.d.ts +1 -1
- package/dist/components/renderers/AlertRenderer.d.ts.map +1 -1
- package/dist/components/renderers/AlertStaticDecorator.d.ts +1 -1
- package/dist/components/renderers/AlertStaticDecorator.d.ts.map +1 -1
- package/dist/components/renderers/BannerRenderer.d.ts +1 -1
- package/dist/components/renderers/BannerRenderer.d.ts.map +1 -1
- package/dist/components/renderers/BannerStaticDecorator.d.ts +1 -1
- package/dist/components/renderers/BannerStaticDecorator.d.ts.map +1 -1
- package/dist/components/renderers/CodeBlockRenderer.d.ts +5 -5
- package/dist/components/renderers/CodeBlockRenderer.d.ts.map +1 -1
- package/dist/components/renderers/FootnoteRenderer.d.ts.map +1 -1
- package/dist/components/renderers/FootnoteSectionEditRenderer.d.ts +1 -1
- package/dist/components/renderers/FootnoteSectionEditRenderer.d.ts.map +1 -1
- package/dist/components/renderers/FootnoteSectionRenderer.d.ts +1 -1
- package/dist/components/renderers/FootnoteSectionRenderer.d.ts.map +1 -1
- package/dist/components/renderers/FootnoteStaticRenderer.d.ts +1 -1
- package/dist/components/renderers/FootnoteStaticRenderer.d.ts.map +1 -1
- package/dist/components/renderers/GridStaticDecorator.d.ts +2 -2
- package/dist/components/renderers/GridStaticDecorator.d.ts.map +1 -1
- package/dist/components/renderers/ImageRenderer.d.ts +4 -4
- package/dist/components/renderers/ImageRenderer.d.ts.map +1 -1
- package/dist/components/renderers/KaTeXRenderer.d.ts +1 -1
- package/dist/components/renderers/KaTeXRenderer.d.ts.map +1 -1
- package/dist/components/renderers/LinkCardRenderer.d.ts +4 -4
- package/dist/components/renderers/LinkCardRenderer.d.ts.map +1 -1
- package/dist/components/renderers/MentionRenderer.d.ts +2 -2
- package/dist/components/renderers/MentionRenderer.d.ts.map +1 -1
- package/dist/components/renderers/RubyRenderer.d.ts +1 -1
- package/dist/components/renderers/RubyRenderer.d.ts.map +1 -1
- package/dist/components/renderers/VideoRenderer.d.ts +3 -3
- package/dist/components/renderers/VideoRenderer.d.ts.map +1 -1
- package/dist/config-QGdXDSW9.js +1235 -0
- package/dist/context/ImageUploadContext.d.ts.map +1 -1
- package/dist/context/RendererConfigContext.d.ts +1 -1
- package/dist/context/RendererConfigContext.d.ts.map +1 -1
- package/dist/favicon-BQgbXF_a.js +43 -0
- package/dist/index.d.ts +10 -80
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +151 -161
- package/dist/node-registry-CSRSWJ0q.js +765 -0
- package/dist/nodes/CodeBlockEditNode.d.ts +6 -6
- package/dist/nodes/DetailsNode.d.ts.map +1 -1
- package/dist/nodes/GridContainerNode.d.ts.map +1 -1
- package/dist/nodes/GridEditNode.d.ts.map +1 -1
- package/dist/nodes/ImageNode.d.ts +4 -4
- package/dist/nodes/ImageNode.d.ts.map +1 -1
- package/dist/nodes/LinkCardNode.d.ts +4 -4
- package/dist/nodes/LinkCardNode.d.ts.map +1 -1
- package/dist/nodes/VideoNode.d.ts +2 -2
- package/dist/nodes/VideoNode.d.ts.map +1 -1
- package/dist/nodes-entry.d.ts +28 -0
- package/dist/nodes-entry.d.ts.map +1 -0
- package/dist/nodes-entry.mjs +44 -0
- package/dist/plugins/AutoLinkPlugin.d.ts.map +1 -1
- package/dist/plugins/ImageUploadPlugin.d.ts +2 -2
- package/dist/plugins/ImageUploadPlugin.d.ts.map +1 -1
- package/dist/plugins/MarkdownPastePlugin.d.ts.map +1 -1
- package/dist/plugins/OnChangePlugin.d.ts +1 -1
- package/dist/plugins/OnChangePlugin.d.ts.map +1 -1
- package/dist/plugins/image-upload-command.d.ts.map +1 -1
- package/dist/plugins/image-upload.css.d.ts +1 -4
- package/dist/plugins/image-upload.css.d.ts.map +1 -1
- package/dist/plugins-entry.d.ts +22 -0
- package/dist/plugins-entry.d.ts.map +1 -0
- package/dist/plugins-entry.mjs +27 -0
- package/dist/renderers-entry.d.ts +23 -0
- package/dist/renderers-entry.d.ts.map +1 -0
- package/dist/renderers-entry.mjs +60 -0
- package/dist/rich-editor.css +1 -1
- package/dist/{utils-fpeaZV1R.js → shared.css-DNuMYx6Q.js} +4 -1
- package/dist/static-entry.mjs +23 -21
- package/dist/styles/article.css.d.ts.map +1 -1
- package/dist/styles-entry.mjs +1 -2
- package/dist/theme-CRza9nbF.js +924 -0
- package/dist/transformers/code-block.d.ts.map +1 -1
- package/dist/types/renderer-config.d.ts +6 -6
- package/dist/types/renderer-config.d.ts.map +1 -1
- package/dist/types/slash-menu.d.ts +6 -6
- package/dist/types/slash-menu.d.ts.map +1 -1
- package/dist/types.d.ts +18 -13
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/comment-anchor.d.ts +8 -8
- package/dist/utils/comment-anchor.d.ts.map +1 -1
- package/package.json +50 -33
- package/dist/RichEditor-EI3rR1-9.js +0 -2789
- package/dist/components/decorators/nested-doc-dialog.css.d.ts +0 -28
- package/dist/components/decorators/nested-doc-dialog.css.d.ts.map +0 -1
- package/dist/editor.d.ts +0 -6
- package/dist/editor.d.ts.map +0 -1
- package/dist/editor.mjs +0 -12
- package/dist/favicon-C6Esc0tp.js +0 -2470
- package/dist/shared.css-BqX4HjVE.js +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageUploadContext.d.ts","sourceRoot":"","sources":["../../src/context/ImageUploadContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"ImageUploadContext.d.ts","sourceRoot":"","sources":["../../src/context/ImageUploadContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAIlE,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,EACN,QAAQ,GACT,EAAE;IACD,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB,+BAEA;AAED,wBAAgB,cAAc,IAAI,aAAa,GAAG,IAAI,CAErD"}
|
|
@@ -3,10 +3,10 @@ import { RichEditorVariant } from '../types';
|
|
|
3
3
|
import { RendererConfig } from '../types/renderer-config';
|
|
4
4
|
export type RendererMode = 'editor' | 'renderer';
|
|
5
5
|
export interface RendererConfigProviderProps {
|
|
6
|
+
children: ReactNode;
|
|
6
7
|
config?: RendererConfig;
|
|
7
8
|
mode: RendererMode;
|
|
8
9
|
variant: RichEditorVariant;
|
|
9
|
-
children: ReactNode;
|
|
10
10
|
}
|
|
11
11
|
export declare function RendererConfigProvider({ config, mode, variant, children, }: RendererConfigProviderProps): import("react").JSX.Element;
|
|
12
12
|
export declare function useRendererConfig(): RendererConfig | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RendererConfigContext.d.ts","sourceRoot":"","sources":["../../src/context/RendererConfigContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"RendererConfigContext.d.ts","sourceRoot":"","sources":["../../src/context/RendererConfigContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,UAAU,CAAC;AAcjD,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,iBAAiB,CAAC;CAC5B;AAED,wBAAgB,sBAAsB,CAAC,EACrC,MAAM,EACN,IAAI,EACJ,OAAO,EACP,QAAQ,GACT,EAAE,2BAA2B,+BAG7B;AAED,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,SAAS,CAE9D;AAED,wBAAgB,eAAe,IAAI,YAAY,CAE9C;AAED,wBAAgB,UAAU,IAAI,iBAAiB,CAE9C"}
|
|
@@ -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
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,91 +1,21 @@
|
|
|
1
|
+
export { CorePlugins } from './components/CorePlugins';
|
|
2
|
+
export type { LinkFaviconProps } from './components/LinkFavicon';
|
|
3
|
+
export { LinkFavicon } from './components/LinkFavicon';
|
|
1
4
|
export { RichEditor } from './components/RichEditor';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
5
|
+
export type { RichEditorShellProps } from './components/RichEditorShell';
|
|
6
|
+
export { RichEditorShell } from './components/RichEditorShell';
|
|
7
|
+
export { getVariantClass } from './components/utils';
|
|
4
8
|
export type { ColorScheme } from './context/ColorSchemeContext';
|
|
5
|
-
export { ColorSchemeProvider, useColorScheme
|
|
9
|
+
export { ColorSchemeProvider, useColorScheme } from './context/ColorSchemeContext';
|
|
6
10
|
export type { FootnoteDefinitionsContextValue } from './context/FootnoteDefinitionsContext';
|
|
7
11
|
export { FootnoteDefinitionsProvider, useFootnoteContent, useFootnoteDefinitions, useFootnoteDisplayNumber, } from './context/FootnoteDefinitionsContext';
|
|
8
|
-
export {
|
|
12
|
+
export type { RenderEditorStateFn } from './context/NestedContentRendererContext';
|
|
13
|
+
export { NestedContentRendererProvider, useNestedContentRenderer, useOptionalNestedContentRenderer, } from './context/NestedContentRendererContext';
|
|
9
14
|
export type { RendererMode } from './context/RendererConfigContext';
|
|
10
|
-
export { useRendererMode, useVariant } from './context/RendererConfigContext';
|
|
15
|
+
export { RendererConfigProvider, useRendererConfig, useRendererMode, useVariant, } from './context/RendererConfigContext';
|
|
11
16
|
export * from './styles';
|
|
12
|
-
export { ALL_TRANSFORMERS } from './transformers';
|
|
13
17
|
export type { RichEditorProps, RichEditorVariant } from './types';
|
|
14
18
|
export type { RendererConfig } from './types/renderer-config';
|
|
15
|
-
export type { CommandItemConfig, CommandPlacement, SlashMenuItemConfig, ToolbarGroup, } from './types/slash-menu';
|
|
16
|
-
export { createRendererDecoration } from './components/RendererWrapper';
|
|
17
|
-
export { getVariantClass } from './components/utils';
|
|
18
|
-
export { useRendererConfig } from './context/RendererConfigContext';
|
|
19
|
-
export { getResolvedEditNodes, setResolvedEditNodes } from './node-registry';
|
|
20
|
-
export { NESTED_EDITOR_NODES } from './nodes/shared';
|
|
21
|
-
export type { SerializedMermaidNode } from './nodes/MermaidNode';
|
|
22
|
-
export { $createMermaidNode, $isMermaidNode, MermaidNode, } from './nodes/MermaidNode';
|
|
23
|
-
export type { SerializedRubyNode } from './nodes/RubyNode';
|
|
24
|
-
export { $createRubyNode, $isRubyNode, RubyNode } from './nodes/RubyNode';
|
|
25
|
-
export type { AlertType } from './nodes/AlertQuoteNode';
|
|
26
|
-
export { ALERT_LABELS, ALERT_TYPES } from './nodes/AlertQuoteNode';
|
|
27
|
-
export { AutoLinkPlugin } from './plugins/AutoLinkPlugin';
|
|
28
|
-
export { BlockExitPlugin } from './plugins/BlockExitPlugin';
|
|
29
|
-
export { HorizontalRulePlugin } from './plugins/HorizontalRulePlugin';
|
|
30
|
-
export { ImagePlugin } from './plugins/ImagePlugin';
|
|
31
|
-
export { ImageUploadPlugin } from './plugins/ImageUploadPlugin';
|
|
32
|
-
export { KaTeXPlugin } from './plugins/KaTeXPlugin';
|
|
33
|
-
export { LinkFaviconPlugin } from './plugins/LinkFaviconPlugin';
|
|
34
|
-
export { MarkdownShortcutsPlugin } from './plugins/MarkdownShortcutsPlugin';
|
|
35
|
-
export { MermaidPlugin } from './plugins/MermaidPlugin';
|
|
36
|
-
export { INSERT_ALERT_COMMAND } from './plugins/AlertPlugin';
|
|
37
|
-
export { FootnotePlugin } from './plugins/FootnotePlugin';
|
|
38
|
-
export { OPEN_IMAGE_UPLOAD_DIALOG_COMMAND } from './plugins/image-upload-command';
|
|
39
|
-
export { INSERT_IMAGE_COMMAND } from './plugins/ImagePlugin';
|
|
40
|
-
export { defaultImageUpload, type ImageUploadFn, type ImageUploadResult, } from './plugins/ImageUploadPlugin';
|
|
41
|
-
export { INSERT_KATEX_BLOCK_COMMAND, INSERT_KATEX_INLINE_COMMAND, } from './plugins/KaTeXPlugin';
|
|
42
|
-
export { INSERT_MERMAID_COMMAND } from './plugins/MermaidPlugin';
|
|
43
|
-
export type { BannerType } from './nodes/BannerNode';
|
|
44
|
-
export { BANNER_LABELS, BANNER_TYPES } from './nodes/BannerNode';
|
|
45
|
-
export type { SerializedGridContainerNode } from './nodes/GridContainerNode';
|
|
46
|
-
export { $createGridContainerNode, $isGridContainerNode, GridContainerNode, } from './nodes/GridContainerNode';
|
|
47
|
-
export { FootnoteSectionEditNode } from './nodes/FootnoteSectionEditNode';
|
|
48
|
-
export type { SerializedFootnoteSectionNode } from './nodes/FootnoteSectionNode';
|
|
49
|
-
export { $createFootnoteSectionNode, $isFootnoteSectionNode, FootnoteSectionNode, } from './nodes/FootnoteSectionNode';
|
|
50
|
-
export type { ImageNodePayload, SerializedImageNode } from './nodes/ImageNode';
|
|
51
|
-
export { $createImageNode, $isImageNode, ImageNode } from './nodes/ImageNode';
|
|
52
|
-
export type { AlertRendererProps } from './components/renderers/AlertRenderer';
|
|
53
|
-
export type { BannerRendererProps } from './components/renderers/BannerRenderer';
|
|
54
|
-
export type { CodeBlockRendererProps } from './components/renderers/CodeBlockRenderer';
|
|
55
|
-
export type { FootnoteRendererProps } from './components/renderers/FootnoteRenderer';
|
|
56
|
-
export { FootnoteRenderer } from './components/renderers/FootnoteRenderer';
|
|
57
|
-
export type { FootnoteSectionRendererProps } from './components/renderers/FootnoteSectionRenderer';
|
|
58
|
-
export type { ImageRendererProps } from './components/renderers/ImageRenderer';
|
|
59
|
-
export type { KaTeXRendererProps } from './components/renderers/KaTeXRenderer';
|
|
60
|
-
export type { LinkCardRendererProps } from './components/renderers/LinkCardRenderer';
|
|
61
|
-
export type { MentionRendererProps } from './components/renderers/MentionRenderer';
|
|
62
|
-
export type { MermaidRendererProps } from './components/renderers/MermaidRenderer';
|
|
63
|
-
export type { RubyRendererProps } from './components/renderers/RubyRenderer';
|
|
64
|
-
export type { VideoRendererProps } from './components/renderers/VideoRenderer';
|
|
65
|
-
export type { SerializedMentionNode } from './nodes/MentionNode';
|
|
66
|
-
export { $createMentionNode, $isMentionNode, MentionNode, } from './nodes/MentionNode';
|
|
67
|
-
export type { GalleryRendererProps } from './types/renderer-config';
|
|
68
|
-
export type { GalleryImage } from './types/renderer-config';
|
|
69
|
-
export type { CodeFile, CodeSnippetRendererProps, } from './types/renderer-config';
|
|
70
|
-
export { LinkCardRenderer } from './components/renderers/LinkCardRenderer';
|
|
71
|
-
export type { LinkCardNodePayload, SerializedLinkCardNode, } from './nodes/LinkCardNode';
|
|
72
|
-
export { $createLinkCardNode, $isLinkCardNode, LinkCardNode, } from './nodes/LinkCardNode';
|
|
73
|
-
export { KaTeXRenderer } from './components/renderers/KaTeXRenderer';
|
|
74
|
-
export { RubyRenderer } from './components/renderers/RubyRenderer';
|
|
75
|
-
export type { SerializedKaTeXBlockNode } from './nodes/KaTeXBlockNode';
|
|
76
|
-
export { $isKaTeXBlockNode, KaTeXBlockNode } from './nodes/KaTeXBlockNode';
|
|
77
|
-
export type { SerializedKaTeXInlineNode } from './nodes/KaTeXInlineNode';
|
|
78
|
-
export { $isKaTeXInlineNode, KaTeXInlineNode } from './nodes/KaTeXInlineNode';
|
|
79
|
-
export { computeImageMeta, decodeThumbHash } from './utils/thumbhash';
|
|
80
|
-
export type { RenderEditorStateFn } from './context/NestedContentRendererContext';
|
|
81
|
-
export { NestedContentRendererProvider, useNestedContentRenderer, useOptionalNestedContentRenderer, } from './context/NestedContentRendererContext';
|
|
82
|
-
export type { FootnoteStaticRendererProps } from './components/renderers/FootnoteStaticRenderer';
|
|
83
|
-
export { FootnoteStaticRenderer } from './components/renderers/FootnoteStaticRenderer';
|
|
84
|
-
export { collectCommandItems } from './utils/collect-command-items';
|
|
85
|
-
export { extractTextContent } from './utils/extractTextContent';
|
|
86
|
-
export type { LinkFaviconProps } from './components/LinkFavicon';
|
|
87
|
-
export { LinkFavicon } from './components/LinkFavicon';
|
|
88
|
-
export { blockIdState } from './plugins/BlockIdPlugin';
|
|
89
19
|
export type { AnchorError, AnchorResult, BlockAnchor, CommentAnchor, RangeAnchor, } from './utils/comment-anchor';
|
|
90
20
|
export { buildBlockAnchor, buildRangeAnchor } from './utils/comment-anchor';
|
|
91
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
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,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,YAAY,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnF,YAAY,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAC5F,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,sCAAsC,CAAC;AAC9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EACL,6BAA6B,EAC7B,wBAAwB,EACxB,gCAAgC,GACjC,MAAM,wCAAwC,CAAC;AAChD,YAAY,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,UAAU,GACX,MAAM,iCAAiC,CAAC;AACzC,cAAc,UAAU,CAAC;AACzB,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAClE,YAAY,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,YAAY,EACV,WAAW,EACX,YAAY,EACZ,WAAW,EACX,aAAa,EACb,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,76 +1,139 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { h as useFootnoteContent, j as useFootnoteDisplayNumber } from "./favicon-C6Esc0tp.js";
|
|
4
|
-
import { $, r, s as s2, t, v, w, x, y, z, A as A2, B as B2, D, E, G, H as H2, I as I2, J, K as K2, L as L2, M as M2, C, F as F2, O, P, Q, S, T, U, V, W, X, Y, Z, N as N2, _, a0, a as a2, b, a1, e as e2, c as c2, a2 as a22, f as f2, g as g2, u as u2, i as i2, k as k2, l as l2, m as m2, n as n2, o } from "./favicon-C6Esc0tp.js";
|
|
5
|
-
import { a as a3, c as c3, g as g3, n as n3 } from "./utils-fpeaZV1R.js";
|
|
6
|
-
import { r as r2 } from "./shared.css-BqX4HjVE.js";
|
|
7
|
-
import { articleTheme, commentTheme, noteTheme, vars } from "@haklex/rich-style-token/styles";
|
|
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-WQpet-vq.js";
|
|
2
|
+
import { L } from "./LinkFavicon-B9SOaYCR.js";
|
|
8
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
4
|
+
import { s as setResolvedEditNodes, a as allEditNodes } from "./node-registry-CSRSWJ0q.js";
|
|
5
|
+
import { I as ImagePlugin, K as KaTeXPlugin, A as AlertPlugin, M as MermaidPlugin } from "./MermaidPlugin-CIQbyjXF.js";
|
|
6
|
+
import { PortalThemeProvider } from "@haklex/rich-style-token";
|
|
7
|
+
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
8
|
+
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
9
|
+
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
10
|
+
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
11
|
+
import { C as ColorSchemeProvider } from "./config-QGdXDSW9.js";
|
|
12
|
+
import { u } from "./config-QGdXDSW9.js";
|
|
13
|
+
import { R as RendererConfigProvider } from "./KaTeXRenderer-C8jv_5xr.js";
|
|
14
|
+
import { F, u as u2, b, d, e, f, g } from "./KaTeXRenderer-C8jv_5xr.js";
|
|
15
|
+
import { e as editorTheme } from "./theme-CRza9nbF.js";
|
|
16
|
+
import { N, u as u3, b as b2 } from "./theme-CRza9nbF.js";
|
|
17
|
+
import { ContentEditable as ContentEditable$1 } from "@lexical/react/LexicalContentEditable";
|
|
18
|
+
/* empty css */
|
|
19
|
+
import { b as clsx, g as getVariantClass } from "./shared.css-DNuMYx6Q.js";
|
|
20
|
+
import { a, c, n, r } from "./shared.css-DNuMYx6Q.js";
|
|
21
|
+
import { articleTheme, commentTheme, noteTheme, vars } from "@haklex/rich-style-token/styles";
|
|
12
22
|
import { $getRoot, $getSelection, $isRangeSelection, $getState, $isElementNode, $isTextNode, $isLineBreakNode } from "lexical";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
var contentWrapper = "b94s950";
|
|
24
|
+
var content = "b94s951";
|
|
25
|
+
var placeholder = "b94s952";
|
|
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
|
+
}
|
|
30
49
|
);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
50
|
+
}
|
|
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,
|
|
38
93
|
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
94
|
+
ErrorBoundary: LexicalErrorBoundary,
|
|
95
|
+
contentEditable: /* @__PURE__ */ jsx(
|
|
96
|
+
ContentEditable,
|
|
97
|
+
{
|
|
98
|
+
className: contentClassName,
|
|
99
|
+
hasHeader: !!header,
|
|
100
|
+
placeholder: placeholder2
|
|
101
|
+
}
|
|
102
|
+
)
|
|
48
103
|
}
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
for (const { klass } of nodes.values()) {
|
|
59
|
-
const configs = klass.commandItems ?? klass.slashMenuItems;
|
|
60
|
-
if (configs) {
|
|
61
|
-
for (const config of configs) {
|
|
62
|
-
items.push(config);
|
|
63
|
-
}
|
|
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
|
+
]
|
|
64
113
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
114
|
+
) }) }) }) }) });
|
|
115
|
+
}
|
|
116
|
+
function RichEditor({ extraNodes, imageUpload, children, ...shellProps }) {
|
|
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
|
+
] }) });
|
|
67
130
|
}
|
|
68
131
|
function computeBlockFingerprint(block) {
|
|
69
132
|
const text = block.getTextContent();
|
|
70
133
|
const input = text.slice(0, 200) + String(text.length);
|
|
71
134
|
let hash = 5381;
|
|
72
|
-
for (let
|
|
73
|
-
hash = (hash << 5) + hash + (input.codePointAt(
|
|
135
|
+
for (let i = 0; i < input.length; i++) {
|
|
136
|
+
hash = (hash << 5) + hash + (input.codePointAt(i) ?? 0) | 0;
|
|
74
137
|
}
|
|
75
138
|
return (hash >>> 0).toString(16);
|
|
76
139
|
}
|
|
@@ -144,7 +207,7 @@ function $buildBlockAnchorData(block) {
|
|
|
144
207
|
function buildBlockAnchor(editor, blockKey) {
|
|
145
208
|
return editor.read(() => {
|
|
146
209
|
if (blockKey) {
|
|
147
|
-
const node = $getRoot().getChildren().find((
|
|
210
|
+
const node = $getRoot().getChildren().find((c2) => c2.getKey() === blockKey);
|
|
148
211
|
if (!node || !("getChildren" in node)) {
|
|
149
212
|
return { ok: false, error: "not-root-block" };
|
|
150
213
|
}
|
|
@@ -186,16 +249,8 @@ function buildRangeAnchor(editor) {
|
|
|
186
249
|
}
|
|
187
250
|
const anchorPoint = $resolveSelectionPoint(selection, "anchor");
|
|
188
251
|
const focusPoint = $resolveSelectionPoint(selection, "focus");
|
|
189
|
-
let startOffset = $getTextOffsetInBlock(
|
|
190
|
-
|
|
191
|
-
anchorPoint.node,
|
|
192
|
-
anchorPoint.offset
|
|
193
|
-
);
|
|
194
|
-
let endOffset = $getTextOffsetInBlock(
|
|
195
|
-
block,
|
|
196
|
-
focusPoint.node,
|
|
197
|
-
focusPoint.offset
|
|
198
|
-
);
|
|
252
|
+
let startOffset = $getTextOffsetInBlock(block, anchorPoint.node, anchorPoint.offset);
|
|
253
|
+
let endOffset = $getTextOffsetInBlock(block, focusPoint.node, focusPoint.offset);
|
|
199
254
|
if (startOffset > endOffset) {
|
|
200
255
|
[startOffset, endOffset] = [endOffset, startOffset];
|
|
201
256
|
}
|
|
@@ -221,98 +276,33 @@ function buildRangeAnchor(editor) {
|
|
|
221
276
|
});
|
|
222
277
|
}
|
|
223
278
|
export {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
z as $isGridContainerNode,
|
|
233
|
-
A2 as $isImageNode,
|
|
234
|
-
B2 as $isKaTeXBlockNode,
|
|
235
|
-
D as $isKaTeXInlineNode,
|
|
236
|
-
E as $isLinkCardNode,
|
|
237
|
-
G as $isMentionNode,
|
|
238
|
-
H2 as $isMermaidNode,
|
|
239
|
-
I2 as $isRubyNode,
|
|
240
|
-
J as ALERT_LABELS,
|
|
241
|
-
K2 as ALERT_TYPES,
|
|
242
|
-
A as ALL_TRANSFORMERS,
|
|
243
|
-
d as AutoLinkPlugin,
|
|
244
|
-
L2 as BANNER_LABELS,
|
|
245
|
-
M2 as BANNER_TYPES,
|
|
246
|
-
B as BlockExitPlugin,
|
|
247
|
-
C as ColorSchemeProvider,
|
|
248
|
-
F2 as FootnoteDefinitionsProvider,
|
|
249
|
-
F as FootnotePlugin,
|
|
250
|
-
FootnoteRenderer,
|
|
251
|
-
e as FootnoteSectionEditNode,
|
|
252
|
-
O as FootnoteSectionNode,
|
|
253
|
-
P as FootnoteStaticRenderer,
|
|
254
|
-
Q as GridContainerNode,
|
|
255
|
-
H as HorizontalRulePlugin,
|
|
256
|
-
I as INSERT_ALERT_COMMAND,
|
|
257
|
-
f as INSERT_IMAGE_COMMAND,
|
|
258
|
-
h as INSERT_KATEX_BLOCK_COMMAND,
|
|
259
|
-
i as INSERT_KATEX_INLINE_COMMAND,
|
|
260
|
-
j as INSERT_MERMAID_COMMAND,
|
|
261
|
-
S as ImageNode,
|
|
262
|
-
k as ImagePlugin,
|
|
263
|
-
l as ImageUploadPlugin,
|
|
264
|
-
T as KaTeXBlockNode,
|
|
265
|
-
U as KaTeXInlineNode,
|
|
266
|
-
K as KaTeXPlugin,
|
|
267
|
-
V as KaTeXRenderer,
|
|
268
|
-
W as LinkCardNode,
|
|
269
|
-
X as LinkCardRenderer,
|
|
270
|
-
L3 as LinkFavicon,
|
|
271
|
-
L as LinkFaviconPlugin,
|
|
272
|
-
M as MarkdownShortcutsPlugin,
|
|
273
|
-
Y as MentionNode,
|
|
274
|
-
Z as MermaidNode,
|
|
275
|
-
m as MermaidPlugin,
|
|
276
|
-
N as NESTED_EDITOR_NODES,
|
|
277
|
-
N2 as NestedContentRendererProvider,
|
|
278
|
-
_ as OPEN_IMAGE_UPLOAD_DIALOG_COMMAND,
|
|
279
|
-
R as RichEditor,
|
|
280
|
-
a0 as RubyNode,
|
|
281
|
-
R2 as RubyRenderer,
|
|
282
|
-
a as allEditNodes,
|
|
283
|
-
a2 as allNodes,
|
|
279
|
+
ColorSchemeProvider,
|
|
280
|
+
CorePlugins,
|
|
281
|
+
F as FootnoteDefinitionsProvider,
|
|
282
|
+
L as LinkFavicon,
|
|
283
|
+
N as NestedContentRendererProvider,
|
|
284
|
+
RendererConfigProvider,
|
|
285
|
+
RichEditor,
|
|
286
|
+
RichEditorShell,
|
|
284
287
|
articleTheme,
|
|
285
|
-
|
|
286
|
-
blockIdState,
|
|
288
|
+
a as articleVariant,
|
|
287
289
|
buildBlockAnchor,
|
|
288
290
|
buildRangeAnchor,
|
|
289
|
-
b as builtinNodes,
|
|
290
|
-
collectCommandItems,
|
|
291
291
|
commentTheme,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
c as customEditNodes,
|
|
296
|
-
c2 as customNodes,
|
|
297
|
-
a22 as decodeThumbHash,
|
|
298
|
-
n as defaultImageUpload,
|
|
299
|
-
f2 as editorTheme,
|
|
300
|
-
g2 as extractTextContent,
|
|
301
|
-
g as getResolvedEditNodes,
|
|
302
|
-
g3 as getVariantClass,
|
|
292
|
+
c as commentVariant,
|
|
293
|
+
editorTheme,
|
|
294
|
+
getVariantClass,
|
|
303
295
|
noteTheme,
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
u2 as
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
n2 as useRendererMode,
|
|
316
|
-
o as useVariant,
|
|
296
|
+
n as noteVariant,
|
|
297
|
+
r as richContent,
|
|
298
|
+
u as useColorScheme,
|
|
299
|
+
u2 as useFootnoteContent,
|
|
300
|
+
b as useFootnoteDefinitions,
|
|
301
|
+
d as useFootnoteDisplayNumber,
|
|
302
|
+
u3 as useNestedContentRenderer,
|
|
303
|
+
b2 as useOptionalNestedContentRenderer,
|
|
304
|
+
e as useRendererConfig,
|
|
305
|
+
f as useRendererMode,
|
|
306
|
+
g as useVariant,
|
|
317
307
|
vars
|
|
318
308
|
};
|