xmlui 0.9.78 → 0.9.79

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.
@@ -145,7 +145,11 @@ const build = (_a) => __awaiter(void 0, [_a], void 0, function* ({ buildMode = "
145
145
  "process.env.VITE_USED_COMPONENTS_Fragment": JSON.stringify(process.env.VITE_USED_COMPONENTS_Fragment),
146
146
  "process.env.VITE_USED_COMPONENTS_Table": JSON.stringify(process.env.VITE_USED_COMPONENTS_Table),
147
147
  "process.env.VITE_USED_COMPONENTS_List": JSON.stringify(process.env.VITE_USED_COMPONENTS_List),
148
- "process.env.VITE_USED_COMPONENTS_DateRangePicker": JSON.stringify(process.env.VITE_USED_COMPONENTS_DateRangePicker),
148
+ "process.env.VITE_USED_COMPONENTS_XmluiCodeHightlighter": JSON.stringify(process.env.VITE_USED_COMPONENTS_XmluiCodeHightlighter),
149
+ "process.env.VITE_USED_COMPONENTS_HelloWorld": JSON.stringify(process.env.VITE_USED_COMPONENTS_HelloWorld),
150
+ "process.env.VITE_USED_COMPONENTS_Charts": JSON.stringify(process.env.VITE_USED_COMPONENTS_Charts),
151
+ "process.env.VITE_INCLUDE_HTML_COMPONENTS": JSON.stringify(process.env.VITE_INCLUDE_HTML_COMPONENTS),
152
+ "process.env.VITE_USED_COMPONENTS_TableEditor": JSON.stringify(process.env.VITE_USED_COMPONENTS_TableEditor),
149
153
  "process.env.VITE_USED_COMPONENTS_DatePicker": JSON.stringify(process.env.VITE_USED_COMPONENTS_DatePicker),
150
154
  "process.env.VITE_USED_COMPONENTS_NavPanel": JSON.stringify(process.env.VITE_USED_COMPONENTS_NavPanel),
151
155
  "process.env.VITE_USED_COMPONENTS_Pages": JSON.stringify(process.env.VITE_USED_COMPONENTS_Pages),
@@ -162,6 +166,7 @@ const build = (_a) => __awaiter(void 0, [_a], void 0, function* ({ buildMode = "
162
166
  "process.env.VITE_USED_COMPONENTS_Items": JSON.stringify(process.env.VITE_USED_COMPONENTS_Items),
163
167
  "process.env.VITE_USED_COMPONENTS_SelectionStore": JSON.stringify(process.env.VITE_USED_COMPONENTS_SelectionStore),
164
168
  "process.env.VITE_INCLUDE_REST_COMPONENTS": JSON.stringify(process.env.VITE_INCLUDE_REST_COMPONENTS),
169
+ "process.env.VITE_USED_COMPONENTS_EmojiSelector": JSON.stringify(process.env.VITE_USED_COMPONENTS_EmojiSelector),
165
170
  } }));
166
171
  if (buildMode === "INLINE_ALL") {
167
172
  return;
@@ -34,8 +34,8 @@ function zipDirectory(sourceDir_1) {
34
34
  });
35
35
  }
36
36
  function zipDist(_a) {
37
- return __awaiter(this, arguments, void 0, function* ({ target = "ui.zip" }) {
38
- yield zipDirectory(process.cwd() + "/dist", `${process.cwd()}/${target}`);
37
+ return __awaiter(this, arguments, void 0, function* ({ target = "ui.zip", source = "dist" }) {
38
+ yield zipDirectory(`${process.cwd()}/${source}`, `${process.cwd()}/${target}`);
39
39
  });
40
40
  }
41
41
  function dedupeArg(arg) {
@@ -84,8 +84,8 @@ switch (script) {
84
84
  break;
85
85
  }
86
86
  case "zip-dist": {
87
- const { target } = yargs_1.argv;
88
- zipDist({ target });
87
+ const { target, source } = yargs_1.argv;
88
+ zipDist({ target, source });
89
89
  break;
90
90
  }
91
91
  default: {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmlui",
3
- "version": "0.9.78",
3
+ "version": "0.9.79",
4
4
  "sideEffects": false,
5
5
  "scripts": {
6
6
  "start-test-bed": "cd src/testing/infrastructure && xmlui start",
@@ -377,6 +377,12 @@ class ComponentRegistry {
377
377
  this.registerCoreComponent(LineChart_1.lineChartComponentRenderer);
378
378
  this.registerCoreComponent(PieChart_1.pieChartComponentRenderer);
379
379
  }
380
+ if (process.env.VITE_USED_COMPONENTS_EmojiSelector !== "false") {
381
+ this.registerCoreComponent(EmojiSelector_1.emojiSelectorRenderer);
382
+ }
383
+ if (process.env.VITE_USED_COMPONENTS_DatePicker !== "false") {
384
+ this.registerCoreComponent(DatePicker_1.datePickerComponentRenderer);
385
+ }
380
386
  if (process.env.VITE_INCLUDE_REST_COMPONENTS !== "false") {
381
387
  //TODO, if it proves to be a working solution, make these components skippable, too
382
388
  this.registerCoreComponent(PageMetaTitle_1.pageMetaTitleComponentRenderer);
@@ -390,13 +396,11 @@ class ComponentRegistry {
390
396
  this.registerCoreComponent(RealTimeAdapter_1.realTimeAdapterComponentRenderer);
391
397
  this.registerCoreComponent(TextBox_1.textBoxComponentRenderer);
392
398
  this.registerCoreComponent(TextBox_1.passwordInputComponentRenderer);
393
- this.registerCoreComponent(EmojiSelector_1.emojiSelectorRenderer);
394
399
  this.registerCoreComponent(NumberBox_1.numberBoxComponentRenderer);
395
400
  this.registerCoreComponent(NumberBox2_1.numberBox2ComponentRenderer);
396
401
  this.registerCoreComponent(HoverCard_1.hoverCardComponentRenderer);
397
402
  this.registerCoreComponent(RadioGroup_1.radioGroupRenderer);
398
403
  this.registerCoreComponent(FileInput_1.fileInputRenderer);
399
- this.registerCoreComponent(DatePicker_1.datePickerComponentRenderer);
400
404
  this.registerCoreComponent(Spinner_1.spinnerComponentRenderer);
401
405
  this.registerCoreComponent(Select_1.selectComponentRenderer);
402
406
  this.registerCoreComponent(AutoComplete_1.autoCompleteComponentRenderer);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultProps = void 0;
4
+ const constants_1 = require("../../components-core/constants");
5
+ exports.defaultProps = {
6
+ theme: "light",
7
+ select: constants_1.noop,
8
+ autoFocus: false,
9
+ };
@@ -6,13 +6,14 @@ const renderers_1 = require("../../components-core/renderers");
6
6
  const ThemeContext_1 = require("../../components-core/theming/ThemeContext");
7
7
  const metadata_helpers_1 = require("../metadata-helpers");
8
8
  const EmojiSelectorNative_1 = require("./EmojiSelectorNative");
9
+ const DefaultProps_1 = require("./DefaultProps");
9
10
  const COMP = "EmojiSelector";
10
11
  exports.EmojiSelectorMd = (0, metadata_helpers_1.createMetadata)({
11
12
  status: "experimental",
12
13
  description: "`EmojiSelector` enables users to browse, search and select emojis from " +
13
14
  "their system's native emoji set.",
14
15
  props: {
15
- autoFocus: Object.assign(Object.assign({}, (0, metadata_helpers_1.dAutoFocus)()), { defaultValue: EmojiSelectorNative_1.defaultProps.autoFocus }),
16
+ autoFocus: Object.assign(Object.assign({}, (0, metadata_helpers_1.dAutoFocus)()), { defaultValue: DefaultProps_1.defaultProps.autoFocus }),
16
17
  },
17
18
  events: {
18
19
  select: (0, metadata_helpers_1.d)(`This event is fired when the user selects an emoticon from this component.`),
@@ -42,16 +42,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
42
42
  });
43
43
  };
44
44
  Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.EmojiSelector = exports.defaultProps = void 0;
45
+ exports.EmojiSelector = void 0;
46
46
  const jsx_runtime_1 = require("react/jsx-runtime");
47
47
  const emoji_picker_react_1 = __importStar(require("emoji-picker-react"));
48
- const constants_1 = require("../../components-core/constants");
49
- exports.defaultProps = {
50
- theme: emoji_picker_react_1.Theme.LIGHT,
51
- select: constants_1.noop,
52
- autoFocus: false,
53
- };
54
- const EmojiSelector = ({ select = exports.defaultProps.select, theme = exports.defaultProps.theme, autoFocus = exports.defaultProps.autoFocus, }) => ((0, jsx_runtime_1.jsx)(emoji_picker_react_1.default, { autoFocusSearch: autoFocus, onEmojiClick: (emojiObject) => __awaiter(void 0, void 0, void 0, function* () {
48
+ const DefaultProps_1 = require("./DefaultProps");
49
+ // =====================================================================================================================
50
+ // React EmojiSelector component implementation
51
+ const EmojiSelector = ({ select = DefaultProps_1.defaultProps.select, theme = DefaultProps_1.defaultProps.theme, autoFocus = DefaultProps_1.defaultProps.autoFocus, }) => ((0, jsx_runtime_1.jsx)(emoji_picker_react_1.default, { autoFocusSearch: autoFocus, onEmojiClick: (emojiObject) => __awaiter(void 0, void 0, void 0, function* () {
55
52
  yield select(emojiObject.emoji);
56
53
  }), lazyLoadEmojis: true, theme: theme, previewConfig: { showPreview: false }, skinTonesDisabled: true, height: 360, emojiStyle: emoji_picker_react_1.EmojiStyle.NATIVE }));
57
54
  exports.EmojiSelector = EmojiSelector;
@@ -1,145 +1,16 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
38
5
  Object.defineProperty(exports, "__esModule", { value: true });
39
6
  exports.editorComponentRenderer = exports.TableEditorMd = void 0;
40
7
  const jsx_runtime_1 = require("react/jsx-runtime");
41
- const react_1 = __importStar(require("react"));
42
- const react_2 = require("@tiptap/react");
43
- const starter_kit_1 = __importDefault(require("@tiptap/starter-kit"));
44
- const extension_table_1 = __importDefault(require("@tiptap/extension-table"));
45
- const extension_table_row_1 = __importDefault(require("@tiptap/extension-table-row"));
46
- const extension_table_cell_1 = __importDefault(require("@tiptap/extension-table-cell"));
47
- const extension_table_header_1 = __importDefault(require("@tiptap/extension-table-header"));
48
- const ButtonNative_1 = require("../Button/ButtonNative");
49
- const StackNative_1 = require("../Stack/StackNative");
50
- const TableEditorNative_1 = require("./TableEditorNative");
51
- const turndown_1 = __importDefault(require("turndown"));
52
8
  const metadata_helpers_1 = require("../metadata-helpers");
53
9
  const renderers_1 = require("../../components-core/renderers");
54
10
  const abstractions_1 = require("../abstractions");
55
- const IconNative_1 = __importDefault(require("../Icon/IconNative"));
56
11
  const TableEditor_module_scss_1 = __importDefault(require("./TableEditor.module.scss"));
57
12
  const themeVars_1 = require("../../components-core/theming/themeVars");
58
- const TableEditor = (0, react_1.forwardRef)(function TableEditor({ registerComponentApi, themeColor = "primary", variant = "solid", size = "sm", onDidChange = () => { }, }, ref) {
59
- const editor = (0, react_2.useEditor)({
60
- extensions: [
61
- starter_kit_1.default,
62
- extension_table_1.default.configure({ resizable: true }),
63
- extension_table_row_1.default,
64
- extension_table_header_1.default,
65
- extension_table_cell_1.default,
66
- ],
67
- content: `
68
- <table>
69
- <thead>
70
- <tr>
71
- <th>Fruit</th>
72
- <th>Color</th>
73
- </tr>
74
- </thead>
75
- <tbody>
76
- <tr>
77
- <td>Apple</td>
78
- <td>Red</td>
79
- </tr>
80
- <tr>
81
- <td>Banana</td>
82
- <td>Yellow</td>
83
- </tr>
84
- </tbody>
85
- </table>
86
- `,
87
- });
88
- const turndownService = new turndown_1.default();
89
- turndownService.addRule("table", {
90
- filter: "table",
91
- replacement: function (content, node) {
92
- let rows = [];
93
- for (let row of node.querySelectorAll("tr")) {
94
- let cells = Array.from(row.children).map((cell) => { var _a, _b; return (_b = (_a = cell.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : ""; });
95
- rows.push("| " + cells.join(" | ") + " |");
96
- }
97
- if (rows.length > 1) {
98
- // Add a separator after the header row
99
- const headerSep = "| " +
100
- rows[0]
101
- .split("|")
102
- .slice(1, -1)
103
- .map(() => "---")
104
- .join(" | ") +
105
- " |";
106
- rows.splice(1, 0, headerSep);
107
- }
108
- return rows.join("\n") + "\n";
109
- },
110
- });
111
- (0, react_1.useImperativeHandle)(ref, () => ({
112
- getMarkdownSource: () => { var _a, _b; return turndownService.turndown((_b = (_a = editor === null || editor === void 0 ? void 0 : editor.getHTML) === null || _a === void 0 ? void 0 : _a.call(editor)) !== null && _b !== void 0 ? _b : ""); },
113
- getHtmlSource: () => { var _a, _b; return (_b = (_a = editor === null || editor === void 0 ? void 0 : editor.getHTML) === null || _a === void 0 ? void 0 : _a.call(editor)) !== null && _b !== void 0 ? _b : ""; },
114
- }), [editor]);
115
- react_1.default.useEffect(() => {
116
- if (registerComponentApi && editor) {
117
- registerComponentApi({
118
- getHtmlSource: () => editor.getHTML(),
119
- getMarkdownSource: () => turndownService.turndown(editor.getHTML()),
120
- });
121
- }
122
- }, [registerComponentApi, editor]);
123
- // Emit onDidChange whenever the editor content changes
124
- react_1.default.useEffect(() => {
125
- if (!editor)
126
- return;
127
- const handler = () => {
128
- const html = editor.getHTML();
129
- const markdown = turndownService.turndown(html);
130
- //console.log("[TableEditor] onDidChange about to fire", { html, markdown, onDidChange });
131
- onDidChange({ html, markdown });
132
- };
133
- editor.on("update", handler);
134
- // Emit once on mount
135
- handler();
136
- return () => {
137
- editor.off("update", handler);
138
- };
139
- }, [editor, onDidChange]);
140
- return ((0, jsx_runtime_1.jsxs)("div", { className: "table-editor-root", children: [(0, jsx_runtime_1.jsx)("div", { className: "button-stack", children: (0, jsx_runtime_1.jsxs)(StackNative_1.Stack, { orientation: "horizontal", children: [(0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => editor && editor.commands.addRowAfter(), disabled: !editor, themeColor: themeColor, variant: variant, size: size, orientation: "horizontal", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "table-insert-row", "aria-hidden": true }), children: "Insert Row" }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => editor && editor.commands.deleteRow(), disabled: !editor, themeColor: themeColor, variant: variant, size: size, orientation: "horizontal", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "table-delete-row", "aria-hidden": true }), children: "Delete Row" }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => editor && editor.commands.addColumnAfter(), disabled: !editor, themeColor: themeColor, variant: variant, size: size, orientation: "horizontal", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "table-insert-column", "aria-hidden": true }), children: "Insert Column" }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => editor && editor.commands.deleteColumn(), disabled: !editor, themeColor: themeColor, variant: variant, size: size, orientation: "horizontal", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "table-delete-column", "aria-hidden": true }), children: "Delete Column" })] }) }), (0, jsx_runtime_1.jsx)(TableEditorNative_1.TableEditorNative, { editor: editor, className: TableEditor_module_scss_1.default.editor })] }));
141
- });
142
- exports.default = TableEditor;
13
+ const TableEditorNative_1 = require("./TableEditorNative");
143
14
  // Create metadata for TableEditor that defines allowed props
144
15
  exports.TableEditorMd = (0, metadata_helpers_1.createMetadata)({
145
16
  status: "stable",
@@ -178,6 +49,5 @@ exports.TableEditorMd = (0, metadata_helpers_1.createMetadata)({
178
49
  });
179
50
  exports.editorComponentRenderer = (0, renderers_1.createComponentRenderer)("TableEditor", exports.TableEditorMd, ({ node, extractValue, registerComponentApi, lookupEventHandler }) => {
180
51
  const handler = lookupEventHandler === null || lookupEventHandler === void 0 ? void 0 : lookupEventHandler("didChange");
181
- //console.log("[TableEditor renderer] didChange handler:", handler);
182
- return ((0, jsx_runtime_1.jsx)(TableEditor, { themeColor: extractValue.asOptionalString(node.props.themeColor), variant: extractValue.asOptionalString(node.props.variant), size: extractValue.asOptionalString(node.props.size), registerComponentApi: registerComponentApi, onDidChange: handler }));
52
+ return ((0, jsx_runtime_1.jsx)(TableEditorNative_1.TableEditor, { themeColor: extractValue.asOptionalString(node.props.themeColor), variant: extractValue.asOptionalString(node.props.variant), size: extractValue.asOptionalString(node.props.size), registerComponentApi: registerComponentApi, onDidChange: handler }));
183
53
  });
@@ -1,8 +1,136 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TableEditorNative = TableEditorNative;
39
+ exports.TableEditor = void 0;
4
40
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("@tiptap/react");
6
- function TableEditorNative({ editor, className }) {
7
- return ((0, jsx_runtime_1.jsx)("div", { className: className, children: (0, jsx_runtime_1.jsx)(react_1.EditorContent, { editor: editor }) }));
8
- }
41
+ const react_1 = __importStar(require("react"));
42
+ const react_2 = require("@tiptap/react");
43
+ const starter_kit_1 = __importDefault(require("@tiptap/starter-kit"));
44
+ const extension_table_1 = __importDefault(require("@tiptap/extension-table"));
45
+ const extension_table_row_1 = __importDefault(require("@tiptap/extension-table-row"));
46
+ const extension_table_cell_1 = __importDefault(require("@tiptap/extension-table-cell"));
47
+ const extension_table_header_1 = __importDefault(require("@tiptap/extension-table-header"));
48
+ const ButtonNative_1 = require("../Button/ButtonNative");
49
+ const StackNative_1 = require("../Stack/StackNative");
50
+ const turndown_1 = __importDefault(require("turndown"));
51
+ const IconNative_1 = __importDefault(require("../Icon/IconNative"));
52
+ const TableEditor_module_scss_1 = __importDefault(require("./TableEditor.module.scss"));
53
+ exports.TableEditor = (0, react_1.forwardRef)(function TableEditor({ registerComponentApi, themeColor = "primary", variant = "solid", size = "sm", onDidChange = () => { }, }, ref) {
54
+ const editor = (0, react_2.useEditor)({
55
+ extensions: [
56
+ starter_kit_1.default,
57
+ extension_table_1.default.configure({ resizable: true }),
58
+ extension_table_row_1.default,
59
+ extension_table_header_1.default,
60
+ extension_table_cell_1.default,
61
+ ],
62
+ content: `
63
+ <table>
64
+ <thead>
65
+ <tr>
66
+ <th>Fruit</th>
67
+ <th>Color</th>
68
+ </tr>
69
+ </thead>
70
+ <tbody>
71
+ <tr>
72
+ <td>Apple</td>
73
+ <td>Red</td>
74
+ </tr>
75
+ <tr>
76
+ <td>Banana</td>
77
+ <td>Yellow</td>
78
+ </tr>
79
+ </tbody>
80
+ </table>
81
+ `,
82
+ });
83
+ const turndownService = new turndown_1.default();
84
+ turndownService.addRule("table", {
85
+ filter: "table",
86
+ replacement: function (content, node) {
87
+ let rows = [];
88
+ for (let row of node.querySelectorAll("tr")) {
89
+ let cells = Array.from(row.children).map((cell) => { var _a, _b; return (_b = (_a = cell.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : ""; });
90
+ rows.push("| " + cells.join(" | ") + " |");
91
+ }
92
+ if (rows.length > 1) {
93
+ // Add a separator after the header row
94
+ const headerSep = "| " +
95
+ rows[0]
96
+ .split("|")
97
+ .slice(1, -1)
98
+ .map(() => "---")
99
+ .join(" | ") +
100
+ " |";
101
+ rows.splice(1, 0, headerSep);
102
+ }
103
+ return rows.join("\n") + "\n";
104
+ },
105
+ });
106
+ (0, react_1.useImperativeHandle)(ref, () => ({
107
+ getMarkdownSource: () => { var _a, _b; return turndownService.turndown((_b = (_a = editor === null || editor === void 0 ? void 0 : editor.getHTML) === null || _a === void 0 ? void 0 : _a.call(editor)) !== null && _b !== void 0 ? _b : ""); },
108
+ getHtmlSource: () => { var _a, _b; return (_b = (_a = editor === null || editor === void 0 ? void 0 : editor.getHTML) === null || _a === void 0 ? void 0 : _a.call(editor)) !== null && _b !== void 0 ? _b : ""; },
109
+ }), [editor]);
110
+ react_1.default.useEffect(() => {
111
+ if (registerComponentApi && editor) {
112
+ registerComponentApi({
113
+ getHtmlSource: () => editor.getHTML(),
114
+ getMarkdownSource: () => turndownService.turndown(editor.getHTML()),
115
+ });
116
+ }
117
+ }, [registerComponentApi, editor]);
118
+ // Emit onDidChange whenever the editor content changes
119
+ react_1.default.useEffect(() => {
120
+ if (!editor)
121
+ return;
122
+ const handler = () => {
123
+ const html = editor.getHTML();
124
+ const markdown = turndownService.turndown(html);
125
+ //console.log("[TableEditor] onDidChange about to fire", { html, markdown, onDidChange });
126
+ onDidChange({ html, markdown });
127
+ };
128
+ editor.on("update", handler);
129
+ // Emit once on mount
130
+ handler();
131
+ return () => {
132
+ editor.off("update", handler);
133
+ };
134
+ }, [editor, onDidChange]);
135
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "table-editor-root", children: [(0, jsx_runtime_1.jsx)("div", { className: "button-stack", children: (0, jsx_runtime_1.jsxs)(StackNative_1.Stack, { orientation: "horizontal", children: [(0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => editor && editor.commands.addRowAfter(), disabled: !editor, themeColor: themeColor, variant: variant, size: size, orientation: "horizontal", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "table-insert-row", "aria-hidden": true }), children: "Insert Row" }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => editor && editor.commands.deleteRow(), disabled: !editor, themeColor: themeColor, variant: variant, size: size, orientation: "horizontal", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "table-delete-row", "aria-hidden": true }), children: "Delete Row" }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => editor && editor.commands.addColumnAfter(), disabled: !editor, themeColor: themeColor, variant: variant, size: size, orientation: "horizontal", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "table-insert-column", "aria-hidden": true }), children: "Insert Column" }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { onClick: () => editor && editor.commands.deleteColumn(), disabled: !editor, themeColor: themeColor, variant: variant, size: size, orientation: "horizontal", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "table-delete-column", "aria-hidden": true }), children: "Delete Column" })] }) }), (0, jsx_runtime_1.jsx)("div", { className: TableEditor_module_scss_1.default.editor, children: (0, jsx_runtime_1.jsx)(react_2.EditorContent, { editor: editor }) })] }));
136
+ });