@tailor-cms/ce-table-manifest 0.0.1 → 0.0.3

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/dist/index.cjs CHANGED
@@ -27,37 +27,56 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
 
29
29
  // src/index.ts
30
- var src_exports = {};
31
- __export(src_exports, {
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
32
  Direction: () => Direction,
33
- default: () => src_default,
33
+ default: () => index_default,
34
34
  initState: () => initState,
35
35
  name: () => name,
36
36
  type: () => type,
37
+ utils: () => utils_exports,
37
38
  version: () => version
38
39
  });
39
- module.exports = __toCommonJS(src_exports);
40
+ module.exports = __toCommonJS(index_exports);
40
41
  var import_times = __toESM(require("lodash/times"), 1);
41
42
  var import_uuid = require("uuid");
42
43
 
43
44
  // src/utils.ts
45
+ var utils_exports = {};
46
+ __export(utils_exports, {
47
+ addCell: () => addCell,
48
+ addEmbed: () => addEmbed,
49
+ removeCell: () => removeCell,
50
+ removeEmbed: () => removeEmbed
51
+ });
44
52
  var import_find = __toESM(require("lodash/find"), 1);
45
53
  function addCell(row, cell) {
46
- if (!row.cells)
47
- row.cells = {};
54
+ if (!row.cells) row.cells = {};
48
55
  row.cells[cell.id] = cell;
49
56
  return cell;
50
57
  }
58
+ function removeCell(row, predicate = {}) {
59
+ const cell = (0, import_find.default)(row.cells, predicate);
60
+ if (!cell) return;
61
+ delete row.cells[cell.id];
62
+ return cell;
63
+ }
51
64
  function addEmbed(embeds, cellId, tableId) {
52
65
  const embed = {
53
66
  id: cellId,
54
- type: "TIPTAP_HTML",
67
+ type: "JODIT_HTML",
55
68
  embedded: true,
56
69
  data: { tableId, cellId }
57
70
  };
58
71
  embeds[cellId] = embed;
59
72
  return embed;
60
73
  }
74
+ function removeEmbed(embeds, predicate = {}) {
75
+ const embed = (0, import_find.default)(embeds, predicate);
76
+ if (!embed) return;
77
+ delete embeds[embed.id];
78
+ return embed;
79
+ }
61
80
 
62
81
  // src/interfaces.ts
63
82
  var Direction = /* @__PURE__ */ ((Direction2) => {
@@ -102,12 +121,13 @@ var manifest = {
102
121
  initState,
103
122
  ui
104
123
  };
105
- var src_default = manifest;
124
+ var index_default = manifest;
106
125
  // Annotate the CommonJS export names for ESM import in node:
107
126
  0 && (module.exports = {
108
127
  Direction,
109
128
  initState,
110
129
  name,
111
130
  type,
131
+ utils,
112
132
  version
113
133
  });
package/dist/index.d.cts CHANGED
@@ -67,10 +67,31 @@ interface ElementManifest {
67
67
  };
68
68
  }
69
69
 
70
+ declare function addCell(row: Row, cell: Cell): Cell;
71
+ declare function removeCell(row: Row, predicate?: {}): Cell;
72
+ declare function addEmbed(embeds: Embeds, cellId: string, tableId: string): {
73
+ id: string;
74
+ type: string;
75
+ embedded: boolean;
76
+ data: {
77
+ tableId: string;
78
+ cellId: string;
79
+ };
80
+ };
81
+ declare function removeEmbed(embeds: Embeds, predicate?: {}): any;
82
+
83
+ declare const utils_addCell: typeof addCell;
84
+ declare const utils_addEmbed: typeof addEmbed;
85
+ declare const utils_removeCell: typeof removeCell;
86
+ declare const utils_removeEmbed: typeof removeEmbed;
87
+ declare namespace utils {
88
+ export { utils_addCell as addCell, utils_addEmbed as addEmbed, utils_removeCell as removeCell, utils_removeEmbed as removeEmbed };
89
+ }
90
+
70
91
  declare const type = "TABLE";
71
92
  declare const name = "Table";
72
93
  declare const initState: DataInitializer;
73
94
  declare const version = "1.0";
74
95
  declare const manifest: ElementManifest;
75
96
 
76
- export { type Cell, type Cells, type DataInitializer, Direction, type Element, type ElementData, type ElementManifest, type Embed, type Embeds, type Row, type Rows, manifest as default, initState, name, type, version };
97
+ export { type Cell, type Cells, type DataInitializer, Direction, type Element, type ElementData, type ElementManifest, type Embed, type Embeds, type Row, type Rows, manifest as default, initState, name, type, utils, version };
package/dist/index.d.ts CHANGED
@@ -67,10 +67,31 @@ interface ElementManifest {
67
67
  };
68
68
  }
69
69
 
70
+ declare function addCell(row: Row, cell: Cell): Cell;
71
+ declare function removeCell(row: Row, predicate?: {}): Cell;
72
+ declare function addEmbed(embeds: Embeds, cellId: string, tableId: string): {
73
+ id: string;
74
+ type: string;
75
+ embedded: boolean;
76
+ data: {
77
+ tableId: string;
78
+ cellId: string;
79
+ };
80
+ };
81
+ declare function removeEmbed(embeds: Embeds, predicate?: {}): any;
82
+
83
+ declare const utils_addCell: typeof addCell;
84
+ declare const utils_addEmbed: typeof addEmbed;
85
+ declare const utils_removeCell: typeof removeCell;
86
+ declare const utils_removeEmbed: typeof removeEmbed;
87
+ declare namespace utils {
88
+ export { utils_addCell as addCell, utils_addEmbed as addEmbed, utils_removeCell as removeCell, utils_removeEmbed as removeEmbed };
89
+ }
90
+
70
91
  declare const type = "TABLE";
71
92
  declare const name = "Table";
72
93
  declare const initState: DataInitializer;
73
94
  declare const version = "1.0";
74
95
  declare const manifest: ElementManifest;
75
96
 
76
- export { type Cell, type Cells, type DataInitializer, Direction, type Element, type ElementData, type ElementManifest, type Embed, type Embeds, type Row, type Rows, manifest as default, initState, name, type, version };
97
+ export { type Cell, type Cells, type DataInitializer, Direction, type Element, type ElementData, type ElementManifest, type Embed, type Embeds, type Row, type Rows, manifest as default, initState, name, type, utils, version };
package/dist/index.js CHANGED
@@ -1,25 +1,49 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name2 in all)
4
+ __defProp(target, name2, { get: all[name2], enumerable: true });
5
+ };
6
+
1
7
  // src/index.ts
2
8
  import times from "lodash/times";
3
9
  import { v4 as uuid } from "uuid";
4
10
 
5
11
  // src/utils.ts
12
+ var utils_exports = {};
13
+ __export(utils_exports, {
14
+ addCell: () => addCell,
15
+ addEmbed: () => addEmbed,
16
+ removeCell: () => removeCell,
17
+ removeEmbed: () => removeEmbed
18
+ });
6
19
  import find from "lodash/find";
7
20
  function addCell(row, cell) {
8
- if (!row.cells)
9
- row.cells = {};
21
+ if (!row.cells) row.cells = {};
10
22
  row.cells[cell.id] = cell;
11
23
  return cell;
12
24
  }
25
+ function removeCell(row, predicate = {}) {
26
+ const cell = find(row.cells, predicate);
27
+ if (!cell) return;
28
+ delete row.cells[cell.id];
29
+ return cell;
30
+ }
13
31
  function addEmbed(embeds, cellId, tableId) {
14
32
  const embed = {
15
33
  id: cellId,
16
- type: "TIPTAP_HTML",
34
+ type: "JODIT_HTML",
17
35
  embedded: true,
18
36
  data: { tableId, cellId }
19
37
  };
20
38
  embeds[cellId] = embed;
21
39
  return embed;
22
40
  }
41
+ function removeEmbed(embeds, predicate = {}) {
42
+ const embed = find(embeds, predicate);
43
+ if (!embed) return;
44
+ delete embeds[embed.id];
45
+ return embed;
46
+ }
23
47
 
24
48
  // src/interfaces.ts
25
49
  var Direction = /* @__PURE__ */ ((Direction2) => {
@@ -64,12 +88,13 @@ var manifest = {
64
88
  initState,
65
89
  ui
66
90
  };
67
- var src_default = manifest;
91
+ var index_default = manifest;
68
92
  export {
69
93
  Direction,
70
- src_default as default,
94
+ index_default as default,
71
95
  initState,
72
96
  name,
73
97
  type,
98
+ utils_exports as utils,
74
99
  version
75
100
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Tailor CMS table manifest",
4
4
  "author": "Studion <info@gostudion.com> (https://github.com/tailor-cms)",
5
5
  "type": "module",
6
- "version": "0.0.1",
6
+ "version": "0.0.3",
7
7
  "exports": {
8
8
  ".": {
9
9
  "import": "./dist/index.js",
@@ -18,8 +18,8 @@
18
18
  "devDependencies": {
19
19
  "@tailor-cms/eslint-config": "0.0.2",
20
20
  "@types/lodash": "^4.17.14",
21
- "tsup": "^7.2.0",
22
- "typescript": "^5.1.6"
21
+ "tsup": "^8.3.6",
22
+ "typescript": "^5.7.3"
23
23
  },
24
24
  "dependencies": {
25
25
  "lodash": "^4.17.21",