draftly 2.0.0 → 2.1.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/dist/{chunk-BWJLMREN.cjs → chunk-EQUQHE2E.cjs} +26 -24
- package/dist/chunk-EQUQHE2E.cjs.map +1 -0
- package/dist/{chunk-L2XSK57Y.js → chunk-NRPI5O6Y.js} +1267 -551
- package/dist/chunk-NRPI5O6Y.js.map +1 -0
- package/dist/{chunk-W5ALMXG2.cjs → chunk-OMFUE4AQ.cjs} +1304 -588
- package/dist/chunk-OMFUE4AQ.cjs.map +1 -0
- package/dist/{chunk-EEHILRG5.js → chunk-TD3L5C45.js} +13 -11
- package/dist/chunk-TD3L5C45.js.map +1 -0
- package/dist/{chunk-ZUI3GI3W.js → chunk-UCHBDJ4R.js} +22 -20
- package/dist/chunk-UCHBDJ4R.js.map +1 -0
- package/dist/{chunk-TBVZEK2H.cjs → chunk-W75QUUQC.cjs} +13 -11
- package/dist/chunk-W75QUUQC.cjs.map +1 -0
- package/dist/editor/index.cjs +16 -16
- package/dist/editor/index.js +2 -2
- package/dist/index.cjs +33 -33
- package/dist/index.js +3 -3
- package/dist/plugins/index.cjs +19 -19
- package/dist/plugins/index.d.cts +77 -42
- package/dist/plugins/index.d.ts +77 -42
- package/dist/plugins/index.js +3 -3
- package/dist/preview/index.cjs +1 -1
- package/dist/preview/index.js +1 -1
- package/package.json +1 -1
- package/src/editor/draftly.ts +29 -27
- package/src/editor/utils.ts +13 -11
- package/src/plugins/table-plugin.ts +1759 -900
- package/dist/chunk-BWJLMREN.cjs.map +0 -1
- package/dist/chunk-EEHILRG5.js.map +0 -1
- package/dist/chunk-L2XSK57Y.js.map +0 -1
- package/dist/chunk-TBVZEK2H.cjs.map +0 -1
- package/dist/chunk-W5ALMXG2.cjs.map +0 -1
- package/dist/chunk-ZUI3GI3W.js.map +0 -1
package/dist/plugins/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { d as DraftlyPlugin, T as ThemeEnum, f as ThemeStyle, a as DecorationPlugin, D as DecorationContext, e as PluginContext } from '../draftly-BBL-AdOl.cjs';
|
|
2
2
|
import { SyntaxNode } from '@lezer/common';
|
|
3
3
|
import { Extension } from '@codemirror/state';
|
|
4
|
-
import
|
|
4
|
+
import * as _codemirror_view from '@codemirror/view';
|
|
5
|
+
import { KeyBinding, EditorView } from '@codemirror/view';
|
|
5
6
|
import { MarkdownConfig } from '@lezer/markdown';
|
|
6
7
|
import * as _lezer_highlight from '@lezer/highlight';
|
|
7
8
|
import { Highlighter } from '@lezer/highlight';
|
|
@@ -191,63 +192,97 @@ declare class ListPlugin extends DecorationPlugin {
|
|
|
191
192
|
}): string | null;
|
|
192
193
|
}
|
|
193
194
|
|
|
194
|
-
|
|
195
|
+
interface PreviewContextLike {
|
|
195
196
|
sliceDoc(from: number, to: number): string;
|
|
196
197
|
sanitize(html: string): string;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* TablePlugin — Renders GFM markdown tables as styled widgets.
|
|
200
|
-
*
|
|
201
|
-
* Features:
|
|
202
|
-
* - Rendered table widget with rounded borders, alternate row colors, cell borders
|
|
203
|
-
* - Alignment support (`:---:`, `----:`, `:---`)
|
|
204
|
-
* - Monospace raw markdown when cursor is inside the table
|
|
205
|
-
* - Keyboard shortcuts for table creation, adding rows/columns
|
|
206
|
-
* - Enter in last row/last cell: creates row, again removes it
|
|
207
|
-
* - Auto-formats table markdown to align pipes
|
|
208
|
-
*/
|
|
198
|
+
}
|
|
209
199
|
declare class TablePlugin extends DecorationPlugin {
|
|
210
200
|
readonly name = "table";
|
|
211
|
-
readonly version = "
|
|
201
|
+
readonly version = "2.0.0";
|
|
212
202
|
decorationPriority: number;
|
|
213
203
|
readonly requiredNodes: readonly ["Table", "TableHeader", "TableDelimiter", "TableRow", "TableCell"];
|
|
214
|
-
/** Configuration stored from onRegister */
|
|
215
204
|
private draftlyConfig;
|
|
205
|
+
private pendingNormalizationView;
|
|
206
|
+
private pendingPaddingView;
|
|
207
|
+
private pendingSelectionRepairView;
|
|
208
|
+
/** Stores the editor config for preview rendering and shared behavior. */
|
|
216
209
|
onRegister(context: PluginContext): void;
|
|
210
|
+
/** Exposes the plugin theme used for editor and preview styling. */
|
|
217
211
|
get theme(): (theme: ThemeEnum) => ThemeStyle;
|
|
212
|
+
/** Enables GFM table parsing for the editor and preview renderer. */
|
|
213
|
+
getMarkdownConfig(): MarkdownConfig;
|
|
214
|
+
/** Registers block wrappers and atomic ranges for the table UI. */
|
|
215
|
+
getExtensions(): Extension[];
|
|
216
|
+
/** Provides the table-specific keyboard shortcuts and navigation. */
|
|
218
217
|
getKeymap(): KeyBinding[];
|
|
218
|
+
/** Builds the high-priority key bindings used inside tables. */
|
|
219
|
+
private buildTableKeymap;
|
|
220
|
+
/** Schedules an initial normalization pass once the view is ready. */
|
|
221
|
+
onViewReady(view: EditorView): void;
|
|
222
|
+
/** Re-schedules normalization after user-driven document changes. */
|
|
223
|
+
onViewUpdate(update: _codemirror_view.ViewUpdate): void;
|
|
224
|
+
/** Intercepts table-specific DOM key handling before browser defaults run. */
|
|
225
|
+
private handleDomKeydown;
|
|
226
|
+
/** Builds the visual table decorations for every parsed table block. */
|
|
219
227
|
buildDecorations(ctx: DecorationContext): void;
|
|
220
|
-
/**
|
|
221
|
-
|
|
222
|
-
|
|
228
|
+
/** Renders the full table node to semantic preview HTML. */
|
|
229
|
+
renderToHTML(node: SyntaxNode, _children: string, ctx: PreviewContextLike): Promise<string | null>;
|
|
230
|
+
/** Computes the block wrapper ranges used to group table lines. */
|
|
231
|
+
private computeBlockWrappers;
|
|
232
|
+
/** Computes atomic ranges for delimiters and inline break tags. */
|
|
233
|
+
private computeAtomicRanges;
|
|
234
|
+
/** Applies row, cell, and control decorations for a single table. */
|
|
235
|
+
private decorateTable;
|
|
236
|
+
/** Applies the visual cell decorations for a single table row line. */
|
|
237
|
+
private decorateLine;
|
|
238
|
+
/** Normalizes every parsed table block back into canonical markdown. */
|
|
239
|
+
private normalizeTables;
|
|
240
|
+
/** Defers table normalization until the current update cycle is finished. */
|
|
241
|
+
private scheduleNormalization;
|
|
242
|
+
/** Adds missing spacer lines above and below tables after edits. */
|
|
243
|
+
private ensureTablePadding;
|
|
244
|
+
/** Schedules a padding-only pass after the current update cycle finishes. */
|
|
245
|
+
private schedulePadding;
|
|
246
|
+
/** Repairs carets that land in hidden table markup instead of editable cell content. */
|
|
247
|
+
private ensureTableSelection;
|
|
248
|
+
/** Schedules table selection repair after the current update finishes. */
|
|
249
|
+
private scheduleSelectionRepair;
|
|
250
|
+
/** Rewrites a table block and restores the caret to a target cell position. */
|
|
251
|
+
private replaceTable;
|
|
252
|
+
/** Inserts an empty body row below the given logical row index. */
|
|
253
|
+
private insertRowBelow;
|
|
254
|
+
/** Inserts a starter table near the current cursor line. */
|
|
223
255
|
private insertTable;
|
|
224
|
-
/**
|
|
225
|
-
* Add a new row below the current row (Mod-Enter)
|
|
226
|
-
*/
|
|
256
|
+
/** Adds a new empty body row to the active table. */
|
|
227
257
|
private addRow;
|
|
228
|
-
/**
|
|
229
|
-
|
|
230
|
-
|
|
258
|
+
/** Appends a row and keeps the caret in the requested column. */
|
|
259
|
+
private appendRow;
|
|
260
|
+
/** Inserts a new column after the current column. */
|
|
231
261
|
private addColumn;
|
|
232
|
-
/**
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
private
|
|
238
|
-
/**
|
|
239
|
-
* Handle Tab key inside a table — move to next/previous cell
|
|
240
|
-
*/
|
|
262
|
+
/** Appends a new column at the far right of the table. */
|
|
263
|
+
private appendColumn;
|
|
264
|
+
/** Removes the current body row or clears the last remaining row. */
|
|
265
|
+
private removeRow;
|
|
266
|
+
/** Removes the current column when the table has more than one column. */
|
|
267
|
+
private removeColumn;
|
|
268
|
+
/** Moves to the next or previous logical cell with Tab navigation. */
|
|
241
269
|
private handleTab;
|
|
242
|
-
/**
|
|
243
|
-
|
|
244
|
-
|
|
270
|
+
/** Moves horizontally between adjacent cells when the caret hits an edge. */
|
|
271
|
+
private handleArrowHorizontal;
|
|
272
|
+
/** Moves vertically between rows while keeping the current column. */
|
|
273
|
+
private handleArrowVertical;
|
|
274
|
+
/** Advances downward on Enter and manages the trailing empty row behavior. */
|
|
275
|
+
private handleEnter;
|
|
276
|
+
/** Inserts a canonical `<br />` token inside the current table cell. */
|
|
277
|
+
private insertBreakTag;
|
|
278
|
+
/** Deletes a whole `<br />` token when backspace or delete hits it. */
|
|
279
|
+
private handleBreakDeletion;
|
|
280
|
+
/** Moves the current selection anchor into a target cell. */
|
|
281
|
+
private moveSelectionToCell;
|
|
282
|
+
/** Returns the table currently containing the editor cursor. */
|
|
245
283
|
private getTableAtCursor;
|
|
246
|
-
/**
|
|
247
|
-
|
|
248
|
-
*/
|
|
249
|
-
private splitLineToCells;
|
|
250
|
-
renderToHTML(node: SyntaxNode, _children: string, _ctx: PreviewContextLike): Promise<string | null>;
|
|
284
|
+
/** Returns the active cell under the current selection head. */
|
|
285
|
+
private getCurrentCell;
|
|
251
286
|
}
|
|
252
287
|
|
|
253
288
|
/**
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { d as DraftlyPlugin, T as ThemeEnum, f as ThemeStyle, a as DecorationPlugin, D as DecorationContext, e as PluginContext } from '../draftly-BBL-AdOl.js';
|
|
2
2
|
import { SyntaxNode } from '@lezer/common';
|
|
3
3
|
import { Extension } from '@codemirror/state';
|
|
4
|
-
import
|
|
4
|
+
import * as _codemirror_view from '@codemirror/view';
|
|
5
|
+
import { KeyBinding, EditorView } from '@codemirror/view';
|
|
5
6
|
import { MarkdownConfig } from '@lezer/markdown';
|
|
6
7
|
import * as _lezer_highlight from '@lezer/highlight';
|
|
7
8
|
import { Highlighter } from '@lezer/highlight';
|
|
@@ -191,63 +192,97 @@ declare class ListPlugin extends DecorationPlugin {
|
|
|
191
192
|
}): string | null;
|
|
192
193
|
}
|
|
193
194
|
|
|
194
|
-
|
|
195
|
+
interface PreviewContextLike {
|
|
195
196
|
sliceDoc(from: number, to: number): string;
|
|
196
197
|
sanitize(html: string): string;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* TablePlugin — Renders GFM markdown tables as styled widgets.
|
|
200
|
-
*
|
|
201
|
-
* Features:
|
|
202
|
-
* - Rendered table widget with rounded borders, alternate row colors, cell borders
|
|
203
|
-
* - Alignment support (`:---:`, `----:`, `:---`)
|
|
204
|
-
* - Monospace raw markdown when cursor is inside the table
|
|
205
|
-
* - Keyboard shortcuts for table creation, adding rows/columns
|
|
206
|
-
* - Enter in last row/last cell: creates row, again removes it
|
|
207
|
-
* - Auto-formats table markdown to align pipes
|
|
208
|
-
*/
|
|
198
|
+
}
|
|
209
199
|
declare class TablePlugin extends DecorationPlugin {
|
|
210
200
|
readonly name = "table";
|
|
211
|
-
readonly version = "
|
|
201
|
+
readonly version = "2.0.0";
|
|
212
202
|
decorationPriority: number;
|
|
213
203
|
readonly requiredNodes: readonly ["Table", "TableHeader", "TableDelimiter", "TableRow", "TableCell"];
|
|
214
|
-
/** Configuration stored from onRegister */
|
|
215
204
|
private draftlyConfig;
|
|
205
|
+
private pendingNormalizationView;
|
|
206
|
+
private pendingPaddingView;
|
|
207
|
+
private pendingSelectionRepairView;
|
|
208
|
+
/** Stores the editor config for preview rendering and shared behavior. */
|
|
216
209
|
onRegister(context: PluginContext): void;
|
|
210
|
+
/** Exposes the plugin theme used for editor and preview styling. */
|
|
217
211
|
get theme(): (theme: ThemeEnum) => ThemeStyle;
|
|
212
|
+
/** Enables GFM table parsing for the editor and preview renderer. */
|
|
213
|
+
getMarkdownConfig(): MarkdownConfig;
|
|
214
|
+
/** Registers block wrappers and atomic ranges for the table UI. */
|
|
215
|
+
getExtensions(): Extension[];
|
|
216
|
+
/** Provides the table-specific keyboard shortcuts and navigation. */
|
|
218
217
|
getKeymap(): KeyBinding[];
|
|
218
|
+
/** Builds the high-priority key bindings used inside tables. */
|
|
219
|
+
private buildTableKeymap;
|
|
220
|
+
/** Schedules an initial normalization pass once the view is ready. */
|
|
221
|
+
onViewReady(view: EditorView): void;
|
|
222
|
+
/** Re-schedules normalization after user-driven document changes. */
|
|
223
|
+
onViewUpdate(update: _codemirror_view.ViewUpdate): void;
|
|
224
|
+
/** Intercepts table-specific DOM key handling before browser defaults run. */
|
|
225
|
+
private handleDomKeydown;
|
|
226
|
+
/** Builds the visual table decorations for every parsed table block. */
|
|
219
227
|
buildDecorations(ctx: DecorationContext): void;
|
|
220
|
-
/**
|
|
221
|
-
|
|
222
|
-
|
|
228
|
+
/** Renders the full table node to semantic preview HTML. */
|
|
229
|
+
renderToHTML(node: SyntaxNode, _children: string, ctx: PreviewContextLike): Promise<string | null>;
|
|
230
|
+
/** Computes the block wrapper ranges used to group table lines. */
|
|
231
|
+
private computeBlockWrappers;
|
|
232
|
+
/** Computes atomic ranges for delimiters and inline break tags. */
|
|
233
|
+
private computeAtomicRanges;
|
|
234
|
+
/** Applies row, cell, and control decorations for a single table. */
|
|
235
|
+
private decorateTable;
|
|
236
|
+
/** Applies the visual cell decorations for a single table row line. */
|
|
237
|
+
private decorateLine;
|
|
238
|
+
/** Normalizes every parsed table block back into canonical markdown. */
|
|
239
|
+
private normalizeTables;
|
|
240
|
+
/** Defers table normalization until the current update cycle is finished. */
|
|
241
|
+
private scheduleNormalization;
|
|
242
|
+
/** Adds missing spacer lines above and below tables after edits. */
|
|
243
|
+
private ensureTablePadding;
|
|
244
|
+
/** Schedules a padding-only pass after the current update cycle finishes. */
|
|
245
|
+
private schedulePadding;
|
|
246
|
+
/** Repairs carets that land in hidden table markup instead of editable cell content. */
|
|
247
|
+
private ensureTableSelection;
|
|
248
|
+
/** Schedules table selection repair after the current update finishes. */
|
|
249
|
+
private scheduleSelectionRepair;
|
|
250
|
+
/** Rewrites a table block and restores the caret to a target cell position. */
|
|
251
|
+
private replaceTable;
|
|
252
|
+
/** Inserts an empty body row below the given logical row index. */
|
|
253
|
+
private insertRowBelow;
|
|
254
|
+
/** Inserts a starter table near the current cursor line. */
|
|
223
255
|
private insertTable;
|
|
224
|
-
/**
|
|
225
|
-
* Add a new row below the current row (Mod-Enter)
|
|
226
|
-
*/
|
|
256
|
+
/** Adds a new empty body row to the active table. */
|
|
227
257
|
private addRow;
|
|
228
|
-
/**
|
|
229
|
-
|
|
230
|
-
|
|
258
|
+
/** Appends a row and keeps the caret in the requested column. */
|
|
259
|
+
private appendRow;
|
|
260
|
+
/** Inserts a new column after the current column. */
|
|
231
261
|
private addColumn;
|
|
232
|
-
/**
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
private
|
|
238
|
-
/**
|
|
239
|
-
* Handle Tab key inside a table — move to next/previous cell
|
|
240
|
-
*/
|
|
262
|
+
/** Appends a new column at the far right of the table. */
|
|
263
|
+
private appendColumn;
|
|
264
|
+
/** Removes the current body row or clears the last remaining row. */
|
|
265
|
+
private removeRow;
|
|
266
|
+
/** Removes the current column when the table has more than one column. */
|
|
267
|
+
private removeColumn;
|
|
268
|
+
/** Moves to the next or previous logical cell with Tab navigation. */
|
|
241
269
|
private handleTab;
|
|
242
|
-
/**
|
|
243
|
-
|
|
244
|
-
|
|
270
|
+
/** Moves horizontally between adjacent cells when the caret hits an edge. */
|
|
271
|
+
private handleArrowHorizontal;
|
|
272
|
+
/** Moves vertically between rows while keeping the current column. */
|
|
273
|
+
private handleArrowVertical;
|
|
274
|
+
/** Advances downward on Enter and manages the trailing empty row behavior. */
|
|
275
|
+
private handleEnter;
|
|
276
|
+
/** Inserts a canonical `<br />` token inside the current table cell. */
|
|
277
|
+
private insertBreakTag;
|
|
278
|
+
/** Deletes a whole `<br />` token when backspace or delete hits it. */
|
|
279
|
+
private handleBreakDeletion;
|
|
280
|
+
/** Moves the current selection anchor into a target cell. */
|
|
281
|
+
private moveSelectionToCell;
|
|
282
|
+
/** Returns the table currently containing the editor cursor. */
|
|
245
283
|
private getTableAtCursor;
|
|
246
|
-
/**
|
|
247
|
-
|
|
248
|
-
*/
|
|
249
|
-
private splitLineToCells;
|
|
250
|
-
renderToHTML(node: SyntaxNode, _children: string, _ctx: PreviewContextLike): Promise<string | null>;
|
|
284
|
+
/** Returns the active cell under the current selection head. */
|
|
285
|
+
private getCurrentCell;
|
|
251
286
|
}
|
|
252
287
|
|
|
253
288
|
/**
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { CodePlugin, EmojiPlugin, HRPlugin, HTMLPlugin, HeadingPlugin, ImagePlugin, InlinePlugin, LinkPlugin, ListPlugin, MathPlugin, MermaidPlugin, ParagraphPlugin, QuotePlugin, TablePlugin, allPlugins, essentialPlugins } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { CodePlugin, EmojiPlugin, HRPlugin, HTMLPlugin, HeadingPlugin, ImagePlugin, InlinePlugin, LinkPlugin, ListPlugin, MathPlugin, MermaidPlugin, ParagraphPlugin, QuotePlugin, TablePlugin, allPlugins, essentialPlugins } from '../chunk-NRPI5O6Y.js';
|
|
2
|
+
import '../chunk-UCHBDJ4R.js';
|
|
3
3
|
import '../chunk-JF3WXXMJ.js';
|
|
4
4
|
import '../chunk-I563H35S.js';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-TD3L5C45.js';
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/preview/index.cjs
CHANGED
package/dist/preview/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { generateCSS, preview } from '../chunk-IAXF4SJL.js';
|
|
2
2
|
export { PreviewRenderer, defaultRenderers, escapeHtml, generateSyntaxThemeCSS } from '../chunk-I563H35S.js';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-TD3L5C45.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
package/src/editor/draftly.ts
CHANGED
|
@@ -114,33 +114,35 @@ export function draftly(config: DraftlyConfig = {}): Extension[] {
|
|
|
114
114
|
// Create plugin context for lifecycle methods
|
|
115
115
|
const pluginContext: PluginContext = { config };
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
117
|
+
if (!disableViewPlugin) {
|
|
118
|
+
// Process each plugin
|
|
119
|
+
for (const plugin of allPlugins) {
|
|
120
|
+
// Call onRegister lifecycle hook
|
|
121
|
+
plugin.onRegister(pluginContext);
|
|
122
|
+
|
|
123
|
+
// Collect extensions via class method
|
|
124
|
+
const exts = plugin.getExtensions();
|
|
125
|
+
if (exts.length > 0) {
|
|
126
|
+
pluginExtensions.push(...exts);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Collect keymaps via class method
|
|
130
|
+
const keys = plugin.getKeymap();
|
|
131
|
+
if (keys.length > 0) {
|
|
132
|
+
pluginKeymaps.push(...keys);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Collect theme via class method
|
|
136
|
+
const theme = plugin.theme;
|
|
137
|
+
if (baseStyles && theme && typeof theme === "function") {
|
|
138
|
+
pluginExtensions.push(EditorView.theme(theme(configTheme)));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Collect markdown parser extensions via class method
|
|
142
|
+
const md = plugin.getMarkdownConfig();
|
|
143
|
+
if (md) {
|
|
144
|
+
markdownExtensions.push(md);
|
|
145
|
+
}
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
148
|
|
package/src/editor/utils.ts
CHANGED
|
@@ -80,18 +80,20 @@ export function createTheme({
|
|
|
80
80
|
export function flattenThemeStyles(themeStyles: ThemeStyle, parentSelector?: string): ThemeStyle {
|
|
81
81
|
const flattened: ThemeStyle = {};
|
|
82
82
|
|
|
83
|
-
for (const [
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// Add styles to the flattened object
|
|
91
|
-
if (parentSelector) {
|
|
92
|
-
flattened[parentSelector] = { ...flattened[parentSelector], [selector]: styles };
|
|
83
|
+
for (const [selectors, styles] of Object.entries(themeStyles)) {
|
|
84
|
+
for (const selector of selectors.split(",")) {
|
|
85
|
+
if (typeof styles === "object" && !Array.isArray(styles)) {
|
|
86
|
+
// Flatten nested styles
|
|
87
|
+
const fullSelector = fixSelector(parentSelector ? `${parentSelector} ${selector}` : selector);
|
|
88
|
+
const nestedStyles = flattenThemeStyles(styles as ThemeStyle, fullSelector);
|
|
89
|
+
Object.assign(flattened, nestedStyles);
|
|
93
90
|
} else {
|
|
94
|
-
|
|
91
|
+
// Add styles to the flattened object
|
|
92
|
+
if (parentSelector) {
|
|
93
|
+
flattened[parentSelector] = { ...flattened[parentSelector], [selector]: styles };
|
|
94
|
+
} else {
|
|
95
|
+
flattened[selector] = styles as StyleSpec;
|
|
96
|
+
}
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
99
|
}
|