@threadlabs/looma 0.1.4 → 0.1.6
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 +5 -4
- package/editor/chunk-CX4QDKSV.js +22 -0
- package/editor/{chunk-CWCXYQMT.js → chunk-KQQTYVRW.js} +29 -15
- package/editor/{chunk-YGJLGDQC.js → chunk-NJ2KAMS2.js} +2203 -17
- package/editor/extensions/index.d.ts +74 -20
- package/editor/extensions/index.js +22 -4
- package/editor/index.d.ts +3 -3
- package/editor/index.js +25 -5
- package/editor/table-overlay-Bq0F5xPg.d.ts +64 -0
- package/editor/ui.d.ts +2 -12
- package/editor/ui.js +9 -1
- package/editor.css +264 -0
- package/layout/index.css +1 -1
- package/layout.css +1 -1
- package/package.json +9 -2
- package/tokens.css +17 -0
- package/vue/chunk-KDA4RFLQ.js +203 -0
- package/vue/editor/index.d.ts +93 -3
- package/vue/editor/index.js +486 -30
- package/vue/index.js +38 -82
- package/editor/table-overlay-DTr3KC9e.d.ts +0 -12
- package/vue/chunk-P72L3GWE.js +0 -84
package/README.md
CHANGED
|
@@ -10,12 +10,13 @@ pnpm add @threadlabs/looma
|
|
|
10
10
|
```ts
|
|
11
11
|
import { openOverlay } from "@threadlabs/looma";
|
|
12
12
|
import { TopBar } from "@threadlabs/looma/vue";
|
|
13
|
-
import {
|
|
13
|
+
import { LoomaEditor } from "@threadlabs/looma/vue/editor";
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
Vue and Tiptap are optional to the package as a whole. `/vue` needs only Vue 3.5
|
|
17
17
|
or newer. Looma's `/editor` and `/vue/editor` surfaces are Tiptap-backed and
|
|
18
|
-
ship Looma's concrete extension set within those subpaths
|
|
19
|
-
must also install `@tiptap/vue-3@^2.11.5`
|
|
20
|
-
|
|
18
|
+
ship Looma's concrete extension set within those subpaths. `/vue/editor` consumers
|
|
19
|
+
must also install `@tiptap/vue-3@^2.11.5`; `LoomaEditor` owns the Tiptap lifecycle,
|
|
20
|
+
formatting toolbar, slash menu, image insertion, and table editing. `/editor/ui`
|
|
21
|
+
is the low-level UI-only boundary. See the
|
|
21
22
|
repository getting-started guide for the full CSS and adapter setup.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/table-backgrounds.ts
|
|
2
|
+
var TABLE_CELL_BACKGROUND_PRESETS = {
|
|
3
|
+
none: null,
|
|
4
|
+
gray: "#f3f4f6",
|
|
5
|
+
yellow: "#fef3c7",
|
|
6
|
+
blue: "#dbeafe",
|
|
7
|
+
green: "#dcfce7",
|
|
8
|
+
red: "#fee2e2"
|
|
9
|
+
};
|
|
10
|
+
var TABLE_CELL_BACKGROUND_OPTIONS = [
|
|
11
|
+
{ action: "background-none", label: "Default", value: TABLE_CELL_BACKGROUND_PRESETS.none, swatch: null },
|
|
12
|
+
{ action: "background-gray", label: "Gray", value: TABLE_CELL_BACKGROUND_PRESETS.gray, swatch: TABLE_CELL_BACKGROUND_PRESETS.gray },
|
|
13
|
+
{ action: "background-yellow", label: "Yellow", value: TABLE_CELL_BACKGROUND_PRESETS.yellow, swatch: TABLE_CELL_BACKGROUND_PRESETS.yellow },
|
|
14
|
+
{ action: "background-blue", label: "Blue", value: TABLE_CELL_BACKGROUND_PRESETS.blue, swatch: TABLE_CELL_BACKGROUND_PRESETS.blue },
|
|
15
|
+
{ action: "background-green", label: "Green", value: TABLE_CELL_BACKGROUND_PRESETS.green, swatch: TABLE_CELL_BACKGROUND_PRESETS.green },
|
|
16
|
+
{ action: "background-red", label: "Red", value: TABLE_CELL_BACKGROUND_PRESETS.red, swatch: TABLE_CELL_BACKGROUND_PRESETS.red }
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
TABLE_CELL_BACKGROUND_PRESETS,
|
|
21
|
+
TABLE_CELL_BACKGROUND_OPTIONS
|
|
22
|
+
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TABLE_CELL_BACKGROUND_OPTIONS
|
|
3
|
+
} from "./chunk-CX4QDKSV.js";
|
|
4
|
+
|
|
1
5
|
// src/table-context-menu.ts
|
|
2
6
|
var TAG = "ui-editor-table-context-menu";
|
|
3
7
|
function dispatchTableAction(element, action) {
|
|
@@ -79,18 +83,10 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
79
83
|
this.hidden = !open;
|
|
80
84
|
if (!open) return;
|
|
81
85
|
const currentBackground = this.getAttribute("cell-background");
|
|
82
|
-
const backgroundActions = [
|
|
83
|
-
{ action: "background-none", label: "Default", value: null, swatch: null },
|
|
84
|
-
{ action: "background-gray", label: "Gray", value: "#f3f4f6", swatch: "#f3f4f6" },
|
|
85
|
-
{ action: "background-yellow", label: "Yellow", value: "#fef3c7", swatch: "#fef3c7" },
|
|
86
|
-
{ action: "background-blue", label: "Blue", value: "#dbeafe", swatch: "#dbeafe" },
|
|
87
|
-
{ action: "background-green", label: "Green", value: "#dcfce7", swatch: "#dcfce7" },
|
|
88
|
-
{ action: "background-red", label: "Red", value: "#fee2e2", swatch: "#fee2e2" }
|
|
89
|
-
];
|
|
90
86
|
const sections = [
|
|
91
87
|
{
|
|
92
88
|
heading: "Cell background",
|
|
93
|
-
backgrounds:
|
|
89
|
+
backgrounds: TABLE_CELL_BACKGROUND_OPTIONS
|
|
94
90
|
},
|
|
95
91
|
{
|
|
96
92
|
heading: "Structure",
|
|
@@ -176,6 +172,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
176
172
|
return [
|
|
177
173
|
"open",
|
|
178
174
|
"cell-alignment",
|
|
175
|
+
"cell-background",
|
|
179
176
|
"can-add-row-after",
|
|
180
177
|
"can-add-column-after",
|
|
181
178
|
"can-add-row-before",
|
|
@@ -252,6 +249,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
252
249
|
return;
|
|
253
250
|
}
|
|
254
251
|
const activeAlignment = this.getAlignmentAttr();
|
|
252
|
+
const currentBackground = this.getAttribute("cell-background");
|
|
255
253
|
const alignmentActions = [
|
|
256
254
|
{ action: "align-left", label: "Left" },
|
|
257
255
|
{ action: "align-center", label: "Center" },
|
|
@@ -269,6 +267,13 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
269
267
|
{ action: "add-column-before", label: "Add column left", can: "can-add-column-before" }
|
|
270
268
|
]
|
|
271
269
|
},
|
|
270
|
+
{
|
|
271
|
+
heading: "Cells",
|
|
272
|
+
actions: [
|
|
273
|
+
{ action: "merge-cells", label: "Merge selected cells", can: "can-merge-cells" },
|
|
274
|
+
{ action: "split-cell", label: "Split merged cell", can: "can-split-cell" }
|
|
275
|
+
]
|
|
276
|
+
},
|
|
272
277
|
{
|
|
273
278
|
heading: "Table",
|
|
274
279
|
actions: [
|
|
@@ -295,14 +300,23 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
295
300
|
(action) => `<button type="button" data-action="${action.action}">${action.label}</button>`
|
|
296
301
|
).join(""),
|
|
297
302
|
structuralActions.length > 0 ? "</div>" : "",
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
303
|
+
'<div class="ui-editor-table-toolbar__sep" aria-hidden="true"></div>',
|
|
304
|
+
'<div class="ui-editor-table-toolbar__overflow">',
|
|
305
|
+
`<button type="button" class="ui-editor-table-toolbar__more" data-action="toggle-overflow" aria-haspopup="menu" aria-expanded="${this.#overflowOpen ? "true" : "false"}">Table options</button>`,
|
|
306
|
+
this.#overflowOpen ? [
|
|
302
307
|
'<div class="ui-editor-table-toolbar__menu" role="menu" aria-label="More table actions">',
|
|
308
|
+
'<div class="ui-editor-table-toolbar__menu-section" role="none">',
|
|
309
|
+
'<div class="ui-editor-table-toolbar__menu-heading" role="presentation">Background</div>',
|
|
310
|
+
'<div class="ui-editor-table-toolbar__swatches" role="group" aria-label="Cell background">',
|
|
311
|
+
TABLE_CELL_BACKGROUND_OPTIONS.map((background) => {
|
|
312
|
+
const isSelected = (background.value ?? "") === (currentBackground ?? "");
|
|
313
|
+
return `<button type="button" class="ui-editor-table-toolbar__swatch-button" role="menuitemradio" aria-checked="${isSelected ? "true" : "false"}" data-action="${background.action}"${isSelected ? ' data-selected="true"' : ""}><span class="ui-editor-table-toolbar__swatch${background.swatch ? "" : " ui-editor-table-toolbar__swatch--default"}"${background.swatch ? ` style="--ui-editor-table-toolbar-swatch:${background.swatch}"` : ""}></span><span>${background.label}</span></button>`;
|
|
314
|
+
}).join(""),
|
|
315
|
+
"</div>",
|
|
316
|
+
"</div>",
|
|
303
317
|
availableOverflowSections.map(
|
|
304
318
|
(section) => [
|
|
305
|
-
'<div class="ui-editor-table-toolbar__menu-section" role="none">',
|
|
319
|
+
'<div class="ui-editor-table-toolbar__menu-section ui-editor-table-toolbar__menu-section--divided" role="none">',
|
|
306
320
|
`<div class="ui-editor-table-toolbar__menu-heading" role="presentation">${section.heading}</div>`,
|
|
307
321
|
section.actions.map((action) => {
|
|
308
322
|
const tone = "tone" in action ? action.tone : void 0;
|
|
@@ -313,7 +327,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
313
327
|
).join(""),
|
|
314
328
|
"</div>"
|
|
315
329
|
].join("") : "",
|
|
316
|
-
|
|
330
|
+
"</div>",
|
|
317
331
|
"</div>"
|
|
318
332
|
].join("");
|
|
319
333
|
}
|