@lexical/table 0.8.0 → 0.9.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/LexicalTable.dev.js +361 -40
- package/LexicalTable.prod.js +3 -3
- package/LexicalTableCellNode.d.ts +2 -2
- package/LexicalTableNode.d.ts +1 -1
- package/LexicalTableRowNode.d.ts +2 -2
- package/package.json +3 -3
package/LexicalTable.prod.js
CHANGED
@@ -6,9 +6,9 @@
|
|
6
6
|
*/
|
7
7
|
'use strict';var d=require("lexical"),n=require("@lexical/utils");let q={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};
|
8
8
|
class r extends d.DEPRECATED_GridCellNode{static getType(){return"tablecell"}static clone(a){return new r(a.__headerState,a.__colSpan,a.__width,a.__key)}static importDOM(){return{td:()=>({conversion:x,priority:0}),th:()=>({conversion:x,priority:0})}}static importJSON(a){return z(a.headerState,a.colSpan,a.width||void 0)}constructor(a=q.NO_STATUS,b=1,e,h){super(b,h);this.__headerState=a;this.__width=e}createDOM(a){let b=document.createElement(this.getTag());this.__width&&(b.style.width=`${this.__width}px`);
|
9
|
-
n.addClassNamesToElement(b,a.theme.tableCell,this.hasHeader()&&a.theme.tableCellHeader);return b}exportDOM(a){({element:a}=super.exportDOM(a));if(a){let b=this.getParentOrThrow().getChildrenSize();a.style.border="1px solid black";a.style.width=`${this.getWidth()||Math.max(90,700/b)}px`;a.style.verticalAlign="top";
|
10
|
-
type:"tablecell",width:this.getWidth()}}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(a){this.getWritable().__headerState=a;return this.__headerState}getHeaderStyles(){return this.getLatest().__headerState}setWidth(a){this.getWritable().__width=a;return this.__width}getWidth(){return this.getLatest().__width}toggleHeaderStyle(a){let b=
|
11
|
-
a)===a}hasHeader(){return this.getLatest().__headerState!==q.NO_STATUS}updateDOM(a){return a.__headerState!==this.__headerState||a.__width!==this.__width}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}
|
9
|
+
1!==this.__colSpan&&(b.colSpan=this.__colSpan);1!==this.__rowSpan&&(b.rowSpan=this.__rowSpan);n.addClassNamesToElement(b,a.theme.tableCell,this.hasHeader()&&a.theme.tableCellHeader);return b}exportDOM(a){({element:a}=super.exportDOM(a));if(a){let b=this.getParentOrThrow().getChildrenSize();a.style.border="1px solid black";1!==this.__colSpan&&(a.colSpan=this.__colSpan);1!==this.__rowSpan&&(a.rowSpan=this.__rowSpan);a.style.width=`${this.getWidth()||Math.max(90,700/b)}px`;a.style.verticalAlign="top";
|
10
|
+
a.style.textAlign="start";this.hasHeader()&&(a.style.backgroundColor="#f2f3f5")}return{element:a}}exportJSON(){return{...super.exportJSON(),colSpan:super.__colSpan,headerState:this.__headerState,type:"tablecell",width:this.getWidth()}}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(a){this.getWritable().__headerState=a;return this.__headerState}getHeaderStyles(){return this.getLatest().__headerState}setWidth(a){this.getWritable().__width=a;return this.__width}getWidth(){return this.getLatest().__width}toggleHeaderStyle(a){let b=
|
11
|
+
this.getWritable();b.__headerState=(b.__headerState&a)===a?b.__headerState-a:b.__headerState+a;return b}hasHeaderState(a){return(this.getHeaderStyles()&a)===a}hasHeader(){return this.getLatest().__headerState!==q.NO_STATUS}updateDOM(a){return a.__headerState!==this.__headerState||a.__width!==this.__width||a.__colSpan!==this.__colSpan||a.__rowSpan!==this.__rowSpan}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}
|
12
12
|
function x(a){a=a.nodeName.toLowerCase();return{forChild:(b,e)=>{if(B(e)&&!d.$isElementNode(b)){e=d.$createParagraphNode();if(d.$isLineBreakNode(b)&&"\n"===b.getTextContent())return null;e.append(b);return e}return b},node:z("th"===a?q.ROW:q.NO_STATUS)}}function z(a,b=1,e){return d.$applyNodeReplacement(new r(a,b,e))}function B(a){return a instanceof r}
|
13
13
|
class C extends d.DEPRECATED_GridRowNode{static getType(){return"tablerow"}static clone(a){return new C(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:D,priority:0})}}static importJSON(a){return E(a.height)}constructor(a,b){super(b);this.__height=a}exportJSON(){return{...super.exportJSON(),type:"tablerow",version:1}}createDOM(a){let b=document.createElement("tr");this.__height&&(b.style.height=`${this.__height}px`);n.addClassNamesToElement(b,a.theme.tableRow);return b}isShadowRoot(){return!0}setHeight(a){this.getWritable().__height=
|
14
14
|
a;return this.__height}getHeight(){return this.getLatest().__height}updateDOM(a){return a.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function D(){return{node:E()}}function E(a){return d.$applyNodeReplacement(new C(a))}function F(a){return a instanceof C}function G(a){throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?code=${a} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
|
@@ -16,7 +16,7 @@ export declare const TableCellHeaderStates: {
|
|
16
16
|
export declare type TableCellHeaderState = typeof TableCellHeaderStates[keyof typeof TableCellHeaderStates];
|
17
17
|
export declare type SerializedTableCellNode = Spread<{
|
18
18
|
headerState: TableCellHeaderState;
|
19
|
-
type:
|
19
|
+
type: string;
|
20
20
|
width?: number;
|
21
21
|
}, SerializedGridCellNode>;
|
22
22
|
/** @noInheritDoc */
|
@@ -25,7 +25,7 @@ export declare class TableCellNode extends DEPRECATED_GridCellNode {
|
|
25
25
|
__headerState: TableCellHeaderState;
|
26
26
|
/** @internal */
|
27
27
|
__width?: number;
|
28
|
-
static getType():
|
28
|
+
static getType(): string;
|
29
29
|
static clone(node: TableCellNode): TableCellNode;
|
30
30
|
static importDOM(): DOMConversionMap | null;
|
31
31
|
static importJSON(serializedNode: SerializedTableCellNode): TableCellNode;
|
package/LexicalTableNode.d.ts
CHANGED
@@ -17,7 +17,7 @@ export declare type SerializedTableNode = Spread<{
|
|
17
17
|
export declare class TableNode extends DEPRECATED_GridNode {
|
18
18
|
/** @internal */
|
19
19
|
__grid?: Grid;
|
20
|
-
static getType():
|
20
|
+
static getType(): string;
|
21
21
|
static clone(node: TableNode): TableNode;
|
22
22
|
static importDOM(): DOMConversionMap | null;
|
23
23
|
static importJSON(_serializedNode: SerializedTableNode): TableNode;
|
package/LexicalTableRowNode.d.ts
CHANGED
@@ -9,14 +9,14 @@ import type { Spread } from 'lexical';
|
|
9
9
|
import { DEPRECATED_GridRowNode, DOMConversionMap, DOMConversionOutput, EditorConfig, LexicalNode, NodeKey, SerializedElementNode } from 'lexical';
|
10
10
|
export declare type SerializedTableRowNode = Spread<{
|
11
11
|
height: number;
|
12
|
-
type:
|
12
|
+
type: string;
|
13
13
|
version: 1;
|
14
14
|
}, SerializedElementNode>;
|
15
15
|
/** @noInheritDoc */
|
16
16
|
export declare class TableRowNode extends DEPRECATED_GridRowNode {
|
17
17
|
/** @internal */
|
18
18
|
__height?: number;
|
19
|
-
static getType():
|
19
|
+
static getType(): string;
|
20
20
|
static clone(node: TableRowNode): TableRowNode;
|
21
21
|
static importDOM(): DOMConversionMap | null;
|
22
22
|
static importJSON(serializedNode: SerializedTableRowNode): TableRowNode;
|
package/package.json
CHANGED
@@ -8,13 +8,13 @@
|
|
8
8
|
"table"
|
9
9
|
],
|
10
10
|
"license": "MIT",
|
11
|
-
"version": "0.
|
11
|
+
"version": "0.9.0",
|
12
12
|
"main": "LexicalTable.js",
|
13
13
|
"peerDependencies": {
|
14
|
-
"lexical": "0.
|
14
|
+
"lexical": "0.9.0"
|
15
15
|
},
|
16
16
|
"dependencies": {
|
17
|
-
"@lexical/utils": "0.
|
17
|
+
"@lexical/utils": "0.9.0"
|
18
18
|
},
|
19
19
|
"repository": {
|
20
20
|
"type": "git",
|