@mnykj/wangeditoroptimize-table-module 1.0.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/README.md +3 -0
- package/dist/css/style.css +1 -0
- package/dist/index.esm.js +3389 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/table-module/src/constants/svg.d.ts +17 -0
- package/dist/table-module/src/index.d.ts +8 -0
- package/dist/table-module/src/locale/en.d.ts +17 -0
- package/dist/table-module/src/locale/index.d.ts +5 -0
- package/dist/table-module/src/locale/zh-CN.d.ts +17 -0
- package/dist/table-module/src/module/custom-types.d.ts +22 -0
- package/dist/table-module/src/module/elem-to-html.d.ts +21 -0
- package/dist/table-module/src/module/helpers.d.ts +22 -0
- package/dist/table-module/src/module/index.d.ts +7 -0
- package/dist/table-module/src/module/menu/DeleteCol.d.ts +15 -0
- package/dist/table-module/src/module/menu/DeleteRow.d.ts +15 -0
- package/dist/table-module/src/module/menu/DeleteTable.d.ts +15 -0
- package/dist/table-module/src/module/menu/FullWidth.d.ts +15 -0
- package/dist/table-module/src/module/menu/InsertCol.d.ts +15 -0
- package/dist/table-module/src/module/menu/InsertRow.d.ts +15 -0
- package/dist/table-module/src/module/menu/InsertTable.d.ts +24 -0
- package/dist/table-module/src/module/menu/TableHeader.d.ts +15 -0
- package/dist/table-module/src/module/menu/index.d.ts +44 -0
- package/dist/table-module/src/module/parse-elem-html.d.ts +24 -0
- package/dist/table-module/src/module/plugin.d.ts +7 -0
- package/dist/table-module/src/module/pre-parse-html.d.ts +15 -0
- package/dist/table-module/src/module/render-elem/index.d.ts +19 -0
- package/dist/table-module/src/module/render-elem/render-cell.d.ts +9 -0
- package/dist/table-module/src/module/render-elem/render-row.d.ts +9 -0
- package/dist/table-module/src/module/render-elem/render-table.d.ts +9 -0
- package/dist/table-module/src/utils/dom.d.ts +26 -0
- package/dist/table-module/src/utils/util.d.ts +10 -0
- package/package.json +52 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description icon svg
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 【注意】svg 字符串的长度 ,否则会导致代码体积过大
|
|
7
|
+
* 尽量选择 https://www.iconfont.cn/collections/detail?spm=a313x.7781069.0.da5a778a4&cid=20293
|
|
8
|
+
* 找不到再从 iconfont.com 搜索
|
|
9
|
+
*/
|
|
10
|
+
export declare const TABLE_SVG = "<svg viewBox=\"0 0 1024 1024\"><path d=\"M0 64v896h1024V64H0z m384 576v-192h256v192h-256z m256 64v192h-256v-192h256z m0-512v192h-256V192h256zM320 192v192H64V192h256z m-256 256h256v192H64v-192z m640 0h256v192h-256v-192z m0-64V192h256v192h-256zM64 704h256v192H64v-192z m640 192v-192h256v192h-256z\"></path></svg>";
|
|
11
|
+
export declare const TRASH_SVG = "<svg viewBox=\"0 0 1024 1024\"><path d=\"M826.8032 356.5312c-19.328 0-36.3776 15.6928-36.3776 35.0464v524.2624c0 19.328-16 34.56-35.328 34.56H264.9344c-19.328 0-35.5072-15.3088-35.5072-34.56V390.0416c0-19.328-14.1568-35.0464-33.5104-35.0464s-33.5104 15.6928-33.5104 35.0464V915.712c0 57.9328 44.6208 108.288 102.528 108.288H755.2c57.9328 0 108.0832-50.4576 108.0832-108.288V391.4752c-0.1024-19.2512-17.1264-34.944-36.48-34.944z\" p-id=\"9577\"></path><path d=\"M437.1712 775.7568V390.6048c0-19.328-14.1568-35.0464-33.5104-35.0464s-33.5104 15.616-33.5104 35.0464v385.152c0 19.328 14.1568 35.0464 33.5104 35.0464s33.5104-15.7184 33.5104-35.0464zM649.7024 775.7568V390.6048c0-19.328-17.0496-35.0464-36.3776-35.0464s-36.3776 15.616-36.3776 35.0464v385.152c0 19.328 17.0496 35.0464 36.3776 35.0464s36.3776-15.7184 36.3776-35.0464zM965.0432 217.0368h-174.6176V145.5104c0-57.9328-47.2064-101.76-104.6528-101.76h-350.976c-57.8304 0-105.3952 43.8528-105.3952 101.76v71.5264H54.784c-19.4304 0-35.0464 14.1568-35.0464 33.5104 0 19.328 15.616 33.5104 35.0464 33.5104h910.3616c19.328 0 35.0464-14.1568 35.0464-33.5104 0-19.3536-15.6928-33.5104-35.1488-33.5104z m-247.3728 0H297.3952V145.5104c0-19.328 18.2016-34.7648 37.4272-34.7648h350.976c19.1488 0 31.872 15.1296 31.872 34.7648v71.5264z\"></path></svg>";
|
|
12
|
+
export declare const ADD_ROW_SVG = "<svg viewBox=\"0 0 1048 1024\"><path d=\"M707.7888 521.0112h-147.456v-147.456H488.2432v147.456h-147.456v68.8128h147.456v147.456h72.0896v-147.456h147.456zM0 917.504V0h1048.576v917.504H0zM327.68 65.536H65.536v196.608H327.68V65.536z m327.68 0H393.216v196.608h262.144V65.536z m327.68 0h-262.144v196.608h262.144V65.536z m0 258.8672H65.536v462.0288H983.04V324.4032z\"></path></svg>";
|
|
13
|
+
export declare const DEL_ROW_SVG = "<svg viewBox=\"0 0 1048 1024\"><path d=\"M907.6736 586.5472L747.1104 425.984l163.84-163.84-78.6432-78.6432-163.84 163.84L507.904 186.7776 429.2608 262.144l163.84 163.84-167.1168 167.1168 78.6432 78.6432 167.1168-167.1168 160.5632 160.5632 75.3664-78.6432zM0 917.504V0h1048.576v917.504H0z m983.04-327.68h-22.9376l-65.536-65.536H983.04V327.68h-91.7504l65.536-65.536h26.2144V65.536H65.536v196.608h317.8496l65.536 65.536H65.536v196.608h380.1088l-65.536 65.536H65.536v196.608H983.04v-196.608z\"></path></svg>";
|
|
14
|
+
export declare const ADD_COL_SVG = "<svg viewBox=\"0 0 1048 1024\"><path d=\"M327.68 193.3312v186.7776H140.9024v91.7504H327.68v186.7776h88.4736V471.8592h190.0544V380.1088H416.1536V193.3312zM0 917.504V0h1048.576v917.504H0zM655.36 65.536H65.536v720.896H655.36V65.536z m327.68 0h-262.144v196.608h262.144V65.536z m0 262.144h-262.144v196.608h262.144V327.68z m0 262.144h-262.144v196.608h262.144v-196.608z\"></path></svg>";
|
|
15
|
+
export declare const DEL_COL_SVG = "<svg viewBox=\"0 0 1048 1024\"><path d=\"M327.68 510.976L393.216 445.44v-13.1072L327.68 366.7968V510.976z m327.68-78.4384l65.536-65.536V507.904L655.36 442.368v-9.8304z m393.216 484.9664V0H0v917.504h1048.576z m-65.536-131.072h-262.144v-52.4288l-13.1072 13.1072-52.4288-52.4288v91.7504H393.216v-91.7504l-52.4288 52.4288-13.1072-13.1072v52.4288H65.536V65.536H327.68v121.2416l36.0448-36.0448 29.4912 29.4912V62.2592h262.144V180.224l49.152-49.152 16.384 16.384V62.2592h262.144V786.432z m-294.912-108.1344l-160.5632-160.5632-167.1168 167.1168-78.6432-78.6432 167.1168-167.1168L288.3584 278.528l78.6432-78.6432 160.5632 160.5632 163.84-163.84 78.6432 78.6432-163.84 163.84 160.5632 160.5632-78.6432 78.6432z\"></path></svg>";
|
|
16
|
+
export declare const TABLE_HEADER_SVG = "<svg viewBox=\"0 0 1024 1024\"><path d=\"M704 128l-64 0L384 128 320 128 0 128l0 256 0 64 0 192 0 64 0 256 320 0 64 0 256 0 64 0 320 0 0-256 0-64L1024 448 1024 384 1024 128 704 128zM640 640 384 640 384 448l256 0L640 640zM64 448l256 0 0 192L64 640 64 448zM320 896 64 896l0-192 256 0L320 896zM640 896 384 896l0-192 256 0L640 896zM960 896l-256 0 0-192 256 0L960 896zM960 640l-256 0L704 448l256 0L960 640z\"></path></svg>";
|
|
17
|
+
export declare const FULL_WIDTH_SVG = "<svg viewBox=\"0 0 1228 1024\"><path d=\"M862.514337 563.200461H404.581995v121.753478a13.311987 13.311987 0 0 1-6.655993 11.468789 10.23999 10.23999 0 0 1-12.083188-1.433599l-204.799795-179.199821a13.721586 13.721586 0 0 1 0-20.479979l204.799795-179.302221a10.23999 10.23999 0 0 1 12.185588-1.535998 13.209587 13.209587 0 0 1 6.553593 11.673588v115.097485h457.932342V319.693504a11.571188 11.571188 0 0 1 18.841582-10.239989l204.799795 179.19982a13.721586 13.721586 0 0 1 0 20.47998l-204.799795 179.199821a10.23999 10.23999 0 0 1-12.185588 1.535998 13.311987 13.311987 0 0 1-6.655994-11.571188V563.200461zM136.499064 14.951409v993.893406a15.257585 15.257585 0 0 1-15.155185 15.052785H15.155185A15.155185 15.155185 0 0 1 0 1008.844815V14.951409a15.257585 15.257585 0 0 1 15.155185-15.052785h106.086294a15.155185 15.155185 0 0 1 15.257585 15.155185zM1228.798771 14.951409v993.893406a15.257585 15.257585 0 0 1-15.155185 15.052785h-106.188693a15.155185 15.155185 0 0 1-15.155185-15.052785V14.951409a15.257585 15.257585 0 0 1 15.155185-15.052785h106.086293A15.155185 15.155185 0 0 1 1228.798771 15.053809z\"></path></svg>";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description i18n en
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
declare const _default: {
|
|
6
|
+
tableModule: {
|
|
7
|
+
deleteCol: string;
|
|
8
|
+
deleteRow: string;
|
|
9
|
+
deleteTable: string;
|
|
10
|
+
widthAuto: string;
|
|
11
|
+
insertCol: string;
|
|
12
|
+
insertRow: string;
|
|
13
|
+
insertTable: string;
|
|
14
|
+
header: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description i18n zh-CN
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
declare const _default: {
|
|
6
|
+
tableModule: {
|
|
7
|
+
deleteCol: string;
|
|
8
|
+
deleteRow: string;
|
|
9
|
+
deleteTable: string;
|
|
10
|
+
widthAuto: string;
|
|
11
|
+
insertCol: string;
|
|
12
|
+
insertRow: string;
|
|
13
|
+
insertTable: string;
|
|
14
|
+
header: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 自定义 element
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { Text } from 'slate';
|
|
6
|
+
export declare type TableCellElement = {
|
|
7
|
+
type: 'table-cell';
|
|
8
|
+
isHeader?: boolean;
|
|
9
|
+
colSpan?: number;
|
|
10
|
+
rowSpan?: number;
|
|
11
|
+
width?: string;
|
|
12
|
+
children: Text[];
|
|
13
|
+
};
|
|
14
|
+
export declare type TableRowElement = {
|
|
15
|
+
type: 'table-row';
|
|
16
|
+
children: TableCellElement[];
|
|
17
|
+
};
|
|
18
|
+
export declare type TableElement = {
|
|
19
|
+
type: 'table';
|
|
20
|
+
width: string;
|
|
21
|
+
children: TableRowElement[];
|
|
22
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description to html
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { Element } from 'slate';
|
|
6
|
+
declare function tableToHtml(elemNode: Element, childrenHtml: string): string;
|
|
7
|
+
declare function tableRowToHtml(elem: Element, childrenHtml: string): string;
|
|
8
|
+
declare function tableCellToHtml(cellNode: Element, childrenHtml: string): string;
|
|
9
|
+
export declare const tableToHtmlConf: {
|
|
10
|
+
type: string;
|
|
11
|
+
elemToHtml: typeof tableToHtml;
|
|
12
|
+
};
|
|
13
|
+
export declare const tableRowToHtmlConf: {
|
|
14
|
+
type: string;
|
|
15
|
+
elemToHtml: typeof tableRowToHtml;
|
|
16
|
+
};
|
|
17
|
+
export declare const tableCellToHtmlConf: {
|
|
18
|
+
type: string;
|
|
19
|
+
elemToHtml: typeof tableCellToHtml;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description table menu helpers
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IDomEditor } from '@mnykj/wangeditoroptimize-core';
|
|
6
|
+
import { TableElement, TableCellElement } from './custom-types';
|
|
7
|
+
/**
|
|
8
|
+
* 获取第一行所有 cells
|
|
9
|
+
* @param tableNode table node
|
|
10
|
+
*/
|
|
11
|
+
export declare function getFirstRowCells(tableNode: TableElement): TableCellElement[];
|
|
12
|
+
/**
|
|
13
|
+
* 表格是否带有表头?
|
|
14
|
+
* @param tableNode table node
|
|
15
|
+
*/
|
|
16
|
+
export declare function isTableWithHeader(tableNode: TableElement): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 单元格是否在第一行
|
|
19
|
+
* @param editor editor
|
|
20
|
+
* @param cellNode cell node
|
|
21
|
+
*/
|
|
22
|
+
export declare function isCellInFirstRow(editor: IDomEditor, cellNode: TableCellElement): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description del col menu
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IButtonMenu, IDomEditor } from '@mnykj/wangeditoroptimize-core';
|
|
6
|
+
declare class DeleteCol implements IButtonMenu {
|
|
7
|
+
readonly title: string;
|
|
8
|
+
readonly iconSvg = "<svg viewBox=\"0 0 1048 1024\"><path d=\"M327.68 510.976L393.216 445.44v-13.1072L327.68 366.7968V510.976z m327.68-78.4384l65.536-65.536V507.904L655.36 442.368v-9.8304z m393.216 484.9664V0H0v917.504h1048.576z m-65.536-131.072h-262.144v-52.4288l-13.1072 13.1072-52.4288-52.4288v91.7504H393.216v-91.7504l-52.4288 52.4288-13.1072-13.1072v52.4288H65.536V65.536H327.68v121.2416l36.0448-36.0448 29.4912 29.4912V62.2592h262.144V180.224l49.152-49.152 16.384 16.384V62.2592h262.144V786.432z m-294.912-108.1344l-160.5632-160.5632-167.1168 167.1168-78.6432-78.6432 167.1168-167.1168L288.3584 278.528l78.6432-78.6432 160.5632 160.5632 163.84-163.84 78.6432 78.6432-163.84 163.84 160.5632 160.5632-78.6432 78.6432z\"></path></svg>";
|
|
9
|
+
readonly tag = "button";
|
|
10
|
+
getValue(editor: IDomEditor): string | boolean;
|
|
11
|
+
isActive(editor: IDomEditor): boolean;
|
|
12
|
+
isDisabled(editor: IDomEditor): boolean;
|
|
13
|
+
exec(editor: IDomEditor, value: string | boolean): void;
|
|
14
|
+
}
|
|
15
|
+
export default DeleteCol;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description del row menu
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IButtonMenu, IDomEditor } from '@mnykj/wangeditoroptimize-core';
|
|
6
|
+
declare class DeleteRow implements IButtonMenu {
|
|
7
|
+
readonly title: string;
|
|
8
|
+
readonly iconSvg = "<svg viewBox=\"0 0 1048 1024\"><path d=\"M907.6736 586.5472L747.1104 425.984l163.84-163.84-78.6432-78.6432-163.84 163.84L507.904 186.7776 429.2608 262.144l163.84 163.84-167.1168 167.1168 78.6432 78.6432 167.1168-167.1168 160.5632 160.5632 75.3664-78.6432zM0 917.504V0h1048.576v917.504H0z m983.04-327.68h-22.9376l-65.536-65.536H983.04V327.68h-91.7504l65.536-65.536h26.2144V65.536H65.536v196.608h317.8496l65.536 65.536H65.536v196.608h380.1088l-65.536 65.536H65.536v196.608H983.04v-196.608z\"></path></svg>";
|
|
9
|
+
readonly tag = "button";
|
|
10
|
+
getValue(editor: IDomEditor): string | boolean;
|
|
11
|
+
isActive(editor: IDomEditor): boolean;
|
|
12
|
+
isDisabled(editor: IDomEditor): boolean;
|
|
13
|
+
exec(editor: IDomEditor, value: string | boolean): void;
|
|
14
|
+
}
|
|
15
|
+
export default DeleteRow;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description del table menu
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IButtonMenu, IDomEditor } from '@mnykj/wangeditoroptimize-core';
|
|
6
|
+
declare class DeleteTable implements IButtonMenu {
|
|
7
|
+
readonly title: string;
|
|
8
|
+
readonly iconSvg = "<svg viewBox=\"0 0 1024 1024\"><path d=\"M826.8032 356.5312c-19.328 0-36.3776 15.6928-36.3776 35.0464v524.2624c0 19.328-16 34.56-35.328 34.56H264.9344c-19.328 0-35.5072-15.3088-35.5072-34.56V390.0416c0-19.328-14.1568-35.0464-33.5104-35.0464s-33.5104 15.6928-33.5104 35.0464V915.712c0 57.9328 44.6208 108.288 102.528 108.288H755.2c57.9328 0 108.0832-50.4576 108.0832-108.288V391.4752c-0.1024-19.2512-17.1264-34.944-36.48-34.944z\" p-id=\"9577\"></path><path d=\"M437.1712 775.7568V390.6048c0-19.328-14.1568-35.0464-33.5104-35.0464s-33.5104 15.616-33.5104 35.0464v385.152c0 19.328 14.1568 35.0464 33.5104 35.0464s33.5104-15.7184 33.5104-35.0464zM649.7024 775.7568V390.6048c0-19.328-17.0496-35.0464-36.3776-35.0464s-36.3776 15.616-36.3776 35.0464v385.152c0 19.328 17.0496 35.0464 36.3776 35.0464s36.3776-15.7184 36.3776-35.0464zM965.0432 217.0368h-174.6176V145.5104c0-57.9328-47.2064-101.76-104.6528-101.76h-350.976c-57.8304 0-105.3952 43.8528-105.3952 101.76v71.5264H54.784c-19.4304 0-35.0464 14.1568-35.0464 33.5104 0 19.328 15.616 33.5104 35.0464 33.5104h910.3616c19.328 0 35.0464-14.1568 35.0464-33.5104 0-19.3536-15.6928-33.5104-35.1488-33.5104z m-247.3728 0H297.3952V145.5104c0-19.328 18.2016-34.7648 37.4272-34.7648h350.976c19.1488 0 31.872 15.1296 31.872 34.7648v71.5264z\"></path></svg>";
|
|
9
|
+
readonly tag = "button";
|
|
10
|
+
getValue(editor: IDomEditor): string | boolean;
|
|
11
|
+
isActive(editor: IDomEditor): boolean;
|
|
12
|
+
isDisabled(editor: IDomEditor): boolean;
|
|
13
|
+
exec(editor: IDomEditor, value: string | boolean): void;
|
|
14
|
+
}
|
|
15
|
+
export default DeleteTable;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description table full width menu
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IButtonMenu, IDomEditor } from '@mnykj/wangeditoroptimize-core';
|
|
6
|
+
declare class TableFullWidth implements IButtonMenu {
|
|
7
|
+
readonly title: string;
|
|
8
|
+
readonly iconSvg = "<svg viewBox=\"0 0 1228 1024\"><path d=\"M862.514337 563.200461H404.581995v121.753478a13.311987 13.311987 0 0 1-6.655993 11.468789 10.23999 10.23999 0 0 1-12.083188-1.433599l-204.799795-179.199821a13.721586 13.721586 0 0 1 0-20.479979l204.799795-179.302221a10.23999 10.23999 0 0 1 12.185588-1.535998 13.209587 13.209587 0 0 1 6.553593 11.673588v115.097485h457.932342V319.693504a11.571188 11.571188 0 0 1 18.841582-10.239989l204.799795 179.19982a13.721586 13.721586 0 0 1 0 20.47998l-204.799795 179.199821a10.23999 10.23999 0 0 1-12.185588 1.535998 13.311987 13.311987 0 0 1-6.655994-11.571188V563.200461zM136.499064 14.951409v993.893406a15.257585 15.257585 0 0 1-15.155185 15.052785H15.155185A15.155185 15.155185 0 0 1 0 1008.844815V14.951409a15.257585 15.257585 0 0 1 15.155185-15.052785h106.086294a15.155185 15.155185 0 0 1 15.257585 15.155185zM1228.798771 14.951409v993.893406a15.257585 15.257585 0 0 1-15.155185 15.052785h-106.188693a15.155185 15.155185 0 0 1-15.155185-15.052785V14.951409a15.257585 15.257585 0 0 1 15.155185-15.052785h106.086293A15.155185 15.155185 0 0 1 1228.798771 15.053809z\"></path></svg>";
|
|
9
|
+
readonly tag = "button";
|
|
10
|
+
getValue(editor: IDomEditor): string | boolean;
|
|
11
|
+
isActive(editor: IDomEditor): boolean;
|
|
12
|
+
isDisabled(editor: IDomEditor): boolean;
|
|
13
|
+
exec(editor: IDomEditor, value: string | boolean): void;
|
|
14
|
+
}
|
|
15
|
+
export default TableFullWidth;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description insert col menu
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IButtonMenu, IDomEditor } from '@mnykj/wangeditoroptimize-core';
|
|
6
|
+
declare class InsertCol implements IButtonMenu {
|
|
7
|
+
readonly title: string;
|
|
8
|
+
readonly iconSvg = "<svg viewBox=\"0 0 1048 1024\"><path d=\"M327.68 193.3312v186.7776H140.9024v91.7504H327.68v186.7776h88.4736V471.8592h190.0544V380.1088H416.1536V193.3312zM0 917.504V0h1048.576v917.504H0zM655.36 65.536H65.536v720.896H655.36V65.536z m327.68 0h-262.144v196.608h262.144V65.536z m0 262.144h-262.144v196.608h262.144V327.68z m0 262.144h-262.144v196.608h262.144v-196.608z\"></path></svg>";
|
|
9
|
+
readonly tag = "button";
|
|
10
|
+
getValue(editor: IDomEditor): string | boolean;
|
|
11
|
+
isActive(editor: IDomEditor): boolean;
|
|
12
|
+
isDisabled(editor: IDomEditor): boolean;
|
|
13
|
+
exec(editor: IDomEditor, value: string | boolean): void;
|
|
14
|
+
}
|
|
15
|
+
export default InsertCol;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description insert row menu
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IButtonMenu, IDomEditor } from '@mnykj/wangeditoroptimize-core';
|
|
6
|
+
declare class InsertRow implements IButtonMenu {
|
|
7
|
+
readonly title: string;
|
|
8
|
+
readonly iconSvg = "<svg viewBox=\"0 0 1048 1024\"><path d=\"M707.7888 521.0112h-147.456v-147.456H488.2432v147.456h-147.456v68.8128h147.456v147.456h72.0896v-147.456h147.456zM0 917.504V0h1048.576v917.504H0zM327.68 65.536H65.536v196.608H327.68V65.536z m327.68 0H393.216v196.608h262.144V65.536z m327.68 0h-262.144v196.608h262.144V65.536z m0 258.8672H65.536v462.0288H983.04V324.4032z\"></path></svg>";
|
|
9
|
+
readonly tag = "button";
|
|
10
|
+
getValue(editor: IDomEditor): string | boolean;
|
|
11
|
+
isActive(editor: IDomEditor): boolean;
|
|
12
|
+
isDisabled(editor: IDomEditor): boolean;
|
|
13
|
+
exec(editor: IDomEditor, value: string | boolean): void;
|
|
14
|
+
}
|
|
15
|
+
export default InsertRow;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description insert table menu
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IDropPanelMenu, IDomEditor } from '@mnykj/wangeditoroptimize-core';
|
|
6
|
+
import { DOMElement } from '../../utils/dom';
|
|
7
|
+
declare class InsertTable implements IDropPanelMenu {
|
|
8
|
+
title: string;
|
|
9
|
+
iconSvg: string;
|
|
10
|
+
tag: string;
|
|
11
|
+
showDropPanel: boolean;
|
|
12
|
+
private $content;
|
|
13
|
+
getValue(editor: IDomEditor): string | boolean;
|
|
14
|
+
isActive(editor: IDomEditor): boolean;
|
|
15
|
+
exec(editor: IDomEditor, value: string | boolean): void;
|
|
16
|
+
isDisabled(editor: IDomEditor): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 获取 panel 内容
|
|
19
|
+
* @param editor editor
|
|
20
|
+
*/
|
|
21
|
+
getPanelContentElem(editor: IDomEditor): DOMElement;
|
|
22
|
+
private insertTable;
|
|
23
|
+
}
|
|
24
|
+
export default InsertTable;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description table header menu
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IButtonMenu, IDomEditor } from '@mnykj/wangeditoroptimize-core';
|
|
6
|
+
declare class TableHeader implements IButtonMenu {
|
|
7
|
+
readonly title: string;
|
|
8
|
+
readonly iconSvg = "<svg viewBox=\"0 0 1024 1024\"><path d=\"M704 128l-64 0L384 128 320 128 0 128l0 256 0 64 0 192 0 64 0 256 320 0 64 0 256 0 64 0 320 0 0-256 0-64L1024 448 1024 384 1024 128 704 128zM640 640 384 640 384 448l256 0L640 640zM64 448l256 0 0 192L64 640 64 448zM320 896 64 896l0-192 256 0L320 896zM640 896 384 896l0-192 256 0L640 896zM960 896l-256 0 0-192 256 0L960 896zM960 640l-256 0L704 448l256 0L960 640z\"></path></svg>";
|
|
9
|
+
readonly tag = "button";
|
|
10
|
+
getValue(editor: IDomEditor): string | boolean;
|
|
11
|
+
isActive(editor: IDomEditor): boolean;
|
|
12
|
+
isDisabled(editor: IDomEditor): boolean;
|
|
13
|
+
exec(editor: IDomEditor, value: string | boolean): void;
|
|
14
|
+
}
|
|
15
|
+
export default TableHeader;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description table menu
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import InsertTable from './InsertTable';
|
|
6
|
+
import DeleteTable from './DeleteTable';
|
|
7
|
+
import InsertRow from './InsertRow';
|
|
8
|
+
import DeleteRow from './DeleteRow';
|
|
9
|
+
import InsertCol from './InsertCol';
|
|
10
|
+
import DeleteCol from './DeleteCol';
|
|
11
|
+
import TableHander from './TableHeader';
|
|
12
|
+
import FullWidth from './FullWidth';
|
|
13
|
+
export declare const insertTableMenuConf: {
|
|
14
|
+
key: string;
|
|
15
|
+
factory(): InsertTable;
|
|
16
|
+
};
|
|
17
|
+
export declare const deleteTableMenuConf: {
|
|
18
|
+
key: string;
|
|
19
|
+
factory(): DeleteTable;
|
|
20
|
+
};
|
|
21
|
+
export declare const insertTableRowConf: {
|
|
22
|
+
key: string;
|
|
23
|
+
factory(): InsertRow;
|
|
24
|
+
};
|
|
25
|
+
export declare const deleteTableRowConf: {
|
|
26
|
+
key: string;
|
|
27
|
+
factory(): DeleteRow;
|
|
28
|
+
};
|
|
29
|
+
export declare const insertTableColConf: {
|
|
30
|
+
key: string;
|
|
31
|
+
factory(): InsertCol;
|
|
32
|
+
};
|
|
33
|
+
export declare const deleteTableColConf: {
|
|
34
|
+
key: string;
|
|
35
|
+
factory(): DeleteCol;
|
|
36
|
+
};
|
|
37
|
+
export declare const tableHeaderMenuConf: {
|
|
38
|
+
key: string;
|
|
39
|
+
factory(): TableHander;
|
|
40
|
+
};
|
|
41
|
+
export declare const tableFullWidthMenuConf: {
|
|
42
|
+
key: string;
|
|
43
|
+
factory(): FullWidth;
|
|
44
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description parse html
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { Descendant } from 'slate';
|
|
6
|
+
import { IDomEditor } from '@mnykj/wangeditoroptimize-core';
|
|
7
|
+
import { TableCellElement, TableRowElement, TableElement } from './custom-types';
|
|
8
|
+
import { DOMElement } from '../utils/dom';
|
|
9
|
+
declare function parseCellHtml(elem: DOMElement, children: Descendant[], editor: IDomEditor): TableCellElement;
|
|
10
|
+
export declare const parseCellHtmlConf: {
|
|
11
|
+
selector: string;
|
|
12
|
+
parseElemHtml: typeof parseCellHtml;
|
|
13
|
+
};
|
|
14
|
+
declare function parseRowHtml(elem: DOMElement, children: Descendant[], editor: IDomEditor): TableRowElement;
|
|
15
|
+
export declare const parseRowHtmlConf: {
|
|
16
|
+
selector: string;
|
|
17
|
+
parseElemHtml: typeof parseRowHtml;
|
|
18
|
+
};
|
|
19
|
+
declare function parseTableHtml(elem: DOMElement, children: Descendant[], editor: IDomEditor): TableElement;
|
|
20
|
+
export declare const parseTableHtmlConf: {
|
|
21
|
+
selector: string;
|
|
22
|
+
parseElemHtml: typeof parseTableHtml;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description pre parse html
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { DOMElement } from '../utils/dom';
|
|
6
|
+
/**
|
|
7
|
+
* pre-prase table ,去掉 <tbody>
|
|
8
|
+
* @param table table elem
|
|
9
|
+
*/
|
|
10
|
+
declare function preParse(tableElem: DOMElement): DOMElement;
|
|
11
|
+
export declare const preParseTableHtmlConf: {
|
|
12
|
+
selector: string;
|
|
13
|
+
preParseHtml: typeof preParse;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description render elem
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import renderTable from './render-table';
|
|
6
|
+
import renderTableRow from './render-row';
|
|
7
|
+
import renderTableCell from './render-cell';
|
|
8
|
+
export declare const renderTableConf: {
|
|
9
|
+
type: string;
|
|
10
|
+
renderElem: typeof renderTable;
|
|
11
|
+
};
|
|
12
|
+
export declare const renderTableRowConf: {
|
|
13
|
+
type: string;
|
|
14
|
+
renderElem: typeof renderTableRow;
|
|
15
|
+
};
|
|
16
|
+
export declare const renderTableCellConf: {
|
|
17
|
+
type: string;
|
|
18
|
+
renderElem: typeof renderTableCell;
|
|
19
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description render cell
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { Element as SlateElement } from 'slate';
|
|
6
|
+
import { VNode } from 'snabbdom';
|
|
7
|
+
import { IDomEditor } from '@mnykj/wangeditoroptimize-core';
|
|
8
|
+
declare function renderTableCell(cellNode: SlateElement, children: VNode[] | null, editor: IDomEditor): VNode;
|
|
9
|
+
export default renderTableCell;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description render row
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { Element as SlateElement } from 'slate';
|
|
6
|
+
import { VNode } from 'snabbdom';
|
|
7
|
+
import { IDomEditor } from '@mnykj/wangeditoroptimize-core';
|
|
8
|
+
declare function renderTableRow(elemNode: SlateElement, children: VNode[] | null, editor: IDomEditor): VNode;
|
|
9
|
+
export default renderTableRow;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description render table with top toolbar
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { Element as SlateElement } from 'slate';
|
|
6
|
+
import { VNode } from 'snabbdom';
|
|
7
|
+
import { IDomEditor } from '@mnykj/wangeditoroptimize-core';
|
|
8
|
+
declare function renderTable(elemNode: SlateElement, children: VNode[] | null, editor: IDomEditor): VNode;
|
|
9
|
+
export default renderTable;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description DOM 操作
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import $, { Dom7Array } from 'dom7';
|
|
6
|
+
export { Dom7Array } from 'dom7';
|
|
7
|
+
export default $;
|
|
8
|
+
/**
|
|
9
|
+
* 获取 tagName lower-case
|
|
10
|
+
* @param $elem $elem
|
|
11
|
+
*/
|
|
12
|
+
export declare function getTagName($elem: Dom7Array): string;
|
|
13
|
+
/**
|
|
14
|
+
* 获取 $elem 某一个 style 值
|
|
15
|
+
* @param $elem $elem
|
|
16
|
+
* @param styleKey style key
|
|
17
|
+
*/
|
|
18
|
+
export declare function getStyleValue($elem: Dom7Array, styleKey: string): string;
|
|
19
|
+
import DOMNode = globalThis.Node;
|
|
20
|
+
import DOMComment = globalThis.Comment;
|
|
21
|
+
import DOMElement = globalThis.Element;
|
|
22
|
+
import DOMText = globalThis.Text;
|
|
23
|
+
import DOMRange = globalThis.Range;
|
|
24
|
+
import DOMSelection = globalThis.Selection;
|
|
25
|
+
import DOMStaticRange = globalThis.StaticRange;
|
|
26
|
+
export { DOMNode, DOMComment, DOMElement, DOMText, DOMRange, DOMSelection, DOMStaticRange };
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mnykj/wangeditoroptimize-table-module",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "wangEditor table module",
|
|
5
|
+
"author": "wangfupeng1988 <wangfupeng1988@163.com>",
|
|
6
|
+
"contributors": [],
|
|
7
|
+
"homepage": "https://github.com/wangeditor-team/wangEditor#readme",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"types": "dist/table-module/src/index.d.ts",
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"module": "dist/index.esm.js",
|
|
12
|
+
"browser": {
|
|
13
|
+
"./dist/index.js": "./dist/index.js",
|
|
14
|
+
"./dist/index.esm.js": "./dist/index.esm.js"
|
|
15
|
+
},
|
|
16
|
+
"directories": {
|
|
17
|
+
"lib": "dist",
|
|
18
|
+
"test": "__tests__"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public",
|
|
25
|
+
"registry": "https://registry.npmjs.org/"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/wangeditor-team/wangEditor.git"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"test": "jest",
|
|
33
|
+
"test-c": "jest --coverage",
|
|
34
|
+
"dev": "cross-env NODE_ENV=development rollup -c rollup.config.js",
|
|
35
|
+
"dev-watch": "cross-env NODE_ENV=development rollup -c rollup.config.js -w",
|
|
36
|
+
"build": "cross-env NODE_ENV=production rollup -c rollup.config.js",
|
|
37
|
+
"dev-size-stats": "cross-env NODE_ENV=development:size_stats rollup -c rollup.config.js",
|
|
38
|
+
"size-stats": "cross-env NODE_ENV=production:size_stats rollup -c rollup.config.js"
|
|
39
|
+
},
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/wangeditor-team/wangEditor/issues"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@mnykj/wangeditoroptimize-core": "^1.0.0",
|
|
45
|
+
"dom7": "^3.0.0",
|
|
46
|
+
"lodash.isequal": "^4.5.0",
|
|
47
|
+
"lodash.throttle": "^4.1.1",
|
|
48
|
+
"nanoid": "^3.2.0",
|
|
49
|
+
"slate": "^0.72.0",
|
|
50
|
+
"snabbdom": "^3.1.0"
|
|
51
|
+
}
|
|
52
|
+
}
|