@blade-hq/agent-react 2612.0.0-beta.87 → 2612.0.0-beta.88
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/SessionPluginConfigForm-Y657MKRX.js +9 -0
- package/dist/chat/ChatPanel.d.ts +3 -1
- package/dist/chat/chat-column-width.d.ts +2 -2
- package/dist/{chunk-GBZEFIGW.js → chunk-5ESAKOUV.js} +2 -2
- package/dist/{chunk-K6N5CQDP.js → chunk-5UGLGKFI.js} +205 -7
- package/dist/chunk-5UGLGKFI.js.map +1 -0
- package/dist/{chunk-34MHG656.js → chunk-7LVZQ4LS.js} +95 -77
- package/dist/chunk-7LVZQ4LS.js.map +1 -0
- package/dist/{chunk-J6YPRDQH.js → chunk-GXHHSZSS.js} +2 -2
- package/dist/{chunk-G6OC5I4W.js → chunk-LOXIHCL2.js} +13 -7
- package/dist/{chunk-G6OC5I4W.js.map → chunk-LOXIHCL2.js.map} +1 -1
- package/dist/{chunk-WG2HHYGK.js → chunk-NADWKQYZ.js} +76 -11
- package/dist/{chunk-WG2HHYGK.js.map → chunk-NADWKQYZ.js.map} +1 -1
- package/dist/{chunk-JFGBDNDD.js → chunk-PWUFWSMN.js} +3 -3
- package/dist/{chunk-GJZGRIDJ.js → chunk-QKI7OC5D.js} +245 -19
- package/dist/chunk-QKI7OC5D.js.map +1 -0
- package/dist/{chunk-5ZV73E5D.js → chunk-SEJUZPT5.js} +10 -1
- package/dist/chunk-SEJUZPT5.js.map +1 -0
- package/dist/{chunk-BZHMZBYT.js → chunk-VTEKA5HD.js} +281 -102
- package/dist/{chunk-BZHMZBYT.js.map → chunk-VTEKA5HD.js.map} +1 -1
- package/dist/connectors.js +3 -3
- package/dist/index.js +9 -9
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +616 -46
- package/dist/internal.js.map +1 -1
- package/dist/questions.js +4 -4
- package/dist/rich-input.js +647 -826
- package/dist/rich-input.js.map +1 -1
- package/dist/tool-details.js +5 -5
- package/package.json +2 -2
- package/dist/SessionPluginConfigForm-2KG4TG4W.js +0 -9
- package/dist/chat-WA7YIAHD.css +0 -180
- package/dist/chunk-34MHG656.js.map +0 -1
- package/dist/chunk-5ZV73E5D.js.map +0 -1
- package/dist/chunk-GJZGRIDJ.js.map +0 -1
- package/dist/chunk-K6N5CQDP.js.map +0 -1
- /package/dist/{SessionPluginConfigForm-2KG4TG4W.js.map → SessionPluginConfigForm-Y657MKRX.js.map} +0 -0
- /package/dist/{chunk-GBZEFIGW.js.map → chunk-5ESAKOUV.js.map} +0 -0
- /package/dist/{chunk-J6YPRDQH.js.map → chunk-GXHHSZSS.js.map} +0 -0
- /package/dist/{chunk-JFGBDNDD.js.map → chunk-PWUFWSMN.js.map} +0 -0
package/dist/rich-input.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ConnectorPanel,
|
|
3
3
|
PluginTriggerStack,
|
|
4
|
+
backgroundTaskDismissals,
|
|
5
|
+
composerChannels,
|
|
4
6
|
selectionFromItem,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
skillDisplayName,
|
|
8
|
+
triggerSummary,
|
|
9
|
+
useComposerChannels,
|
|
10
|
+
useDismissedBackgroundTasks,
|
|
11
|
+
visibleSkills
|
|
12
|
+
} from "./chunk-5UGLGKFI.js";
|
|
7
13
|
import {
|
|
8
14
|
MODEL_REASONING_LEVELS_KEY,
|
|
9
15
|
PREFERRED_MODEL_KEY,
|
|
@@ -40,8 +46,8 @@ import {
|
|
|
40
46
|
useSessionDataInvalidation,
|
|
41
47
|
useSessionSkills,
|
|
42
48
|
useSkillStats
|
|
43
|
-
} from "./chunk-
|
|
44
|
-
import "./chunk-
|
|
49
|
+
} from "./chunk-7LVZQ4LS.js";
|
|
50
|
+
import "./chunk-PWUFWSMN.js";
|
|
45
51
|
import {
|
|
46
52
|
cn,
|
|
47
53
|
notifyChat,
|
|
@@ -53,7 +59,7 @@ import {
|
|
|
53
59
|
useSessionHandle,
|
|
54
60
|
useSessionSource,
|
|
55
61
|
useSessionState
|
|
56
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-VTEKA5HD.js";
|
|
57
63
|
import {
|
|
58
64
|
Dialog,
|
|
59
65
|
DialogClose,
|
|
@@ -62,8 +68,8 @@ import {
|
|
|
62
68
|
cn as cn2,
|
|
63
69
|
dist_exports4 as dist_exports,
|
|
64
70
|
usePortalContainer
|
|
65
|
-
} from "./chunk-
|
|
66
|
-
import "./chunk-
|
|
71
|
+
} from "./chunk-GXHHSZSS.js";
|
|
72
|
+
import "./chunk-5ESAKOUV.js";
|
|
67
73
|
import {
|
|
68
74
|
Archive,
|
|
69
75
|
ArrowUp,
|
|
@@ -96,7 +102,7 @@ import {
|
|
|
96
102
|
Square,
|
|
97
103
|
Terminal,
|
|
98
104
|
X
|
|
99
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-SEJUZPT5.js";
|
|
100
106
|
import {
|
|
101
107
|
__commonJS,
|
|
102
108
|
__require,
|
|
@@ -188,7 +194,7 @@ var require_with_selector_development = __commonJS({
|
|
|
188
194
|
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
189
195
|
}
|
|
190
196
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
191
|
-
var React2 = __require("react"), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is,
|
|
197
|
+
var React2 = __require("react"), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore4 = shim.useSyncExternalStore, useRef8 = React2.useRef, useEffect11 = React2.useEffect, useMemo8 = React2.useMemo, useDebugValue3 = React2.useDebugValue;
|
|
192
198
|
exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
193
199
|
var instRef = useRef8(null);
|
|
194
200
|
if (null === instRef.current) {
|
|
@@ -230,7 +236,7 @@ var require_with_selector_development = __commonJS({
|
|
|
230
236
|
},
|
|
231
237
|
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
232
238
|
);
|
|
233
|
-
var value =
|
|
239
|
+
var value = useSyncExternalStore4(subscribe, instRef[0], instRef[1]);
|
|
234
240
|
useEffect11(
|
|
235
241
|
function() {
|
|
236
242
|
inst.hasValue = true;
|
|
@@ -261,41 +267,6 @@ var require_with_selector = __commonJS({
|
|
|
261
267
|
// src/rich-input/BackgroundTasksPill.tsx
|
|
262
268
|
import { useMemo, useState } from "react";
|
|
263
269
|
|
|
264
|
-
// src/chat/runtime/background-task-dismissals.ts
|
|
265
|
-
import { useSyncExternalStore } from "react";
|
|
266
|
-
var state = {};
|
|
267
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
268
|
-
var NO_IDS = [];
|
|
269
|
-
function emit() {
|
|
270
|
-
for (const listener of [...listeners]) listener();
|
|
271
|
-
}
|
|
272
|
-
var backgroundTaskDismissals = {
|
|
273
|
-
getState: () => state,
|
|
274
|
-
subscribe(listener) {
|
|
275
|
-
listeners.add(listener);
|
|
276
|
-
return () => {
|
|
277
|
-
listeners.delete(listener);
|
|
278
|
-
};
|
|
279
|
-
},
|
|
280
|
-
dismiss(sessionId, taskId) {
|
|
281
|
-
const existing = state[sessionId] ?? [];
|
|
282
|
-
if (existing.includes(taskId)) return;
|
|
283
|
-
state = { ...state, [sessionId]: [...existing, taskId] };
|
|
284
|
-
emit();
|
|
285
|
-
},
|
|
286
|
-
reset() {
|
|
287
|
-
state = {};
|
|
288
|
-
emit();
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
function useDismissedBackgroundTasks(sessionId) {
|
|
292
|
-
return useSyncExternalStore(
|
|
293
|
-
backgroundTaskDismissals.subscribe,
|
|
294
|
-
() => state[sessionId] ?? NO_IDS,
|
|
295
|
-
() => state[sessionId] ?? NO_IDS
|
|
296
|
-
);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
270
|
// src/rich-input/lib/background-tasks-view.ts
|
|
300
271
|
var LIVE_STATUSES = /* @__PURE__ */ new Set(["starting", "running", "cancelling"]);
|
|
301
272
|
var ATTENTION_STATUSES = /* @__PURE__ */ new Set(["failed", "lost"]);
|
|
@@ -2580,19 +2551,19 @@ function dfa(nfa2) {
|
|
|
2580
2551
|
});
|
|
2581
2552
|
});
|
|
2582
2553
|
});
|
|
2583
|
-
let
|
|
2554
|
+
let state = labeled[states.join(",")] = new ContentMatch(states.indexOf(nfa2.length - 1) > -1);
|
|
2584
2555
|
for (let i = 0; i < out.length; i++) {
|
|
2585
2556
|
let states2 = out[i][1].sort(cmp);
|
|
2586
|
-
|
|
2557
|
+
state.next.push({ type: out[i][0], next: labeled[states2.join(",")] || explore(states2) });
|
|
2587
2558
|
}
|
|
2588
|
-
return
|
|
2559
|
+
return state;
|
|
2589
2560
|
}
|
|
2590
2561
|
}
|
|
2591
2562
|
function checkForDeadEnds(match, stream) {
|
|
2592
2563
|
for (let i = 0, work = [match]; i < work.length; i++) {
|
|
2593
|
-
let
|
|
2594
|
-
for (let j = 0; j <
|
|
2595
|
-
let { type, next } =
|
|
2564
|
+
let state = work[i], dead = !state.validEnd, nodes = [];
|
|
2565
|
+
for (let j = 0; j < state.next.length; j++) {
|
|
2566
|
+
let { type, next } = state.next[j];
|
|
2596
2567
|
nodes.push(type.name);
|
|
2597
2568
|
if (dead && !(type.isText || type.hasRequiredAttrs()))
|
|
2598
2569
|
dead = false;
|
|
@@ -6200,14 +6171,14 @@ var Transaction = class extends Transform {
|
|
|
6200
6171
|
/**
|
|
6201
6172
|
@internal
|
|
6202
6173
|
*/
|
|
6203
|
-
constructor(
|
|
6204
|
-
super(
|
|
6174
|
+
constructor(state) {
|
|
6175
|
+
super(state.doc);
|
|
6205
6176
|
this.curSelectionFor = 0;
|
|
6206
6177
|
this.updated = 0;
|
|
6207
6178
|
this.meta = /* @__PURE__ */ Object.create(null);
|
|
6208
6179
|
this.time = Date.now();
|
|
6209
|
-
this.curSelection =
|
|
6210
|
-
this.storedMarks =
|
|
6180
|
+
this.curSelection = state.selection;
|
|
6181
|
+
this.storedMarks = state.storedMarks;
|
|
6211
6182
|
}
|
|
6212
6183
|
/**
|
|
6213
6184
|
The transaction's current selection. This defaults to the editor
|
|
@@ -6413,8 +6384,8 @@ var baseFields = [
|
|
|
6413
6384
|
init(config) {
|
|
6414
6385
|
return config.storedMarks || null;
|
|
6415
6386
|
},
|
|
6416
|
-
apply(tr2, _marks, _old,
|
|
6417
|
-
return
|
|
6387
|
+
apply(tr2, _marks, _old, state) {
|
|
6388
|
+
return state.selection.$cursor ? tr2.storedMarks : null;
|
|
6418
6389
|
}
|
|
6419
6390
|
}),
|
|
6420
6391
|
new FieldDesc("scrollToSelection", {
|
|
@@ -6578,9 +6549,9 @@ var EditorState = class _EditorState {
|
|
|
6578
6549
|
for (let prop in pluginFields) {
|
|
6579
6550
|
if (prop == "doc" || prop == "selection")
|
|
6580
6551
|
throw new RangeError("The JSON fields `doc` and `selection` are reserved");
|
|
6581
|
-
let plugin = pluginFields[prop],
|
|
6582
|
-
if (
|
|
6583
|
-
result[prop] =
|
|
6552
|
+
let plugin = pluginFields[prop], state = plugin.spec.state;
|
|
6553
|
+
if (state && state.toJSON)
|
|
6554
|
+
result[prop] = state.toJSON.call(plugin, this[plugin.key]);
|
|
6584
6555
|
}
|
|
6585
6556
|
return result;
|
|
6586
6557
|
}
|
|
@@ -6609,9 +6580,9 @@ var EditorState = class _EditorState {
|
|
|
6609
6580
|
} else {
|
|
6610
6581
|
if (pluginFields)
|
|
6611
6582
|
for (let prop in pluginFields) {
|
|
6612
|
-
let plugin = pluginFields[prop],
|
|
6613
|
-
if (plugin.key == field.name &&
|
|
6614
|
-
instance[field.name] =
|
|
6583
|
+
let plugin = pluginFields[prop], state = plugin.spec.state;
|
|
6584
|
+
if (plugin.key == field.name && state && state.fromJSON && Object.prototype.hasOwnProperty.call(json, prop)) {
|
|
6585
|
+
instance[field.name] = state.fromJSON.call(plugin, config, json[prop], instance);
|
|
6615
6586
|
return;
|
|
6616
6587
|
}
|
|
6617
6588
|
}
|
|
@@ -6646,8 +6617,8 @@ var Plugin = class {
|
|
|
6646
6617
|
/**
|
|
6647
6618
|
Extract the plugin's state field from an editor state.
|
|
6648
6619
|
*/
|
|
6649
|
-
getState(
|
|
6650
|
-
return
|
|
6620
|
+
getState(state) {
|
|
6621
|
+
return state[this.key];
|
|
6651
6622
|
}
|
|
6652
6623
|
};
|
|
6653
6624
|
var keys = /* @__PURE__ */ Object.create(null);
|
|
@@ -6668,33 +6639,33 @@ var PluginKey = class {
|
|
|
6668
6639
|
Get the active plugin with this key, if any, from an editor
|
|
6669
6640
|
state.
|
|
6670
6641
|
*/
|
|
6671
|
-
get(
|
|
6672
|
-
return
|
|
6642
|
+
get(state) {
|
|
6643
|
+
return state.config.pluginsByKey[this.key];
|
|
6673
6644
|
}
|
|
6674
6645
|
/**
|
|
6675
6646
|
Get the plugin's state from an editor state.
|
|
6676
6647
|
*/
|
|
6677
|
-
getState(
|
|
6678
|
-
return
|
|
6648
|
+
getState(state) {
|
|
6649
|
+
return state[this.key];
|
|
6679
6650
|
}
|
|
6680
6651
|
};
|
|
6681
6652
|
|
|
6682
6653
|
// ../../node_modules/.pnpm/prosemirror-commands@1.7.1/node_modules/prosemirror-commands/dist/index.js
|
|
6683
|
-
var deleteSelection = (
|
|
6684
|
-
if (
|
|
6654
|
+
var deleteSelection = (state, dispatch) => {
|
|
6655
|
+
if (state.selection.empty)
|
|
6685
6656
|
return false;
|
|
6686
6657
|
if (dispatch)
|
|
6687
|
-
dispatch(
|
|
6658
|
+
dispatch(state.tr.deleteSelection().scrollIntoView());
|
|
6688
6659
|
return true;
|
|
6689
6660
|
};
|
|
6690
|
-
function atBlockStart(
|
|
6691
|
-
let { $cursor } =
|
|
6692
|
-
if (!$cursor || (view ? !view.endOfTextblock("backward",
|
|
6661
|
+
function atBlockStart(state, view) {
|
|
6662
|
+
let { $cursor } = state.selection;
|
|
6663
|
+
if (!$cursor || (view ? !view.endOfTextblock("backward", state) : $cursor.parentOffset > 0))
|
|
6693
6664
|
return null;
|
|
6694
6665
|
return $cursor;
|
|
6695
6666
|
}
|
|
6696
|
-
var joinBackward = (
|
|
6697
|
-
let $cursor = atBlockStart(
|
|
6667
|
+
var joinBackward = (state, dispatch, view) => {
|
|
6668
|
+
let $cursor = atBlockStart(state, view);
|
|
6698
6669
|
if (!$cursor)
|
|
6699
6670
|
return false;
|
|
6700
6671
|
let $cut = findCutBefore($cursor);
|
|
@@ -6703,18 +6674,18 @@ var joinBackward = (state3, dispatch, view) => {
|
|
|
6703
6674
|
if (target == null)
|
|
6704
6675
|
return false;
|
|
6705
6676
|
if (dispatch)
|
|
6706
|
-
dispatch(
|
|
6677
|
+
dispatch(state.tr.lift(range, target).scrollIntoView());
|
|
6707
6678
|
return true;
|
|
6708
6679
|
}
|
|
6709
6680
|
let before = $cut.nodeBefore;
|
|
6710
|
-
if (deleteBarrier(
|
|
6681
|
+
if (deleteBarrier(state, $cut, dispatch, -1))
|
|
6711
6682
|
return true;
|
|
6712
6683
|
if ($cursor.parent.content.size == 0 && (textblockAt(before, "end") || NodeSelection.isSelectable(before))) {
|
|
6713
6684
|
for (let depth = $cursor.depth; ; depth--) {
|
|
6714
|
-
let delStep = replaceStep(
|
|
6685
|
+
let delStep = replaceStep(state.doc, $cursor.before(depth), $cursor.after(depth), Slice.empty);
|
|
6715
6686
|
if (delStep && delStep.slice.size < delStep.to - delStep.from) {
|
|
6716
6687
|
if (dispatch) {
|
|
6717
|
-
let tr2 =
|
|
6688
|
+
let tr2 = state.tr.step(delStep);
|
|
6718
6689
|
tr2.setSelection(textblockAt(before, "end") ? Selection.findFrom(tr2.doc.resolve(tr2.mapping.map($cut.pos, -1)), -1) : NodeSelection.create(tr2.doc, $cut.pos - before.nodeSize));
|
|
6719
6690
|
dispatch(tr2.scrollIntoView());
|
|
6720
6691
|
}
|
|
@@ -6726,26 +6697,26 @@ var joinBackward = (state3, dispatch, view) => {
|
|
|
6726
6697
|
}
|
|
6727
6698
|
if (before.isAtom && $cut.depth == $cursor.depth - 1) {
|
|
6728
6699
|
if (dispatch)
|
|
6729
|
-
dispatch(
|
|
6700
|
+
dispatch(state.tr.delete($cut.pos - before.nodeSize, $cut.pos).scrollIntoView());
|
|
6730
6701
|
return true;
|
|
6731
6702
|
}
|
|
6732
6703
|
return false;
|
|
6733
6704
|
};
|
|
6734
|
-
var joinTextblockBackward = (
|
|
6735
|
-
let $cursor = atBlockStart(
|
|
6705
|
+
var joinTextblockBackward = (state, dispatch, view) => {
|
|
6706
|
+
let $cursor = atBlockStart(state, view);
|
|
6736
6707
|
if (!$cursor)
|
|
6737
6708
|
return false;
|
|
6738
6709
|
let $cut = findCutBefore($cursor);
|
|
6739
|
-
return $cut ? joinTextblocksAround(
|
|
6710
|
+
return $cut ? joinTextblocksAround(state, $cut, dispatch) : false;
|
|
6740
6711
|
};
|
|
6741
|
-
var joinTextblockForward = (
|
|
6742
|
-
let $cursor = atBlockEnd(
|
|
6712
|
+
var joinTextblockForward = (state, dispatch, view) => {
|
|
6713
|
+
let $cursor = atBlockEnd(state, view);
|
|
6743
6714
|
if (!$cursor)
|
|
6744
6715
|
return false;
|
|
6745
6716
|
let $cut = findCutAfter($cursor);
|
|
6746
|
-
return $cut ? joinTextblocksAround(
|
|
6717
|
+
return $cut ? joinTextblocksAround(state, $cut, dispatch) : false;
|
|
6747
6718
|
};
|
|
6748
|
-
function joinTextblocksAround(
|
|
6719
|
+
function joinTextblocksAround(state, $cut, dispatch) {
|
|
6749
6720
|
let before = $cut.nodeBefore, beforeText = before, beforePos = $cut.pos - 1;
|
|
6750
6721
|
for (; !beforeText.isTextblock; beforePos--) {
|
|
6751
6722
|
if (beforeText.type.spec.isolating)
|
|
@@ -6764,11 +6735,11 @@ function joinTextblocksAround(state3, $cut, dispatch) {
|
|
|
6764
6735
|
return false;
|
|
6765
6736
|
afterText = child;
|
|
6766
6737
|
}
|
|
6767
|
-
let step = replaceStep(
|
|
6738
|
+
let step = replaceStep(state.doc, beforePos, afterPos, Slice.empty);
|
|
6768
6739
|
if (!step || step.from != beforePos || step instanceof ReplaceStep && step.slice.size >= afterPos - beforePos)
|
|
6769
6740
|
return false;
|
|
6770
6741
|
if (dispatch) {
|
|
6771
|
-
let tr2 =
|
|
6742
|
+
let tr2 = state.tr.step(step);
|
|
6772
6743
|
tr2.setSelection(TextSelection.create(tr2.doc, beforePos));
|
|
6773
6744
|
dispatch(tr2.scrollIntoView());
|
|
6774
6745
|
}
|
|
@@ -6783,12 +6754,12 @@ function textblockAt(node, side, only = false) {
|
|
|
6783
6754
|
}
|
|
6784
6755
|
return false;
|
|
6785
6756
|
}
|
|
6786
|
-
var selectNodeBackward = (
|
|
6787
|
-
let { $head, empty: empty2 } =
|
|
6757
|
+
var selectNodeBackward = (state, dispatch, view) => {
|
|
6758
|
+
let { $head, empty: empty2 } = state.selection, $cut = $head;
|
|
6788
6759
|
if (!empty2)
|
|
6789
6760
|
return false;
|
|
6790
6761
|
if ($head.parent.isTextblock) {
|
|
6791
|
-
if (view ? !view.endOfTextblock("backward",
|
|
6762
|
+
if (view ? !view.endOfTextblock("backward", state) : $head.parentOffset > 0)
|
|
6792
6763
|
return false;
|
|
6793
6764
|
$cut = findCutBefore($head);
|
|
6794
6765
|
}
|
|
@@ -6796,7 +6767,7 @@ var selectNodeBackward = (state3, dispatch, view) => {
|
|
|
6796
6767
|
if (!node || !NodeSelection.isSelectable(node))
|
|
6797
6768
|
return false;
|
|
6798
6769
|
if (dispatch)
|
|
6799
|
-
dispatch(
|
|
6770
|
+
dispatch(state.tr.setSelection(NodeSelection.create(state.doc, $cut.pos - node.nodeSize)).scrollIntoView());
|
|
6800
6771
|
return true;
|
|
6801
6772
|
};
|
|
6802
6773
|
function findCutBefore($pos) {
|
|
@@ -6809,27 +6780,27 @@ function findCutBefore($pos) {
|
|
|
6809
6780
|
}
|
|
6810
6781
|
return null;
|
|
6811
6782
|
}
|
|
6812
|
-
function atBlockEnd(
|
|
6813
|
-
let { $cursor } =
|
|
6814
|
-
if (!$cursor || (view ? !view.endOfTextblock("forward",
|
|
6783
|
+
function atBlockEnd(state, view) {
|
|
6784
|
+
let { $cursor } = state.selection;
|
|
6785
|
+
if (!$cursor || (view ? !view.endOfTextblock("forward", state) : $cursor.parentOffset < $cursor.parent.content.size))
|
|
6815
6786
|
return null;
|
|
6816
6787
|
return $cursor;
|
|
6817
6788
|
}
|
|
6818
|
-
var joinForward = (
|
|
6819
|
-
let $cursor = atBlockEnd(
|
|
6789
|
+
var joinForward = (state, dispatch, view) => {
|
|
6790
|
+
let $cursor = atBlockEnd(state, view);
|
|
6820
6791
|
if (!$cursor)
|
|
6821
6792
|
return false;
|
|
6822
6793
|
let $cut = findCutAfter($cursor);
|
|
6823
6794
|
if (!$cut)
|
|
6824
6795
|
return false;
|
|
6825
6796
|
let after = $cut.nodeAfter;
|
|
6826
|
-
if (deleteBarrier(
|
|
6797
|
+
if (deleteBarrier(state, $cut, dispatch, 1))
|
|
6827
6798
|
return true;
|
|
6828
6799
|
if ($cursor.parent.content.size == 0 && (textblockAt(after, "start") || NodeSelection.isSelectable(after))) {
|
|
6829
|
-
let delStep = replaceStep(
|
|
6800
|
+
let delStep = replaceStep(state.doc, $cursor.before(), $cursor.after(), Slice.empty);
|
|
6830
6801
|
if (delStep && delStep.slice.size < delStep.to - delStep.from) {
|
|
6831
6802
|
if (dispatch) {
|
|
6832
|
-
let tr2 =
|
|
6803
|
+
let tr2 = state.tr.step(delStep);
|
|
6833
6804
|
tr2.setSelection(textblockAt(after, "start") ? Selection.findFrom(tr2.doc.resolve(tr2.mapping.map($cut.pos)), 1) : NodeSelection.create(tr2.doc, tr2.mapping.map($cut.pos)));
|
|
6834
6805
|
dispatch(tr2.scrollIntoView());
|
|
6835
6806
|
}
|
|
@@ -6838,17 +6809,17 @@ var joinForward = (state3, dispatch, view) => {
|
|
|
6838
6809
|
}
|
|
6839
6810
|
if (after.isAtom && $cut.depth == $cursor.depth - 1) {
|
|
6840
6811
|
if (dispatch)
|
|
6841
|
-
dispatch(
|
|
6812
|
+
dispatch(state.tr.delete($cut.pos, $cut.pos + after.nodeSize).scrollIntoView());
|
|
6842
6813
|
return true;
|
|
6843
6814
|
}
|
|
6844
6815
|
return false;
|
|
6845
6816
|
};
|
|
6846
|
-
var selectNodeForward = (
|
|
6847
|
-
let { $head, empty: empty2 } =
|
|
6817
|
+
var selectNodeForward = (state, dispatch, view) => {
|
|
6818
|
+
let { $head, empty: empty2 } = state.selection, $cut = $head;
|
|
6848
6819
|
if (!empty2)
|
|
6849
6820
|
return false;
|
|
6850
6821
|
if ($head.parent.isTextblock) {
|
|
6851
|
-
if (view ? !view.endOfTextblock("forward",
|
|
6822
|
+
if (view ? !view.endOfTextblock("forward", state) : $head.parentOffset < $head.parent.content.size)
|
|
6852
6823
|
return false;
|
|
6853
6824
|
$cut = findCutAfter($head);
|
|
6854
6825
|
}
|
|
@@ -6856,7 +6827,7 @@ var selectNodeForward = (state3, dispatch, view) => {
|
|
|
6856
6827
|
if (!node || !NodeSelection.isSelectable(node))
|
|
6857
6828
|
return false;
|
|
6858
6829
|
if (dispatch)
|
|
6859
|
-
dispatch(
|
|
6830
|
+
dispatch(state.tr.setSelection(NodeSelection.create(state.doc, $cut.pos)).scrollIntoView());
|
|
6860
6831
|
return true;
|
|
6861
6832
|
};
|
|
6862
6833
|
function findCutAfter($pos) {
|
|
@@ -6870,55 +6841,55 @@ function findCutAfter($pos) {
|
|
|
6870
6841
|
}
|
|
6871
6842
|
return null;
|
|
6872
6843
|
}
|
|
6873
|
-
var joinUp = (
|
|
6874
|
-
let sel =
|
|
6844
|
+
var joinUp = (state, dispatch) => {
|
|
6845
|
+
let sel = state.selection, nodeSel = sel instanceof NodeSelection, point;
|
|
6875
6846
|
if (nodeSel) {
|
|
6876
|
-
if (sel.node.isTextblock || !canJoin(
|
|
6847
|
+
if (sel.node.isTextblock || !canJoin(state.doc, sel.from))
|
|
6877
6848
|
return false;
|
|
6878
6849
|
point = sel.from;
|
|
6879
6850
|
} else {
|
|
6880
|
-
point = joinPoint(
|
|
6851
|
+
point = joinPoint(state.doc, sel.from, -1);
|
|
6881
6852
|
if (point == null)
|
|
6882
6853
|
return false;
|
|
6883
6854
|
}
|
|
6884
6855
|
if (dispatch) {
|
|
6885
|
-
let tr2 =
|
|
6856
|
+
let tr2 = state.tr.join(point);
|
|
6886
6857
|
if (nodeSel)
|
|
6887
|
-
tr2.setSelection(NodeSelection.create(tr2.doc, point -
|
|
6858
|
+
tr2.setSelection(NodeSelection.create(tr2.doc, point - state.doc.resolve(point).nodeBefore.nodeSize));
|
|
6888
6859
|
dispatch(tr2.scrollIntoView());
|
|
6889
6860
|
}
|
|
6890
6861
|
return true;
|
|
6891
6862
|
};
|
|
6892
|
-
var joinDown = (
|
|
6893
|
-
let sel =
|
|
6863
|
+
var joinDown = (state, dispatch) => {
|
|
6864
|
+
let sel = state.selection, point;
|
|
6894
6865
|
if (sel instanceof NodeSelection) {
|
|
6895
|
-
if (sel.node.isTextblock || !canJoin(
|
|
6866
|
+
if (sel.node.isTextblock || !canJoin(state.doc, sel.to))
|
|
6896
6867
|
return false;
|
|
6897
6868
|
point = sel.to;
|
|
6898
6869
|
} else {
|
|
6899
|
-
point = joinPoint(
|
|
6870
|
+
point = joinPoint(state.doc, sel.to, 1);
|
|
6900
6871
|
if (point == null)
|
|
6901
6872
|
return false;
|
|
6902
6873
|
}
|
|
6903
6874
|
if (dispatch)
|
|
6904
|
-
dispatch(
|
|
6875
|
+
dispatch(state.tr.join(point).scrollIntoView());
|
|
6905
6876
|
return true;
|
|
6906
6877
|
};
|
|
6907
|
-
var lift2 = (
|
|
6908
|
-
let { $from, $to } =
|
|
6878
|
+
var lift2 = (state, dispatch) => {
|
|
6879
|
+
let { $from, $to } = state.selection;
|
|
6909
6880
|
let range = $from.blockRange($to), target = range && liftTarget(range);
|
|
6910
6881
|
if (target == null)
|
|
6911
6882
|
return false;
|
|
6912
6883
|
if (dispatch)
|
|
6913
|
-
dispatch(
|
|
6884
|
+
dispatch(state.tr.lift(range, target).scrollIntoView());
|
|
6914
6885
|
return true;
|
|
6915
6886
|
};
|
|
6916
|
-
var newlineInCode = (
|
|
6917
|
-
let { $head, $anchor } =
|
|
6887
|
+
var newlineInCode = (state, dispatch) => {
|
|
6888
|
+
let { $head, $anchor } = state.selection;
|
|
6918
6889
|
if (!$head.parent.type.spec.code || !$head.sameParent($anchor))
|
|
6919
6890
|
return false;
|
|
6920
6891
|
if (dispatch)
|
|
6921
|
-
dispatch(
|
|
6892
|
+
dispatch(state.tr.insertText("\n").scrollIntoView());
|
|
6922
6893
|
return true;
|
|
6923
6894
|
};
|
|
6924
6895
|
function defaultBlockAt(match) {
|
|
@@ -6929,22 +6900,22 @@ function defaultBlockAt(match) {
|
|
|
6929
6900
|
}
|
|
6930
6901
|
return null;
|
|
6931
6902
|
}
|
|
6932
|
-
var exitCode = (
|
|
6933
|
-
let { $head, $anchor } =
|
|
6903
|
+
var exitCode = (state, dispatch) => {
|
|
6904
|
+
let { $head, $anchor } = state.selection;
|
|
6934
6905
|
if (!$head.parent.type.spec.code || !$head.sameParent($anchor))
|
|
6935
6906
|
return false;
|
|
6936
6907
|
let above = $head.node(-1), after = $head.indexAfter(-1), type = defaultBlockAt(above.contentMatchAt(after));
|
|
6937
6908
|
if (!type || !above.canReplaceWith(after, after, type))
|
|
6938
6909
|
return false;
|
|
6939
6910
|
if (dispatch) {
|
|
6940
|
-
let pos = $head.after(), tr2 =
|
|
6911
|
+
let pos = $head.after(), tr2 = state.tr.replaceWith(pos, pos, type.createAndFill());
|
|
6941
6912
|
tr2.setSelection(Selection.near(tr2.doc.resolve(pos), 1));
|
|
6942
6913
|
dispatch(tr2.scrollIntoView());
|
|
6943
6914
|
}
|
|
6944
6915
|
return true;
|
|
6945
6916
|
};
|
|
6946
|
-
var createParagraphNear = (
|
|
6947
|
-
let sel =
|
|
6917
|
+
var createParagraphNear = (state, dispatch) => {
|
|
6918
|
+
let sel = state.selection, { $from, $to } = sel;
|
|
6948
6919
|
if (sel instanceof AllSelection || $from.parent.inlineContent || $to.parent.inlineContent)
|
|
6949
6920
|
return false;
|
|
6950
6921
|
let type = defaultBlockAt($to.parent.contentMatchAt($to.indexAfter()));
|
|
@@ -6952,21 +6923,21 @@ var createParagraphNear = (state3, dispatch) => {
|
|
|
6952
6923
|
return false;
|
|
6953
6924
|
if (dispatch) {
|
|
6954
6925
|
let side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to).pos;
|
|
6955
|
-
let tr2 =
|
|
6926
|
+
let tr2 = state.tr.insert(side, type.createAndFill());
|
|
6956
6927
|
tr2.setSelection(TextSelection.create(tr2.doc, side + 1));
|
|
6957
6928
|
dispatch(tr2.scrollIntoView());
|
|
6958
6929
|
}
|
|
6959
6930
|
return true;
|
|
6960
6931
|
};
|
|
6961
|
-
var liftEmptyBlock = (
|
|
6962
|
-
let { $cursor } =
|
|
6932
|
+
var liftEmptyBlock = (state, dispatch) => {
|
|
6933
|
+
let { $cursor } = state.selection;
|
|
6963
6934
|
if (!$cursor || $cursor.parent.content.size)
|
|
6964
6935
|
return false;
|
|
6965
6936
|
if ($cursor.depth > 1 && $cursor.after() != $cursor.end(-1)) {
|
|
6966
6937
|
let before = $cursor.before();
|
|
6967
|
-
if (canSplit(
|
|
6938
|
+
if (canSplit(state.doc, before)) {
|
|
6968
6939
|
if (dispatch)
|
|
6969
|
-
dispatch(
|
|
6940
|
+
dispatch(state.tr.split(before).scrollIntoView());
|
|
6970
6941
|
return true;
|
|
6971
6942
|
}
|
|
6972
6943
|
}
|
|
@@ -6974,17 +6945,17 @@ var liftEmptyBlock = (state3, dispatch) => {
|
|
|
6974
6945
|
if (target == null)
|
|
6975
6946
|
return false;
|
|
6976
6947
|
if (dispatch)
|
|
6977
|
-
dispatch(
|
|
6948
|
+
dispatch(state.tr.lift(range, target).scrollIntoView());
|
|
6978
6949
|
return true;
|
|
6979
6950
|
};
|
|
6980
6951
|
function splitBlockAs(splitNode) {
|
|
6981
|
-
return (
|
|
6982
|
-
let { $from, $to } =
|
|
6983
|
-
if (
|
|
6984
|
-
if (!$from.parentOffset || !canSplit(
|
|
6952
|
+
return (state, dispatch) => {
|
|
6953
|
+
let { $from, $to } = state.selection;
|
|
6954
|
+
if (state.selection instanceof NodeSelection && state.selection.node.isBlock) {
|
|
6955
|
+
if (!$from.parentOffset || !canSplit(state.doc, $from.pos))
|
|
6985
6956
|
return false;
|
|
6986
6957
|
if (dispatch)
|
|
6987
|
-
dispatch(
|
|
6958
|
+
dispatch(state.tr.split($from.pos).scrollIntoView());
|
|
6988
6959
|
return true;
|
|
6989
6960
|
}
|
|
6990
6961
|
if (!$from.depth)
|
|
@@ -7007,8 +6978,8 @@ function splitBlockAs(splitNode) {
|
|
|
7007
6978
|
types.unshift(null);
|
|
7008
6979
|
}
|
|
7009
6980
|
}
|
|
7010
|
-
let tr2 =
|
|
7011
|
-
if (
|
|
6981
|
+
let tr2 = state.tr;
|
|
6982
|
+
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection)
|
|
7012
6983
|
tr2.deleteSelection();
|
|
7013
6984
|
let splitPos = tr2.mapping.map($from.pos);
|
|
7014
6985
|
let can = canSplit(tr2.doc, splitPos, types.length, types);
|
|
@@ -7030,40 +7001,40 @@ function splitBlockAs(splitNode) {
|
|
|
7030
7001
|
};
|
|
7031
7002
|
}
|
|
7032
7003
|
var splitBlock = splitBlockAs();
|
|
7033
|
-
var selectParentNode = (
|
|
7034
|
-
let { $from, to } =
|
|
7004
|
+
var selectParentNode = (state, dispatch) => {
|
|
7005
|
+
let { $from, to } = state.selection, pos;
|
|
7035
7006
|
let same = $from.sharedDepth(to);
|
|
7036
7007
|
if (same == 0)
|
|
7037
7008
|
return false;
|
|
7038
7009
|
pos = $from.before(same);
|
|
7039
7010
|
if (dispatch)
|
|
7040
|
-
dispatch(
|
|
7011
|
+
dispatch(state.tr.setSelection(NodeSelection.create(state.doc, pos)));
|
|
7041
7012
|
return true;
|
|
7042
7013
|
};
|
|
7043
|
-
var selectAll = (
|
|
7014
|
+
var selectAll = (state, dispatch) => {
|
|
7044
7015
|
if (dispatch)
|
|
7045
|
-
dispatch(
|
|
7016
|
+
dispatch(state.tr.setSelection(new AllSelection(state.doc)));
|
|
7046
7017
|
return true;
|
|
7047
7018
|
};
|
|
7048
|
-
function joinMaybeClear(
|
|
7019
|
+
function joinMaybeClear(state, $pos, dispatch) {
|
|
7049
7020
|
let before = $pos.nodeBefore, after = $pos.nodeAfter, index = $pos.index();
|
|
7050
7021
|
if (!before || !after || !before.type.compatibleContent(after.type))
|
|
7051
7022
|
return false;
|
|
7052
7023
|
if (!before.content.size && $pos.parent.canReplace(index - 1, index)) {
|
|
7053
7024
|
if (dispatch)
|
|
7054
|
-
dispatch(
|
|
7025
|
+
dispatch(state.tr.delete($pos.pos - before.nodeSize, $pos.pos).scrollIntoView());
|
|
7055
7026
|
return true;
|
|
7056
7027
|
}
|
|
7057
|
-
if (!$pos.parent.canReplace(index, index + 1) || !(after.isTextblock || canJoin(
|
|
7028
|
+
if (!$pos.parent.canReplace(index, index + 1) || !(after.isTextblock || canJoin(state.doc, $pos.pos)))
|
|
7058
7029
|
return false;
|
|
7059
7030
|
if (dispatch)
|
|
7060
|
-
dispatch(
|
|
7031
|
+
dispatch(state.tr.join($pos.pos).scrollIntoView());
|
|
7061
7032
|
return true;
|
|
7062
7033
|
}
|
|
7063
|
-
function deleteBarrier(
|
|
7034
|
+
function deleteBarrier(state, $cut, dispatch, dir) {
|
|
7064
7035
|
let before = $cut.nodeBefore, after = $cut.nodeAfter, conn, match;
|
|
7065
7036
|
let isolated = before.type.spec.isolating || after.type.spec.isolating;
|
|
7066
|
-
if (!isolated && joinMaybeClear(
|
|
7037
|
+
if (!isolated && joinMaybeClear(state, $cut, dispatch))
|
|
7067
7038
|
return true;
|
|
7068
7039
|
let canDelAfter = !isolated && $cut.parent.canReplace($cut.index(), $cut.index() + 1);
|
|
7069
7040
|
if (canDelAfter && (conn = (match = before.contentMatchAt(before.childCount)).findWrapping(after.type)) && match.matchType(conn[0] || after.type).validEnd) {
|
|
@@ -7072,7 +7043,7 @@ function deleteBarrier(state3, $cut, dispatch, dir) {
|
|
|
7072
7043
|
for (let i = conn.length - 1; i >= 0; i--)
|
|
7073
7044
|
wrap2 = Fragment2.from(conn[i].create(null, wrap2));
|
|
7074
7045
|
wrap2 = Fragment2.from(before.copy(wrap2));
|
|
7075
|
-
let tr2 =
|
|
7046
|
+
let tr2 = state.tr.step(new ReplaceAroundStep($cut.pos - 1, end, $cut.pos, end, new Slice(wrap2, 1, 0), conn.length, true));
|
|
7076
7047
|
let $joinAt = tr2.doc.resolve(end + 2 * conn.length);
|
|
7077
7048
|
if ($joinAt.nodeAfter && $joinAt.nodeAfter.type == before.type && canJoin(tr2.doc, $joinAt.pos))
|
|
7078
7049
|
tr2.join($joinAt.pos);
|
|
@@ -7084,7 +7055,7 @@ function deleteBarrier(state3, $cut, dispatch, dir) {
|
|
|
7084
7055
|
let range = selAfter && selAfter.$from.blockRange(selAfter.$to), target = range && liftTarget(range);
|
|
7085
7056
|
if (target != null && target >= $cut.depth) {
|
|
7086
7057
|
if (dispatch)
|
|
7087
|
-
dispatch(
|
|
7058
|
+
dispatch(state.tr.lift(range, target).scrollIntoView());
|
|
7088
7059
|
return true;
|
|
7089
7060
|
}
|
|
7090
7061
|
if (canDelAfter && textblockAt(after, "start", true) && textblockAt(before, "end")) {
|
|
@@ -7103,7 +7074,7 @@ function deleteBarrier(state3, $cut, dispatch, dir) {
|
|
|
7103
7074
|
let end = Fragment2.empty;
|
|
7104
7075
|
for (let i = wrap2.length - 1; i >= 0; i--)
|
|
7105
7076
|
end = Fragment2.from(wrap2[i].copy(end));
|
|
7106
|
-
let tr2 =
|
|
7077
|
+
let tr2 = state.tr.step(new ReplaceAroundStep($cut.pos - wrap2.length, $cut.pos + after.nodeSize, $cut.pos + afterDepth, $cut.pos + after.nodeSize - afterDepth, new Slice(end, wrap2.length, 0), 0, true));
|
|
7107
7078
|
dispatch(tr2.scrollIntoView());
|
|
7108
7079
|
}
|
|
7109
7080
|
return true;
|
|
@@ -7112,8 +7083,8 @@ function deleteBarrier(state3, $cut, dispatch, dir) {
|
|
|
7112
7083
|
return false;
|
|
7113
7084
|
}
|
|
7114
7085
|
function selectTextblockSide(side) {
|
|
7115
|
-
return function(
|
|
7116
|
-
let sel =
|
|
7086
|
+
return function(state, dispatch) {
|
|
7087
|
+
let sel = state.selection, $pos = side < 0 ? sel.$from : sel.$to;
|
|
7117
7088
|
let depth = $pos.depth;
|
|
7118
7089
|
while ($pos.node(depth).isInline) {
|
|
7119
7090
|
if (!depth)
|
|
@@ -7123,29 +7094,29 @@ function selectTextblockSide(side) {
|
|
|
7123
7094
|
if (!$pos.node(depth).isTextblock)
|
|
7124
7095
|
return false;
|
|
7125
7096
|
if (dispatch)
|
|
7126
|
-
dispatch(
|
|
7097
|
+
dispatch(state.tr.setSelection(TextSelection.create(state.doc, side < 0 ? $pos.start(depth) : $pos.end(depth))));
|
|
7127
7098
|
return true;
|
|
7128
7099
|
};
|
|
7129
7100
|
}
|
|
7130
7101
|
var selectTextblockStart = selectTextblockSide(-1);
|
|
7131
7102
|
var selectTextblockEnd = selectTextblockSide(1);
|
|
7132
7103
|
function wrapIn(nodeType, attrs = null) {
|
|
7133
|
-
return function(
|
|
7134
|
-
let { $from, $to } =
|
|
7104
|
+
return function(state, dispatch) {
|
|
7105
|
+
let { $from, $to } = state.selection;
|
|
7135
7106
|
let range = $from.blockRange($to), wrapping = range && findWrapping(range, nodeType, attrs);
|
|
7136
7107
|
if (!wrapping)
|
|
7137
7108
|
return false;
|
|
7138
7109
|
if (dispatch)
|
|
7139
|
-
dispatch(
|
|
7110
|
+
dispatch(state.tr.wrap(range, wrapping).scrollIntoView());
|
|
7140
7111
|
return true;
|
|
7141
7112
|
};
|
|
7142
7113
|
}
|
|
7143
7114
|
function setBlockType2(nodeType, attrs = null) {
|
|
7144
|
-
return function(
|
|
7115
|
+
return function(state, dispatch) {
|
|
7145
7116
|
let applicable = false;
|
|
7146
|
-
for (let i = 0; i <
|
|
7147
|
-
let { $from: { pos: from2 }, $to: { pos: to } } =
|
|
7148
|
-
|
|
7117
|
+
for (let i = 0; i < state.selection.ranges.length && !applicable; i++) {
|
|
7118
|
+
let { $from: { pos: from2 }, $to: { pos: to } } = state.selection.ranges[i];
|
|
7119
|
+
state.doc.nodesBetween(from2, to, (node, pos) => {
|
|
7149
7120
|
if (applicable)
|
|
7150
7121
|
return false;
|
|
7151
7122
|
if (!node.isTextblock || node.hasMarkup(nodeType, attrs))
|
|
@@ -7153,7 +7124,7 @@ function setBlockType2(nodeType, attrs = null) {
|
|
|
7153
7124
|
if (node.type == nodeType) {
|
|
7154
7125
|
applicable = true;
|
|
7155
7126
|
} else {
|
|
7156
|
-
let $pos =
|
|
7127
|
+
let $pos = state.doc.resolve(pos), index = $pos.index();
|
|
7157
7128
|
applicable = $pos.parent.canReplaceWith(index, index + 1, nodeType);
|
|
7158
7129
|
}
|
|
7159
7130
|
});
|
|
@@ -7161,9 +7132,9 @@ function setBlockType2(nodeType, attrs = null) {
|
|
|
7161
7132
|
if (!applicable)
|
|
7162
7133
|
return false;
|
|
7163
7134
|
if (dispatch) {
|
|
7164
|
-
let tr2 =
|
|
7165
|
-
for (let i = 0; i <
|
|
7166
|
-
let { $from: { pos: from2 }, $to: { pos: to } } =
|
|
7135
|
+
let tr2 = state.tr;
|
|
7136
|
+
for (let i = 0; i < state.selection.ranges.length; i++) {
|
|
7137
|
+
let { $from: { pos: from2 }, $to: { pos: to } } = state.selection.ranges[i];
|
|
7167
7138
|
tr2.setBlockType(from2, to, nodeType, attrs);
|
|
7168
7139
|
}
|
|
7169
7140
|
dispatch(tr2.scrollIntoView());
|
|
@@ -7172,9 +7143,9 @@ function setBlockType2(nodeType, attrs = null) {
|
|
|
7172
7143
|
};
|
|
7173
7144
|
}
|
|
7174
7145
|
function chainCommands(...commands) {
|
|
7175
|
-
return function(
|
|
7146
|
+
return function(state, dispatch, view) {
|
|
7176
7147
|
for (let i = 0; i < commands.length; i++)
|
|
7177
|
-
if (commands[i](
|
|
7148
|
+
if (commands[i](state, dispatch, view))
|
|
7178
7149
|
return true;
|
|
7179
7150
|
return false;
|
|
7180
7151
|
};
|
|
@@ -7207,12 +7178,12 @@ var mac = typeof navigator != "undefined" ? /Mac|iP(hone|[oa]d)/.test(navigator.
|
|
|
7207
7178
|
|
|
7208
7179
|
// ../../node_modules/.pnpm/prosemirror-schema-list@1.5.1/node_modules/prosemirror-schema-list/dist/index.js
|
|
7209
7180
|
function wrapInList(listType, attrs = null) {
|
|
7210
|
-
return function(
|
|
7211
|
-
let { $from, $to } =
|
|
7181
|
+
return function(state, dispatch) {
|
|
7182
|
+
let { $from, $to } = state.selection;
|
|
7212
7183
|
let range = $from.blockRange($to);
|
|
7213
7184
|
if (!range)
|
|
7214
7185
|
return false;
|
|
7215
|
-
let tr2 = dispatch ?
|
|
7186
|
+
let tr2 = dispatch ? state.tr : null;
|
|
7216
7187
|
if (!wrapRangeInList(tr2, range, listType, attrs))
|
|
7217
7188
|
return false;
|
|
7218
7189
|
if (dispatch)
|
|
@@ -7259,21 +7230,21 @@ function doWrapInList(tr2, range, wrappers, joinBefore, listType) {
|
|
|
7259
7230
|
return tr2;
|
|
7260
7231
|
}
|
|
7261
7232
|
function liftListItem(itemType) {
|
|
7262
|
-
return function(
|
|
7263
|
-
let { $from, $to } =
|
|
7233
|
+
return function(state, dispatch) {
|
|
7234
|
+
let { $from, $to } = state.selection;
|
|
7264
7235
|
let range = $from.blockRange($to, (node) => node.childCount > 0 && node.firstChild.type == itemType);
|
|
7265
7236
|
if (!range)
|
|
7266
7237
|
return false;
|
|
7267
7238
|
if (!dispatch)
|
|
7268
7239
|
return true;
|
|
7269
7240
|
if ($from.node(range.depth - 1).type == itemType)
|
|
7270
|
-
return liftToOuterList(
|
|
7241
|
+
return liftToOuterList(state, dispatch, itemType, range);
|
|
7271
7242
|
else
|
|
7272
|
-
return liftOutOfList(
|
|
7243
|
+
return liftOutOfList(state, dispatch, range);
|
|
7273
7244
|
};
|
|
7274
7245
|
}
|
|
7275
|
-
function liftToOuterList(
|
|
7276
|
-
let tr2 =
|
|
7246
|
+
function liftToOuterList(state, dispatch, itemType, range) {
|
|
7247
|
+
let tr2 = state.tr, end = range.end, endOfList = range.$to.end(range.depth);
|
|
7277
7248
|
if (end < endOfList) {
|
|
7278
7249
|
tr2.step(new ReplaceAroundStep(end - 1, endOfList, end, endOfList, new Slice(Fragment2.from(itemType.create(null, range.parent.copy())), 1, 0), 1, true));
|
|
7279
7250
|
range = new NodeRange(tr2.doc.resolve(range.$from.pos), tr2.doc.resolve(endOfList), range.depth);
|
|
@@ -7288,8 +7259,8 @@ function liftToOuterList(state3, dispatch, itemType, range) {
|
|
|
7288
7259
|
dispatch(tr2.scrollIntoView());
|
|
7289
7260
|
return true;
|
|
7290
7261
|
}
|
|
7291
|
-
function liftOutOfList(
|
|
7292
|
-
let tr2 =
|
|
7262
|
+
function liftOutOfList(state, dispatch, range) {
|
|
7263
|
+
let tr2 = state.tr, list = range.parent;
|
|
7293
7264
|
for (let pos = range.end, i = range.endIndex - 1, e = range.startIndex; i > e; i--) {
|
|
7294
7265
|
pos -= list.child(i).nodeSize;
|
|
7295
7266
|
tr2.delete(pos - 1, pos + 1);
|
|
@@ -7307,8 +7278,8 @@ function liftOutOfList(state3, dispatch, range) {
|
|
|
7307
7278
|
return true;
|
|
7308
7279
|
}
|
|
7309
7280
|
function sinkListItem(itemType) {
|
|
7310
|
-
return function(
|
|
7311
|
-
let { $from, $to } =
|
|
7281
|
+
return function(state, dispatch) {
|
|
7282
|
+
let { $from, $to } = state.selection;
|
|
7312
7283
|
let range = $from.blockRange($to, (node) => node.childCount > 0 && node.firstChild.type == itemType);
|
|
7313
7284
|
if (!range)
|
|
7314
7285
|
return false;
|
|
@@ -7323,7 +7294,7 @@ function sinkListItem(itemType) {
|
|
|
7323
7294
|
let inner = Fragment2.from(nestedBefore ? itemType.create() : null);
|
|
7324
7295
|
let slice2 = new Slice(Fragment2.from(itemType.create(null, Fragment2.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
|
|
7325
7296
|
let before = range.start, after = range.end;
|
|
7326
|
-
dispatch(
|
|
7297
|
+
dispatch(state.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice2, 1, true)).scrollIntoView());
|
|
7327
7298
|
}
|
|
7328
7299
|
return true;
|
|
7329
7300
|
};
|
|
@@ -7872,25 +7843,25 @@ function flattenH(rect, top) {
|
|
|
7872
7843
|
let y = top ? rect.top : rect.bottom;
|
|
7873
7844
|
return { top: y, bottom: y, left: rect.left, right: rect.right };
|
|
7874
7845
|
}
|
|
7875
|
-
function withFlushedState(view,
|
|
7846
|
+
function withFlushedState(view, state, f) {
|
|
7876
7847
|
let viewState = view.state, active = view.root.activeElement;
|
|
7877
|
-
if (viewState !=
|
|
7878
|
-
view.updateState(
|
|
7848
|
+
if (viewState != state)
|
|
7849
|
+
view.updateState(state);
|
|
7879
7850
|
if (active != view.dom)
|
|
7880
7851
|
view.focus();
|
|
7881
7852
|
try {
|
|
7882
7853
|
return f();
|
|
7883
7854
|
} finally {
|
|
7884
|
-
if (viewState !=
|
|
7855
|
+
if (viewState != state)
|
|
7885
7856
|
view.updateState(viewState);
|
|
7886
7857
|
if (active != view.dom && active)
|
|
7887
7858
|
active.focus();
|
|
7888
7859
|
}
|
|
7889
7860
|
}
|
|
7890
|
-
function endOfTextblockVertical(view,
|
|
7891
|
-
let sel =
|
|
7861
|
+
function endOfTextblockVertical(view, state, dir) {
|
|
7862
|
+
let sel = state.selection;
|
|
7892
7863
|
let $pos = dir == "up" ? sel.$from : sel.$to;
|
|
7893
|
-
return withFlushedState(view,
|
|
7864
|
+
return withFlushedState(view, state, () => {
|
|
7894
7865
|
let { node: dom } = view.docView.domFromPos($pos.pos, dir == "up" ? -1 : 1);
|
|
7895
7866
|
for (; ; ) {
|
|
7896
7867
|
let nearest = view.docView.nearestDesc(dom, true);
|
|
@@ -7921,8 +7892,8 @@ function endOfTextblockVertical(view, state3, dir) {
|
|
|
7921
7892
|
});
|
|
7922
7893
|
}
|
|
7923
7894
|
var maybeRTL = /[\u0590-\u08ac]/;
|
|
7924
|
-
function endOfTextblockHorizontal(view,
|
|
7925
|
-
let { $head } =
|
|
7895
|
+
function endOfTextblockHorizontal(view, state, dir) {
|
|
7896
|
+
let { $head } = state.selection;
|
|
7926
7897
|
if (!$head.parent.isTextblock)
|
|
7927
7898
|
return false;
|
|
7928
7899
|
let offset = $head.parentOffset, atStart = !offset, atEnd = offset == $head.parent.content.size;
|
|
@@ -7931,7 +7902,7 @@ function endOfTextblockHorizontal(view, state3, dir) {
|
|
|
7931
7902
|
return $head.pos == $head.start() || $head.pos == $head.end();
|
|
7932
7903
|
if (!maybeRTL.test($head.parent.textContent) || !sel.modify)
|
|
7933
7904
|
return dir == "left" || dir == "backward" ? atStart : atEnd;
|
|
7934
|
-
return withFlushedState(view,
|
|
7905
|
+
return withFlushedState(view, state, () => {
|
|
7935
7906
|
let { focusNode: oldNode, focusOffset: oldOff, anchorNode, anchorOffset } = view.domSelectionRange();
|
|
7936
7907
|
let oldBidiLevel = sel.caretBidiLevel;
|
|
7937
7908
|
sel.modify("move", dir, "character");
|
|
@@ -7952,12 +7923,12 @@ function endOfTextblockHorizontal(view, state3, dir) {
|
|
|
7952
7923
|
var cachedState = null;
|
|
7953
7924
|
var cachedDir = null;
|
|
7954
7925
|
var cachedResult = false;
|
|
7955
|
-
function endOfTextblock(view,
|
|
7956
|
-
if (cachedState ==
|
|
7926
|
+
function endOfTextblock(view, state, dir) {
|
|
7927
|
+
if (cachedState == state && cachedDir == dir)
|
|
7957
7928
|
return cachedResult;
|
|
7958
|
-
cachedState =
|
|
7929
|
+
cachedState = state;
|
|
7959
7930
|
cachedDir = dir;
|
|
7960
|
-
return cachedResult = dir == "up" || dir == "down" ? endOfTextblockVertical(view,
|
|
7931
|
+
return cachedResult = dir == "up" || dir == "down" ? endOfTextblockVertical(view, state, dir) : endOfTextblockHorizontal(view, state, dir);
|
|
7961
7932
|
}
|
|
7962
7933
|
var NOT_DIRTY = 0;
|
|
7963
7934
|
var CHILD_DIRTY = 1;
|
|
@@ -9490,10 +9461,10 @@ function anchorInRightPlace(view) {
|
|
|
9490
9461
|
let domSel = view.domSelectionRange();
|
|
9491
9462
|
return isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset);
|
|
9492
9463
|
}
|
|
9493
|
-
function moveSelectionBlock(
|
|
9494
|
-
let { $anchor, $head } =
|
|
9464
|
+
function moveSelectionBlock(state, dir) {
|
|
9465
|
+
let { $anchor, $head } = state.selection;
|
|
9495
9466
|
let $side = dir > 0 ? $anchor.max($head) : $anchor.min($head);
|
|
9496
|
-
let $start = !$side.parent.inlineContent ? $side : $side.depth ?
|
|
9467
|
+
let $start = !$side.parent.inlineContent ? $side : $side.depth ? state.doc.resolve(dir > 0 ? $side.after() : $side.before()) : null;
|
|
9497
9468
|
return $start && Selection.findFrom($start, dir);
|
|
9498
9469
|
}
|
|
9499
9470
|
function apply(view, sel) {
|
|
@@ -9697,9 +9668,9 @@ function setSelFocus(view, node, offset) {
|
|
|
9697
9668
|
sel.extend(node, offset);
|
|
9698
9669
|
}
|
|
9699
9670
|
view.domObserver.setCurSelection();
|
|
9700
|
-
let { state
|
|
9671
|
+
let { state } = view;
|
|
9701
9672
|
setTimeout(() => {
|
|
9702
|
-
if (view.state ==
|
|
9673
|
+
if (view.state == state)
|
|
9703
9674
|
selectionToDOM(view);
|
|
9704
9675
|
}, 50);
|
|
9705
9676
|
}
|
|
@@ -9764,9 +9735,9 @@ function stopNativeHorizontalDelete(view, dir) {
|
|
|
9764
9735
|
}
|
|
9765
9736
|
return false;
|
|
9766
9737
|
}
|
|
9767
|
-
function switchEditable(view, node,
|
|
9738
|
+
function switchEditable(view, node, state) {
|
|
9768
9739
|
view.domObserver.stop();
|
|
9769
|
-
node.contentEditable =
|
|
9740
|
+
node.contentEditable = state;
|
|
9770
9741
|
view.domObserver.start();
|
|
9771
9742
|
}
|
|
9772
9743
|
function safariDownArrowBug(view) {
|
|
@@ -10432,14 +10403,14 @@ var timeoutComposition = android ? 5e3 : -1;
|
|
|
10432
10403
|
editHandlers.compositionstart = editHandlers.compositionupdate = (view) => {
|
|
10433
10404
|
if (!view.composing) {
|
|
10434
10405
|
view.domObserver.flush();
|
|
10435
|
-
let { state
|
|
10436
|
-
if (
|
|
10406
|
+
let { state } = view, $pos = state.selection.$to;
|
|
10407
|
+
if (state.selection instanceof TextSelection && (state.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some((m) => m.type.spec.inclusive === false) || chrome && windows && selectionBeforeUneditable(view))) {
|
|
10437
10408
|
view.markCursor = view.state.storedMarks || $pos.marks();
|
|
10438
10409
|
endComposition(view, true);
|
|
10439
10410
|
view.markCursor = null;
|
|
10440
10411
|
} else {
|
|
10441
|
-
endComposition(view, !
|
|
10442
|
-
if (gecko &&
|
|
10412
|
+
endComposition(view, !state.selection.empty);
|
|
10413
|
+
if (gecko && state.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length) {
|
|
10443
10414
|
let sel = view.domSelectionRange();
|
|
10444
10415
|
for (let node = sel.focusNode, offset = sel.focusOffset; node && node.nodeType == 1 && offset != 0; ) {
|
|
10445
10416
|
let before = offset < 0 ? node.lastChild : node.childNodes[offset - 1];
|
|
@@ -12142,18 +12113,18 @@ var EditorView = class {
|
|
|
12142
12113
|
Update the editor's `state` prop, without touching any of the
|
|
12143
12114
|
other props.
|
|
12144
12115
|
*/
|
|
12145
|
-
updateState(
|
|
12146
|
-
this.updateStateInner(
|
|
12116
|
+
updateState(state) {
|
|
12117
|
+
this.updateStateInner(state, this._props);
|
|
12147
12118
|
}
|
|
12148
|
-
updateStateInner(
|
|
12119
|
+
updateStateInner(state, prevProps) {
|
|
12149
12120
|
var _a;
|
|
12150
12121
|
let prev = this.state, redraw = false, updateSel = false;
|
|
12151
|
-
if (
|
|
12122
|
+
if (state.storedMarks && this.composing) {
|
|
12152
12123
|
clearComposition(this);
|
|
12153
12124
|
updateSel = true;
|
|
12154
12125
|
}
|
|
12155
|
-
this.state =
|
|
12156
|
-
let pluginsChanged = prev.plugins !=
|
|
12126
|
+
this.state = state;
|
|
12127
|
+
let pluginsChanged = prev.plugins != state.plugins || this._props.plugins != prevProps.plugins;
|
|
12157
12128
|
if (pluginsChanged || this._props.plugins != prevProps.plugins || this._props.nodeViews != prevProps.nodeViews) {
|
|
12158
12129
|
let nodeViews = buildNodeViews(this);
|
|
12159
12130
|
if (changedNodeViews(nodeViews, this.nodeViews)) {
|
|
@@ -12167,22 +12138,22 @@ var EditorView = class {
|
|
|
12167
12138
|
this.editable = getEditable(this);
|
|
12168
12139
|
updateCursorWrapper(this);
|
|
12169
12140
|
let innerDeco = viewDecorations(this), outerDeco = computeDocDeco(this);
|
|
12170
|
-
let scroll = prev.plugins !=
|
|
12171
|
-
let updateDoc = redraw || !this.docView.matchesNode(
|
|
12172
|
-
if (updateDoc || !
|
|
12141
|
+
let scroll = prev.plugins != state.plugins && !prev.doc.eq(state.doc) ? "reset" : state.scrollToSelection > prev.scrollToSelection ? "to selection" : "preserve";
|
|
12142
|
+
let updateDoc = redraw || !this.docView.matchesNode(state.doc, outerDeco, innerDeco);
|
|
12143
|
+
if (updateDoc || !state.selection.eq(prev.selection))
|
|
12173
12144
|
updateSel = true;
|
|
12174
12145
|
let oldScrollPos = scroll == "preserve" && updateSel && this.dom.style.overflowAnchor == null && storeScrollPos(this);
|
|
12175
12146
|
if (updateSel) {
|
|
12176
12147
|
this.domObserver.stop();
|
|
12177
|
-
let forceSelUpdate = updateDoc && (ie || chrome) && !this.composing && !prev.selection.empty && !
|
|
12148
|
+
let forceSelUpdate = updateDoc && (ie || chrome) && !this.composing && !prev.selection.empty && !state.selection.empty && selectionContextChanged(prev.selection, state.selection);
|
|
12178
12149
|
if (updateDoc) {
|
|
12179
12150
|
let chromeKludge = chrome ? this.trackWrites = this.domSelectionRange().focusNode : null;
|
|
12180
12151
|
if (this.composing)
|
|
12181
12152
|
this.input.compositionNode = findCompositionNode(this);
|
|
12182
|
-
if (redraw || !this.docView.update(
|
|
12153
|
+
if (redraw || !this.docView.update(state.doc, outerDeco, innerDeco, this)) {
|
|
12183
12154
|
this.docView.updateOuterDeco(outerDeco);
|
|
12184
12155
|
this.docView.destroy();
|
|
12185
|
-
this.docView = docViewDesc(
|
|
12156
|
+
this.docView = docViewDesc(state.doc, outerDeco, innerDeco, this.dom, this);
|
|
12186
12157
|
}
|
|
12187
12158
|
if (chromeKludge && (!this.trackWrites || !this.dom.contains(this.trackWrites)))
|
|
12188
12159
|
forceSelUpdate = true;
|
|
@@ -12190,13 +12161,13 @@ var EditorView = class {
|
|
|
12190
12161
|
if (forceSelUpdate || !(this.input.mouseDown && this.domObserver.currentSelection.eq(this.domSelectionRange()) && anchorInRightPlace(this))) {
|
|
12191
12162
|
selectionToDOM(this, forceSelUpdate);
|
|
12192
12163
|
} else {
|
|
12193
|
-
syncNodeSelection(this,
|
|
12164
|
+
syncNodeSelection(this, state.selection);
|
|
12194
12165
|
this.domObserver.setCurSelection();
|
|
12195
12166
|
}
|
|
12196
12167
|
this.domObserver.start();
|
|
12197
12168
|
}
|
|
12198
12169
|
this.updatePluginViews(prev);
|
|
12199
|
-
if (((_a = this.dragging) === null || _a === void 0 ? void 0 : _a.node) && !prev.doc.eq(
|
|
12170
|
+
if (((_a = this.dragging) === null || _a === void 0 ? void 0 : _a.node) && !prev.doc.eq(state.doc))
|
|
12200
12171
|
this.updateDraggedNode(this.dragging, prev);
|
|
12201
12172
|
if (scroll == "reset") {
|
|
12202
12173
|
this.dom.scrollTop = 0;
|
|
@@ -12406,8 +12377,8 @@ var EditorView = class {
|
|
|
12406
12377
|
to the view's current state by default, but it is possible to
|
|
12407
12378
|
pass a different state.
|
|
12408
12379
|
*/
|
|
12409
|
-
endOfTextblock(dir,
|
|
12410
|
-
return endOfTextblock(this,
|
|
12380
|
+
endOfTextblock(dir, state) {
|
|
12381
|
+
return endOfTextblock(this, state || this.state, dir);
|
|
12411
12382
|
}
|
|
12412
12383
|
/**
|
|
12413
12384
|
Run the editor's paste logic with the given HTML string. The
|
|
@@ -12748,18 +12719,18 @@ var __export = (target, all) => {
|
|
|
12748
12719
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12749
12720
|
};
|
|
12750
12721
|
function createChainableState(config) {
|
|
12751
|
-
const { state
|
|
12722
|
+
const { state, transaction } = config;
|
|
12752
12723
|
let { selection } = transaction;
|
|
12753
12724
|
let { doc: doc3 } = transaction;
|
|
12754
12725
|
let { storedMarks } = transaction;
|
|
12755
12726
|
return {
|
|
12756
|
-
...
|
|
12757
|
-
apply:
|
|
12758
|
-
applyTransaction:
|
|
12759
|
-
plugins:
|
|
12760
|
-
schema:
|
|
12761
|
-
reconfigure:
|
|
12762
|
-
toJSON:
|
|
12727
|
+
...state,
|
|
12728
|
+
apply: state.apply.bind(state),
|
|
12729
|
+
applyTransaction: state.applyTransaction.bind(state),
|
|
12730
|
+
plugins: state.plugins,
|
|
12731
|
+
schema: state.schema,
|
|
12732
|
+
reconfigure: state.reconfigure.bind(state),
|
|
12733
|
+
toJSON: state.toJSON.bind(state),
|
|
12763
12734
|
get storedMarks() {
|
|
12764
12735
|
return storedMarks;
|
|
12765
12736
|
},
|
|
@@ -12790,9 +12761,9 @@ var CommandManager = class {
|
|
|
12790
12761
|
return this.customState || this.editor.state;
|
|
12791
12762
|
}
|
|
12792
12763
|
get commands() {
|
|
12793
|
-
const { rawCommands, editor, state
|
|
12764
|
+
const { rawCommands, editor, state } = this;
|
|
12794
12765
|
const { view } = editor;
|
|
12795
|
-
const { tr: tr2 } =
|
|
12766
|
+
const { tr: tr2 } = state;
|
|
12796
12767
|
const props = this.buildProps(tr2);
|
|
12797
12768
|
return Object.fromEntries(
|
|
12798
12769
|
Object.entries(rawCommands).map(([name, command2]) => {
|
|
@@ -12814,11 +12785,11 @@ var CommandManager = class {
|
|
|
12814
12785
|
return () => this.createCan();
|
|
12815
12786
|
}
|
|
12816
12787
|
createChain(startTr, shouldDispatch = true) {
|
|
12817
|
-
const { rawCommands, editor, state
|
|
12788
|
+
const { rawCommands, editor, state } = this;
|
|
12818
12789
|
const { view } = editor;
|
|
12819
12790
|
const callbacks = [];
|
|
12820
12791
|
const hasStartTransaction = !!startTr;
|
|
12821
|
-
const tr2 = startTr ||
|
|
12792
|
+
const tr2 = startTr || state.tr;
|
|
12822
12793
|
const run32 = () => {
|
|
12823
12794
|
if (!hasStartTransaction && shouldDispatch && !tr2.getMeta("preventDispatch") && !this.hasCustomState) {
|
|
12824
12795
|
view.dispatch(tr2);
|
|
@@ -12842,9 +12813,9 @@ var CommandManager = class {
|
|
|
12842
12813
|
return chain;
|
|
12843
12814
|
}
|
|
12844
12815
|
createCan(startTr) {
|
|
12845
|
-
const { rawCommands, state
|
|
12816
|
+
const { rawCommands, state } = this;
|
|
12846
12817
|
const dispatch = false;
|
|
12847
|
-
const tr2 = startTr ||
|
|
12818
|
+
const tr2 = startTr || state.tr;
|
|
12848
12819
|
const props = this.buildProps(tr2, dispatch);
|
|
12849
12820
|
const formattedCommands = Object.fromEntries(
|
|
12850
12821
|
Object.entries(rawCommands).map(([name, command2]) => {
|
|
@@ -12857,14 +12828,14 @@ var CommandManager = class {
|
|
|
12857
12828
|
};
|
|
12858
12829
|
}
|
|
12859
12830
|
buildProps(tr2, shouldDispatch = true) {
|
|
12860
|
-
const { rawCommands, editor, state
|
|
12831
|
+
const { rawCommands, editor, state } = this;
|
|
12861
12832
|
const { view } = editor;
|
|
12862
12833
|
const props = {
|
|
12863
12834
|
tr: tr2,
|
|
12864
12835
|
editor,
|
|
12865
12836
|
view,
|
|
12866
12837
|
state: createChainableState({
|
|
12867
|
-
state
|
|
12838
|
+
state,
|
|
12868
12839
|
transaction: tr2
|
|
12869
12840
|
}),
|
|
12870
12841
|
dispatch: shouldDispatch ? () => void 0 : void 0,
|
|
@@ -12958,14 +12929,14 @@ var blur = () => ({ editor, view }) => {
|
|
|
12958
12929
|
var clearContent = (emitUpdate = true) => ({ commands }) => {
|
|
12959
12930
|
return commands.setContent("", { emitUpdate });
|
|
12960
12931
|
};
|
|
12961
|
-
var clearNodes = () => ({ state
|
|
12932
|
+
var clearNodes = () => ({ state, tr: tr2, dispatch }) => {
|
|
12962
12933
|
const { selection } = tr2;
|
|
12963
12934
|
const { ranges } = selection;
|
|
12964
12935
|
if (!dispatch) {
|
|
12965
12936
|
return true;
|
|
12966
12937
|
}
|
|
12967
12938
|
ranges.forEach(({ $from, $to }) => {
|
|
12968
|
-
|
|
12939
|
+
state.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
|
|
12969
12940
|
if (node.type.isText) {
|
|
12970
12941
|
return;
|
|
12971
12942
|
}
|
|
@@ -12991,12 +12962,12 @@ var clearNodes = () => ({ state: state3, tr: tr2, dispatch }) => {
|
|
|
12991
12962
|
var command = (fn) => (props) => {
|
|
12992
12963
|
return fn(props);
|
|
12993
12964
|
};
|
|
12994
|
-
var createParagraphNear2 = () => ({ state
|
|
12995
|
-
return createParagraphNear(
|
|
12965
|
+
var createParagraphNear2 = () => ({ state, dispatch }) => {
|
|
12966
|
+
return createParagraphNear(state, dispatch);
|
|
12996
12967
|
};
|
|
12997
12968
|
var cut = (originRange, targetPos) => ({ editor, tr: tr2 }) => {
|
|
12998
|
-
const { state
|
|
12999
|
-
const contentSlice =
|
|
12969
|
+
const { state } = editor;
|
|
12970
|
+
const contentSlice = state.doc.slice(originRange.from, originRange.to);
|
|
13000
12971
|
tr2.deleteRange(originRange.from, originRange.to);
|
|
13001
12972
|
const newPos = tr2.mapping.map(targetPos);
|
|
13002
12973
|
tr2.insert(newPos, contentSlice.content);
|
|
@@ -13032,8 +13003,8 @@ function getNodeType(nameOrType, schema) {
|
|
|
13032
13003
|
}
|
|
13033
13004
|
return nameOrType;
|
|
13034
13005
|
}
|
|
13035
|
-
var deleteNode = (typeOrName) => ({ tr: tr2, state
|
|
13036
|
-
const type = getNodeType(typeOrName,
|
|
13006
|
+
var deleteNode = (typeOrName) => ({ tr: tr2, state, dispatch }) => {
|
|
13007
|
+
const type = getNodeType(typeOrName, state.schema);
|
|
13037
13008
|
const $pos = tr2.selection.$anchor;
|
|
13038
13009
|
for (let depth = $pos.depth; depth > 0; depth -= 1) {
|
|
13039
13010
|
const node = $pos.node(depth);
|
|
@@ -13055,14 +13026,14 @@ var deleteRange2 = (range) => ({ tr: tr2, dispatch }) => {
|
|
|
13055
13026
|
}
|
|
13056
13027
|
return true;
|
|
13057
13028
|
};
|
|
13058
|
-
var deleteSelection2 = () => ({ state
|
|
13059
|
-
return deleteSelection(
|
|
13029
|
+
var deleteSelection2 = () => ({ state, dispatch }) => {
|
|
13030
|
+
return deleteSelection(state, dispatch);
|
|
13060
13031
|
};
|
|
13061
13032
|
var enter = () => ({ commands }) => {
|
|
13062
13033
|
return commands.keyboardShortcut("Enter");
|
|
13063
13034
|
};
|
|
13064
|
-
var exitCode2 = () => ({ state
|
|
13065
|
-
return exitCode(
|
|
13035
|
+
var exitCode2 = () => ({ state, dispatch }) => {
|
|
13036
|
+
return exitCode(state, dispatch);
|
|
13066
13037
|
};
|
|
13067
13038
|
function isRegExp(value) {
|
|
13068
13039
|
return Object.prototype.toString.call(value) === "[object RegExp]";
|
|
@@ -13137,8 +13108,8 @@ function getMarkType(nameOrType, schema) {
|
|
|
13137
13108
|
}
|
|
13138
13109
|
return nameOrType;
|
|
13139
13110
|
}
|
|
13140
|
-
var extendMarkRange = (typeOrName, attributes = {}) => ({ tr: tr2, state
|
|
13141
|
-
const type = getMarkType(typeOrName,
|
|
13111
|
+
var extendMarkRange = (typeOrName, attributes = {}) => ({ tr: tr2, state, dispatch }) => {
|
|
13112
|
+
const type = getMarkType(typeOrName, state.schema);
|
|
13142
13113
|
const { doc: doc3, selection } = tr2;
|
|
13143
13114
|
const { $from, from: from2, to } = selection;
|
|
13144
13115
|
if (dispatch) {
|
|
@@ -13468,21 +13439,21 @@ var insertContentAt = (position, value, options) => ({ tr: tr2, dispatch, editor
|
|
|
13468
13439
|
}
|
|
13469
13440
|
return true;
|
|
13470
13441
|
};
|
|
13471
|
-
var joinUp2 = () => ({ state
|
|
13472
|
-
return joinUp(
|
|
13442
|
+
var joinUp2 = () => ({ state, dispatch }) => {
|
|
13443
|
+
return joinUp(state, dispatch);
|
|
13473
13444
|
};
|
|
13474
|
-
var joinDown2 = () => ({ state
|
|
13475
|
-
return joinDown(
|
|
13445
|
+
var joinDown2 = () => ({ state, dispatch }) => {
|
|
13446
|
+
return joinDown(state, dispatch);
|
|
13476
13447
|
};
|
|
13477
|
-
var joinBackward2 = () => ({ state
|
|
13478
|
-
return joinBackward(
|
|
13448
|
+
var joinBackward2 = () => ({ state, dispatch }) => {
|
|
13449
|
+
return joinBackward(state, dispatch);
|
|
13479
13450
|
};
|
|
13480
|
-
var joinForward2 = () => ({ state
|
|
13481
|
-
return joinForward(
|
|
13451
|
+
var joinForward2 = () => ({ state, dispatch }) => {
|
|
13452
|
+
return joinForward(state, dispatch);
|
|
13482
13453
|
};
|
|
13483
|
-
var joinItemBackward = () => ({ state
|
|
13454
|
+
var joinItemBackward = () => ({ state, dispatch, tr: tr2 }) => {
|
|
13484
13455
|
try {
|
|
13485
|
-
const point = joinPoint(
|
|
13456
|
+
const point = joinPoint(state.doc, state.selection.$from.pos, -1);
|
|
13486
13457
|
if (point === null || point === void 0) {
|
|
13487
13458
|
return false;
|
|
13488
13459
|
}
|
|
@@ -13495,9 +13466,9 @@ var joinItemBackward = () => ({ state: state3, dispatch, tr: tr2 }) => {
|
|
|
13495
13466
|
return false;
|
|
13496
13467
|
}
|
|
13497
13468
|
};
|
|
13498
|
-
var joinItemForward = () => ({ state
|
|
13469
|
+
var joinItemForward = () => ({ state, dispatch, tr: tr2 }) => {
|
|
13499
13470
|
try {
|
|
13500
|
-
const point = joinPoint(
|
|
13471
|
+
const point = joinPoint(state.doc, state.selection.$from.pos, 1);
|
|
13501
13472
|
if (point === null || point === void 0) {
|
|
13502
13473
|
return false;
|
|
13503
13474
|
}
|
|
@@ -13510,11 +13481,11 @@ var joinItemForward = () => ({ state: state3, dispatch, tr: tr2 }) => {
|
|
|
13510
13481
|
return false;
|
|
13511
13482
|
}
|
|
13512
13483
|
};
|
|
13513
|
-
var joinTextblockBackward2 = () => ({ state
|
|
13514
|
-
return joinTextblockBackward(
|
|
13484
|
+
var joinTextblockBackward2 = () => ({ state, dispatch }) => {
|
|
13485
|
+
return joinTextblockBackward(state, dispatch);
|
|
13515
13486
|
};
|
|
13516
|
-
var joinTextblockForward2 = () => ({ state
|
|
13517
|
-
return joinTextblockForward(
|
|
13487
|
+
var joinTextblockForward2 = () => ({ state, dispatch }) => {
|
|
13488
|
+
return joinTextblockForward(state, dispatch);
|
|
13518
13489
|
};
|
|
13519
13490
|
function isMacOS() {
|
|
13520
13491
|
return typeof navigator !== "undefined" ? /Mac/.test(navigator.platform) : false;
|
|
@@ -13586,11 +13557,11 @@ var keyboardShortcut = (name) => ({ editor, view, tr: tr2, dispatch }) => {
|
|
|
13586
13557
|
});
|
|
13587
13558
|
return true;
|
|
13588
13559
|
};
|
|
13589
|
-
function isNodeActive(
|
|
13590
|
-
const { from: from2, to, empty: empty2 } =
|
|
13591
|
-
const type = typeOrName ? getNodeType(typeOrName,
|
|
13560
|
+
function isNodeActive(state, typeOrName, attributes = {}) {
|
|
13561
|
+
const { from: from2, to, empty: empty2 } = state.selection;
|
|
13562
|
+
const type = typeOrName ? getNodeType(typeOrName, state.schema) : null;
|
|
13592
13563
|
const nodeRanges = [];
|
|
13593
|
-
|
|
13564
|
+
state.doc.nodesBetween(from2, to, (node, pos) => {
|
|
13594
13565
|
if (node.isText) {
|
|
13595
13566
|
return;
|
|
13596
13567
|
}
|
|
@@ -13615,23 +13586,23 @@ function isNodeActive(state3, typeOrName, attributes = {}) {
|
|
|
13615
13586
|
const range = matchedNodeRanges.reduce((sum, nodeRange) => sum + nodeRange.to - nodeRange.from, 0);
|
|
13616
13587
|
return range >= selectionRange;
|
|
13617
13588
|
}
|
|
13618
|
-
var lift3 = (typeOrName, attributes = {}) => ({ state
|
|
13619
|
-
const type = getNodeType(typeOrName,
|
|
13620
|
-
const isActive2 = isNodeActive(
|
|
13589
|
+
var lift3 = (typeOrName, attributes = {}) => ({ state, dispatch }) => {
|
|
13590
|
+
const type = getNodeType(typeOrName, state.schema);
|
|
13591
|
+
const isActive2 = isNodeActive(state, type, attributes);
|
|
13621
13592
|
if (!isActive2) {
|
|
13622
13593
|
return false;
|
|
13623
13594
|
}
|
|
13624
|
-
return lift2(
|
|
13595
|
+
return lift2(state, dispatch);
|
|
13625
13596
|
};
|
|
13626
|
-
var liftEmptyBlock2 = () => ({ state
|
|
13627
|
-
return liftEmptyBlock(
|
|
13597
|
+
var liftEmptyBlock2 = () => ({ state, dispatch }) => {
|
|
13598
|
+
return liftEmptyBlock(state, dispatch);
|
|
13628
13599
|
};
|
|
13629
|
-
var liftListItem2 = (typeOrName) => ({ state
|
|
13630
|
-
const type = getNodeType(typeOrName,
|
|
13631
|
-
return liftListItem(type)(
|
|
13600
|
+
var liftListItem2 = (typeOrName) => ({ state, dispatch }) => {
|
|
13601
|
+
const type = getNodeType(typeOrName, state.schema);
|
|
13602
|
+
return liftListItem(type)(state, dispatch);
|
|
13632
13603
|
};
|
|
13633
|
-
var newlineInCode2 = () => ({ state
|
|
13634
|
-
return newlineInCode(
|
|
13604
|
+
var newlineInCode2 = () => ({ state, dispatch }) => {
|
|
13605
|
+
return newlineInCode(state, dispatch);
|
|
13635
13606
|
};
|
|
13636
13607
|
function getSchemaTypeNameByName(name, schema) {
|
|
13637
13608
|
if (schema.nodes[name]) {
|
|
@@ -13651,25 +13622,25 @@ function deleteProps(obj, propOrProps) {
|
|
|
13651
13622
|
return newObj;
|
|
13652
13623
|
}, {});
|
|
13653
13624
|
}
|
|
13654
|
-
var resetAttributes = (typeOrName, attributes) => ({ tr: tr2, state
|
|
13625
|
+
var resetAttributes = (typeOrName, attributes) => ({ tr: tr2, state, dispatch }) => {
|
|
13655
13626
|
let nodeType = null;
|
|
13656
13627
|
let markType = null;
|
|
13657
13628
|
const schemaType = getSchemaTypeNameByName(
|
|
13658
13629
|
typeof typeOrName === "string" ? typeOrName : typeOrName.name,
|
|
13659
|
-
|
|
13630
|
+
state.schema
|
|
13660
13631
|
);
|
|
13661
13632
|
if (!schemaType) {
|
|
13662
13633
|
return false;
|
|
13663
13634
|
}
|
|
13664
13635
|
if (schemaType === "node") {
|
|
13665
|
-
nodeType = getNodeType(typeOrName,
|
|
13636
|
+
nodeType = getNodeType(typeOrName, state.schema);
|
|
13666
13637
|
}
|
|
13667
13638
|
if (schemaType === "mark") {
|
|
13668
|
-
markType = getMarkType(typeOrName,
|
|
13639
|
+
markType = getMarkType(typeOrName, state.schema);
|
|
13669
13640
|
}
|
|
13670
13641
|
let canReset = false;
|
|
13671
13642
|
tr2.selection.ranges.forEach((range) => {
|
|
13672
|
-
|
|
13643
|
+
state.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => {
|
|
13673
13644
|
if (nodeType && nodeType === node.type) {
|
|
13674
13645
|
canReset = true;
|
|
13675
13646
|
if (dispatch) {
|
|
@@ -13703,20 +13674,20 @@ var selectAll2 = () => ({ tr: tr2, dispatch }) => {
|
|
|
13703
13674
|
}
|
|
13704
13675
|
return true;
|
|
13705
13676
|
};
|
|
13706
|
-
var selectNodeBackward2 = () => ({ state
|
|
13707
|
-
return selectNodeBackward(
|
|
13677
|
+
var selectNodeBackward2 = () => ({ state, dispatch }) => {
|
|
13678
|
+
return selectNodeBackward(state, dispatch);
|
|
13708
13679
|
};
|
|
13709
|
-
var selectNodeForward2 = () => ({ state
|
|
13710
|
-
return selectNodeForward(
|
|
13680
|
+
var selectNodeForward2 = () => ({ state, dispatch }) => {
|
|
13681
|
+
return selectNodeForward(state, dispatch);
|
|
13711
13682
|
};
|
|
13712
|
-
var selectParentNode2 = () => ({ state
|
|
13713
|
-
return selectParentNode(
|
|
13683
|
+
var selectParentNode2 = () => ({ state, dispatch }) => {
|
|
13684
|
+
return selectParentNode(state, dispatch);
|
|
13714
13685
|
};
|
|
13715
|
-
var selectTextblockEnd2 = () => ({ state
|
|
13716
|
-
return selectTextblockEnd(
|
|
13686
|
+
var selectTextblockEnd2 = () => ({ state, dispatch }) => {
|
|
13687
|
+
return selectTextblockEnd(state, dispatch);
|
|
13717
13688
|
};
|
|
13718
|
-
var selectTextblockStart2 = () => ({ state
|
|
13719
|
-
return selectTextblockStart(
|
|
13689
|
+
var selectTextblockStart2 = () => ({ state, dispatch }) => {
|
|
13690
|
+
return selectTextblockStart(state, dispatch);
|
|
13720
13691
|
};
|
|
13721
13692
|
function createDocument(content, schema, parseOptions = {}, options = {}) {
|
|
13722
13693
|
return createNodeFromContent(content, schema, {
|
|
@@ -13744,17 +13715,17 @@ var setContent = (content, { errorOnInvalidContent, emitUpdate = true, parseOpti
|
|
|
13744
13715
|
errorOnInvalidContent: errorOnInvalidContent != null ? errorOnInvalidContent : editor.options.enableContentCheck
|
|
13745
13716
|
});
|
|
13746
13717
|
};
|
|
13747
|
-
function getMarkAttributes(
|
|
13748
|
-
const type = getMarkType(typeOrName,
|
|
13749
|
-
const { from: from2, to, empty: empty2 } =
|
|
13718
|
+
function getMarkAttributes(state, typeOrName) {
|
|
13719
|
+
const type = getMarkType(typeOrName, state.schema);
|
|
13720
|
+
const { from: from2, to, empty: empty2 } = state.selection;
|
|
13750
13721
|
const marks = [];
|
|
13751
13722
|
if (empty2) {
|
|
13752
|
-
if (
|
|
13753
|
-
marks.push(...
|
|
13723
|
+
if (state.storedMarks) {
|
|
13724
|
+
marks.push(...state.storedMarks);
|
|
13754
13725
|
}
|
|
13755
|
-
marks.push(...
|
|
13726
|
+
marks.push(...state.selection.$head.marks());
|
|
13756
13727
|
} else {
|
|
13757
|
-
|
|
13728
|
+
state.doc.nodesBetween(from2, to, (node) => {
|
|
13758
13729
|
marks.push(...node.marks);
|
|
13759
13730
|
});
|
|
13760
13731
|
}
|
|
@@ -14294,11 +14265,11 @@ function getTextSerializersFromSchema(schema) {
|
|
|
14294
14265
|
Object.entries(schema.nodes).filter(([, node]) => node.spec.toText).map(([name, node]) => [name, node.spec.toText])
|
|
14295
14266
|
);
|
|
14296
14267
|
}
|
|
14297
|
-
function getNodeAttributes(
|
|
14298
|
-
const type = getNodeType(typeOrName,
|
|
14299
|
-
const { from: from2, to } =
|
|
14268
|
+
function getNodeAttributes(state, typeOrName) {
|
|
14269
|
+
const type = getNodeType(typeOrName, state.schema);
|
|
14270
|
+
const { from: from2, to } = state.selection;
|
|
14300
14271
|
const nodes = [];
|
|
14301
|
-
|
|
14272
|
+
state.doc.nodesBetween(from2, to, (node2) => {
|
|
14302
14273
|
nodes.push(node2);
|
|
14303
14274
|
});
|
|
14304
14275
|
const node = nodes.reverse().find((nodeItem) => nodeItem.type.name === type.name);
|
|
@@ -14307,16 +14278,16 @@ function getNodeAttributes(state3, typeOrName) {
|
|
|
14307
14278
|
}
|
|
14308
14279
|
return { ...node.attrs };
|
|
14309
14280
|
}
|
|
14310
|
-
function getAttributes(
|
|
14281
|
+
function getAttributes(state, typeOrName) {
|
|
14311
14282
|
const schemaType = getSchemaTypeNameByName(
|
|
14312
14283
|
typeof typeOrName === "string" ? typeOrName : typeOrName.name,
|
|
14313
|
-
|
|
14284
|
+
state.schema
|
|
14314
14285
|
);
|
|
14315
14286
|
if (schemaType === "node") {
|
|
14316
|
-
return getNodeAttributes(
|
|
14287
|
+
return getNodeAttributes(state, typeOrName);
|
|
14317
14288
|
}
|
|
14318
14289
|
if (schemaType === "mark") {
|
|
14319
|
-
return getMarkAttributes(
|
|
14290
|
+
return getMarkAttributes(state, typeOrName);
|
|
14320
14291
|
}
|
|
14321
14292
|
return {};
|
|
14322
14293
|
}
|
|
@@ -14401,8 +14372,8 @@ function getMarksBetween(from2, to, doc3) {
|
|
|
14401
14372
|
}
|
|
14402
14373
|
return marks;
|
|
14403
14374
|
}
|
|
14404
|
-
var getNodeAtPosition = (
|
|
14405
|
-
const $pos =
|
|
14375
|
+
var getNodeAtPosition = (state, typeOrName, pos, maxDepth = 20) => {
|
|
14376
|
+
const $pos = state.doc.resolve(pos);
|
|
14406
14377
|
let currentDepth = maxDepth;
|
|
14407
14378
|
let node = null;
|
|
14408
14379
|
while (currentDepth > 0 && node === null) {
|
|
@@ -14446,11 +14417,11 @@ var getTextContentFromNodes = ($from, maxMatch = 500) => {
|
|
|
14446
14417
|
});
|
|
14447
14418
|
return textBefore;
|
|
14448
14419
|
};
|
|
14449
|
-
function isMarkActive(
|
|
14450
|
-
const { empty: empty2, ranges } =
|
|
14451
|
-
const type = typeOrName ? getMarkType(typeOrName,
|
|
14420
|
+
function isMarkActive(state, typeOrName, attributes = {}) {
|
|
14421
|
+
const { empty: empty2, ranges } = state.selection;
|
|
14422
|
+
const type = typeOrName ? getMarkType(typeOrName, state.schema) : null;
|
|
14452
14423
|
if (empty2) {
|
|
14453
|
-
return !!(
|
|
14424
|
+
return !!(state.storedMarks || state.selection.$from.marks()).filter((mark) => {
|
|
14454
14425
|
if (!type) {
|
|
14455
14426
|
return true;
|
|
14456
14427
|
}
|
|
@@ -14462,7 +14433,7 @@ function isMarkActive(state3, typeOrName, attributes = {}) {
|
|
|
14462
14433
|
ranges.forEach(({ $from, $to }) => {
|
|
14463
14434
|
const from2 = $from.pos;
|
|
14464
14435
|
const to = $to.pos;
|
|
14465
|
-
|
|
14436
|
+
state.doc.nodesBetween(from2, to, (node, pos) => {
|
|
14466
14437
|
if (type && node.inlineContent && !node.type.allowsMarkType(type)) {
|
|
14467
14438
|
return false;
|
|
14468
14439
|
}
|
|
@@ -14500,27 +14471,27 @@ function isMarkActive(state3, typeOrName, attributes = {}) {
|
|
|
14500
14471
|
const range = matchedRange > 0 ? matchedRange + excludedRange : matchedRange;
|
|
14501
14472
|
return range >= selectionRange;
|
|
14502
14473
|
}
|
|
14503
|
-
function isActive(
|
|
14474
|
+
function isActive(state, name, attributes = {}) {
|
|
14504
14475
|
if (!name) {
|
|
14505
|
-
return isNodeActive(
|
|
14476
|
+
return isNodeActive(state, null, attributes) || isMarkActive(state, null, attributes);
|
|
14506
14477
|
}
|
|
14507
|
-
const schemaType = getSchemaTypeNameByName(name,
|
|
14478
|
+
const schemaType = getSchemaTypeNameByName(name, state.schema);
|
|
14508
14479
|
if (schemaType === "node") {
|
|
14509
|
-
return isNodeActive(
|
|
14480
|
+
return isNodeActive(state, name, attributes);
|
|
14510
14481
|
}
|
|
14511
14482
|
if (schemaType === "mark") {
|
|
14512
|
-
return isMarkActive(
|
|
14483
|
+
return isMarkActive(state, name, attributes);
|
|
14513
14484
|
}
|
|
14514
14485
|
return false;
|
|
14515
14486
|
}
|
|
14516
|
-
var isAtEndOfNode = (
|
|
14517
|
-
const { $from, $to, $anchor } =
|
|
14487
|
+
var isAtEndOfNode = (state, nodeType) => {
|
|
14488
|
+
const { $from, $to, $anchor } = state.selection;
|
|
14518
14489
|
if (nodeType) {
|
|
14519
|
-
const parentNode2 = findParentNode((node) => node.type.name === nodeType)(
|
|
14490
|
+
const parentNode2 = findParentNode((node) => node.type.name === nodeType)(state.selection);
|
|
14520
14491
|
if (!parentNode2) {
|
|
14521
14492
|
return false;
|
|
14522
14493
|
}
|
|
14523
|
-
const $parentPos =
|
|
14494
|
+
const $parentPos = state.doc.resolve(parentNode2.pos + 1);
|
|
14524
14495
|
if ($anchor.pos + 1 === $parentPos.end()) {
|
|
14525
14496
|
return true;
|
|
14526
14497
|
}
|
|
@@ -14531,8 +14502,8 @@ var isAtEndOfNode = (state3, nodeType) => {
|
|
|
14531
14502
|
}
|
|
14532
14503
|
return true;
|
|
14533
14504
|
};
|
|
14534
|
-
var isAtStartOfNode = (
|
|
14535
|
-
const { $from, $to } =
|
|
14505
|
+
var isAtStartOfNode = (state) => {
|
|
14506
|
+
const { $from, $to } = state.selection;
|
|
14536
14507
|
if ($from.parentOffset > 0 || $from.pos !== $to.pos) {
|
|
14537
14508
|
return false;
|
|
14538
14509
|
}
|
|
@@ -14632,7 +14603,7 @@ function getUpdatedPosition(position, transaction) {
|
|
|
14632
14603
|
function createMappablePosition(position) {
|
|
14633
14604
|
return new MappablePosition(position);
|
|
14634
14605
|
}
|
|
14635
|
-
function canSetMark(
|
|
14606
|
+
function canSetMark(state, tr2, newMarkType) {
|
|
14636
14607
|
var _a;
|
|
14637
14608
|
const { selection } = tr2;
|
|
14638
14609
|
let cursor = null;
|
|
@@ -14640,14 +14611,14 @@ function canSetMark(state3, tr2, newMarkType) {
|
|
|
14640
14611
|
cursor = selection.$cursor;
|
|
14641
14612
|
}
|
|
14642
14613
|
if (cursor) {
|
|
14643
|
-
const currentMarks = (_a =
|
|
14614
|
+
const currentMarks = (_a = state.storedMarks) != null ? _a : cursor.marks();
|
|
14644
14615
|
const parentAllowsMarkType = cursor.parent.type.allowsMarkType(newMarkType);
|
|
14645
14616
|
return parentAllowsMarkType && (!!newMarkType.isInSet(currentMarks) || !currentMarks.some((mark) => mark.type.excludes(newMarkType)));
|
|
14646
14617
|
}
|
|
14647
14618
|
const { ranges } = selection;
|
|
14648
14619
|
return ranges.some(({ $from, $to }) => {
|
|
14649
|
-
let someNodeSupportsMark = $from.depth === 0 ?
|
|
14650
|
-
|
|
14620
|
+
let someNodeSupportsMark = $from.depth === 0 ? state.doc.inlineContent && state.doc.type.allowsMarkType(newMarkType) : false;
|
|
14621
|
+
state.doc.nodesBetween($from.pos, $to.pos, (node, _pos, parent) => {
|
|
14651
14622
|
if (someNodeSupportsMark) {
|
|
14652
14623
|
return false;
|
|
14653
14624
|
}
|
|
@@ -14661,13 +14632,13 @@ function canSetMark(state3, tr2, newMarkType) {
|
|
|
14661
14632
|
return someNodeSupportsMark;
|
|
14662
14633
|
});
|
|
14663
14634
|
}
|
|
14664
|
-
var setMark = (typeOrName, attributes = {}) => ({ tr: tr2, state
|
|
14635
|
+
var setMark = (typeOrName, attributes = {}) => ({ tr: tr2, state, dispatch }) => {
|
|
14665
14636
|
const { selection } = tr2;
|
|
14666
14637
|
const { empty: empty2, ranges } = selection;
|
|
14667
|
-
const type = getMarkType(typeOrName,
|
|
14638
|
+
const type = getMarkType(typeOrName, state.schema);
|
|
14668
14639
|
if (dispatch) {
|
|
14669
14640
|
if (empty2) {
|
|
14670
|
-
const oldAttributes = getMarkAttributes(
|
|
14641
|
+
const oldAttributes = getMarkAttributes(state, type);
|
|
14671
14642
|
tr2.addStoredMark(
|
|
14672
14643
|
type.create({
|
|
14673
14644
|
...oldAttributes,
|
|
@@ -14678,7 +14649,7 @@ var setMark = (typeOrName, attributes = {}) => ({ tr: tr2, state: state3, dispat
|
|
|
14678
14649
|
ranges.forEach((range) => {
|
|
14679
14650
|
const from2 = range.$from.pos;
|
|
14680
14651
|
const to = range.$to.pos;
|
|
14681
|
-
|
|
14652
|
+
state.doc.nodesBetween(from2, to, (node, pos) => {
|
|
14682
14653
|
const trimmedFrom = Math.max(pos, from2);
|
|
14683
14654
|
const trimmedTo = Math.min(pos + node.nodeSize, to);
|
|
14684
14655
|
const someHasMark = node.marks.find((mark) => mark.type === type);
|
|
@@ -14702,24 +14673,24 @@ var setMark = (typeOrName, attributes = {}) => ({ tr: tr2, state: state3, dispat
|
|
|
14702
14673
|
});
|
|
14703
14674
|
}
|
|
14704
14675
|
}
|
|
14705
|
-
return canSetMark(
|
|
14676
|
+
return canSetMark(state, tr2, type);
|
|
14706
14677
|
};
|
|
14707
14678
|
var setMeta = (key, value) => ({ tr: tr2 }) => {
|
|
14708
14679
|
tr2.setMeta(key, value);
|
|
14709
14680
|
return true;
|
|
14710
14681
|
};
|
|
14711
|
-
var setNode = (typeOrName, attributes = {}) => ({ state
|
|
14712
|
-
const type = getNodeType(typeOrName,
|
|
14682
|
+
var setNode = (typeOrName, attributes = {}) => ({ state, dispatch, chain }) => {
|
|
14683
|
+
const type = getNodeType(typeOrName, state.schema);
|
|
14713
14684
|
let attributesToCopy;
|
|
14714
|
-
if (
|
|
14715
|
-
attributesToCopy =
|
|
14685
|
+
if (state.selection.$anchor.sameParent(state.selection.$head)) {
|
|
14686
|
+
attributesToCopy = state.selection.$anchor.parent.attrs;
|
|
14716
14687
|
}
|
|
14717
14688
|
if (!type.isTextblock) {
|
|
14718
14689
|
console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.');
|
|
14719
14690
|
return false;
|
|
14720
14691
|
}
|
|
14721
14692
|
return chain().command(({ commands }) => {
|
|
14722
|
-
const canSetBlock = setBlockType2(type, { ...attributesToCopy, ...attributes })(
|
|
14693
|
+
const canSetBlock = setBlockType2(type, { ...attributesToCopy, ...attributes })(state);
|
|
14723
14694
|
if (canSetBlock) {
|
|
14724
14695
|
return true;
|
|
14725
14696
|
}
|
|
@@ -14737,8 +14708,8 @@ var setNodeSelection = (position) => ({ tr: tr2, dispatch }) => {
|
|
|
14737
14708
|
}
|
|
14738
14709
|
return true;
|
|
14739
14710
|
};
|
|
14740
|
-
var setTextDirection = (direction, position) => ({ tr: tr2, state
|
|
14741
|
-
const { selection } =
|
|
14711
|
+
var setTextDirection = (direction, position) => ({ tr: tr2, state, dispatch }) => {
|
|
14712
|
+
const { selection } = state;
|
|
14742
14713
|
let from2;
|
|
14743
14714
|
let to;
|
|
14744
14715
|
if (typeof position === "number") {
|
|
@@ -14777,18 +14748,18 @@ var setTextSelection = (position) => ({ tr: tr2, dispatch }) => {
|
|
|
14777
14748
|
}
|
|
14778
14749
|
return true;
|
|
14779
14750
|
};
|
|
14780
|
-
var sinkListItem2 = (typeOrName) => ({ state
|
|
14781
|
-
const type = getNodeType(typeOrName,
|
|
14782
|
-
return sinkListItem(type)(
|
|
14751
|
+
var sinkListItem2 = (typeOrName) => ({ state, dispatch }) => {
|
|
14752
|
+
const type = getNodeType(typeOrName, state.schema);
|
|
14753
|
+
return sinkListItem(type)(state, dispatch);
|
|
14783
14754
|
};
|
|
14784
|
-
function ensureMarks(
|
|
14785
|
-
const marks =
|
|
14755
|
+
function ensureMarks(state, splittableMarks) {
|
|
14756
|
+
const marks = state.storedMarks || state.selection.$to.parentOffset && state.selection.$from.marks();
|
|
14786
14757
|
if (marks) {
|
|
14787
14758
|
const filteredMarks = marks.filter((mark) => splittableMarks == null ? void 0 : splittableMarks.includes(mark.type.name));
|
|
14788
|
-
|
|
14759
|
+
state.tr.ensureMarks(filteredMarks);
|
|
14789
14760
|
}
|
|
14790
14761
|
}
|
|
14791
|
-
var splitBlock2 = ({ keepMarks = true } = {}) => ({ tr: tr2, state
|
|
14762
|
+
var splitBlock2 = ({ keepMarks = true } = {}) => ({ tr: tr2, state, dispatch, editor }) => {
|
|
14792
14763
|
const { selection, doc: doc3 } = tr2;
|
|
14793
14764
|
const { $from, $to } = selection;
|
|
14794
14765
|
const extensionAttributes = editor.extensionManager.attributes;
|
|
@@ -14799,7 +14770,7 @@ var splitBlock2 = ({ keepMarks = true } = {}) => ({ tr: tr2, state: state3, disp
|
|
|
14799
14770
|
}
|
|
14800
14771
|
if (dispatch) {
|
|
14801
14772
|
if (keepMarks) {
|
|
14802
|
-
ensureMarks(
|
|
14773
|
+
ensureMarks(state, editor.extensionManager.splittableMarks);
|
|
14803
14774
|
}
|
|
14804
14775
|
tr2.split($from.pos).scrollIntoView();
|
|
14805
14776
|
}
|
|
@@ -14841,17 +14812,17 @@ var splitBlock2 = ({ keepMarks = true } = {}) => ({ tr: tr2, state: state3, disp
|
|
|
14841
14812
|
}
|
|
14842
14813
|
}
|
|
14843
14814
|
if (keepMarks) {
|
|
14844
|
-
ensureMarks(
|
|
14815
|
+
ensureMarks(state, editor.extensionManager.splittableMarks);
|
|
14845
14816
|
}
|
|
14846
14817
|
tr2.scrollIntoView();
|
|
14847
14818
|
}
|
|
14848
14819
|
return can;
|
|
14849
14820
|
};
|
|
14850
|
-
var splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr: tr2, state
|
|
14821
|
+
var splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr: tr2, state, dispatch, editor }) => {
|
|
14851
14822
|
var _a;
|
|
14852
|
-
const type = getNodeType(typeOrName,
|
|
14853
|
-
const { $from, $to } =
|
|
14854
|
-
const node =
|
|
14823
|
+
const type = getNodeType(typeOrName, state.schema);
|
|
14824
|
+
const { $from, $to } = state.selection;
|
|
14825
|
+
const node = state.selection.node;
|
|
14855
14826
|
if (node && node.isBlock || $from.depth < 2 || !$from.sameParent($to)) {
|
|
14856
14827
|
return false;
|
|
14857
14828
|
}
|
|
@@ -14916,7 +14887,7 @@ var splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr: tr2, state: state
|
|
|
14916
14887
|
return false;
|
|
14917
14888
|
}
|
|
14918
14889
|
if (dispatch) {
|
|
14919
|
-
const { selection, storedMarks } =
|
|
14890
|
+
const { selection, storedMarks } = state;
|
|
14920
14891
|
const { splittableMarks } = editor.extensionManager;
|
|
14921
14892
|
const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
|
|
14922
14893
|
tr2.split($from.pos, 2, types).scrollIntoView();
|
|
@@ -14962,11 +14933,11 @@ var joinListForwards = (tr2, listType) => {
|
|
|
14962
14933
|
tr2.join(after);
|
|
14963
14934
|
return true;
|
|
14964
14935
|
};
|
|
14965
|
-
var toggleList = (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) => ({ editor, tr: tr2, state
|
|
14936
|
+
var toggleList = (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) => ({ editor, tr: tr2, state, dispatch, chain, commands, can }) => {
|
|
14966
14937
|
const { extensions, splittableMarks } = editor.extensionManager;
|
|
14967
|
-
const listType = getNodeType(listTypeOrName,
|
|
14968
|
-
const itemType = getNodeType(itemTypeOrName,
|
|
14969
|
-
const { selection, storedMarks } =
|
|
14938
|
+
const listType = getNodeType(listTypeOrName, state.schema);
|
|
14939
|
+
const itemType = getNodeType(itemTypeOrName, state.schema);
|
|
14940
|
+
const { selection, storedMarks } = state;
|
|
14970
14941
|
const { $from, $to } = selection;
|
|
14971
14942
|
const range = $from.blockRange($to);
|
|
14972
14943
|
const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
|
|
@@ -15004,51 +14975,51 @@ var toggleList = (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) =>
|
|
|
15004
14975
|
return commands.clearNodes();
|
|
15005
14976
|
}).wrapInList(listType, attributes).command(() => joinListBackwards(tr2, listType)).command(() => joinListForwards(tr2, listType)).run();
|
|
15006
14977
|
};
|
|
15007
|
-
var toggleMark = (typeOrName, attributes = {}, options = {}) => ({ state
|
|
14978
|
+
var toggleMark = (typeOrName, attributes = {}, options = {}) => ({ state, commands }) => {
|
|
15008
14979
|
const { extendEmptyMarkRange = false } = options;
|
|
15009
|
-
const type = getMarkType(typeOrName,
|
|
15010
|
-
const isActive2 = isMarkActive(
|
|
14980
|
+
const type = getMarkType(typeOrName, state.schema);
|
|
14981
|
+
const isActive2 = isMarkActive(state, type, attributes);
|
|
15011
14982
|
if (isActive2) {
|
|
15012
14983
|
return commands.unsetMark(type, { extendEmptyMarkRange });
|
|
15013
14984
|
}
|
|
15014
14985
|
return commands.setMark(type, attributes);
|
|
15015
14986
|
};
|
|
15016
|
-
var toggleNode = (typeOrName, toggleTypeOrName, attributes = {}) => ({ state
|
|
15017
|
-
const type = getNodeType(typeOrName,
|
|
15018
|
-
const toggleType = getNodeType(toggleTypeOrName,
|
|
15019
|
-
const isActive2 = isNodeActive(
|
|
14987
|
+
var toggleNode = (typeOrName, toggleTypeOrName, attributes = {}) => ({ state, commands }) => {
|
|
14988
|
+
const type = getNodeType(typeOrName, state.schema);
|
|
14989
|
+
const toggleType = getNodeType(toggleTypeOrName, state.schema);
|
|
14990
|
+
const isActive2 = isNodeActive(state, type, attributes);
|
|
15020
14991
|
let attributesToCopy;
|
|
15021
|
-
if (
|
|
15022
|
-
attributesToCopy =
|
|
14992
|
+
if (state.selection.$anchor.sameParent(state.selection.$head)) {
|
|
14993
|
+
attributesToCopy = state.selection.$anchor.parent.attrs;
|
|
15023
14994
|
}
|
|
15024
14995
|
if (isActive2) {
|
|
15025
14996
|
return commands.setNode(toggleType, attributesToCopy);
|
|
15026
14997
|
}
|
|
15027
14998
|
return commands.setNode(type, { ...attributesToCopy, ...attributes });
|
|
15028
14999
|
};
|
|
15029
|
-
var toggleWrap = (typeOrName, attributes = {}) => ({ state
|
|
15030
|
-
const type = getNodeType(typeOrName,
|
|
15031
|
-
const isActive2 = isNodeActive(
|
|
15000
|
+
var toggleWrap = (typeOrName, attributes = {}) => ({ state, commands }) => {
|
|
15001
|
+
const type = getNodeType(typeOrName, state.schema);
|
|
15002
|
+
const isActive2 = isNodeActive(state, type, attributes);
|
|
15032
15003
|
if (isActive2) {
|
|
15033
15004
|
return commands.lift(type);
|
|
15034
15005
|
}
|
|
15035
15006
|
return commands.wrapIn(type, attributes);
|
|
15036
15007
|
};
|
|
15037
|
-
var undoInputRule = () => ({ state
|
|
15038
|
-
const plugins =
|
|
15008
|
+
var undoInputRule = () => ({ state, dispatch }) => {
|
|
15009
|
+
const plugins = state.plugins;
|
|
15039
15010
|
for (let i = 0; i < plugins.length; i += 1) {
|
|
15040
15011
|
const plugin = plugins[i];
|
|
15041
15012
|
let undoable;
|
|
15042
|
-
if (plugin.spec.isInputRules && (undoable = plugin.getState(
|
|
15013
|
+
if (plugin.spec.isInputRules && (undoable = plugin.getState(state))) {
|
|
15043
15014
|
if (dispatch) {
|
|
15044
|
-
const tr2 =
|
|
15015
|
+
const tr2 = state.tr;
|
|
15045
15016
|
const toUndo = undoable.transform;
|
|
15046
15017
|
for (let j = toUndo.steps.length - 1; j >= 0; j -= 1) {
|
|
15047
15018
|
tr2.step(toUndo.steps[j].invert(toUndo.docs[j]));
|
|
15048
15019
|
}
|
|
15049
15020
|
if (undoable.text) {
|
|
15050
15021
|
const marks = tr2.doc.resolve(undoable.from).marks();
|
|
15051
|
-
tr2.replaceWith(undoable.from, undoable.to,
|
|
15022
|
+
tr2.replaceWith(undoable.from, undoable.to, state.schema.text(undoable.text, marks));
|
|
15052
15023
|
} else {
|
|
15053
15024
|
tr2.delete(undoable.from, undoable.to);
|
|
15054
15025
|
}
|
|
@@ -15071,11 +15042,11 @@ var unsetAllMarks = () => ({ tr: tr2, dispatch }) => {
|
|
|
15071
15042
|
}
|
|
15072
15043
|
return true;
|
|
15073
15044
|
};
|
|
15074
|
-
var unsetMark = (typeOrName, options = {}) => ({ tr: tr2, state
|
|
15045
|
+
var unsetMark = (typeOrName, options = {}) => ({ tr: tr2, state, dispatch }) => {
|
|
15075
15046
|
var _a;
|
|
15076
15047
|
const { extendEmptyMarkRange = false } = options;
|
|
15077
15048
|
const { selection } = tr2;
|
|
15078
|
-
const type = getMarkType(typeOrName,
|
|
15049
|
+
const type = getMarkType(typeOrName, state.schema);
|
|
15079
15050
|
const { $from, empty: empty2, ranges } = selection;
|
|
15080
15051
|
if (!dispatch) {
|
|
15081
15052
|
return true;
|
|
@@ -15097,8 +15068,8 @@ var unsetMark = (typeOrName, options = {}) => ({ tr: tr2, state: state3, dispatc
|
|
|
15097
15068
|
tr2.removeStoredMark(type);
|
|
15098
15069
|
return true;
|
|
15099
15070
|
};
|
|
15100
|
-
var unsetTextDirection = (position) => ({ tr: tr2, state
|
|
15101
|
-
const { selection } =
|
|
15071
|
+
var unsetTextDirection = (position) => ({ tr: tr2, state, dispatch }) => {
|
|
15072
|
+
const { selection } = state;
|
|
15102
15073
|
let from2;
|
|
15103
15074
|
let to;
|
|
15104
15075
|
if (typeof position === "number") {
|
|
@@ -15123,21 +15094,21 @@ var unsetTextDirection = (position) => ({ tr: tr2, state: state3, dispatch }) =>
|
|
|
15123
15094
|
}
|
|
15124
15095
|
return true;
|
|
15125
15096
|
};
|
|
15126
|
-
var updateAttributes = (typeOrName, attributes = {}) => ({ tr: tr2, state
|
|
15097
|
+
var updateAttributes = (typeOrName, attributes = {}) => ({ tr: tr2, state, dispatch }) => {
|
|
15127
15098
|
let nodeType = null;
|
|
15128
15099
|
let markType = null;
|
|
15129
15100
|
const schemaType = getSchemaTypeNameByName(
|
|
15130
15101
|
typeof typeOrName === "string" ? typeOrName : typeOrName.name,
|
|
15131
|
-
|
|
15102
|
+
state.schema
|
|
15132
15103
|
);
|
|
15133
15104
|
if (!schemaType) {
|
|
15134
15105
|
return false;
|
|
15135
15106
|
}
|
|
15136
15107
|
if (schemaType === "node") {
|
|
15137
|
-
nodeType = getNodeType(typeOrName,
|
|
15108
|
+
nodeType = getNodeType(typeOrName, state.schema);
|
|
15138
15109
|
}
|
|
15139
15110
|
if (schemaType === "mark") {
|
|
15140
|
-
markType = getMarkType(typeOrName,
|
|
15111
|
+
markType = getMarkType(typeOrName, state.schema);
|
|
15141
15112
|
}
|
|
15142
15113
|
let canUpdate = false;
|
|
15143
15114
|
tr2.selection.ranges.forEach((range) => {
|
|
@@ -15148,7 +15119,7 @@ var updateAttributes = (typeOrName, attributes = {}) => ({ tr: tr2, state: state
|
|
|
15148
15119
|
let trimmedFrom;
|
|
15149
15120
|
let trimmedTo;
|
|
15150
15121
|
if (tr2.selection.empty) {
|
|
15151
|
-
|
|
15122
|
+
state.doc.nodesBetween(from2, to, (node, pos) => {
|
|
15152
15123
|
if (nodeType && nodeType === node.type) {
|
|
15153
15124
|
canUpdate = true;
|
|
15154
15125
|
trimmedFrom = Math.max(pos, from2);
|
|
@@ -15158,7 +15129,7 @@ var updateAttributes = (typeOrName, attributes = {}) => ({ tr: tr2, state: state
|
|
|
15158
15129
|
}
|
|
15159
15130
|
});
|
|
15160
15131
|
} else {
|
|
15161
|
-
|
|
15132
|
+
state.doc.nodesBetween(from2, to, (node, pos) => {
|
|
15162
15133
|
if (pos < from2 && nodeType && nodeType === node.type) {
|
|
15163
15134
|
canUpdate = true;
|
|
15164
15135
|
trimmedFrom = Math.max(pos, from2);
|
|
@@ -15223,13 +15194,13 @@ var updateAttributes = (typeOrName, attributes = {}) => ({ tr: tr2, state: state
|
|
|
15223
15194
|
});
|
|
15224
15195
|
return canUpdate;
|
|
15225
15196
|
};
|
|
15226
|
-
var wrapIn2 = (typeOrName, attributes = {}) => ({ state
|
|
15227
|
-
const type = getNodeType(typeOrName,
|
|
15228
|
-
return wrapIn(type, attributes)(
|
|
15197
|
+
var wrapIn2 = (typeOrName, attributes = {}) => ({ state, dispatch }) => {
|
|
15198
|
+
const type = getNodeType(typeOrName, state.schema);
|
|
15199
|
+
return wrapIn(type, attributes)(state, dispatch);
|
|
15229
15200
|
};
|
|
15230
|
-
var wrapInList2 = (typeOrName, attributes = {}) => ({ state
|
|
15231
|
-
const type = getNodeType(typeOrName,
|
|
15232
|
-
return wrapInList(type, attributes)(
|
|
15201
|
+
var wrapInList2 = (typeOrName, attributes = {}) => ({ state, dispatch }) => {
|
|
15202
|
+
const type = getNodeType(typeOrName, state.schema);
|
|
15203
|
+
return wrapInList(type, attributes)(state, dispatch);
|
|
15233
15204
|
};
|
|
15234
15205
|
var EventEmitter = class {
|
|
15235
15206
|
constructor() {
|
|
@@ -15325,7 +15296,7 @@ function run(config) {
|
|
|
15325
15296
|
return;
|
|
15326
15297
|
}
|
|
15327
15298
|
const tr2 = view.state.tr;
|
|
15328
|
-
const
|
|
15299
|
+
const state = createChainableState({
|
|
15329
15300
|
state: view.state,
|
|
15330
15301
|
transaction: tr2
|
|
15331
15302
|
});
|
|
@@ -15335,10 +15306,10 @@ function run(config) {
|
|
|
15335
15306
|
};
|
|
15336
15307
|
const { commands, chain, can } = new CommandManager({
|
|
15337
15308
|
editor,
|
|
15338
|
-
state
|
|
15309
|
+
state
|
|
15339
15310
|
});
|
|
15340
15311
|
const handler = rule.handler({
|
|
15341
|
-
state
|
|
15312
|
+
state,
|
|
15342
15313
|
range,
|
|
15343
15314
|
match,
|
|
15344
15315
|
commands,
|
|
@@ -15368,7 +15339,7 @@ function inputRulesPlugin(props) {
|
|
|
15368
15339
|
init() {
|
|
15369
15340
|
return null;
|
|
15370
15341
|
},
|
|
15371
|
-
apply(tr2, prev,
|
|
15342
|
+
apply(tr2, prev, state) {
|
|
15372
15343
|
const stored = tr2.getMeta(plugin);
|
|
15373
15344
|
if (stored) {
|
|
15374
15345
|
return stored;
|
|
@@ -15381,7 +15352,7 @@ function inputRulesPlugin(props) {
|
|
|
15381
15352
|
if (typeof text === "string") {
|
|
15382
15353
|
text = text;
|
|
15383
15354
|
} else {
|
|
15384
|
-
text = getHTMLFromFragment(Fragment2.from(text),
|
|
15355
|
+
text = getHTMLFromFragment(Fragment2.from(text), state.schema);
|
|
15385
15356
|
}
|
|
15386
15357
|
const { from: from2 } = simulatedInputMeta;
|
|
15387
15358
|
const to = from2 + text.length;
|
|
@@ -15600,13 +15571,13 @@ var pasteRuleMatcherHandler = (text, find2, event) => {
|
|
|
15600
15571
|
});
|
|
15601
15572
|
};
|
|
15602
15573
|
function run2(config) {
|
|
15603
|
-
const { editor, state
|
|
15574
|
+
const { editor, state, from: from2, to, rule, pasteEvent, dropEvent } = config;
|
|
15604
15575
|
const { commands, chain, can } = new CommandManager({
|
|
15605
15576
|
editor,
|
|
15606
|
-
state
|
|
15577
|
+
state
|
|
15607
15578
|
});
|
|
15608
15579
|
const handlers2 = [];
|
|
15609
|
-
|
|
15580
|
+
state.doc.nodesBetween(from2, to, (node, pos) => {
|
|
15610
15581
|
var _a, _b, _c, _d, _e;
|
|
15611
15582
|
if (((_b = (_a = node.type) == null ? void 0 : _a.spec) == null ? void 0 : _b.code) || !(node.isText || node.isTextblock || node.isInline)) {
|
|
15612
15583
|
return;
|
|
@@ -15626,11 +15597,11 @@ function run2(config) {
|
|
|
15626
15597
|
const start = resolvedFrom + match.index + 1;
|
|
15627
15598
|
const end = start + match[0].length;
|
|
15628
15599
|
const range = {
|
|
15629
|
-
from:
|
|
15630
|
-
to:
|
|
15600
|
+
from: state.tr.mapping.map(start),
|
|
15601
|
+
to: state.tr.mapping.map(end)
|
|
15631
15602
|
};
|
|
15632
15603
|
const handler = rule.handler({
|
|
15633
|
-
state
|
|
15604
|
+
state,
|
|
15634
15605
|
range,
|
|
15635
15606
|
match,
|
|
15636
15607
|
commands,
|
|
@@ -15667,15 +15638,15 @@ function pasteRulesPlugin(props) {
|
|
|
15667
15638
|
dropEvent = null;
|
|
15668
15639
|
}
|
|
15669
15640
|
const processEvent = ({
|
|
15670
|
-
state
|
|
15641
|
+
state,
|
|
15671
15642
|
from: from2,
|
|
15672
15643
|
to,
|
|
15673
15644
|
rule,
|
|
15674
15645
|
pasteEvt
|
|
15675
15646
|
}) => {
|
|
15676
|
-
const tr2 =
|
|
15647
|
+
const tr2 = state.tr;
|
|
15677
15648
|
const chainableState = createChainableState({
|
|
15678
|
-
state
|
|
15649
|
+
state,
|
|
15679
15650
|
transaction: tr2
|
|
15680
15651
|
});
|
|
15681
15652
|
const handler = run2({
|
|
@@ -15750,7 +15721,7 @@ function pasteRulesPlugin(props) {
|
|
|
15750
15721
|
}
|
|
15751
15722
|
}
|
|
15752
15723
|
},
|
|
15753
|
-
appendTransaction: (transactions, oldState,
|
|
15724
|
+
appendTransaction: (transactions, oldState, state) => {
|
|
15754
15725
|
const transaction = transactions[0];
|
|
15755
15726
|
const isPaste = transaction.getMeta("uiEvent") === "paste" && !isPastedFromProseMirror;
|
|
15756
15727
|
const isDrop = transaction.getMeta("uiEvent") === "drop" && !isDroppedFromProseMirror;
|
|
@@ -15764,27 +15735,27 @@ function pasteRulesPlugin(props) {
|
|
|
15764
15735
|
if (typeof text === "string") {
|
|
15765
15736
|
text = text;
|
|
15766
15737
|
} else {
|
|
15767
|
-
text = getHTMLFromFragment(Fragment2.from(text),
|
|
15738
|
+
text = getHTMLFromFragment(Fragment2.from(text), state.schema);
|
|
15768
15739
|
}
|
|
15769
15740
|
const { from: from22 } = simulatedPasteMeta;
|
|
15770
15741
|
const to2 = from22 + text.length;
|
|
15771
15742
|
const pasteEvt = createClipboardPasteEvent(text);
|
|
15772
15743
|
return processEvent({
|
|
15773
15744
|
rule,
|
|
15774
|
-
state
|
|
15745
|
+
state,
|
|
15775
15746
|
from: from22,
|
|
15776
15747
|
to: { b: to2 },
|
|
15777
15748
|
pasteEvt
|
|
15778
15749
|
});
|
|
15779
15750
|
}
|
|
15780
|
-
const from2 = oldState.doc.content.findDiffStart(
|
|
15781
|
-
const to = oldState.doc.content.findDiffEnd(
|
|
15751
|
+
const from2 = oldState.doc.content.findDiffStart(state.doc.content);
|
|
15752
|
+
const to = oldState.doc.content.findDiffEnd(state.doc.content);
|
|
15782
15753
|
if (!isNumber(from2) || !to || from2 === to.b) {
|
|
15783
15754
|
return;
|
|
15784
15755
|
}
|
|
15785
15756
|
return processEvent({
|
|
15786
15757
|
rule,
|
|
15787
|
-
state
|
|
15758
|
+
state,
|
|
15788
15759
|
from: from2,
|
|
15789
15760
|
to,
|
|
15790
15761
|
pasteEvt: pasteEvent
|
|
@@ -16159,8 +16130,8 @@ var ClipboardTextSerializer = Extension.create({
|
|
|
16159
16130
|
props: {
|
|
16160
16131
|
clipboardTextSerializer: () => {
|
|
16161
16132
|
const { editor } = this;
|
|
16162
|
-
const { state
|
|
16163
|
-
const { doc: doc3, selection } =
|
|
16133
|
+
const { state, schema } = editor;
|
|
16134
|
+
const { doc: doc3, selection } = state;
|
|
16164
16135
|
const { ranges } = selection;
|
|
16165
16136
|
const from2 = Math.min(...ranges.map((range2) => range2.$from.pos));
|
|
16166
16137
|
const to = Math.max(...ranges.map((range2) => range2.$to.pos));
|
|
@@ -16410,13 +16381,13 @@ var Keymap = Extension.create({
|
|
|
16410
16381
|
return;
|
|
16411
16382
|
}
|
|
16412
16383
|
const tr2 = newState.tr;
|
|
16413
|
-
const
|
|
16384
|
+
const state = createChainableState({
|
|
16414
16385
|
state: newState,
|
|
16415
16386
|
transaction: tr2
|
|
16416
16387
|
});
|
|
16417
16388
|
const { commands } = new CommandManager({
|
|
16418
16389
|
editor: this.editor,
|
|
16419
|
-
state
|
|
16390
|
+
state
|
|
16420
16391
|
});
|
|
16421
16392
|
commands.clearNodes();
|
|
16422
16393
|
if (!tr2.steps.length) {
|
|
@@ -16986,8 +16957,8 @@ var Editor = class extends EventEmitter {
|
|
|
16986
16957
|
return new Proxy(
|
|
16987
16958
|
{
|
|
16988
16959
|
state: this.editorState,
|
|
16989
|
-
updateState: (
|
|
16990
|
-
this.editorState =
|
|
16960
|
+
updateState: (state) => {
|
|
16961
|
+
this.editorState = state;
|
|
16991
16962
|
},
|
|
16992
16963
|
dispatch: (tr2) => {
|
|
16993
16964
|
this.dispatchTransaction(tr2);
|
|
@@ -17034,9 +17005,9 @@ var Editor = class extends EventEmitter {
|
|
|
17034
17005
|
*/
|
|
17035
17006
|
registerPlugin(plugin, handlePlugins) {
|
|
17036
17007
|
const plugins = isFunction(handlePlugins) ? handlePlugins(plugin, [...this.state.plugins]) : [...this.state.plugins, plugin];
|
|
17037
|
-
const
|
|
17038
|
-
this.view.updateState(
|
|
17039
|
-
return
|
|
17008
|
+
const state = this.state.reconfigure({ plugins });
|
|
17009
|
+
this.view.updateState(state);
|
|
17010
|
+
return state;
|
|
17040
17011
|
}
|
|
17041
17012
|
/**
|
|
17042
17013
|
* Unregister a ProseMirror plugin.
|
|
@@ -17057,11 +17028,11 @@ var Editor = class extends EventEmitter {
|
|
|
17057
17028
|
if (prevPlugins.length === plugins.length) {
|
|
17058
17029
|
return void 0;
|
|
17059
17030
|
}
|
|
17060
|
-
const
|
|
17031
|
+
const state = this.state.reconfigure({
|
|
17061
17032
|
plugins
|
|
17062
17033
|
});
|
|
17063
|
-
this.view.updateState(
|
|
17064
|
-
return
|
|
17034
|
+
this.view.updateState(state);
|
|
17035
|
+
return state;
|
|
17065
17036
|
}
|
|
17066
17037
|
/**
|
|
17067
17038
|
* Creates an extension manager.
|
|
@@ -17216,19 +17187,19 @@ var Editor = class extends EventEmitter {
|
|
|
17216
17187
|
});
|
|
17217
17188
|
return;
|
|
17218
17189
|
}
|
|
17219
|
-
const { state
|
|
17220
|
-
const selectionHasChanged = !this.state.selection.eq(
|
|
17190
|
+
const { state, transactions } = this.state.applyTransaction(transaction);
|
|
17191
|
+
const selectionHasChanged = !this.state.selection.eq(state.selection);
|
|
17221
17192
|
const rootTrWasApplied = transactions.includes(transaction);
|
|
17222
17193
|
const prevState = this.state;
|
|
17223
17194
|
this.emit("beforeTransaction", {
|
|
17224
17195
|
editor: this,
|
|
17225
17196
|
transaction,
|
|
17226
|
-
nextState:
|
|
17197
|
+
nextState: state
|
|
17227
17198
|
});
|
|
17228
17199
|
if (!rootTrWasApplied) {
|
|
17229
17200
|
return;
|
|
17230
17201
|
}
|
|
17231
|
-
this.view.updateState(
|
|
17202
|
+
this.view.updateState(state);
|
|
17232
17203
|
this.emit("transaction", {
|
|
17233
17204
|
editor: this,
|
|
17234
17205
|
transaction,
|
|
@@ -17259,7 +17230,7 @@ var Editor = class extends EventEmitter {
|
|
|
17259
17230
|
transaction: mostRecentFocusTr
|
|
17260
17231
|
});
|
|
17261
17232
|
}
|
|
17262
|
-
if (transaction.getMeta("preventUpdate") || !transactions.some((tr2) => tr2.docChanged) || prevState.doc.eq(
|
|
17233
|
+
if (transaction.getMeta("preventUpdate") || !transactions.some((tr2) => tr2.docChanged) || prevState.doc.eq(state.doc)) {
|
|
17263
17234
|
return;
|
|
17264
17235
|
}
|
|
17265
17236
|
this.emit("update", {
|
|
@@ -17344,19 +17315,19 @@ var Editor = class extends EventEmitter {
|
|
|
17344
17315
|
function markInputRule(config) {
|
|
17345
17316
|
return new InputRule({
|
|
17346
17317
|
find: config.find,
|
|
17347
|
-
handler: ({ state
|
|
17318
|
+
handler: ({ state, range, match }) => {
|
|
17348
17319
|
const attributes = callOrReturn(config.getAttributes, void 0, match);
|
|
17349
17320
|
if (attributes === false || attributes === null) {
|
|
17350
17321
|
return null;
|
|
17351
17322
|
}
|
|
17352
|
-
const { tr: tr2 } =
|
|
17323
|
+
const { tr: tr2 } = state;
|
|
17353
17324
|
const captureGroup = match[match.length - 1];
|
|
17354
17325
|
const fullMatch = match[0];
|
|
17355
17326
|
if (captureGroup) {
|
|
17356
17327
|
const startSpaces = fullMatch.search(/\S/);
|
|
17357
17328
|
const textStart = range.from + fullMatch.indexOf(captureGroup);
|
|
17358
17329
|
const textEnd = textStart + captureGroup.length;
|
|
17359
|
-
const excludedMarks = getMarksBetween(range.from, range.to,
|
|
17330
|
+
const excludedMarks = getMarksBetween(range.from, range.to, state.doc).filter((item) => {
|
|
17360
17331
|
const excluded = item.mark.type.excluded;
|
|
17361
17332
|
return excluded.find((type) => type === config.type && type !== item.mark.type);
|
|
17362
17333
|
}).filter((item) => item.to > textStart);
|
|
@@ -17380,9 +17351,9 @@ function markInputRule(config) {
|
|
|
17380
17351
|
function nodeInputRule(config) {
|
|
17381
17352
|
return new InputRule({
|
|
17382
17353
|
find: config.find,
|
|
17383
|
-
handler: ({ state
|
|
17354
|
+
handler: ({ state, range, match }) => {
|
|
17384
17355
|
const attributes = callOrReturn(config.getAttributes, void 0, match) || {};
|
|
17385
|
-
const { tr: tr2 } =
|
|
17356
|
+
const { tr: tr2 } = state;
|
|
17386
17357
|
const start = range.from;
|
|
17387
17358
|
let end = range.to;
|
|
17388
17359
|
const newNode = config.type.create(attributes);
|
|
@@ -17409,13 +17380,13 @@ function nodeInputRule(config) {
|
|
|
17409
17380
|
function textblockTypeInputRule(config) {
|
|
17410
17381
|
return new InputRule({
|
|
17411
17382
|
find: config.find,
|
|
17412
|
-
handler: ({ state
|
|
17413
|
-
const $start =
|
|
17383
|
+
handler: ({ state, range, match }) => {
|
|
17384
|
+
const $start = state.doc.resolve(range.from);
|
|
17414
17385
|
const attributes = callOrReturn(config.getAttributes, void 0, match) || {};
|
|
17415
17386
|
if (!$start.node(-1).canReplaceWith($start.index(-1), $start.indexAfter(-1), config.type)) {
|
|
17416
17387
|
return null;
|
|
17417
17388
|
}
|
|
17418
|
-
|
|
17389
|
+
state.tr.delete(range.from, range.to).setBlockType(range.from, range.from, config.type, attributes);
|
|
17419
17390
|
},
|
|
17420
17391
|
undoable: config.undoable
|
|
17421
17392
|
});
|
|
@@ -17423,9 +17394,9 @@ function textblockTypeInputRule(config) {
|
|
|
17423
17394
|
function wrappingInputRule(config) {
|
|
17424
17395
|
return new InputRule({
|
|
17425
17396
|
find: config.find,
|
|
17426
|
-
handler: ({ state
|
|
17397
|
+
handler: ({ state, range, match, chain }) => {
|
|
17427
17398
|
const attributes = callOrReturn(config.getAttributes, void 0, match) || {};
|
|
17428
|
-
const tr2 =
|
|
17399
|
+
const tr2 = state.tr.delete(range.from, range.to);
|
|
17429
17400
|
const $start = tr2.doc.resolve(range.from);
|
|
17430
17401
|
const blockRange = $start.blockRange();
|
|
17431
17402
|
const wrapping = blockRange && findWrapping(blockRange, config.type, attributes);
|
|
@@ -17434,7 +17405,7 @@ function wrappingInputRule(config) {
|
|
|
17434
17405
|
}
|
|
17435
17406
|
tr2.wrap(blockRange, wrapping);
|
|
17436
17407
|
if (config.keepMarks && config.editor) {
|
|
17437
|
-
const { selection, storedMarks } =
|
|
17408
|
+
const { selection, storedMarks } = state;
|
|
17438
17409
|
const { splittableMarks } = config.editor.extensionManager;
|
|
17439
17410
|
const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
|
|
17440
17411
|
if (marks) {
|
|
@@ -17454,8 +17425,8 @@ function wrappingInputRule(config) {
|
|
|
17454
17425
|
undoable: config.undoable
|
|
17455
17426
|
});
|
|
17456
17427
|
}
|
|
17457
|
-
function canInsertNode(
|
|
17458
|
-
const { selection } =
|
|
17428
|
+
function canInsertNode(state, nodeType) {
|
|
17429
|
+
const { selection } = state;
|
|
17459
17430
|
const { $from } = selection;
|
|
17460
17431
|
if (selection instanceof NodeSelection) {
|
|
17461
17432
|
const index = $from.index();
|
|
@@ -17957,8 +17928,8 @@ ${indentedChild}`;
|
|
|
17957
17928
|
return output;
|
|
17958
17929
|
}
|
|
17959
17930
|
function updateMarkViewAttributes(checkMark, editor, attrs = {}) {
|
|
17960
|
-
const { state
|
|
17961
|
-
const { doc: doc3, tr: tr2 } =
|
|
17931
|
+
const { state } = editor;
|
|
17932
|
+
const { doc: doc3, tr: tr2 } = state;
|
|
17962
17933
|
const thisMark = checkMark;
|
|
17963
17934
|
doc3.descendants((node, pos) => {
|
|
17964
17935
|
const from2 = tr2.mapping.map(pos);
|
|
@@ -18016,12 +17987,12 @@ var Node3 = class _Node extends Extendable {
|
|
|
18016
17987
|
function markPasteRule(config) {
|
|
18017
17988
|
return new PasteRule({
|
|
18018
17989
|
find: config.find,
|
|
18019
|
-
handler: ({ state
|
|
17990
|
+
handler: ({ state, range, match, pasteEvent }) => {
|
|
18020
17991
|
const attributes = callOrReturn(config.getAttributes, void 0, match, pasteEvent);
|
|
18021
17992
|
if (attributes === false || attributes === null) {
|
|
18022
17993
|
return null;
|
|
18023
17994
|
}
|
|
18024
|
-
const { tr: tr2 } =
|
|
17995
|
+
const { tr: tr2 } = state;
|
|
18025
17996
|
const captureGroup = match[match.length - 1];
|
|
18026
17997
|
const fullMatch = match[0];
|
|
18027
17998
|
let markEnd = range.to;
|
|
@@ -18029,7 +18000,7 @@ function markPasteRule(config) {
|
|
|
18029
18000
|
const startSpaces = fullMatch.search(/\S/);
|
|
18030
18001
|
const textStart = range.from + fullMatch.indexOf(captureGroup);
|
|
18031
18002
|
const textEnd = textStart + captureGroup.length;
|
|
18032
|
-
const excludedMarks = getMarksBetween(range.from, range.to,
|
|
18003
|
+
const excludedMarks = getMarksBetween(range.from, range.to, state.doc).filter((item) => {
|
|
18033
18004
|
const excluded = item.mark.type.excluded;
|
|
18034
18005
|
return excluded.find((type) => type === config.type && type !== item.mark.type);
|
|
18035
18006
|
}).filter((item) => item.to > textStart);
|
|
@@ -18129,8 +18100,8 @@ function Suggestion({
|
|
|
18129
18100
|
return getAnchorClientRect;
|
|
18130
18101
|
}
|
|
18131
18102
|
return () => {
|
|
18132
|
-
const
|
|
18133
|
-
const decorationId =
|
|
18103
|
+
const state = pluginKey.getState(editor.state);
|
|
18104
|
+
const decorationId = state == null ? void 0 : state.decorationId;
|
|
18134
18105
|
const currentDecorationNode = view.dom.querySelector(`[data-decoration-id="${decorationId}"]`);
|
|
18135
18106
|
return (currentDecorationNode == null ? void 0 : currentDecorationNode.getBoundingClientRect()) || null;
|
|
18136
18107
|
};
|
|
@@ -18138,17 +18109,17 @@ function Suggestion({
|
|
|
18138
18109
|
function dispatchExit(view, pluginKeyRef) {
|
|
18139
18110
|
var _a;
|
|
18140
18111
|
try {
|
|
18141
|
-
const
|
|
18142
|
-
const decorationNode = (
|
|
18112
|
+
const state = pluginKey.getState(view.state);
|
|
18113
|
+
const decorationNode = (state == null ? void 0 : state.decorationId) ? view.dom.querySelector(`[data-decoration-id="${state.decorationId}"]`) : null;
|
|
18143
18114
|
const exitProps = {
|
|
18144
18115
|
// @ts-ignore editor is available in closure
|
|
18145
18116
|
editor,
|
|
18146
|
-
range: (
|
|
18147
|
-
query: (
|
|
18148
|
-
text: (
|
|
18117
|
+
range: (state == null ? void 0 : state.range) || { from: 0, to: 0 },
|
|
18118
|
+
query: (state == null ? void 0 : state.query) || null,
|
|
18119
|
+
text: (state == null ? void 0 : state.text) || null,
|
|
18149
18120
|
items: [],
|
|
18150
18121
|
command: (commandProps) => {
|
|
18151
|
-
return command2({ editor, range: (
|
|
18122
|
+
return command2({ editor, range: (state == null ? void 0 : state.range) || { from: 0, to: 0 }, props: commandProps });
|
|
18152
18123
|
},
|
|
18153
18124
|
decorationNode,
|
|
18154
18125
|
clientRect: clientRectFor(view, decorationNode)
|
|
@@ -18177,18 +18148,18 @@ function Suggestion({
|
|
|
18177
18148
|
if (!handleStart && !handleChange && !handleExit) {
|
|
18178
18149
|
return;
|
|
18179
18150
|
}
|
|
18180
|
-
const
|
|
18181
|
-
const decorationNode = view.dom.querySelector(`[data-decoration-id="${
|
|
18151
|
+
const state = handleExit && !handleStart ? prev : next;
|
|
18152
|
+
const decorationNode = view.dom.querySelector(`[data-decoration-id="${state.decorationId}"]`);
|
|
18182
18153
|
props = {
|
|
18183
18154
|
editor,
|
|
18184
|
-
range:
|
|
18185
|
-
query:
|
|
18186
|
-
text:
|
|
18155
|
+
range: state.range,
|
|
18156
|
+
query: state.query,
|
|
18157
|
+
text: state.text,
|
|
18187
18158
|
items: [],
|
|
18188
18159
|
command: (commandProps) => {
|
|
18189
18160
|
return command2({
|
|
18190
18161
|
editor,
|
|
18191
|
-
range:
|
|
18162
|
+
range: state.range,
|
|
18192
18163
|
props: commandProps
|
|
18193
18164
|
});
|
|
18194
18165
|
},
|
|
@@ -18204,7 +18175,7 @@ function Suggestion({
|
|
|
18204
18175
|
if (handleChange || handleStart) {
|
|
18205
18176
|
props.items = await items({
|
|
18206
18177
|
editor,
|
|
18207
|
-
query:
|
|
18178
|
+
query: state.query
|
|
18208
18179
|
});
|
|
18209
18180
|
}
|
|
18210
18181
|
if (handleExit) {
|
|
@@ -18229,7 +18200,7 @@ function Suggestion({
|
|
|
18229
18200
|
state: {
|
|
18230
18201
|
// Initialize the plugin's internal state.
|
|
18231
18202
|
init() {
|
|
18232
|
-
const
|
|
18203
|
+
const state = {
|
|
18233
18204
|
active: false,
|
|
18234
18205
|
range: {
|
|
18235
18206
|
from: 0,
|
|
@@ -18239,10 +18210,10 @@ function Suggestion({
|
|
|
18239
18210
|
text: null,
|
|
18240
18211
|
composing: false
|
|
18241
18212
|
};
|
|
18242
|
-
return
|
|
18213
|
+
return state;
|
|
18243
18214
|
},
|
|
18244
18215
|
// Apply changes to the plugin state from a view transaction.
|
|
18245
|
-
apply(transaction, prev, _oldState,
|
|
18216
|
+
apply(transaction, prev, _oldState, state) {
|
|
18246
18217
|
const { isEditable } = editor;
|
|
18247
18218
|
const { composing } = editor.view;
|
|
18248
18219
|
const { selection } = transaction;
|
|
@@ -18273,7 +18244,7 @@ function Suggestion({
|
|
|
18273
18244
|
const decorationId = `id_${Math.floor(Math.random() * 4294967295)}`;
|
|
18274
18245
|
if (match && allow({
|
|
18275
18246
|
editor,
|
|
18276
|
-
state
|
|
18247
|
+
state,
|
|
18277
18248
|
range: match.range,
|
|
18278
18249
|
isActive: prev.active
|
|
18279
18250
|
}) && (!shouldShow || shouldShow({
|
|
@@ -18312,21 +18283,21 @@ function Suggestion({
|
|
|
18312
18283
|
return false;
|
|
18313
18284
|
}
|
|
18314
18285
|
if (event.key === "Escape" || event.key === "Esc") {
|
|
18315
|
-
const
|
|
18286
|
+
const state = plugin.getState(view.state);
|
|
18316
18287
|
const cachedNode = (_a = props == null ? void 0 : props.decorationNode) != null ? _a : null;
|
|
18317
|
-
const decorationNode = cachedNode != null ? cachedNode : (
|
|
18318
|
-
const handledByKeyDown = ((_b = renderer == null ? void 0 : renderer.onKeyDown) == null ? void 0 : _b.call(renderer, { view, event, range:
|
|
18288
|
+
const decorationNode = cachedNode != null ? cachedNode : (state == null ? void 0 : state.decorationId) ? view.dom.querySelector(`[data-decoration-id="${state.decorationId}"]`) : null;
|
|
18289
|
+
const handledByKeyDown = ((_b = renderer == null ? void 0 : renderer.onKeyDown) == null ? void 0 : _b.call(renderer, { view, event, range: state.range })) || false;
|
|
18319
18290
|
if (handledByKeyDown) {
|
|
18320
18291
|
return true;
|
|
18321
18292
|
}
|
|
18322
18293
|
const exitProps = {
|
|
18323
18294
|
editor,
|
|
18324
|
-
range:
|
|
18325
|
-
query:
|
|
18326
|
-
text:
|
|
18295
|
+
range: state.range,
|
|
18296
|
+
query: state.query,
|
|
18297
|
+
text: state.text,
|
|
18327
18298
|
items: [],
|
|
18328
18299
|
command: (commandProps) => {
|
|
18329
|
-
return command2({ editor, range:
|
|
18300
|
+
return command2({ editor, range: state.range, props: commandProps });
|
|
18330
18301
|
},
|
|
18331
18302
|
decorationNode,
|
|
18332
18303
|
// If we have a cached decoration node, use it for the clientRect
|
|
@@ -18344,8 +18315,8 @@ function Suggestion({
|
|
|
18344
18315
|
return handled;
|
|
18345
18316
|
},
|
|
18346
18317
|
// Setup decorator on the currently active suggestion.
|
|
18347
|
-
decorations(
|
|
18348
|
-
const { active, range, decorationId, query } = plugin.getState(
|
|
18318
|
+
decorations(state) {
|
|
18319
|
+
const { active, range, decorationId, query } = plugin.getState(state);
|
|
18349
18320
|
if (!active) {
|
|
18350
18321
|
return null;
|
|
18351
18322
|
}
|
|
@@ -18354,7 +18325,7 @@ function Suggestion({
|
|
|
18354
18325
|
if (isEmpty) {
|
|
18355
18326
|
classNames.push(decorationEmptyClass);
|
|
18356
18327
|
}
|
|
18357
|
-
return DecorationSet.create(
|
|
18328
|
+
return DecorationSet.create(state.doc, [
|
|
18358
18329
|
Decoration.inline(range.from, range.to, {
|
|
18359
18330
|
nodeName: decorationTag,
|
|
18360
18331
|
class: classNames.join(" "),
|
|
@@ -18403,9 +18374,9 @@ function getSuggestionOptions({
|
|
|
18403
18374
|
]).run();
|
|
18404
18375
|
(_c = (_b = editor.view.dom.ownerDocument.defaultView) == null ? void 0 : _b.getSelection()) == null ? void 0 : _c.collapseToEnd();
|
|
18405
18376
|
},
|
|
18406
|
-
allow: ({ state
|
|
18407
|
-
const $from =
|
|
18408
|
-
const type =
|
|
18377
|
+
allow: ({ state, range }) => {
|
|
18378
|
+
const $from = state.doc.resolve(range.from);
|
|
18379
|
+
const type = state.schema.nodes[extensionName];
|
|
18409
18380
|
const allow = !!$from.parent.type.contentMatch.matchType(type);
|
|
18410
18381
|
return allow;
|
|
18411
18382
|
},
|
|
@@ -18574,16 +18545,16 @@ var Mention = Node3.create({
|
|
|
18574
18545
|
},
|
|
18575
18546
|
addKeyboardShortcuts() {
|
|
18576
18547
|
return {
|
|
18577
|
-
Backspace: () => this.editor.commands.command(({ tr: tr2, state
|
|
18548
|
+
Backspace: () => this.editor.commands.command(({ tr: tr2, state }) => {
|
|
18578
18549
|
let isMention = false;
|
|
18579
|
-
const { selection } =
|
|
18550
|
+
const { selection } = state;
|
|
18580
18551
|
const { empty: empty2, anchor } = selection;
|
|
18581
18552
|
if (!empty2) {
|
|
18582
18553
|
return false;
|
|
18583
18554
|
}
|
|
18584
18555
|
let mentionNode = new Node2();
|
|
18585
18556
|
let mentionPos = 0;
|
|
18586
|
-
|
|
18557
|
+
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
18587
18558
|
if (node.type.name === this.name) {
|
|
18588
18559
|
isMention = true;
|
|
18589
18560
|
mentionNode = node;
|
|
@@ -18825,142 +18796,6 @@ var TopicAssetMention = index_default.extend({
|
|
|
18825
18796
|
}
|
|
18826
18797
|
});
|
|
18827
18798
|
|
|
18828
|
-
// src/chat/runtime/composer-channels.ts
|
|
18829
|
-
import { normalizeTopicAssetRefs as normalizeTopicAssetRefs2 } from "@blade-hq/agent-client";
|
|
18830
|
-
import { useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
18831
|
-
function buildSignalId() {
|
|
18832
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
18833
|
-
return crypto.randomUUID();
|
|
18834
|
-
}
|
|
18835
|
-
return `bridge-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
18836
|
-
}
|
|
18837
|
-
function withoutKey(record, key) {
|
|
18838
|
-
if (!(key in record)) return record;
|
|
18839
|
-
const next = { ...record };
|
|
18840
|
-
delete next[key];
|
|
18841
|
-
return next;
|
|
18842
|
-
}
|
|
18843
|
-
var state2 = {
|
|
18844
|
-
topicAssetReferences: {},
|
|
18845
|
-
pendingContexts: {},
|
|
18846
|
-
draftAppends: {},
|
|
18847
|
-
sendRequests: {},
|
|
18848
|
-
modelDrafts: {},
|
|
18849
|
-
rewindDrafts: {}
|
|
18850
|
-
};
|
|
18851
|
-
var listeners2 = /* @__PURE__ */ new Set();
|
|
18852
|
-
function setState(update) {
|
|
18853
|
-
const next = update(state2);
|
|
18854
|
-
if (next === state2) return;
|
|
18855
|
-
state2 = next;
|
|
18856
|
-
for (const listener of [...listeners2]) listener();
|
|
18857
|
-
}
|
|
18858
|
-
function consume(key, sessionId) {
|
|
18859
|
-
const signals = state2[key][sessionId] ?? [];
|
|
18860
|
-
if (signals.length === 0) return [];
|
|
18861
|
-
setState((current) => ({ ...current, [key]: withoutKey(current[key], sessionId) }));
|
|
18862
|
-
return signals;
|
|
18863
|
-
}
|
|
18864
|
-
var composerChannels = {
|
|
18865
|
-
getState: () => state2,
|
|
18866
|
-
addTopicAssetReference(sessionId, ref) {
|
|
18867
|
-
setState((current) => ({ ...current, topicAssetReferences: { ...current.topicAssetReferences, [sessionId]: normalizeTopicAssetRefs2([...current.topicAssetReferences[sessionId] ?? [], ref]) } }));
|
|
18868
|
-
},
|
|
18869
|
-
consumeTopicAssetReferences: (sessionId) => consume("topicAssetReferences", sessionId),
|
|
18870
|
-
subscribe(listener) {
|
|
18871
|
-
listeners2.add(listener);
|
|
18872
|
-
return () => {
|
|
18873
|
-
listeners2.delete(listener);
|
|
18874
|
-
};
|
|
18875
|
-
},
|
|
18876
|
-
addPendingContext(sessionId, context) {
|
|
18877
|
-
setState((current) => ({
|
|
18878
|
-
...current,
|
|
18879
|
-
pendingContexts: {
|
|
18880
|
-
...current.pendingContexts,
|
|
18881
|
-
[sessionId]: [
|
|
18882
|
-
...current.pendingContexts[sessionId] ?? [],
|
|
18883
|
-
{ id: buildSignalId(), label: context.label, content: context.content, imageUrl: context.imageUrl }
|
|
18884
|
-
]
|
|
18885
|
-
}
|
|
18886
|
-
}));
|
|
18887
|
-
},
|
|
18888
|
-
removePendingContext(sessionId, contextId) {
|
|
18889
|
-
setState((current) => {
|
|
18890
|
-
const contexts = current.pendingContexts[sessionId];
|
|
18891
|
-
if (!contexts?.length) return current;
|
|
18892
|
-
const next = contexts.filter((context) => context.id !== contextId);
|
|
18893
|
-
if (next.length === contexts.length) return current;
|
|
18894
|
-
return {
|
|
18895
|
-
...current,
|
|
18896
|
-
pendingContexts: next.length > 0 ? { ...current.pendingContexts, [sessionId]: next } : withoutKey(current.pendingContexts, sessionId)
|
|
18897
|
-
};
|
|
18898
|
-
});
|
|
18899
|
-
},
|
|
18900
|
-
consumePendingContexts: (sessionId) => consume("pendingContexts", sessionId),
|
|
18901
|
-
clearPendingContexts(sessionId) {
|
|
18902
|
-
setState((current) => ({ ...current, pendingContexts: withoutKey(current.pendingContexts, sessionId) }));
|
|
18903
|
-
},
|
|
18904
|
-
addDraftAppend(sessionId, text, separate) {
|
|
18905
|
-
setState((current) => ({
|
|
18906
|
-
...current,
|
|
18907
|
-
draftAppends: {
|
|
18908
|
-
...current.draftAppends,
|
|
18909
|
-
[sessionId]: [...current.draftAppends[sessionId] ?? [], { id: buildSignalId(), text, separate }]
|
|
18910
|
-
}
|
|
18911
|
-
}));
|
|
18912
|
-
},
|
|
18913
|
-
consumeDraftAppends: (sessionId) => consume("draftAppends", sessionId),
|
|
18914
|
-
clearDraftAppends(sessionId) {
|
|
18915
|
-
setState((current) => ({ ...current, draftAppends: withoutKey(current.draftAppends, sessionId) }));
|
|
18916
|
-
},
|
|
18917
|
-
addSendRequest(sessionId) {
|
|
18918
|
-
setState((current) => ({
|
|
18919
|
-
...current,
|
|
18920
|
-
sendRequests: {
|
|
18921
|
-
...current.sendRequests,
|
|
18922
|
-
[sessionId]: [...current.sendRequests[sessionId] ?? [], { id: buildSignalId() }]
|
|
18923
|
-
}
|
|
18924
|
-
}));
|
|
18925
|
-
},
|
|
18926
|
-
consumeSendRequests: (sessionId) => consume("sendRequests", sessionId),
|
|
18927
|
-
clearSendRequests(sessionId) {
|
|
18928
|
-
setState((current) => ({ ...current, sendRequests: withoutKey(current.sendRequests, sessionId) }));
|
|
18929
|
-
},
|
|
18930
|
-
setModelDraft(sessionId, model) {
|
|
18931
|
-
setState(
|
|
18932
|
-
(current) => current.modelDrafts[sessionId] === model ? current : { ...current, modelDrafts: { ...current.modelDrafts, [sessionId]: model } }
|
|
18933
|
-
);
|
|
18934
|
-
},
|
|
18935
|
-
clearModelDraft(sessionId) {
|
|
18936
|
-
setState((current) => ({ ...current, modelDrafts: withoutKey(current.modelDrafts, sessionId) }));
|
|
18937
|
-
},
|
|
18938
|
-
setRewindDraft(sessionId, text) {
|
|
18939
|
-
setState(
|
|
18940
|
-
(current) => text === null ? { ...current, rewindDrafts: withoutKey(current.rewindDrafts, sessionId) } : { ...current, rewindDrafts: { ...current.rewindDrafts, [sessionId]: text } }
|
|
18941
|
-
);
|
|
18942
|
-
},
|
|
18943
|
-
clearSession(sessionId) {
|
|
18944
|
-
setState((current) => ({
|
|
18945
|
-
...current,
|
|
18946
|
-
topicAssetReferences: withoutKey(current.topicAssetReferences, sessionId),
|
|
18947
|
-
pendingContexts: withoutKey(current.pendingContexts, sessionId),
|
|
18948
|
-
draftAppends: withoutKey(current.draftAppends, sessionId),
|
|
18949
|
-
sendRequests: withoutKey(current.sendRequests, sessionId)
|
|
18950
|
-
}));
|
|
18951
|
-
},
|
|
18952
|
-
reset() {
|
|
18953
|
-
setState(() => ({ topicAssetReferences: {}, pendingContexts: {}, draftAppends: {}, sendRequests: {}, modelDrafts: {}, rewindDrafts: {} }));
|
|
18954
|
-
}
|
|
18955
|
-
};
|
|
18956
|
-
function useComposerChannels(selector) {
|
|
18957
|
-
return useSyncExternalStore2(
|
|
18958
|
-
composerChannels.subscribe,
|
|
18959
|
-
() => selector(state2),
|
|
18960
|
-
() => selector(state2)
|
|
18961
|
-
);
|
|
18962
|
-
}
|
|
18963
|
-
|
|
18964
18799
|
// src/rich-input/lib/topic-asset-suggestions.ts
|
|
18965
18800
|
async function getTopicAssetSuggestionItems(client, topicId, query) {
|
|
18966
18801
|
if (!topicId) return [];
|
|
@@ -19083,16 +18918,16 @@ import { useDebugValue as useDebugValue2, useEffect as useEffect2, useRef as use
|
|
|
19083
18918
|
var { getOwnPropertyNames, getOwnPropertySymbols } = Object;
|
|
19084
18919
|
var { hasOwnProperty } = Object.prototype;
|
|
19085
18920
|
function combineComparators(comparatorA, comparatorB) {
|
|
19086
|
-
return function isEqual(a, b,
|
|
19087
|
-
return comparatorA(a, b,
|
|
18921
|
+
return function isEqual(a, b, state) {
|
|
18922
|
+
return comparatorA(a, b, state) && comparatorB(a, b, state);
|
|
19088
18923
|
};
|
|
19089
18924
|
}
|
|
19090
18925
|
function createIsCircular(areItemsEqual) {
|
|
19091
|
-
return function isCircular(a, b,
|
|
18926
|
+
return function isCircular(a, b, state) {
|
|
19092
18927
|
if (!a || !b || typeof a !== "object" || typeof b !== "object") {
|
|
19093
|
-
return areItemsEqual(a, b,
|
|
18928
|
+
return areItemsEqual(a, b, state);
|
|
19094
18929
|
}
|
|
19095
|
-
const { cache } =
|
|
18930
|
+
const { cache } = state;
|
|
19096
18931
|
const cachedA = cache.get(a);
|
|
19097
18932
|
const cachedB = cache.get(b);
|
|
19098
18933
|
if (cachedA && cachedB) {
|
|
@@ -19100,7 +18935,7 @@ function createIsCircular(areItemsEqual) {
|
|
|
19100
18935
|
}
|
|
19101
18936
|
cache.set(a, b);
|
|
19102
18937
|
cache.set(b, a);
|
|
19103
|
-
const result = areItemsEqual(a, b,
|
|
18938
|
+
const result = areItemsEqual(a, b, state);
|
|
19104
18939
|
cache.delete(a);
|
|
19105
18940
|
cache.delete(b);
|
|
19106
18941
|
return result;
|
|
@@ -19126,13 +18961,13 @@ var { getOwnPropertyDescriptor, keys: keys2 } = Object;
|
|
|
19126
18961
|
function areArrayBuffersEqual(a, b) {
|
|
19127
18962
|
return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a), new Uint8Array(b));
|
|
19128
18963
|
}
|
|
19129
|
-
function areArraysEqual(a, b,
|
|
18964
|
+
function areArraysEqual(a, b, state) {
|
|
19130
18965
|
let index = a.length;
|
|
19131
18966
|
if (b.length !== index) {
|
|
19132
18967
|
return false;
|
|
19133
18968
|
}
|
|
19134
18969
|
while (index-- > 0) {
|
|
19135
|
-
if (!
|
|
18970
|
+
if (!state.equals(a[index], b[index], index, index, a, b, state)) {
|
|
19136
18971
|
return false;
|
|
19137
18972
|
}
|
|
19138
18973
|
}
|
|
@@ -19150,7 +18985,7 @@ function areErrorsEqual(a, b) {
|
|
|
19150
18985
|
function areFunctionsEqual(a, b) {
|
|
19151
18986
|
return a === b;
|
|
19152
18987
|
}
|
|
19153
|
-
function areMapsEqual(a, b,
|
|
18988
|
+
function areMapsEqual(a, b, state) {
|
|
19154
18989
|
const size = a.size;
|
|
19155
18990
|
if (size !== b.size) {
|
|
19156
18991
|
return false;
|
|
@@ -19180,7 +19015,7 @@ function areMapsEqual(a, b, state3) {
|
|
|
19180
19015
|
}
|
|
19181
19016
|
const aEntry = aResult.value;
|
|
19182
19017
|
const bEntry = bResult.value;
|
|
19183
|
-
if (
|
|
19018
|
+
if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state) && state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {
|
|
19184
19019
|
hasMatch = matchedIndices[matchIndex] = true;
|
|
19185
19020
|
break;
|
|
19186
19021
|
}
|
|
@@ -19194,20 +19029,20 @@ function areMapsEqual(a, b, state3) {
|
|
|
19194
19029
|
return true;
|
|
19195
19030
|
}
|
|
19196
19031
|
var areNumbersEqual = sameValueZeroEqual;
|
|
19197
|
-
function areObjectsEqual(a, b,
|
|
19032
|
+
function areObjectsEqual(a, b, state) {
|
|
19198
19033
|
const properties = keys2(a);
|
|
19199
19034
|
let index = properties.length;
|
|
19200
19035
|
if (keys2(b).length !== index) {
|
|
19201
19036
|
return false;
|
|
19202
19037
|
}
|
|
19203
19038
|
while (index-- > 0) {
|
|
19204
|
-
if (!isPropertyEqual(a, b,
|
|
19039
|
+
if (!isPropertyEqual(a, b, state, properties[index])) {
|
|
19205
19040
|
return false;
|
|
19206
19041
|
}
|
|
19207
19042
|
}
|
|
19208
19043
|
return true;
|
|
19209
19044
|
}
|
|
19210
|
-
function areObjectsEqualStrict(a, b,
|
|
19045
|
+
function areObjectsEqualStrict(a, b, state) {
|
|
19211
19046
|
const properties = getStrictProperties(a);
|
|
19212
19047
|
let index = properties.length;
|
|
19213
19048
|
if (getStrictProperties(b).length !== index) {
|
|
@@ -19218,7 +19053,7 @@ function areObjectsEqualStrict(a, b, state3) {
|
|
|
19218
19053
|
let descriptorB;
|
|
19219
19054
|
while (index-- > 0) {
|
|
19220
19055
|
property = properties[index];
|
|
19221
|
-
if (!isPropertyEqual(a, b,
|
|
19056
|
+
if (!isPropertyEqual(a, b, state, property)) {
|
|
19222
19057
|
return false;
|
|
19223
19058
|
}
|
|
19224
19059
|
descriptorA = getOwnPropertyDescriptor(a, property);
|
|
@@ -19235,7 +19070,7 @@ function arePrimitiveWrappersEqual(a, b) {
|
|
|
19235
19070
|
function areRegExpsEqual(a, b) {
|
|
19236
19071
|
return a.source === b.source && a.flags === b.flags;
|
|
19237
19072
|
}
|
|
19238
|
-
function areSetsEqual(a, b,
|
|
19073
|
+
function areSetsEqual(a, b, state) {
|
|
19239
19074
|
const size = a.size;
|
|
19240
19075
|
if (size !== b.size) {
|
|
19241
19076
|
return false;
|
|
@@ -19258,7 +19093,7 @@ function areSetsEqual(a, b, state3) {
|
|
|
19258
19093
|
if (bResult.done) {
|
|
19259
19094
|
break;
|
|
19260
19095
|
}
|
|
19261
|
-
if (!matchedIndices[matchIndex] &&
|
|
19096
|
+
if (!matchedIndices[matchIndex] && state.equals(aResult.value, bResult.value, aResult.value, bResult.value, a, b, state)) {
|
|
19262
19097
|
hasMatch = matchedIndices[matchIndex] = true;
|
|
19263
19098
|
break;
|
|
19264
19099
|
}
|
|
@@ -19285,11 +19120,11 @@ function areTypedArraysEqual(a, b) {
|
|
|
19285
19120
|
function areUrlsEqual(a, b) {
|
|
19286
19121
|
return a.hostname === b.hostname && a.pathname === b.pathname && a.protocol === b.protocol && a.port === b.port && a.hash === b.hash && a.username === b.username && a.password === b.password;
|
|
19287
19122
|
}
|
|
19288
|
-
function isPropertyEqual(a, b,
|
|
19123
|
+
function isPropertyEqual(a, b, state, property) {
|
|
19289
19124
|
if ((property === REACT_OWNER || property === PREACT_OWNER || property === PREACT_VNODE) && (a.$$typeof || b.$$typeof)) {
|
|
19290
19125
|
return true;
|
|
19291
19126
|
}
|
|
19292
|
-
return hasOwn(b, property) &&
|
|
19127
|
+
return hasOwn(b, property) && state.equals(a[property], b[property], property, property, a, b, state);
|
|
19293
19128
|
}
|
|
19294
19129
|
var ARRAY_BUFFER_TAG = "[object ArrayBuffer]";
|
|
19295
19130
|
var ARGUMENTS_TAG = "[object Arguments]";
|
|
@@ -19320,7 +19155,7 @@ var TYPED_ARRAY_TAGS = {
|
|
|
19320
19155
|
var URL_TAG = "[object URL]";
|
|
19321
19156
|
var toString = Object.prototype.toString;
|
|
19322
19157
|
function createEqualityComparator({ areArrayBuffersEqual: areArrayBuffersEqual2, areArraysEqual: areArraysEqual2, areDataViewsEqual: areDataViewsEqual2, areDatesEqual: areDatesEqual2, areErrorsEqual: areErrorsEqual2, areFunctionsEqual: areFunctionsEqual2, areMapsEqual: areMapsEqual2, areNumbersEqual: areNumbersEqual2, areObjectsEqual: areObjectsEqual2, arePrimitiveWrappersEqual: arePrimitiveWrappersEqual2, areRegExpsEqual: areRegExpsEqual2, areSetsEqual: areSetsEqual2, areTypedArraysEqual: areTypedArraysEqual2, areUrlsEqual: areUrlsEqual2, unknownTagComparators }) {
|
|
19323
|
-
return function comparator(a, b,
|
|
19158
|
+
return function comparator(a, b, state) {
|
|
19324
19159
|
if (a === b) {
|
|
19325
19160
|
return true;
|
|
19326
19161
|
}
|
|
@@ -19333,10 +19168,10 @@ function createEqualityComparator({ areArrayBuffersEqual: areArrayBuffersEqual2,
|
|
|
19333
19168
|
}
|
|
19334
19169
|
if (type !== "object") {
|
|
19335
19170
|
if (type === "number") {
|
|
19336
|
-
return areNumbersEqual2(a, b,
|
|
19171
|
+
return areNumbersEqual2(a, b, state);
|
|
19337
19172
|
}
|
|
19338
19173
|
if (type === "function") {
|
|
19339
|
-
return areFunctionsEqual2(a, b,
|
|
19174
|
+
return areFunctionsEqual2(a, b, state);
|
|
19340
19175
|
}
|
|
19341
19176
|
return false;
|
|
19342
19177
|
}
|
|
@@ -19345,59 +19180,59 @@ function createEqualityComparator({ areArrayBuffersEqual: areArrayBuffersEqual2,
|
|
|
19345
19180
|
return false;
|
|
19346
19181
|
}
|
|
19347
19182
|
if (constructor === Object) {
|
|
19348
|
-
return areObjectsEqual2(a, b,
|
|
19183
|
+
return areObjectsEqual2(a, b, state);
|
|
19349
19184
|
}
|
|
19350
19185
|
if (Array.isArray(a)) {
|
|
19351
|
-
return areArraysEqual2(a, b,
|
|
19186
|
+
return areArraysEqual2(a, b, state);
|
|
19352
19187
|
}
|
|
19353
19188
|
if (constructor === Date) {
|
|
19354
|
-
return areDatesEqual2(a, b,
|
|
19189
|
+
return areDatesEqual2(a, b, state);
|
|
19355
19190
|
}
|
|
19356
19191
|
if (constructor === RegExp) {
|
|
19357
|
-
return areRegExpsEqual2(a, b,
|
|
19192
|
+
return areRegExpsEqual2(a, b, state);
|
|
19358
19193
|
}
|
|
19359
19194
|
if (constructor === Map) {
|
|
19360
|
-
return areMapsEqual2(a, b,
|
|
19195
|
+
return areMapsEqual2(a, b, state);
|
|
19361
19196
|
}
|
|
19362
19197
|
if (constructor === Set) {
|
|
19363
|
-
return areSetsEqual2(a, b,
|
|
19198
|
+
return areSetsEqual2(a, b, state);
|
|
19364
19199
|
}
|
|
19365
19200
|
const tag = toString.call(a);
|
|
19366
19201
|
if (tag === DATE_TAG) {
|
|
19367
|
-
return areDatesEqual2(a, b,
|
|
19202
|
+
return areDatesEqual2(a, b, state);
|
|
19368
19203
|
}
|
|
19369
19204
|
if (tag === REG_EXP_TAG) {
|
|
19370
|
-
return areRegExpsEqual2(a, b,
|
|
19205
|
+
return areRegExpsEqual2(a, b, state);
|
|
19371
19206
|
}
|
|
19372
19207
|
if (tag === MAP_TAG) {
|
|
19373
|
-
return areMapsEqual2(a, b,
|
|
19208
|
+
return areMapsEqual2(a, b, state);
|
|
19374
19209
|
}
|
|
19375
19210
|
if (tag === SET_TAG) {
|
|
19376
|
-
return areSetsEqual2(a, b,
|
|
19211
|
+
return areSetsEqual2(a, b, state);
|
|
19377
19212
|
}
|
|
19378
19213
|
if (tag === OBJECT_TAG) {
|
|
19379
|
-
return typeof a.then !== "function" && typeof b.then !== "function" && areObjectsEqual2(a, b,
|
|
19214
|
+
return typeof a.then !== "function" && typeof b.then !== "function" && areObjectsEqual2(a, b, state);
|
|
19380
19215
|
}
|
|
19381
19216
|
if (tag === URL_TAG) {
|
|
19382
|
-
return areUrlsEqual2(a, b,
|
|
19217
|
+
return areUrlsEqual2(a, b, state);
|
|
19383
19218
|
}
|
|
19384
19219
|
if (tag === ERROR_TAG) {
|
|
19385
|
-
return areErrorsEqual2(a, b,
|
|
19220
|
+
return areErrorsEqual2(a, b, state);
|
|
19386
19221
|
}
|
|
19387
19222
|
if (tag === ARGUMENTS_TAG) {
|
|
19388
|
-
return areObjectsEqual2(a, b,
|
|
19223
|
+
return areObjectsEqual2(a, b, state);
|
|
19389
19224
|
}
|
|
19390
19225
|
if (TYPED_ARRAY_TAGS[tag]) {
|
|
19391
|
-
return areTypedArraysEqual2(a, b,
|
|
19226
|
+
return areTypedArraysEqual2(a, b, state);
|
|
19392
19227
|
}
|
|
19393
19228
|
if (tag === ARRAY_BUFFER_TAG) {
|
|
19394
|
-
return areArrayBuffersEqual2(a, b,
|
|
19229
|
+
return areArrayBuffersEqual2(a, b, state);
|
|
19395
19230
|
}
|
|
19396
19231
|
if (tag === DATA_VIEW_TAG) {
|
|
19397
|
-
return areDataViewsEqual2(a, b,
|
|
19232
|
+
return areDataViewsEqual2(a, b, state);
|
|
19398
19233
|
}
|
|
19399
19234
|
if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {
|
|
19400
|
-
return arePrimitiveWrappersEqual2(a, b,
|
|
19235
|
+
return arePrimitiveWrappersEqual2(a, b, state);
|
|
19401
19236
|
}
|
|
19402
19237
|
if (unknownTagComparators) {
|
|
19403
19238
|
let unknownTagComparator = unknownTagComparators[tag];
|
|
@@ -19408,7 +19243,7 @@ function createEqualityComparator({ areArrayBuffersEqual: areArrayBuffersEqual2,
|
|
|
19408
19243
|
}
|
|
19409
19244
|
}
|
|
19410
19245
|
if (unknownTagComparator) {
|
|
19411
|
-
return unknownTagComparator(a, b,
|
|
19246
|
+
return unknownTagComparator(a, b, state);
|
|
19412
19247
|
}
|
|
19413
19248
|
}
|
|
19414
19249
|
return false;
|
|
@@ -19450,8 +19285,8 @@ function createEqualityComparatorConfig({ circular, createCustomConfig, strict }
|
|
|
19450
19285
|
return config;
|
|
19451
19286
|
}
|
|
19452
19287
|
function createInternalEqualityComparator(compare) {
|
|
19453
|
-
return function(a, b, _indexOrKeyA, _indexOrKeyB, _parentA, _parentB,
|
|
19454
|
-
return compare(a, b,
|
|
19288
|
+
return function(a, b, _indexOrKeyA, _indexOrKeyB, _parentA, _parentB, state) {
|
|
19289
|
+
return compare(a, b, state);
|
|
19455
19290
|
};
|
|
19456
19291
|
}
|
|
19457
19292
|
function createIsEqual({ circular, comparator, createState, equals, strict }) {
|
|
@@ -19476,14 +19311,14 @@ function createIsEqual({ circular, comparator, createState, equals, strict }) {
|
|
|
19476
19311
|
});
|
|
19477
19312
|
};
|
|
19478
19313
|
}
|
|
19479
|
-
const
|
|
19314
|
+
const state = {
|
|
19480
19315
|
cache: void 0,
|
|
19481
19316
|
equals,
|
|
19482
19317
|
meta: void 0,
|
|
19483
19318
|
strict
|
|
19484
19319
|
};
|
|
19485
19320
|
return function isEqual(a, b) {
|
|
19486
|
-
return comparator(a, b,
|
|
19321
|
+
return comparator(a, b, state);
|
|
19487
19322
|
};
|
|
19488
19323
|
}
|
|
19489
19324
|
var deepEqual = createCustomEqual();
|
|
@@ -20457,8 +20292,8 @@ var CodeBlock = Node3.create({
|
|
|
20457
20292
|
return false;
|
|
20458
20293
|
}
|
|
20459
20294
|
const tabSize = (_a = this.options.tabSize) != null ? _a : DEFAULT_TAB_SIZE;
|
|
20460
|
-
const { state
|
|
20461
|
-
const { selection } =
|
|
20295
|
+
const { state } = editor;
|
|
20296
|
+
const { selection } = state;
|
|
20462
20297
|
const { $from, empty: empty2 } = selection;
|
|
20463
20298
|
if ($from.parent.type !== this.type) {
|
|
20464
20299
|
return false;
|
|
@@ -20469,10 +20304,10 @@ var CodeBlock = Node3.create({
|
|
|
20469
20304
|
}
|
|
20470
20305
|
return editor.commands.command(({ tr: tr2 }) => {
|
|
20471
20306
|
const { from: from2, to } = selection;
|
|
20472
|
-
const text =
|
|
20307
|
+
const text = state.doc.textBetween(from2, to, "\n", "\n");
|
|
20473
20308
|
const lines = text.split("\n");
|
|
20474
20309
|
const indentedText = lines.map((line) => indent + line).join("\n");
|
|
20475
|
-
tr2.replaceWith(from2, to,
|
|
20310
|
+
tr2.replaceWith(from2, to, state.schema.text(indentedText));
|
|
20476
20311
|
return true;
|
|
20477
20312
|
});
|
|
20478
20313
|
},
|
|
@@ -20483,8 +20318,8 @@ var CodeBlock = Node3.create({
|
|
|
20483
20318
|
return false;
|
|
20484
20319
|
}
|
|
20485
20320
|
const tabSize = (_a = this.options.tabSize) != null ? _a : DEFAULT_TAB_SIZE;
|
|
20486
|
-
const { state
|
|
20487
|
-
const { selection } =
|
|
20321
|
+
const { state } = editor;
|
|
20322
|
+
const { selection } = state;
|
|
20488
20323
|
const { $from, empty: empty2 } = selection;
|
|
20489
20324
|
if ($from.parent.type !== this.type) {
|
|
20490
20325
|
return false;
|
|
@@ -20495,7 +20330,7 @@ var CodeBlock = Node3.create({
|
|
|
20495
20330
|
const { pos } = $from;
|
|
20496
20331
|
const codeBlockStart = $from.start();
|
|
20497
20332
|
const codeBlockEnd = $from.end();
|
|
20498
|
-
const allText =
|
|
20333
|
+
const allText = state.doc.textBetween(codeBlockStart, codeBlockEnd, "\n", "\n");
|
|
20499
20334
|
const lines = allText.split("\n");
|
|
20500
20335
|
let currentLineIndex = 0;
|
|
20501
20336
|
let charCount = 0;
|
|
@@ -20527,7 +20362,7 @@ var CodeBlock = Node3.create({
|
|
|
20527
20362
|
}
|
|
20528
20363
|
return editor.commands.command(({ tr: tr2 }) => {
|
|
20529
20364
|
const { from: from2, to } = selection;
|
|
20530
|
-
const text =
|
|
20365
|
+
const text = state.doc.textBetween(from2, to, "\n", "\n");
|
|
20531
20366
|
const lines = text.split("\n");
|
|
20532
20367
|
const reverseIndentText = lines.map((line) => {
|
|
20533
20368
|
var _a2;
|
|
@@ -20535,7 +20370,7 @@ var CodeBlock = Node3.create({
|
|
|
20535
20370
|
const spacesToRemove = Math.min(leadingSpaces.length, tabSize);
|
|
20536
20371
|
return line.slice(spacesToRemove);
|
|
20537
20372
|
}).join("\n");
|
|
20538
|
-
tr2.replaceWith(from2, to,
|
|
20373
|
+
tr2.replaceWith(from2, to, state.schema.text(reverseIndentText));
|
|
20539
20374
|
return true;
|
|
20540
20375
|
});
|
|
20541
20376
|
},
|
|
@@ -20544,8 +20379,8 @@ var CodeBlock = Node3.create({
|
|
|
20544
20379
|
if (!this.options.exitOnTripleEnter) {
|
|
20545
20380
|
return false;
|
|
20546
20381
|
}
|
|
20547
|
-
const { state
|
|
20548
|
-
const { selection } =
|
|
20382
|
+
const { state } = editor;
|
|
20383
|
+
const { selection } = state;
|
|
20549
20384
|
const { $from, empty: empty2 } = selection;
|
|
20550
20385
|
if (!empty2 || $from.parent.type !== this.type) {
|
|
20551
20386
|
return false;
|
|
@@ -20565,8 +20400,8 @@ var CodeBlock = Node3.create({
|
|
|
20565
20400
|
if (!this.options.exitOnArrowDown) {
|
|
20566
20401
|
return false;
|
|
20567
20402
|
}
|
|
20568
|
-
const { state
|
|
20569
|
-
const { selection, doc: doc3 } =
|
|
20403
|
+
const { state } = editor;
|
|
20404
|
+
const { selection, doc: doc3 } = state;
|
|
20570
20405
|
const { $from, empty: empty2 } = selection;
|
|
20571
20406
|
if (!empty2 || $from.parent.type !== this.type) {
|
|
20572
20407
|
return false;
|
|
@@ -20690,11 +20525,11 @@ var HardBreak = Node3.create({
|
|
|
20690
20525
|
},
|
|
20691
20526
|
addCommands() {
|
|
20692
20527
|
return {
|
|
20693
|
-
setHardBreak: () => ({ commands, chain, state
|
|
20528
|
+
setHardBreak: () => ({ commands, chain, state, editor }) => {
|
|
20694
20529
|
return commands.first([
|
|
20695
20530
|
() => commands.exitCode(),
|
|
20696
20531
|
() => commands.command(() => {
|
|
20697
|
-
const { selection, storedMarks } =
|
|
20532
|
+
const { selection, storedMarks } = state;
|
|
20698
20533
|
if (selection.$from.parent.type.spec.isolating) {
|
|
20699
20534
|
return false;
|
|
20700
20535
|
}
|
|
@@ -20829,11 +20664,11 @@ var HorizontalRule = Node3.create({
|
|
|
20829
20664
|
},
|
|
20830
20665
|
addCommands() {
|
|
20831
20666
|
return {
|
|
20832
|
-
setHorizontalRule: () => ({ chain, state
|
|
20833
|
-
if (!canInsertNode(
|
|
20667
|
+
setHorizontalRule: () => ({ chain, state }) => {
|
|
20668
|
+
if (!canInsertNode(state, state.schema.nodes[this.name])) {
|
|
20834
20669
|
return false;
|
|
20835
20670
|
}
|
|
20836
|
-
const { selection } =
|
|
20671
|
+
const { selection } = state;
|
|
20837
20672
|
const { $to: $originTo } = selection;
|
|
20838
20673
|
const currentChain = chain();
|
|
20839
20674
|
if (isNodeSelection(selection)) {
|
|
@@ -21045,19 +20880,19 @@ State.prototype = {
|
|
|
21045
20880
|
* @returns {?State<T>} the next state, if any
|
|
21046
20881
|
*/
|
|
21047
20882
|
go(input) {
|
|
21048
|
-
const
|
|
21049
|
-
const nextState =
|
|
20883
|
+
const state = this;
|
|
20884
|
+
const nextState = state.j[input];
|
|
21050
20885
|
if (nextState) {
|
|
21051
20886
|
return nextState;
|
|
21052
20887
|
}
|
|
21053
|
-
for (let i = 0; i <
|
|
21054
|
-
const regex =
|
|
21055
|
-
const nextState2 =
|
|
20888
|
+
for (let i = 0; i < state.jr.length; i++) {
|
|
20889
|
+
const regex = state.jr[i][0];
|
|
20890
|
+
const nextState2 = state.jr[i][1];
|
|
21056
20891
|
if (nextState2 && regex.test(input)) {
|
|
21057
20892
|
return nextState2;
|
|
21058
20893
|
}
|
|
21059
20894
|
}
|
|
21060
|
-
return
|
|
20895
|
+
return state.jd;
|
|
21061
20896
|
},
|
|
21062
20897
|
/**
|
|
21063
20898
|
* Whether the state has a transition for the given input. Set the second
|
|
@@ -21116,15 +20951,15 @@ State.prototype = {
|
|
|
21116
20951
|
* @returns {State<T>} taken after the given input
|
|
21117
20952
|
*/
|
|
21118
20953
|
ts(input, next, flags, groups) {
|
|
21119
|
-
let
|
|
20954
|
+
let state = this;
|
|
21120
20955
|
const len = input.length;
|
|
21121
20956
|
if (!len) {
|
|
21122
|
-
return
|
|
20957
|
+
return state;
|
|
21123
20958
|
}
|
|
21124
20959
|
for (let i = 0; i < len - 1; i++) {
|
|
21125
|
-
|
|
20960
|
+
state = state.tt(input[i]);
|
|
21126
20961
|
}
|
|
21127
|
-
return
|
|
20962
|
+
return state.tt(input[len - 1], next, flags, groups);
|
|
21128
20963
|
},
|
|
21129
20964
|
/**
|
|
21130
20965
|
* Short for "take transition", this is a method for building/working with
|
|
@@ -21154,13 +20989,13 @@ State.prototype = {
|
|
|
21154
20989
|
*/
|
|
21155
20990
|
tt(input, next, flags, groups) {
|
|
21156
20991
|
groups = groups || State.groups;
|
|
21157
|
-
const
|
|
20992
|
+
const state = this;
|
|
21158
20993
|
if (next && next.j) {
|
|
21159
|
-
|
|
20994
|
+
state.j[input] = next;
|
|
21160
20995
|
return next;
|
|
21161
20996
|
}
|
|
21162
20997
|
const t = next;
|
|
21163
|
-
let nextState, templateState =
|
|
20998
|
+
let nextState, templateState = state.go(input);
|
|
21164
20999
|
if (templateState) {
|
|
21165
21000
|
nextState = new State();
|
|
21166
21001
|
Object.assign(nextState.j, templateState.j);
|
|
@@ -21181,14 +21016,14 @@ State.prototype = {
|
|
|
21181
21016
|
}
|
|
21182
21017
|
nextState.t = t;
|
|
21183
21018
|
}
|
|
21184
|
-
|
|
21019
|
+
state.j[input] = nextState;
|
|
21185
21020
|
return nextState;
|
|
21186
21021
|
}
|
|
21187
21022
|
};
|
|
21188
|
-
var ta = (
|
|
21189
|
-
var tr = (
|
|
21190
|
-
var ts = (
|
|
21191
|
-
var tt = (
|
|
21023
|
+
var ta = (state, input, next, flags, groups) => state.ta(input, next, flags, groups);
|
|
21024
|
+
var tr = (state, regexp, next, flags, groups) => state.tr(regexp, next, flags, groups);
|
|
21025
|
+
var ts = (state, input, next, flags, groups) => state.ts(input, next, flags, groups);
|
|
21026
|
+
var tt = (state, input, next, flags, groups) => state.tt(input, next, flags, groups);
|
|
21192
21027
|
var WORD = "WORD";
|
|
21193
21028
|
var UWORD = "UWORD";
|
|
21194
21029
|
var ASCIINUMERICAL = "ASCIINUMERICAL";
|
|
@@ -21485,18 +21320,18 @@ function run$1(start, str) {
|
|
|
21485
21320
|
let cursor = 0;
|
|
21486
21321
|
let charCursor = 0;
|
|
21487
21322
|
while (charCursor < charCount) {
|
|
21488
|
-
let
|
|
21323
|
+
let state = start;
|
|
21489
21324
|
let nextState = null;
|
|
21490
21325
|
let tokenLength = 0;
|
|
21491
21326
|
let latestAccepting = null;
|
|
21492
21327
|
let sinceAccepts = -1;
|
|
21493
21328
|
let charsSinceAccepts = -1;
|
|
21494
|
-
while (charCursor < charCount && (nextState =
|
|
21495
|
-
|
|
21496
|
-
if (
|
|
21329
|
+
while (charCursor < charCount && (nextState = state.go(iterable[charCursor]))) {
|
|
21330
|
+
state = nextState;
|
|
21331
|
+
if (state.accepts()) {
|
|
21497
21332
|
sinceAccepts = 0;
|
|
21498
21333
|
charsSinceAccepts = 0;
|
|
21499
|
-
latestAccepting =
|
|
21334
|
+
latestAccepting = state;
|
|
21500
21335
|
} else if (sinceAccepts >= 0) {
|
|
21501
21336
|
sinceAccepts += iterable[charCursor].length;
|
|
21502
21337
|
charsSinceAccepts++;
|
|
@@ -21534,23 +21369,23 @@ function stringToArray(str) {
|
|
|
21534
21369
|
}
|
|
21535
21370
|
return result;
|
|
21536
21371
|
}
|
|
21537
|
-
function fastts(
|
|
21372
|
+
function fastts(state, input, t, defaultt, jr) {
|
|
21538
21373
|
let next;
|
|
21539
21374
|
const len = input.length;
|
|
21540
21375
|
for (let i = 0; i < len - 1; i++) {
|
|
21541
21376
|
const char = input[i];
|
|
21542
|
-
if (
|
|
21543
|
-
next =
|
|
21377
|
+
if (state.j[char]) {
|
|
21378
|
+
next = state.j[char];
|
|
21544
21379
|
} else {
|
|
21545
21380
|
next = new State(defaultt);
|
|
21546
21381
|
next.jr = jr.slice();
|
|
21547
|
-
|
|
21382
|
+
state.j[char] = next;
|
|
21548
21383
|
}
|
|
21549
|
-
|
|
21384
|
+
state = next;
|
|
21550
21385
|
}
|
|
21551
21386
|
next = new State(t);
|
|
21552
21387
|
next.jr = jr.slice();
|
|
21553
|
-
|
|
21388
|
+
state.j[input[len - 1]] = next;
|
|
21554
21389
|
return next;
|
|
21555
21390
|
}
|
|
21556
21391
|
function decodeTlds(encoded) {
|
|
@@ -21993,21 +21828,21 @@ function run3(start, input, tokens) {
|
|
|
21993
21828
|
let multis = [];
|
|
21994
21829
|
let textTokens = [];
|
|
21995
21830
|
while (cursor < len) {
|
|
21996
|
-
let
|
|
21831
|
+
let state = start;
|
|
21997
21832
|
let secondState = null;
|
|
21998
21833
|
let nextState = null;
|
|
21999
21834
|
let multiLength = 0;
|
|
22000
21835
|
let latestAccepting = null;
|
|
22001
21836
|
let sinceAccepts = -1;
|
|
22002
|
-
while (cursor < len && !(secondState =
|
|
21837
|
+
while (cursor < len && !(secondState = state.go(tokens[cursor].t))) {
|
|
22003
21838
|
textTokens.push(tokens[cursor++]);
|
|
22004
21839
|
}
|
|
22005
|
-
while (cursor < len && (nextState = secondState ||
|
|
21840
|
+
while (cursor < len && (nextState = secondState || state.go(tokens[cursor].t))) {
|
|
22006
21841
|
secondState = null;
|
|
22007
|
-
|
|
22008
|
-
if (
|
|
21842
|
+
state = nextState;
|
|
21843
|
+
if (state.accepts()) {
|
|
22009
21844
|
sinceAccepts = 0;
|
|
22010
|
-
latestAccepting =
|
|
21845
|
+
latestAccepting = state;
|
|
22011
21846
|
} else if (sinceAccepts >= 0) {
|
|
22012
21847
|
sinceAccepts++;
|
|
22013
21848
|
}
|
|
@@ -22264,8 +22099,8 @@ function pasteHandler(options) {
|
|
|
22264
22099
|
props: {
|
|
22265
22100
|
handlePaste: (view, _event, slice2) => {
|
|
22266
22101
|
const { shouldAutoLink } = options;
|
|
22267
|
-
const { state
|
|
22268
|
-
const { selection } =
|
|
22102
|
+
const { state } = view;
|
|
22103
|
+
const { selection } = state;
|
|
22269
22104
|
const { empty: empty2 } = selection;
|
|
22270
22105
|
if (empty2) {
|
|
22271
22106
|
return false;
|
|
@@ -22723,9 +22558,9 @@ __export2(listHelpers_exports, {
|
|
|
22723
22558
|
nextListIsDeeper: () => nextListIsDeeper,
|
|
22724
22559
|
nextListIsHigher: () => nextListIsHigher
|
|
22725
22560
|
});
|
|
22726
|
-
var findListItemPos = (typeOrName,
|
|
22727
|
-
const { $from } =
|
|
22728
|
-
const nodeType = getNodeType(typeOrName,
|
|
22561
|
+
var findListItemPos = (typeOrName, state) => {
|
|
22562
|
+
const { $from } = state.selection;
|
|
22563
|
+
const nodeType = getNodeType(typeOrName, state.schema);
|
|
22729
22564
|
let currentNode = null;
|
|
22730
22565
|
let currentDepth = $from.depth;
|
|
22731
22566
|
let currentPos = $from.pos;
|
|
@@ -22742,14 +22577,14 @@ var findListItemPos = (typeOrName, state3) => {
|
|
|
22742
22577
|
if (targetDepth === null) {
|
|
22743
22578
|
return null;
|
|
22744
22579
|
}
|
|
22745
|
-
return { $pos:
|
|
22580
|
+
return { $pos: state.doc.resolve(currentPos), depth: targetDepth };
|
|
22746
22581
|
};
|
|
22747
|
-
var getNextListDepth = (typeOrName,
|
|
22748
|
-
const listItemPos = findListItemPos(typeOrName,
|
|
22582
|
+
var getNextListDepth = (typeOrName, state) => {
|
|
22583
|
+
const listItemPos = findListItemPos(typeOrName, state);
|
|
22749
22584
|
if (!listItemPos) {
|
|
22750
22585
|
return false;
|
|
22751
22586
|
}
|
|
22752
|
-
const [, depth] = getNodeAtPosition(
|
|
22587
|
+
const [, depth] = getNodeAtPosition(state, typeOrName, listItemPos.$pos.pos + 4);
|
|
22753
22588
|
return depth;
|
|
22754
22589
|
};
|
|
22755
22590
|
var hasListBefore = (editorState, name, parentListTypes) => {
|
|
@@ -22761,10 +22596,10 @@ var hasListBefore = (editorState, name, parentListTypes) => {
|
|
|
22761
22596
|
}
|
|
22762
22597
|
return true;
|
|
22763
22598
|
};
|
|
22764
|
-
var hasListItemBefore = (typeOrName,
|
|
22599
|
+
var hasListItemBefore = (typeOrName, state) => {
|
|
22765
22600
|
var _a;
|
|
22766
|
-
const { $anchor } =
|
|
22767
|
-
const $targetPos =
|
|
22601
|
+
const { $anchor } = state.selection;
|
|
22602
|
+
const $targetPos = state.doc.resolve($anchor.pos - 2);
|
|
22768
22603
|
if ($targetPos.index() === 0) {
|
|
22769
22604
|
return false;
|
|
22770
22605
|
}
|
|
@@ -22773,11 +22608,11 @@ var hasListItemBefore = (typeOrName, state3) => {
|
|
|
22773
22608
|
}
|
|
22774
22609
|
return true;
|
|
22775
22610
|
};
|
|
22776
|
-
var listItemHasSubList = (typeOrName,
|
|
22611
|
+
var listItemHasSubList = (typeOrName, state, node) => {
|
|
22777
22612
|
if (!node) {
|
|
22778
22613
|
return false;
|
|
22779
22614
|
}
|
|
22780
|
-
const nodeType = getNodeType(typeOrName,
|
|
22615
|
+
const nodeType = getNodeType(typeOrName, state.schema);
|
|
22781
22616
|
let hasSubList = false;
|
|
22782
22617
|
node.descendants((child) => {
|
|
22783
22618
|
if (child.type === nodeType) {
|
|
@@ -22827,9 +22662,9 @@ var handleBackspace = (editor, name, parentListTypes) => {
|
|
|
22827
22662
|
}
|
|
22828
22663
|
return editor.chain().liftListItem(name).run();
|
|
22829
22664
|
};
|
|
22830
|
-
var nextListIsDeeper = (typeOrName,
|
|
22831
|
-
const listDepth = getNextListDepth(typeOrName,
|
|
22832
|
-
const listItemPos = findListItemPos(typeOrName,
|
|
22665
|
+
var nextListIsDeeper = (typeOrName, state) => {
|
|
22666
|
+
const listDepth = getNextListDepth(typeOrName, state);
|
|
22667
|
+
const listItemPos = findListItemPos(typeOrName, state);
|
|
22833
22668
|
if (!listItemPos || !listDepth) {
|
|
22834
22669
|
return false;
|
|
22835
22670
|
}
|
|
@@ -22838,9 +22673,9 @@ var nextListIsDeeper = (typeOrName, state3) => {
|
|
|
22838
22673
|
}
|
|
22839
22674
|
return false;
|
|
22840
22675
|
};
|
|
22841
|
-
var nextListIsHigher = (typeOrName,
|
|
22842
|
-
const listDepth = getNextListDepth(typeOrName,
|
|
22843
|
-
const listItemPos = findListItemPos(typeOrName,
|
|
22676
|
+
var nextListIsHigher = (typeOrName, state) => {
|
|
22677
|
+
const listDepth = getNextListDepth(typeOrName, state);
|
|
22678
|
+
const listItemPos = findListItemPos(typeOrName, state);
|
|
22844
22679
|
if (!listItemPos || !listDepth) {
|
|
22845
22680
|
return false;
|
|
22846
22681
|
}
|
|
@@ -22869,10 +22704,10 @@ var handleDelete = (editor, name) => {
|
|
|
22869
22704
|
}
|
|
22870
22705
|
return editor.commands.joinItemForward();
|
|
22871
22706
|
};
|
|
22872
|
-
var hasListItemAfter = (typeOrName,
|
|
22707
|
+
var hasListItemAfter = (typeOrName, state) => {
|
|
22873
22708
|
var _a;
|
|
22874
|
-
const { $anchor } =
|
|
22875
|
-
const $targetPos =
|
|
22709
|
+
const { $anchor } = state.selection;
|
|
22710
|
+
const $targetPos = state.doc.resolve($anchor.pos - $anchor.parentOffset - 2);
|
|
22876
22711
|
if ($targetPos.index() === $targetPos.parent.childCount - 1) {
|
|
22877
22712
|
return false;
|
|
22878
22713
|
}
|
|
@@ -24072,20 +23907,20 @@ var handleKeyDown = keydownHandler({
|
|
|
24072
23907
|
});
|
|
24073
23908
|
function arrow(axis, dir) {
|
|
24074
23909
|
const dirStr = axis == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
|
|
24075
|
-
return function(
|
|
24076
|
-
let sel =
|
|
23910
|
+
return function(state, dispatch, view) {
|
|
23911
|
+
let sel = state.selection;
|
|
24077
23912
|
let $start = dir > 0 ? sel.$to : sel.$from, mustMove = sel.empty;
|
|
24078
23913
|
if (sel instanceof TextSelection) {
|
|
24079
23914
|
if (!view.endOfTextblock(dirStr) || $start.depth == 0)
|
|
24080
23915
|
return false;
|
|
24081
23916
|
mustMove = false;
|
|
24082
|
-
$start =
|
|
23917
|
+
$start = state.doc.resolve(dir > 0 ? $start.after() : $start.before());
|
|
24083
23918
|
}
|
|
24084
23919
|
let $found = GapCursor.findGapCursorFrom($start, dir, mustMove);
|
|
24085
23920
|
if (!$found)
|
|
24086
23921
|
return false;
|
|
24087
23922
|
if (dispatch)
|
|
24088
|
-
dispatch(
|
|
23923
|
+
dispatch(state.tr.setSelection(new GapCursor($found)));
|
|
24089
23924
|
return true;
|
|
24090
23925
|
};
|
|
24091
23926
|
}
|
|
@@ -24116,12 +23951,12 @@ function beforeinput(view, event) {
|
|
|
24116
23951
|
view.dispatch(tr2);
|
|
24117
23952
|
return false;
|
|
24118
23953
|
}
|
|
24119
|
-
function drawGapCursor(
|
|
24120
|
-
if (!(
|
|
23954
|
+
function drawGapCursor(state) {
|
|
23955
|
+
if (!(state.selection instanceof GapCursor))
|
|
24121
23956
|
return null;
|
|
24122
23957
|
let node = document.createElement("div");
|
|
24123
23958
|
node.className = "ProseMirror-gapcursor";
|
|
24124
|
-
return DecorationSet.create(
|
|
23959
|
+
return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node, { key: "gapcursor" })]);
|
|
24125
23960
|
}
|
|
24126
23961
|
|
|
24127
23962
|
// ../../node_modules/.pnpm/rope-sequence@1.3.4/node_modules/rope-sequence/dist/index.js
|
|
@@ -24316,7 +24151,7 @@ var Branch = class _Branch {
|
|
|
24316
24151
|
}
|
|
24317
24152
|
// Pop the latest event off the branch's history and apply it
|
|
24318
24153
|
// to a document transform.
|
|
24319
|
-
popEvent(
|
|
24154
|
+
popEvent(state, preserveItems) {
|
|
24320
24155
|
if (this.eventCount == 0)
|
|
24321
24156
|
return null;
|
|
24322
24157
|
let end = this.items.length;
|
|
@@ -24332,7 +24167,7 @@ var Branch = class _Branch {
|
|
|
24332
24167
|
remap = this.remapping(end, this.items.length);
|
|
24333
24168
|
mapFrom = remap.maps.length;
|
|
24334
24169
|
}
|
|
24335
|
-
let transform =
|
|
24170
|
+
let transform = state.tr;
|
|
24336
24171
|
let selection, remaining;
|
|
24337
24172
|
let addAfter = [], addBefore = [];
|
|
24338
24173
|
this.items.forEach((item, i) => {
|
|
@@ -24529,7 +24364,7 @@ var HistoryState = class {
|
|
|
24529
24364
|
}
|
|
24530
24365
|
};
|
|
24531
24366
|
var DEPTH_OVERFLOW = 20;
|
|
24532
|
-
function applyTransaction(history2,
|
|
24367
|
+
function applyTransaction(history2, state, tr2, options) {
|
|
24533
24368
|
let historyTr = tr2.getMeta(historyKey), rebased;
|
|
24534
24369
|
if (historyTr)
|
|
24535
24370
|
return historyTr.historyState;
|
|
@@ -24540,14 +24375,14 @@ function applyTransaction(history2, state3, tr2, options) {
|
|
|
24540
24375
|
return history2;
|
|
24541
24376
|
} else if (appended && appended.getMeta(historyKey)) {
|
|
24542
24377
|
if (appended.getMeta(historyKey).redo)
|
|
24543
|
-
return new HistoryState(history2.done.addTransform(tr2, void 0, options, mustPreserveItems(
|
|
24378
|
+
return new HistoryState(history2.done.addTransform(tr2, void 0, options, mustPreserveItems(state)), history2.undone, rangesFor(tr2.mapping.maps), history2.prevTime, history2.prevComposition);
|
|
24544
24379
|
else
|
|
24545
|
-
return new HistoryState(history2.done, history2.undone.addTransform(tr2, void 0, options, mustPreserveItems(
|
|
24380
|
+
return new HistoryState(history2.done, history2.undone.addTransform(tr2, void 0, options, mustPreserveItems(state)), null, history2.prevTime, history2.prevComposition);
|
|
24546
24381
|
} else if (tr2.getMeta("addToHistory") !== false && !(appended && appended.getMeta("addToHistory") === false)) {
|
|
24547
24382
|
let composition = tr2.getMeta("composition");
|
|
24548
24383
|
let newGroup = history2.prevTime == 0 || !appended && history2.prevComposition != composition && (history2.prevTime < (tr2.time || 0) - options.newGroupDelay || !isAdjacentTo(tr2, history2.prevRanges));
|
|
24549
24384
|
let prevRanges = appended ? mapRanges(history2.prevRanges, tr2.mapping) : rangesFor(tr2.mapping.maps);
|
|
24550
|
-
return new HistoryState(history2.done.addTransform(tr2, newGroup ?
|
|
24385
|
+
return new HistoryState(history2.done.addTransform(tr2, newGroup ? state.selection.getBookmark() : void 0, options, mustPreserveItems(state)), Branch.empty, prevRanges, tr2.time, composition == null ? history2.prevComposition : composition);
|
|
24551
24386
|
} else if (rebased = tr2.getMeta("rebased")) {
|
|
24552
24387
|
return new HistoryState(history2.done.rebased(tr2, rebased), history2.undone.rebased(tr2, rebased), mapRanges(history2.prevRanges, tr2.mapping), history2.prevTime, history2.prevComposition);
|
|
24553
24388
|
} else {
|
|
@@ -24584,21 +24419,21 @@ function mapRanges(ranges, mapping) {
|
|
|
24584
24419
|
}
|
|
24585
24420
|
return result;
|
|
24586
24421
|
}
|
|
24587
|
-
function histTransaction(history2,
|
|
24588
|
-
let preserveItems = mustPreserveItems(
|
|
24589
|
-
let histOptions = historyKey.get(
|
|
24590
|
-
let pop = (redo2 ? history2.undone : history2.done).popEvent(
|
|
24422
|
+
function histTransaction(history2, state, redo2) {
|
|
24423
|
+
let preserveItems = mustPreserveItems(state);
|
|
24424
|
+
let histOptions = historyKey.get(state).spec.config;
|
|
24425
|
+
let pop = (redo2 ? history2.undone : history2.done).popEvent(state, preserveItems);
|
|
24591
24426
|
if (!pop)
|
|
24592
24427
|
return null;
|
|
24593
24428
|
let selection = pop.selection.resolve(pop.transform.doc);
|
|
24594
|
-
let added = (redo2 ? history2.done : history2.undone).addTransform(pop.transform,
|
|
24429
|
+
let added = (redo2 ? history2.done : history2.undone).addTransform(pop.transform, state.selection.getBookmark(), histOptions, preserveItems);
|
|
24595
24430
|
let newHist = new HistoryState(redo2 ? added : pop.remaining, redo2 ? pop.remaining : added, null, 0, -1);
|
|
24596
24431
|
return pop.transform.setSelection(selection).setMeta(historyKey, { redo: redo2, historyState: newHist });
|
|
24597
24432
|
}
|
|
24598
24433
|
var cachedPreserveItems = false;
|
|
24599
24434
|
var cachedPreserveItemsPlugins = null;
|
|
24600
|
-
function mustPreserveItems(
|
|
24601
|
-
let plugins =
|
|
24435
|
+
function mustPreserveItems(state) {
|
|
24436
|
+
let plugins = state.plugins;
|
|
24602
24437
|
if (cachedPreserveItemsPlugins != plugins) {
|
|
24603
24438
|
cachedPreserveItems = false;
|
|
24604
24439
|
cachedPreserveItemsPlugins = plugins;
|
|
@@ -24623,8 +24458,8 @@ function history(config = {}) {
|
|
|
24623
24458
|
init() {
|
|
24624
24459
|
return new HistoryState(Branch.empty, Branch.empty, null, 0, -1);
|
|
24625
24460
|
},
|
|
24626
|
-
apply(tr2, hist,
|
|
24627
|
-
return applyTransaction(hist,
|
|
24461
|
+
apply(tr2, hist, state) {
|
|
24462
|
+
return applyTransaction(hist, state, tr2, config);
|
|
24628
24463
|
}
|
|
24629
24464
|
},
|
|
24630
24465
|
config,
|
|
@@ -24643,12 +24478,12 @@ function history(config = {}) {
|
|
|
24643
24478
|
});
|
|
24644
24479
|
}
|
|
24645
24480
|
function buildCommand(redo2, scroll) {
|
|
24646
|
-
return (
|
|
24647
|
-
let hist = historyKey.getState(
|
|
24481
|
+
return (state, dispatch) => {
|
|
24482
|
+
let hist = historyKey.getState(state);
|
|
24648
24483
|
if (!hist || (redo2 ? hist.undone : hist.done).eventCount == 0)
|
|
24649
24484
|
return false;
|
|
24650
24485
|
if (dispatch) {
|
|
24651
|
-
let tr2 = histTransaction(hist,
|
|
24486
|
+
let tr2 = histTransaction(hist, state, redo2);
|
|
24652
24487
|
if (tr2)
|
|
24653
24488
|
dispatch(scroll ? tr2.scrollIntoView() : tr2);
|
|
24654
24489
|
}
|
|
@@ -24721,12 +24556,12 @@ var CharacterCount = Extension.create({
|
|
|
24721
24556
|
}
|
|
24722
24557
|
initialEvaluationDone = true;
|
|
24723
24558
|
},
|
|
24724
|
-
filterTransaction: (transaction,
|
|
24559
|
+
filterTransaction: (transaction, state) => {
|
|
24725
24560
|
const limit = this.options.limit;
|
|
24726
24561
|
if (!transaction.docChanged || limit === 0 || limit === null || limit === void 0) {
|
|
24727
24562
|
return true;
|
|
24728
24563
|
}
|
|
24729
|
-
const oldSize = this.storage.characters({ node:
|
|
24564
|
+
const oldSize = this.storage.characters({ node: state.doc });
|
|
24730
24565
|
const newSize = this.storage.characters({ node: transaction.doc });
|
|
24731
24566
|
if (newSize <= limit) {
|
|
24732
24567
|
return true;
|
|
@@ -24921,12 +24756,12 @@ var Selection2 = Extension.create({
|
|
|
24921
24756
|
new Plugin({
|
|
24922
24757
|
key: new PluginKey("selection"),
|
|
24923
24758
|
props: {
|
|
24924
|
-
decorations(
|
|
24925
|
-
if (
|
|
24759
|
+
decorations(state) {
|
|
24760
|
+
if (state.selection.empty || editor.isFocused || !editor.isEditable || isNodeSelection(state.selection) || editor.view.dragging) {
|
|
24926
24761
|
return null;
|
|
24927
24762
|
}
|
|
24928
|
-
return DecorationSet.create(
|
|
24929
|
-
Decoration.inline(
|
|
24763
|
+
return DecorationSet.create(state.doc, [
|
|
24764
|
+
Decoration.inline(state.selection.from, state.selection.to, {
|
|
24930
24765
|
class: options.className
|
|
24931
24766
|
})
|
|
24932
24767
|
]);
|
|
@@ -24955,9 +24790,9 @@ var TrailingNode = Extension.create({
|
|
|
24955
24790
|
return [
|
|
24956
24791
|
new Plugin({
|
|
24957
24792
|
key: plugin,
|
|
24958
|
-
appendTransaction: (_, __,
|
|
24959
|
-
const { doc: doc3, tr: tr2, schema } =
|
|
24960
|
-
const shouldInsertNodeAtEnd = plugin.getState(
|
|
24793
|
+
appendTransaction: (_, __, state) => {
|
|
24794
|
+
const { doc: doc3, tr: tr2, schema } = state;
|
|
24795
|
+
const shouldInsertNodeAtEnd = plugin.getState(state);
|
|
24961
24796
|
const endPosition = doc3.content.size;
|
|
24962
24797
|
const type = schema.nodes[defaultNode];
|
|
24963
24798
|
if (!shouldInsertNodeAtEnd) {
|
|
@@ -24966,8 +24801,8 @@ var TrailingNode = Extension.create({
|
|
|
24966
24801
|
return tr2.insert(endPosition, type.create());
|
|
24967
24802
|
},
|
|
24968
24803
|
state: {
|
|
24969
|
-
init: (_,
|
|
24970
|
-
const lastNode =
|
|
24804
|
+
init: (_, state) => {
|
|
24805
|
+
const lastNode = state.tr.doc.lastChild;
|
|
24971
24806
|
return !nodeEqualsType({ node: lastNode, types: disabledNodes });
|
|
24972
24807
|
},
|
|
24973
24808
|
apply: (tr2, value) => {
|
|
@@ -24995,11 +24830,11 @@ var UndoRedo = Extension.create({
|
|
|
24995
24830
|
},
|
|
24996
24831
|
addCommands() {
|
|
24997
24832
|
return {
|
|
24998
|
-
undo: () => ({ state
|
|
24999
|
-
return undo(
|
|
24833
|
+
undo: () => ({ state, dispatch }) => {
|
|
24834
|
+
return undo(state, dispatch);
|
|
25000
24835
|
},
|
|
25001
|
-
redo: () => ({ state
|
|
25002
|
-
return redo(
|
|
24836
|
+
redo: () => ({ state, dispatch }) => {
|
|
24837
|
+
return redo(state, dispatch);
|
|
25003
24838
|
}
|
|
25004
24839
|
};
|
|
25005
24840
|
},
|
|
@@ -25103,15 +24938,6 @@ import {
|
|
|
25103
24938
|
} from "react";
|
|
25104
24939
|
import { createRoot } from "react-dom/client";
|
|
25105
24940
|
|
|
25106
|
-
// src/chat/lib/skill-name.ts
|
|
25107
|
-
function skillDisplayName(skill) {
|
|
25108
|
-
const displayName = (skill.display_name ?? skill.displayName ?? "").trim();
|
|
25109
|
-
if (displayName) {
|
|
25110
|
-
return displayName;
|
|
25111
|
-
}
|
|
25112
|
-
return (skill.skill_id ?? skill.skillId ?? "").trim();
|
|
25113
|
-
}
|
|
25114
|
-
|
|
25115
24941
|
// src/rich-input/voice/use-tiptap-voice-input.ts
|
|
25116
24942
|
import { useCallback, useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
25117
24943
|
var IDLE_VOICE = {
|
|
@@ -25347,7 +25173,7 @@ function useComposerModel(activeSessionId) {
|
|
|
25347
25173
|
const [selectingSession, setSelectingSession] = useState4(null);
|
|
25348
25174
|
const selectingRef = useRef4(null);
|
|
25349
25175
|
const sharedModelDraft = useComposerChannels(
|
|
25350
|
-
(
|
|
25176
|
+
(state) => activeSessionId ? state.modelDrafts[activeSessionId] : void 0
|
|
25351
25177
|
);
|
|
25352
25178
|
const explicitModelSelection = activeSessionId ? sharedModelDraft ? { sessionId: activeSessionId, model: sharedModelDraft } : null : newSessionModelSelection;
|
|
25353
25179
|
const {
|
|
@@ -25748,11 +25574,6 @@ function StandardModelSelector({
|
|
|
25748
25574
|
// src/rich-input/SkillStatusBar.tsx
|
|
25749
25575
|
import { useMemo as useMemo5 } from "react";
|
|
25750
25576
|
|
|
25751
|
-
// src/chat/lib/skill-visibility.ts
|
|
25752
|
-
function visibleSkills(skills, mode) {
|
|
25753
|
-
return mode === "developer" ? skills : skills.filter((skill) => !skill.builtin);
|
|
25754
|
-
}
|
|
25755
|
-
|
|
25756
25577
|
// src/rich-input/lib/token-pressure.ts
|
|
25757
25578
|
var NO_PRESSURE = { ratio: 0, level: "normal" };
|
|
25758
25579
|
function clampRatio(value) {
|
|
@@ -26034,7 +25855,7 @@ function SkillStatusBar({
|
|
|
26034
25855
|
}
|
|
26035
25856
|
|
|
26036
25857
|
// src/rich-input/InputActionSubmenu.tsx
|
|
26037
|
-
import { useSyncExternalStore as
|
|
25858
|
+
import { useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
26038
25859
|
import { jsx as jsx15, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
26039
25860
|
var narrowQuery = "(max-width: 639px)";
|
|
26040
25861
|
function subscribeToViewport(onChange) {
|
|
@@ -26044,7 +25865,7 @@ function subscribeToViewport(onChange) {
|
|
|
26044
25865
|
}
|
|
26045
25866
|
var isNarrowViewport = () => window.matchMedia(narrowQuery).matches;
|
|
26046
25867
|
function InputActionSubmenu({ label, icon, open, onOpenChange, children, disabled = false }) {
|
|
26047
|
-
const narrow =
|
|
25868
|
+
const narrow = useSyncExternalStore3(subscribeToViewport, isNarrowViewport, () => false);
|
|
26048
25869
|
return /* @__PURE__ */ jsxs6(dist_exports.Root, { open, onOpenChange, children: [
|
|
26049
25870
|
/* @__PURE__ */ jsx15(dist_exports.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs6(
|
|
26050
25871
|
"button",
|
|
@@ -26763,7 +26584,7 @@ function useReferenceCandidates(getScope, sources) {
|
|
|
26763
26584
|
import { useCallback as useCallback3, useEffect as useEffect8, useMemo as useMemo6, useState as useState8 } from "react";
|
|
26764
26585
|
|
|
26765
26586
|
// src/rich-input/lib/input-history-document.ts
|
|
26766
|
-
import { normalizeTopicAssetRefs as
|
|
26587
|
+
import { normalizeTopicAssetRefs as normalizeTopicAssetRefs2 } from "@blade-hq/agent-client";
|
|
26767
26588
|
function copyEditorDocument(value) {
|
|
26768
26589
|
const attributes = {
|
|
26769
26590
|
pluginMention: { provider: "string", plugin: "string", server: "string", id: "string", label: "string" },
|
|
@@ -26801,7 +26622,7 @@ function copyEditorDocument(value) {
|
|
|
26801
26622
|
if (expected === "string" && typeof attr !== "string" || expected === "number" && typeof attr !== "number" || expected === "boolean" && typeof attr !== "boolean") return null;
|
|
26802
26623
|
attrs[key] = attr;
|
|
26803
26624
|
}
|
|
26804
|
-
if (type === "topicAssetMention" &&
|
|
26625
|
+
if (type === "topicAssetMention" && normalizeTopicAssetRefs2([attrs]).length !== 1) return null;
|
|
26805
26626
|
return { type, attrs };
|
|
26806
26627
|
};
|
|
26807
26628
|
try {
|
|
@@ -28350,20 +28171,20 @@ function ChatInput({
|
|
|
28350
28171
|
isLoading: isModelLoading
|
|
28351
28172
|
} = model;
|
|
28352
28173
|
const rewindDraft = useComposerChannels(
|
|
28353
|
-
(
|
|
28174
|
+
(state) => activeSessionId ? state.rewindDrafts[activeSessionId] : void 0
|
|
28354
28175
|
);
|
|
28355
28176
|
const pendingContexts = useComposerChannels(
|
|
28356
|
-
(
|
|
28177
|
+
(state) => activeSessionId ? state.pendingContexts[activeSessionId] : void 0
|
|
28357
28178
|
);
|
|
28358
28179
|
const draftAppends = useComposerChannels(
|
|
28359
|
-
(
|
|
28180
|
+
(state) => activeSessionId ? state.draftAppends[activeSessionId] : void 0
|
|
28360
28181
|
);
|
|
28361
28182
|
const sendRequests = useComposerChannels(
|
|
28362
|
-
(
|
|
28183
|
+
(state) => activeSessionId ? state.sendRequests[activeSessionId] : void 0
|
|
28363
28184
|
);
|
|
28364
28185
|
const connectionStatus = useComposerConnection(activeSessionId);
|
|
28365
28186
|
const inputHistory = useInputHistory(activeSessionId, client);
|
|
28366
|
-
const queuedTopicRefs = useComposerChannels((
|
|
28187
|
+
const queuedTopicRefs = useComposerChannels((state) => activeSessionId ? state.topicAssetReferences[activeSessionId] : void 0);
|
|
28367
28188
|
const getTopicSuggestions = useEffectEvent(async (query) => {
|
|
28368
28189
|
if (!activeSessionId) return [];
|
|
28369
28190
|
try {
|
|
@@ -28651,7 +28472,7 @@ function ChatInput({
|
|
|
28651
28472
|
return false;
|
|
28652
28473
|
},
|
|
28653
28474
|
keydown: (_view, event) => {
|
|
28654
|
-
const
|
|
28475
|
+
const state = getEditorState();
|
|
28655
28476
|
const fileMentionState = editorRef.current ? fileMentionSuggestionKey.getState(editorRef.current.view.state) : void 0;
|
|
28656
28477
|
if (fileMentionState?.active) {
|
|
28657
28478
|
return false;
|
|
@@ -28661,33 +28482,33 @@ function ChatInput({
|
|
|
28661
28482
|
return false;
|
|
28662
28483
|
}
|
|
28663
28484
|
const actionMenuOpen2 = actionMenuOpenRef.current;
|
|
28664
|
-
if (shouldHandleHistoryKey(event, actionMenuOpen2) && event.key === "ArrowUp" && (
|
|
28665
|
-
const previousEntry =
|
|
28485
|
+
if (shouldHandleHistoryKey(event, actionMenuOpen2) && event.key === "ArrowUp" && (state.input.trim().length === 0 || state.isNavigatingHistory)) {
|
|
28486
|
+
const previousEntry = state.navigateUp(editorRef.current?.getJSON());
|
|
28666
28487
|
if (!previousEntry) {
|
|
28667
28488
|
return false;
|
|
28668
28489
|
}
|
|
28669
28490
|
event.preventDefault();
|
|
28670
|
-
editorRef.current?.commands.setContent(retainTopicAssetMentions(previousEntry.document,
|
|
28491
|
+
editorRef.current?.commands.setContent(retainTopicAssetMentions(previousEntry.document, state.topicId));
|
|
28671
28492
|
editorRef.current?.commands.focus("end");
|
|
28672
28493
|
return true;
|
|
28673
28494
|
}
|
|
28674
28495
|
if (shouldHandleHistoryKey(event, actionMenuOpen2) && event.key === "ArrowDown") {
|
|
28675
|
-
const nextEntry =
|
|
28496
|
+
const nextEntry = state.navigateDown();
|
|
28676
28497
|
if (nextEntry == null) {
|
|
28677
28498
|
return false;
|
|
28678
28499
|
}
|
|
28679
28500
|
event.preventDefault();
|
|
28680
|
-
editorRef.current?.commands.setContent(retainTopicAssetMentions(nextEntry.document,
|
|
28501
|
+
editorRef.current?.commands.setContent(retainTopicAssetMentions(nextEntry.document, state.topicId));
|
|
28681
28502
|
editorRef.current?.commands.focus("end");
|
|
28682
28503
|
return true;
|
|
28683
28504
|
}
|
|
28684
|
-
if (
|
|
28505
|
+
if (state.onDoubleEscape && event.key === "Escape" && !isImeCompositionKey(event) && !event.repeat) {
|
|
28685
28506
|
const now = Date.now();
|
|
28686
28507
|
if (now - lastEscapeAtRef.current <= DOUBLE_ESCAPE_MS) {
|
|
28687
28508
|
lastEscapeAtRef.current = 0;
|
|
28688
28509
|
event.preventDefault();
|
|
28689
28510
|
const rect = editorRef.current?.view.dom.getBoundingClientRect() ?? null;
|
|
28690
|
-
|
|
28511
|
+
state.onDoubleEscape(rect);
|
|
28691
28512
|
return true;
|
|
28692
28513
|
}
|
|
28693
28514
|
lastEscapeAtRef.current = now;
|
|
@@ -28695,10 +28516,10 @@ function ChatInput({
|
|
|
28695
28516
|
}
|
|
28696
28517
|
if (shouldSubmitChatInput(event, actionMenuOpen2)) {
|
|
28697
28518
|
event.preventDefault();
|
|
28698
|
-
if (
|
|
28519
|
+
if (state.connectionStatus !== "connected") {
|
|
28699
28520
|
return true;
|
|
28700
28521
|
}
|
|
28701
|
-
void
|
|
28522
|
+
void state.handleSubmit(isQueueShortcut(event));
|
|
28702
28523
|
return true;
|
|
28703
28524
|
}
|
|
28704
28525
|
return false;
|
|
@@ -29157,8 +28978,8 @@ ${append2.text}` : append2.text;
|
|
|
29157
28978
|
const submitWhileRunning = isStreaming && !isStopping && queueWhileRunning;
|
|
29158
28979
|
const hasComposerContent = Boolean(input.trim()) || hasValidAttachments || hasRenderedAttachments || hasPendingContexts;
|
|
29159
28980
|
const isSendDisabled = connectionStatus !== "connected" || isCompacting || !submitWhileRunning && isModelLoading || !submitWhileRunning && !hasAvailableModel || isSubmitting || hasUploadingFiles || !input.trim() && !hasValidAttachments && !hasRenderedAttachments && !hasPendingContexts;
|
|
29160
|
-
const hasRecoverableLastTurn = useSessionState(activeSessionId ?? "", (
|
|
29161
|
-
const last =
|
|
28981
|
+
const hasRecoverableLastTurn = useSessionState(activeSessionId ?? "", (state) => {
|
|
28982
|
+
const last = state.messages.at(-1);
|
|
29162
28983
|
return Boolean(
|
|
29163
28984
|
last && last.role === "assistant" && (last.status === "interrupted" || last.status === "failed")
|
|
29164
28985
|
);
|