@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
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Layout blocks"
|
|
3
|
-
description: "Use the built-in layout kit and learn what each block can edit."
|
|
4
|
-
url: "https://ginko-editor.lupinum.com/docs/getting-started/layout-blocks"
|
|
5
|
-
route: "/docs/getting-started/layout-blocks"
|
|
6
|
-
locale: "en"
|
|
7
|
-
section: "Documentation"
|
|
8
|
-
collection: "docs"
|
|
9
|
-
source: "ginko-content"
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
> Use the built-in layout kit and learn what each block can edit.
|
|
13
|
-
|
|
14
|
-
# Layout blocks
|
|
15
|
-
|
|
16
|
-
The editor includes a layout kit. It contains the Ginko Docs components, for
|
|
17
|
-
example callouts, tabs, accordions, steps, cards, and timelines. The kit uses
|
|
18
|
-
the Ginko Docs component policy without changes. A document that you write
|
|
19
|
-
with this kit renders on a Ginko Docs site.
|
|
20
|
-
|
|
21
|
-
## Add the kit
|
|
22
|
-
|
|
23
|
-
Import the kit from the `authoring` entry. It has no Vue dependency, so you can
|
|
24
|
-
also use it on a server.
|
|
25
|
-
|
|
26
|
-
```ts [authoring.ts]
|
|
27
|
-
import {
|
|
28
|
-
composeAuthoringKits,
|
|
29
|
-
createGinkoLayoutKit,
|
|
30
|
-
ginkoLayoutKitSource,
|
|
31
|
-
} from '@lupinum/ginko-editor/authoring'
|
|
32
|
-
|
|
33
|
-
// The layout kit alone.
|
|
34
|
-
export const layoutKit = await createGinkoLayoutKit()
|
|
35
|
-
|
|
36
|
-
// The layout kit and your own components.
|
|
37
|
-
export const kit = await composeAuthoringKits(ginkoLayoutKitSource, hostKitSource)
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Pass the kit to the `authoring-kit` property of `GinkoEditor`. Each component
|
|
41
|
-
tag can occur in one source only. Do not compose this kit with another kit that
|
|
42
|
-
also defines the Docs tags.
|
|
43
|
-
|
|
44
|
-
Your reading site must render the same tags. A Ginko Docs site renders them
|
|
45
|
-
with its `Mdc*` components. `ginkoLayoutComponentNames` lists the component
|
|
46
|
-
name for each tag. `ginkoLayoutComponentPolicy` is the policy for your Content
|
|
47
|
-
configuration.
|
|
48
|
-
|
|
49
|
-
## Insert a block
|
|
50
|
-
|
|
51
|
-
Type `/` or select **Insert**. The layout blocks are in the **Layout**,
|
|
52
|
-
**Callouts**, **Media**, **Text**, and **Advanced** groups. Each recipe inserts
|
|
53
|
-
a complete example that you can change:
|
|
54
|
-
|
|
55
|
-
- **Tabs** inserts two tabs.
|
|
56
|
-
- **Accordion** inserts two items.
|
|
57
|
-
- **Steps** inserts three steps. Each level-three heading starts a step.
|
|
58
|
-
- **Cards** inserts a grid with two cards.
|
|
59
|
-
- **Timeline** inserts two events.
|
|
60
|
-
- **Code group** inserts two code blocks with file names.
|
|
61
|
-
|
|
62
|
-
## Edit containers
|
|
63
|
-
|
|
64
|
-
Tabs, accordions, steps, cards, timelines, code groups, code trees, and quizzes
|
|
65
|
-
are containers. The canvas shows their items and an add control.
|
|
66
|
-
|
|
67
|
-
| Container | On the canvas |
|
|
68
|
-
| --- | --- |
|
|
69
|
-
| Tabs | A tab strip above the content. Select a tab to show and edit its content. **+** adds a tab after the selected tab. |
|
|
70
|
-
| Code group | A tab strip with the file name or language of each code block. **+** adds a code block. |
|
|
71
|
-
| Accordion | Each item has an editable title. The arrow collapses an item in this view only. |
|
|
72
|
-
| Steps | A number beside each level-three heading. **Add step** adds a heading and a paragraph at the end. |
|
|
73
|
-
| Cards | A grid with the number of columns from the `cols` property. |
|
|
74
|
-
| Timeline | A marker beside each event. |
|
|
75
|
-
| Code tree, quiz | A list of items with an add control. |
|
|
76
|
-
|
|
77
|
-
Use the tab strip with the keyboard:
|
|
78
|
-
|
|
79
|
-
- The arrow keys, Home, and End select a tab.
|
|
80
|
-
- Enter or the Down arrow moves the caret into the tab content.
|
|
81
|
-
- F2 or a double-click renames a tab. Enter saves the name. Escape cancels.
|
|
82
|
-
- Delete removes a tab.
|
|
83
|
-
|
|
84
|
-
When a tab or an item has content, the remove control asks for a second
|
|
85
|
-
selection to confirm. A container always keeps one item. To remove the last item,
|
|
86
|
-
remove the whole block from its settings.
|
|
87
|
-
|
|
88
|
-
Each add, remove, and rename is one change. One Undo reverses it. Each change
|
|
89
|
-
must pass the Content policy, like all other component edits. When the policy
|
|
90
|
-
rejects a change, the document stays the same and the canvas shows a message.
|
|
91
|
-
|
|
92
|
-
The selected tab and collapsed accordion items are view state. They are not
|
|
93
|
-
saved in the document, in the undo history, or in collaboration steps. When the
|
|
94
|
-
caret moves into a hidden tab, that tab becomes visible.
|
|
95
|
-
|
|
96
|
-
When the caret is inside a tab or an item, the block menu shows the add action
|
|
97
|
-
of that container first, for example **Add tab**.
|
|
98
|
-
|
|
99
|
-
## Block reference
|
|
100
|
-
|
|
101
|
-
| Block | Tags | What you can edit | Limits |
|
|
102
|
-
| --- | --- | --- | --- |
|
|
103
|
-
| Callouts | `note`, `info`, `warning`, `error`, `success`, `idea` | Title on the canvas, icon, appearance, and content. Switch between callout types in the settings. | None. |
|
|
104
|
-
| Aside, excerpt | `aside`, `excerpt` | Label on the canvas, source, appearance, and content. | None. |
|
|
105
|
-
| Columns | `layout`, `column` | Content of each column. The divider sets both widths. | A column must stay inside a layout. |
|
|
106
|
-
| Tabs | `tabs`, `tab` | Tab names, tab icons, layout, padding, and tab content. | The editor shows one tab at a time. |
|
|
107
|
-
| Accordion | `accordion`, `accordion-item` | Item titles, item values, open items (JSON), and content. | The `title` and `content` slots are kept but have no separate editor. |
|
|
108
|
-
| Steps | `steps` | Step headings, step content, and mode. | Only level-three headings start a step. |
|
|
109
|
-
| Cards | `cards`, `card` | Card titles, descriptions, links, icons, images (URL), and content. | The `title`, `description`, and `footer` slots have no separate editor. |
|
|
110
|
-
| Timeline | `timeline`, `timeline-item` | Event titles, dates, labels, icons, the current event, and content. | None. |
|
|
111
|
-
| Code group | `code-group` | Code, language, and file name of each code block. | Only code blocks are items. |
|
|
112
|
-
| Code tree | `code-tree` | Code blocks with file paths, the selected file, and folder expansion. | The canvas shows a list, not a file tree. |
|
|
113
|
-
| Files | `files` | The file list, the highlighted path, and annotations (JSON). | The canvas shows the Markdown list. |
|
|
114
|
-
| Collapse | `collapse` | Content and appearance. | The canvas always shows all content. |
|
|
115
|
-
| Center | `center` | Size, maximum width, style, and content. | None. |
|
|
116
|
-
| Figure | `figure` | Image URL, alternative text, caption, aspect, fit, size, bleed, and zoom. | Enter the image URL in the settings. The image picker does not fill it. |
|
|
117
|
-
| Drop cap | `dropcap` | Number of lines (JSON) and content. | The canvas does not show the large letter. |
|
|
118
|
-
| Keyboard key | `kbd` | The key text in a sentence. | Inline only. |
|
|
119
|
-
| Read more | `read-more` | Title and links (JSON). | The canvas shows no link list. |
|
|
120
|
-
| Table of contents | `toc` | Title, depth (JSON), and open state (JSON). | The canvas does not show the headings. |
|
|
121
|
-
| Quiz | `quiz`, `quiz-question` | Quiz text and labels, questions, choices (JSON), and explanations. | The canvas does not check answers. |
|
|
122
|
-
| API reference | `api` | Title, icon, method, path, and groups (JSON). | The Docs renderer shows only the groups. It does not show block content. |
|
|
123
|
-
|
|
124
|
-
The Markdown image is the editor's own image block. The Docs `img` renderer shows
|
|
125
|
-
it. It is not part of this kit.
|
|
126
|
-
|
|
127
|
-
## JSON properties
|
|
128
|
-
|
|
129
|
-
Some properties hold structured data, for example read-more links or quiz
|
|
130
|
-
choices. Their settings field accepts JSON text. The editor applies the value
|
|
131
|
-
only when the text is valid JSON. When the text is not valid, the field shows an
|
|
132
|
-
error and the document keeps the previous value. You cannot clear a required
|
|
133
|
-
JSON property.
|
|
134
|
-
|
|
135
|
-
```json [Quiz choices]
|
|
136
|
-
[
|
|
137
|
-
{ "text": "Descriptive alternative text", "correct": true },
|
|
138
|
-
{ "text": "A longer file name", "correct": false }
|
|
139
|
-
]
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## Source syntax
|
|
143
|
-
|
|
144
|
-
The recipes use the colon syntax of the Docs examples, for example `::tabs`.
|
|
145
|
-
Colon syntax stores number and boolean properties as text. When a block has
|
|
146
|
-
such a property, the editor saves that block with angle syntax, for example
|
|
147
|
-
`<Toc :depth="2" />`. The property then keeps its type, and the Docs policy
|
|
148
|
-
accepts it. The block renders the same way.
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Validate content on the server"
|
|
3
|
-
description: "Use the same schema and conversion boundary without mounting a Vue editor."
|
|
4
|
-
url: "https://ginko-editor.lupinum.com/docs/getting-started/runtime"
|
|
5
|
-
route: "/docs/getting-started/runtime"
|
|
6
|
-
locale: "en"
|
|
7
|
-
section: "Documentation"
|
|
8
|
-
collection: "docs"
|
|
9
|
-
source: "ginko-content"
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
> Use the same schema and conversion boundary without mounting a Vue editor.
|
|
13
|
-
|
|
14
|
-
# Validate content on the server
|
|
15
|
-
|
|
16
|
-
Import `@lupinum/ginko-editor/runtime` when a backend needs to validate an editor
|
|
17
|
-
document or prepare a content checkpoint. This entry shares its schema and
|
|
18
|
-
conversion code with the visual editor. It does not import Vue views, styles,
|
|
19
|
-
or browser globals.
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
import {
|
|
23
|
-
createEditorSchema,
|
|
24
|
-
prepareMarkdownForVisualEditing,
|
|
25
|
-
convertTiptapDocToMarkdown,
|
|
26
|
-
} from '@lupinum/ginko-editor/runtime'
|
|
27
|
-
|
|
28
|
-
const schema = createEditorSchema()
|
|
29
|
-
const prepared = await prepareMarkdownForVisualEditing(source, undefined, schema, authoringKit)
|
|
30
|
-
if (!prepared.ok || !prepared.value) {
|
|
31
|
-
throw new Error('This source needs source editing.')
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const document = schema.nodeFromJSON(prepared.value)
|
|
35
|
-
document.check()
|
|
36
|
-
const checkpoint = await convertTiptapDocToMarkdown(document.toJSON())
|
|
37
|
-
if (!checkpoint.ok) {
|
|
38
|
-
throw new Error('The document cannot be saved as portable content.')
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Use the same authoring kit and output options as the host editor. Components,
|
|
43
|
-
properties, and slots remain subject to the shared Content policy. Inspect
|
|
44
|
-
the returned `issues` to explain a rejected conversion. Never replace failed
|
|
45
|
-
content with an empty document.
|
|
46
|
-
|
|
47
|
-
The schema describes supported node structure. A structurally valid document
|
|
48
|
-
can still contain values that fail a host's content policy. Validate both before
|
|
49
|
-
accepting a checkpoint. Authorization, version checks, storage, and document
|
|
50
|
-
identity belong to the host. This entry does not provide a collaboration server.
|
|
51
|
-
|
|
52
|
-
The runtime uses the package's pinned TipTap dependencies. Use the same package
|
|
53
|
-
version on the server and client when exchanging editor documents.
|
|
54
|
-
|
|
55
|
-
## Preserve property changes
|
|
56
|
-
|
|
57
|
-
`createEditorSchema()` also registers `SetNodePropertyStep` and
|
|
58
|
-
`SetComponentVariantStep`, and `SetNodeAttributeStep` for decoding editor operations. The canvas uses the
|
|
59
|
-
property step for individual component settings, titles,
|
|
60
|
-
and column sizes. A step changes one property on the current node. It keeps
|
|
61
|
-
other properties and the node's current body.
|
|
62
|
-
|
|
63
|
-
```ts
|
|
64
|
-
import { SetNodePropertyStep } from '@lupinum/ginko-editor/runtime'
|
|
65
|
-
|
|
66
|
-
const step = new SetNodePropertyStep(position, 'title', 'A useful title')
|
|
67
|
-
const wireValue = step.toJSON()
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Use `undefined` to remove a property and `null` to store a null value. The wire
|
|
71
|
-
format uses an explicit removal flag. Independent property changes survive
|
|
72
|
-
rebasing, which adjusts pending operations after another edit. For two changes
|
|
73
|
-
to the same property, the last accepted operation wins. This is a field update,
|
|
74
|
-
not character-by-character collaboration within a title input. Consecutive typing
|
|
75
|
-
in one property field forms an undo group. Variant changes keep the tag and its
|
|
76
|
-
source metadata together while preserving other properties and body text.
|
|
77
|
-
|
|
78
|
-
The step validates its wire shape. The host must still validate the resulting
|
|
79
|
-
document against the Content policy and enforce authorization. Deploy clients
|
|
80
|
-
and servers that understand `ginkoSetNodePropertyV1` together before exchanging
|
|
81
|
-
these operations. Variant changes use `ginkoSetComponentVariantV1`. Older clients
|
|
82
|
-
cannot decode these steps.
|
|
83
|
-
|
|
84
|
-
`SetNodeAttributeStep` uses `ginkoSetNodeAttributeV1` for schema attributes such
|
|
85
|
-
as a code block's language or filename. It changes one declared attribute and
|
|
86
|
-
preserves the other attributes and current body. Component properties still use
|
|
87
|
-
`SetNodePropertyStep`.
|
|
88
|
-
|
|
89
|
-
For shared documents, use the [collaboration boundary](/raw/docs/getting-started/collaboration.md)
|
|
90
|
-
to validate exact-version batches and produce source checkpoints.
|
|
91
|
-
|
|
92
|
-
## Enforce a content profile
|
|
93
|
-
|
|
94
|
-
The editor's `profile` prop limits what a writer can create. The editor does
|
|
95
|
-
not change content that it loads, and a writer can still use the source view of
|
|
96
|
-
the default variant. Check the profile again where you store the document.
|
|
97
|
-
|
|
98
|
-
```ts
|
|
99
|
-
import { createEditorSchema, findProfileViolations } from '@lupinum/ginko-editor/runtime'
|
|
100
|
-
|
|
101
|
-
const violations = findProfileViolations(document.toJSON(), 'inline')
|
|
102
|
-
if (violations.length) {
|
|
103
|
-
throw new Error(`Remove ${violations.map(item => item.type).join(', ')} from this text.`)
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
`findProfileViolations` accepts TipTap JSON or a ProseMirror node. Each entry
|
|
108
|
-
has a `kind` (`node` or `mark`), a `type`, and, for a heading, its `level`.
|
|
109
|
-
`editorProfiles` contains the allowed node and mark names of each profile.
|
|
110
|
-
`sanitizeFragment(fragment, schema, profile)` reduces content to a profile in
|
|
111
|
-
the same way as paste.
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Getting started"
|
|
3
|
-
description: "Install Ginko Editor and use its first API."
|
|
4
|
-
url: "https://ginko-editor.lupinum.com/docs/getting-started"
|
|
5
|
-
route: "/docs/getting-started"
|
|
6
|
-
locale: "en"
|
|
7
|
-
section: "Documentation"
|
|
8
|
-
collection: "docs"
|
|
9
|
-
source: "ginko-content"
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
> Install Ginko Editor and use its first API.
|
|
13
|
-
|
|
14
|
-
# Get started with Ginko Editor
|
|
15
|
-
|
|
16
|
-
A portable Vue editor for Ginko content.
|
|
17
|
-
|
|
18
|
-
## Install
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
pnpm add @lupinum/ginko-editor @lupinum/ginko-content @tiptap/core @tiptap/pm @tiptap/vue-3 vue
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Use the package
|
|
25
|
-
|
|
26
|
-
```vue
|
|
27
|
-
<script setup lang="ts">
|
|
28
|
-
import { ref } from 'vue'
|
|
29
|
-
import { GinkoEditor } from '@lupinum/ginko-editor'
|
|
30
|
-
import '@lupinum/ginko-editor/style.css'
|
|
31
|
-
|
|
32
|
-
const source = ref('# Hello\n')
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
<template>
|
|
36
|
-
<GinkoEditor v-model="source" :enable-images="false" :enable-files="false" :enable-video="false" />
|
|
37
|
-
</template>
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
The Markdown source is the canonical value. Opening the editor and changing
|
|
41
|
-
modes do not rewrite it. The editor keeps invalid or unsupported documents in
|
|
42
|
-
source mode so that visual editing cannot discard content.
|
|
43
|
-
|
|
44
|
-
## Write and insert blocks
|
|
45
|
-
|
|
46
|
-
Type `/` at the start of a paragraph, or select **Insert**. Search for a block,
|
|
47
|
-
use the arrow keys to choose it, and press Enter. Escape closes the menu and
|
|
48
|
-
returns focus to the document. Normal headings, lists, quotes, code, dividers,
|
|
49
|
-
tables, and image requests are available without a component kit.
|
|
50
|
-
|
|
51
|
-
An `authoring-kit` adds the host's component recipes to the same menu. The
|
|
52
|
-
built-in [layout kit](/raw/docs/getting-started/layout-blocks.md) adds the Ginko Docs
|
|
53
|
-
components, such as tabs, accordions, steps, and cards. Recipe
|
|
54
|
-
`keywords` provide aliases such as `/note`. An optional `description` explains
|
|
55
|
-
what the recipe does. Component titles and labels appear on the writing canvas;
|
|
56
|
-
edit a title directly, or open the block’s cog to change its properties, switch
|
|
57
|
-
callout type, duplicate it, or delete it. Two-column layouts have a divider that
|
|
58
|
-
snaps to three width pairs; drag it or use the arrow keys. Table row and column
|
|
59
|
-
actions appear in small icon menus beside the active table.
|
|
60
|
-
|
|
61
|
-
The `recipe-preview` slot receives `{ recipe }`. Use `recipe.source` with Ginko
|
|
62
|
-
Content's parser, the kit's policy, and your own registered render components to
|
|
63
|
-
show the real component. The editor does not import host components or choose
|
|
64
|
-
how they render. The playground demonstrates this integration,
|
|
65
|
-
including a component library and a live reader preview.
|
|
66
|
-
|
|
67
|
-
## Save and select assets
|
|
68
|
-
|
|
69
|
-
Your application owns saving and asset storage. For inline uploads, pass an
|
|
70
|
-
`image-upload` callback; it receives `(file, { signal })` and resolves with a
|
|
71
|
-
durable `{ url, alt }`, or an `{ id }` resolved by `asset-provider`. Add image,
|
|
72
|
-
`/image`, and Replace image use a drop zone with a file chooser. The editor accepts
|
|
73
|
-
one image per placeholder, up to 10 MB by default. Set `image-max-bytes` to change
|
|
74
|
-
the limit. Reject to show an error and allow retry.
|
|
75
|
-
Respect the signal to cancel abandoned uploads.
|
|
76
|
-
|
|
77
|
-
You can also drop a file onto the editor without inserting a placeholder first.
|
|
78
|
-
Confirm Add image, or drop onto an existing editor image and confirm Replace
|
|
79
|
-
image in a popover attached to that image without moving the document. Cancel
|
|
80
|
-
leaves the document unchanged. To accept drops across a larger
|
|
81
|
-
workspace, pass its element as `image-drop-target`; drops outside the editor
|
|
82
|
-
append to the document. Other nested editors retain their own drop handling.
|
|
83
|
-
|
|
84
|
-
Unfinished uploads count as pending changes and block `flush()` with
|
|
85
|
-
`image_upload_pending`. Finish or remove them before leaving. The docs playground
|
|
86
|
-
stores images locally in this browser; a production host supplies durable storage.
|
|
87
|
-
|
|
88
|
-
Add `image-picker` to browse existing images in the same add/replace flow. It
|
|
89
|
-
receives `{ signal, current? }` and resolves a stored image reference, a durable
|
|
90
|
-
URL, or `null` on cancellation. `GinkoImagePicker` supplies a controlled library
|
|
91
|
-
dialog; your application provides its data and search. See [Images](/raw/docs/getting-started/images.md)
|
|
92
|
-
for the callback adapter.
|
|
93
|
-
|
|
94
|
-
When neither image callback is provided, handle `request-image`. For files and
|
|
95
|
-
video, handle `request-file` and `request-video`. Complete the request with
|
|
96
|
-
`request.complete(asset)`, or `request.complete(null)` on cancellation.
|
|
97
|
-
Each request can complete once. Cancellation is permanent. Completion returns
|
|
98
|
-
`false` if no asset was applied, including an empty source or a changed document,
|
|
99
|
-
selection, mode, or editability. Disable unsupported pickers with
|
|
100
|
-
`:enable-images="false"`, `:enable-files="false"`, or `:enable-video="false"`.
|
|
101
|
-
These flags control insertion; existing media remains readable and removable.
|
|
102
|
-
Validate the chosen asset against your content contract before completing it.
|
|
103
|
-
Set `image-output="markdown"` for native Markdown image output.
|
|
104
|
-
|
|
105
|
-
Before navigation or document replacement, await the editor's `flush()` method.
|
|
106
|
-
Continue only when it returns `{ ok: true }`, then await your own save operation.
|
|
107
|
-
Keep the editor available when flush fails so the author can correct the
|
|
108
|
-
document or use Undo. The editor blocks a switch to Markdown while visual edits
|
|
109
|
-
cannot be converted safely.
|
|
110
|
-
|
|
111
|
-
Copy and Cut produce raw Markdown and component source, including titles and
|
|
112
|
-
properties. You can share that source with AI tools or paste it back. Text
|
|
113
|
-
selected within a title or settings input keeps normal text copying. Markdown paste passes through
|
|
114
|
-
Content's parser and the editor's fidelity checks. If a paste cannot preserve
|
|
115
|
-
meaning, the editor leaves the document unchanged and shows a message.
|
|
116
|
-
|
|
117
|
-
The playground saves drafts only in the current browser. It offers Write,
|
|
118
|
-
Split view, and Preview modes. Opening an example or a new page offers an Undo
|
|
119
|
-
action to recover the previous page. These host behaviors are examples, not
|
|
120
|
-
persistence services inside the editor package.
|
|
121
|
-
|
|
122
|
-
## Customize the writing experience
|
|
123
|
-
|
|
124
|
-
The default toolbar includes text styles, lists, formatting, code blocks, tables,
|
|
125
|
-
and image actions. Use [Customize the editor](/raw/docs/getting-started/customize.md) to
|
|
126
|
-
choose commands, use your own shadcn buttons, change messages and shortcuts, or
|
|
127
|
-
place overlays inside a host dialog. Check [Component coverage](/raw/docs/getting-started/component-coverage.md)
|
|
128
|
-
before enabling a Docs component in an authoring kit.
|