@openleaf-editor/core 0.1.0-beta.2 → 0.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -0
- package/dist/autolink.d.ts +7 -4
- package/dist/autolink.d.ts.map +1 -1
- package/dist/autolink.js +90 -11
- package/dist/autolink.js.map +1 -1
- package/dist/command-helpers.d.ts +8 -0
- package/dist/command-helpers.d.ts.map +1 -0
- package/dist/command-helpers.js +36 -0
- package/dist/command-helpers.js.map +1 -0
- package/dist/commands.d.ts +21 -63
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +430 -346
- package/dist/commands.js.map +1 -1
- package/dist/css.d.ts +1 -175
- package/dist/css.d.ts.map +1 -1
- package/dist/css.js +1 -516
- package/dist/css.js.map +1 -1
- package/dist/disclosure.d.ts +21 -0
- package/dist/disclosure.d.ts.map +1 -0
- package/dist/disclosure.js +144 -0
- package/dist/disclosure.js.map +1 -0
- package/dist/elements.d.ts +2 -0
- package/dist/elements.d.ts.map +1 -0
- package/dist/elements.js +2 -0
- package/dist/elements.js.map +1 -0
- package/dist/embed.d.ts +1 -51
- package/dist/embed.d.ts.map +1 -1
- package/dist/embed.js +1 -115
- package/dist/embed.js.map +1 -1
- package/dist/errors.d.ts +38 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +40 -0
- package/dist/errors.js.map +1 -0
- package/dist/extensions.d.ts +46 -5
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +272 -52
- package/dist/extensions.js.map +1 -1
- package/dist/figure-drag.d.ts +26 -0
- package/dist/figure-drag.d.ts.map +1 -0
- package/dist/figure-drag.js +75 -0
- package/dist/figure-drag.js.map +1 -0
- package/dist/formats.d.ts.map +1 -1
- package/dist/formats.js +19 -7
- package/dist/formats.js.map +1 -1
- package/dist/gapcursor.d.ts +14 -0
- package/dist/gapcursor.d.ts.map +1 -0
- package/dist/gapcursor.js +17 -0
- package/dist/gapcursor.js.map +1 -0
- package/dist/html.d.ts +32 -2
- package/dist/html.d.ts.map +1 -1
- package/dist/html.js +185 -31
- package/dist/html.js.map +1 -1
- package/dist/index.d.ts +23 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -6
- package/dist/index.js.map +1 -1
- package/dist/insert-commands.d.ts +172 -0
- package/dist/insert-commands.d.ts.map +1 -0
- package/dist/insert-commands.js +560 -0
- package/dist/insert-commands.js.map +1 -0
- package/dist/isolating-selection.d.ts +59 -0
- package/dist/isolating-selection.d.ts.map +1 -0
- package/dist/isolating-selection.js +251 -0
- package/dist/isolating-selection.js.map +1 -0
- package/dist/noneditable.d.ts.map +1 -1
- package/dist/noneditable.js +18 -4
- package/dist/noneditable.js.map +1 -1
- package/dist/plugins.d.ts +20 -2
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +27 -2
- package/dist/plugins.js.map +1 -1
- package/dist/preserve.d.ts +48 -17
- package/dist/preserve.d.ts.map +1 -1
- package/dist/preserve.js +214 -43
- package/dist/preserve.js.map +1 -1
- package/dist/schema.d.ts +15 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +157 -28
- package/dist/schema.js.map +1 -1
- package/dist/structure.d.ts +32 -0
- package/dist/structure.d.ts.map +1 -1
- package/dist/structure.js +53 -10
- package/dist/structure.js.map +1 -1
- package/dist/tables.d.ts +47 -1
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +417 -40
- package/dist/tables.js.map +1 -1
- package/dist/testing.d.ts +3 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +3 -0
- package/dist/testing.js.map +1 -0
- package/dist/tokens.d.ts +8 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +54 -6
- package/dist/tokens.js.map +1 -1
- package/dist/url.d.ts +1 -25
- package/dist/url.d.ts.map +1 -1
- package/dist/url.js +1 -77
- package/dist/url.js.map +1 -1
- package/dist/visual-aids.d.ts +11 -1
- package/dist/visual-aids.d.ts.map +1 -1
- package/dist/visual-aids.js +124 -36
- package/dist/visual-aids.js.map +1 -1
- package/package.json +17 -1
package/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# @openleaf-editor/core
|
|
2
|
+
|
|
3
|
+
The schema, commands, HTML input and output, and the content-preservation
|
|
4
|
+
layer. No UI, no framework dependencies.
|
|
5
|
+
|
|
6
|
+
> **Editor output is untrusted input.** Whatever the editor produces — and
|
|
7
|
+
> whatever a user pasted into it — must be sanitized **on your server** before it
|
|
8
|
+
> is stored or rendered as HTML. Client-side sanitization is a user-experience
|
|
9
|
+
> feature, not a security control: anything the editor strips can be put back
|
|
10
|
+
> with developer tools, because the editor runs under the user's control.
|
|
11
|
+
>
|
|
12
|
+
> [`@openleaf-editor/sanitize`](https://github.com/PeytonNowlin/openleaf/tree/main/packages/sanitize) ships the
|
|
13
|
+
> canonical allowlist as data and generates configuration for DOMPurify, Python
|
|
14
|
+
> `bleach` and PHP HTMLPurifier from it, so client and server enforce the same
|
|
15
|
+
> rules. Read [SECURITY.md](https://github.com/PeytonNowlin/openleaf/blob/main/SECURITY.md) before you ship.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm install @openleaf-editor/core@beta
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Keep every `@openleaf-editor/*` package on the same version. They pin each other
|
|
24
|
+
exactly, so mixing versions installs two copies of the schema and the toolbar
|
|
25
|
+
registry -- and a node built by one is not a node type the other accepts.
|
|
26
|
+
|
|
27
|
+
## What it is for
|
|
28
|
+
|
|
29
|
+
Most integrations never import this directly -- they use
|
|
30
|
+
[`@openleaf-editor/element`](../element), which builds an editor out of it. You
|
|
31
|
+
want `core` when you are embedding ProseMirror yourself, running HTML through the
|
|
32
|
+
schema on a server, or writing a plugin.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { coreSchema, parseHtml, serializeHtml, roundTrip } from '@openleaf-editor/core'
|
|
36
|
+
|
|
37
|
+
roundTrip('<p style="text-align:center">hi</p>')
|
|
38
|
+
// '<p style="text-align:center">hi</p>'
|
|
39
|
+
roundTrip('<p><strong class="brand-name">Acme</strong></p>')
|
|
40
|
+
// '<p><strong class="brand-name">Acme</strong></p>'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## The preservation layer is the point
|
|
44
|
+
|
|
45
|
+
A schema-based editor has to decide what it understands, and the usual answer for
|
|
46
|
+
everything else is to delete it. `core` keeps unrecognised markup as a
|
|
47
|
+
selectable, movable atom that round-trips byte-for-byte instead.
|
|
48
|
+
|
|
49
|
+
Block-level tags the HTML parser will not keep inside a `<p>` (`div`, `section`,
|
|
50
|
+
and the rest of `CLOSES_OPEN_P`) are stored as block atoms even when they appear
|
|
51
|
+
inside a blockquote or list item. Treating them as inline would wrap them in a
|
|
52
|
+
paragraph the next parse splits, growing two empty paragraphs on every save.
|
|
53
|
+
|
|
54
|
+
That is why the schema is larger than it might look: `<table>`, `<figure>`,
|
|
55
|
+
`<details>`, `<video>`, allowlisted `<iframe>` embeds and the typography marks are
|
|
56
|
+
all modelled here rather than in an opt-in plugin. Not because every deployment
|
|
57
|
+
edits them, but because a node type that is absent is content that becomes an
|
|
58
|
+
atom -- and "we kept your tables and you may not touch them" is not something you
|
|
59
|
+
can tell a CMS with a fifteen-year archive. A `<figcaption>` is only a modelled
|
|
60
|
+
node inside a modelled `<figure>`; outside one it is that same atom, so it is
|
|
61
|
+
never emitted inside a `<p>` the next parse would split.
|
|
62
|
+
|
|
63
|
+
The editing chrome for those things is opt-in. The storage format is not.
|
|
64
|
+
|
|
65
|
+
## Commands and predicates
|
|
66
|
+
|
|
67
|
+
Commands take ProseMirror's `(state, dispatch, view)` shape. Every one has a
|
|
68
|
+
matching predicate, so a control can show its state without duplicating the
|
|
69
|
+
logic:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { setFontFamily, activeFontFamily } from '@openleaf-editor/core'
|
|
73
|
+
|
|
74
|
+
activeFontFamily(view.state) // 'Georgia' | null
|
|
75
|
+
setFontFamily('Georgia')(view.state, view.dispatch) // boolean
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`selectedImage` / `updateImage` (and the matching media pair) are how the
|
|
79
|
+
insert-image control also edits: a `NodeSelection` on the picture or its
|
|
80
|
+
`<figure>` prefills the dialog, and Save uses `setNodeMarkup` so caption,
|
|
81
|
+
class and dimensions survive.
|
|
82
|
+
|
|
83
|
+
A predicate returns `null` for a mixed selection rather than the first value it
|
|
84
|
+
finds -- a dropdown showing "Georgia" for a range that is half Georgia would be
|
|
85
|
+
worse than showing nothing.
|
|
86
|
+
|
|
87
|
+
Block-type commands (`setHeading`, `setParagraph`, `toggleCodeBlock`) refuse a
|
|
88
|
+
textblock whose content the destination cannot hold. A captioned `<figure>` is a
|
|
89
|
+
textblock in the schema (`content: 'inline+'`) but not a paragraph: converting it
|
|
90
|
+
used to produce an `<h2>` holding an image and a `<figcaption>`, and
|
|
91
|
+
`toggleCodeBlock` threw. `canInsert` also stops at an isolating node, so
|
|
92
|
+
inserting an `<hr>` cannot split a figure.
|
|
93
|
+
|
|
94
|
+
## Isolating selections
|
|
95
|
+
|
|
96
|
+
If you construct a ProseMirror editor yourself, install `gapCursorPlugin()`
|
|
97
|
+
and `isolatingSelectionPlugin()` next to `history()` and the keymap.
|
|
98
|
+
|
|
99
|
+
Without the gap cursor, a document that is only a page-break or a `<details>`
|
|
100
|
+
has no legal caret beside it, and typing replaces the atom. Without the
|
|
101
|
+
isolating clamp, a `TextSelection` that starts in a `<blockquote>` and ends
|
|
102
|
+
inside a following `<details>` throws on the next keystroke (`Cannot join
|
|
103
|
+
details onto blockquote`), and the recovery rewrites the document with no undo
|
|
104
|
+
entry. The isolating plugin also handles `beforeinput` so a keystroke cannot
|
|
105
|
+
skip the clamp when the model caret is still collapsed and only the DOM range
|
|
106
|
+
crosses the boundary. `<openleaf-editor>` already installs both. Details are in
|
|
107
|
+
[authoring-plugins.md §4.11](../../docs/authoring-plugins.md#411-isolating-nodes-clamp-the-selection-at-their-boundary).
|
|
108
|
+
|
|
109
|
+
## Captioned figures
|
|
110
|
+
|
|
111
|
+
If you construct a ProseMirror editor yourself, install `figureDragPlugin()`
|
|
112
|
+
next to `isolatingSelectionPlugin()`. Dragging the `<img>` inside a captioned
|
|
113
|
+
`<figure>` otherwise moves only the image and leaves the caption behind.
|
|
114
|
+
`<openleaf-editor>` already installs the plugin.
|
|
115
|
+
|
|
116
|
+
## Safety
|
|
117
|
+
|
|
118
|
+
URL, CSS and embed rules come from
|
|
119
|
+
[`@openleaf-editor/content-policy`](../content-policy), shared with
|
|
120
|
+
[`@openleaf-editor/sanitize`](../sanitize) so the editor and your server cannot
|
|
121
|
+
disagree. `javascript:` URLs, `on*` handlers and unallowlisted iframes are dropped
|
|
122
|
+
on the way in, with tests. Sanitize on the server anyway -- anything a client
|
|
123
|
+
strips can be put back with developer tools.
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
Apache-2.0.
|
package/dist/autolink.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Turn a typed URL into a link when the author finishes it.
|
|
3
3
|
*
|
|
4
|
-
* Space
|
|
5
|
-
* have in mail clients and office
|
|
6
|
-
* that is already a link, and it
|
|
7
|
-
*
|
|
4
|
+
* Space, Enter, and the end of an IME composition are the commit points,
|
|
5
|
+
* matching the behaviour authors already have in mail clients and office
|
|
6
|
+
* software. The plugin never rewrites a range that is already a link, and it
|
|
7
|
+
* refuses anything `isSafeUrl` would drop, so typing `javascript:` cannot
|
|
8
|
+
* become a mark the serializer would then emit. It also never `addMark`s
|
|
9
|
+
* while `view.composing` is true: rewriting the document under an open IME
|
|
10
|
+
* is how keyboards start duplicating or dropping characters.
|
|
8
11
|
*/
|
|
9
12
|
import { Plugin } from 'prosemirror-state';
|
|
10
13
|
export declare function hrefFromTypedUrl(raw: string): string | null;
|
package/dist/autolink.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autolink.d.ts","sourceRoot":"","sources":["../src/autolink.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"autolink.d.ts","sourceRoot":"","sources":["../src/autolink.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAiD,MAAM,mBAAmB,CAAA;AA+CzF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK3D;AAuCD,wBAAgB,cAAc,IAAI,MAAM,CA6DvC"}
|
package/dist/autolink.js
CHANGED
|
@@ -1,22 +1,59 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Turn a typed URL into a link when the author finishes it.
|
|
3
3
|
*
|
|
4
|
-
* Space
|
|
5
|
-
* have in mail clients and office
|
|
6
|
-
* that is already a link, and it
|
|
7
|
-
*
|
|
4
|
+
* Space, Enter, and the end of an IME composition are the commit points,
|
|
5
|
+
* matching the behaviour authors already have in mail clients and office
|
|
6
|
+
* software. The plugin never rewrites a range that is already a link, and it
|
|
7
|
+
* refuses anything `isSafeUrl` would drop, so typing `javascript:` cannot
|
|
8
|
+
* become a mark the serializer would then emit. It also never `addMark`s
|
|
9
|
+
* while `view.composing` is true: rewriting the document under an open IME
|
|
10
|
+
* is how keyboards start duplicating or dropping characters.
|
|
8
11
|
*/
|
|
9
12
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
10
13
|
import { isSafeUrl } from './url.js';
|
|
11
14
|
const key = new PluginKey('openleaf-autolink');
|
|
12
15
|
/**
|
|
13
|
-
* A URL at the end of a typed run.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
+
* A URL at the end of a typed run. Parentheses are in the match so
|
|
17
|
+
* `(www.example.com)` and `Foo_(bar)` can both be considered; the strip below
|
|
18
|
+
* decides which trailing `)` is prose and which is the URL. Angle brackets stay
|
|
19
|
+
* out because they are HTML delimiters, not URL characters we want to mark.
|
|
16
20
|
*/
|
|
17
|
-
const TRAILING_URL = /(?:https?:\/\/|www\.)[^\s<>
|
|
21
|
+
const TRAILING_URL = /(?:https?:\/\/|www\.)[^\s<>]+$/i;
|
|
22
|
+
/**
|
|
23
|
+
* Closers that end a URL in a sentence, a citation, or quotes. `)` is handled
|
|
24
|
+
* separately: a trailing one is prose when unmatched, and part of the URL when
|
|
25
|
+
* it balances an earlier `(`.
|
|
26
|
+
*/
|
|
27
|
+
const TRAILING_PUNCTUATION = /[.,;:!?\]}'"]/;
|
|
28
|
+
function stripTrailingUrlPunctuation(token) {
|
|
29
|
+
let s = token;
|
|
30
|
+
while (s.length > 0) {
|
|
31
|
+
const last = s.charAt(s.length - 1);
|
|
32
|
+
if (TRAILING_PUNCTUATION.test(last)) {
|
|
33
|
+
s = s.slice(0, -1);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (last === ')') {
|
|
37
|
+
let opens = 0;
|
|
38
|
+
let closes = 0;
|
|
39
|
+
for (let i = 0; i < s.length; i++) {
|
|
40
|
+
const ch = s.charAt(i);
|
|
41
|
+
if (ch === '(')
|
|
42
|
+
opens++;
|
|
43
|
+
else if (ch === ')')
|
|
44
|
+
closes++;
|
|
45
|
+
}
|
|
46
|
+
if (closes > opens) {
|
|
47
|
+
s = s.slice(0, -1);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
return s;
|
|
54
|
+
}
|
|
18
55
|
export function hrefFromTypedUrl(raw) {
|
|
19
|
-
const trimmed = raw
|
|
56
|
+
const trimmed = stripTrailingUrlPunctuation(raw);
|
|
20
57
|
if (!trimmed)
|
|
21
58
|
return null;
|
|
22
59
|
const href = /^www\./i.test(trimmed) ? `https://${trimmed}` : trimmed;
|
|
@@ -32,11 +69,15 @@ function trailingUrl(state, end) {
|
|
|
32
69
|
const match = TRAILING_URL.exec(trimmed);
|
|
33
70
|
if (!match)
|
|
34
71
|
return null;
|
|
35
|
-
const
|
|
72
|
+
const token = match[0];
|
|
73
|
+
const bare = stripTrailingUrlPunctuation(token);
|
|
74
|
+
if (!bare)
|
|
75
|
+
return null;
|
|
76
|
+
const href = hrefFromTypedUrl(bare);
|
|
36
77
|
if (!href)
|
|
37
78
|
return null;
|
|
38
79
|
const from = parentStart + (match.index ?? 0);
|
|
39
|
-
const to =
|
|
80
|
+
const to = from + bare.length;
|
|
40
81
|
if (from >= to)
|
|
41
82
|
return null;
|
|
42
83
|
const link = state.schema.marks['link'];
|
|
@@ -63,9 +104,31 @@ function maybeAutolink(view, end) {
|
|
|
63
104
|
return true;
|
|
64
105
|
}
|
|
65
106
|
export function autolinkPlugin() {
|
|
107
|
+
// `appendTransaction` is handed states, not the view, and the composing
|
|
108
|
+
// guard is a property of the view. The `view` prop is the supported way to
|
|
109
|
+
// reach one: PM calls it once per editor this plugin is installed in, and
|
|
110
|
+
// `autolinkPlugin()` mints a fresh plugin per editor, so this holds the view
|
|
111
|
+
// that owns the transactions `appendTransaction` sees.
|
|
112
|
+
let host = null;
|
|
66
113
|
return new Plugin({
|
|
67
114
|
key,
|
|
115
|
+
view(editorView) {
|
|
116
|
+
host = editorView;
|
|
117
|
+
return {
|
|
118
|
+
destroy() {
|
|
119
|
+
host = null;
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
},
|
|
68
123
|
appendTransaction(transactions, _oldState, newState) {
|
|
124
|
+
// The same guard the three props carry, and the one this path was
|
|
125
|
+
// missing: a composing IME reaches here through `readDOMChange`, which
|
|
126
|
+
// dispatches a doc-changing transaction per composition update. A
|
|
127
|
+
// composition buffer that happens to hold a space after a URL would
|
|
128
|
+
// otherwise get an `addMark` under the open IME -- the exact rewrite the
|
|
129
|
+
// header comment says never happens.
|
|
130
|
+
if (host?.composing)
|
|
131
|
+
return null;
|
|
69
132
|
if (!transactions.some((tr) => tr.docChanged))
|
|
70
133
|
return null;
|
|
71
134
|
if (transactions.some((tr) => tr.getMeta(key)))
|
|
@@ -80,13 +143,29 @@ export function autolinkPlugin() {
|
|
|
80
143
|
return tr ? tr.setMeta(key, true) : null;
|
|
81
144
|
},
|
|
82
145
|
props: {
|
|
146
|
+
handleDOMEvents: {
|
|
147
|
+
compositionend(view) {
|
|
148
|
+
// This prop runs *before* PM's compositionend (which sets composing=false,
|
|
149
|
+
// then flushes pending records on a microtask). Never return true.
|
|
150
|
+
setTimeout(() => {
|
|
151
|
+
if (view.isDestroyed || view.composing)
|
|
152
|
+
return;
|
|
153
|
+
maybeAutolink(view, view.state.selection.from);
|
|
154
|
+
}, 0);
|
|
155
|
+
return false;
|
|
156
|
+
},
|
|
157
|
+
},
|
|
83
158
|
handleTextInput(view, from, _to, text) {
|
|
159
|
+
if (view.composing)
|
|
160
|
+
return false;
|
|
84
161
|
if (text !== ' ' && text !== '\u00a0')
|
|
85
162
|
return false;
|
|
86
163
|
maybeAutolink(view, from);
|
|
87
164
|
return false;
|
|
88
165
|
},
|
|
89
166
|
handleKeyDown(view, event) {
|
|
167
|
+
if (view.composing)
|
|
168
|
+
return false;
|
|
90
169
|
if (event.key !== 'Enter' || event.shiftKey)
|
|
91
170
|
return false;
|
|
92
171
|
maybeAutolink(view, view.state.selection.from);
|
package/dist/autolink.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autolink.js","sourceRoot":"","sources":["../src/autolink.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"autolink.js","sourceRoot":"","sources":["../src/autolink.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAsC,MAAM,mBAAmB,CAAA;AAEzF,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,mBAAmB,CAAC,CAAA;AAE9C;;;;;GAKG;AACH,MAAM,YAAY,GAAG,iCAAiC,CAAA;AAE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EAAmE;oBACnE,UAAU,CAAC,GAAG,EAAE;wBACd,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,SAAS;4BAAE,OAAM;wBAC9C,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;oBAChD,CAAC,EAAE,CAAC,CAAC,CAAA;oBACL,OAAO,KAAK,CAAA;gBACd,CAAC;aACF;YACD,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI;gBACnC,IAAI,IAAI,CAAC,SAAS;oBAAE,OAAO,KAAK,CAAA;gBAChC,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,QAAQ;oBAAE,OAAO,KAAK,CAAA;gBACnD,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;gBACzB,OAAO,KAAK,CAAA;YACd,CAAC;YACD,aAAa,CAAC,IAAI,EAAE,KAAK;gBACvB,IAAI,IAAI,CAAC,SAAS;oBAAE,OAAO,KAAK,CAAA;gBAChC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,IAAI,KAAK,CAAC,QAAQ;oBAAE,OAAO,KAAK,CAAA;gBACzD,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;gBAC9C,OAAO,KAAK,CAAA;YACd,CAAC;SACF;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MarkType, NodeType } from 'prosemirror-model';
|
|
2
|
+
import type { Command, EditorState } from 'prosemirror-state';
|
|
3
|
+
export declare function markIn(state: EditorState, name: string): MarkType | undefined;
|
|
4
|
+
export declare function nodeIn(state: EditorState, name: string): NodeType | undefined;
|
|
5
|
+
export declare function markCommand(name: string, build: (type: MarkType) => Command): Command;
|
|
6
|
+
export declare function nodeCommand(name: string, build: (type: NodeType) => Command): Command;
|
|
7
|
+
export declare function canInsertNode(state: EditorState, nodeName: string): boolean;
|
|
8
|
+
//# sourceMappingURL=command-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-helpers.d.ts","sourceRoot":"","sources":["../src/command-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE7D,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAE7E;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAE7E;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,GAAG,OAAO,CAKrF;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,GAAG,OAAO,CAKrF;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAa3E"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export function markIn(state, name) {
|
|
2
|
+
return state.schema.marks[name];
|
|
3
|
+
}
|
|
4
|
+
export function nodeIn(state, name) {
|
|
5
|
+
return state.schema.nodes[name];
|
|
6
|
+
}
|
|
7
|
+
export function markCommand(name, build) {
|
|
8
|
+
return (state, dispatch, view) => {
|
|
9
|
+
const type = markIn(state, name);
|
|
10
|
+
return type ? build(type)(state, dispatch, view) : false;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function nodeCommand(name, build) {
|
|
14
|
+
return (state, dispatch, view) => {
|
|
15
|
+
const type = nodeIn(state, name);
|
|
16
|
+
return type ? build(type)(state, dispatch, view) : false;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function canInsertNode(state, nodeName) {
|
|
20
|
+
const type = nodeIn(state, nodeName);
|
|
21
|
+
if (!type)
|
|
22
|
+
return false;
|
|
23
|
+
const { $from } = state.selection;
|
|
24
|
+
for (let depth = $from.depth; depth >= 0; depth -= 1) {
|
|
25
|
+
const index = $from.index(depth);
|
|
26
|
+
if ($from.node(depth).canReplaceWith(index, index, type))
|
|
27
|
+
return true;
|
|
28
|
+
// Isolating nodes (figure, table cells, details, preserved atoms) must not
|
|
29
|
+
// be split to make room for a sibling. Walking past them is how
|
|
30
|
+
// insertHorizontalRule used to bisect a captioned image.
|
|
31
|
+
if ($from.node(depth).type.spec.isolating)
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=command-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-helpers.js","sourceRoot":"","sources":["../src/command-helpers.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,MAAM,CAAC,KAAkB,EAAE,IAAY;IACrD,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AACjC,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,KAAkB,EAAE,IAAY;IACrD,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AACjC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,KAAkC;IAC1E,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;QAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QAChC,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC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|
|
15
15
|
import { type Attrs } from 'prosemirror-model';
|
|
16
|
-
import type
|
|
16
|
+
import { type Command, type EditorState } from 'prosemirror-state';
|
|
17
17
|
import { type Align, type Dir, type ListStyle } from './css.js';
|
|
18
|
-
import { type ImageAlign } from './tokens.js';
|
|
19
18
|
/**
|
|
20
19
|
* Is this mark active at the cursor, or across the selection?
|
|
21
20
|
*
|
|
@@ -41,6 +40,16 @@ export declare const toggleInlineCode: Command;
|
|
|
41
40
|
export declare const toggleSubscript: Command;
|
|
42
41
|
export declare const toggleSuperscript: Command;
|
|
43
42
|
export declare const setParagraph: Command;
|
|
43
|
+
/**
|
|
44
|
+
* `level` is the only attribute this command decides; everything else about the
|
|
45
|
+
* block is the author's and travels with it.
|
|
46
|
+
*
|
|
47
|
+
* `id` needs no special case any more, and that is a property of the schema
|
|
48
|
+
* rather than a shortcut: `paragraph` does not declare an `id`, so `carryOver`
|
|
49
|
+
* cannot promote one from a paragraph, while a heading's own `id` is declared
|
|
50
|
+
* and does come across. A paragraph stored as `<p id="x">` keeps its id anyway,
|
|
51
|
+
* through the carried residue, which is where an unmodelled attribute belongs.
|
|
52
|
+
*/
|
|
44
53
|
export declare function setHeading(level: number): Command;
|
|
45
54
|
/**
|
|
46
55
|
* Toggle a heading level: applying the level you are already in returns the
|
|
@@ -84,7 +93,11 @@ export declare function activeListStyle(state: EditorState): ListStyle | null;
|
|
|
84
93
|
*/
|
|
85
94
|
export declare function activeTextAlign(state: EditorState): Align | null;
|
|
86
95
|
/**
|
|
87
|
-
* Set the alignment of every alignable
|
|
96
|
+
* Set the alignment of every alignable node in the selection. `null` clears it.
|
|
97
|
+
*
|
|
98
|
+
* Images store `left` / `right` / `center` on `image.attrs.align`; serialization
|
|
99
|
+
* maps those to the `ol-*` classes. Justify is skipped on images, because it
|
|
100
|
+
* is not an image alignment.
|
|
88
101
|
*
|
|
89
102
|
* Reports true whenever there is something to align, even if it already carries
|
|
90
103
|
* this value. The alternative -- returning false because the work is already
|
|
@@ -122,68 +135,13 @@ export declare function activeLanguage(state: EditorState): string | null;
|
|
|
122
135
|
* Strip character formatting and block decoration from the selection.
|
|
123
136
|
*
|
|
124
137
|
* Links stay: they are a destination, not a look. Direction stays: it is
|
|
125
|
-
* content.
|
|
126
|
-
*
|
|
138
|
+
* content. Language stays: it is the same kind of fact as direction, only
|
|
139
|
+
* modelled as a mark (`<span lang>`) rather than a node attribute. Headings
|
|
140
|
+
* and lists stay: they are structure. Alignment, indent, line height, fonts,
|
|
141
|
+
* colours, and the common character marks go.
|
|
127
142
|
*/
|
|
128
143
|
export declare const clearFormatting: Command;
|
|
129
|
-
export
|
|
130
|
-
href: string;
|
|
131
|
-
title?: string | null;
|
|
132
|
-
target?: string | null;
|
|
133
|
-
rel?: string | null;
|
|
134
|
-
id?: string | null;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Apply or update a link across the selection.
|
|
138
|
-
*
|
|
139
|
-
* Removes any existing link first: without that, updating a link that only
|
|
140
|
-
* partially overlaps the selection leaves two adjacent links with different
|
|
141
|
-
* hrefs, which looks fine and is wrong.
|
|
142
|
-
*/
|
|
143
|
-
export declare function setLink(attrs: LinkAttrs): Command;
|
|
144
|
-
export declare const unsetLink: Command;
|
|
145
|
-
export interface ImageAttrs {
|
|
146
|
-
src: string;
|
|
147
|
-
alt?: string | null;
|
|
148
|
-
title?: string | null;
|
|
149
|
-
width?: string | null;
|
|
150
|
-
height?: string | null;
|
|
151
|
-
align?: ImageAlign | null;
|
|
152
|
-
className?: string | null;
|
|
153
|
-
/**
|
|
154
|
-
* When present, the image is wrapped in `<figure>` with this caption.
|
|
155
|
-
* An empty string still wraps: a figure with no caption text is how an
|
|
156
|
-
* author says "this will have a caption" without writing one yet.
|
|
157
|
-
*/
|
|
158
|
-
caption?: string | null;
|
|
159
|
-
}
|
|
160
|
-
export declare function insertImage(attrs: ImageAttrs): Command;
|
|
161
|
-
export declare function insertText(text: string): Command;
|
|
162
|
-
export declare const insertNonBreakingSpace: Command;
|
|
163
|
-
export declare const insertPageBreak: Command;
|
|
164
|
-
export declare function insertNamedAnchor(id: string): Command;
|
|
165
|
-
export declare function setHeadingId(id: string | null): Command;
|
|
166
|
-
export declare function insertDetails(summaryText?: string): Command;
|
|
167
|
-
export interface MediaAttrs {
|
|
168
|
-
src: string;
|
|
169
|
-
title?: string | null;
|
|
170
|
-
width?: string | null;
|
|
171
|
-
height?: string | null;
|
|
172
|
-
controls?: boolean;
|
|
173
|
-
poster?: string | null;
|
|
174
|
-
allow?: string | null;
|
|
175
|
-
allowfullscreen?: boolean;
|
|
176
|
-
}
|
|
177
|
-
export declare function insertVideo(attrs: MediaAttrs): Command;
|
|
178
|
-
export declare function insertAudio(attrs: MediaAttrs): Command;
|
|
179
|
-
export declare function insertIframe(attrs: MediaAttrs): Command;
|
|
180
|
-
/**
|
|
181
|
-
* Parse HTML against the live schema and insert it.
|
|
182
|
-
*
|
|
183
|
-
* Used by the snippet picker. The HTML still goes through the same parse
|
|
184
|
-
* pipeline as stored content, so a snippet cannot smuggle in a `<script>`.
|
|
185
|
-
*/
|
|
186
|
-
export declare function insertHtml(html: string): Command;
|
|
144
|
+
export { insertAudio, insertDetails, insertHtml, insertIframe, insertImage, insertNamedAnchor, insertNonBreakingSpace, insertPageBreak, insertText, insertVideo, selectedImage, selectedMedia, setHeadingId, setLink, unsetLink, updateImage, updateMedia, type ImageAttrs, type LinkAttrs, type MediaAttrs, type MediaSource, type SelectedImage, type SelectedMedia, } from './insert-commands.js';
|
|
187
145
|
export { redo, undo } from 'prosemirror-history';
|
|
188
146
|
export declare const canUndo: (state: EditorState) => boolean;
|
|
189
147
|
export declare const canRedo: (state: EditorState) => boolean;
|
package/dist/commands.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"commands.d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