@lupinum/ginko-editor 0.1.0 → 0.18.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/CHANGELOG.md +7 -73
- package/LICENSE +1 -1
- package/README.md +15 -340
- package/dist/assets.d.ts +70 -0
- package/dist/assets.js +31 -0
- package/dist/core/component-props.d.ts +87 -0
- package/dist/core/component-props.js +134 -0
- package/dist/core/convert.d.ts +24 -0
- package/dist/core/convert.js +278 -0
- package/dist/core/editor.d.ts +60 -0
- package/dist/core/editor.js +85 -0
- package/dist/core/extensions.d.ts +38 -0
- package/dist/core/extensions.js +444 -0
- package/dist/core/file-images.d.ts +9 -0
- package/dist/core/file-images.js +54 -0
- package/dist/core/image-frame.d.ts +23 -0
- package/dist/core/image-frame.js +24 -0
- package/dist/core/index.d.ts +17 -0
- package/dist/core/index.js +17 -0
- package/dist/core/link-card.d.ts +20 -0
- package/dist/core/link-card.js +70 -0
- package/dist/core/link.d.ts +3 -0
- package/dist/core/link.js +8 -0
- package/dist/core/move.d.ts +11 -0
- package/dist/core/move.js +37 -0
- package/dist/core/paste-html.d.ts +6 -0
- package/dist/core/paste-html.js +384 -0
- package/dist/core/paste.d.ts +21 -0
- package/dist/core/paste.js +108 -0
- package/dist/core/problems.d.ts +31 -0
- package/dist/core/problems.js +54 -0
- package/dist/core/search.d.ts +47 -0
- package/dist/core/search.js +148 -0
- package/dist/core/slash.d.ts +93 -0
- package/dist/core/slash.js +215 -0
- package/dist/core/table.d.ts +34 -0
- package/dist/core/table.js +141 -0
- package/dist/core/uploads.d.ts +23 -0
- package/dist/core/uploads.js +71 -0
- package/dist/core/use-editor.d.ts +19 -0
- package/dist/core/use-editor.js +53 -0
- package/dist/index.d.ts +6 -15
- package/dist/index.js +6 -5668
- package/dist/issues.d.ts +49 -0
- package/dist/issues.js +9 -0
- package/dist/today.d.ts +6 -0
- package/dist/today.js +19 -0
- package/dist/useUpload.d.ts +48 -0
- package/dist/useUpload.js +59 -0
- package/dist/values.d.ts +14 -0
- package/dist/values.js +36 -0
- package/package.json +35 -95
- package/dist/GinkoEditor.vue.d.ts +0 -96
- package/dist/GinkoImagePicker.vue.d.ts +0 -36
- package/dist/agent/AGENTS.md +0 -13
- package/dist/agent/pages/docs/getting-started/collaboration.md +0 -435
- package/dist/agent/pages/docs/getting-started/component-coverage.md +0 -107
- package/dist/agent/pages/docs/getting-started/customize.md +0 -384
- package/dist/agent/pages/docs/getting-started/images.md +0 -188
- package/dist/agent/pages/docs/getting-started/in-place-editing.md +0 -110
- package/dist/agent/pages/docs/getting-started/layout-blocks.md +0 -148
- package/dist/agent/pages/docs/getting-started/runtime.md +0 -111
- package/dist/agent/pages/docs/getting-started.md +0 -128
- package/dist/authoring-D7MJezVG.js +0 -1780
- package/dist/authoring-D7MJezVG.js.map +0 -1
- package/dist/authoring.d.ts +0 -122
- package/dist/authoring.js +0 -2
- package/dist/collaboration.d.ts +0 -14
- package/dist/collaboration.js +0 -907
- package/dist/collaboration.js.map +0 -1
- package/dist/composables/useAssetRequests.d.ts +0 -44
- package/dist/composables/useCollaborationBinding.d.ts +0 -59
- package/dist/composables/useDevice.d.ts +0 -10
- package/dist/composables/useInsertMenu.d.ts +0 -67
- package/dist/composables/useMarkdownSync.d.ts +0 -96
- package/dist/composables/useStableAuthoringKit.d.ts +0 -16
- package/dist/documentConfig-Z6LdrWZj.js +0 -2360
- package/dist/documentConfig-Z6LdrWZj.js.map +0 -1
- package/dist/editorProps.d.ts +0 -124
- package/dist/index.js.map +0 -1
- package/dist/layout-kit.d.ts +0 -922
- package/dist/lib/collaboration/presence-record.d.ts +0 -18
- package/dist/lib/collaboration/presence.d.ts +0 -103
- package/dist/lib/collaboration/protocol.d.ts +0 -133
- package/dist/lib/collaboration/recovery.d.ts +0 -45
- package/dist/lib/collaboration/session.d.ts +0 -163
- package/dist/lib/collaboration/validation.d.ts +0 -42
- package/dist/lib/component-converters.d.ts +0 -119
- package/dist/lib/config/documentConfig.d.ts +0 -19
- package/dist/lib/config/editorConfig.d.ts +0 -38
- package/dist/lib/container-items.d.ts +0 -55
- package/dist/lib/conversionInvariants.d.ts +0 -3
- package/dist/lib/conversionLogger.d.ts +0 -10
- package/dist/lib/conversionPipeline.d.ts +0 -17
- package/dist/lib/conversionState.d.ts +0 -10
- package/dist/lib/conversionTypes.d.ts +0 -50
- package/dist/lib/editor-operations.d.ts +0 -39
- package/dist/lib/environment.d.ts +0 -6
- package/dist/lib/extensions/code-block.d.ts +0 -18
- package/dist/lib/extensions/component-boundary.d.ts +0 -9
- package/dist/lib/extensions/container-items.d.ts +0 -29
- package/dist/lib/extensions/element.d.ts +0 -19
- package/dist/lib/extensions/file.d.ts +0 -24
- package/dist/lib/extensions/heading.d.ts +0 -5
- package/dist/lib/extensions/image-upload.d.ts +0 -39
- package/dist/lib/extensions/image.d.ts +0 -39
- package/dist/lib/extensions/index.d.ts +0 -10
- package/dist/lib/extensions/inline-element.d.ts +0 -13
- package/dist/lib/extensions/markdown-clipboard.d.ts +0 -21
- package/dist/lib/extensions/profile.d.ts +0 -11
- package/dist/lib/extensions/slot.d.ts +0 -16
- package/dist/lib/extensions/span-style.d.ts +0 -15
- package/dist/lib/extensions/video.d.ts +0 -15
- package/dist/lib/image-properties.d.ts +0 -20
- package/dist/lib/input-rules.d.ts +0 -7
- package/dist/lib/markdown.d.ts +0 -11
- package/dist/lib/marks.d.ts +0 -7
- package/dist/lib/mdcToTiptap.d.ts +0 -20
- package/dist/lib/mdcTypes.d.ts +0 -20
- package/dist/lib/nodes.d.ts +0 -57
- package/dist/lib/nodeviews/block-actions.d.ts +0 -7
- package/dist/lib/nodeviews/code.d.ts +0 -4
- package/dist/lib/nodeviews/columns.d.ts +0 -17
- package/dist/lib/nodeviews/component.d.ts +0 -6
- package/dist/lib/nodeviews/icons.d.ts +0 -26
- package/dist/lib/nodeviews/image.d.ts +0 -9
- package/dist/lib/nodeviews/items.d.ts +0 -15
- package/dist/lib/nodeviews/lifecycle.d.ts +0 -45
- package/dist/lib/nodeviews/popover.d.ts +0 -15
- package/dist/lib/nodeviews/settings.d.ts +0 -11
- package/dist/lib/nodeviews/table-operations.d.ts +0 -50
- package/dist/lib/nodeviews/table.d.ts +0 -4
- package/dist/lib/profiles.d.ts +0 -62
- package/dist/lib/property-input.d.ts +0 -10
- package/dist/lib/property-step.d.ts +0 -77
- package/dist/lib/props.d.ts +0 -13
- package/dist/lib/stripStyleNodes.d.ts +0 -2
- package/dist/lib/tiptapToMdc.d.ts +0 -18
- package/dist/presence-record-CLdPZWKC.js +0 -291
- package/dist/presence-record-CLdPZWKC.js.map +0 -1
- package/dist/runtime.d.ts +0 -13
- package/dist/runtime.js +0 -3
- package/dist/style.css +0 -2
- package/dist/types.d.ts +0 -126
- package/dist/ui/GinkoActionButton.vue.d.ts +0 -8
- package/dist/ui/GinkoInsertMenu.vue.d.ts +0 -49
- package/dist/ui/GinkoKeyboardDock.vue.d.ts +0 -15
- package/dist/ui/GinkoNodePopover.vue.d.ts +0 -21
- package/dist/ui/GinkoRecipeIcon.vue.d.ts +0 -6
- package/dist/ui/GinkoSelectionToolbar.vue.d.ts +0 -10
- package/dist/ui/GinkoToolbar.vue.d.ts +0 -26
- package/dist/ui/GinkoToolbarIcon.vue.d.ts +0 -6
- package/dist/ui/block-shortcuts.d.ts +0 -6
- package/dist/ui/commands.d.ts +0 -78
- package/dist/ui/context.d.ts +0 -23
- package/dist/ui/editor-keyboard.d.ts +0 -15
- package/dist/ui/messages.d.ts +0 -214
- package/dist/ui/messages.de.d.ts +0 -6
- package/dist/ui/recipe-command.d.ts +0 -14
- package/dist/ui/recipe-search.d.ts +0 -47
- package/dist/ui/slash-command.d.ts +0 -17
- package/dist/ui/writingRecipes.d.ts +0 -13
- package/skills/ginko-editor/SKILL.md +0 -40
- package/skills/ginko-editor/agents/openai.yaml +0 -4
- package/skills/ginko-editor/references/in-place-editing.md +0 -50
- package/skills/ginko-editor/references/quickstart.md +0 -55
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
3
|
+
import { moveTableColumn, moveTableRow, selectedRect, TableMap } from "@tiptap/pm/tables";
|
|
4
|
+
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
5
|
+
function rectOf(state) {
|
|
6
|
+
for (let d = state.selection.$from.depth; d > 0; d--) {
|
|
7
|
+
if (state.selection.$from.node(d).type.spec.tableRole === "table") return selectedRect(state);
|
|
8
|
+
}
|
|
9
|
+
return void 0;
|
|
10
|
+
}
|
|
11
|
+
const ALIGN = /(?:^|;)\s*text-align\s*:\s*(left|center|right)\s*(?:;|$)/;
|
|
12
|
+
export function alignOf(props) {
|
|
13
|
+
const style = props?.style;
|
|
14
|
+
return typeof style === "string" ? ALIGN.exec(style)?.[1] : void 0;
|
|
15
|
+
}
|
|
16
|
+
const alignAt = (table, map, column) => alignOf(table.nodeAt(map.map[column])?.attrs.props);
|
|
17
|
+
export function inTableCell(state) {
|
|
18
|
+
const { $from } = state.selection;
|
|
19
|
+
for (let d = $from.depth; d > 0; d--) {
|
|
20
|
+
const role = $from.node(d).type.spec.tableRole;
|
|
21
|
+
if (role === "cell" || role === "header_cell") return true;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
export function tableAt(state) {
|
|
26
|
+
const rect = rectOf(state);
|
|
27
|
+
if (!rect) return void 0;
|
|
28
|
+
return { row: rect.top, column: rect.left, rows: rect.map.height, columns: rect.map.width, align: alignAt(rect.table, rect.map, rect.left) };
|
|
29
|
+
}
|
|
30
|
+
function alignDecorations(doc) {
|
|
31
|
+
const shown = [];
|
|
32
|
+
doc.descendants((node, pos) => {
|
|
33
|
+
if (node.type.spec.tableRole !== "table") return !node.isTextblock;
|
|
34
|
+
const map = TableMap.get(node);
|
|
35
|
+
for (let column = 0; column < map.width; column++) {
|
|
36
|
+
const align = alignAt(node, map, column);
|
|
37
|
+
if (!align) continue;
|
|
38
|
+
for (const offset of new Set(map.map.filter((_, i) => i % map.width === column))) {
|
|
39
|
+
const from = pos + 1 + offset;
|
|
40
|
+
shown.push(Decoration.node(from, from + node.nodeAt(offset).nodeSize, { style: `text-align:${align}` }));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
});
|
|
45
|
+
return DecorationSet.create(doc, shown);
|
|
46
|
+
}
|
|
47
|
+
export const TableKeys = Extension.create({
|
|
48
|
+
name: "ginkoTableKeys",
|
|
49
|
+
priority: 1e3,
|
|
50
|
+
addKeyboardShortcuts() {
|
|
51
|
+
const stay = () => inTableCell(this.editor.state);
|
|
52
|
+
return { "Enter": stay, "Shift-Enter": stay, "Mod-Enter": stay };
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const alignKey = new PluginKey("ginkoTableAlign");
|
|
56
|
+
export const TableAlign = Extension.create({
|
|
57
|
+
name: "ginkoTableAlign",
|
|
58
|
+
addProseMirrorPlugins() {
|
|
59
|
+
return [new Plugin({
|
|
60
|
+
key: alignKey,
|
|
61
|
+
state: { init: (_, state) => alignDecorations(state.doc), apply: (tr, old) => tr.docChanged ? alignDecorations(tr.doc) : old },
|
|
62
|
+
props: { decorations: (state) => alignKey.getState(state) }
|
|
63
|
+
})];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
export function canRunTable(state, command) {
|
|
67
|
+
const at = tableAt(state);
|
|
68
|
+
if (!at) return false;
|
|
69
|
+
switch (command) {
|
|
70
|
+
case "addRowBefore":
|
|
71
|
+
return at.row > 0;
|
|
72
|
+
case "moveRowUp":
|
|
73
|
+
return at.row > 1;
|
|
74
|
+
case "moveRowDown":
|
|
75
|
+
return at.row > 0 && at.row < at.rows - 1;
|
|
76
|
+
case "moveColumnLeft":
|
|
77
|
+
return at.column > 0;
|
|
78
|
+
case "moveColumnRight":
|
|
79
|
+
return at.column < at.columns - 1;
|
|
80
|
+
case "deleteRow":
|
|
81
|
+
return at.row > 0;
|
|
82
|
+
case "deleteColumn":
|
|
83
|
+
return at.columns > 1;
|
|
84
|
+
default:
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export function runTable(editor, command) {
|
|
89
|
+
const at = tableAt(editor.state);
|
|
90
|
+
if (!at || !canRunTable(editor.state, command)) return false;
|
|
91
|
+
const chain = editor.chain().focus();
|
|
92
|
+
const move = (kind, by) => chain.command(({ state, dispatch }) => {
|
|
93
|
+
const from = kind === "row" ? at.row : at.column;
|
|
94
|
+
return (kind === "row" ? moveTableRow : moveTableColumn)({ from, to: from + by, select: false })(state, dispatch);
|
|
95
|
+
});
|
|
96
|
+
switch (command) {
|
|
97
|
+
case "addRowBefore":
|
|
98
|
+
return chain.addRowBefore().run();
|
|
99
|
+
case "addRowAfter":
|
|
100
|
+
return chain.addRowAfter().run();
|
|
101
|
+
case "addColumnBefore":
|
|
102
|
+
return chain.addColumnBefore().run();
|
|
103
|
+
case "addColumnAfter":
|
|
104
|
+
return chain.addColumnAfter().run();
|
|
105
|
+
case "moveRowUp":
|
|
106
|
+
return move("row", -1).run();
|
|
107
|
+
case "moveRowDown":
|
|
108
|
+
return move("row", 1).run();
|
|
109
|
+
case "moveColumnLeft":
|
|
110
|
+
return move("column", -1).run();
|
|
111
|
+
case "moveColumnRight":
|
|
112
|
+
return move("column", 1).run();
|
|
113
|
+
case "deleteRow":
|
|
114
|
+
return chain.deleteRow().run();
|
|
115
|
+
case "deleteColumn":
|
|
116
|
+
return chain.deleteColumn().run();
|
|
117
|
+
case "deleteTable":
|
|
118
|
+
return chain.deleteTable().run();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export function setColumnAlign(editor, align) {
|
|
122
|
+
const rect = rectOf(editor.state);
|
|
123
|
+
if (!rect) return false;
|
|
124
|
+
return editor.chain().focus().command(({ tr }) => {
|
|
125
|
+
const seen = /* @__PURE__ */ new Set();
|
|
126
|
+
for (let row = 0; row < rect.map.height; row++) {
|
|
127
|
+
const offset = rect.map.map[row * rect.map.width + rect.left];
|
|
128
|
+
if (seen.has(offset)) continue;
|
|
129
|
+
seen.add(offset);
|
|
130
|
+
const cell = rect.table.nodeAt(offset);
|
|
131
|
+
if (!cell) continue;
|
|
132
|
+
const props = { ...cell.attrs.props };
|
|
133
|
+
const rest = typeof props.style === "string" ? props.style.replace(ALIGN, ";").replace(/^;|;$/g, "").trim() : "";
|
|
134
|
+
const style = [rest, align && `text-align:${align}`].filter(Boolean).join(";");
|
|
135
|
+
if (style) props.style = style;
|
|
136
|
+
else delete props.style;
|
|
137
|
+
tr.setNodeAttribute(rect.tableStart + offset, "props", props);
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
}).run();
|
|
141
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Extension, type Editor } from '@tiptap/core';
|
|
2
|
+
/** The default (German) text of the placeholder; `startUpload` takes the text in the UI language. */
|
|
3
|
+
export declare const UPLOADING_TEXT = "wird hochgeladen \u2026";
|
|
4
|
+
export declare function uploadPlaceholders(): Extension<any, any>;
|
|
5
|
+
/**
|
|
6
|
+
* Shows the place at `pos`, called `id`, with `text` (default German) in it. With `replace`, `pos` is a picture that the
|
|
7
|
+
* upload replaces: the place shows after it, and the picture stays until `finishUpload`. Returns false when the editor
|
|
8
|
+
* has no such place (a profile without images).
|
|
9
|
+
*/
|
|
10
|
+
export declare function startUpload(editor: Editor, id: string, pos: number, text?: string, replace?: boolean): boolean;
|
|
11
|
+
/** True while the place `id` is in the document. */
|
|
12
|
+
export declare const isUploading: (editor: Editor, id: string) => boolean;
|
|
13
|
+
/** Removes the place without inserting anything (upload failed or cancelled). */
|
|
14
|
+
export declare function cancelUpload(editor: Editor, id: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Swaps the place `id` for the image; a replacing place also removes its picture, when that is still there unchanged
|
|
17
|
+
* (else the image goes in at the place). Returns the position of the image, or undefined when the place is gone (the
|
|
18
|
+
* text around it was deleted) and nothing was inserted.
|
|
19
|
+
*/
|
|
20
|
+
export declare function finishUpload(editor: Editor, id: string, image: {
|
|
21
|
+
src: string;
|
|
22
|
+
alt: string;
|
|
23
|
+
}): number | undefined;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
3
|
+
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
4
|
+
export const UPLOADING_TEXT = "wird hochgeladen \u2026";
|
|
5
|
+
const key = new PluginKey("ginkoUploads");
|
|
6
|
+
function placeholder(text) {
|
|
7
|
+
const el = document.createElement("span");
|
|
8
|
+
el.className = "ginko-uploading";
|
|
9
|
+
el.setAttribute("data-ginko-uploading", "");
|
|
10
|
+
el.setAttribute("contenteditable", "false");
|
|
11
|
+
el.setAttribute("role", "status");
|
|
12
|
+
el.textContent = text;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
export function uploadPlaceholders() {
|
|
16
|
+
return Extension.create({
|
|
17
|
+
name: "ginkoUploads",
|
|
18
|
+
addProseMirrorPlugins() {
|
|
19
|
+
return [new Plugin({
|
|
20
|
+
key,
|
|
21
|
+
state: {
|
|
22
|
+
init: () => DecorationSet.empty,
|
|
23
|
+
apply(tr, set) {
|
|
24
|
+
const next = set.map(tr.mapping, tr.doc);
|
|
25
|
+
const meta = tr.getMeta(key);
|
|
26
|
+
if (meta?.add) {
|
|
27
|
+
const { id, pos, text, replaces } = meta.add;
|
|
28
|
+
return next.add(tr.doc, [Decoration.widget(pos, () => placeholder(text), { id, side: replaces === void 0 ? 1 : -1, key: id, replaces })]);
|
|
29
|
+
}
|
|
30
|
+
if (meta?.remove) return next.remove(next.find(void 0, void 0, (spec) => spec.id === meta.remove));
|
|
31
|
+
return next;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
props: { decorations: (state) => key.getState(state) }
|
|
35
|
+
})];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const found = (editor, id) => key.getState(editor.state)?.find(void 0, void 0, (spec) => spec.id === id)[0];
|
|
40
|
+
const where = (editor, id) => found(editor, id)?.from;
|
|
41
|
+
export function startUpload(editor, id, pos, text = UPLOADING_TEXT, replace = false) {
|
|
42
|
+
if (!key.getState(editor.state) || !editor.schema.nodes.image) return false;
|
|
43
|
+
const old = replace ? editor.state.doc.nodeAt(pos) : void 0;
|
|
44
|
+
const add = old?.type.name === "image" ? { id, pos: pos + old.nodeSize, text, replaces: String(old.attrs.src ?? "") } : { id, pos, text };
|
|
45
|
+
editor.view.dispatch(editor.state.tr.setMeta(key, { add }));
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
export const isUploading = (editor, id) => where(editor, id) !== void 0;
|
|
49
|
+
export function cancelUpload(editor, id) {
|
|
50
|
+
if (editor.isDestroyed) return;
|
|
51
|
+
editor.view.dispatch(editor.state.tr.setMeta(key, { remove: id }));
|
|
52
|
+
}
|
|
53
|
+
export function finishUpload(editor, id, image) {
|
|
54
|
+
if (editor.isDestroyed) return void 0;
|
|
55
|
+
const place = found(editor, id);
|
|
56
|
+
if (!place) return void 0;
|
|
57
|
+
const type = editor.schema.nodes.image;
|
|
58
|
+
if (!type) {
|
|
59
|
+
cancelUpload(editor, id);
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
const at = place.from;
|
|
63
|
+
const replaces = place.spec.replaces;
|
|
64
|
+
const before = editor.state.doc.resolve(at).nodeBefore;
|
|
65
|
+
const old = replaces !== void 0 && before?.type.name === "image" && String(before.attrs.src ?? "") === replaces ? before : void 0;
|
|
66
|
+
const tr = editor.state.tr.setMeta(key, { remove: id });
|
|
67
|
+
const from = old ? at - old.nodeSize : at;
|
|
68
|
+
tr.replaceWith(from, at, type.create({ src: image.src, alt: image.alt }));
|
|
69
|
+
editor.view.dispatch(tr);
|
|
70
|
+
return from;
|
|
71
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import { type GinkoEditorHandle, type GinkoEditorOptions } from './editor.js';
|
|
3
|
+
export declare function useGinkoEditor(options: MaybeRefOrGetter<GinkoEditorOptions>): {
|
|
4
|
+
/** Resolves when the first open() is done. */
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
open: () => Promise<void>;
|
|
7
|
+
destroy: () => void;
|
|
8
|
+
handle: import("vue").ShallowRef<GinkoEditorHandle | undefined, GinkoEditorHandle | undefined>;
|
|
9
|
+
/** `undefined` until opened. */
|
|
10
|
+
mode: import("vue").ComputedRef<"rich" | "source" | undefined>;
|
|
11
|
+
/** The TipTap editor in rich mode, for `<EditorContent>`. */
|
|
12
|
+
editor: import("vue").ComputedRef<import("@tiptap/core").Editor | undefined>;
|
|
13
|
+
problems: import("vue").ComputedRef<string[]>;
|
|
14
|
+
/** `problems` with catalog key and parameters, for `coreMessage(locale, key, params)`. */
|
|
15
|
+
problemMessages: import("vue").ComputedRef<import("@lupinum/ginko/internal").Described[]>;
|
|
16
|
+
dirty: import("vue").Ref<boolean, boolean>;
|
|
17
|
+
/** The Markdown for the field. Before the editor is open, an empty string. */
|
|
18
|
+
markdown: () => Promise<string>;
|
|
19
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { computed, getCurrentScope, onScopeDispose, ref, shallowRef, toValue } from "vue";
|
|
2
|
+
import { createGinkoEditor } from "./editor.js";
|
|
3
|
+
export function useGinkoEditor(options) {
|
|
4
|
+
const handle = shallowRef();
|
|
5
|
+
const dirty = ref(false);
|
|
6
|
+
let stop;
|
|
7
|
+
let run = 0;
|
|
8
|
+
let ended = false;
|
|
9
|
+
const close = () => {
|
|
10
|
+
stop?.();
|
|
11
|
+
stop = void 0;
|
|
12
|
+
handle.value?.destroy();
|
|
13
|
+
handle.value = void 0;
|
|
14
|
+
dirty.value = false;
|
|
15
|
+
};
|
|
16
|
+
async function open() {
|
|
17
|
+
const mine = ++run;
|
|
18
|
+
const next = await createGinkoEditor(toValue(options));
|
|
19
|
+
if (mine !== run || ended) {
|
|
20
|
+
next.destroy();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
close();
|
|
24
|
+
handle.value = next;
|
|
25
|
+
stop = next.onChange(() => {
|
|
26
|
+
dirty.value = next.dirty;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function destroy() {
|
|
30
|
+
ended = true;
|
|
31
|
+
run++;
|
|
32
|
+
close();
|
|
33
|
+
}
|
|
34
|
+
if (getCurrentScope()) onScopeDispose(destroy);
|
|
35
|
+
const ready = open();
|
|
36
|
+
return {
|
|
37
|
+
/** Resolves when the first open() is done. */
|
|
38
|
+
ready,
|
|
39
|
+
open,
|
|
40
|
+
destroy,
|
|
41
|
+
handle,
|
|
42
|
+
/** `undefined` until opened. */
|
|
43
|
+
mode: computed(() => handle.value?.mode),
|
|
44
|
+
/** The TipTap editor in rich mode, for `<EditorContent>`. */
|
|
45
|
+
editor: computed(() => handle.value?.editor),
|
|
46
|
+
problems: computed(() => handle.value?.problems ?? []),
|
|
47
|
+
/** `problems` with catalog key and parameters, for `coreMessage(locale, key, params)`. */
|
|
48
|
+
problemMessages: computed(() => handle.value?.problemMessages ?? []),
|
|
49
|
+
dirty,
|
|
50
|
+
/** The Markdown for the field. Before the editor is open, an empty string. */
|
|
51
|
+
markdown: async () => await handle.value?.markdown() ?? ""
|
|
52
|
+
};
|
|
53
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export { defaultMessages } from './ui/messages.js';
|
|
8
|
-
export { germanMessages } from './ui/messages.de';
|
|
9
|
-
export { editorProfiles, findProfileViolations, sanitizeFragment } from './lib/profiles.js';
|
|
10
|
-
export type { EditorProfile, EditorProfileName, EditorProfileViolation } from './lib/profiles.js';
|
|
11
|
-
export type { EditorMessageKey, EditorMessageParams } from './ui/messages.js';
|
|
12
|
-
export { composeAuthoringKits, createAuthoringKit, createGinkoLayoutKit, ginkoLayoutComponentNames, ginkoLayoutComponentPolicy, ginkoLayoutKitSource, parseAuthoringSource, } from './authoring.js';
|
|
13
|
-
export type { AuthoringControl, AuthoringKit, AuthoringKitSource, AuthoringRecipe, ComponentAuthoringField, ComponentAuthoringMetadata, ComponentCanvasItems, ComponentItemsPresentation, ComponentImplementationMetadata, ComponentImplementationProp, ImplementationPropType, AuthoringKitSourceV1, AuthoringKitV1, AuthoringRecipeV1, ComponentAuthoringFieldV1, ComponentAuthoringMetadataV1, ComponentImplementationMetadataV1, ComponentImplementationPropV1, } from './authoring.js';
|
|
14
|
-
export type { AssetInfo, AssetProvider, EditorAssetReference, EditorAssetRequest, EditorFile, EditorFlushError, EditorFlushResult, EditorFlushStateError, EditorFlushStateErrorCode, EditorImage, EditorImagePickerItem, EditorVideo, GinkoEditorHandle, ImagePicker, ImageUploadHandler, JsonPrimitive, JsonRecord, JsonValue, LegacyImageUploadResult, VideoInfo, } from './types.js';
|
|
15
|
-
export type { ConversionErrorPayload, ConversionHealthState, ConversionIssue, ConversionIssueCode, ConversionPhase, ConversionRecoveredPayload, ConversionSeverity, ConversionTraceEvent, } from './lib/conversionPipeline.js';
|
|
1
|
+
export * from './assets.js';
|
|
2
|
+
export * from './issues.js';
|
|
3
|
+
export * from './today.js';
|
|
4
|
+
export * from './useUpload.js';
|
|
5
|
+
export * from './values.js';
|
|
6
|
+
export * from './core/index.js';
|