@astl/editor-tiptap 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +99 -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 +51 -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/blocks.js
ADDED
|
@@ -0,0 +1,460 @@
|
|
|
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 { directionOf, } from '@astl/core';
|
|
9
|
+
import { EDITOR_NAMESPACE, GLYPHS, positionOf, splitPlacement, TYPE_GLYPHS, widthPercent, } from '@astl/editor';
|
|
10
|
+
import { Extension } from '@tiptap/core';
|
|
11
|
+
import { closeHistory, redo, undo } from '@tiptap/pm/history';
|
|
12
|
+
import { Fragment } from '@tiptap/pm/model';
|
|
13
|
+
import { NodeSelection, Plugin, PluginKey, Selection, TextSelection, } from '@tiptap/pm/state';
|
|
14
|
+
import { Decoration, DecorationSet } from '@tiptap/pm/view';
|
|
15
|
+
import { render } from 'lit';
|
|
16
|
+
import { sourceOf } from './source.js';
|
|
17
|
+
const PAGE = 'astlPage';
|
|
18
|
+
/** The nodes of `<astl-columns>` and its `<astl-column>`s (`astlColumn` is the child of an `astl-match`). */
|
|
19
|
+
export const LAYOUT = 'astlLayout';
|
|
20
|
+
export const LAYOUT_COLUMN = 'astlLayoutColumn';
|
|
21
|
+
/** The frames validate this long after the last change, as the issues list does, so typing is not interrupted. */
|
|
22
|
+
const CHECK_DELAY_MS = 300;
|
|
23
|
+
/** Block components are blocks of their own. */
|
|
24
|
+
export const isBlockOf = (typeOf) => (node) => typeOf(node)?.display === 'block';
|
|
25
|
+
/** The transaction meta of a block transaction: its `SurfaceChange`, for the surface to announce. */
|
|
26
|
+
export const BLOCK_CHANGE = 'astlBlockChange';
|
|
27
|
+
/** The blocks directly in `node`. A layout is one here: it is what the blocks around it move past. */
|
|
28
|
+
function levelIn(node, start, isBlock) {
|
|
29
|
+
const out = [];
|
|
30
|
+
const place = { parent: node, parentStart: start };
|
|
31
|
+
let run = null;
|
|
32
|
+
node.forEach((child, offset, index) => {
|
|
33
|
+
const from = start + offset;
|
|
34
|
+
const to = from + child.nodeSize;
|
|
35
|
+
const layout = child.type.name === LAYOUT;
|
|
36
|
+
if (layout || isBlock(child)) {
|
|
37
|
+
if (run !== null)
|
|
38
|
+
out.push(run);
|
|
39
|
+
run = null;
|
|
40
|
+
out.push({ from, to, start: index, end: index + 1, component: layout ? null : child, ...place });
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
run =
|
|
44
|
+
run === null
|
|
45
|
+
? { from, to, start: index, end: index + 1, component: null, ...place }
|
|
46
|
+
: { ...run, to, end: index + 1 };
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
if (run !== null)
|
|
50
|
+
out.push(run);
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
/** The blocks of a page in reading order: a layout is not one, the blocks in its columns are. */
|
|
54
|
+
function blocksIn(node, start, isBlock) {
|
|
55
|
+
return levelIn(node, start, isBlock).flatMap((block) => {
|
|
56
|
+
const layout = node.child(block.start);
|
|
57
|
+
if (layout.type.name !== LAYOUT)
|
|
58
|
+
return [block];
|
|
59
|
+
const inColumns = [];
|
|
60
|
+
layout.forEach((column, offset) => {
|
|
61
|
+
inColumns.push(...blocksIn(column, block.from + offset + 2, isBlock));
|
|
62
|
+
});
|
|
63
|
+
return inColumns;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/** The pages of `doc` (one container for a document without pages), each with its blocks. */
|
|
67
|
+
export function blockContainers(doc, isBlock) {
|
|
68
|
+
if (doc.firstChild?.type.name !== PAGE)
|
|
69
|
+
return [{ page: null, node: doc, start: 0, blocks: blocksIn(doc, 0, isBlock) }];
|
|
70
|
+
const out = [];
|
|
71
|
+
doc.forEach((page, offset) => {
|
|
72
|
+
const id = page.attrs.attributes?.id;
|
|
73
|
+
out.push({
|
|
74
|
+
page: id === undefined || id === '' ? null : id,
|
|
75
|
+
node: page,
|
|
76
|
+
start: offset + 1,
|
|
77
|
+
blocks: blocksIn(page, offset + 1, isBlock),
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
const containerOf = (doc, page, isBlock) => blockContainers(doc, isBlock).find((c) => c.page === page) ?? null;
|
|
83
|
+
/** The block holding the cursor of `state`, or null (between pages). */
|
|
84
|
+
export function cursorIn(state, isBlock) {
|
|
85
|
+
const { doc, selection } = state;
|
|
86
|
+
const paged = doc.firstChild?.type.name === PAGE;
|
|
87
|
+
const depth = paged ? 1 : 0;
|
|
88
|
+
const { $from } = selection;
|
|
89
|
+
if ($from.depth < depth)
|
|
90
|
+
return null;
|
|
91
|
+
const containers = blockContainers(doc, isBlock);
|
|
92
|
+
const container = paged ? containers[$from.index(0)] : containers[0];
|
|
93
|
+
const last = container?.blocks.at(-1);
|
|
94
|
+
if (container === undefined || last === undefined)
|
|
95
|
+
return null;
|
|
96
|
+
// Past the last block, the last block. On a layout itself (selected whole), no block.
|
|
97
|
+
const at = Math.min($from.pos, last.to - 1);
|
|
98
|
+
const block = container.blocks.findIndex((b) => at >= b.from && at < b.to);
|
|
99
|
+
return block < 0 ? null : { page: container.page, index: block };
|
|
100
|
+
}
|
|
101
|
+
/** The index of the block at `pos` on the page `page` of `doc`. */
|
|
102
|
+
function indexAt(doc, page, pos, isBlock) {
|
|
103
|
+
return containerOf(doc, page, isBlock)?.blocks.findIndex((b) => pos >= b.from && pos < b.to) ?? -1;
|
|
104
|
+
}
|
|
105
|
+
/** The cursor on a block at `pos`: a component atom selected whole, else the start of its text. */
|
|
106
|
+
function selectionAt(doc, pos) {
|
|
107
|
+
const node = doc.nodeAt(pos);
|
|
108
|
+
if (node?.isAtom === true && NodeSelection.isSelectable(node))
|
|
109
|
+
return NodeSelection.create(doc, pos);
|
|
110
|
+
return Selection.near(doc.resolve(pos + 1));
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Moves a block one place up or down among its siblings in `tr` (`EditorAdapter.moveBlock`), the cursor with it: its
|
|
114
|
+
* index on the page after the move, or null, changing nothing, at the start or end of its page or column (a block
|
|
115
|
+
* never leaves its column) or for a place without a block.
|
|
116
|
+
*/
|
|
117
|
+
export function moveBlockIn(tr, place, direction, isBlock) {
|
|
118
|
+
const block = containerOf(tr.doc, place.page, isBlock)?.blocks[place.index];
|
|
119
|
+
if (block === undefined)
|
|
120
|
+
return null;
|
|
121
|
+
const level = levelIn(block.parent, block.parentStart, isBlock);
|
|
122
|
+
const other = level[level.findIndex((b) => b.from === block.from) + (direction === 'up' ? -1 : 1)];
|
|
123
|
+
if (other === undefined)
|
|
124
|
+
return null;
|
|
125
|
+
const [first, second] = direction === 'up' ? [other, block] : [block, other];
|
|
126
|
+
const nodes = [];
|
|
127
|
+
for (let i = second.start; i < second.end; i++)
|
|
128
|
+
nodes.push(block.parent.child(i));
|
|
129
|
+
const content = Fragment.from(nodes);
|
|
130
|
+
// The second goes before the first: deleting it first leaves the first's position as it is.
|
|
131
|
+
tr.delete(second.from, second.to);
|
|
132
|
+
tr.insert(first.from, content);
|
|
133
|
+
const at = direction === 'up' ? first.from : first.from + content.size;
|
|
134
|
+
tr.setSelection(selectionAt(tr.doc, at));
|
|
135
|
+
const index = indexAt(tr.doc, place.page, at, isBlock);
|
|
136
|
+
closeHistory(tr)
|
|
137
|
+
.setMeta(BLOCK_CHANGE, {
|
|
138
|
+
key: direction === 'up' ? 'surface.blockMovedUp' : 'surface.blockMovedDown',
|
|
139
|
+
params: { n: index + 1 },
|
|
140
|
+
})
|
|
141
|
+
.scrollIntoView();
|
|
142
|
+
return index;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Deletes a block in `tr` (`EditorAdapter.removeBlock`); the only block of a page or a column leaves an empty paragraph.
|
|
146
|
+
* The cursor goes to the block that took its place, else the one before. False, changing nothing, for a place without
|
|
147
|
+
* a block.
|
|
148
|
+
*/
|
|
149
|
+
export function removeBlockIn(tr, place, isBlock) {
|
|
150
|
+
const block = containerOf(tr.doc, place.page, isBlock)?.blocks[place.index];
|
|
151
|
+
const paragraph = tr.doc.type.schema.nodes.paragraph;
|
|
152
|
+
if (block === undefined || paragraph === undefined)
|
|
153
|
+
return false;
|
|
154
|
+
const last = block.end === block.parent.childCount;
|
|
155
|
+
const only = last && block.start === 0;
|
|
156
|
+
if (only)
|
|
157
|
+
tr.replaceWith(block.from, block.to, paragraph.create());
|
|
158
|
+
else
|
|
159
|
+
tr.delete(block.from, block.to);
|
|
160
|
+
tr.setSelection(only
|
|
161
|
+
? TextSelection.create(tr.doc, block.from + 1)
|
|
162
|
+
: last
|
|
163
|
+
? Selection.near(tr.doc.resolve(block.from), -1)
|
|
164
|
+
: selectionAt(tr.doc, block.from));
|
|
165
|
+
closeHistory(tr)
|
|
166
|
+
.setMeta(BLOCK_CHANGE, {
|
|
167
|
+
key: 'surface.blockRemoved',
|
|
168
|
+
params: { n: place.index + 1 },
|
|
169
|
+
})
|
|
170
|
+
.scrollIntoView();
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
/** The points a graded component holds: its own `points`, else the default 1. */
|
|
174
|
+
export function pointsOf(node) {
|
|
175
|
+
const n = Number(node.attrs.attributes?.points);
|
|
176
|
+
return Number.isFinite(n) && n > 0 ? n : 1;
|
|
177
|
+
}
|
|
178
|
+
const SVG = 'http://www.w3.org/2000/svg';
|
|
179
|
+
const ICONS = {
|
|
180
|
+
error: 'M10 2.5a7.5 7.5 0 1 1 0 15a7.5 7.5 0 1 1 0-15zM7 7l6 6m0-6l-6 6',
|
|
181
|
+
warning: 'M10 2.8l7.6 13.4H2.4zM10 8v3.6M10 14.2v.01',
|
|
182
|
+
};
|
|
183
|
+
/** A 20 by 20 line icon hidden from assistive technology: one of `ICONS`, or a type's glyph. */
|
|
184
|
+
function icon(name) {
|
|
185
|
+
const svg = document.createElementNS(SVG, 'svg');
|
|
186
|
+
svg.setAttribute('viewBox', '0 0 20 20');
|
|
187
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
188
|
+
svg.setAttribute('focusable', 'false');
|
|
189
|
+
svg.classList.add('astl-icon');
|
|
190
|
+
if (typeof name !== 'string')
|
|
191
|
+
render(name, svg);
|
|
192
|
+
else
|
|
193
|
+
svg.appendChild(document.createElementNS(SVG, 'path')).setAttribute('d', ICONS[name]);
|
|
194
|
+
return svg;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Undo or redo pressed on one of the surface's own controls (a marker, "Add option"), which ProseMirror leaves alone:
|
|
198
|
+
* the editor's history, the focus back in the text first (the control may be gone after). A text field keeps its own.
|
|
199
|
+
*/
|
|
200
|
+
export function historyKey(view, event) {
|
|
201
|
+
const target = event.target;
|
|
202
|
+
if (!(event.ctrlKey || event.metaKey) || event.altKey || target.localName === 'input')
|
|
203
|
+
return;
|
|
204
|
+
const key = event.key.toLowerCase();
|
|
205
|
+
const command = key === 'z' ? (event.shiftKey ? redo : undo) : key === 'y' && !event.shiftKey ? redo : null;
|
|
206
|
+
if (command === null)
|
|
207
|
+
return;
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
view.focus();
|
|
210
|
+
command(view.state, view.dispatch);
|
|
211
|
+
}
|
|
212
|
+
/** What a position line says of a box at `position`, `width` percent wide (null: its own width). */
|
|
213
|
+
export function placeLabel(t, position, width) {
|
|
214
|
+
const where = t(`style.position.${position}`);
|
|
215
|
+
return width === null
|
|
216
|
+
? { text: where, label: t('surface.picture.placeAuto', { position: where }) }
|
|
217
|
+
: {
|
|
218
|
+
text: `${where} · ${width}%`,
|
|
219
|
+
label: t('surface.picture.place', { position: where, width: `${width}%` }),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Where a component's frame, tab and notes sit: its position and width (the frame's inside draws the rest of its
|
|
224
|
+
* style). Floated, each clears the one before on its side, so the three stack as one box with text beside them.
|
|
225
|
+
*/
|
|
226
|
+
export function placedStyle(component) {
|
|
227
|
+
const style = component.attrs.attributes?.style ?? '';
|
|
228
|
+
const { placed } = splitPlacement(style);
|
|
229
|
+
if (placed === '')
|
|
230
|
+
return '';
|
|
231
|
+
const position = positionOf(style);
|
|
232
|
+
const clear = position === 'start' ? 'inline-start' : position === 'end' ? 'inline-end' : 'none';
|
|
233
|
+
return clear === 'none' ? placed : `${placed}; clear: ${clear}`;
|
|
234
|
+
}
|
|
235
|
+
/** What of a placement the tab row and the notes take: the frame keeps the space under it, they keep their display. */
|
|
236
|
+
const withoutBlockEnd = (place) => place
|
|
237
|
+
.split('; ')
|
|
238
|
+
.filter((one) => !one.startsWith('margin-block-end') && !one.startsWith('display'))
|
|
239
|
+
.join('; ');
|
|
240
|
+
/**
|
|
241
|
+
* Frames over the pages: decorations only. Text runs flow on the sheet unframed; each block component directly on a
|
|
242
|
+
* page is framed (`astl-frame` on its node), with a label tab at the frame's top start (`astl-frame-tab`: the type's
|
|
243
|
+
* icon, its label and a summary: how many repeated children it holds, `surface.items`, and its points). The frame with
|
|
244
|
+
* the cursor takes `astl-frame-current` and `data-astl-current` (the accent; its tab filled). The frames validate the document a moment after
|
|
245
|
+
* each change: one with issues (those of its components, as the outline counts them) takes `astl-frame-error` or
|
|
246
|
+
* `astl-frame-warning`, dashed in that colour, and says them under its tab, errors first, as `authoring.describe`
|
|
247
|
+
* names them without the page. `name` maps a tag to its node type's name.
|
|
248
|
+
*/
|
|
249
|
+
export function blocksExtension(authoring, typeOf, name, openStyle) {
|
|
250
|
+
const t = (key, params) => authoring.t(EDITOR_NAMESPACE, key, params);
|
|
251
|
+
const ui = { lang: authoring.locale, dir: directionOf(authoring.locale) };
|
|
252
|
+
const isBlock = isBlockOf(typeOf);
|
|
253
|
+
const label = (manifest) => {
|
|
254
|
+
const descriptor = authoring.descriptor(manifest.tag);
|
|
255
|
+
if (descriptor === null)
|
|
256
|
+
return manifest.tag;
|
|
257
|
+
const text = authoring.t(descriptor.manifest.messages, descriptor.label);
|
|
258
|
+
return text === descriptor.label ? manifest.tag : text;
|
|
259
|
+
};
|
|
260
|
+
/** How many children it holds of the kinds it may repeat (options, items, zones), or null: it repeats none. */
|
|
261
|
+
const itemsOf = (node, manifest) => {
|
|
262
|
+
const names = new Set(manifest.children.filter((c) => c.max !== 1).map((c) => name(c.tag)));
|
|
263
|
+
if (names.size === 0)
|
|
264
|
+
return null;
|
|
265
|
+
if (node.isAtom) {
|
|
266
|
+
const kept = node.attrs.children;
|
|
267
|
+
return kept.filter((c) => typeof c !== 'string' && names.has(name(c.tag))).length;
|
|
268
|
+
}
|
|
269
|
+
// Rich children are nodes; the inline children of rich content (marked words) are marks, one per id.
|
|
270
|
+
let count = 0;
|
|
271
|
+
const marked = new Set();
|
|
272
|
+
node.descendants((child) => {
|
|
273
|
+
if (names.has(child.type.name))
|
|
274
|
+
count++;
|
|
275
|
+
for (const mark of child.marks) {
|
|
276
|
+
if (names.has(mark.type.name))
|
|
277
|
+
marked.add(mark.attrs.attributes?.id ?? mark);
|
|
278
|
+
}
|
|
279
|
+
return true;
|
|
280
|
+
});
|
|
281
|
+
return count + marked.size;
|
|
282
|
+
};
|
|
283
|
+
/**
|
|
284
|
+
* The row over a frame: its tab at the start and its position line at the end, which opens the component's style form
|
|
285
|
+
* (`openStyle`). The row is placed and sized as the frame is, so both stay over it. The line is kept in the row while
|
|
286
|
+
* hidden, so the row is as high with the cursor in the frame as without it; on a row too narrow for both, it goes
|
|
287
|
+
* above the tab, never over it.
|
|
288
|
+
*/
|
|
289
|
+
const tabDom = (tab) => {
|
|
290
|
+
const head = Object.assign(document.createElement('div'), { className: 'astl-frame-head', ...ui });
|
|
291
|
+
head.contentEditable = 'false';
|
|
292
|
+
if (tab.place !== '')
|
|
293
|
+
head.style.cssText = withoutBlockEnd(tab.place);
|
|
294
|
+
if (tab.classes.includes('astl-frame-current'))
|
|
295
|
+
head.classList.add('astl-frame-head-current');
|
|
296
|
+
const dom = head.appendChild(Object.assign(document.createElement('div'), { className: tab.classes }));
|
|
297
|
+
fillTab(dom, tab);
|
|
298
|
+
const line = head.appendChild(document.createElement(openStyle === undefined ? 'span' : 'button'));
|
|
299
|
+
line.className = 'astl-frame-line';
|
|
300
|
+
line.textContent = tab.line.text;
|
|
301
|
+
line.setAttribute('aria-label', tab.line.label);
|
|
302
|
+
if (openStyle !== undefined) {
|
|
303
|
+
Object.assign(line, { type: 'button', tabIndex: -1 });
|
|
304
|
+
line.addEventListener('click', (event) => {
|
|
305
|
+
event.preventDefault();
|
|
306
|
+
openStyle();
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
return head;
|
|
310
|
+
};
|
|
311
|
+
const fillTab = (dom, tab) => {
|
|
312
|
+
const glyphs = TYPE_GLYPHS.get(tab.glyph) ?? GLYPHS.block;
|
|
313
|
+
const type = Object.assign(document.createElement('span'), { className: 'astl-frame-type' });
|
|
314
|
+
type.textContent = tab.label;
|
|
315
|
+
dom.append(icon(glyphs), type);
|
|
316
|
+
for (const text of tab.meta) {
|
|
317
|
+
const meta = dom.appendChild(document.createElement('span'));
|
|
318
|
+
meta.className = 'astl-frame-meta';
|
|
319
|
+
meta.textContent = text;
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
/** A frame's issues: the severity word for a screen reader, then the sentence, after an icon. */
|
|
323
|
+
const notesDom = (severity, notes, current, place) => {
|
|
324
|
+
const dom = Object.assign(document.createElement('div'), {
|
|
325
|
+
className: `astl-frame-notes astl-frame-${severity}${current ? ' astl-frame-current' : ''}`,
|
|
326
|
+
...ui,
|
|
327
|
+
});
|
|
328
|
+
dom.contentEditable = 'false';
|
|
329
|
+
if (place !== '')
|
|
330
|
+
dom.style.cssText = withoutBlockEnd(place);
|
|
331
|
+
for (const [level, sentence] of notes) {
|
|
332
|
+
const note = dom.appendChild(document.createElement('div'));
|
|
333
|
+
note.className = 'astl-frame-note';
|
|
334
|
+
note.dataset.severity = level;
|
|
335
|
+
const word = Object.assign(document.createElement('span'), { className: 'astl-vh' });
|
|
336
|
+
word.textContent = t(`severity.${level}`);
|
|
337
|
+
const said = Object.assign(document.createElement('span'), { className: 'astl-frame-note-text' });
|
|
338
|
+
said.textContent = sentence;
|
|
339
|
+
note.append(icon(level), word, said);
|
|
340
|
+
}
|
|
341
|
+
return dom;
|
|
342
|
+
};
|
|
343
|
+
/** The issues of a component and its children, errors first. */
|
|
344
|
+
const issuesOf = (state, block, checked) => {
|
|
345
|
+
const ids = new Set();
|
|
346
|
+
state.doc.nodesBetween(block.from, block.to, (node) => {
|
|
347
|
+
if (typeOf(node) === null)
|
|
348
|
+
return true;
|
|
349
|
+
const id = node.attrs.attributes?.id;
|
|
350
|
+
if (id !== undefined)
|
|
351
|
+
ids.add(id);
|
|
352
|
+
return false;
|
|
353
|
+
});
|
|
354
|
+
return checked.issues
|
|
355
|
+
.filter((issue) => issue.at.element !== null && ids.has(issue.at.element))
|
|
356
|
+
.sort((a, b) => Number(a.severity !== 'error') - Number(b.severity !== 'error'));
|
|
357
|
+
};
|
|
358
|
+
const decorate = (state, checked) => {
|
|
359
|
+
const decorations = [];
|
|
360
|
+
const cursor = cursorIn(state, isBlock);
|
|
361
|
+
for (const container of blockContainers(state.doc, isBlock)) {
|
|
362
|
+
container.blocks.forEach((block, index) => {
|
|
363
|
+
const component = block.component;
|
|
364
|
+
const manifest = component === null ? null : typeOf(component);
|
|
365
|
+
if (component === null || manifest === null)
|
|
366
|
+
return;
|
|
367
|
+
const issues = issuesOf(state, block, checked);
|
|
368
|
+
const severity = issues[0]?.severity ?? null;
|
|
369
|
+
const current = cursor !== null && cursor.page === container.page && cursor.index === index;
|
|
370
|
+
const classes = ['astl-frame'];
|
|
371
|
+
if (current)
|
|
372
|
+
classes.push('astl-frame-current');
|
|
373
|
+
if (severity !== null)
|
|
374
|
+
classes.push(`astl-frame-${severity}`);
|
|
375
|
+
const items = itemsOf(component, manifest);
|
|
376
|
+
const meta = [
|
|
377
|
+
...(items === null ? [] : [t('surface.items', { n: items })]),
|
|
378
|
+
...(manifest.graded ? [t('surface.points', { points: pointsOf(component) })] : []),
|
|
379
|
+
];
|
|
380
|
+
const place = placedStyle(component);
|
|
381
|
+
const style = component.attrs.attributes?.style ?? '';
|
|
382
|
+
const tab = {
|
|
383
|
+
glyph: authoring.descriptor(manifest.tag)?.icon ?? '',
|
|
384
|
+
label: label(manifest),
|
|
385
|
+
meta,
|
|
386
|
+
classes: classes.join(' ').replace('astl-frame', 'astl-frame-tab'),
|
|
387
|
+
place,
|
|
388
|
+
line: placeLabel(t, positionOf(style), widthPercent(style)),
|
|
389
|
+
};
|
|
390
|
+
// The tab first, then the notes: the lower side comes first at one position.
|
|
391
|
+
decorations.push(Decoration.widget(block.from, () => tabDom(tab), {
|
|
392
|
+
key: `tab\n${JSON.stringify(tab)}`,
|
|
393
|
+
side: -2,
|
|
394
|
+
stopEvent: () => true,
|
|
395
|
+
ignoreSelection: true,
|
|
396
|
+
}));
|
|
397
|
+
if (severity !== null) {
|
|
398
|
+
const notes = issues.map((issue) => [issue.severity, authoring.describe(issue, checked.source, { page: false })]);
|
|
399
|
+
decorations.push(Decoration.widget(block.from, () => notesDom(severity, notes, current, place), {
|
|
400
|
+
key: `notes\n${JSON.stringify(notes)}\n${current}\n${place}`,
|
|
401
|
+
side: -1,
|
|
402
|
+
stopEvent: () => true,
|
|
403
|
+
ignoreSelection: true,
|
|
404
|
+
}));
|
|
405
|
+
}
|
|
406
|
+
// `data-astl-current` is how a host finds the frame with the cursor in the light DOM.
|
|
407
|
+
decorations.push(Decoration.node(block.from, block.to, {
|
|
408
|
+
class: classes.join(' '),
|
|
409
|
+
...(place === '' ? {} : { style: place }),
|
|
410
|
+
...(current ? { 'data-astl-current': '' } : {}),
|
|
411
|
+
}));
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
return DecorationSet.create(state.doc, decorations);
|
|
415
|
+
};
|
|
416
|
+
const key = new PluginKey('astlBlocks');
|
|
417
|
+
const check = (doc) => {
|
|
418
|
+
const source = sourceOf(doc);
|
|
419
|
+
return { issues: authoring.validate(source).issues, source };
|
|
420
|
+
};
|
|
421
|
+
return Extension.create({
|
|
422
|
+
name: 'astlBlocks',
|
|
423
|
+
addProseMirrorPlugins: () => [
|
|
424
|
+
new Plugin({
|
|
425
|
+
key,
|
|
426
|
+
state: {
|
|
427
|
+
init: (_, state) => {
|
|
428
|
+
const checked = check(state.doc);
|
|
429
|
+
return { checked, decorations: decorate(state, checked) };
|
|
430
|
+
},
|
|
431
|
+
apply: (tr, previous, _, state) => {
|
|
432
|
+
const checked = tr.getMeta(key) ?? previous.checked;
|
|
433
|
+
return tr.docChanged || tr.selectionSet || checked !== previous.checked
|
|
434
|
+
? { checked, decorations: decorate(state, checked) }
|
|
435
|
+
: previous;
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
props: { decorations: (state) => key.getState(state)?.decorations ?? DecorationSet.empty },
|
|
439
|
+
// A change is validated once typing pauses; until then, the frames keep the issues they had, by component.
|
|
440
|
+
view: () => {
|
|
441
|
+
let timer;
|
|
442
|
+
return {
|
|
443
|
+
update: (view, previous) => {
|
|
444
|
+
if (view.state.doc === previous.doc)
|
|
445
|
+
return;
|
|
446
|
+
clearTimeout(timer);
|
|
447
|
+
timer = setTimeout(() => {
|
|
448
|
+
if (view.isDestroyed)
|
|
449
|
+
return;
|
|
450
|
+
view.dispatch(view.state.tr.setMeta(key, check(view.state.doc)).setMeta('addToHistory', false));
|
|
451
|
+
}, CHECK_DELAY_MS);
|
|
452
|
+
},
|
|
453
|
+
destroy: () => clearTimeout(timer),
|
|
454
|
+
};
|
|
455
|
+
},
|
|
456
|
+
}),
|
|
457
|
+
],
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
//# sourceMappingURL=blocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.js","sourceRoot":"","sources":["../src/blocks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAEL,WAAW,GAKZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAEL,gBAAgB,EAChB,MAAM,EAEN,UAAU,EACV,cAAc,EACd,WAAW,EACX,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAuB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAEL,aAAa,EACb,MAAM,EACN,SAAS,EACT,SAAS,EACT,aAAa,GAEd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,aAAa,EAAmB,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAA0B,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,IAAI,GAAG,UAAU,CAAC;AAExB,6GAA6G;AAC7G,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC;AACnC,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAEhD,kHAAkH;AAClH,MAAM,cAAc,GAAG,GAAG,CAAC;AA8B3B,gDAAgD;AAChD,MAAM,CAAC,MAAM,SAAS,GACpB,C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pB,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;gCACtB,IAAI,IAAI,CAAC,WAAW;oCAAE,OAAO;gCAC7B,IAAI,CAAC,QAAQ,CACX,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,KAAK,CAAC,CACjF,CAAC;4BACJ,CAAC,EAAE,cAAc,CAAC,CAAC;wBACrB,CAAC;wBACD,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC;qBACnC,CAAC;gBACJ,CAAC;aACF,CAAC;SACH;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist/define.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { EditorDescriptor, EngineOptions, MessageCatalog } from '@astl/core';
|
|
2
|
+
import { type EditorFont, type EditorStylePreset, type PickPicture, type UploadAsset } from '@astl/editor';
|
|
3
|
+
import type { ElementEntry } from '@astl/player';
|
|
4
|
+
/** The same option names, types and meanings as `createEngine` and `definePlayer`; the editor makes its own secret. */
|
|
5
|
+
export interface DefineEditorOptions extends Omit<EngineOptions, 'secret'> {
|
|
6
|
+
/** Insert menu and inspector entries: one per type authors can add. */
|
|
7
|
+
readonly editors: readonly EditorDescriptor[];
|
|
8
|
+
/** Player elements for the preview, eager or lazy. */
|
|
9
|
+
readonly elements: readonly ElementEntry[];
|
|
10
|
+
/**
|
|
11
|
+
* Stores a picture file and returns its address (it must pass `urlPolicy`): the picture dialog, pasted and dropped
|
|
12
|
+
* pictures and picture fields use it. Without it, pictures are added by address only (or from `pickPicture`).
|
|
13
|
+
* Reject with `UploadRefused` to tell the author why.
|
|
14
|
+
*/
|
|
15
|
+
readonly uploadAsset?: UploadAsset;
|
|
16
|
+
/**
|
|
17
|
+
* Opens the host's own picture library and gives the chosen picture (its address must pass `urlPolicy`), or null:
|
|
18
|
+
* the picture dialog and picture fields offer it beside the upload. The picture dialog closes while the library is
|
|
19
|
+
* open, keeping what the author typed, so a modal of the host's own takes the pointer and the keys.
|
|
20
|
+
*/
|
|
21
|
+
readonly pickPicture?: PickPicture;
|
|
22
|
+
/**
|
|
23
|
+
* Catalogs only the insert menus show (their one-line descriptions), loaded when a menu first opens;
|
|
24
|
+
* `@astl/astrolabe` passes the built-in ones. Default: none (the menus show the names alone).
|
|
25
|
+
*/
|
|
26
|
+
readonly menuMessages?: () => Promise<readonly MessageCatalog[]>;
|
|
27
|
+
/**
|
|
28
|
+
* The fonts the toolbar and the style form offer, in order: a name and a CSS stack the style allow-list keeps (any
|
|
29
|
+
* other throws). A later call's list replaces it. Default: `DEFAULT_FONTS`, stacks every system has.
|
|
30
|
+
*/
|
|
31
|
+
readonly fonts?: readonly EditorFont[];
|
|
32
|
+
/**
|
|
33
|
+
* The ready styles the style menu and the style form offer, in order; `[]`: none. A name `isStyleName` refuses, a
|
|
34
|
+
* declaration the style allow-list refuses or a name given twice throws. A later call's list replaces it. Default:
|
|
35
|
+
* `DEFAULT_STYLES`.
|
|
36
|
+
*/
|
|
37
|
+
readonly styles?: readonly EditorStylePreset[];
|
|
38
|
+
/** Default: the global `customElements`. */
|
|
39
|
+
readonly registry?: CustomElementRegistry;
|
|
40
|
+
/**
|
|
41
|
+
* The toolbar's featured inserts, as buttons before "Elements": component tags, `tag:template` for a named starter,
|
|
42
|
+
* and `text`, `picture`, `page-break`. A later call's list replaces it; an element's `featured` overrides it.
|
|
43
|
+
* Default: none.
|
|
44
|
+
*/
|
|
45
|
+
readonly featured?: readonly string[];
|
|
46
|
+
/**
|
|
47
|
+
* The host's views, after "Visual" and "HTML" in the view switch: each shows the host's content in the slot
|
|
48
|
+
* `view-<name>` in place of the editor. A later call's list replaces it; an element's `views` overrides it.
|
|
49
|
+
* Default: none.
|
|
50
|
+
*/
|
|
51
|
+
readonly views?: readonly EditorHostView[];
|
|
52
|
+
}
|
|
53
|
+
/** A host view of `<astl-editor>`: its name (lower-case letters, digits and dashes) and its label in the switch. */
|
|
54
|
+
export interface EditorHostView {
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly label: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Registers components, editor descriptors, preview elements and looks for every `<astl-editor>`, and defines
|
|
60
|
+
* `<astl-editor>` and the kit elements (nothing is defined on import). A second call adds to the first; a tag or a look
|
|
61
|
+
* name already registered by another object throws, as two copies would otherwise mix silently.
|
|
62
|
+
*/
|
|
63
|
+
export declare function defineEditor(options: DefineEditorOptions): void;
|
|
64
|
+
//# sourceMappingURL=define.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,uHAAuH;AACvH,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC;IACxE,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC9C,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CAAC;IACjE;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC/C,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IAC1C;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;CAC5C;AAED,oHAAoH;AACpH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAID;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAS/D"}
|
package/dist/define.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineAuthoringElements, } from '@astl/editor';
|
|
2
|
+
import { AstlEditor, register } from './element.js';
|
|
3
|
+
const TAG = 'astl-editor';
|
|
4
|
+
/**
|
|
5
|
+
* Registers components, editor descriptors, preview elements and looks for every `<astl-editor>`, and defines
|
|
6
|
+
* `<astl-editor>` and the kit elements (nothing is defined on import). A second call adds to the first; a tag or a look
|
|
7
|
+
* name already registered by another object throws, as two copies would otherwise mix silently.
|
|
8
|
+
*/
|
|
9
|
+
export function defineEditor(options) {
|
|
10
|
+
const registry = options.registry ?? customElements;
|
|
11
|
+
const existing = registry.get(TAG);
|
|
12
|
+
if (existing !== undefined && existing !== AstlEditor)
|
|
13
|
+
throw new Error(`<${TAG}> is already defined by another class`);
|
|
14
|
+
// The kit first: if it throws, nothing is registered.
|
|
15
|
+
defineAuthoringElements(registry);
|
|
16
|
+
register(options);
|
|
17
|
+
if (existing === undefined)
|
|
18
|
+
registry.define(TAG, AstlEditor);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=define.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,GAKxB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AA0DpD,MAAM,GAAG,GAAG,aAAa,CAAC;AAE1B;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,OAA4B;IACvD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,cAAc,CAAC;IACpD,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,UAAU;QACnD,MAAM,IAAI,KAAK,CAAC,IAAI,GAAG,uCAAuC,CAAC,CAAC;IAClE,sDAAsD;IACtD,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAClC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClB,IAAI,QAAQ,KAAK,SAAS;QAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AAC/D,CAAC"}
|