@nerd-bible/wordgard 0.6.2-beta7 → 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 +40 -18
- package/dist/editor.d.ts +16 -4
- package/dist/editor.js +188 -95
- package/dist/history.js +7 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- 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.d.ts +111 -1
- package/dist/table.js +32 -22
- package/package.json +1 -1
package/dist/editor.js
CHANGED
|
@@ -132,6 +132,7 @@ function joinRanges(ranges) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
var Mark_ = Mark;
|
|
135
136
|
class Widget {
|
|
136
137
|
value;
|
|
137
138
|
constructor(type,
|
|
@@ -198,6 +199,7 @@ class Widget {
|
|
|
198
199
|
render() {
|
|
199
200
|
let img = document.createElement("img");
|
|
200
201
|
img.className = "wg-buffer";
|
|
202
|
+
img.alt = "";
|
|
201
203
|
return img;
|
|
202
204
|
},
|
|
203
205
|
editable: true
|
|
@@ -206,6 +208,7 @@ class Widget {
|
|
|
206
208
|
render() {
|
|
207
209
|
let img = document.createElement("img");
|
|
208
210
|
img.className = "wg-blockBuffer";
|
|
211
|
+
img.alt = "";
|
|
209
212
|
return img;
|
|
210
213
|
},
|
|
211
214
|
editable: true
|
|
@@ -286,15 +289,15 @@ const Decoration = /*@__PURE__*/(function (Decoration) {
|
|
|
286
289
|
}
|
|
287
290
|
Tag.attribute = attribute;
|
|
288
291
|
})(Decoration.Tag || (Decoration.Tag = {}));
|
|
289
|
-
(function (Mark
|
|
292
|
+
(function (Mark) {
|
|
290
293
|
function shape(type, shape) {
|
|
291
|
-
if (type instanceof
|
|
294
|
+
if (type instanceof Mark_)
|
|
292
295
|
type = type.type;
|
|
293
296
|
if (type.spanning && !("element" in shape))
|
|
294
297
|
throw new Error("Spanning marks must have an element shape");
|
|
295
|
-
return markShape.of({ type, modified:
|
|
298
|
+
return markShape.of({ type, modified: Mark_.Type.define(type.name, { ...type.spec, shape }) });
|
|
296
299
|
}
|
|
297
|
-
Mark
|
|
300
|
+
Mark.shape = shape;
|
|
298
301
|
})(Decoration.Mark || (Decoration.Mark = {}));
|
|
299
302
|
class Point {
|
|
300
303
|
constructor() { }
|
|
@@ -313,6 +316,7 @@ const Decoration = /*@__PURE__*/(function (Decoration) {
|
|
|
313
316
|
return new WrapperDecoration(wrapper, spec?.target ? Elt.Selector.parse(spec.target) : null);
|
|
314
317
|
}
|
|
315
318
|
static source = GardState.Facet.define({
|
|
319
|
+
name: "pointDecorations",
|
|
316
320
|
combine: sources => sources.concat(nodeSelection)
|
|
317
321
|
});
|
|
318
322
|
static set(source) { return PointSet.create(source); }
|
|
@@ -337,19 +341,21 @@ const Decoration = /*@__PURE__*/(function (Decoration) {
|
|
|
337
341
|
static attribute(attr, value, options = {}) {
|
|
338
342
|
return new AttributeRangeDecoration(attr, value, options);
|
|
339
343
|
}
|
|
340
|
-
static source = GardState.Facet.define();
|
|
344
|
+
static source = GardState.Facet.define({ name: "rangeDecorations" });
|
|
341
345
|
static set(source) { return RangeSet.create(source); }
|
|
342
346
|
static none = RangeSet.empty;
|
|
343
347
|
}
|
|
344
348
|
Decoration.Range = Range;
|
|
345
349
|
;return Decoration})({});
|
|
346
350
|
const tagShape = /*@__PURE__*/GardState.Facet.define({
|
|
351
|
+
name: "tagShape",
|
|
347
352
|
combine: shapes => new Map(shapes.map(s => [s.type, s.shape]).reverse())
|
|
348
353
|
});
|
|
349
|
-
const tagWrapper = /*@__PURE__*/GardState.Facet.define();
|
|
350
|
-
const tagWidget = /*@__PURE__*/GardState.Facet.define();
|
|
351
|
-
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" });
|
|
352
357
|
const markShape = /*@__PURE__*/GardState.Facet.define({
|
|
358
|
+
name: "markShape",
|
|
353
359
|
combine: shapes => new Map(shapes.map(s => [s.type, s.modified]).reverse())
|
|
354
360
|
});
|
|
355
361
|
function memo(f) {
|
|
@@ -763,15 +769,17 @@ class DecoIterator {
|
|
|
763
769
|
shape = applyDeco(shape, deco, node.tag);
|
|
764
770
|
let wrappers = this.nodeWrappers(node.tag, iter.active, !shape.hasContent);
|
|
765
771
|
let atom = !shape.hasContent;
|
|
766
|
-
if (atom)
|
|
772
|
+
if (atom) {
|
|
767
773
|
walker.node(node, shape, wrappers, pos + node.length > to ? to - pos : undefined);
|
|
768
|
-
|
|
774
|
+
}
|
|
775
|
+
else {
|
|
769
776
|
walker.enter(node, shape, wrappers);
|
|
770
|
-
|
|
777
|
+
this.widgets(node.tag, 2, walker);
|
|
778
|
+
}
|
|
771
779
|
return !atom;
|
|
772
780
|
},
|
|
773
781
|
leavePlot: tag => {
|
|
774
|
-
if (started)
|
|
782
|
+
if (started && !atomParent)
|
|
775
783
|
this.widgets(tag, 3, walker);
|
|
776
784
|
else
|
|
777
785
|
started = true;
|
|
@@ -779,7 +787,7 @@ class DecoIterator {
|
|
|
779
787
|
this.widgets(tag, 1, walker);
|
|
780
788
|
}
|
|
781
789
|
};
|
|
782
|
-
if (inclusiveStart) {
|
|
790
|
+
if (inclusiveStart && !atomParent) {
|
|
783
791
|
let before = pos.nodeBefore;
|
|
784
792
|
if (before)
|
|
785
793
|
this.widgets(before.tag, 1, walker);
|
|
@@ -791,9 +799,10 @@ class DecoIterator {
|
|
|
791
799
|
let end = Math.min(to, atomParent.after), done = atomParent.after <= to;
|
|
792
800
|
walker.nodePart(atomParent.node, end - pos.pos, done);
|
|
793
801
|
pos = pos.advance(end - pos.pos);
|
|
794
|
-
if (done)
|
|
802
|
+
if (done) {
|
|
795
803
|
this.widgets(atomParent.node.tag, 1, walker);
|
|
796
|
-
|
|
804
|
+
atomParent = undefined;
|
|
805
|
+
}
|
|
797
806
|
while (iter.point && iter.from < end)
|
|
798
807
|
iter.next();
|
|
799
808
|
}
|
|
@@ -899,7 +908,7 @@ function eqArray(a, b) {
|
|
|
899
908
|
return false;
|
|
900
909
|
return true;
|
|
901
910
|
}
|
|
902
|
-
const exceptionSink = /*@__PURE__*/GardState.Facet.define();
|
|
911
|
+
const exceptionSink = /*@__PURE__*/GardState.Facet.define({ name: "exceptionSink" });
|
|
903
912
|
function logException(state, exception, context) {
|
|
904
913
|
let handler = state.facet(exceptionSink);
|
|
905
914
|
if (handler.length)
|
|
@@ -912,6 +921,28 @@ function logException(state, exception, context) {
|
|
|
912
921
|
console.error(exception);
|
|
913
922
|
}
|
|
914
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
|
+
|
|
915
946
|
function getSelection(root) {
|
|
916
947
|
let target;
|
|
917
948
|
if (root.nodeType == 11) { target = root.getSelection ? root : root.ownerDocument;
|
|
@@ -921,6 +952,17 @@ function getSelection(root) {
|
|
|
921
952
|
}
|
|
922
953
|
return target.getSelection();
|
|
923
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
|
+
}
|
|
924
966
|
function hasSelection(dom, selection) {
|
|
925
967
|
if (!selection.focusNode)
|
|
926
968
|
return false;
|
|
@@ -2082,6 +2124,9 @@ class ContentUpdate {
|
|
|
2082
2124
|
this.partialNode = null;
|
|
2083
2125
|
this.new.addChild(this.buildNodeShape(tag, length + (to - from), shape, reuse));
|
|
2084
2126
|
}
|
|
2127
|
+
else {
|
|
2128
|
+
this.partialNode.length += to - from;
|
|
2129
|
+
}
|
|
2085
2130
|
}
|
|
2086
2131
|
}
|
|
2087
2132
|
else if (this.new.lastChild instanceof TextTile && !this.new.lastChild.isComposition) {
|
|
@@ -2295,6 +2340,9 @@ class ContentUpdate {
|
|
|
2295
2340
|
for (let i = 0; i < wrappers; i++)
|
|
2296
2341
|
this.up();
|
|
2297
2342
|
}
|
|
2343
|
+
else {
|
|
2344
|
+
this.partialNode.length += length;
|
|
2345
|
+
}
|
|
2298
2346
|
},
|
|
2299
2347
|
widget: (widget, side) => {
|
|
2300
2348
|
let sideFlag = side < 0 ? 32 : side > 0 ? 64 : 0;
|
|
@@ -2675,36 +2723,28 @@ function flattenH(rect, top) {
|
|
|
2675
2723
|
return rect.height ? new DOMRect(rect.left, top ? rect.top : rect.bottom, rect.width, 0) : rect;
|
|
2676
2724
|
}
|
|
2677
2725
|
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
const
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
const
|
|
2685
|
-
const
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
const clipboardOutputFilter = /*@__PURE__*/GardState.Facet.define();
|
|
2701
|
-
const clipboardOutputHTMLFilter = /*@__PURE__*/GardState.Facet.define();
|
|
2702
|
-
const clipboardTextSerializer = /*@__PURE__*/GardState.Facet.define();
|
|
2703
|
-
const clipboardOutputTextFilter = /*@__PURE__*/GardState.Facet.define();
|
|
2704
|
-
const clipboardInputFilter = /*@__PURE__*/GardState.Facet.define();
|
|
2705
|
-
const clipboardInputHTMLFilter = /*@__PURE__*/GardState.Facet.define();
|
|
2706
|
-
const clipboardTextParser = /*@__PURE__*/GardState.Facet.define();
|
|
2707
|
-
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
|
+
});
|
|
2708
2748
|
function writeClipboard(state, slice, data) {
|
|
2709
2749
|
for (let filter of state.facet(clipboardOutputFilter))
|
|
2710
2750
|
slice = filter(slice, state);
|
|
@@ -2752,9 +2792,7 @@ function writeClipboard(state, slice, data) {
|
|
|
2752
2792
|
function isOpen(elt) {
|
|
2753
2793
|
return (elt.getAttribute("wg-open") || null);
|
|
2754
2794
|
}
|
|
2755
|
-
function readClipboard(state,
|
|
2756
|
-
let html = data.getData("text/html");
|
|
2757
|
-
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) {
|
|
2758
2796
|
let slice;
|
|
2759
2797
|
if (text && (targetContext.parent.node.type.hasRole(Node.Role.Code) || !html || plain)) {
|
|
2760
2798
|
for (let filter of state.facet(clipboardInputTextFilter))
|
|
@@ -2852,8 +2890,12 @@ function restoreReplacedSpaces(dom) {
|
|
|
2852
2890
|
}
|
|
2853
2891
|
}
|
|
2854
2892
|
|
|
2855
|
-
const theme$1 = /*@__PURE__*/GardState.Facet.define({
|
|
2893
|
+
const theme$1 = /*@__PURE__*/GardState.Facet.define({
|
|
2894
|
+
name: "theme",
|
|
2895
|
+
combine: strs => strs.join(" ")
|
|
2896
|
+
});
|
|
2856
2897
|
const colorScheme = /*@__PURE__*/GardState.Facet.define({
|
|
2898
|
+
name: "colorScheme",
|
|
2857
2899
|
combine: values => values.length ? values[0] : "light"
|
|
2858
2900
|
});
|
|
2859
2901
|
const styleID = /*@__PURE__*/StyleModule.newName(), baseLightID = /*@__PURE__*/StyleModule.newName(), baseDarkID = /*@__PURE__*/StyleModule.newName();
|
|
@@ -2881,7 +2923,7 @@ const baseStyles = /*@__PURE__*/buildTheme("." + styleID, {
|
|
|
2881
2923
|
flexDirection: "column",
|
|
2882
2924
|
border: "1px solid var(--wg-border-color)"
|
|
2883
2925
|
},
|
|
2884
|
-
"
|
|
2926
|
+
"&.wg-focused": {
|
|
2885
2927
|
outline: "1px solid var(--wg-highlight-color)",
|
|
2886
2928
|
"& > wg-scroller > wg-cursor-layer": {
|
|
2887
2929
|
animation: "steps(1) wg-blink 1.2s infinite"
|
|
@@ -3404,6 +3446,7 @@ class DOMObserver {
|
|
|
3404
3446
|
clear() {
|
|
3405
3447
|
this.takeRecords();
|
|
3406
3448
|
this.readSelectionRange();
|
|
3449
|
+
this.selectionChanged = false;
|
|
3407
3450
|
}
|
|
3408
3451
|
takeRecords() {
|
|
3409
3452
|
for (let mut of this.observer.takeRecords())
|
|
@@ -3494,6 +3537,7 @@ class KeyBinding {
|
|
|
3494
3537
|
this.extension = KeyBinding.source.of(this);
|
|
3495
3538
|
}
|
|
3496
3539
|
static of(spec) { return new KeyBinding(spec); }
|
|
3540
|
+
toString() { return `KeyBinding:${this.spec.key || this.spec.char || "??"}`; }
|
|
3497
3541
|
}
|
|
3498
3542
|
;KeyBinding = /*@__PURE__*/(function (KeyBinding) {
|
|
3499
3543
|
function handle(wg, event) {
|
|
@@ -3506,9 +3550,11 @@ class KeyBinding {
|
|
|
3506
3550
|
return s.facet(KeyBinding.useDefaultKeymap) ? bindings.concat(KeyBinding.defaultKeymap) : bindings;
|
|
3507
3551
|
});
|
|
3508
3552
|
KeyBinding.source = GardState.Facet.define({
|
|
3553
|
+
name: "keyBinding",
|
|
3509
3554
|
enables: KeyBinding.keymap
|
|
3510
3555
|
});
|
|
3511
3556
|
KeyBinding.useDefaultKeymap = GardState.Facet.define({
|
|
3557
|
+
name: "useDefaultKeymap",
|
|
3512
3558
|
combine: input => input.length ? input[0] : true
|
|
3513
3559
|
});
|
|
3514
3560
|
class Group {
|
|
@@ -3665,7 +3711,7 @@ class NormalizedBinding {
|
|
|
3665
3711
|
}
|
|
3666
3712
|
const keymapCache = /*@__PURE__*/(() => new WeakMap())();
|
|
3667
3713
|
function getKeymap(state) {
|
|
3668
|
-
let bindings = state.field(KeyBinding.keymap);
|
|
3714
|
+
let bindings = state.field(KeyBinding.keymap, false);
|
|
3669
3715
|
let found = keymapCache.get(bindings);
|
|
3670
3716
|
if (!found)
|
|
3671
3717
|
keymapCache.set(bindings, found = buildKeymap(bindings, currentPlatform));
|
|
@@ -3754,6 +3800,7 @@ function buildCharKeyCodes() {
|
|
|
3754
3800
|
const charKeyCodes = /*@__PURE__*/buildCharKeyCodes();
|
|
3755
3801
|
|
|
3756
3802
|
const eventHandler = /*@__PURE__*/GardState.Facet.define({
|
|
3803
|
+
name: "eventHandler",
|
|
3757
3804
|
combine: handlers => {
|
|
3758
3805
|
let result = Object.create(null);
|
|
3759
3806
|
for (let { event, handler } of handlers)
|
|
@@ -3762,6 +3809,7 @@ const eventHandler = /*@__PURE__*/GardState.Facet.define({
|
|
|
3762
3809
|
}
|
|
3763
3810
|
});
|
|
3764
3811
|
const eventObserver = /*@__PURE__*/GardState.Facet.define({
|
|
3812
|
+
name: "eventObserver",
|
|
3765
3813
|
combine: observers => {
|
|
3766
3814
|
let result = Object.create(null);
|
|
3767
3815
|
for (let { event, observer } of observers)
|
|
@@ -3949,22 +3997,18 @@ class InputState {
|
|
|
3949
3997
|
Command.dispatch(wg, insertText, { from, to, insert, userEvent: "input.type" });
|
|
3950
3998
|
}
|
|
3951
3999
|
else if (type == "insertFromPaste") {
|
|
3952
|
-
let
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
if (slice) {
|
|
3958
|
-
wg.dispatch({
|
|
3959
|
-
changes: { correct: { from, to, insert: slice, fit: true }, local: true },
|
|
3960
|
-
selection: isSel ? (cx, changes) => GardSelection.near(cx, changes.mapPos(to, 1), -1) : undefined,
|
|
3961
|
-
userEvent: "input.paste",
|
|
3962
|
-
scrollIntoView: isSel
|
|
3963
|
-
});
|
|
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);
|
|
3964
4005
|
}
|
|
4006
|
+
let transfer = event.dataTransfer;
|
|
4007
|
+
doPaste(wg, getHTML(transfer), getText(transfer), isSel ? null : range, event);
|
|
3965
4008
|
}
|
|
3966
4009
|
else if ((type == "insertReplacementText" || type == "insertFromYank")) {
|
|
3967
|
-
let
|
|
4010
|
+
let transfer = event.dataTransfer;
|
|
4011
|
+
let read = readClipboard(wg.state, getHTML(transfer), getText(transfer), wg.state.sel.head, true);
|
|
3968
4012
|
let { from, to } = this.unflushedSelection ? wg.state.selection : range;
|
|
3969
4013
|
let sel = wg.state.selection, touchesSel = from <= sel.to && to >= sel.from;
|
|
3970
4014
|
if (read)
|
|
@@ -4104,6 +4148,12 @@ class InputState {
|
|
|
4104
4148
|
this.mouseSelection.disconnect();
|
|
4105
4149
|
}
|
|
4106
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
|
+
}
|
|
4107
4157
|
function isSingleChar(doc, from, to) {
|
|
4108
4158
|
if (to > from + 10)
|
|
4109
4159
|
return false;
|
|
@@ -4142,8 +4192,22 @@ function computeHandlers(state) {
|
|
|
4142
4192
|
record(type).observers.push(baseObservers[type]);
|
|
4143
4193
|
return result;
|
|
4144
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
|
+
}
|
|
4145
4209
|
const dragScrollMargin = 6;
|
|
4146
|
-
const mouseSelectionStyle = /*@__PURE__*/GardState.Facet.define();
|
|
4210
|
+
const mouseSelectionStyle = /*@__PURE__*/GardState.Facet.define({ name: "mouseSelectionStyle" });
|
|
4147
4211
|
function dragScrollSpeed(dist) {
|
|
4148
4212
|
return Math.max(0, dist) * 0.7 + 8;
|
|
4149
4213
|
}
|
|
@@ -4257,7 +4321,7 @@ class MouseSelection {
|
|
|
4257
4321
|
setTimeout(() => this.select(this.lastEvent), 20);
|
|
4258
4322
|
}
|
|
4259
4323
|
}
|
|
4260
|
-
const dragBehavior = /*@__PURE__*/GardState.Facet.define();
|
|
4324
|
+
const dragBehavior = /*@__PURE__*/GardState.Facet.define({ name: "dragBehavior" });
|
|
4261
4325
|
function dragMovesSelection(wg, event) {
|
|
4262
4326
|
let facet = wg.state.facet(dragBehavior);
|
|
4263
4327
|
return facet.length ? facet[0](event) : browser.mac ? !event.altKey : !event.ctrlKey;
|
|
@@ -4333,8 +4397,8 @@ function basicMouseSelection(wg, event) {
|
|
|
4333
4397
|
}
|
|
4334
4398
|
};
|
|
4335
4399
|
}
|
|
4336
|
-
const dropHandler = /*@__PURE__*/GardState.Facet.define();
|
|
4337
|
-
const pasteHandler = /*@__PURE__*/GardState.Facet.define();
|
|
4400
|
+
const dropHandler = /*@__PURE__*/GardState.Facet.define({ name: "dropHandler" });
|
|
4401
|
+
const pasteHandler = /*@__PURE__*/GardState.Facet.define({ name: "pasteHandler" });
|
|
4338
4402
|
function copy(wg, event) {
|
|
4339
4403
|
let { state } = wg;
|
|
4340
4404
|
if (!state.selection.empty && event.clipboardData) {
|
|
@@ -4350,7 +4414,7 @@ function copy(wg, event) {
|
|
|
4350
4414
|
}
|
|
4351
4415
|
return true;
|
|
4352
4416
|
}
|
|
4353
|
-
const isFocusChange = /*@__PURE__*/Transaction.Annotation.define();
|
|
4417
|
+
const isFocusChange = /*@__PURE__*/Transaction.Annotation.define("focusChange");
|
|
4354
4418
|
function updateForFocusChange(wg) {
|
|
4355
4419
|
setTimeout(() => {
|
|
4356
4420
|
let focus = wg.hasFocus;
|
|
@@ -4484,9 +4548,10 @@ const baseHandlers = {
|
|
|
4484
4548
|
copy,
|
|
4485
4549
|
cut: copy,
|
|
4486
4550
|
drop(wg, event) {
|
|
4487
|
-
|
|
4551
|
+
let data = event.dataTransfer;
|
|
4552
|
+
if (!data || wg.state.readOnly)
|
|
4488
4553
|
return true;
|
|
4489
|
-
let slice = readClipboard(wg.state,
|
|
4554
|
+
let slice = readClipboard(wg.state, getHTML(data), getText(data), wg.state.sel.head, false);
|
|
4490
4555
|
if (!slice)
|
|
4491
4556
|
return false;
|
|
4492
4557
|
let dropPos = wg.posAtCoords({ x: event.clientX, y: event.clientY }).pos;
|
|
@@ -4521,7 +4586,7 @@ const baseHandlers = {
|
|
|
4521
4586
|
if (ranges.length) {
|
|
4522
4587
|
let r = ranges[0], empty = r.collapsed;
|
|
4523
4588
|
let from = wg.inputState.getDOMPos(r.startContainer, r.startOffset);
|
|
4524
|
-
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 };
|
|
4525
4590
|
editable = inEditableDOM(wg, r.startContainer) && (empty || inEditableDOM(wg, r.endContainer));
|
|
4526
4591
|
}
|
|
4527
4592
|
wg.inputState.beforeInput(event, wg.inputState.pendingInputEvent = data);
|
|
@@ -4578,7 +4643,10 @@ const baseObservers = {
|
|
|
4578
4643
|
}
|
|
4579
4644
|
};
|
|
4580
4645
|
|
|
4581
|
-
const scrollIntoView = /*@__PURE__*/Transaction.Effect.define({
|
|
4646
|
+
const scrollIntoView = /*@__PURE__*/Transaction.Effect.define({
|
|
4647
|
+
name: "scrollIntoView",
|
|
4648
|
+
map: (t, ch) => t.map(ch)
|
|
4649
|
+
});
|
|
4582
4650
|
const selectionScrollSpec = {
|
|
4583
4651
|
x: "nearest",
|
|
4584
4652
|
y: "nearest",
|
|
@@ -4680,6 +4748,7 @@ class ViewState {
|
|
|
4680
4748
|
}
|
|
4681
4749
|
|
|
4682
4750
|
const cursorBlinkRate = /*@__PURE__*/GardState.Facet.define({
|
|
4751
|
+
name: "cursorBlinkRate",
|
|
4683
4752
|
combine: inputs => inputs.length ? Math.min(...inputs) : 1200
|
|
4684
4753
|
});
|
|
4685
4754
|
class CursorStyle {
|
|
@@ -4866,7 +4935,7 @@ function setBlinkRate(state, dom) {
|
|
|
4866
4935
|
dom.style.animationDuration = state.facet(cursorBlinkRate) + "ms";
|
|
4867
4936
|
}
|
|
4868
4937
|
|
|
4869
|
-
const dirCompartment = /*@__PURE__*/GardState.Compartment.define();
|
|
4938
|
+
const dirCompartment = /*@__PURE__*/GardState.Compartment.define("direction");
|
|
4870
4939
|
class Wordgard {
|
|
4871
4940
|
static create(spec) { return new Wordgard(spec); }
|
|
4872
4941
|
get state() { return this.viewState.state; }
|
|
@@ -5104,12 +5173,12 @@ class Wordgard {
|
|
|
5104
5173
|
}
|
|
5105
5174
|
for (let i = 0; i < this.plugins.length; i++)
|
|
5106
5175
|
this.plugins[i].update(this);
|
|
5107
|
-
if (
|
|
5176
|
+
if (update.state.facet(eventHandler) != update.startState.facet(eventHandler))
|
|
5108
5177
|
this.inputState.ensureHandlers(update.state);
|
|
5109
5178
|
}
|
|
5110
5179
|
updateAttrs() {
|
|
5111
5180
|
let editorAttrs = attrsFromFacet(this, Wordgard.editorAttributes, [
|
|
5112
|
-
"class", this.themeClasses
|
|
5181
|
+
"class", this.themeClasses + (this.inputState.notifiedFocused ? " wg-focused" : "")
|
|
5113
5182
|
]);
|
|
5114
5183
|
let contentAttrs = attrsFromFacet(this, Wordgard.contentAttributes, [
|
|
5115
5184
|
"aria-multiline", "true",
|
|
@@ -5265,18 +5334,21 @@ class Wordgard {
|
|
|
5265
5334
|
static clipboardTextParser = clipboardTextParser;
|
|
5266
5335
|
static clipboardInputTextFilter = clipboardInputTextFilter;
|
|
5267
5336
|
static pasteHandler = pasteHandler;
|
|
5337
|
+
paste(html, text) { doPaste(this, html, text || "", null, null); }
|
|
5268
5338
|
static dropHandler = dropHandler;
|
|
5269
5339
|
static isFocusChange = isFocusChange;
|
|
5270
|
-
static styleModule = /*@__PURE__*/GardState.Facet.define();
|
|
5340
|
+
static styleModule = /*@__PURE__*/GardState.Facet.define({ name: "styleModule" });
|
|
5271
5341
|
static domEventHandler(event, handler) {
|
|
5272
5342
|
return eventHandler.of({ event, handler: handler });
|
|
5273
5343
|
}
|
|
5274
5344
|
static domEventObserver(event, observer) {
|
|
5275
5345
|
return eventObserver.of({ event, observer: observer });
|
|
5276
5346
|
}
|
|
5277
|
-
static scrollHandler = /*@__PURE__*/GardState.Facet.define();
|
|
5347
|
+
static scrollHandler = /*@__PURE__*/GardState.Facet.define({ name: "scrollHandler" });
|
|
5278
5348
|
static exceptionSink = exceptionSink;
|
|
5279
|
-
static transactionListener = /*@__PURE__*/GardState.Facet.define(
|
|
5349
|
+
static transactionListener = /*@__PURE__*/GardState.Facet.define({
|
|
5350
|
+
name: "transactionListener"
|
|
5351
|
+
});
|
|
5280
5352
|
runTransactionListeners(trs) {
|
|
5281
5353
|
for (let l of this.state.facet(Wordgard.transactionListener)) {
|
|
5282
5354
|
let has = this.pendingTransactionListeners.get(l);
|
|
@@ -5291,8 +5363,11 @@ class Wordgard {
|
|
|
5291
5363
|
next.value(trs, this);
|
|
5292
5364
|
}
|
|
5293
5365
|
}
|
|
5294
|
-
static updateListener = /*@__PURE__*/GardState.Facet.define();
|
|
5295
|
-
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
|
+
});
|
|
5296
5371
|
static cursorBlinkRate = cursorBlinkRate;
|
|
5297
5372
|
static mouseSelectionStyle = mouseSelectionStyle;
|
|
5298
5373
|
static dragMovesSelection = dragBehavior;
|
|
@@ -5340,12 +5415,19 @@ class Wordgard {
|
|
|
5340
5415
|
}
|
|
5341
5416
|
});
|
|
5342
5417
|
}
|
|
5343
|
-
static cspNonce = /*@__PURE__*/GardState.Facet.define({
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
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" });
|
|
5347
5425
|
static DocTile = DocTile;
|
|
5348
|
-
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
|
+
}
|
|
5349
5431
|
}
|
|
5350
5432
|
let _wrapElement = null;
|
|
5351
5433
|
function wrapElementConstructor() {
|
|
@@ -5467,7 +5549,7 @@ function attrsFromFacet(wg, facet, base) {
|
|
|
5467
5549
|
}
|
|
5468
5550
|
Wordgard.Update = Update;
|
|
5469
5551
|
;return Wordgard})(Wordgard);
|
|
5470
|
-
const editorPlugin = /*@__PURE__*/GardState.Facet.define();
|
|
5552
|
+
const editorPlugin = /*@__PURE__*/GardState.Facet.define({ name: "editorPlugin" });
|
|
5471
5553
|
const cursorPlugin = /*@__PURE__*/Wordgard.Plugin.fromClass(CursorLayer);
|
|
5472
5554
|
class PluginInstance {
|
|
5473
5555
|
spec;
|
|
@@ -5630,6 +5712,7 @@ class TooltipViewManager {
|
|
|
5630
5712
|
}
|
|
5631
5713
|
}
|
|
5632
5714
|
const tooltipConfig = /*@__PURE__*/GardState.Facet.define({
|
|
5715
|
+
name: "tooltipConfig",
|
|
5633
5716
|
combine: values => ({
|
|
5634
5717
|
position: browser.ios ? "absolute" : values.find(conf => conf.position)?.position || "fixed",
|
|
5635
5718
|
parent: values.find(conf => conf.parent)?.parent || null,
|
|
@@ -5941,13 +6024,14 @@ const styles = /*@__PURE__*/Wordgard.styles({
|
|
|
5941
6024
|
},
|
|
5942
6025
|
},
|
|
5943
6026
|
});
|
|
5944
|
-
const closeHoverTooltipEffect = /*@__PURE__*/Transaction.Effect.define();
|
|
6027
|
+
const closeHoverTooltipEffect = /*@__PURE__*/Transaction.Effect.define({ name: "closeHover" });
|
|
5945
6028
|
const Tooltip = /*@__PURE__*/(function (Tooltip) {
|
|
5946
6029
|
function configure(config = {}) {
|
|
5947
6030
|
return tooltipConfig.of(config);
|
|
5948
6031
|
}
|
|
5949
6032
|
Tooltip.configure = configure;
|
|
5950
6033
|
Tooltip.show = GardState.Facet.define({
|
|
6034
|
+
name: "tooltip",
|
|
5951
6035
|
enables: [tooltipPlugin, styles]
|
|
5952
6036
|
});
|
|
5953
6037
|
function get(wg, tooltip) {
|
|
@@ -6019,6 +6103,7 @@ const Tooltip = /*@__PURE__*/(function (Tooltip) {
|
|
|
6019
6103
|
;return Tooltip})({});
|
|
6020
6104
|
const noOffset = { x: 0, y: 0 };
|
|
6021
6105
|
const showHoverTooltip = /*@__PURE__*/GardState.Facet.define({
|
|
6106
|
+
name: "showHoverTooltip",
|
|
6022
6107
|
combine: inputs => inputs.reduce((a, i) => a.concat(i), [])
|
|
6023
6108
|
});
|
|
6024
6109
|
class HoverTooltipHost {
|
|
@@ -6371,9 +6456,10 @@ class OpenDialog {
|
|
|
6371
6456
|
this.offset = offset;
|
|
6372
6457
|
}
|
|
6373
6458
|
}
|
|
6374
|
-
const openDialog = /*@__PURE__*/Transaction.Effect.define();
|
|
6375
|
-
const closeDialog = /*@__PURE__*/Transaction.Effect.define();
|
|
6459
|
+
const openDialog = /*@__PURE__*/Transaction.Effect.define({ name: "openDialog" });
|
|
6460
|
+
const closeDialog = /*@__PURE__*/Transaction.Effect.define({ name: "closeDialog" });
|
|
6376
6461
|
const dialogs = /*@__PURE__*/GardState.Field.define({
|
|
6462
|
+
name: "dialogs",
|
|
6377
6463
|
create: () => [],
|
|
6378
6464
|
update: (value, tr) => {
|
|
6379
6465
|
for (let e of tr.effects) {
|
|
@@ -6664,6 +6750,7 @@ function decoratePlots(config) {
|
|
|
6664
6750
|
}
|
|
6665
6751
|
|
|
6666
6752
|
const panelConfig = /*@__PURE__*/GardState.Facet.define({
|
|
6753
|
+
name: "panelConfig",
|
|
6667
6754
|
combine(configs) {
|
|
6668
6755
|
let topContainer, bottomContainer;
|
|
6669
6756
|
for (let c of configs) {
|
|
@@ -6755,6 +6842,7 @@ const panelPlugin = /*@__PURE__*/Wordgard.Plugin.fromClass(class {
|
|
|
6755
6842
|
}));
|
|
6756
6843
|
const Panel = /*@__PURE__*/(function (Panel) {
|
|
6757
6844
|
Panel.show = GardState.Facet.define({
|
|
6845
|
+
name: "panel",
|
|
6758
6846
|
enables: panelPlugin
|
|
6759
6847
|
});
|
|
6760
6848
|
function get(wg, constructor) {
|
|
@@ -7369,6 +7457,7 @@ const theme = /*@__PURE__*/Wordgard.styles({
|
|
|
7369
7457
|
},
|
|
7370
7458
|
});
|
|
7371
7459
|
const barTemplate = /*@__PURE__*/GardState.Facet.define({
|
|
7460
|
+
name: "menuBarTemplate",
|
|
7372
7461
|
combine: inputs => inputs.length ? inputs[0] : [Menu.Group.top.template()]
|
|
7373
7462
|
});
|
|
7374
7463
|
function menuBar(config = {}) {
|
|
@@ -7378,7 +7467,7 @@ function menuBar(config = {}) {
|
|
|
7378
7467
|
return extensions;
|
|
7379
7468
|
}
|
|
7380
7469
|
|
|
7381
|
-
const inputRule = /*@__PURE__*/GardState.Facet.define();
|
|
7470
|
+
const inputRule = /*@__PURE__*/GardState.Facet.define({ name: "inputRule" });
|
|
7382
7471
|
const appender = /*@__PURE__*/Transaction.appender.of(applyInputRules);
|
|
7383
7472
|
class InputRule {
|
|
7384
7473
|
expr;
|
|
@@ -7434,13 +7523,14 @@ class InputRule {
|
|
|
7434
7523
|
lookahead: empty ? /^$/ : undefined
|
|
7435
7524
|
});
|
|
7436
7525
|
}
|
|
7526
|
+
toString() { return `InputRule(${this.expr})`; }
|
|
7437
7527
|
}
|
|
7438
7528
|
;InputRule = /*@__PURE__*/(function (InputRule) {
|
|
7439
7529
|
InputRule.emDash = InputRule.define({ expr: /--$/, apply: "—" });
|
|
7440
7530
|
InputRule.ellipsis = InputRule.define({ expr: /\.\.\.$/, apply: "…" });
|
|
7441
|
-
InputRule.openDoubleQuote = InputRule.define({ expr: /(
|
|
7531
|
+
InputRule.openDoubleQuote = InputRule.define({ expr: /(?<=^|[\s\{\[\(\<'"\u2018\u201C])"$/, apply: "“" });
|
|
7442
7532
|
InputRule.closeDoubleQuote = InputRule.define({ expr: /"$/, apply: "”" });
|
|
7443
|
-
InputRule.openSingleQuote = InputRule.define({ expr: /(
|
|
7533
|
+
InputRule.openSingleQuote = InputRule.define({ expr: /(?<=^|[\s\{\[\(\<'"\u2018\u201C])'$/, apply: "‘" });
|
|
7444
7534
|
InputRule.closeSingleQuote = InputRule.define({ expr: /'$/, apply: "’" });
|
|
7445
7535
|
InputRule.smartQuotes = [InputRule.openDoubleQuote, InputRule.closeDoubleQuote, InputRule.openSingleQuote, InputRule.closeSingleQuote];
|
|
7446
7536
|
;return InputRule})(InputRule);
|
|
@@ -7524,7 +7614,7 @@ const placeholderWidget = /*@__PURE__*/Widget.define({
|
|
|
7524
7614
|
return elt;
|
|
7525
7615
|
}
|
|
7526
7616
|
});
|
|
7527
|
-
const placeholderShape = /*@__PURE__*/GardState.Facet.define();
|
|
7617
|
+
const placeholderShape = /*@__PURE__*/GardState.Facet.define({ name: "placeholderShape" });
|
|
7528
7618
|
function showPlaceholder(state) {
|
|
7529
7619
|
let pos = -1;
|
|
7530
7620
|
if (state.doc.length == 0)
|
|
@@ -7539,6 +7629,7 @@ function showPlaceholder(state) {
|
|
|
7539
7629
|
return Decoration.Point.set([[Decoration.Point.widget(placeholderWidget.of(shape[0]), { side: 1 }), pos]]);
|
|
7540
7630
|
}
|
|
7541
7631
|
const placeholderField = /*@__PURE__*/GardState.Field.define({
|
|
7632
|
+
name: "placeholder",
|
|
7542
7633
|
create(state) {
|
|
7543
7634
|
return showPlaceholder(state);
|
|
7544
7635
|
},
|
|
@@ -7555,9 +7646,11 @@ function placeholder(content) {
|
|
|
7555
7646
|
}
|
|
7556
7647
|
|
|
7557
7648
|
const setDropCursorPos = /*@__PURE__*/Transaction.Effect.define({
|
|
7649
|
+
name: "setDropCursorPos",
|
|
7558
7650
|
map(pos, mapping) { return pos == null ? null : { pos: mapping.mapPos(pos.pos), side: pos.side }; }
|
|
7559
7651
|
});
|
|
7560
7652
|
const dropCursorPos = /*@__PURE__*/GardState.Field.define({
|
|
7653
|
+
name: "dropCursorPos",
|
|
7561
7654
|
create() { return null; },
|
|
7562
7655
|
update(pos, tr) {
|
|
7563
7656
|
if (pos != null)
|