@haklex/rich-editor 0.51.1 → 0.52.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/{SubmitShortcutPlugin-BbQBy2MJ.js → SubmitShortcutPlugin-DwZzJlZ0.js} +2 -2
- package/dist/components/renderers/CodeBlockRenderer.d.ts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{node-registry-BSEUpIjy.js → node-registry-B2ZLKN5B.js} +4 -21
- package/dist/nodes-entry.mjs +1 -1
- package/dist/plugins-entry.mjs +1 -1
- package/package.json +5 -10
- package/dist/utils/shiki.d.ts +0 -6
- package/dist/utils/shiki.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as setCodeBlockCursorIntent, o as $createCodeBlockEditNode, s as $createBannerEditNode, t as getResolvedEditNodes } from "./node-registry-
|
|
1
|
+
import { c as setCodeBlockCursorIntent, o as $createCodeBlockEditNode, s as $createBannerEditNode, t as getResolvedEditNodes } from "./node-registry-B2ZLKN5B.js";
|
|
2
2
|
import "./utils-CdxPji5z.js";
|
|
3
3
|
import { $ as INLINE_DRAG_MIME, B as FootnoteNode, C as KaTeXBlockNode, G as AlertQuoteNode, O as $withAdaptiveImageDisplayWidth, Q as INLINE_DRAG_ATTR, V as OPEN_FILE_PICKER_COMMAND, _ as MentionNode, b as KaTeXInlineNode, c as SpoilerNode, h as $createMentionNode, k as OPEN_IMAGE_UPLOAD_DIALOG_COMMAND, o as $createSpoilerNode, q as extractTextContent, v as $createKaTeXInlineNode, w as $createImageNode, x as $createKaTeXBlockNode, z as $createFootnoteNode } from "./theme-Blq1EG_t.js";
|
|
4
4
|
import { i as FootnoteDefinitionsProvider, t as computeImageMeta } from "./thumbhash-DHHqtr0c.js";
|
|
@@ -22,9 +22,9 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
22
22
|
import { $convertFromMarkdownString, CHECK_LIST, CODE, QUOTE, TRANSFORMERS } from "@lexical/markdown";
|
|
23
23
|
import { $createTableCellNode, $createTableNode, $createTableRowNode, TableCellHeaderStates } from "@lexical/table";
|
|
24
24
|
import { Check, Info, Link2, Upload } from "lucide-react";
|
|
25
|
+
import { ActionBar, ActionButton, Dialog, DialogPopup, DialogTitle, SegmentedControl } from "@haklex/rich-editor-ui";
|
|
25
26
|
import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
|
|
26
27
|
import { nanoid } from "nanoid";
|
|
27
|
-
import { ActionBar, ActionButton, Dialog, DialogPopup, DialogTitle, SegmentedControl } from "@haklex/rich-editor-ui";
|
|
28
28
|
//#region src/plugins/AutoLinkPlugin.tsx
|
|
29
29
|
var DEFAULT_MATCHERS = [createLinkMatcherWithRegExp(/https?:\/\/(?:www\.)?[\w#%+.:=@~-]{1,256}\.[A-Za-z]{2}[\w#%&()+./:=?@~-]*/), createLinkMatcherWithRegExp(/(?:[\w%+.-]+@[\d.a-z-]+\.[a-z]{2,})/i, (text) => `mailto:${text}`)];
|
|
30
30
|
function AutoLinkPlugin({ matchers }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlockRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/renderers/CodeBlockRenderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CodeBlockRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/renderers/CodeBlockRenderer.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,KAAK,IAAI,CAAC;IACtD,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,QAAQ,EACR,eAAe,EAAE,mBAAmB,GACrC,EAAE,sBAAsB,+BA6FxB"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as FileUploadPlugin, C as createTextSelectionStore, D as ImageUploadPlugin, E as LinkFaviconPlugin, F as VideoUploadProvider, L as ImageUploadProvider, N as BlockIdPlugin, O as defaultImageUpload, P as blockIdState, S as TextSelectionStoreProvider, T as useTextSelectionStore, U as CorePlugins, V as FileUploadProvider, _ as $getRootBlock, a as AutoFocusPlugin, b as buildBlockAnchor, c as $captureTextSelection, d as createDOMRangeFromTextSelection, f as findDOMPointByTextOffset, g as TEXT_SELECTION_HIGHLIGHT_NAME, h as getTextOffsetFromDOMPoint, i as EditorRefPlugin, l as $captureTextSelectionFromRangeSelection, m as getDOMRectFromTextSelection, n as OnChangePlugin, o as VideoUploadPlugin, p as getBlockElementById, r as FootnotePlugin, s as TextSelectionPlugin, t as SubmitShortcutPlugin, u as $restoreTextSelection, v as $getTextOffsetInBlock, w as useTextSelectionSnapshot, x as buildRangeAnchor, y as $resolveSelectionPoint, z as ImagePreprocessProvider } from "./SubmitShortcutPlugin-
|
|
2
|
-
import { n as setResolvedEditNodes, r as allEditNodes } from "./node-registry-
|
|
1
|
+
import { A as FileUploadPlugin, C as createTextSelectionStore, D as ImageUploadPlugin, E as LinkFaviconPlugin, F as VideoUploadProvider, L as ImageUploadProvider, N as BlockIdPlugin, O as defaultImageUpload, P as blockIdState, S as TextSelectionStoreProvider, T as useTextSelectionStore, U as CorePlugins, V as FileUploadProvider, _ as $getRootBlock, a as AutoFocusPlugin, b as buildBlockAnchor, c as $captureTextSelection, d as createDOMRangeFromTextSelection, f as findDOMPointByTextOffset, g as TEXT_SELECTION_HIGHLIGHT_NAME, h as getTextOffsetFromDOMPoint, i as EditorRefPlugin, l as $captureTextSelectionFromRangeSelection, m as getDOMRectFromTextSelection, n as OnChangePlugin, o as VideoUploadPlugin, p as getBlockElementById, r as FootnotePlugin, s as TextSelectionPlugin, t as SubmitShortcutPlugin, u as $restoreTextSelection, v as $getTextOffsetInBlock, w as useTextSelectionSnapshot, x as buildRangeAnchor, y as $resolveSelectionPoint, z as ImagePreprocessProvider } from "./SubmitShortcutPlugin-DwZzJlZ0.js";
|
|
2
|
+
import { n as setResolvedEditNodes, r as allEditNodes } from "./node-registry-B2ZLKN5B.js";
|
|
3
3
|
import { a as chatVariant, c as semanticClassNames, i as commentVariant, l as sharedStyles, n as getVariantClass, o as articleVariant, r as noteVariant, s as richContent, t as clsx } from "./utils-CdxPji5z.js";
|
|
4
4
|
import { X as useNestedContentRenderer, Y as NestedContentRendererProvider, Z as useOptionalNestedContentRenderer, t as editorTheme } from "./theme-Blq1EG_t.js";
|
|
5
5
|
import { C as MENTION_NODE_KEY, D as VIDEO_NODE_KEY, E as TAG_NODE_KEY, S as LINK_CARD_NODE_KEY, T as RUBY_NODE_KEY, _ as FILE_NODE_KEY, a as useFootnoteContent, b as IMAGE_NODE_KEY, d as useRendererConfig, f as useRendererMode, g as CODE_BLOCK_NODE_KEY, h as BANNER_NODE_KEY, i as FootnoteDefinitionsProvider, m as ALERT_NODE_KEY, o as useFootnoteDefinitions, p as useVariant, s as useFootnoteDisplayNumber, u as RendererConfigProvider, v as FOOTNOTE_NODE_KEY, w as MERMAID_NODE_KEY, x as KATEX_NODE_KEY, y as FOOTNOTE_SECTION_NODE_KEY } from "./thumbhash-DHHqtr0c.js";
|
|
@@ -14,6 +14,7 @@ import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
|
14
14
|
import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer";
|
|
15
15
|
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
16
16
|
import { useLexicalNodeSelection } from "@lexical/react/useLexicalNodeSelection";
|
|
17
|
+
import { highlightCode } from "@haklex/rich-editor-ui";
|
|
17
18
|
//#region src/utils/codeBlockSelectionIntent.ts
|
|
18
19
|
var codeBlockCursorIntentMap = /* @__PURE__ */ new Map();
|
|
19
20
|
function setCodeBlockCursorIntent(nodeKey, placement) {
|
|
@@ -143,36 +144,18 @@ function $createBannerEditNode(bannerType, contentState) {
|
|
|
143
144
|
return new BannerEditNode(bannerType, contentState);
|
|
144
145
|
}
|
|
145
146
|
//#endregion
|
|
146
|
-
//#region src/utils/shiki.ts
|
|
147
|
-
var codeToHtmlFn = null;
|
|
148
|
-
var shikiLoadPromise = null;
|
|
149
|
-
function loadCodeToHtml() {
|
|
150
|
-
if (codeToHtmlFn) return Promise.resolve(codeToHtmlFn);
|
|
151
|
-
if (!shikiLoadPromise) shikiLoadPromise = import("shiki/bundle/full").then((mod) => {
|
|
152
|
-
codeToHtmlFn = mod.codeToHtml;
|
|
153
|
-
return mod.codeToHtml;
|
|
154
|
-
}).catch((err) => {
|
|
155
|
-
shikiLoadPromise = null;
|
|
156
|
-
throw err;
|
|
157
|
-
});
|
|
158
|
-
return shikiLoadPromise;
|
|
159
|
-
}
|
|
160
|
-
//#endregion
|
|
161
147
|
//#region src/components/renderers/CodeBlockRenderer.tsx
|
|
162
148
|
function CodeBlockRenderer({ code, language, showLineNumbers: showLineNumbersProp }) {
|
|
163
149
|
const variant = useVariant();
|
|
164
150
|
const showLineNumbers = showLineNumbersProp ?? (variant !== "comment" && variant !== "chat");
|
|
165
|
-
const
|
|
151
|
+
const colorScheme = useColorScheme();
|
|
166
152
|
const [highlightedHtml, setHighlightedHtml] = useState(null);
|
|
167
153
|
const [copied, setCopied] = useState(false);
|
|
168
154
|
const copyTimerRef = useRef(void 0);
|
|
169
155
|
useEffect(() => {
|
|
170
156
|
let cancelled = false;
|
|
171
157
|
setHighlightedHtml(null);
|
|
172
|
-
|
|
173
|
-
lang: language,
|
|
174
|
-
theme: shikiTheme
|
|
175
|
-
})).then((html) => {
|
|
158
|
+
highlightCode(code, language, colorScheme === "dark" ? "dark" : "light").then((html) => {
|
|
176
159
|
if (!cancelled) setHighlightedHtml(html);
|
|
177
160
|
}).catch(() => {
|
|
178
161
|
if (!cancelled) setHighlightedHtml(null);
|
|
@@ -183,7 +166,7 @@ function CodeBlockRenderer({ code, language, showLineNumbers: showLineNumbersPro
|
|
|
183
166
|
}, [
|
|
184
167
|
code,
|
|
185
168
|
language,
|
|
186
|
-
|
|
169
|
+
colorScheme
|
|
187
170
|
]);
|
|
188
171
|
useEffect(() => {
|
|
189
172
|
return () => clearTimeout(copyTimerRef.current);
|
package/dist/nodes-entry.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as FootnoteSectionEditNode, i as customEditNodes, n as setResolvedEditNodes, r as allEditNodes, t as getResolvedEditNodes } from "./node-registry-
|
|
1
|
+
import { a as FootnoteSectionEditNode, i as customEditNodes, n as setResolvedEditNodes, r as allEditNodes, t as getResolvedEditNodes } from "./node-registry-B2ZLKN5B.js";
|
|
2
2
|
import { A as computeImageDisplayPixels, C as KaTeXBlockNode, D as sanitizeImageLayout, E as ImageNode, F as imageDisplaySizeAfterResize, I as resolveImageDisplaySize, L as sanitizeImageDisplayWidth, M as imageDisplayCssVars, N as imageDisplayDataAttr, P as imageDisplayFieldsFromSize, R as sanitizeImageFixedPx, S as $isKaTeXBlockNode, T as $isImageNode, U as ALERT_LABELS, W as ALERT_TYPES, _ as MentionNode, b as KaTeXInlineNode, d as RichQuoteNode, f as $createMermaidNode, g as $isMentionNode, h as $createMentionNode, i as TagNode, j as convertImageDisplaySize, l as $createRichQuoteNode, m as MermaidNode, n as $createTagNode, p as $isMermaidNode, r as $isTagNode, u as $isRichQuoteNode, w as $createImageNode, y as $isKaTeXInlineNode } from "./theme-Blq1EG_t.js";
|
|
3
3
|
import { C as fileExtFromName, E as $createCommentNode, N as BANNER_LABELS, O as $isCommentNode, P as BANNER_TYPES, S as FileNode, _ as $createFootnoteSectionNode, a as customNodes, b as $createFileNode, c as $createRubyNode, d as $createLinkCardNode, f as $isLinkCardNode, g as GridContainerNode, h as $isGridContainerNode, i as builtinNodes, k as CommentNode, l as $isRubyNode, m as $createGridContainerNode, p as LinkCardNode, r as allNodes, u as RubyNode, v as $isFootnoteSectionNode, x as $isFileNode, y as FootnoteSectionNode } from "./ColorSchemeContext-RLg0uDRt.js";
|
|
4
4
|
import { r as NESTED_EDITOR_NODES } from "./AlertQuoteEditNode-DuAjHXTP.js";
|
package/dist/plugins-entry.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as FileUploadPlugin, B as useImagePreprocess, D as ImageUploadPlugin, E as LinkFaviconPlugin, F as VideoUploadProvider, G as MarkdownPastePlugin, H as useFileUpload, I as useVideoUpload, J as HorizontalRulePlugin, K as ALL_TRANSFORMERS, L as ImageUploadProvider, M as useFileUploadEntry, N as BlockIdPlugin, O as defaultImageUpload, P as blockIdState, Q as AutoLinkPlugin, R as useImageUpload, U as CorePlugins, V as FileUploadProvider, W as MarkdownShortcutsPlugin, X as registerClickBelowCommand, Y as ClickBelowPlugin, Z as BlockExitPlugin, a as AutoFocusPlugin, i as EditorRefPlugin, j as setFileUploadEntry, k as resolvePreprocessTargets, n as OnChangePlugin, o as VideoUploadPlugin, q as InlineDndPlugin, r as FootnotePlugin, s as TextSelectionPlugin, t as SubmitShortcutPlugin, z as ImagePreprocessProvider } from "./SubmitShortcutPlugin-
|
|
1
|
+
import { A as FileUploadPlugin, B as useImagePreprocess, D as ImageUploadPlugin, E as LinkFaviconPlugin, F as VideoUploadProvider, G as MarkdownPastePlugin, H as useFileUpload, I as useVideoUpload, J as HorizontalRulePlugin, K as ALL_TRANSFORMERS, L as ImageUploadProvider, M as useFileUploadEntry, N as BlockIdPlugin, O as defaultImageUpload, P as blockIdState, Q as AutoLinkPlugin, R as useImageUpload, U as CorePlugins, V as FileUploadProvider, W as MarkdownShortcutsPlugin, X as registerClickBelowCommand, Y as ClickBelowPlugin, Z as BlockExitPlugin, a as AutoFocusPlugin, i as EditorRefPlugin, j as setFileUploadEntry, k as resolvePreprocessTargets, n as OnChangePlugin, o as VideoUploadPlugin, q as InlineDndPlugin, r as FootnotePlugin, s as TextSelectionPlugin, t as SubmitShortcutPlugin, z as ImagePreprocessProvider } from "./SubmitShortcutPlugin-DwZzJlZ0.js";
|
|
2
2
|
import { Q as INLINE_DRAG_ATTR, et as markInlineDraggable } from "./theme-Blq1EG_t.js";
|
|
3
3
|
import { o as PasteLinkPlugin } from "./AlertQuoteEditNode-DuAjHXTP.js";
|
|
4
4
|
import { a as KaTeXPlugin, c as AlertPlugin, n as MermaidPlugin, s as ImagePlugin } from "./MermaidPlugin-By_8nKNX.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.0",
|
|
4
4
|
"description": "Core rich text editor based on Lexical",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"dist"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@haklex/rich-editor-ui": "0.
|
|
49
|
-
"@haklex/rich-headless": "0.
|
|
50
|
-
"@haklex/rich-style-token": "0.
|
|
48
|
+
"@haklex/rich-editor-ui": "0.52.0",
|
|
49
|
+
"@haklex/rich-headless": "0.52.0",
|
|
50
|
+
"@haklex/rich-style-token": "0.52.0",
|
|
51
51
|
"@lexical/code-core": "^0.52.0",
|
|
52
52
|
"nanoid": "^6.0.2",
|
|
53
53
|
"thumbhash": "^0.1.1"
|
|
@@ -69,7 +69,6 @@
|
|
|
69
69
|
"lucide-react": "^1.59.0",
|
|
70
70
|
"react": "^19.3.1",
|
|
71
71
|
"react-dom": "^19.3.1",
|
|
72
|
-
"shiki": "^4.5.0",
|
|
73
72
|
"typescript": "^7.0.2",
|
|
74
73
|
"unplugin-dts": "^1.1.2",
|
|
75
74
|
"vite": "^8.3.4"
|
|
@@ -87,15 +86,11 @@
|
|
|
87
86
|
"lexical": "^0.52.0",
|
|
88
87
|
"lucide-react": "^1.0.0",
|
|
89
88
|
"react": ">=19",
|
|
90
|
-
"react-dom": ">=19"
|
|
91
|
-
"shiki": ">=4.0.0"
|
|
89
|
+
"react-dom": ">=19"
|
|
92
90
|
},
|
|
93
91
|
"peerDependenciesMeta": {
|
|
94
92
|
"katex": {
|
|
95
93
|
"optional": true
|
|
96
|
-
},
|
|
97
|
-
"shiki": {
|
|
98
|
-
"optional": true
|
|
99
94
|
}
|
|
100
95
|
},
|
|
101
96
|
"publishConfig": {
|
package/dist/utils/shiki.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shiki.d.ts","sourceRoot":"","sources":["../../src/utils/shiki.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,CACzB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,KACrC,OAAO,CAAC,MAAM,CAAC,CAAC;AAKrB,wBAAgB,cAAc,IAAI,OAAO,CAAC,YAAY,CAAC,CActD"}
|