@astl/editor-tiptap 0.0.0 → 0.1.1
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 +111 -0
- package/LICENSE +202 -0
- package/README.md +49 -0
- package/dist/adapter.d.ts +13 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +421 -0
- package/dist/adapter.js.map +1 -0
- package/dist/blocks.d.ts +96 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +460 -0
- package/dist/blocks.js.map +1 -0
- package/dist/define.d.ts +64 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +20 -0
- package/dist/define.js.map +1 -0
- package/dist/element.d.ts +91 -0
- package/dist/element.d.ts.map +1 -0
- package/dist/element.js +779 -0
- package/dist/element.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts.d.ts +52 -0
- package/dist/layouts.d.ts.map +1 -0
- package/dist/layouts.js +198 -0
- package/dist/layouts.js.map +1 -0
- package/dist/nodes.d.ts +150 -0
- package/dist/nodes.d.ts.map +1 -0
- package/dist/nodes.js +2426 -0
- package/dist/nodes.js.map +1 -0
- package/dist/source-view.d.ts +26 -0
- package/dist/source-view.d.ts.map +1 -0
- package/dist/source-view.js +114 -0
- package/dist/source-view.js.map +1 -0
- package/dist/source.d.ts +8 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +24 -0
- package/dist/source.js.map +1 -0
- package/dist/style.d.ts +16 -0
- package/dist/style.d.ts.map +1 -0
- package/dist/style.js +568 -0
- package/dist/style.js.map +1 -0
- package/dist/styles.d.ts +5 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +921 -0
- package/dist/styles.js.map +1 -0
- package/dist/surface.d.ts +24 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +90 -0
- package/dist/surface.js.map +1 -0
- package/dist/tiptap.d.ts +10 -0
- package/dist/tiptap.d.ts.map +1 -0
- package/dist/tiptap.js +9 -0
- package/dist/tiptap.js.map +1 -0
- package/package.json +63 -4
- package/src/adapter.ts +421 -0
- package/src/blocks.ts +577 -0
- package/src/define.ts +84 -0
- package/src/element.ts +988 -0
- package/src/index.ts +10 -0
- package/src/layouts.ts +220 -0
- package/src/nodes.ts +2690 -0
- package/src/source-view.ts +138 -0
- package/src/source.ts +27 -0
- package/src/style.ts +638 -0
- package/src/styles.ts +931 -0
- package/src/surface.ts +110 -0
- package/src/tiptap.ts +9 -0
package/dist/adapter.js
ADDED
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EditorAdapter over a TipTap editor. Everything crosses the boundary as source HTML in the content format, so the
|
|
3
|
+
* authoring kit never sees a ProseMirror node, and this file is the whole integration.
|
|
4
|
+
*/
|
|
5
|
+
import { inertStyles, STYLE_TAG, } from '@astl/core';
|
|
6
|
+
import { scanElements } from '@astl/editor';
|
|
7
|
+
import { closeHistory } from '@tiptap/pm/history';
|
|
8
|
+
import { DOMSerializer, DOMParser as SchemaParser } from '@tiptap/pm/model';
|
|
9
|
+
import { NodeSelection, TextSelection } from '@tiptap/pm/state';
|
|
10
|
+
import { cursorIn, isBlockOf, LAYOUT, LAYOUT_COLUMN, moveBlockIn, removeBlockIn } from './blocks.js';
|
|
11
|
+
import { addPageIn, attributesOf, mergePageIn, nodeName, removePageIn, splitPageIn } from './nodes.js';
|
|
12
|
+
import { inert, sourceOf, toHtml } from './source.js';
|
|
13
|
+
import { createStyles } from './style.js';
|
|
14
|
+
const MARKS = ['bold', 'italic', 'underline', 'link'];
|
|
15
|
+
const FORMATS = [
|
|
16
|
+
...MARKS,
|
|
17
|
+
'paragraph',
|
|
18
|
+
'heading',
|
|
19
|
+
'subheading',
|
|
20
|
+
'bulleted',
|
|
21
|
+
'numbered',
|
|
22
|
+
];
|
|
23
|
+
/** The command of a format on a chain; `active` says whether the format is on at the cursor. */
|
|
24
|
+
function formatCommand(chain, format, active, href) {
|
|
25
|
+
switch (format) {
|
|
26
|
+
case 'bold':
|
|
27
|
+
return chain.toggleBold();
|
|
28
|
+
case 'italic':
|
|
29
|
+
return chain.toggleItalic();
|
|
30
|
+
case 'underline':
|
|
31
|
+
return chain.toggleUnderline();
|
|
32
|
+
case 'link':
|
|
33
|
+
return href === undefined || href === ''
|
|
34
|
+
? chain.extendMarkRange('link').unsetLink()
|
|
35
|
+
: chain.extendMarkRange('link').setLink({ href });
|
|
36
|
+
case 'paragraph':
|
|
37
|
+
return chain.setParagraph();
|
|
38
|
+
case 'heading':
|
|
39
|
+
return active ? chain.setParagraph() : chain.setHeading({ level: 3 });
|
|
40
|
+
case 'subheading':
|
|
41
|
+
return active ? chain.setParagraph() : chain.setHeading({ level: 4 });
|
|
42
|
+
case 'bulleted':
|
|
43
|
+
return chain.toggleBulletList();
|
|
44
|
+
case 'numbered':
|
|
45
|
+
return chain.toggleOrderedList();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Attribute changes are applied in place (so the selection survives); other changes replace the content. */
|
|
49
|
+
function patch(tr, pos, from, to) {
|
|
50
|
+
if (!from.sameMarkup(to))
|
|
51
|
+
tr.setNodeMarkup(pos, undefined, to.attrs, from.marks);
|
|
52
|
+
if (from.isLeaf || from.content.eq(to.content))
|
|
53
|
+
return;
|
|
54
|
+
const sameShape = from.childCount === to.childCount &&
|
|
55
|
+
from.content.content.every((child, i) => child.type === to.child(i).type && (!child.isText || child.eq(to.child(i))));
|
|
56
|
+
if (!sameShape) {
|
|
57
|
+
tr.replaceWith(pos + 1, pos + from.nodeSize - 1, to.content);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// Last child first, so earlier positions stay valid.
|
|
61
|
+
const offsets = [];
|
|
62
|
+
from.forEach((_, offset) => {
|
|
63
|
+
offsets.push(offset);
|
|
64
|
+
});
|
|
65
|
+
for (let i = from.childCount - 1; i >= 0; i--)
|
|
66
|
+
patch(tr, pos + 1 + (offsets[i] ?? 0), from.child(i), to.child(i));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The `EditorAdapter` over a TipTap editor made with `astrolabeExtensions`: the source in and out, one element by id,
|
|
70
|
+
* the selection and change events, for the kit elements or `<astl-editor>`'s `adapter`. `manifests` are the types of
|
|
71
|
+
* its schema, as given to `astrolabeExtensions`.
|
|
72
|
+
*/
|
|
73
|
+
export function createTiptapAdapter(editor, manifests) {
|
|
74
|
+
const tags = new Map(manifests.map((m) => [nodeName(m.tag), m.tag]));
|
|
75
|
+
const types = new Map(manifests.map((m) => [nodeName(m.tag), m]));
|
|
76
|
+
const childTags = new Map(manifests.flatMap((m) => (m.children ?? []).map((child) => [nodeName(child.tag), child.tag])));
|
|
77
|
+
const isBlock = isBlockOf((node) => types.get(node.type.name) ?? null);
|
|
78
|
+
const serializer = DOMSerializer.fromSchema(editor.schema);
|
|
79
|
+
const parser = SchemaParser.fromSchema(editor.schema);
|
|
80
|
+
const isComponent = (node) => tags.has(node.type.name);
|
|
81
|
+
const toSelection = (node) => {
|
|
82
|
+
const id = node.attrs.attributes.id;
|
|
83
|
+
return typeof id === 'string' && id !== '' ? { id, tag: tags.get(node.type.name) ?? '' } : null;
|
|
84
|
+
};
|
|
85
|
+
/** A page or a component by source id, with its position. */
|
|
86
|
+
const find = (id) => {
|
|
87
|
+
let found = null;
|
|
88
|
+
editor.state.doc.descendants((node, pos) => {
|
|
89
|
+
if (found !== null)
|
|
90
|
+
return false;
|
|
91
|
+
if ((isComponent(node) || node.type.name === 'astlPage') && node.attrs.attributes.id === id) {
|
|
92
|
+
found = { node, pos };
|
|
93
|
+
}
|
|
94
|
+
return found === null;
|
|
95
|
+
});
|
|
96
|
+
return found;
|
|
97
|
+
};
|
|
98
|
+
/** The component the cursor is on: a selected atom, a block around the cursor, or an atom next to it. */
|
|
99
|
+
const selection = () => {
|
|
100
|
+
const current = editor.state.selection;
|
|
101
|
+
if (current instanceof NodeSelection && isComponent(current.node))
|
|
102
|
+
return toSelection(current.node);
|
|
103
|
+
const { $from } = current;
|
|
104
|
+
for (let depth = $from.depth; depth > 0; depth--) {
|
|
105
|
+
if (isComponent($from.node(depth)))
|
|
106
|
+
return toSelection($from.node(depth));
|
|
107
|
+
}
|
|
108
|
+
const near = [$from.nodeAfter, $from.nodeBefore].find((node) => node !== null && isComponent(node));
|
|
109
|
+
return near ? toSelection(near) : null;
|
|
110
|
+
};
|
|
111
|
+
/** Where `select` puts the cursor: on an atom, or at the start of a block or a page. */
|
|
112
|
+
const placeAt = (id) => {
|
|
113
|
+
const hit = find(id);
|
|
114
|
+
if (hit === null)
|
|
115
|
+
return null;
|
|
116
|
+
const { doc } = editor.state;
|
|
117
|
+
return hit.node.isAtom
|
|
118
|
+
? NodeSelection.create(doc, hit.pos)
|
|
119
|
+
: TextSelection.near(doc.resolve(hit.pos + 1));
|
|
120
|
+
};
|
|
121
|
+
/** The selected text when the selection is text in one text block outside components, else ''. */
|
|
122
|
+
const selectedText = () => {
|
|
123
|
+
const { doc, selection: current } = editor.state;
|
|
124
|
+
if (!(current instanceof TextSelection) || current.empty || !current.$from.sameParent(current.$to))
|
|
125
|
+
return '';
|
|
126
|
+
for (let depth = current.$from.depth; depth > 0; depth--)
|
|
127
|
+
if (isComponent(current.$from.node(depth)))
|
|
128
|
+
return '';
|
|
129
|
+
let plain = true;
|
|
130
|
+
doc.nodesBetween(current.from, current.to, (node) => {
|
|
131
|
+
if (node.isInline && !node.isText)
|
|
132
|
+
plain = false;
|
|
133
|
+
return plain;
|
|
134
|
+
});
|
|
135
|
+
return plain ? doc.textBetween(current.from, current.to).trim() : '';
|
|
136
|
+
};
|
|
137
|
+
/** Where formats apply: nowhere on a selected component, marks only in a component's children. */
|
|
138
|
+
const allowed = () => {
|
|
139
|
+
const current = editor.state.selection;
|
|
140
|
+
if (current instanceof NodeSelection && isComponent(current.node))
|
|
141
|
+
return [];
|
|
142
|
+
for (let depth = current.$from.depth; depth > 0; depth--) {
|
|
143
|
+
const node = current.$from.node(depth);
|
|
144
|
+
if (isComponent(node))
|
|
145
|
+
return types.get(node.type.name)?.content === 'flow' ? FORMATS : MARKS;
|
|
146
|
+
}
|
|
147
|
+
return FORMATS;
|
|
148
|
+
};
|
|
149
|
+
const formatState = () => {
|
|
150
|
+
const { selection: current } = editor.state;
|
|
151
|
+
const active = [];
|
|
152
|
+
const parent = current.$from.parent;
|
|
153
|
+
const component = current instanceof NodeSelection && isComponent(current.node);
|
|
154
|
+
for (const mark of ['bold', 'italic', 'underline', 'link'])
|
|
155
|
+
if (editor.isActive(mark))
|
|
156
|
+
active.push(mark);
|
|
157
|
+
if (!component && parent.type.name === 'paragraph')
|
|
158
|
+
active.push('paragraph');
|
|
159
|
+
if (!component && parent.type.name === 'heading')
|
|
160
|
+
active.push(parent.attrs.level === 4 ? 'subheading' : 'heading');
|
|
161
|
+
if (editor.isActive('bulletList'))
|
|
162
|
+
active.push('bulleted');
|
|
163
|
+
if (editor.isActive('orderedList'))
|
|
164
|
+
active.push('numbered');
|
|
165
|
+
const can = editor.can();
|
|
166
|
+
const possible = {
|
|
167
|
+
bold: () => can.toggleBold(),
|
|
168
|
+
italic: () => can.toggleItalic(),
|
|
169
|
+
underline: () => can.toggleUnderline(),
|
|
170
|
+
link: () => (!current.empty || editor.isActive('link')) && can.setLink({ href: 'https://example.org' }),
|
|
171
|
+
paragraph: () => can.setParagraph() || active.includes('paragraph'),
|
|
172
|
+
heading: () => can.setHeading({ level: 3 }) || active.includes('heading'),
|
|
173
|
+
subheading: () => can.setHeading({ level: 4 }) || active.includes('subheading'),
|
|
174
|
+
bulleted: () => can.toggleBulletList(),
|
|
175
|
+
numbered: () => can.toggleOrderedList(),
|
|
176
|
+
};
|
|
177
|
+
const href = editor.getAttributes('link').href;
|
|
178
|
+
return {
|
|
179
|
+
active,
|
|
180
|
+
enabled: allowed().filter((format) => possible[format]()),
|
|
181
|
+
href: typeof href === 'string' ? href : null,
|
|
182
|
+
undo: can.undo(),
|
|
183
|
+
redo: can.redo(),
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
/** Runs a command chain on the editor, focused, as an undo step of its own: whether the document changed. */
|
|
187
|
+
const step = (build) => {
|
|
188
|
+
const before = editor.state.doc;
|
|
189
|
+
build(editor
|
|
190
|
+
.chain()
|
|
191
|
+
.focus()
|
|
192
|
+
.command(({ tr }) => {
|
|
193
|
+
closeHistory(tr);
|
|
194
|
+
return true;
|
|
195
|
+
})).run();
|
|
196
|
+
return editor.state.doc !== before;
|
|
197
|
+
};
|
|
198
|
+
const adapter = {
|
|
199
|
+
getSource: () => sourceOf(editor.state.doc),
|
|
200
|
+
setSource(source) {
|
|
201
|
+
const body = new DOMParser().parseFromString(inertStyles(source), 'text/html').body;
|
|
202
|
+
const doc = body.querySelector('astl-doc');
|
|
203
|
+
// The document's rules are kept on its node, wherever among its children they are: they print first.
|
|
204
|
+
const rules = doc === null ? [] : [...doc.children].filter((el) => el.localName === STYLE_TAG);
|
|
205
|
+
for (const rule of rules)
|
|
206
|
+
rule.remove();
|
|
207
|
+
const { content } = parser.parse(doc ?? body);
|
|
208
|
+
const tr = editor.state.tr;
|
|
209
|
+
// A change of the document's own attributes (its look, from the inspector) keeps the content and the cursor.
|
|
210
|
+
if (!content.eq(editor.state.doc.content))
|
|
211
|
+
tr.replaceWith(0, editor.state.doc.content.size, content);
|
|
212
|
+
const kept = rules.map(attributesOf);
|
|
213
|
+
if (JSON.stringify(kept) !== JSON.stringify(editor.state.doc.attrs.rules))
|
|
214
|
+
tr.setDocAttribute('rules', kept);
|
|
215
|
+
editor.view.dispatch(tr.setDocAttribute('attributes', doc === null ? {} : attributesOf(doc)));
|
|
216
|
+
},
|
|
217
|
+
insert(html, options = {}) {
|
|
218
|
+
const { doc, selection: current } = editor.state;
|
|
219
|
+
const parsed = inertStyles(html);
|
|
220
|
+
const box = inert.createElement('div');
|
|
221
|
+
box.innerHTML = parsed;
|
|
222
|
+
const first = parser.parseSlice(box).content.firstChild;
|
|
223
|
+
const inline = first?.isInline ?? true;
|
|
224
|
+
const layout = first?.type.name === LAYOUT;
|
|
225
|
+
// Never replace or nest into the component at the cursor: insert after it. A selected component in text takes
|
|
226
|
+
// inline snippets after it; a block goes after its block, below.
|
|
227
|
+
const selected = current instanceof NodeSelection && isComponent(current.node) ? current.node : null;
|
|
228
|
+
let at = selected !== null && (inline || !selected.isInline) ? current.to : null;
|
|
229
|
+
for (let depth = current.$from.depth; at === null && depth > 0; depth--) {
|
|
230
|
+
if (isComponent(current.$from.node(depth)))
|
|
231
|
+
at = current.$from.after(depth);
|
|
232
|
+
}
|
|
233
|
+
// A layout never nests: from inside one, a new one goes after it.
|
|
234
|
+
for (let depth = current.$from.depth; layout && depth > 0; depth--) {
|
|
235
|
+
if (current.$from.node(depth).type.name === LAYOUT)
|
|
236
|
+
at = current.$from.after(depth);
|
|
237
|
+
}
|
|
238
|
+
const replace = options.replaceSelection === true && at === null && selectedText() !== '';
|
|
239
|
+
if (at === null && replace) {
|
|
240
|
+
// The selected text without the spaces around it: "word " becomes the snippet and a space.
|
|
241
|
+
const text = doc.textBetween(current.from, current.to);
|
|
242
|
+
at = {
|
|
243
|
+
from: current.from + (text.length - text.trimStart().length),
|
|
244
|
+
to: current.to - (text.length - text.trimEnd().length),
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
else if (at === null && !inline) {
|
|
248
|
+
// Blocks go after the element the cursor is in on its page or in its column, or in the place of an empty
|
|
249
|
+
// paragraph.
|
|
250
|
+
const { $from } = current;
|
|
251
|
+
let top = doc.firstChild?.type.name === 'astlPage' ? 1 : 0;
|
|
252
|
+
for (let depth = $from.depth; depth > top; depth--) {
|
|
253
|
+
if ($from.node(depth).type.name === LAYOUT_COLUMN)
|
|
254
|
+
top = depth;
|
|
255
|
+
}
|
|
256
|
+
if ($from.depth > top) {
|
|
257
|
+
const node = $from.node(top + 1);
|
|
258
|
+
at =
|
|
259
|
+
node.type.name === 'paragraph' && node.content.size === 0
|
|
260
|
+
? { from: $from.before(top + 1), to: $from.after(top + 1) }
|
|
261
|
+
: $from.after(top + 1);
|
|
262
|
+
}
|
|
263
|
+
else
|
|
264
|
+
at = current.to;
|
|
265
|
+
}
|
|
266
|
+
editor
|
|
267
|
+
.chain()
|
|
268
|
+
.insertContentAt(at ?? current.to, parsed)
|
|
269
|
+
.run();
|
|
270
|
+
// The new element becomes the selection, so the inspector shows it (focus stays where it is); a word that
|
|
271
|
+
// became an inline element keeps the cursor after it, for the author to write on.
|
|
272
|
+
const id = scanElements(html)[0]?.id;
|
|
273
|
+
const placed = id ? placeAt(id) : null;
|
|
274
|
+
if (placed instanceof NodeSelection && replace && placed.node.isInline) {
|
|
275
|
+
editor.view.dispatch(editor.state.tr.setSelection(TextSelection.create(editor.state.doc, placed.to)));
|
|
276
|
+
}
|
|
277
|
+
else if (placed !== null)
|
|
278
|
+
editor.view.dispatch(editor.state.tr.setSelection(placed));
|
|
279
|
+
},
|
|
280
|
+
getElement(id) {
|
|
281
|
+
const hit = find(id);
|
|
282
|
+
return hit !== null && isComponent(hit.node)
|
|
283
|
+
? toHtml(serializer.serializeNode(hit.node, { document: inert }))
|
|
284
|
+
: null;
|
|
285
|
+
},
|
|
286
|
+
replaceElement(id, html) {
|
|
287
|
+
const hit = find(id);
|
|
288
|
+
if (hit === null || !isComponent(hit.node))
|
|
289
|
+
return;
|
|
290
|
+
const box = inert.createElement('div');
|
|
291
|
+
box.innerHTML = inertStyles(html);
|
|
292
|
+
let next = null;
|
|
293
|
+
parser.parseSlice(box).content.descendants((node) => {
|
|
294
|
+
if (next === null && node.type === hit.node.type)
|
|
295
|
+
next = node;
|
|
296
|
+
return next === null;
|
|
297
|
+
});
|
|
298
|
+
if (next === null)
|
|
299
|
+
return;
|
|
300
|
+
const selected = editor.state.selection instanceof NodeSelection && editor.state.selection.from === hit.pos;
|
|
301
|
+
const tr = editor.state.tr;
|
|
302
|
+
patch(tr, hit.pos, hit.node, next);
|
|
303
|
+
if (!tr.docChanged)
|
|
304
|
+
return;
|
|
305
|
+
if (selected)
|
|
306
|
+
tr.setSelection(NodeSelection.create(tr.doc, hit.pos));
|
|
307
|
+
editor.view.dispatch(tr);
|
|
308
|
+
},
|
|
309
|
+
getSelection: selection,
|
|
310
|
+
select(id) {
|
|
311
|
+
const placed = placeAt(id);
|
|
312
|
+
if (placed === null)
|
|
313
|
+
return;
|
|
314
|
+
editor.view.dispatch(editor.state.tr.setSelection(placed).scrollIntoView());
|
|
315
|
+
editor.view.focus();
|
|
316
|
+
},
|
|
317
|
+
onChange(listener) {
|
|
318
|
+
const run = () => listener();
|
|
319
|
+
editor.on('update', run);
|
|
320
|
+
return () => editor.off('update', run);
|
|
321
|
+
},
|
|
322
|
+
wrap(tag) {
|
|
323
|
+
const changed = editor.commands.astlWrap(tag);
|
|
324
|
+
editor.view.focus();
|
|
325
|
+
return changed;
|
|
326
|
+
},
|
|
327
|
+
splitPage() {
|
|
328
|
+
const tr = editor.state.tr;
|
|
329
|
+
const id = splitPageIn(tr);
|
|
330
|
+
if (id !== null)
|
|
331
|
+
editor.view.dispatch(tr);
|
|
332
|
+
return id;
|
|
333
|
+
},
|
|
334
|
+
addPage(after) {
|
|
335
|
+
const tr = editor.state.tr;
|
|
336
|
+
const id = addPageIn(tr, after);
|
|
337
|
+
editor.view.dispatch(tr);
|
|
338
|
+
return id;
|
|
339
|
+
},
|
|
340
|
+
mergePage(id) {
|
|
341
|
+
const tr = editor.state.tr;
|
|
342
|
+
const joined = mergePageIn(tr, id);
|
|
343
|
+
if (joined)
|
|
344
|
+
editor.view.dispatch(tr);
|
|
345
|
+
return joined;
|
|
346
|
+
},
|
|
347
|
+
removePage(id) {
|
|
348
|
+
const tr = editor.state.tr;
|
|
349
|
+
const removed = removePageIn(tr, id);
|
|
350
|
+
if (removed)
|
|
351
|
+
editor.view.dispatch(tr);
|
|
352
|
+
return removed;
|
|
353
|
+
},
|
|
354
|
+
format(format, href) {
|
|
355
|
+
if (!allowed().includes(format))
|
|
356
|
+
return false;
|
|
357
|
+
const active = formatState().active.includes(format);
|
|
358
|
+
return step((chain) => formatCommand(chain, format, active, href));
|
|
359
|
+
},
|
|
360
|
+
formatState,
|
|
361
|
+
undo() {
|
|
362
|
+
const before = editor.state.doc;
|
|
363
|
+
editor.chain().focus().undo().run();
|
|
364
|
+
return editor.state.doc !== before;
|
|
365
|
+
},
|
|
366
|
+
redo() {
|
|
367
|
+
const before = editor.state.doc;
|
|
368
|
+
editor.chain().focus().redo().run();
|
|
369
|
+
return editor.state.doc !== before;
|
|
370
|
+
},
|
|
371
|
+
moveBlock(block, direction) {
|
|
372
|
+
const tr = editor.state.tr;
|
|
373
|
+
if (moveBlockIn(tr, block, direction, isBlock) === null)
|
|
374
|
+
return false;
|
|
375
|
+
editor.view.dispatch(tr);
|
|
376
|
+
return true;
|
|
377
|
+
},
|
|
378
|
+
removeBlock(block) {
|
|
379
|
+
const tr = editor.state.tr;
|
|
380
|
+
if (!removeBlockIn(tr, block, isBlock))
|
|
381
|
+
return false;
|
|
382
|
+
editor.view.dispatch(tr);
|
|
383
|
+
return true;
|
|
384
|
+
},
|
|
385
|
+
getCursor: () => cursorIn(editor.state, isBlock),
|
|
386
|
+
onCursorChange(listener) {
|
|
387
|
+
// Focus and blur are transactions too: they change nothing a toolbar shows.
|
|
388
|
+
const run = ({ transaction }) => {
|
|
389
|
+
if (transaction.docChanged || transaction.selectionSet || transaction.storedMarksSet)
|
|
390
|
+
listener();
|
|
391
|
+
};
|
|
392
|
+
editor.on('transaction', run);
|
|
393
|
+
return () => editor.off('transaction', run);
|
|
394
|
+
},
|
|
395
|
+
selectedText,
|
|
396
|
+
focus() {
|
|
397
|
+
// A surface that has the focus keeps it: focusing again writes the last known cursor over a click's new one.
|
|
398
|
+
if (!editor.view.hasFocus())
|
|
399
|
+
editor.view.focus();
|
|
400
|
+
},
|
|
401
|
+
onSelectionChange(listener) {
|
|
402
|
+
let last = selection();
|
|
403
|
+
const run = () => {
|
|
404
|
+
const now = selection();
|
|
405
|
+
if (now?.id === last?.id && now?.tag === last?.tag)
|
|
406
|
+
return;
|
|
407
|
+
last = now;
|
|
408
|
+
listener(now);
|
|
409
|
+
};
|
|
410
|
+
editor.on('selectionUpdate', run);
|
|
411
|
+
editor.on('update', run);
|
|
412
|
+
return () => {
|
|
413
|
+
editor.off('selectionUpdate', run);
|
|
414
|
+
editor.off('update', run);
|
|
415
|
+
};
|
|
416
|
+
},
|
|
417
|
+
style: createStyles(editor, isComponent, (node) => tags.get(node.type.name) ?? childTags.get(node.type.name) ?? node.type.name, (html) => adapter.insert(html)),
|
|
418
|
+
};
|
|
419
|
+
return adapter;
|
|
420
|
+
}
|
|
421
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAML,WAAW,EACX,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAuB,SAAS,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACjG,OAAO,EAAE,aAAa,EAAkB,aAAa,EAAoB,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACrG,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACvG,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,KAAK,GAA4B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C,MAAM,CAAC,IAAI,CAAC,CAC/B;KACF,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/blocks.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Blocks (`EditorBlockPlace`): a page's content as the adapter moves and deletes it. Each block component directly on a
|
|
3
|
+
* page or in a column of a layout is one block; the nodes between two of them are one text block; they are numbered in
|
|
4
|
+
* reading order, through the columns. The content format has no blocks, so nothing here changes the schema: the page is
|
|
5
|
+
* one flowing text, and decorations frame each block component, with a label tab and its issues; the adapter (and the
|
|
6
|
+
* inspector through it) moves and deletes blocks, each as one undo step.
|
|
7
|
+
*/
|
|
8
|
+
import { type ComponentManifest, type EditorBlockPlace, type MessageParams } from '@astl/core';
|
|
9
|
+
import { type Authoring, type Placement } from '@astl/editor';
|
|
10
|
+
import { Extension } from '@tiptap/core';
|
|
11
|
+
import { type Node as PMNode } from '@tiptap/pm/model';
|
|
12
|
+
import { type EditorState, type Transaction } from '@tiptap/pm/state';
|
|
13
|
+
import { type EditorView } from '@tiptap/pm/view';
|
|
14
|
+
/** The nodes of `<astl-columns>` and its `<astl-column>`s (`astlColumn` is the child of an `astl-match`). */
|
|
15
|
+
export declare const LAYOUT = "astlLayout";
|
|
16
|
+
export declare const LAYOUT_COLUMN = "astlLayoutColumn";
|
|
17
|
+
/** One block of a page: its nodes' positions (`from` before the first, `to` after the last) and child indices. */
|
|
18
|
+
export interface BlockRange {
|
|
19
|
+
readonly from: number;
|
|
20
|
+
readonly to: number;
|
|
21
|
+
/** Its first node's index among its parent's children, and one past its last. */
|
|
22
|
+
readonly start: number;
|
|
23
|
+
readonly end: number;
|
|
24
|
+
/** The component of a component block; null for a text block. */
|
|
25
|
+
readonly component: PMNode | null;
|
|
26
|
+
/** The page, document or column it is directly in, and where that one's content starts. */
|
|
27
|
+
readonly parent: PMNode;
|
|
28
|
+
readonly parentStart: number;
|
|
29
|
+
}
|
|
30
|
+
/** A page, or a document without pages: its id, its node, where its content starts, its blocks. */
|
|
31
|
+
export interface BlockContainer {
|
|
32
|
+
readonly page: string | null;
|
|
33
|
+
readonly node: PMNode;
|
|
34
|
+
readonly start: number;
|
|
35
|
+
readonly blocks: readonly BlockRange[];
|
|
36
|
+
}
|
|
37
|
+
/** Whether a node directly on a page is a block component (a block of its own). */
|
|
38
|
+
export type IsBlock = (node: PMNode) => boolean;
|
|
39
|
+
/** The component type of an editor node, or null for content and children. */
|
|
40
|
+
export type TypeOf = (node: PMNode) => ComponentManifest | null;
|
|
41
|
+
/** Block components are blocks of their own. */
|
|
42
|
+
export declare const isBlockOf: (typeOf: TypeOf) => IsBlock;
|
|
43
|
+
/**
|
|
44
|
+
* What a block or a page transaction did, as the status line says it: a key of the kit's namespace and its parameters,
|
|
45
|
+
* blocks numbered from 1 on their page and pages from 1 ("Block 2 deleted", "Page 2 added").
|
|
46
|
+
*/
|
|
47
|
+
export interface SurfaceChange {
|
|
48
|
+
readonly key: string;
|
|
49
|
+
readonly params: MessageParams;
|
|
50
|
+
}
|
|
51
|
+
/** The transaction meta of a block transaction: its `SurfaceChange`, for the surface to announce. */
|
|
52
|
+
export declare const BLOCK_CHANGE = "astlBlockChange";
|
|
53
|
+
/** The pages of `doc` (one container for a document without pages), each with its blocks. */
|
|
54
|
+
export declare function blockContainers(doc: PMNode, isBlock: IsBlock): BlockContainer[];
|
|
55
|
+
/** The block holding the cursor of `state`, or null (between pages). */
|
|
56
|
+
export declare function cursorIn(state: EditorState, isBlock: IsBlock): EditorBlockPlace | null;
|
|
57
|
+
/**
|
|
58
|
+
* Moves a block one place up or down among its siblings in `tr` (`EditorAdapter.moveBlock`), the cursor with it: its
|
|
59
|
+
* index on the page after the move, or null, changing nothing, at the start or end of its page or column (a block
|
|
60
|
+
* never leaves its column) or for a place without a block.
|
|
61
|
+
*/
|
|
62
|
+
export declare function moveBlockIn(tr: Transaction, place: EditorBlockPlace, direction: 'up' | 'down', isBlock: IsBlock): number | null;
|
|
63
|
+
/**
|
|
64
|
+
* Deletes a block in `tr` (`EditorAdapter.removeBlock`); the only block of a page or a column leaves an empty paragraph.
|
|
65
|
+
* The cursor goes to the block that took its place, else the one before. False, changing nothing, for a place without
|
|
66
|
+
* a block.
|
|
67
|
+
*/
|
|
68
|
+
export declare function removeBlockIn(tr: Transaction, place: EditorBlockPlace, isBlock: IsBlock): boolean;
|
|
69
|
+
/** The points a graded component holds: its own `points`, else the default 1. */
|
|
70
|
+
export declare function pointsOf(node: PMNode): number;
|
|
71
|
+
/**
|
|
72
|
+
* Undo or redo pressed on one of the surface's own controls (a marker, "Add option"), which ProseMirror leaves alone:
|
|
73
|
+
* the editor's history, the focus back in the text first (the control may be gone after). A text field keeps its own.
|
|
74
|
+
*/
|
|
75
|
+
export declare function historyKey(view: EditorView, event: KeyboardEvent): void;
|
|
76
|
+
/** What a position line says of a box at `position`, `width` percent wide (null: its own width). */
|
|
77
|
+
export declare function placeLabel(t: (key: string, params?: MessageParams) => string, position: Placement, width: number | null): {
|
|
78
|
+
readonly text: string;
|
|
79
|
+
readonly label: string;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Where a component's frame, tab and notes sit: its position and width (the frame's inside draws the rest of its
|
|
83
|
+
* style). Floated, each clears the one before on its side, so the three stack as one box with text beside them.
|
|
84
|
+
*/
|
|
85
|
+
export declare function placedStyle(component: PMNode): string;
|
|
86
|
+
/**
|
|
87
|
+
* Frames over the pages: decorations only. Text runs flow on the sheet unframed; each block component directly on a
|
|
88
|
+
* page is framed (`astl-frame` on its node), with a label tab at the frame's top start (`astl-frame-tab`: the type's
|
|
89
|
+
* icon, its label and a summary: how many repeated children it holds, `surface.items`, and its points). The frame with
|
|
90
|
+
* the cursor takes `astl-frame-current` and `data-astl-current` (the accent; its tab filled). The frames validate the document a moment after
|
|
91
|
+
* each change: one with issues (those of its components, as the outline counts them) takes `astl-frame-error` or
|
|
92
|
+
* `astl-frame-warning`, dashed in that colour, and says them under its tab, errors first, as `authoring.describe`
|
|
93
|
+
* names them without the page. `name` maps a tag to its node type's name.
|
|
94
|
+
*/
|
|
95
|
+
export declare function blocksExtension(authoring: Authoring, typeOf: TypeOf, name: (tag: string) => string, openStyle?: () => void): Extension;
|
|
96
|
+
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,gBAAgB,EAErB,KAAK,aAAa,EAEnB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,KAAK,SAAS,EAGd,KAAK,SAAS,EAKf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAY,KAAK,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EACL,KAAK,WAAW,EAMhB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAA6B,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAM7E,6GAA6G;AAC7G,eAAO,MAAM,MAAM,eAAe,CAAC;AACnC,eAAO,MAAM,aAAa,qBAAqB,CAAC;AAKhD,kHAAkH;AAClH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,2FAA2F;IAC3F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,mGAAmG;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