@prosekit/core 0.9.0 → 0.11.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/dist/{editor-4lgGc3CY.d.ts → editor.d.ts} +58 -18
- package/dist/editor.d.ts.map +1 -0
- package/dist/{editor-DGNUXn-u.js → editor.js} +40 -81
- package/dist/editor.js.map +1 -0
- package/dist/prosekit-core-test.d.ts +1 -2
- package/dist/prosekit-core-test.d.ts.map +1 -1
- package/dist/prosekit-core-test.js +2 -4
- package/dist/prosekit-core-test.js.map +1 -1
- package/dist/prosekit-core.d.ts +148 -68
- package/dist/prosekit-core.d.ts.map +1 -1
- package/dist/prosekit-core.js +184 -138
- package/dist/prosekit-core.js.map +1 -1
- package/package.json +9 -9
- package/src/commands/add-mark.ts +3 -6
- package/src/commands/expand-mark.ts +4 -11
- package/src/commands/insert-default-block.spec.ts +4 -8
- package/src/commands/insert-default-block.ts +2 -5
- package/src/commands/insert-node.ts +7 -11
- package/src/commands/remove-mark.ts +3 -6
- package/src/commands/remove-node.ts +4 -4
- package/src/commands/select-block.spec.ts +6 -8
- package/src/commands/select-block.ts +2 -5
- package/src/commands/set-block-type.ts +3 -6
- package/src/commands/set-node-attrs-between.spec.ts +221 -0
- package/src/commands/set-node-attrs-between.ts +77 -0
- package/src/commands/set-node-attrs.spec.ts +129 -0
- package/src/commands/set-node-attrs.ts +26 -27
- package/src/commands/toggle-mark.ts +3 -6
- package/src/commands/toggle-node.ts +4 -7
- package/src/commands/toggle-wrap.spec.ts +2 -6
- package/src/commands/toggle-wrap.ts +3 -6
- package/src/commands/unset-block-type.spec.ts +2 -6
- package/src/commands/unset-block-type.ts +3 -9
- package/src/commands/unset-mark.spec.ts +2 -6
- package/src/commands/unset-mark.ts +1 -1
- package/src/commands/wrap.ts +2 -5
- package/src/editor/action.spec.ts +5 -9
- package/src/editor/action.ts +7 -14
- package/src/editor/editor.spec.ts +8 -15
- package/src/editor/editor.ts +18 -52
- package/src/editor/union.spec.ts +8 -12
- package/src/editor/union.ts +4 -7
- package/src/editor/with-priority.ts +3 -3
- package/src/error.ts +8 -1
- package/src/extensions/clipboard-serializer.ts +22 -26
- package/src/extensions/command.ts +22 -54
- package/src/extensions/default-state.spec.ts +4 -8
- package/src/extensions/default-state.ts +6 -12
- package/src/extensions/events/doc-change.ts +2 -2
- package/src/extensions/events/dom-event.spec.ts +4 -9
- package/src/extensions/events/dom-event.ts +9 -21
- package/src/extensions/events/editor-event.ts +8 -20
- package/src/extensions/events/focus.spec.ts +7 -12
- package/src/extensions/events/focus.ts +2 -2
- package/src/extensions/events/plugin-view.ts +5 -12
- package/src/extensions/history.ts +7 -14
- package/src/extensions/keymap-base.spec.ts +6 -15
- package/src/extensions/keymap-base.ts +6 -9
- package/src/extensions/keymap.spec.ts +10 -24
- package/src/extensions/keymap.ts +5 -15
- package/src/extensions/mark-spec.spec.ts +6 -21
- package/src/extensions/mark-spec.ts +10 -21
- package/src/extensions/mark-view-effect.ts +6 -12
- package/src/extensions/mark-view.ts +5 -11
- package/src/extensions/node-spec.spec.ts +10 -26
- package/src/extensions/node-spec.ts +10 -21
- package/src/extensions/node-view-effect.ts +6 -12
- package/src/extensions/node-view.ts +5 -11
- package/src/extensions/plugin.spec.ts +9 -22
- package/src/extensions/plugin.ts +6 -15
- package/src/facets/base-extension.ts +7 -10
- package/src/facets/command.ts +3 -9
- package/src/facets/facet-extension.spec.ts +10 -21
- package/src/facets/facet-extension.ts +12 -8
- package/src/facets/facet-node.spec.ts +4 -11
- package/src/facets/facet-node.ts +27 -22
- package/src/facets/facet.spec.ts +2 -5
- package/src/facets/facet.ts +14 -7
- package/src/facets/root.ts +2 -2
- package/src/facets/schema-spec.ts +3 -10
- package/src/facets/schema.ts +4 -13
- package/src/facets/state.spec.ts +8 -15
- package/src/facets/state.ts +5 -19
- package/src/facets/union-extension.ts +10 -13
- package/src/index.ts +74 -200
- package/src/test/index.ts +1 -4
- package/src/test/test-builder.ts +2 -5
- package/src/test/test-editor.spec.ts +2 -6
- package/src/test/test-editor.ts +7 -26
- package/src/testing/index.ts +26 -22
- package/src/types/extension-mark.ts +1 -1
- package/src/types/extension-node.ts +1 -1
- package/src/types/extension.spec.ts +2 -5
- package/src/types/extension.ts +8 -18
- package/src/types/pick-string-literal.spec.ts +2 -2
- package/src/types/pick-string-literal.ts +1 -1
- package/src/types/pick-sub-type.spec.ts +2 -2
- package/src/types/priority.ts +50 -7
- package/src/types/simplify-deeper.spec.ts +2 -2
- package/src/types/simplify-union.spec.ts +2 -2
- package/src/types/simplify-union.ts +1 -4
- package/src/utils/array-grouping.spec.ts +2 -5
- package/src/utils/assert.ts +1 -1
- package/src/utils/attrs-match.ts +1 -5
- package/src/utils/can-use-regex-lookbehind.ts +2 -8
- package/src/utils/clsx.spec.ts +2 -5
- package/src/utils/combine-event-handlers.spec.ts +2 -6
- package/src/utils/default-block-at.ts +1 -4
- package/src/utils/editor-content.spec.ts +3 -6
- package/src/utils/editor-content.ts +5 -17
- package/src/utils/find-node.ts +65 -0
- package/src/utils/find-parent-node-of-type.ts +6 -12
- package/src/utils/find-parent-node.spec.ts +3 -7
- package/src/utils/find-parent-node.ts +1 -4
- package/src/utils/get-custom-selection.ts +1 -5
- package/src/utils/get-dom-api.ts +1 -1
- package/src/utils/get-mark-type.ts +2 -5
- package/src/utils/get-node-type.ts +2 -5
- package/src/utils/get-node-types.ts +2 -5
- package/src/utils/includes-mark.ts +2 -6
- package/src/utils/is-at-block-start.ts +1 -4
- package/src/utils/is-mark-absent.spec.ts +3 -6
- package/src/utils/is-mark-absent.ts +2 -6
- package/src/utils/is-mark-active.ts +4 -7
- package/src/utils/is-node-active.spec.ts +109 -0
- package/src/utils/is-node-active.ts +19 -10
- package/src/utils/is-subset.spec.ts +2 -5
- package/src/utils/maybe-run.spec.ts +2 -6
- package/src/utils/merge-objects.spec.ts +2 -5
- package/src/utils/merge-objects.ts +3 -2
- package/src/utils/merge-specs.ts +2 -5
- package/src/utils/object-equal.spec.ts +2 -5
- package/src/utils/output-spec.test.ts +2 -6
- package/src/utils/output-spec.ts +2 -10
- package/src/utils/parse.spec.ts +6 -15
- package/src/utils/parse.ts +4 -16
- package/src/utils/remove-undefined-values.spec.ts +2 -5
- package/src/utils/set-selection-around.ts +1 -4
- package/src/utils/type-assertion.ts +2 -21
- package/src/utils/unicode.spec.ts +2 -5
- package/src/utils/with-skip-code-block.ts +1 -1
- package/dist/editor-4lgGc3CY.d.ts.map +0 -1
- package/dist/editor-DGNUXn-u.js.map +0 -1
package/dist/prosekit-core.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as isMark, B as ProseKitError, C as defineFacetPayload, D as isNodeActive, E as defineFacet, F as isTextSelection, I as getNodeType, L as assert, M as isProseMirrorNode, N as isSelection, O as isAllSelection, P as isSlice, R as getMarkType, S as stateFacet, T as rootFacet, _ as jsonFromState, a as union, b as nodeFromJSON, c as isMarkActive, d as elementFromJSON, f as elementFromNode, g as jsonFromNode, h as jsonFromHTML, j as isNodeSelection, k as isFragment, l as isMarkAbsent, m as htmlFromNode, p as htmlFromJSON, r as createEditor, t as Editor, u as defineDefaultState, v as nodeFromElement, w as schemaFacet, x as stateFromJSON, y as nodeFromHTML, z as EditorNotFoundError } from "./editor.js";
|
|
2
2
|
import { Plugin, PluginKey, ProseMirrorPlugin, TextSelection } from "@prosekit/pm/state";
|
|
3
|
-
import { ReplaceAroundStep, findWrapping, insertPoint } from "@prosekit/pm/transform";
|
|
4
|
-
import { baseKeymap, chainCommands, createParagraphNear, deleteSelection, joinTextblockBackward, lift, liftEmptyBlock, newlineInCode, selectAll as selectAll$1, selectNodeBackward, setBlockType as setBlockType$1, toggleMark as toggleMark$1 } from "@prosekit/pm/commands";
|
|
5
3
|
import { DOMSerializer, Fragment, Slice } from "@prosekit/pm/model";
|
|
6
|
-
import {
|
|
4
|
+
import { ReplaceAroundStep, dropPoint, findWrapping } from "@prosekit/pm/transform";
|
|
5
|
+
import { baseKeymap, chainCommands, createParagraphNear, deleteSelection, joinTextblockBackward, lift, liftEmptyBlock, newlineInCode, selectAll as selectAll$1, selectNodeBackward, setBlockType as setBlockType$1, toggleMark as toggleMark$1 } from "@prosekit/pm/commands";
|
|
6
|
+
import { isElementLike, isNotNullish, mapGroupBy, supportsRegexLookbehind } from "@ocavue/utils";
|
|
7
7
|
import { history, redo, undo } from "@prosekit/pm/history";
|
|
8
8
|
import { keydownHandler } from "@prosekit/pm/keymap";
|
|
9
9
|
import { splitSplittableBlock } from "prosemirror-splittable";
|
|
10
10
|
import OrderedMap from "orderedmap";
|
|
11
11
|
import clsxLite from "clsx/lite";
|
|
12
|
-
|
|
13
12
|
//#region src/commands/add-mark.ts
|
|
14
13
|
/**
|
|
15
14
|
* Returns a command that adds the given mark with the given attributes.
|
|
@@ -26,7 +25,6 @@ function addMark(options) {
|
|
|
26
25
|
return true;
|
|
27
26
|
};
|
|
28
27
|
}
|
|
29
|
-
|
|
30
28
|
//#endregion
|
|
31
29
|
//#region src/commands/expand-mark.ts
|
|
32
30
|
/**
|
|
@@ -64,7 +62,6 @@ function expandMarkAfter($pos, predicate) {
|
|
|
64
62
|
else break;
|
|
65
63
|
return $pos.posAtIndex(boundaryIndex) + parent.child(boundaryIndex).nodeSize;
|
|
66
64
|
}
|
|
67
|
-
|
|
68
65
|
//#endregion
|
|
69
66
|
//#region src/utils/default-block-at.ts
|
|
70
67
|
/**
|
|
@@ -77,7 +74,6 @@ function defaultBlockAt(match) {
|
|
|
77
74
|
}
|
|
78
75
|
return null;
|
|
79
76
|
}
|
|
80
|
-
|
|
81
77
|
//#endregion
|
|
82
78
|
//#region src/commands/insert-default-block.ts
|
|
83
79
|
/**
|
|
@@ -107,7 +103,6 @@ function insertDefaultBlock(options) {
|
|
|
107
103
|
return true;
|
|
108
104
|
};
|
|
109
105
|
}
|
|
110
|
-
|
|
111
106
|
//#endregion
|
|
112
107
|
//#region src/utils/set-selection-around.ts
|
|
113
108
|
function setSelectionAround(tr, pos) {
|
|
@@ -116,7 +111,6 @@ function setSelectionAround(tr, pos) {
|
|
|
116
111
|
const selection = TextSelection.between($pos, $pos);
|
|
117
112
|
tr.setSelection(selection);
|
|
118
113
|
}
|
|
119
|
-
|
|
120
114
|
//#endregion
|
|
121
115
|
//#region src/commands/insert-node.ts
|
|
122
116
|
/**
|
|
@@ -129,7 +123,7 @@ function insertNode(options) {
|
|
|
129
123
|
return (state, dispatch) => {
|
|
130
124
|
const node = options.node ? options.node : options.type ? getNodeType(state.schema, options.type).createAndFill(options.attrs) : null;
|
|
131
125
|
assert(node, "You must provide either a node or a type");
|
|
132
|
-
const insertPos =
|
|
126
|
+
const insertPos = dropPoint(state.doc, options.pos ?? state.selection.anchor, new Slice(Fragment.from([node]), 0, 0));
|
|
133
127
|
if (insertPos == null) return false;
|
|
134
128
|
if (dispatch) {
|
|
135
129
|
const tr = state.tr.insert(insertPos, node);
|
|
@@ -139,7 +133,6 @@ function insertNode(options) {
|
|
|
139
133
|
return true;
|
|
140
134
|
};
|
|
141
135
|
}
|
|
142
|
-
|
|
143
136
|
//#endregion
|
|
144
137
|
//#region src/commands/remove-mark.ts
|
|
145
138
|
/**
|
|
@@ -158,7 +151,6 @@ function removeMark(options) {
|
|
|
158
151
|
return true;
|
|
159
152
|
};
|
|
160
153
|
}
|
|
161
|
-
|
|
162
154
|
//#endregion
|
|
163
155
|
//#region src/utils/find-parent-node.ts
|
|
164
156
|
/**
|
|
@@ -177,7 +169,15 @@ function findParentNode(predicate, $pos) {
|
|
|
177
169
|
};
|
|
178
170
|
}
|
|
179
171
|
}
|
|
180
|
-
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/utils/get-node-types.ts
|
|
174
|
+
/**
|
|
175
|
+
* @internal
|
|
176
|
+
*/
|
|
177
|
+
function getNodeTypes(schema, types) {
|
|
178
|
+
if (Array.isArray(types)) return types.map((type) => getNodeType(schema, type));
|
|
179
|
+
return [getNodeType(schema, types)];
|
|
180
|
+
}
|
|
181
181
|
//#endregion
|
|
182
182
|
//#region src/utils/find-parent-node-of-type.ts
|
|
183
183
|
/**
|
|
@@ -186,10 +186,9 @@ function findParentNode(predicate, $pos) {
|
|
|
186
186
|
* @public
|
|
187
187
|
*/
|
|
188
188
|
function findParentNodeOfType(type, $pos) {
|
|
189
|
-
const
|
|
190
|
-
return findParentNode((node) => node.type
|
|
189
|
+
const nodeTypes = getNodeTypes($pos.doc.type.schema, type);
|
|
190
|
+
return findParentNode((node) => nodeTypes.includes(node.type), $pos);
|
|
191
191
|
}
|
|
192
|
-
|
|
193
192
|
//#endregion
|
|
194
193
|
//#region src/commands/remove-node.ts
|
|
195
194
|
/**
|
|
@@ -207,7 +206,6 @@ function removeNode(options) {
|
|
|
207
206
|
return true;
|
|
208
207
|
};
|
|
209
208
|
}
|
|
210
|
-
|
|
211
209
|
//#endregion
|
|
212
210
|
//#region src/commands/select-all.ts
|
|
213
211
|
/**
|
|
@@ -218,7 +216,6 @@ function removeNode(options) {
|
|
|
218
216
|
function selectAll() {
|
|
219
217
|
return selectAll$1;
|
|
220
218
|
}
|
|
221
|
-
|
|
222
219
|
//#endregion
|
|
223
220
|
//#region src/commands/select-block.ts
|
|
224
221
|
function getTextblockEndpoint(selection, side) {
|
|
@@ -257,7 +254,6 @@ const selectBlockCommand = (state, dispatch) => {
|
|
|
257
254
|
function selectBlock() {
|
|
258
255
|
return selectBlockCommand;
|
|
259
256
|
}
|
|
260
|
-
|
|
261
257
|
//#endregion
|
|
262
258
|
//#region src/utils/get-custom-selection.ts
|
|
263
259
|
function getCustomSelection(state, from, to) {
|
|
@@ -269,7 +265,6 @@ function getCustomSelection(state, from, to) {
|
|
|
269
265
|
}
|
|
270
266
|
return state.selection;
|
|
271
267
|
}
|
|
272
|
-
|
|
273
268
|
//#endregion
|
|
274
269
|
//#region src/commands/set-block-type.ts
|
|
275
270
|
/**
|
|
@@ -308,44 +303,70 @@ function setBlockType(options) {
|
|
|
308
303
|
return true;
|
|
309
304
|
};
|
|
310
305
|
}
|
|
311
|
-
|
|
312
306
|
//#endregion
|
|
313
|
-
//#region src/
|
|
307
|
+
//#region src/commands/set-node-attrs-between.ts
|
|
314
308
|
/**
|
|
315
|
-
*
|
|
309
|
+
* Returns a command that sets the attributes of all matching nodes between the
|
|
310
|
+
* `from` and `to` positions.
|
|
311
|
+
*
|
|
312
|
+
* @param options
|
|
313
|
+
*
|
|
314
|
+
* @public
|
|
316
315
|
*/
|
|
317
|
-
function
|
|
318
|
-
|
|
319
|
-
|
|
316
|
+
function setNodeAttrsBetween(options) {
|
|
317
|
+
return (state, dispatch) => {
|
|
318
|
+
const from = options.from ?? state.selection.from;
|
|
319
|
+
const to = options.to ?? state.selection.to;
|
|
320
|
+
if (from > to) return false;
|
|
321
|
+
const nodeTypes = getNodeTypes(state.schema, options.type);
|
|
322
|
+
const positions = [];
|
|
323
|
+
let found = false;
|
|
324
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
325
|
+
if (nodeTypes.includes(node.type)) {
|
|
326
|
+
positions.push(pos);
|
|
327
|
+
found = true;
|
|
328
|
+
}
|
|
329
|
+
if (!dispatch && found) return false;
|
|
330
|
+
});
|
|
331
|
+
if (!found) return false;
|
|
332
|
+
if (dispatch) {
|
|
333
|
+
const { tr } = state;
|
|
334
|
+
for (const [key, value] of Object.entries(options.attrs)) for (const pos of positions) tr.setNodeAttribute(pos, key, value);
|
|
335
|
+
dispatch(tr);
|
|
336
|
+
}
|
|
337
|
+
return true;
|
|
338
|
+
};
|
|
320
339
|
}
|
|
321
|
-
|
|
322
340
|
//#endregion
|
|
323
341
|
//#region src/commands/set-node-attrs.ts
|
|
324
342
|
/**
|
|
325
|
-
* Returns a command that
|
|
343
|
+
* Returns a command that sets the attributes of the current node.
|
|
344
|
+
*
|
|
345
|
+
* @param options
|
|
326
346
|
*
|
|
327
347
|
* @public
|
|
328
348
|
*/
|
|
329
|
-
function setNodeAttrs(
|
|
349
|
+
function setNodeAttrs({ type, attrs, pos }) {
|
|
330
350
|
return (state, dispatch) => {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
351
|
+
let updatePos;
|
|
352
|
+
if (pos == null) {
|
|
353
|
+
const found = findParentNodeOfType(type, state.selection.$anchor);
|
|
354
|
+
if (!found) return false;
|
|
355
|
+
updatePos = found.pos;
|
|
356
|
+
} else {
|
|
357
|
+
const found = state.doc.nodeAt(pos);
|
|
358
|
+
if (!found) return false;
|
|
359
|
+
if (!getNodeTypes(state.schema, type).includes(found.type)) return false;
|
|
360
|
+
updatePos = pos;
|
|
361
|
+
}
|
|
340
362
|
if (dispatch) {
|
|
341
363
|
const { tr } = state;
|
|
342
|
-
for (const
|
|
364
|
+
for (const [key, value] of Object.entries(attrs)) tr.setNodeAttribute(updatePos, key, value);
|
|
343
365
|
dispatch(tr);
|
|
344
366
|
}
|
|
345
367
|
return true;
|
|
346
368
|
};
|
|
347
369
|
}
|
|
348
|
-
|
|
349
370
|
//#endregion
|
|
350
371
|
//#region src/commands/toggle-mark.ts
|
|
351
372
|
/**
|
|
@@ -363,11 +384,10 @@ function toggleMark({ type, attrs, removeWhenPresent = false, enterInlineAtoms =
|
|
|
363
384
|
})(state, dispatch, view);
|
|
364
385
|
};
|
|
365
386
|
}
|
|
366
|
-
|
|
367
387
|
//#endregion
|
|
368
388
|
//#region src/commands/toggle-node.ts
|
|
369
389
|
/**
|
|
370
|
-
* Returns a command that
|
|
390
|
+
* Returns a command that sets the selected textblocks to the given node type
|
|
371
391
|
* with the given attributes.
|
|
372
392
|
*
|
|
373
393
|
* @param options
|
|
@@ -383,7 +403,6 @@ function toggleNode({ type, attrs }) {
|
|
|
383
403
|
} else return setBlockType$1(getNodeType(state.schema, type), attrs)(state, dispatch, view);
|
|
384
404
|
};
|
|
385
405
|
}
|
|
386
|
-
|
|
387
406
|
//#endregion
|
|
388
407
|
//#region src/commands/wrap.ts
|
|
389
408
|
/**
|
|
@@ -404,7 +423,6 @@ function wrap(options) {
|
|
|
404
423
|
return true;
|
|
405
424
|
};
|
|
406
425
|
}
|
|
407
|
-
|
|
408
426
|
//#endregion
|
|
409
427
|
//#region src/commands/toggle-wrap.ts
|
|
410
428
|
/**
|
|
@@ -425,7 +443,6 @@ function toggleWrap(options) {
|
|
|
425
443
|
})(state, dispatch);
|
|
426
444
|
};
|
|
427
445
|
}
|
|
428
|
-
|
|
429
446
|
//#endregion
|
|
430
447
|
//#region src/commands/unset-block-type.ts
|
|
431
448
|
/**
|
|
@@ -463,7 +480,6 @@ function unsetTextBlockType(tr, from, to) {
|
|
|
463
480
|
});
|
|
464
481
|
return tr.steps.length > mapFrom;
|
|
465
482
|
}
|
|
466
|
-
|
|
467
483
|
//#endregion
|
|
468
484
|
//#region src/commands/unset-mark.ts
|
|
469
485
|
/**
|
|
@@ -480,7 +496,6 @@ function unsetMark(options) {
|
|
|
480
496
|
return true;
|
|
481
497
|
};
|
|
482
498
|
}
|
|
483
|
-
|
|
484
499
|
//#endregion
|
|
485
500
|
//#region src/editor/with-priority.ts
|
|
486
501
|
/**
|
|
@@ -500,7 +515,6 @@ function withPriority(extension, priority) {
|
|
|
500
515
|
result.priority = priority;
|
|
501
516
|
return result;
|
|
502
517
|
}
|
|
503
|
-
|
|
504
518
|
//#endregion
|
|
505
519
|
//#region src/extensions/plugin.ts
|
|
506
520
|
/**
|
|
@@ -533,11 +547,10 @@ const pluginFacet = defineFacet({
|
|
|
533
547
|
},
|
|
534
548
|
parent: stateFacet
|
|
535
549
|
});
|
|
536
|
-
|
|
537
550
|
//#endregion
|
|
538
551
|
//#region src/extensions/clipboard-serializer.ts
|
|
539
552
|
function mergeWrappers(wrappers) {
|
|
540
|
-
return (fn) => wrappers.filter(isNotNullish).reduce((fn
|
|
553
|
+
return (fn) => wrappers.filter(isNotNullish).reduce((fn, wrapper) => wrapper(fn), fn);
|
|
541
554
|
}
|
|
542
555
|
function wrapFunction(fn, wrapper) {
|
|
543
556
|
return wrapper ? wrapper(fn) : fn;
|
|
@@ -549,17 +562,17 @@ var CustomDOMSerializer = class extends DOMSerializer {
|
|
|
549
562
|
this.serializeNodeWrapper = serializeNodeWrapper;
|
|
550
563
|
}
|
|
551
564
|
serializeFragment(...args) {
|
|
552
|
-
const fn = (...args
|
|
565
|
+
const fn = (...args) => super.serializeFragment(...args);
|
|
553
566
|
return wrapFunction(fn, this.serializeFragmentWrapper)(...args);
|
|
554
567
|
}
|
|
555
568
|
serializeNode(...args) {
|
|
556
|
-
const fn = (...args
|
|
569
|
+
const fn = (...args) => super.serializeNode(...args);
|
|
557
570
|
return wrapFunction(fn, this.serializeNodeWrapper)(...args);
|
|
558
571
|
}
|
|
559
572
|
};
|
|
573
|
+
const nodesFromSchema = /* @__PURE__ */ DOMSerializer.nodesFromSchema.bind(DOMSerializer);
|
|
574
|
+
const marksFromSchema = /* @__PURE__ */ DOMSerializer.marksFromSchema.bind(DOMSerializer);
|
|
560
575
|
function createCustomDOMSerializer(schema, options) {
|
|
561
|
-
const nodesFromSchema = (...args) => DOMSerializer.nodesFromSchema(...args);
|
|
562
|
-
const marksFromSchema = (...args) => DOMSerializer.marksFromSchema(...args);
|
|
563
576
|
return new CustomDOMSerializer(wrapFunction(nodesFromSchema, options.nodesFromSchemaWrapper)(schema), wrapFunction(marksFromSchema, options.marksFromSchemaWrapper)(schema), options.serializeFragmentWrapper, options.serializeNodeWrapper);
|
|
564
577
|
}
|
|
565
578
|
const clipboardSerializerFacet = defineFacet({
|
|
@@ -587,7 +600,6 @@ const clipboardSerializerFacet = defineFacet({
|
|
|
587
600
|
function defineClipboardSerializer(options) {
|
|
588
601
|
return defineFacetPayload(clipboardSerializerFacet, [options]);
|
|
589
602
|
}
|
|
590
|
-
|
|
591
603
|
//#endregion
|
|
592
604
|
//#region src/commands/insert-text.ts
|
|
593
605
|
/**
|
|
@@ -601,7 +613,6 @@ function insertText({ text, from, to }) {
|
|
|
601
613
|
return true;
|
|
602
614
|
};
|
|
603
615
|
}
|
|
604
|
-
|
|
605
616
|
//#endregion
|
|
606
617
|
//#region src/facets/command.ts
|
|
607
618
|
const commandFacet = defineFacet({
|
|
@@ -615,11 +626,10 @@ const commandFacet = defineFacet({
|
|
|
615
626
|
parent: rootFacet,
|
|
616
627
|
singleton: true
|
|
617
628
|
});
|
|
618
|
-
|
|
619
629
|
//#endregion
|
|
620
630
|
//#region src/extensions/command.ts
|
|
621
|
-
function defineCommands(commands
|
|
622
|
-
return defineFacetPayload(commandFacet, [commands
|
|
631
|
+
function defineCommands(commands) {
|
|
632
|
+
return defineFacetPayload(commandFacet, [commands]);
|
|
623
633
|
}
|
|
624
634
|
/**
|
|
625
635
|
* Add some base commands
|
|
@@ -635,6 +645,7 @@ function defineBaseCommands() {
|
|
|
635
645
|
toggleWrap,
|
|
636
646
|
setBlockType,
|
|
637
647
|
setNodeAttrs,
|
|
648
|
+
setNodeAttrsBetween,
|
|
638
649
|
insertDefaultBlock,
|
|
639
650
|
selectAll,
|
|
640
651
|
selectBlock,
|
|
@@ -644,7 +655,6 @@ function defineBaseCommands() {
|
|
|
644
655
|
unsetMark
|
|
645
656
|
});
|
|
646
657
|
}
|
|
647
|
-
|
|
648
658
|
//#endregion
|
|
649
659
|
//#region src/extensions/events/plugin-view.ts
|
|
650
660
|
/**
|
|
@@ -684,8 +694,8 @@ const pluginViewFacet = defineFacet({
|
|
|
684
694
|
view: (view) => {
|
|
685
695
|
mountHandlers.forEach((fn) => fn(view));
|
|
686
696
|
return {
|
|
687
|
-
update: (view
|
|
688
|
-
updateHandlers.forEach((fn) => fn(view
|
|
697
|
+
update: (view, prevState) => {
|
|
698
|
+
updateHandlers.forEach((fn) => fn(view, prevState));
|
|
689
699
|
},
|
|
690
700
|
destroy: () => {
|
|
691
701
|
unmountHandlers.forEach((fn) => fn());
|
|
@@ -718,7 +728,6 @@ const pluginViewFacet = defineFacet({
|
|
|
718
728
|
singleton: true
|
|
719
729
|
});
|
|
720
730
|
const pluginKey = new PluginKey("prosekit-plugin-view-handler");
|
|
721
|
-
|
|
722
731
|
//#endregion
|
|
723
732
|
//#region src/extensions/events/doc-change.ts
|
|
724
733
|
/**
|
|
@@ -731,7 +740,6 @@ function defineDocChangeHandler(handler) {
|
|
|
731
740
|
if (!view.state.doc.eq(prevState.doc)) handler(view, prevState);
|
|
732
741
|
});
|
|
733
742
|
}
|
|
734
|
-
|
|
735
743
|
//#endregion
|
|
736
744
|
//#region src/utils/array-grouping.ts
|
|
737
745
|
function groupEntries(entries) {
|
|
@@ -739,7 +747,6 @@ function groupEntries(entries) {
|
|
|
739
747
|
for (const [key, value] of entries) (result[key] ||= []).push(value);
|
|
740
748
|
return result;
|
|
741
749
|
}
|
|
742
|
-
|
|
743
750
|
//#endregion
|
|
744
751
|
//#region src/utils/combine-event-handlers.ts
|
|
745
752
|
function combineEventHandlers() {
|
|
@@ -753,7 +760,6 @@ function combineEventHandlers() {
|
|
|
753
760
|
}
|
|
754
761
|
return [setHandlers, combinedEventHandler];
|
|
755
762
|
}
|
|
756
|
-
|
|
757
763
|
//#endregion
|
|
758
764
|
//#region src/extensions/events/dom-event.ts
|
|
759
765
|
/**
|
|
@@ -801,7 +807,6 @@ const domEventFacet = defineFacet({
|
|
|
801
807
|
parent: pluginFacet,
|
|
802
808
|
singleton: true
|
|
803
809
|
});
|
|
804
|
-
|
|
805
810
|
//#endregion
|
|
806
811
|
//#region src/extensions/events/editor-event.ts
|
|
807
812
|
function defineEventFacetPayload(payload) {
|
|
@@ -963,7 +968,6 @@ function setupEditorEventPlugin() {
|
|
|
963
968
|
}
|
|
964
969
|
})];
|
|
965
970
|
}
|
|
966
|
-
|
|
967
971
|
//#endregion
|
|
968
972
|
//#region src/extensions/events/focus.ts
|
|
969
973
|
/**
|
|
@@ -976,7 +980,6 @@ function defineFocusChangeHandler(handler) {
|
|
|
976
980
|
const handleBlur = () => handler(false);
|
|
977
981
|
return defineDomEventFacetPayload(["focus", handleFocus], ["blur", handleBlur]);
|
|
978
982
|
}
|
|
979
|
-
|
|
980
983
|
//#endregion
|
|
981
984
|
//#region src/utils/env.ts
|
|
982
985
|
/**
|
|
@@ -985,7 +988,6 @@ function defineFocusChangeHandler(handler) {
|
|
|
985
988
|
* @internal
|
|
986
989
|
*/
|
|
987
990
|
const isApple = typeof navigator !== "undefined" ? /Mac|iP(hone|[ao]d)/.test(navigator.platform) : false;
|
|
988
|
-
|
|
989
991
|
//#endregion
|
|
990
992
|
//#region src/extensions/keymap.ts
|
|
991
993
|
/**
|
|
@@ -994,8 +996,8 @@ const isApple = typeof navigator !== "undefined" ? /Mac|iP(hone|[ao]d)/.test(nav
|
|
|
994
996
|
*
|
|
995
997
|
* @public
|
|
996
998
|
*/
|
|
997
|
-
function defineKeymap(keymap
|
|
998
|
-
return defineFacetPayload(keymapFacet, [keymap
|
|
999
|
+
function defineKeymap(keymap) {
|
|
1000
|
+
return defineFacetPayload(keymapFacet, [keymap]);
|
|
999
1001
|
}
|
|
1000
1002
|
/**
|
|
1001
1003
|
* @internal
|
|
@@ -1020,7 +1022,6 @@ const keymapFacet = defineFacet({
|
|
|
1020
1022
|
singleton: true
|
|
1021
1023
|
});
|
|
1022
1024
|
const keymapPluginKey = new PluginKey("prosekit-keymap");
|
|
1023
|
-
|
|
1024
1025
|
//#endregion
|
|
1025
1026
|
//#region src/extensions/history.ts
|
|
1026
1027
|
const keymap = {
|
|
@@ -1045,7 +1046,6 @@ function defineHistory({ depth = 200, newGroupDelay = 250 } = {}) {
|
|
|
1045
1046
|
newGroupDelay
|
|
1046
1047
|
})), defineKeymap(keymap), defineCommands(commands));
|
|
1047
1048
|
}
|
|
1048
|
-
|
|
1049
1049
|
//#endregion
|
|
1050
1050
|
//#region src/extensions/keymap-base.ts
|
|
1051
1051
|
const customEnter = chainCommands(newlineInCode, createParagraphNear, liftEmptyBlock, splitSplittableBlock);
|
|
@@ -1057,7 +1057,7 @@ const customBackspace = chainCommands(deleteSelection, joinTextblockBackward, se
|
|
|
1057
1057
|
*
|
|
1058
1058
|
* @public
|
|
1059
1059
|
*/
|
|
1060
|
-
function defineBaseKeymap({ priority =
|
|
1060
|
+
function defineBaseKeymap({ priority = 1, preferBlockSelection = true } = {}) {
|
|
1061
1061
|
return withPriority(defineKeymap({
|
|
1062
1062
|
...baseKeymap,
|
|
1063
1063
|
"Mod-a": preferBlockSelection ? chainCommands(selectBlockCommand, selectAll$1) : selectAll$1,
|
|
@@ -1065,7 +1065,6 @@ function defineBaseKeymap({ priority = Priority.low, preferBlockSelection = true
|
|
|
1065
1065
|
"Backspace": customBackspace
|
|
1066
1066
|
}), priority);
|
|
1067
1067
|
}
|
|
1068
|
-
|
|
1069
1068
|
//#endregion
|
|
1070
1069
|
//#region src/facets/schema-spec.ts
|
|
1071
1070
|
const schemaSpecFacet = defineFacet({
|
|
@@ -1087,7 +1086,6 @@ const schemaSpecFacet = defineFacet({
|
|
|
1087
1086
|
parent: schemaFacet,
|
|
1088
1087
|
singleton: true
|
|
1089
1088
|
});
|
|
1090
|
-
|
|
1091
1089
|
//#endregion
|
|
1092
1090
|
//#region src/utils/remove-undefined-values.ts
|
|
1093
1091
|
function removeUndefinedValues(obj) {
|
|
@@ -1095,14 +1093,12 @@ function removeUndefinedValues(obj) {
|
|
|
1095
1093
|
for (const [key, value] of Object.entries(obj)) if (value !== void 0) result[key] = value;
|
|
1096
1094
|
return result;
|
|
1097
1095
|
}
|
|
1098
|
-
|
|
1099
1096
|
//#endregion
|
|
1100
1097
|
//#region src/utils/merge-objects.ts
|
|
1101
1098
|
function mergeObjects(...objects) {
|
|
1102
1099
|
const filteredObjects = objects.filter(isNotNullish).map(removeUndefinedValues);
|
|
1103
1100
|
return Object.assign({}, ...filteredObjects);
|
|
1104
1101
|
}
|
|
1105
|
-
|
|
1106
1102
|
//#endregion
|
|
1107
1103
|
//#region src/utils/merge-specs.ts
|
|
1108
1104
|
function mergeSpecs(a, b) {
|
|
@@ -1119,7 +1115,6 @@ function mergeSpecs(a, b) {
|
|
|
1119
1115
|
parseDOM: [...a.parseDOM ?? [], ...b.parseDOM ?? []]
|
|
1120
1116
|
});
|
|
1121
1117
|
}
|
|
1122
|
-
|
|
1123
1118
|
//#endregion
|
|
1124
1119
|
//#region src/utils/output-spec.ts
|
|
1125
1120
|
function wrapOutputSpecAttrs(toDOM, options) {
|
|
@@ -1190,7 +1185,6 @@ function setElementAttributes(element, attrs) {
|
|
|
1190
1185
|
function joinStyles(...styles) {
|
|
1191
1186
|
return styles.map((style) => style.trim().replace(/;$/, "")).filter(Boolean).join("; ");
|
|
1192
1187
|
}
|
|
1193
|
-
|
|
1194
1188
|
//#endregion
|
|
1195
1189
|
//#region src/extensions/mark-spec.ts
|
|
1196
1190
|
/**
|
|
@@ -1257,24 +1251,6 @@ const markSpecFacet = defineFacet({
|
|
|
1257
1251
|
parent: schemaSpecFacet,
|
|
1258
1252
|
singleton: true
|
|
1259
1253
|
});
|
|
1260
|
-
|
|
1261
|
-
//#endregion
|
|
1262
|
-
//#region src/extensions/mark-view.ts
|
|
1263
|
-
function defineMarkView(options) {
|
|
1264
|
-
return defineFacetPayload(markViewFacet, [options]);
|
|
1265
|
-
}
|
|
1266
|
-
const markViewFacet = defineFacet({
|
|
1267
|
-
reducer: (inputs) => {
|
|
1268
|
-
const markViews = {};
|
|
1269
|
-
for (const input of inputs) if (!markViews[input.name]) markViews[input.name] = input.constructor;
|
|
1270
|
-
return () => [new ProseMirrorPlugin({
|
|
1271
|
-
key: new PluginKey("prosekit-mark-view"),
|
|
1272
|
-
props: { markViews }
|
|
1273
|
-
})];
|
|
1274
|
-
},
|
|
1275
|
-
parent: pluginFacet
|
|
1276
|
-
});
|
|
1277
|
-
|
|
1278
1254
|
//#endregion
|
|
1279
1255
|
//#region src/extensions/mark-view-effect.ts
|
|
1280
1256
|
/**
|
|
@@ -1297,7 +1273,7 @@ const markViewFactoryFacet = defineFacet({
|
|
|
1297
1273
|
const factories = inputs.map((x) => x[0]).filter(isNotNullish);
|
|
1298
1274
|
const options = inputs.map((x) => x[1]).filter(isNotNullish);
|
|
1299
1275
|
for (const { group, name, args } of options) {
|
|
1300
|
-
const factory = factories.find((factory
|
|
1276
|
+
const factory = factories.find((factory) => factory.group === group);
|
|
1301
1277
|
if (!factory) continue;
|
|
1302
1278
|
markViews[name] = factory.factory(args);
|
|
1303
1279
|
}
|
|
@@ -1308,7 +1284,22 @@ const markViewFactoryFacet = defineFacet({
|
|
|
1308
1284
|
},
|
|
1309
1285
|
parent: pluginFacet
|
|
1310
1286
|
});
|
|
1311
|
-
|
|
1287
|
+
//#endregion
|
|
1288
|
+
//#region src/extensions/mark-view.ts
|
|
1289
|
+
function defineMarkView(options) {
|
|
1290
|
+
return defineFacetPayload(markViewFacet, [options]);
|
|
1291
|
+
}
|
|
1292
|
+
const markViewFacet = defineFacet({
|
|
1293
|
+
reducer: (inputs) => {
|
|
1294
|
+
const markViews = {};
|
|
1295
|
+
for (const input of inputs) if (!markViews[input.name]) markViews[input.name] = input.constructor;
|
|
1296
|
+
return () => [new ProseMirrorPlugin({
|
|
1297
|
+
key: new PluginKey("prosekit-mark-view"),
|
|
1298
|
+
props: { markViews }
|
|
1299
|
+
})];
|
|
1300
|
+
},
|
|
1301
|
+
parent: pluginFacet
|
|
1302
|
+
});
|
|
1312
1303
|
//#endregion
|
|
1313
1304
|
//#region src/extensions/node-spec.ts
|
|
1314
1305
|
/**
|
|
@@ -1379,24 +1370,6 @@ const nodeSpecFacet = defineFacet({
|
|
|
1379
1370
|
parent: schemaSpecFacet,
|
|
1380
1371
|
singleton: true
|
|
1381
1372
|
});
|
|
1382
|
-
|
|
1383
|
-
//#endregion
|
|
1384
|
-
//#region src/extensions/node-view.ts
|
|
1385
|
-
function defineNodeView(options) {
|
|
1386
|
-
return defineFacetPayload(nodeViewFacet, [options]);
|
|
1387
|
-
}
|
|
1388
|
-
const nodeViewFacet = defineFacet({
|
|
1389
|
-
reducer: (inputs) => {
|
|
1390
|
-
const nodeViews = {};
|
|
1391
|
-
for (const input of inputs) if (!nodeViews[input.name]) nodeViews[input.name] = input.constructor;
|
|
1392
|
-
return () => [new ProseMirrorPlugin({
|
|
1393
|
-
key: new PluginKey("prosekit-node-view"),
|
|
1394
|
-
props: { nodeViews }
|
|
1395
|
-
})];
|
|
1396
|
-
},
|
|
1397
|
-
parent: pluginFacet
|
|
1398
|
-
});
|
|
1399
|
-
|
|
1400
1373
|
//#endregion
|
|
1401
1374
|
//#region src/extensions/node-view-effect.ts
|
|
1402
1375
|
/**
|
|
@@ -1419,7 +1392,7 @@ const nodeViewFactoryFacet = defineFacet({
|
|
|
1419
1392
|
const factories = inputs.map((x) => x[0]).filter(isNotNullish);
|
|
1420
1393
|
const options = inputs.map((x) => x[1]).filter(isNotNullish);
|
|
1421
1394
|
for (const { group, name, args } of options) {
|
|
1422
|
-
const factory = factories.find((factory
|
|
1395
|
+
const factory = factories.find((factory) => factory.group === group);
|
|
1423
1396
|
if (!factory) continue;
|
|
1424
1397
|
nodeViews[name] = factory.factory(args);
|
|
1425
1398
|
}
|
|
@@ -1430,20 +1403,59 @@ const nodeViewFactoryFacet = defineFacet({
|
|
|
1430
1403
|
},
|
|
1431
1404
|
parent: pluginFacet
|
|
1432
1405
|
});
|
|
1433
|
-
|
|
1406
|
+
//#endregion
|
|
1407
|
+
//#region src/extensions/node-view.ts
|
|
1408
|
+
function defineNodeView(options) {
|
|
1409
|
+
return defineFacetPayload(nodeViewFacet, [options]);
|
|
1410
|
+
}
|
|
1411
|
+
const nodeViewFacet = defineFacet({
|
|
1412
|
+
reducer: (inputs) => {
|
|
1413
|
+
const nodeViews = {};
|
|
1414
|
+
for (const input of inputs) if (!nodeViews[input.name]) nodeViews[input.name] = input.constructor;
|
|
1415
|
+
return () => [new ProseMirrorPlugin({
|
|
1416
|
+
key: new PluginKey("prosekit-node-view"),
|
|
1417
|
+
props: { nodeViews }
|
|
1418
|
+
})];
|
|
1419
|
+
},
|
|
1420
|
+
parent: pluginFacet
|
|
1421
|
+
});
|
|
1422
|
+
//#endregion
|
|
1423
|
+
//#region src/types/priority.ts
|
|
1424
|
+
/**
|
|
1425
|
+
* ProseKit extension priority.
|
|
1426
|
+
*
|
|
1427
|
+
* There are five priority levels available:
|
|
1428
|
+
*
|
|
1429
|
+
* - `Priority.lowest`
|
|
1430
|
+
* - `Priority.low`
|
|
1431
|
+
* - `Priority.default`
|
|
1432
|
+
* - `Priority.high`
|
|
1433
|
+
* - `Priority.highest`
|
|
1434
|
+
*
|
|
1435
|
+
* @example
|
|
1436
|
+
*
|
|
1437
|
+
* ```ts
|
|
1438
|
+
* import { withPriority, Priority } from 'prosekit/core'
|
|
1439
|
+
* import { myExtension } from './my-extension.js'
|
|
1440
|
+
*
|
|
1441
|
+
* const myExtensionWithHighPriority = withPriority(myExtension, Priority.high)
|
|
1442
|
+
* ```
|
|
1443
|
+
*
|
|
1444
|
+
* @public
|
|
1445
|
+
*/
|
|
1446
|
+
const Priority = {
|
|
1447
|
+
lowest: 0,
|
|
1448
|
+
low: 1,
|
|
1449
|
+
default: 2,
|
|
1450
|
+
high: 3,
|
|
1451
|
+
highest: 4
|
|
1452
|
+
};
|
|
1434
1453
|
//#endregion
|
|
1435
1454
|
//#region src/utils/can-use-regex-lookbehind.ts
|
|
1436
1455
|
/**
|
|
1437
1456
|
* Checks if the browser supports [regex lookbehind assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookbehind_assertion).
|
|
1438
1457
|
*/
|
|
1439
|
-
const canUseRegexLookbehind =
|
|
1440
|
-
try {
|
|
1441
|
-
return "ab".replace(new RegExp("(?<=a)b", "g"), "c") === "ac";
|
|
1442
|
-
} catch {
|
|
1443
|
-
return false;
|
|
1444
|
-
}
|
|
1445
|
-
});
|
|
1446
|
-
|
|
1458
|
+
const canUseRegexLookbehind = supportsRegexLookbehind;
|
|
1447
1459
|
//#endregion
|
|
1448
1460
|
//#region src/utils/clsx.ts
|
|
1449
1461
|
/**
|
|
@@ -1454,7 +1466,6 @@ const canUseRegexLookbehind = once(() => {
|
|
|
1454
1466
|
* @public
|
|
1455
1467
|
*/
|
|
1456
1468
|
const clsx = clsxLite;
|
|
1457
|
-
|
|
1458
1469
|
//#endregion
|
|
1459
1470
|
//#region src/utils/contains-inline-node.ts
|
|
1460
1471
|
/**
|
|
@@ -1468,7 +1479,46 @@ function containsInlineNode(doc, from, to) {
|
|
|
1468
1479
|
});
|
|
1469
1480
|
return found;
|
|
1470
1481
|
}
|
|
1471
|
-
|
|
1482
|
+
//#endregion
|
|
1483
|
+
//#region src/utils/find-node.ts
|
|
1484
|
+
/**
|
|
1485
|
+
* Finds the first node that satisfies the predicate from the given document.
|
|
1486
|
+
*
|
|
1487
|
+
* @internal
|
|
1488
|
+
*/
|
|
1489
|
+
function findNode(doc, predicate) {
|
|
1490
|
+
let found;
|
|
1491
|
+
doc.descendants((node, pos, parent, index) => {
|
|
1492
|
+
if (found) return false;
|
|
1493
|
+
if (predicate(node)) {
|
|
1494
|
+
found = {
|
|
1495
|
+
node,
|
|
1496
|
+
pos,
|
|
1497
|
+
parent,
|
|
1498
|
+
index
|
|
1499
|
+
};
|
|
1500
|
+
return false;
|
|
1501
|
+
}
|
|
1502
|
+
});
|
|
1503
|
+
return found;
|
|
1504
|
+
}
|
|
1505
|
+
/**
|
|
1506
|
+
* Finds all nodes that satisfy the predicate from the given document.
|
|
1507
|
+
*
|
|
1508
|
+
* @internal
|
|
1509
|
+
*/
|
|
1510
|
+
function findNodes(doc, predicate) {
|
|
1511
|
+
const results = [];
|
|
1512
|
+
doc.descendants((node, pos, parent, index) => {
|
|
1513
|
+
if (predicate(node)) results.push({
|
|
1514
|
+
node,
|
|
1515
|
+
pos,
|
|
1516
|
+
parent,
|
|
1517
|
+
index
|
|
1518
|
+
});
|
|
1519
|
+
});
|
|
1520
|
+
return results;
|
|
1521
|
+
}
|
|
1472
1522
|
//#endregion
|
|
1473
1523
|
//#region src/utils/is-at-block-start.ts
|
|
1474
1524
|
/**
|
|
@@ -1481,7 +1531,6 @@ function isAtBlockStart(state, view) {
|
|
|
1481
1531
|
if (!$cursor || (view ? !view.endOfTextblock("backward", state) : $cursor.parentOffset > 0)) return null;
|
|
1482
1532
|
return $cursor;
|
|
1483
1533
|
}
|
|
1484
|
-
|
|
1485
1534
|
//#endregion
|
|
1486
1535
|
//#region src/utils/is-in-code-block.ts
|
|
1487
1536
|
function isCodeBlockType(type) {
|
|
@@ -1495,7 +1544,6 @@ function isCodeBlockType(type) {
|
|
|
1495
1544
|
function isInCodeBlock(selection) {
|
|
1496
1545
|
return isCodeBlockType(selection.$from.parent.type) || isCodeBlockType(selection.$to.parent.type);
|
|
1497
1546
|
}
|
|
1498
|
-
|
|
1499
1547
|
//#endregion
|
|
1500
1548
|
//#region src/utils/maybe-run.ts
|
|
1501
1549
|
/**
|
|
@@ -1504,14 +1552,12 @@ function isInCodeBlock(selection) {
|
|
|
1504
1552
|
function maybeRun(value, ...args) {
|
|
1505
1553
|
return typeof value === "function" ? value(...args) : value;
|
|
1506
1554
|
}
|
|
1507
|
-
|
|
1508
1555
|
//#endregion
|
|
1509
1556
|
//#region src/utils/unicode.ts
|
|
1510
1557
|
/**
|
|
1511
1558
|
* @internal
|
|
1512
1559
|
*/
|
|
1513
1560
|
const OBJECT_REPLACEMENT_CHARACTER = "";
|
|
1514
|
-
|
|
1515
1561
|
//#endregion
|
|
1516
1562
|
//#region src/utils/with-skip-code-block.ts
|
|
1517
1563
|
/**
|
|
@@ -1523,7 +1569,7 @@ function withSkipCodeBlock(command) {
|
|
|
1523
1569
|
return command(state, dispatch, view);
|
|
1524
1570
|
};
|
|
1525
1571
|
}
|
|
1526
|
-
|
|
1527
1572
|
//#endregion
|
|
1528
|
-
export { Editor, EditorNotFoundError, OBJECT_REPLACEMENT_CHARACTER, Priority, ProseKitError, addMark, assert, canUseRegexLookbehind, clsx, containsInlineNode, createEditor, defaultBlockAt, defineBaseCommands, defineBaseKeymap, defineClickHandler, defineClickOnHandler, defineClipboardSerializer, defineCommands, defineDOMEventHandler, defineDefaultState, defineDocChangeHandler, defineDoubleClickHandler, defineDoubleClickOnHandler, defineDropHandler, defineFacet, defineFacetPayload, defineFocusChangeHandler, defineHistory, defineKeyDownHandler, defineKeyPressHandler, defineKeymap, defineMarkAttr, defineMarkSpec, defineMarkView, defineMarkViewComponent, defineMarkViewFactory, defineMountHandler, defineNodeAttr, defineNodeSpec, defineNodeView, defineNodeViewComponent, defineNodeViewFactory, definePasteHandler, definePlugin, defineScrollToSelectionHandler, defineTextInputHandler, defineTripleClickHandler, defineTripleClickOnHandler, defineUnmountHandler, defineUpdateHandler, editorEventFacet, elementFromJSON, elementFromNode, expandMark, findParentNode, findParentNodeOfType, getMarkType, getNodeType, htmlFromJSON, htmlFromNode, insertDefaultBlock, insertNode, isAllSelection, isApple, isAtBlockStart, isFragment, isInCodeBlock, isMark, isMarkAbsent, isMarkActive, isNodeSelection, isProseMirrorNode, isSelection, isSlice, isTextSelection, jsonFromHTML, jsonFromNode, jsonFromState, keymapFacet, maybeRun, nodeFromElement, nodeFromHTML, nodeFromJSON, pluginFacet, removeMark, removeNode, selectAll, selectBlock, setBlockType, setNodeAttrs, setSelectionAround, stateFromJSON, toggleMark, toggleNode, toggleWrap, union, unsetBlockType, unsetMark, withPriority, withSkipCodeBlock, wrap };
|
|
1573
|
+
export { Editor, EditorNotFoundError, OBJECT_REPLACEMENT_CHARACTER, Priority, ProseKitError, addMark, assert, canUseRegexLookbehind, clsx, containsInlineNode, createEditor, defaultBlockAt, defineBaseCommands, defineBaseKeymap, defineClickHandler, defineClickOnHandler, defineClipboardSerializer, defineCommands, defineDOMEventHandler, defineDefaultState, defineDocChangeHandler, defineDoubleClickHandler, defineDoubleClickOnHandler, defineDropHandler, defineFacet, defineFacetPayload, defineFocusChangeHandler, defineHistory, defineKeyDownHandler, defineKeyPressHandler, defineKeymap, defineMarkAttr, defineMarkSpec, defineMarkView, defineMarkViewComponent, defineMarkViewFactory, defineMountHandler, defineNodeAttr, defineNodeSpec, defineNodeView, defineNodeViewComponent, defineNodeViewFactory, definePasteHandler, definePlugin, defineScrollToSelectionHandler, defineTextInputHandler, defineTripleClickHandler, defineTripleClickOnHandler, defineUnmountHandler, defineUpdateHandler, editorEventFacet, elementFromJSON, elementFromNode, expandMark, findNode, findNodes, findParentNode, findParentNodeOfType, getMarkType, getNodeType, htmlFromJSON, htmlFromNode, insertDefaultBlock, insertNode, isAllSelection, isApple, isAtBlockStart, isFragment, isInCodeBlock, isMark, isMarkAbsent, isMarkActive, isNodeSelection, isProseMirrorNode, isSelection, isSlice, isTextSelection, jsonFromHTML, jsonFromNode, jsonFromState, keymapFacet, maybeRun, nodeFromElement, nodeFromHTML, nodeFromJSON, pluginFacet, removeMark, removeNode, selectAll, selectBlock, setBlockType, setNodeAttrs, setNodeAttrsBetween, setSelectionAround, stateFromJSON, toggleMark, toggleNode, toggleWrap, union, unsetBlockType, unsetMark, withPriority, withSkipCodeBlock, wrap };
|
|
1574
|
+
|
|
1529
1575
|
//# sourceMappingURL=prosekit-core.js.map
|