@haklex/rich-editor 0.61.0 → 0.61.1

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.
@@ -1,4 +1,4 @@
1
- import { c as setCodeBlockCursorIntent, o as $createCodeBlockEditNode, s as $createBannerEditNode, t as getResolvedEditNodes } from "./node-registry-jRE4LqH-.js";
1
+ import { c as setCodeBlockCursorIntent, o as $createCodeBlockEditNode, s as $createBannerEditNode, t as getResolvedEditNodes } from "./node-registry-8OWu2S8i.js";
2
2
  /* empty css */
3
3
  import { B as FootnoteNode, C as KaTeXBlockNode, G as AlertQuoteNode, K as extractTextContent, O as $withAdaptiveImageDisplayWidth, Q as INLINE_DRAG_MIME, V as OPEN_FILE_PICKER_COMMAND, Z as INLINE_DRAG_ATTR, _ as MentionNode, b as KaTeXInlineNode, c as SpoilerNode, h as $createMentionNode, k as OPEN_IMAGE_UPLOAD_DIALOG_COMMAND, o as $createSpoilerNode, v as $createKaTeXInlineNode, w as $createImageNode, x as $createKaTeXBlockNode, z as $createFootnoteNode } from "./theme-DH4xzxU-.js";
4
4
  import { i as FootnoteDefinitionsProvider, t as computeImageMeta } from "./thumbhash-GjK8OYAb.js";
@@ -1 +1 @@
1
- {"version":3,"file":"CodeBlockEditDecorator.d.ts","sourceRoot":"","sources":["../../../src/components/decorators/CodeBlockEditDecorator.tsx"],"names":[],"mappings":"AAuBA,UAAU,2BAA2B;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,sBAAsB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,2BAA2B,+BA2K9F"}
1
+ {"version":3,"file":"CodeBlockEditDecorator.d.ts","sourceRoot":"","sources":["../../../src/components/decorators/CodeBlockEditDecorator.tsx"],"names":[],"mappings":"AAyBA,UAAU,2BAA2B;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,sBAAsB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,2BAA2B,+BA4M9F"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { C as createTextSelectionStore, D as ImageUploadPlugin, E as LinkFaviconPlugin, G as CorePlugins, L as VideoUploadProvider, O as defaultImageUpload, P as FileUploadPlugin, S as TextSelectionStoreProvider, T as useTextSelectionStore, U as FileUploadProvider, V as ImagePreprocessProvider, _ as $getRootBlock, a as EditorRefPlugin, b as buildBlockAnchor, c as $captureTextSelection, d as createDOMRangeFromTextSelection, f as findDOMPointByTextOffset, g as TEXT_SELECTION_HIGHLIGHT_NAME, h as getTextOffsetFromDOMPoint, i as FootnotePlugin, l as $captureTextSelectionFromRangeSelection, m as getDOMRectFromTextSelection, n as SubmitShortcutPlugin, o as VideoUploadPlugin, p as getBlockElementById, r as OnChangePlugin, s as TextSelectionPlugin, t as AutoFocusPlugin, u as $restoreTextSelection, v as $getTextOffsetInBlock, w as useTextSelectionSnapshot, x as buildRangeAnchor, y as $resolveSelectionPoint, z as ImageUploadProvider } from "./VirtualizationPlugin-eHBms1eF.js";
2
- import { n as setResolvedEditNodes, r as allEditNodes } from "./node-registry-jRE4LqH-.js";
1
+ import { C as createTextSelectionStore, D as ImageUploadPlugin, E as LinkFaviconPlugin, G as CorePlugins, L as VideoUploadProvider, O as defaultImageUpload, P as FileUploadPlugin, S as TextSelectionStoreProvider, T as useTextSelectionStore, U as FileUploadProvider, V as ImagePreprocessProvider, _ as $getRootBlock, a as EditorRefPlugin, b as buildBlockAnchor, c as $captureTextSelection, d as createDOMRangeFromTextSelection, f as findDOMPointByTextOffset, g as TEXT_SELECTION_HIGHLIGHT_NAME, h as getTextOffsetFromDOMPoint, i as FootnotePlugin, l as $captureTextSelectionFromRangeSelection, m as getDOMRectFromTextSelection, n as SubmitShortcutPlugin, o as VideoUploadPlugin, p as getBlockElementById, r as OnChangePlugin, s as TextSelectionPlugin, t as AutoFocusPlugin, u as $restoreTextSelection, v as $getTextOffsetInBlock, w as useTextSelectionSnapshot, x as buildRangeAnchor, y as $resolveSelectionPoint, z as ImageUploadProvider } from "./VirtualizationPlugin-qZs8amcc.js";
2
+ import { n as setResolvedEditNodes, r as allEditNodes } from "./node-registry-8OWu2S8i.js";
3
3
  import { J as NestedContentRendererProvider, X as useOptionalNestedContentRenderer, Y as useNestedContentRenderer, t as editorTheme } from "./theme-DH4xzxU-.js";
4
4
  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-GjK8OYAb.js";
5
5
  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-E6qVk-NR.js";
@@ -7,7 +7,7 @@ import { n as gridStyles, t as gridClassNames } from "./grid.css-DJWKdYpz.js";
7
7
  import { a as useNestedEditorSync, i as createNestedEditor, n as AlertQuoteEditNode, s as NestedEditorCorePlugins } from "./AlertQuoteEditNode-Ck4v29Wg.js";
8
8
  import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
9
9
  import { createElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
10
- import { $createNodeSelection, $createParagraphNode, $getNodeByKey, $getRoot, $getSelection, $insertNodes, $isDecoratorNode, $isElementNode, $isNodeSelection, $nodesOfType, $setSelection } from "lexical";
10
+ import { $createNodeSelection, $createParagraphNode, $getNodeByKey, $getRoot, $getSelection, $insertNodes, $isDecoratorNode, $isElementNode, $isNodeSelection, $nodesOfType, $setSelection, COMMAND_PRIORITY_HIGH, KEY_DOWN_COMMAND } from "lexical";
11
11
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
12
12
  import { Flag, LayoutGrid, Minus, Plus } from "lucide-react";
13
13
  import { ContentEditable } from "@lexical/react/LexicalContentEditable";
@@ -240,6 +240,26 @@ function CodeBlockEditDecorator({ nodeKey, code, language }) {
240
240
  isSelected,
241
241
  nodeKey
242
242
  ]);
243
+ useEffect(() => {
244
+ if (!editable || !isSelected) return;
245
+ return editor.registerCommand(KEY_DOWN_COMMAND, (event) => {
246
+ if (event.key.length !== 1 || event.metaKey || event.ctrlKey || event.altKey) return false;
247
+ if (event.isComposing) return false;
248
+ if (!editor.getEditorState().read(() => {
249
+ const selection = $getSelection();
250
+ if (!$isNodeSelection(selection)) return false;
251
+ const nodes = selection.getNodes();
252
+ return nodes.length === 1 && nodes[0]?.getKey() === nodeKey;
253
+ })) return false;
254
+ editor.getElementByKey(nodeKey)?.querySelector("[contenteditable=\"true\"]")?.focus();
255
+ return false;
256
+ }, COMMAND_PRIORITY_HIGH);
257
+ }, [
258
+ editable,
259
+ editor,
260
+ isSelected,
261
+ nodeKey
262
+ ]);
243
263
  const handleCodeChange = useCallback((newCode) => {
244
264
  editor.update(() => {
245
265
  const node = $getNodeByKey(nodeKey);
@@ -1,4 +1,4 @@
1
- import { a as FootnoteSectionEditNode, i as customEditNodes, n as setResolvedEditNodes, r as allEditNodes, t as getResolvedEditNodes } from "./node-registry-jRE4LqH-.js";
1
+ import { a as FootnoteSectionEditNode, i as customEditNodes, n as setResolvedEditNodes, r as allEditNodes, t as getResolvedEditNodes } from "./node-registry-8OWu2S8i.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-DH4xzxU-.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-Dc_HebHd.js";
4
4
  import { r as NESTED_EDITOR_NODES } from "./AlertQuoteEditNode-Ck4v29Wg.js";
@@ -1,4 +1,4 @@
1
- import { $ as BlockExitPlugin, A as ImageDialog, B as useImageUpload, D as ImageUploadPlugin, E as LinkFaviconPlugin, F as setFileUploadEntry, G as CorePlugins, H as useImagePreprocess, I as useFileUploadEntry, J as ALL_TRANSFORMERS, K as MarkdownShortcutsPlugin, L as VideoUploadProvider, M as registerImageEditor, N as resolvePreprocessTargets, O as defaultImageUpload, P as FileUploadPlugin, Q as registerClickBelowCommand, R as useVideoUpload, U as FileUploadProvider, V as ImagePreprocessProvider, W as useFileUpload, X as HorizontalRulePlugin, Y as InlineDndPlugin, Z as ClickBelowPlugin, a as EditorRefPlugin, et as AutoLinkPlugin, i as FootnotePlugin, j as getImageEditor, k as presentImageDialog, n as SubmitShortcutPlugin, o as VideoUploadPlugin, q as MarkdownPastePlugin, r as OnChangePlugin, s as TextSelectionPlugin, t as AutoFocusPlugin, z as ImageUploadProvider } from "./VirtualizationPlugin-eHBms1eF.js";
1
+ import { $ as BlockExitPlugin, A as ImageDialog, B as useImageUpload, D as ImageUploadPlugin, E as LinkFaviconPlugin, F as setFileUploadEntry, G as CorePlugins, H as useImagePreprocess, I as useFileUploadEntry, J as ALL_TRANSFORMERS, K as MarkdownShortcutsPlugin, L as VideoUploadProvider, M as registerImageEditor, N as resolvePreprocessTargets, O as defaultImageUpload, P as FileUploadPlugin, Q as registerClickBelowCommand, R as useVideoUpload, U as FileUploadProvider, V as ImagePreprocessProvider, W as useFileUpload, X as HorizontalRulePlugin, Y as InlineDndPlugin, Z as ClickBelowPlugin, a as EditorRefPlugin, et as AutoLinkPlugin, i as FootnotePlugin, j as getImageEditor, k as presentImageDialog, n as SubmitShortcutPlugin, o as VideoUploadPlugin, q as MarkdownPastePlugin, r as OnChangePlugin, s as TextSelectionPlugin, t as AutoFocusPlugin, z as ImageUploadProvider } from "./VirtualizationPlugin-qZs8amcc.js";
2
2
  import { $ as markInlineDraggable, Z as INLINE_DRAG_ATTR } from "./theme-DH4xzxU-.js";
3
3
  import { c as PasteLinkPlugin } from "./AlertQuoteEditNode-Ck4v29Wg.js";
4
4
  import { i as EditorSurfacePlugins, n as ActiveEditorScope, o as useActiveEditor, r as EditorSurfacePlugin, t as VirtualizationPlugin } from "./VirtualizationPlugin-BA7YFDRN.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-editor",
3
- "version": "0.61.0",
3
+ "version": "0.61.1",
4
4
  "description": "Core rich text editor based on Lexical",
5
5
  "repository": {
6
6
  "type": "git",
@@ -57,9 +57,9 @@
57
57
  "dist"
58
58
  ],
59
59
  "dependencies": {
60
- "@haklex/rich-editor-ui": "0.61.0",
61
- "@haklex/rich-headless": "0.61.0",
62
- "@haklex/rich-style-token": "0.61.0",
60
+ "@haklex/rich-editor-ui": "0.61.1",
61
+ "@haklex/rich-headless": "0.61.1",
62
+ "@haklex/rich-style-token": "0.61.1",
63
63
  "@lexical/code-core": "^0.53.0",
64
64
  "nanoid": "^6.0.2",
65
65
  "thumbhash": "^0.1.1"