@lobehub/editor 4.17.0 → 4.17.2

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/es/headless.js CHANGED
@@ -6852,10 +6852,12 @@ function ensureTableControllerDOM(element) {
6852
6852
  if (legacyPlainToolbar instanceof HTMLElement) {
6853
6853
  legacyPlainToolbar.className = "toolbar-row";
6854
6854
  markTableControllerHost(legacyPlainToolbar, true);
6855
- element.append(legacyPlainToolbar);
6855
+ scrollWrapper.append(legacyPlainToolbar);
6856
6856
  }
6857
+ const legacyOuterRowToolbar = element.querySelector(":scope > .toolbar-row");
6858
+ if (legacyOuterRowToolbar instanceof HTMLElement) scrollWrapper.append(legacyOuterRowToolbar);
6857
6859
  ensureToolbar(scrollWrapper, "toolbar-col", true);
6858
- ensureToolbar(element, "toolbar-row", true);
6860
+ ensureToolbar(scrollWrapper, "toolbar-row", true);
6859
6861
  ensureTableScrollIndicators(scrollWrapper);
6860
6862
  }
6861
6863
  function reconcileTableDecorator(editor, node, decorator) {
@@ -4,6 +4,7 @@ import { useLexicalComposerContext } from "../../../editor-kernel/react/react-co
4
4
  import { useLexicalEditor } from "../../../editor-kernel/react/useLexicalEditor.js";
5
5
  import { IBlockMenuService } from "../service/i-block-menu-service.js";
6
6
  import { BlockPlugin } from "../plugin/index.js";
7
+ import { useEditable } from "../../../editor-kernel/react/useEditable.js";
7
8
  import { createRuntimeContext } from "./core/runtime-context.js";
8
9
  import { collectDragBlocks, getBlockMeasureRect, getTableBlockRect, isTableBlockElement } from "./drag/drag-utils.js";
9
10
  import { startBlockDragSession } from "./drag/drag-session.js";
@@ -54,7 +55,8 @@ const ReactBlockPlugin = (props) => {
54
55
  const [isDragging, setIsDragging] = useState(false);
55
56
  const [focusedTableBlockId, setFocusedTableBlockId] = useState(null);
56
57
  const [blockMenuService, setBlockMenuService] = useState(null);
57
- const blockMenuSuppressed = blockMenuService?.isMenuSuppressed() ?? false;
58
+ const { editable } = useEditable();
59
+ const blockMenuSuppressed = (blockMenuService?.isMenuSuppressed() ?? false) || editable === false;
58
60
  useLayoutEffect(() => {
59
61
  if (locale) editor.registerLocale(locale);
60
62
  editor.registerPlugin(BlockPlugin, {
@@ -40,9 +40,6 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
40
40
  pointer-events: auto;
41
41
  position: fixed;
42
42
  z-index: 100;
43
- transition:
44
- inset-inline-start 200ms ease,
45
- inset-block-start 200ms ease;
46
43
  `,
47
44
  menuInner: css`
48
45
  display: flex;
@@ -86,10 +86,12 @@ function ensureTableControllerDOM(element) {
86
86
  if (legacyPlainToolbar instanceof HTMLElement) {
87
87
  legacyPlainToolbar.className = "toolbar-row";
88
88
  markTableControllerHost(legacyPlainToolbar, true);
89
- element.append(legacyPlainToolbar);
89
+ scrollWrapper.append(legacyPlainToolbar);
90
90
  }
91
+ const legacyOuterRowToolbar = element.querySelector(":scope > .toolbar-row");
92
+ if (legacyOuterRowToolbar instanceof HTMLElement) scrollWrapper.append(legacyOuterRowToolbar);
91
93
  ensureToolbar(scrollWrapper, "toolbar-col", true);
92
- ensureToolbar(element, "toolbar-row", true);
94
+ ensureToolbar(scrollWrapper, "toolbar-row", true);
93
95
  ensureTableScrollIndicators(scrollWrapper);
94
96
  }
95
97
  function reconcileTableDecorator(editor, node, decorator) {
@@ -1,6 +1,6 @@
1
1
  import { useTranslation } from "../../../../editor-kernel/react/useTranslation.js";
2
2
  import { $canUnmerge, $selectLastDescendant, computeSelectionCount, currentCellBackgroundColor } from "./utils.js";
3
- import { Dropdown } from "@lobehub/ui";
3
+ import { DropdownMenu } from "@lobehub/ui";
4
4
  import { Grid2X2XIcon, PanelBottomCloseIcon, PanelLeftCloseIcon, PanelRightCloseIcon, PanelTopCloseIcon, TableColumnsSplitIcon, TableRowsSplitIcon } from "lucide-react";
5
5
  import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
6
6
  import { jsx } from "react/jsx-runtime";
@@ -221,8 +221,8 @@ const TableActionMenu = memo(({ editor, tableCellNode: _tableCellNode, cellMerge
221
221
  tableCellNode,
222
222
  clearTableSelection
223
223
  ]);
224
- return /* @__PURE__ */ jsx(Dropdown, {
225
- menu: { items: useMemo(() => {
224
+ return /* @__PURE__ */ jsx(DropdownMenu, {
225
+ items: useMemo(() => {
226
226
  return [
227
227
  {
228
228
  icon: PanelTopCloseIcon,
@@ -287,7 +287,7 @@ const TableActionMenu = memo(({ editor, tableCellNode: _tableCellNode, cellMerge
287
287
  renderDeleteMenuLabel,
288
288
  toggleTableRowIsHeader,
289
289
  toggleTableColumnIsHeader
290
- ]) },
290
+ ]),
291
291
  children
292
292
  });
293
293
  });
@@ -9,6 +9,7 @@ const styles = createStaticStyles(({ css, cssVar }) => css`
9
9
  .lobe-editor-table-scroll-wrapper {
10
10
  position: relative;
11
11
  overflow: auto visible;
12
+ margin-inline: calc(var(--lobe-block-anchor-padding, 54px) * -1);
12
13
  padding-block-start: 14px;
13
14
  }
14
15
 
@@ -62,6 +63,11 @@ const styles = createStaticStyles(({ css, cssVar }) => css`
62
63
  height: 0;
63
64
  }
64
65
 
66
+ .toolbar-col,
67
+ .toolbar-row {
68
+ inset-inline-start: var(--lobe-block-anchor-padding, 54px);
69
+ }
70
+
65
71
  .table-controller,
66
72
  .table-controller-col,
67
73
  .table-controller-row {
@@ -83,6 +89,7 @@ const styles = createStaticStyles(({ css, cssVar }) => css`
83
89
  border-collapse: collapse;
84
90
 
85
91
  width: fit-content;
92
+ margin-inline: var(--lobe-block-anchor-padding, 54px);
86
93
 
87
94
  text-align: start;
88
95
  text-indent: initial;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "4.17.0",
3
+ "version": "4.17.2",
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",