forked from SparkDevNetwork/Rock
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtable.ts
More file actions
32 lines (28 loc) · 1.08 KB
/
table.ts
File metadata and controls
32 lines (28 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { BlockToolConstructorOptions } from "@editorjs/editorjs";
import EditorTable, { TableData, TableConfig as EditorTableConfig } from "./vendor/table/src/plugin"
interface TableConfig extends EditorTableConfig {
/** True if a new table should have headings enabled. */
defaultHeadings?: boolean;
}
/**
* Custom implementation of the Table block.
*/
export class Table extends EditorTable {
constructor(config: BlockToolConstructorOptions<TableData, TableConfig>) {
config.data = config.data || {};
if (config.data.withHeadings === undefined && config.data.content === undefined) {
config.data.withHeadings = config.config?.defaultHeadings ?? false;
}
super(config);
}
/**
* Checks if the block's save data should be included in the structured
* content stream.
*
* @param savedData The data that was returned by the save method.
* @returns true if the block's contents should be included in the save data.
*/
public validate(savedData: TableData) {
return savedData.content.length > 0;
}
}