@codemirror/view 0.19.15 → 0.19.19
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/CHANGELOG.md +30 -0
- package/dist/index.cjs +24 -17
- package/dist/index.d.ts +2 -1
- package/dist/index.js +24 -17
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
## 0.19.19 (2021-11-17)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix a bug that caused the precedence of `editorAttributes` and `contentAttributes` to be inverted, making lower-precedence extensions override higher-precedence ones.
|
|
6
|
+
|
|
7
|
+
## 0.19.18 (2021-11-16)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Fix an issue where the editor wasn't aware it was line-wrapping with its own `lineWrapping` extension enabled.
|
|
12
|
+
|
|
13
|
+
## 0.19.17 (2021-11-16)
|
|
14
|
+
|
|
15
|
+
### Bug fixes
|
|
16
|
+
|
|
17
|
+
Avoid an issue where stretches of whitespace on line wrap points could cause the cursor to be placed outside of the content.
|
|
18
|
+
|
|
19
|
+
## 0.19.16 (2021-11-11)
|
|
20
|
+
|
|
21
|
+
### Breaking changes
|
|
22
|
+
|
|
23
|
+
Block replacement decorations now default to inclusive, because non-inclusive block decorations are rarely what you need.
|
|
24
|
+
|
|
25
|
+
### Bug fixes
|
|
26
|
+
|
|
27
|
+
Fix an issue that caused block widgets to always have a large side value, making it impossible to show them between to replacement decorations.
|
|
28
|
+
|
|
29
|
+
Fix a crash that could happen after some types of viewport changes, due to a bug in the block widget view data structure.
|
|
30
|
+
|
|
1
31
|
## 0.19.15 (2021-11-09)
|
|
2
32
|
|
|
3
33
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -666,7 +666,7 @@ function textCoords(text, pos, side) {
|
|
|
666
666
|
let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];
|
|
667
667
|
if (browser.safari && !flatten && rect.width == 0)
|
|
668
668
|
rect = Array.prototype.find.call(rects, r => r.width) || rect;
|
|
669
|
-
return flatten ? flattenRect(rect, flatten < 0) : rect;
|
|
669
|
+
return flatten ? flattenRect(rect, flatten < 0) : rect || null;
|
|
670
670
|
}
|
|
671
671
|
// Also used for collapsed ranges that don't have a placeholder widget!
|
|
672
672
|
class WidgetView extends InlineView {
|
|
@@ -774,7 +774,7 @@ class WidgetBufferView extends InlineView {
|
|
|
774
774
|
domBoundsAround() { return null; }
|
|
775
775
|
coordsAt(pos) {
|
|
776
776
|
let rects = clientRectsFor(this.dom);
|
|
777
|
-
return rects[rects.length - 1];
|
|
777
|
+
return rects[rects.length - 1] || null;
|
|
778
778
|
}
|
|
779
779
|
get overrideDOMText() {
|
|
780
780
|
return text.Text.of([this.dom.nodeValue.replace(/\u200b/g, "")]);
|
|
@@ -916,7 +916,7 @@ function coordsInChildren(view, pos, side) {
|
|
|
916
916
|
if (!last)
|
|
917
917
|
return view.dom.getBoundingClientRect();
|
|
918
918
|
let rects = clientRectsFor(last);
|
|
919
|
-
return rects[rects.length - 1];
|
|
919
|
+
return rects[rects.length - 1] || null;
|
|
920
920
|
}
|
|
921
921
|
|
|
922
922
|
function combineAttrs(source, target) {
|
|
@@ -1084,8 +1084,6 @@ class Decoration extends rangeset.RangeValue {
|
|
|
1084
1084
|
*/
|
|
1085
1085
|
static widget(spec) {
|
|
1086
1086
|
let side = spec.side || 0;
|
|
1087
|
-
if (spec.block)
|
|
1088
|
-
side += (200000000 /* BigBlock */ + 1) * (side > 0 ? 1 : -1);
|
|
1089
1087
|
return new PointDecoration(spec, side, side, !!spec.block, spec.widget || null, false);
|
|
1090
1088
|
}
|
|
1091
1089
|
/**
|
|
@@ -1094,9 +1092,9 @@ class Decoration extends rangeset.RangeValue {
|
|
|
1094
1092
|
*/
|
|
1095
1093
|
static replace(spec) {
|
|
1096
1094
|
let block = !!spec.block;
|
|
1097
|
-
let { start, end } = getInclusive(spec);
|
|
1098
|
-
let startSide =
|
|
1099
|
-
let endSide =
|
|
1095
|
+
let { start, end } = getInclusive(spec, block);
|
|
1096
|
+
let startSide = 100000000 /* Big */ * (start ? -1 : 1) * (block ? 2 : 1);
|
|
1097
|
+
let endSide = 100000000 /* Big */ * (end ? 1 : -1) * (block ? 2 : 1);
|
|
1100
1098
|
return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);
|
|
1101
1099
|
}
|
|
1102
1100
|
/**
|
|
@@ -1126,7 +1124,7 @@ Decoration.none = rangeset.RangeSet.empty;
|
|
|
1126
1124
|
class MarkDecoration extends Decoration {
|
|
1127
1125
|
constructor(spec) {
|
|
1128
1126
|
let { start, end } = getInclusive(spec);
|
|
1129
|
-
super(100000000 /*
|
|
1127
|
+
super(100000000 /* Big */ * (start ? -1 : 1), 100000000 /* Big */ * (end ? 1 : -1), null, spec);
|
|
1130
1128
|
this.tagName = spec.tagName || "span";
|
|
1131
1129
|
this.class = spec.class || "";
|
|
1132
1130
|
this.attrs = spec.attributes || null;
|
|
@@ -1147,7 +1145,7 @@ class MarkDecoration extends Decoration {
|
|
|
1147
1145
|
MarkDecoration.prototype.point = false;
|
|
1148
1146
|
class LineDecoration extends Decoration {
|
|
1149
1147
|
constructor(spec) {
|
|
1150
|
-
super(-100000000 /*
|
|
1148
|
+
super(-100000000 /* Big */, -100000000 /* Big */, null, spec);
|
|
1151
1149
|
}
|
|
1152
1150
|
eq(other) {
|
|
1153
1151
|
return other instanceof LineDecoration && attrsEq(this.spec.attributes, other.spec.attributes);
|
|
@@ -1188,13 +1186,13 @@ class PointDecoration extends Decoration {
|
|
|
1188
1186
|
}
|
|
1189
1187
|
}
|
|
1190
1188
|
PointDecoration.prototype.point = true;
|
|
1191
|
-
function getInclusive(spec) {
|
|
1189
|
+
function getInclusive(spec, block = false) {
|
|
1192
1190
|
let { inclusiveStart: start, inclusiveEnd: end } = spec;
|
|
1193
1191
|
if (start == null)
|
|
1194
1192
|
start = spec.inclusive;
|
|
1195
1193
|
if (end == null)
|
|
1196
1194
|
end = spec.inclusive;
|
|
1197
|
-
return { start: start
|
|
1195
|
+
return { start: start !== null && start !== void 0 ? start : block, end: end !== null && end !== void 0 ? end : block };
|
|
1198
1196
|
}
|
|
1199
1197
|
function widgetsEq(a, b) {
|
|
1200
1198
|
return a == b || !!(a && b && a.compare(b));
|
|
@@ -1362,7 +1360,9 @@ class BlockWidgetView extends ContentView {
|
|
|
1362
1360
|
split(at) {
|
|
1363
1361
|
let len = this.length - at;
|
|
1364
1362
|
this.length = at;
|
|
1365
|
-
|
|
1363
|
+
let end = new BlockWidgetView(this.widget, len, this.type);
|
|
1364
|
+
end.breakAfter = this.breakAfter;
|
|
1365
|
+
return end;
|
|
1366
1366
|
}
|
|
1367
1367
|
get children() { return none$1; }
|
|
1368
1368
|
sync() {
|
|
@@ -1771,11 +1771,17 @@ class PluginInstance {
|
|
|
1771
1771
|
}
|
|
1772
1772
|
}
|
|
1773
1773
|
PluginInstance.dummy = new PluginInstance(ViewPlugin.define(() => ({})));
|
|
1774
|
+
function combineFacetAttrs(values) {
|
|
1775
|
+
let result = {};
|
|
1776
|
+
for (let i = values.length - 1; i >= 0; i--)
|
|
1777
|
+
combineAttrs(values[i], result);
|
|
1778
|
+
return result;
|
|
1779
|
+
}
|
|
1774
1780
|
const editorAttributes = state.Facet.define({
|
|
1775
|
-
combine:
|
|
1781
|
+
combine: combineFacetAttrs
|
|
1776
1782
|
});
|
|
1777
1783
|
const contentAttributes = state.Facet.define({
|
|
1778
|
-
combine:
|
|
1784
|
+
combine: combineFacetAttrs
|
|
1779
1785
|
});
|
|
1780
1786
|
// Provide decorations
|
|
1781
1787
|
const decorations = state.Facet.define();
|
|
@@ -3742,7 +3748,7 @@ handlers.beforeinput = (view, event) => {
|
|
|
3742
3748
|
}
|
|
3743
3749
|
};
|
|
3744
3750
|
|
|
3745
|
-
const wrappingWhiteSpace = ["pre-wrap", "normal", "pre-line"];
|
|
3751
|
+
const wrappingWhiteSpace = ["pre-wrap", "normal", "pre-line", "break-spaces"];
|
|
3746
3752
|
class HeightOracle {
|
|
3747
3753
|
constructor() {
|
|
3748
3754
|
this.doc = text.Text.empty;
|
|
@@ -4938,7 +4944,8 @@ const baseTheme = buildTheme("." + baseThemeID, {
|
|
|
4938
4944
|
}
|
|
4939
4945
|
},
|
|
4940
4946
|
".cm-lineWrapping": {
|
|
4941
|
-
|
|
4947
|
+
whiteSpace_fallback: "pre-wrap",
|
|
4948
|
+
whiteSpace: "break-spaces",
|
|
4942
4949
|
wordBreak: "break-word",
|
|
4943
4950
|
overflowWrap: "anywhere"
|
|
4944
4951
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -91,7 +91,8 @@ interface ReplaceDecorationSpec {
|
|
|
91
91
|
/**
|
|
92
92
|
Whether this range covers the positions on its sides. This
|
|
93
93
|
influences whether new content becomes part of the range and
|
|
94
|
-
whether the cursor can be drawn on its sides. Defaults to false
|
|
94
|
+
whether the cursor can be drawn on its sides. Defaults to false
|
|
95
|
+
for inline replacements, and true for block replacements.
|
|
95
96
|
*/
|
|
96
97
|
inclusive?: boolean;
|
|
97
98
|
/**
|
package/dist/index.js
CHANGED
|
@@ -663,7 +663,7 @@ function textCoords(text, pos, side) {
|
|
|
663
663
|
let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];
|
|
664
664
|
if (browser.safari && !flatten && rect.width == 0)
|
|
665
665
|
rect = Array.prototype.find.call(rects, r => r.width) || rect;
|
|
666
|
-
return flatten ? flattenRect(rect, flatten < 0) : rect;
|
|
666
|
+
return flatten ? flattenRect(rect, flatten < 0) : rect || null;
|
|
667
667
|
}
|
|
668
668
|
// Also used for collapsed ranges that don't have a placeholder widget!
|
|
669
669
|
class WidgetView extends InlineView {
|
|
@@ -771,7 +771,7 @@ class WidgetBufferView extends InlineView {
|
|
|
771
771
|
domBoundsAround() { return null; }
|
|
772
772
|
coordsAt(pos) {
|
|
773
773
|
let rects = clientRectsFor(this.dom);
|
|
774
|
-
return rects[rects.length - 1];
|
|
774
|
+
return rects[rects.length - 1] || null;
|
|
775
775
|
}
|
|
776
776
|
get overrideDOMText() {
|
|
777
777
|
return Text.of([this.dom.nodeValue.replace(/\u200b/g, "")]);
|
|
@@ -913,7 +913,7 @@ function coordsInChildren(view, pos, side) {
|
|
|
913
913
|
if (!last)
|
|
914
914
|
return view.dom.getBoundingClientRect();
|
|
915
915
|
let rects = clientRectsFor(last);
|
|
916
|
-
return rects[rects.length - 1];
|
|
916
|
+
return rects[rects.length - 1] || null;
|
|
917
917
|
}
|
|
918
918
|
|
|
919
919
|
function combineAttrs(source, target) {
|
|
@@ -1080,8 +1080,6 @@ class Decoration extends RangeValue {
|
|
|
1080
1080
|
*/
|
|
1081
1081
|
static widget(spec) {
|
|
1082
1082
|
let side = spec.side || 0;
|
|
1083
|
-
if (spec.block)
|
|
1084
|
-
side += (200000000 /* BigBlock */ + 1) * (side > 0 ? 1 : -1);
|
|
1085
1083
|
return new PointDecoration(spec, side, side, !!spec.block, spec.widget || null, false);
|
|
1086
1084
|
}
|
|
1087
1085
|
/**
|
|
@@ -1090,9 +1088,9 @@ class Decoration extends RangeValue {
|
|
|
1090
1088
|
*/
|
|
1091
1089
|
static replace(spec) {
|
|
1092
1090
|
let block = !!spec.block;
|
|
1093
|
-
let { start, end } = getInclusive(spec);
|
|
1094
|
-
let startSide =
|
|
1095
|
-
let endSide =
|
|
1091
|
+
let { start, end } = getInclusive(spec, block);
|
|
1092
|
+
let startSide = 100000000 /* Big */ * (start ? -1 : 1) * (block ? 2 : 1);
|
|
1093
|
+
let endSide = 100000000 /* Big */ * (end ? 1 : -1) * (block ? 2 : 1);
|
|
1096
1094
|
return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);
|
|
1097
1095
|
}
|
|
1098
1096
|
/**
|
|
@@ -1122,7 +1120,7 @@ Decoration.none = RangeSet.empty;
|
|
|
1122
1120
|
class MarkDecoration extends Decoration {
|
|
1123
1121
|
constructor(spec) {
|
|
1124
1122
|
let { start, end } = getInclusive(spec);
|
|
1125
|
-
super(100000000 /*
|
|
1123
|
+
super(100000000 /* Big */ * (start ? -1 : 1), 100000000 /* Big */ * (end ? 1 : -1), null, spec);
|
|
1126
1124
|
this.tagName = spec.tagName || "span";
|
|
1127
1125
|
this.class = spec.class || "";
|
|
1128
1126
|
this.attrs = spec.attributes || null;
|
|
@@ -1143,7 +1141,7 @@ class MarkDecoration extends Decoration {
|
|
|
1143
1141
|
MarkDecoration.prototype.point = false;
|
|
1144
1142
|
class LineDecoration extends Decoration {
|
|
1145
1143
|
constructor(spec) {
|
|
1146
|
-
super(-100000000 /*
|
|
1144
|
+
super(-100000000 /* Big */, -100000000 /* Big */, null, spec);
|
|
1147
1145
|
}
|
|
1148
1146
|
eq(other) {
|
|
1149
1147
|
return other instanceof LineDecoration && attrsEq(this.spec.attributes, other.spec.attributes);
|
|
@@ -1184,13 +1182,13 @@ class PointDecoration extends Decoration {
|
|
|
1184
1182
|
}
|
|
1185
1183
|
}
|
|
1186
1184
|
PointDecoration.prototype.point = true;
|
|
1187
|
-
function getInclusive(spec) {
|
|
1185
|
+
function getInclusive(spec, block = false) {
|
|
1188
1186
|
let { inclusiveStart: start, inclusiveEnd: end } = spec;
|
|
1189
1187
|
if (start == null)
|
|
1190
1188
|
start = spec.inclusive;
|
|
1191
1189
|
if (end == null)
|
|
1192
1190
|
end = spec.inclusive;
|
|
1193
|
-
return { start: start
|
|
1191
|
+
return { start: start !== null && start !== void 0 ? start : block, end: end !== null && end !== void 0 ? end : block };
|
|
1194
1192
|
}
|
|
1195
1193
|
function widgetsEq(a, b) {
|
|
1196
1194
|
return a == b || !!(a && b && a.compare(b));
|
|
@@ -1358,7 +1356,9 @@ class BlockWidgetView extends ContentView {
|
|
|
1358
1356
|
split(at) {
|
|
1359
1357
|
let len = this.length - at;
|
|
1360
1358
|
this.length = at;
|
|
1361
|
-
|
|
1359
|
+
let end = new BlockWidgetView(this.widget, len, this.type);
|
|
1360
|
+
end.breakAfter = this.breakAfter;
|
|
1361
|
+
return end;
|
|
1362
1362
|
}
|
|
1363
1363
|
get children() { return none$1; }
|
|
1364
1364
|
sync() {
|
|
@@ -1767,11 +1767,17 @@ class PluginInstance {
|
|
|
1767
1767
|
}
|
|
1768
1768
|
}
|
|
1769
1769
|
PluginInstance.dummy = /*@__PURE__*/new PluginInstance(/*@__PURE__*/ViewPlugin.define(() => ({})));
|
|
1770
|
+
function combineFacetAttrs(values) {
|
|
1771
|
+
let result = {};
|
|
1772
|
+
for (let i = values.length - 1; i >= 0; i--)
|
|
1773
|
+
combineAttrs(values[i], result);
|
|
1774
|
+
return result;
|
|
1775
|
+
}
|
|
1770
1776
|
const editorAttributes = /*@__PURE__*/Facet.define({
|
|
1771
|
-
combine:
|
|
1777
|
+
combine: combineFacetAttrs
|
|
1772
1778
|
});
|
|
1773
1779
|
const contentAttributes = /*@__PURE__*/Facet.define({
|
|
1774
|
-
combine:
|
|
1780
|
+
combine: combineFacetAttrs
|
|
1775
1781
|
});
|
|
1776
1782
|
// Provide decorations
|
|
1777
1783
|
const decorations = /*@__PURE__*/Facet.define();
|
|
@@ -3737,7 +3743,7 @@ handlers.beforeinput = (view, event) => {
|
|
|
3737
3743
|
}
|
|
3738
3744
|
};
|
|
3739
3745
|
|
|
3740
|
-
const wrappingWhiteSpace = ["pre-wrap", "normal", "pre-line"];
|
|
3746
|
+
const wrappingWhiteSpace = ["pre-wrap", "normal", "pre-line", "break-spaces"];
|
|
3741
3747
|
class HeightOracle {
|
|
3742
3748
|
constructor() {
|
|
3743
3749
|
this.doc = Text.empty;
|
|
@@ -4932,7 +4938,8 @@ const baseTheme = /*@__PURE__*/buildTheme("." + baseThemeID, {
|
|
|
4932
4938
|
}
|
|
4933
4939
|
},
|
|
4934
4940
|
".cm-lineWrapping": {
|
|
4935
|
-
|
|
4941
|
+
whiteSpace_fallback: "pre-wrap",
|
|
4942
|
+
whiteSpace: "break-spaces",
|
|
4936
4943
|
wordBreak: "break-word",
|
|
4937
4944
|
overflowWrap: "anywhere"
|
|
4938
4945
|
},
|