@nerd-bible/wordgard 0.6.2-beta8 → 0.6.2-beta9
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/collab.js +3 -0
- package/dist/command.js +6 -2
- package/dist/doc.d.ts +13 -2
- package/dist/doc.js +38 -18
- package/dist/editor.d.ts +13 -2
- package/dist/editor.js +167 -84
- package/dist/history.js +7 -2
- package/dist/phrases.js +1 -0
- package/dist/schema.js +11 -8
- package/dist/set.js +11 -7
- package/dist/state.d.ts +49 -4
- package/dist/state.js +90 -31
- package/dist/table.js +1 -0
- package/package.json +1 -1
package/dist/editor.js
CHANGED
|
@@ -199,6 +199,7 @@ class Widget {
|
|
|
199
199
|
render() {
|
|
200
200
|
let img = document.createElement("img");
|
|
201
201
|
img.className = "wg-buffer";
|
|
202
|
+
img.alt = "";
|
|
202
203
|
return img;
|
|
203
204
|
},
|
|
204
205
|
editable: true
|
|
@@ -207,6 +208,7 @@ class Widget {
|
|
|
207
208
|
render() {
|
|
208
209
|
let img = document.createElement("img");
|
|
209
210
|
img.className = "wg-blockBuffer";
|
|
211
|
+
img.alt = "";
|
|
210
212
|
return img;
|
|
211
213
|
},
|
|
212
214
|
editable: true
|
|
@@ -314,6 +316,7 @@ const Decoration = /*@__PURE__*/(function (Decoration) {
|
|
|
314
316
|
return new WrapperDecoration(wrapper, spec?.target ? Elt.Selector.parse(spec.target) : null);
|
|
315
317
|
}
|
|
316
318
|
static source = GardState.Facet.define({
|
|
319
|
+
name: "pointDecorations",
|
|
317
320
|
combine: sources => sources.concat(nodeSelection)
|
|
318
321
|
});
|
|
319
322
|
static set(source) { return PointSet.create(source); }
|
|
@@ -338,19 +341,21 @@ const Decoration = /*@__PURE__*/(function (Decoration) {
|
|
|
338
341
|
static attribute(attr, value, options = {}) {
|
|
339
342
|
return new AttributeRangeDecoration(attr, value, options);
|
|
340
343
|
}
|
|
341
|
-
static source = GardState.Facet.define();
|
|
344
|
+
static source = GardState.Facet.define({ name: "rangeDecorations" });
|
|
342
345
|
static set(source) { return RangeSet.create(source); }
|
|
343
346
|
static none = RangeSet.empty;
|
|
344
347
|
}
|
|
345
348
|
Decoration.Range = Range;
|
|
346
349
|
;return Decoration})({});
|
|
347
350
|
const tagShape = /*@__PURE__*/GardState.Facet.define({
|
|
351
|
+
name: "tagShape",
|
|
348
352
|
combine: shapes => new Map(shapes.map(s => [s.type, s.shape]).reverse())
|
|
349
353
|
});
|
|
350
|
-
const tagWrapper = /*@__PURE__*/GardState.Facet.define();
|
|
351
|
-
const tagWidget = /*@__PURE__*/GardState.Facet.define();
|
|
352
|
-
const tagAttribute = /*@__PURE__*/GardState.Facet.define();
|
|
354
|
+
const tagWrapper = /*@__PURE__*/GardState.Facet.define({ name: "tagWrapper" });
|
|
355
|
+
const tagWidget = /*@__PURE__*/GardState.Facet.define({ name: "tagWidget" });
|
|
356
|
+
const tagAttribute = /*@__PURE__*/GardState.Facet.define({ name: "tagAttribute" });
|
|
353
357
|
const markShape = /*@__PURE__*/GardState.Facet.define({
|
|
358
|
+
name: "markShape",
|
|
354
359
|
combine: shapes => new Map(shapes.map(s => [s.type, s.modified]).reverse())
|
|
355
360
|
});
|
|
356
361
|
function memo(f) {
|
|
@@ -903,7 +908,7 @@ function eqArray(a, b) {
|
|
|
903
908
|
return false;
|
|
904
909
|
return true;
|
|
905
910
|
}
|
|
906
|
-
const exceptionSink = /*@__PURE__*/GardState.Facet.define();
|
|
911
|
+
const exceptionSink = /*@__PURE__*/GardState.Facet.define({ name: "exceptionSink" });
|
|
907
912
|
function logException(state, exception, context) {
|
|
908
913
|
let handler = state.facet(exceptionSink);
|
|
909
914
|
if (handler.length)
|
|
@@ -916,6 +921,28 @@ function logException(state, exception, context) {
|
|
|
916
921
|
console.error(exception);
|
|
917
922
|
}
|
|
918
923
|
|
|
924
|
+
let nav = typeof navigator != "undefined" ? navigator : { userAgent: "", vendor: "", platform: "" };
|
|
925
|
+
let doc = typeof document != "undefined" ? document : { documentElement: { style: {} } };
|
|
926
|
+
const edge = /*@__PURE__*/(() => /Edge\/(\d+)/.exec(nav.userAgent))();
|
|
927
|
+
const gecko = /*@__PURE__*/(() => !edge && /gecko\/(\d+)/i.test(nav.userAgent))();
|
|
928
|
+
const chrome = /*@__PURE__*/(() => !edge && /Chrome\/(\d+)/.exec(nav.userAgent))();
|
|
929
|
+
const webkit = /*@__PURE__*/(() => "webkitFontSmoothing" in doc.documentElement.style)();
|
|
930
|
+
const safari = /*@__PURE__*/(() => !edge && /Apple Computer/.test(nav.vendor))();
|
|
931
|
+
const ios = /*@__PURE__*/(() => safari && (/Mobile\/\w+/.test(nav.userAgent) || nav.maxTouchPoints > 2))();
|
|
932
|
+
var browser = /*@__PURE__*/(() => ({
|
|
933
|
+
mac: ios || /Mac/.test(nav.platform),
|
|
934
|
+
windows: /Win/.test(nav.platform),
|
|
935
|
+
linux: /Linux|X11/.test(nav.platform),
|
|
936
|
+
gecko_version: gecko ? +(/Firefox\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
|
|
937
|
+
chrome: !!chrome,
|
|
938
|
+
chrome_version: chrome ? +chrome[1] : 0,
|
|
939
|
+
ios,
|
|
940
|
+
android: /Android\b/.test(nav.userAgent),
|
|
941
|
+
webkit,
|
|
942
|
+
webkit_version: webkit ? +(/\bAppleWebKit\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
|
|
943
|
+
safari,
|
|
944
|
+
safari_version: safari ? +(/\bVersion\/(\d+(\.\d+)?)/.exec(nav.userAgent) || [0, 0])[1] : 0}))();
|
|
945
|
+
|
|
919
946
|
function getSelection(root) {
|
|
920
947
|
let target;
|
|
921
948
|
if (root.nodeType == 11) { target = root.getSelection ? root : root.ownerDocument;
|
|
@@ -925,6 +952,17 @@ function getSelection(root) {
|
|
|
925
952
|
}
|
|
926
953
|
return target.getSelection();
|
|
927
954
|
}
|
|
955
|
+
function getSelectionRange(root) {
|
|
956
|
+
let sel = getSelection(root);
|
|
957
|
+
if (!sel)
|
|
958
|
+
return null;
|
|
959
|
+
if (browser.safari && root.nodeType == 11) {
|
|
960
|
+
let range = sel.getComposedRanges(root)[0];
|
|
961
|
+
if (range)
|
|
962
|
+
return range;
|
|
963
|
+
}
|
|
964
|
+
return new StaticRange(sel.getRangeAt(0));
|
|
965
|
+
}
|
|
928
966
|
function hasSelection(dom, selection) {
|
|
929
967
|
if (!selection.focusNode)
|
|
930
968
|
return false;
|
|
@@ -2685,36 +2723,28 @@ function flattenH(rect, top) {
|
|
|
2685
2723
|
return rect.height ? new DOMRect(rect.left, top ? rect.top : rect.bottom, rect.width, 0) : rect;
|
|
2686
2724
|
}
|
|
2687
2725
|
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
const
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
const
|
|
2695
|
-
const
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
const clipboardOutputFilter = /*@__PURE__*/GardState.Facet.define();
|
|
2711
|
-
const clipboardOutputHTMLFilter = /*@__PURE__*/GardState.Facet.define();
|
|
2712
|
-
const clipboardTextSerializer = /*@__PURE__*/GardState.Facet.define();
|
|
2713
|
-
const clipboardOutputTextFilter = /*@__PURE__*/GardState.Facet.define();
|
|
2714
|
-
const clipboardInputFilter = /*@__PURE__*/GardState.Facet.define();
|
|
2715
|
-
const clipboardInputHTMLFilter = /*@__PURE__*/GardState.Facet.define();
|
|
2716
|
-
const clipboardTextParser = /*@__PURE__*/GardState.Facet.define();
|
|
2717
|
-
const clipboardInputTextFilter = /*@__PURE__*/GardState.Facet.define();
|
|
2726
|
+
const clipboardOutputFilter = /*@__PURE__*/GardState.Facet.define({
|
|
2727
|
+
name: "clipboardOutputFilter"
|
|
2728
|
+
});
|
|
2729
|
+
const clipboardOutputHTMLFilter = /*@__PURE__*/GardState.Facet.define({
|
|
2730
|
+
name: "clipboardOutputHTMLFilter"
|
|
2731
|
+
});
|
|
2732
|
+
const clipboardTextSerializer = /*@__PURE__*/GardState.Facet.define({ name: "clipboardTextSerializer" });
|
|
2733
|
+
const clipboardOutputTextFilter = /*@__PURE__*/GardState.Facet.define({
|
|
2734
|
+
name: "clipboardOutputTextFilter"
|
|
2735
|
+
});
|
|
2736
|
+
const clipboardInputFilter = /*@__PURE__*/GardState.Facet.define({
|
|
2737
|
+
name: "clipboardInputFilter"
|
|
2738
|
+
});
|
|
2739
|
+
const clipboardInputHTMLFilter = /*@__PURE__*/GardState.Facet.define({
|
|
2740
|
+
name: "clipboardInputHTMLFilter"
|
|
2741
|
+
});
|
|
2742
|
+
const clipboardTextParser = /*@__PURE__*/GardState.Facet.define({
|
|
2743
|
+
name: "clipboardTextParser"
|
|
2744
|
+
});
|
|
2745
|
+
const clipboardInputTextFilter = /*@__PURE__*/GardState.Facet.define({
|
|
2746
|
+
name: "clipboardInputTextFilter"
|
|
2747
|
+
});
|
|
2718
2748
|
function writeClipboard(state, slice, data) {
|
|
2719
2749
|
for (let filter of state.facet(clipboardOutputFilter))
|
|
2720
2750
|
slice = filter(slice, state);
|
|
@@ -2762,9 +2792,7 @@ function writeClipboard(state, slice, data) {
|
|
|
2762
2792
|
function isOpen(elt) {
|
|
2763
2793
|
return (elt.getAttribute("wg-open") || null);
|
|
2764
2794
|
}
|
|
2765
|
-
function readClipboard(state,
|
|
2766
|
-
let html = data.getData("text/html");
|
|
2767
|
-
let text = data.getData("text/plain") || data.getData("Text") || data.getData("text/uri-list").replace(/\r?\n/g, " ");
|
|
2795
|
+
function readClipboard(state, html, text, targetContext, plain) {
|
|
2768
2796
|
let slice;
|
|
2769
2797
|
if (text && (targetContext.parent.node.type.hasRole(Node.Role.Code) || !html || plain)) {
|
|
2770
2798
|
for (let filter of state.facet(clipboardInputTextFilter))
|
|
@@ -2862,8 +2890,12 @@ function restoreReplacedSpaces(dom) {
|
|
|
2862
2890
|
}
|
|
2863
2891
|
}
|
|
2864
2892
|
|
|
2865
|
-
const theme$1 = /*@__PURE__*/GardState.Facet.define({
|
|
2893
|
+
const theme$1 = /*@__PURE__*/GardState.Facet.define({
|
|
2894
|
+
name: "theme",
|
|
2895
|
+
combine: strs => strs.join(" ")
|
|
2896
|
+
});
|
|
2866
2897
|
const colorScheme = /*@__PURE__*/GardState.Facet.define({
|
|
2898
|
+
name: "colorScheme",
|
|
2867
2899
|
combine: values => values.length ? values[0] : "light"
|
|
2868
2900
|
});
|
|
2869
2901
|
const styleID = /*@__PURE__*/StyleModule.newName(), baseLightID = /*@__PURE__*/StyleModule.newName(), baseDarkID = /*@__PURE__*/StyleModule.newName();
|
|
@@ -2891,7 +2923,7 @@ const baseStyles = /*@__PURE__*/buildTheme("." + styleID, {
|
|
|
2891
2923
|
flexDirection: "column",
|
|
2892
2924
|
border: "1px solid var(--wg-border-color)"
|
|
2893
2925
|
},
|
|
2894
|
-
"
|
|
2926
|
+
"&.wg-focused": {
|
|
2895
2927
|
outline: "1px solid var(--wg-highlight-color)",
|
|
2896
2928
|
"& > wg-scroller > wg-cursor-layer": {
|
|
2897
2929
|
animation: "steps(1) wg-blink 1.2s infinite"
|
|
@@ -3414,6 +3446,7 @@ class DOMObserver {
|
|
|
3414
3446
|
clear() {
|
|
3415
3447
|
this.takeRecords();
|
|
3416
3448
|
this.readSelectionRange();
|
|
3449
|
+
this.selectionChanged = false;
|
|
3417
3450
|
}
|
|
3418
3451
|
takeRecords() {
|
|
3419
3452
|
for (let mut of this.observer.takeRecords())
|
|
@@ -3504,6 +3537,7 @@ class KeyBinding {
|
|
|
3504
3537
|
this.extension = KeyBinding.source.of(this);
|
|
3505
3538
|
}
|
|
3506
3539
|
static of(spec) { return new KeyBinding(spec); }
|
|
3540
|
+
toString() { return `KeyBinding:${this.spec.key || this.spec.char || "??"}`; }
|
|
3507
3541
|
}
|
|
3508
3542
|
;KeyBinding = /*@__PURE__*/(function (KeyBinding) {
|
|
3509
3543
|
function handle(wg, event) {
|
|
@@ -3516,9 +3550,11 @@ class KeyBinding {
|
|
|
3516
3550
|
return s.facet(KeyBinding.useDefaultKeymap) ? bindings.concat(KeyBinding.defaultKeymap) : bindings;
|
|
3517
3551
|
});
|
|
3518
3552
|
KeyBinding.source = GardState.Facet.define({
|
|
3553
|
+
name: "keyBinding",
|
|
3519
3554
|
enables: KeyBinding.keymap
|
|
3520
3555
|
});
|
|
3521
3556
|
KeyBinding.useDefaultKeymap = GardState.Facet.define({
|
|
3557
|
+
name: "useDefaultKeymap",
|
|
3522
3558
|
combine: input => input.length ? input[0] : true
|
|
3523
3559
|
});
|
|
3524
3560
|
class Group {
|
|
@@ -3675,7 +3711,7 @@ class NormalizedBinding {
|
|
|
3675
3711
|
}
|
|
3676
3712
|
const keymapCache = /*@__PURE__*/(() => new WeakMap())();
|
|
3677
3713
|
function getKeymap(state) {
|
|
3678
|
-
let bindings = state.field(KeyBinding.keymap);
|
|
3714
|
+
let bindings = state.field(KeyBinding.keymap, false);
|
|
3679
3715
|
let found = keymapCache.get(bindings);
|
|
3680
3716
|
if (!found)
|
|
3681
3717
|
keymapCache.set(bindings, found = buildKeymap(bindings, currentPlatform));
|
|
@@ -3764,6 +3800,7 @@ function buildCharKeyCodes() {
|
|
|
3764
3800
|
const charKeyCodes = /*@__PURE__*/buildCharKeyCodes();
|
|
3765
3801
|
|
|
3766
3802
|
const eventHandler = /*@__PURE__*/GardState.Facet.define({
|
|
3803
|
+
name: "eventHandler",
|
|
3767
3804
|
combine: handlers => {
|
|
3768
3805
|
let result = Object.create(null);
|
|
3769
3806
|
for (let { event, handler } of handlers)
|
|
@@ -3772,6 +3809,7 @@ const eventHandler = /*@__PURE__*/GardState.Facet.define({
|
|
|
3772
3809
|
}
|
|
3773
3810
|
});
|
|
3774
3811
|
const eventObserver = /*@__PURE__*/GardState.Facet.define({
|
|
3812
|
+
name: "eventObserver",
|
|
3775
3813
|
combine: observers => {
|
|
3776
3814
|
let result = Object.create(null);
|
|
3777
3815
|
for (let { event, observer } of observers)
|
|
@@ -3959,22 +3997,18 @@ class InputState {
|
|
|
3959
3997
|
Command.dispatch(wg, insertText, { from, to, insert, userEvent: "input.type" });
|
|
3960
3998
|
}
|
|
3961
3999
|
else if (type == "insertFromPaste") {
|
|
3962
|
-
let
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
if (slice) {
|
|
3968
|
-
wg.dispatch({
|
|
3969
|
-
changes: { correct: { from, to, insert: slice, fit: true }, local: true },
|
|
3970
|
-
selection: isSel ? (cx, changes) => GardSelection.near(cx, changes.mapPos(to, 1), -1) : undefined,
|
|
3971
|
-
userEvent: "input.paste",
|
|
3972
|
-
scrollIntoView: isSel
|
|
3973
|
-
});
|
|
4000
|
+
let isSel = this.unflushedSelection;
|
|
4001
|
+
if (!isSel) {
|
|
4002
|
+
let r = data.domRange.range, domSel = getSelectionRange(wg.root);
|
|
4003
|
+
isSel = !!domSel && isEquivalentPosition(r.startContainer, r.startOffset, domSel.startContainer, domSel.startOffset) &&
|
|
4004
|
+
isEquivalentPosition(r.endContainer, r.endOffset, domSel.endContainer, domSel.endOffset);
|
|
3974
4005
|
}
|
|
4006
|
+
let transfer = event.dataTransfer;
|
|
4007
|
+
doPaste(wg, getHTML(transfer), getText(transfer), isSel ? null : range, event);
|
|
3975
4008
|
}
|
|
3976
4009
|
else if ((type == "insertReplacementText" || type == "insertFromYank")) {
|
|
3977
|
-
let
|
|
4010
|
+
let transfer = event.dataTransfer;
|
|
4011
|
+
let read = readClipboard(wg.state, getHTML(transfer), getText(transfer), wg.state.sel.head, true);
|
|
3978
4012
|
let { from, to } = this.unflushedSelection ? wg.state.selection : range;
|
|
3979
4013
|
let sel = wg.state.selection, touchesSel = from <= sel.to && to >= sel.from;
|
|
3980
4014
|
if (read)
|
|
@@ -4114,6 +4148,12 @@ class InputState {
|
|
|
4114
4148
|
this.mouseSelection.disconnect();
|
|
4115
4149
|
}
|
|
4116
4150
|
}
|
|
4151
|
+
function getHTML(data) {
|
|
4152
|
+
return data.getData("text/html");
|
|
4153
|
+
}
|
|
4154
|
+
function getText(data) {
|
|
4155
|
+
return data.getData("text/plain") || data.getData("Text") || data.getData("text/uri-list").replace(/\r?\n/g, " ");
|
|
4156
|
+
}
|
|
4117
4157
|
function isSingleChar(doc, from, to) {
|
|
4118
4158
|
if (to > from + 10)
|
|
4119
4159
|
return false;
|
|
@@ -4152,8 +4192,22 @@ function computeHandlers(state) {
|
|
|
4152
4192
|
record(type).observers.push(baseObservers[type]);
|
|
4153
4193
|
return result;
|
|
4154
4194
|
}
|
|
4195
|
+
function doPaste(wg, html, text, targetRange, event) {
|
|
4196
|
+
let { from, to } = targetRange || wg.state.selection.replacementRange;
|
|
4197
|
+
let slice = readClipboard(wg.state, html, text, wg.state.doc.resolve(from), wg.inputState.shiftKey);
|
|
4198
|
+
if (!targetRange && wg.state.facet(pasteHandler).some(h => h(wg, event, slice || Slice.empty, text, html)))
|
|
4199
|
+
return;
|
|
4200
|
+
if (slice) {
|
|
4201
|
+
wg.dispatch({
|
|
4202
|
+
changes: { correct: { from, to, insert: slice, fit: true }, local: true },
|
|
4203
|
+
selection: targetRange ? undefined : (cx, changes) => GardSelection.near(cx, changes.mapPos(to, 1), -1),
|
|
4204
|
+
userEvent: "input.paste",
|
|
4205
|
+
scrollIntoView: !targetRange
|
|
4206
|
+
});
|
|
4207
|
+
}
|
|
4208
|
+
}
|
|
4155
4209
|
const dragScrollMargin = 6;
|
|
4156
|
-
const mouseSelectionStyle = /*@__PURE__*/GardState.Facet.define();
|
|
4210
|
+
const mouseSelectionStyle = /*@__PURE__*/GardState.Facet.define({ name: "mouseSelectionStyle" });
|
|
4157
4211
|
function dragScrollSpeed(dist) {
|
|
4158
4212
|
return Math.max(0, dist) * 0.7 + 8;
|
|
4159
4213
|
}
|
|
@@ -4267,7 +4321,7 @@ class MouseSelection {
|
|
|
4267
4321
|
setTimeout(() => this.select(this.lastEvent), 20);
|
|
4268
4322
|
}
|
|
4269
4323
|
}
|
|
4270
|
-
const dragBehavior = /*@__PURE__*/GardState.Facet.define();
|
|
4324
|
+
const dragBehavior = /*@__PURE__*/GardState.Facet.define({ name: "dragBehavior" });
|
|
4271
4325
|
function dragMovesSelection(wg, event) {
|
|
4272
4326
|
let facet = wg.state.facet(dragBehavior);
|
|
4273
4327
|
return facet.length ? facet[0](event) : browser.mac ? !event.altKey : !event.ctrlKey;
|
|
@@ -4343,8 +4397,8 @@ function basicMouseSelection(wg, event) {
|
|
|
4343
4397
|
}
|
|
4344
4398
|
};
|
|
4345
4399
|
}
|
|
4346
|
-
const dropHandler = /*@__PURE__*/GardState.Facet.define();
|
|
4347
|
-
const pasteHandler = /*@__PURE__*/GardState.Facet.define();
|
|
4400
|
+
const dropHandler = /*@__PURE__*/GardState.Facet.define({ name: "dropHandler" });
|
|
4401
|
+
const pasteHandler = /*@__PURE__*/GardState.Facet.define({ name: "pasteHandler" });
|
|
4348
4402
|
function copy(wg, event) {
|
|
4349
4403
|
let { state } = wg;
|
|
4350
4404
|
if (!state.selection.empty && event.clipboardData) {
|
|
@@ -4360,7 +4414,7 @@ function copy(wg, event) {
|
|
|
4360
4414
|
}
|
|
4361
4415
|
return true;
|
|
4362
4416
|
}
|
|
4363
|
-
const isFocusChange = /*@__PURE__*/Transaction.Annotation.define();
|
|
4417
|
+
const isFocusChange = /*@__PURE__*/Transaction.Annotation.define("focusChange");
|
|
4364
4418
|
function updateForFocusChange(wg) {
|
|
4365
4419
|
setTimeout(() => {
|
|
4366
4420
|
let focus = wg.hasFocus;
|
|
@@ -4494,9 +4548,10 @@ const baseHandlers = {
|
|
|
4494
4548
|
copy,
|
|
4495
4549
|
cut: copy,
|
|
4496
4550
|
drop(wg, event) {
|
|
4497
|
-
|
|
4551
|
+
let data = event.dataTransfer;
|
|
4552
|
+
if (!data || wg.state.readOnly)
|
|
4498
4553
|
return true;
|
|
4499
|
-
let slice = readClipboard(wg.state,
|
|
4554
|
+
let slice = readClipboard(wg.state, getHTML(data), getText(data), wg.state.sel.head, false);
|
|
4500
4555
|
if (!slice)
|
|
4501
4556
|
return false;
|
|
4502
4557
|
let dropPos = wg.posAtCoords({ x: event.clientX, y: event.clientY }).pos;
|
|
@@ -4531,7 +4586,7 @@ const baseHandlers = {
|
|
|
4531
4586
|
if (ranges.length) {
|
|
4532
4587
|
let r = ranges[0], empty = r.collapsed;
|
|
4533
4588
|
let from = wg.inputState.getDOMPos(r.startContainer, r.startOffset);
|
|
4534
|
-
data.domRange = { from, to: empty ? from : wg.inputState.getDOMPos(r.endContainer, r.endOffset) };
|
|
4589
|
+
data.domRange = { from, to: empty ? from : wg.inputState.getDOMPos(r.endContainer, r.endOffset), range: r };
|
|
4535
4590
|
editable = inEditableDOM(wg, r.startContainer) && (empty || inEditableDOM(wg, r.endContainer));
|
|
4536
4591
|
}
|
|
4537
4592
|
wg.inputState.beforeInput(event, wg.inputState.pendingInputEvent = data);
|
|
@@ -4588,7 +4643,10 @@ const baseObservers = {
|
|
|
4588
4643
|
}
|
|
4589
4644
|
};
|
|
4590
4645
|
|
|
4591
|
-
const scrollIntoView = /*@__PURE__*/Transaction.Effect.define({
|
|
4646
|
+
const scrollIntoView = /*@__PURE__*/Transaction.Effect.define({
|
|
4647
|
+
name: "scrollIntoView",
|
|
4648
|
+
map: (t, ch) => t.map(ch)
|
|
4649
|
+
});
|
|
4592
4650
|
const selectionScrollSpec = {
|
|
4593
4651
|
x: "nearest",
|
|
4594
4652
|
y: "nearest",
|
|
@@ -4690,6 +4748,7 @@ class ViewState {
|
|
|
4690
4748
|
}
|
|
4691
4749
|
|
|
4692
4750
|
const cursorBlinkRate = /*@__PURE__*/GardState.Facet.define({
|
|
4751
|
+
name: "cursorBlinkRate",
|
|
4693
4752
|
combine: inputs => inputs.length ? Math.min(...inputs) : 1200
|
|
4694
4753
|
});
|
|
4695
4754
|
class CursorStyle {
|
|
@@ -4876,7 +4935,7 @@ function setBlinkRate(state, dom) {
|
|
|
4876
4935
|
dom.style.animationDuration = state.facet(cursorBlinkRate) + "ms";
|
|
4877
4936
|
}
|
|
4878
4937
|
|
|
4879
|
-
const dirCompartment = /*@__PURE__*/GardState.Compartment.define();
|
|
4938
|
+
const dirCompartment = /*@__PURE__*/GardState.Compartment.define("direction");
|
|
4880
4939
|
class Wordgard {
|
|
4881
4940
|
static create(spec) { return new Wordgard(spec); }
|
|
4882
4941
|
get state() { return this.viewState.state; }
|
|
@@ -5114,12 +5173,12 @@ class Wordgard {
|
|
|
5114
5173
|
}
|
|
5115
5174
|
for (let i = 0; i < this.plugins.length; i++)
|
|
5116
5175
|
this.plugins[i].update(this);
|
|
5117
|
-
if (
|
|
5176
|
+
if (update.state.facet(eventHandler) != update.startState.facet(eventHandler))
|
|
5118
5177
|
this.inputState.ensureHandlers(update.state);
|
|
5119
5178
|
}
|
|
5120
5179
|
updateAttrs() {
|
|
5121
5180
|
let editorAttrs = attrsFromFacet(this, Wordgard.editorAttributes, [
|
|
5122
|
-
"class", this.themeClasses
|
|
5181
|
+
"class", this.themeClasses + (this.inputState.notifiedFocused ? " wg-focused" : "")
|
|
5123
5182
|
]);
|
|
5124
5183
|
let contentAttrs = attrsFromFacet(this, Wordgard.contentAttributes, [
|
|
5125
5184
|
"aria-multiline", "true",
|
|
@@ -5275,18 +5334,21 @@ class Wordgard {
|
|
|
5275
5334
|
static clipboardTextParser = clipboardTextParser;
|
|
5276
5335
|
static clipboardInputTextFilter = clipboardInputTextFilter;
|
|
5277
5336
|
static pasteHandler = pasteHandler;
|
|
5337
|
+
paste(html, text) { doPaste(this, html, text || "", null, null); }
|
|
5278
5338
|
static dropHandler = dropHandler;
|
|
5279
5339
|
static isFocusChange = isFocusChange;
|
|
5280
|
-
static styleModule = /*@__PURE__*/GardState.Facet.define();
|
|
5340
|
+
static styleModule = /*@__PURE__*/GardState.Facet.define({ name: "styleModule" });
|
|
5281
5341
|
static domEventHandler(event, handler) {
|
|
5282
5342
|
return eventHandler.of({ event, handler: handler });
|
|
5283
5343
|
}
|
|
5284
5344
|
static domEventObserver(event, observer) {
|
|
5285
5345
|
return eventObserver.of({ event, observer: observer });
|
|
5286
5346
|
}
|
|
5287
|
-
static scrollHandler = /*@__PURE__*/GardState.Facet.define();
|
|
5347
|
+
static scrollHandler = /*@__PURE__*/GardState.Facet.define({ name: "scrollHandler" });
|
|
5288
5348
|
static exceptionSink = exceptionSink;
|
|
5289
|
-
static transactionListener = /*@__PURE__*/GardState.Facet.define(
|
|
5349
|
+
static transactionListener = /*@__PURE__*/GardState.Facet.define({
|
|
5350
|
+
name: "transactionListener"
|
|
5351
|
+
});
|
|
5290
5352
|
runTransactionListeners(trs) {
|
|
5291
5353
|
for (let l of this.state.facet(Wordgard.transactionListener)) {
|
|
5292
5354
|
let has = this.pendingTransactionListeners.get(l);
|
|
@@ -5301,8 +5363,11 @@ class Wordgard {
|
|
|
5301
5363
|
next.value(trs, this);
|
|
5302
5364
|
}
|
|
5303
5365
|
}
|
|
5304
|
-
static updateListener = /*@__PURE__*/GardState.Facet.define();
|
|
5305
|
-
static editable = /*@__PURE__*/GardState.Facet.define({
|
|
5366
|
+
static updateListener = /*@__PURE__*/GardState.Facet.define({ name: "updateListener" });
|
|
5367
|
+
static editable = /*@__PURE__*/GardState.Facet.define({
|
|
5368
|
+
name: "editable",
|
|
5369
|
+
combine: values => values.length ? values[0] : true
|
|
5370
|
+
});
|
|
5306
5371
|
static cursorBlinkRate = cursorBlinkRate;
|
|
5307
5372
|
static mouseSelectionStyle = mouseSelectionStyle;
|
|
5308
5373
|
static dragMovesSelection = dragBehavior;
|
|
@@ -5350,12 +5415,19 @@ class Wordgard {
|
|
|
5350
5415
|
}
|
|
5351
5416
|
});
|
|
5352
5417
|
}
|
|
5353
|
-
static cspNonce = /*@__PURE__*/GardState.Facet.define({
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5418
|
+
static cspNonce = /*@__PURE__*/GardState.Facet.define({
|
|
5419
|
+
name: "cspNonce",
|
|
5420
|
+
combine: values => values.length ? values[0] : ""
|
|
5421
|
+
});
|
|
5422
|
+
static contentAttributes = /*@__PURE__*/GardState.Facet.define({ name: "contentAttributes" });
|
|
5423
|
+
static editorAttributes = /*@__PURE__*/GardState.Facet.define({ name: "editorAttributes" });
|
|
5424
|
+
static announce = /*@__PURE__*/Transaction.Effect.define({ name: "announce" });
|
|
5357
5425
|
static DocTile = DocTile;
|
|
5358
|
-
static coveredMargins = /*@__PURE__*/GardState.Facet.define();
|
|
5426
|
+
static coveredMargins = /*@__PURE__*/GardState.Facet.define({ name: "coveredMargins" });
|
|
5427
|
+
static findFromDOM(elt) {
|
|
5428
|
+
let wg = elt.wg;
|
|
5429
|
+
return wg instanceof Wordgard ? wg : null;
|
|
5430
|
+
}
|
|
5359
5431
|
}
|
|
5360
5432
|
let _wrapElement = null;
|
|
5361
5433
|
function wrapElementConstructor() {
|
|
@@ -5477,7 +5549,7 @@ function attrsFromFacet(wg, facet, base) {
|
|
|
5477
5549
|
}
|
|
5478
5550
|
Wordgard.Update = Update;
|
|
5479
5551
|
;return Wordgard})(Wordgard);
|
|
5480
|
-
const editorPlugin = /*@__PURE__*/GardState.Facet.define();
|
|
5552
|
+
const editorPlugin = /*@__PURE__*/GardState.Facet.define({ name: "editorPlugin" });
|
|
5481
5553
|
const cursorPlugin = /*@__PURE__*/Wordgard.Plugin.fromClass(CursorLayer);
|
|
5482
5554
|
class PluginInstance {
|
|
5483
5555
|
spec;
|
|
@@ -5640,6 +5712,7 @@ class TooltipViewManager {
|
|
|
5640
5712
|
}
|
|
5641
5713
|
}
|
|
5642
5714
|
const tooltipConfig = /*@__PURE__*/GardState.Facet.define({
|
|
5715
|
+
name: "tooltipConfig",
|
|
5643
5716
|
combine: values => ({
|
|
5644
5717
|
position: browser.ios ? "absolute" : values.find(conf => conf.position)?.position || "fixed",
|
|
5645
5718
|
parent: values.find(conf => conf.parent)?.parent || null,
|
|
@@ -5951,13 +6024,14 @@ const styles = /*@__PURE__*/Wordgard.styles({
|
|
|
5951
6024
|
},
|
|
5952
6025
|
},
|
|
5953
6026
|
});
|
|
5954
|
-
const closeHoverTooltipEffect = /*@__PURE__*/Transaction.Effect.define();
|
|
6027
|
+
const closeHoverTooltipEffect = /*@__PURE__*/Transaction.Effect.define({ name: "closeHover" });
|
|
5955
6028
|
const Tooltip = /*@__PURE__*/(function (Tooltip) {
|
|
5956
6029
|
function configure(config = {}) {
|
|
5957
6030
|
return tooltipConfig.of(config);
|
|
5958
6031
|
}
|
|
5959
6032
|
Tooltip.configure = configure;
|
|
5960
6033
|
Tooltip.show = GardState.Facet.define({
|
|
6034
|
+
name: "tooltip",
|
|
5961
6035
|
enables: [tooltipPlugin, styles]
|
|
5962
6036
|
});
|
|
5963
6037
|
function get(wg, tooltip) {
|
|
@@ -6029,6 +6103,7 @@ const Tooltip = /*@__PURE__*/(function (Tooltip) {
|
|
|
6029
6103
|
;return Tooltip})({});
|
|
6030
6104
|
const noOffset = { x: 0, y: 0 };
|
|
6031
6105
|
const showHoverTooltip = /*@__PURE__*/GardState.Facet.define({
|
|
6106
|
+
name: "showHoverTooltip",
|
|
6032
6107
|
combine: inputs => inputs.reduce((a, i) => a.concat(i), [])
|
|
6033
6108
|
});
|
|
6034
6109
|
class HoverTooltipHost {
|
|
@@ -6381,9 +6456,10 @@ class OpenDialog {
|
|
|
6381
6456
|
this.offset = offset;
|
|
6382
6457
|
}
|
|
6383
6458
|
}
|
|
6384
|
-
const openDialog = /*@__PURE__*/Transaction.Effect.define();
|
|
6385
|
-
const closeDialog = /*@__PURE__*/Transaction.Effect.define();
|
|
6459
|
+
const openDialog = /*@__PURE__*/Transaction.Effect.define({ name: "openDialog" });
|
|
6460
|
+
const closeDialog = /*@__PURE__*/Transaction.Effect.define({ name: "closeDialog" });
|
|
6386
6461
|
const dialogs = /*@__PURE__*/GardState.Field.define({
|
|
6462
|
+
name: "dialogs",
|
|
6387
6463
|
create: () => [],
|
|
6388
6464
|
update: (value, tr) => {
|
|
6389
6465
|
for (let e of tr.effects) {
|
|
@@ -6674,6 +6750,7 @@ function decoratePlots(config) {
|
|
|
6674
6750
|
}
|
|
6675
6751
|
|
|
6676
6752
|
const panelConfig = /*@__PURE__*/GardState.Facet.define({
|
|
6753
|
+
name: "panelConfig",
|
|
6677
6754
|
combine(configs) {
|
|
6678
6755
|
let topContainer, bottomContainer;
|
|
6679
6756
|
for (let c of configs) {
|
|
@@ -6765,6 +6842,7 @@ const panelPlugin = /*@__PURE__*/Wordgard.Plugin.fromClass(class {
|
|
|
6765
6842
|
}));
|
|
6766
6843
|
const Panel = /*@__PURE__*/(function (Panel) {
|
|
6767
6844
|
Panel.show = GardState.Facet.define({
|
|
6845
|
+
name: "panel",
|
|
6768
6846
|
enables: panelPlugin
|
|
6769
6847
|
});
|
|
6770
6848
|
function get(wg, constructor) {
|
|
@@ -7379,6 +7457,7 @@ const theme = /*@__PURE__*/Wordgard.styles({
|
|
|
7379
7457
|
},
|
|
7380
7458
|
});
|
|
7381
7459
|
const barTemplate = /*@__PURE__*/GardState.Facet.define({
|
|
7460
|
+
name: "menuBarTemplate",
|
|
7382
7461
|
combine: inputs => inputs.length ? inputs[0] : [Menu.Group.top.template()]
|
|
7383
7462
|
});
|
|
7384
7463
|
function menuBar(config = {}) {
|
|
@@ -7388,7 +7467,7 @@ function menuBar(config = {}) {
|
|
|
7388
7467
|
return extensions;
|
|
7389
7468
|
}
|
|
7390
7469
|
|
|
7391
|
-
const inputRule = /*@__PURE__*/GardState.Facet.define();
|
|
7470
|
+
const inputRule = /*@__PURE__*/GardState.Facet.define({ name: "inputRule" });
|
|
7392
7471
|
const appender = /*@__PURE__*/Transaction.appender.of(applyInputRules);
|
|
7393
7472
|
class InputRule {
|
|
7394
7473
|
expr;
|
|
@@ -7444,13 +7523,14 @@ class InputRule {
|
|
|
7444
7523
|
lookahead: empty ? /^$/ : undefined
|
|
7445
7524
|
});
|
|
7446
7525
|
}
|
|
7526
|
+
toString() { return `InputRule(${this.expr})`; }
|
|
7447
7527
|
}
|
|
7448
7528
|
;InputRule = /*@__PURE__*/(function (InputRule) {
|
|
7449
7529
|
InputRule.emDash = InputRule.define({ expr: /--$/, apply: "—" });
|
|
7450
7530
|
InputRule.ellipsis = InputRule.define({ expr: /\.\.\.$/, apply: "…" });
|
|
7451
|
-
InputRule.openDoubleQuote = InputRule.define({ expr: /(
|
|
7531
|
+
InputRule.openDoubleQuote = InputRule.define({ expr: /(?<=^|[\s\{\[\(\<'"\u2018\u201C])"$/, apply: "“" });
|
|
7452
7532
|
InputRule.closeDoubleQuote = InputRule.define({ expr: /"$/, apply: "”" });
|
|
7453
|
-
InputRule.openSingleQuote = InputRule.define({ expr: /(
|
|
7533
|
+
InputRule.openSingleQuote = InputRule.define({ expr: /(?<=^|[\s\{\[\(\<'"\u2018\u201C])'$/, apply: "‘" });
|
|
7454
7534
|
InputRule.closeSingleQuote = InputRule.define({ expr: /'$/, apply: "’" });
|
|
7455
7535
|
InputRule.smartQuotes = [InputRule.openDoubleQuote, InputRule.closeDoubleQuote, InputRule.openSingleQuote, InputRule.closeSingleQuote];
|
|
7456
7536
|
;return InputRule})(InputRule);
|
|
@@ -7534,7 +7614,7 @@ const placeholderWidget = /*@__PURE__*/Widget.define({
|
|
|
7534
7614
|
return elt;
|
|
7535
7615
|
}
|
|
7536
7616
|
});
|
|
7537
|
-
const placeholderShape = /*@__PURE__*/GardState.Facet.define();
|
|
7617
|
+
const placeholderShape = /*@__PURE__*/GardState.Facet.define({ name: "placeholderShape" });
|
|
7538
7618
|
function showPlaceholder(state) {
|
|
7539
7619
|
let pos = -1;
|
|
7540
7620
|
if (state.doc.length == 0)
|
|
@@ -7549,6 +7629,7 @@ function showPlaceholder(state) {
|
|
|
7549
7629
|
return Decoration.Point.set([[Decoration.Point.widget(placeholderWidget.of(shape[0]), { side: 1 }), pos]]);
|
|
7550
7630
|
}
|
|
7551
7631
|
const placeholderField = /*@__PURE__*/GardState.Field.define({
|
|
7632
|
+
name: "placeholder",
|
|
7552
7633
|
create(state) {
|
|
7553
7634
|
return showPlaceholder(state);
|
|
7554
7635
|
},
|
|
@@ -7565,9 +7646,11 @@ function placeholder(content) {
|
|
|
7565
7646
|
}
|
|
7566
7647
|
|
|
7567
7648
|
const setDropCursorPos = /*@__PURE__*/Transaction.Effect.define({
|
|
7649
|
+
name: "setDropCursorPos",
|
|
7568
7650
|
map(pos, mapping) { return pos == null ? null : { pos: mapping.mapPos(pos.pos), side: pos.side }; }
|
|
7569
7651
|
});
|
|
7570
7652
|
const dropCursorPos = /*@__PURE__*/GardState.Field.define({
|
|
7653
|
+
name: "dropCursorPos",
|
|
7571
7654
|
create() { return null; },
|
|
7572
7655
|
update(pos, tr) {
|
|
7573
7656
|
if (pos != null)
|
package/dist/history.js
CHANGED
|
@@ -4,6 +4,7 @@ import { Command, undo as undo$1, redo as redo$1, Menu } from 'wordgard/command'
|
|
|
4
4
|
import { phrases } from 'wordgard/phrases';
|
|
5
5
|
|
|
6
6
|
const fromHistory = /*@__PURE__*/Transaction.Effect.define({
|
|
7
|
+
name: "fromHistory",
|
|
7
8
|
map(value, change) {
|
|
8
9
|
return {
|
|
9
10
|
side: value.side,
|
|
@@ -13,6 +14,7 @@ const fromHistory = /*@__PURE__*/Transaction.Effect.define({
|
|
|
13
14
|
}
|
|
14
15
|
});
|
|
15
16
|
const historyConfig = /*@__PURE__*/GardState.Facet.define({
|
|
17
|
+
name: "historyConfig",
|
|
16
18
|
combine(configs) {
|
|
17
19
|
return GardState.Facet.combineConfig(configs, {
|
|
18
20
|
minDepth: 100,
|
|
@@ -26,6 +28,7 @@ const historyConfig = /*@__PURE__*/GardState.Facet.define({
|
|
|
26
28
|
}
|
|
27
29
|
});
|
|
28
30
|
const historyField_ = /*@__PURE__*/GardState.Field.define({
|
|
31
|
+
name: "history",
|
|
29
32
|
create() {
|
|
30
33
|
return new HistoryState(null, null);
|
|
31
34
|
},
|
|
@@ -88,8 +91,10 @@ function history(config = {}) {
|
|
|
88
91
|
}
|
|
89
92
|
;history = /*@__PURE__*/(function (history) {
|
|
90
93
|
history.field = historyField_;
|
|
91
|
-
history.isolate = Transaction.Annotation.define();
|
|
92
|
-
history.invertedEffects = GardState.Facet.define(
|
|
94
|
+
history.isolate = Transaction.Annotation.define("historyIsolate");
|
|
95
|
+
history.invertedEffects = GardState.Facet.define({
|
|
96
|
+
name: "invertedEffects"
|
|
97
|
+
});
|
|
93
98
|
;return history})(history);
|
|
94
99
|
const undo = ({ state }) => {
|
|
95
100
|
let historyState = state.field(historyField_, false);
|