@lexical/react 0.38.3-nightly.20251111.0 → 0.38.3-nightly.20251113.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/LexicalTablePlugin.d.ts
CHANGED
|
@@ -24,6 +24,12 @@ export interface TablePluginProps {
|
|
|
24
24
|
* When `true` (default `false`), tables will be wrapped in a `<div>` to enable horizontal scrolling
|
|
25
25
|
*/
|
|
26
26
|
hasHorizontalScroll?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* When `true` (default `false`), nested tables will be allowed.
|
|
29
|
+
*
|
|
30
|
+
* @experimental Nested tables are not officially supported.
|
|
31
|
+
*/
|
|
32
|
+
hasNestedTables?: boolean;
|
|
27
33
|
}
|
|
28
34
|
/**
|
|
29
35
|
* A plugin to enable all of the features of Lexical's TableNode.
|
|
@@ -31,4 +37,4 @@ export interface TablePluginProps {
|
|
|
31
37
|
* @param props - See type for documentation
|
|
32
38
|
* @returns An element to render in your LexicalComposer
|
|
33
39
|
*/
|
|
34
|
-
export declare function TablePlugin({ hasCellMerge, hasCellBackgroundColor, hasTabHandler, hasHorizontalScroll, }: TablePluginProps): JSX.Element | null;
|
|
40
|
+
export declare function TablePlugin({ hasCellMerge, hasCellBackgroundColor, hasTabHandler, hasHorizontalScroll, hasNestedTables, }: TablePluginProps): JSX.Element | null;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
11
|
+
var extension = require('@lexical/extension');
|
|
11
12
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
12
13
|
var table = require('@lexical/table');
|
|
13
14
|
var react = require('react');
|
|
@@ -30,7 +31,8 @@ function TablePlugin({
|
|
|
30
31
|
hasCellMerge = true,
|
|
31
32
|
hasCellBackgroundColor = true,
|
|
32
33
|
hasTabHandler = true,
|
|
33
|
-
hasHorizontalScroll = false
|
|
34
|
+
hasHorizontalScroll = false,
|
|
35
|
+
hasNestedTables = false
|
|
34
36
|
}) {
|
|
35
37
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
36
38
|
react.useEffect(() => {
|
|
@@ -42,7 +44,13 @@ function TablePlugin({
|
|
|
42
44
|
editor.registerNodeTransform(table.TableNode, () => {})();
|
|
43
45
|
}
|
|
44
46
|
}, [editor, hasHorizontalScroll]);
|
|
45
|
-
react.
|
|
47
|
+
const hasNestedTablesSignal = react.useMemo(() => extension.signal(false), []);
|
|
48
|
+
if (hasNestedTablesSignal.peek() !== hasNestedTables) {
|
|
49
|
+
hasNestedTablesSignal.value = hasNestedTables;
|
|
50
|
+
}
|
|
51
|
+
react.useEffect(() => table.registerTablePlugin(editor, {
|
|
52
|
+
hasNestedTables: hasNestedTablesSignal
|
|
53
|
+
}), [editor, hasNestedTablesSignal]);
|
|
46
54
|
react.useEffect(() => table.registerTableSelectionObserver(editor, hasTabHandler), [editor, hasTabHandler]);
|
|
47
55
|
|
|
48
56
|
// Unmerge cells when the feature isn't enabled
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { signal } from '@lexical/extension';
|
|
9
10
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
10
11
|
import { $isScrollableTablesActive, setScrollableTablesActive, TableNode, registerTablePlugin, registerTableSelectionObserver, registerTableCellUnmergeTransform, TableCellNode } from '@lexical/table';
|
|
11
|
-
import { useEffect } from 'react';
|
|
12
|
+
import { useEffect, useMemo } from 'react';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -28,7 +29,8 @@ function TablePlugin({
|
|
|
28
29
|
hasCellMerge = true,
|
|
29
30
|
hasCellBackgroundColor = true,
|
|
30
31
|
hasTabHandler = true,
|
|
31
|
-
hasHorizontalScroll = false
|
|
32
|
+
hasHorizontalScroll = false,
|
|
33
|
+
hasNestedTables = false
|
|
32
34
|
}) {
|
|
33
35
|
const [editor] = useLexicalComposerContext();
|
|
34
36
|
useEffect(() => {
|
|
@@ -40,7 +42,13 @@ function TablePlugin({
|
|
|
40
42
|
editor.registerNodeTransform(TableNode, () => {})();
|
|
41
43
|
}
|
|
42
44
|
}, [editor, hasHorizontalScroll]);
|
|
43
|
-
|
|
45
|
+
const hasNestedTablesSignal = useMemo(() => signal(false), []);
|
|
46
|
+
if (hasNestedTablesSignal.peek() !== hasNestedTables) {
|
|
47
|
+
hasNestedTablesSignal.value = hasNestedTables;
|
|
48
|
+
}
|
|
49
|
+
useEffect(() => registerTablePlugin(editor, {
|
|
50
|
+
hasNestedTables: hasNestedTablesSignal
|
|
51
|
+
}), [editor, hasNestedTablesSignal]);
|
|
44
52
|
useEffect(() => registerTableSelectionObserver(editor, hasTabHandler), [editor, hasTabHandler]);
|
|
45
53
|
|
|
46
54
|
// Unmerge cells when the feature isn't enabled
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";var e=require("@lexical/react/LexicalComposerContext"),
|
|
9
|
+
"use strict";var e=require("@lexical/extension"),r=require("@lexical/react/LexicalComposerContext"),l=require("@lexical/table"),s=require("react");exports.TablePlugin=function({hasCellMerge:a=!0,hasCellBackgroundColor:t=!0,hasTabHandler:o=!0,hasHorizontalScroll:i=!1,hasNestedTables:n=!1}){const[c]=r.useLexicalComposerContext();s.useEffect(()=>{l.$isScrollableTablesActive(c)!==i&&(l.setScrollableTablesActive(c,i),c.registerNodeTransform(l.TableNode,()=>{})())},[c,i]);const u=s.useMemo(()=>e.signal(!1),[]);return u.peek()!==n&&(u.value=n),s.useEffect(()=>l.registerTablePlugin(c,{hasNestedTables:u}),[c,u]),s.useEffect(()=>l.registerTableSelectionObserver(c,o),[c,o]),s.useEffect(()=>{if(!a)return l.registerTableCellUnmergeTransform(c)},[c,a]),s.useEffect(()=>{if(!t)return c.registerNodeTransform(l.TableCellNode,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})},[c,t,a]),null};
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{useLexicalComposerContext as r}from"@lexical/react/LexicalComposerContext";import{$isScrollableTablesActive as o,setScrollableTablesActive as
|
|
9
|
+
import{signal as e}from"@lexical/extension";import{useLexicalComposerContext as r}from"@lexical/react/LexicalComposerContext";import{$isScrollableTablesActive as o,setScrollableTablesActive as l,TableNode as a,registerTablePlugin as t,registerTableSelectionObserver as n,registerTableCellUnmergeTransform as s,TableCellNode as i}from"@lexical/table";import{useEffect as c,useMemo as m}from"react";function u({hasCellMerge:u=!0,hasCellBackgroundColor:f=!0,hasTabHandler:d=!0,hasHorizontalScroll:g=!1,hasNestedTables:p=!1}){const[x]=r();c(()=>{o(x)!==g&&(l(x,g),x.registerNodeTransform(a,()=>{})())},[x,g]);const C=m(()=>e(!1),[]);return C.peek()!==p&&(C.value=p),c(()=>t(x,{hasNestedTables:C}),[x,C]),c(()=>n(x,d),[x,d]),c(()=>{if(!u)return s(x)},[x,u]),c(()=>{if(!f)return x.registerNodeTransform(i,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})},[x,f,u]),null}export{u as TablePlugin};
|
package/package.json
CHANGED
|
@@ -8,26 +8,26 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.38.3-nightly.
|
|
11
|
+
"version": "0.38.3-nightly.20251113.0",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@floating-ui/react": "^0.27.16",
|
|
14
|
-
"@lexical/devtools-core": "0.38.3-nightly.
|
|
15
|
-
"@lexical/dragon": "0.38.3-nightly.
|
|
16
|
-
"@lexical/extension": "0.38.3-nightly.
|
|
17
|
-
"@lexical/hashtag": "0.38.3-nightly.
|
|
18
|
-
"@lexical/history": "0.38.3-nightly.
|
|
19
|
-
"@lexical/link": "0.38.3-nightly.
|
|
20
|
-
"@lexical/list": "0.38.3-nightly.
|
|
21
|
-
"@lexical/mark": "0.38.3-nightly.
|
|
22
|
-
"@lexical/markdown": "0.38.3-nightly.
|
|
23
|
-
"@lexical/overflow": "0.38.3-nightly.
|
|
24
|
-
"@lexical/plain-text": "0.38.3-nightly.
|
|
25
|
-
"@lexical/rich-text": "0.38.3-nightly.
|
|
26
|
-
"@lexical/table": "0.38.3-nightly.
|
|
27
|
-
"@lexical/text": "0.38.3-nightly.
|
|
28
|
-
"@lexical/utils": "0.38.3-nightly.
|
|
29
|
-
"@lexical/yjs": "0.38.3-nightly.
|
|
30
|
-
"lexical": "0.38.3-nightly.
|
|
14
|
+
"@lexical/devtools-core": "0.38.3-nightly.20251113.0",
|
|
15
|
+
"@lexical/dragon": "0.38.3-nightly.20251113.0",
|
|
16
|
+
"@lexical/extension": "0.38.3-nightly.20251113.0",
|
|
17
|
+
"@lexical/hashtag": "0.38.3-nightly.20251113.0",
|
|
18
|
+
"@lexical/history": "0.38.3-nightly.20251113.0",
|
|
19
|
+
"@lexical/link": "0.38.3-nightly.20251113.0",
|
|
20
|
+
"@lexical/list": "0.38.3-nightly.20251113.0",
|
|
21
|
+
"@lexical/mark": "0.38.3-nightly.20251113.0",
|
|
22
|
+
"@lexical/markdown": "0.38.3-nightly.20251113.0",
|
|
23
|
+
"@lexical/overflow": "0.38.3-nightly.20251113.0",
|
|
24
|
+
"@lexical/plain-text": "0.38.3-nightly.20251113.0",
|
|
25
|
+
"@lexical/rich-text": "0.38.3-nightly.20251113.0",
|
|
26
|
+
"@lexical/table": "0.38.3-nightly.20251113.0",
|
|
27
|
+
"@lexical/text": "0.38.3-nightly.20251113.0",
|
|
28
|
+
"@lexical/utils": "0.38.3-nightly.20251113.0",
|
|
29
|
+
"@lexical/yjs": "0.38.3-nightly.20251113.0",
|
|
30
|
+
"lexical": "0.38.3-nightly.20251113.0",
|
|
31
31
|
"react-error-boundary": "^6.0.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|