@lobehub/editor 1.20.3 → 1.21.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.
@@ -164,6 +164,13 @@ function convertMdastToLexical(node, index, ctx) {
164
164
  ret.push(convertMdastToLexical(child, index, ctx, markdownReaders));
165
165
  return ret;
166
166
  }, []).filter(Boolean).flat();
167
+ while (htmlStack.length > 0) {
168
+ var _children3;
169
+ var tag = htmlStack.shift();
170
+ ctx.pop();
171
+ // @ts-expect-error not error
172
+ (_children3 = _children).push.apply(_children3, [INodeHelper.createTextNode(tag === null || tag === void 0 ? void 0 : tag.node.value)].concat(_toConsumableArray(tag.children)));
173
+ }
167
174
  }
168
175
  if (markdownReaders[node.type]) {
169
176
  var reader = markdownReaders[node.type];
@@ -10,6 +10,7 @@ import { $createQuoteNode, $isHeadingNode, $isQuoteNode } from '@lexical/rich-te
10
10
  import { $setBlocksType } from '@lexical/selection';
11
11
  import { $getNearestNodeOfType, mergeRegister } from '@lexical/utils';
12
12
  import { $createNodeSelection, $getSelection, $isParagraphNode, $isRangeSelection, $setSelection, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, COMMAND_PRIORITY_LOW, FORMAT_TEXT_COMMAND, REDO_COMMAND, SELECTION_CHANGE_COMMAND, UNDO_COMMAND } from 'lexical';
13
+ import { debounce } from 'lodash-es';
13
14
  import { useCallback, useEffect, useMemo, useState } from 'react';
14
15
  import { INSERT_CODEINLINE_COMMAND } from "../../../plugins/code";
15
16
  import { $isSelectionInCodeInline } from "../../../plugins/code/node/code";
@@ -369,14 +370,22 @@ export function useEditorState(editor) {
369
370
  if (!editor) return;
370
371
  var lexicalEditor = editor.getLexicalEditor();
371
372
  var cleanup = function cleanup() {};
373
+ var debounceUpdate = debounce(function () {
374
+ lexicalEditor === null || lexicalEditor === void 0 || lexicalEditor.read(function () {
375
+ $updateToolbar();
376
+ });
377
+ }, 500);
372
378
  var handleLexicalEditor = function handleLexicalEditor(lexicalEditor) {
373
- cleanup = mergeRegister(lexicalEditor.registerUpdateListener(function (_ref) {
379
+ cleanup = mergeRegister(lexicalEditor.registerUpdateListener(debounce(function (_ref) {
374
380
  var editorState = _ref.editorState;
375
381
  editorState.read(function () {
376
382
  $updateToolbar();
377
383
  });
378
- }), lexicalEditor.registerCommand(SELECTION_CHANGE_COMMAND, function () {
379
- $updateToolbar();
384
+ }, 500)), lexicalEditor.registerCommand(SELECTION_CHANGE_COMMAND, function () {
385
+ if (lexicalEditor.isComposing()) {
386
+ return false;
387
+ }
388
+ debounceUpdate();
380
389
  return false;
381
390
  }, COMMAND_PRIORITY_LOW), lexicalEditor.registerCommand(CAN_UNDO_COMMAND, function (payload) {
382
391
  setCanUndo(payload);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "1.20.3",
3
+ "version": "1.21.0",
4
4
  "description": "A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.",
5
5
  "keywords": [
6
6
  "lobehub",