@codemirror/view 0.18.18 → 0.18.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 CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.18.19 (2021-07-12)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix a regression where `EditorView.editable.of(false)` didn't disable editing on Webkit-based browsers.
6
+
1
7
  ## 0.18.18 (2021-07-06)
2
8
 
3
9
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -216,6 +216,19 @@ function dispatchKey(elt, name, code) {
216
216
  elt.dispatchEvent(up);
217
217
  return down.defaultPrevented || up.defaultPrevented;
218
218
  }
219
+ let _plainTextSupported = null;
220
+ function contentEditablePlainTextSupported() {
221
+ if (_plainTextSupported == null) {
222
+ _plainTextSupported = false;
223
+ let dummy = document.createElement("div");
224
+ try {
225
+ dummy.contentEditable = "plaintext-only";
226
+ _plainTextSupported = dummy.contentEditable == "plaintext-only";
227
+ }
228
+ catch (_) { }
229
+ }
230
+ return _plainTextSupported;
231
+ }
219
232
 
220
233
  class DOMPos {
221
234
  constructor(node, offset, precise = true) {
@@ -4667,7 +4680,6 @@ const baseTheme = buildTheme("." + baseThemeID, {
4667
4680
  display: "block",
4668
4681
  whiteSpace: "pre",
4669
4682
  wordWrap: "normal",
4670
- WebkitUserModify: "read-write-plaintext-only",
4671
4683
  boxSizing: "border-box",
4672
4684
  padding: "4px 0",
4673
4685
  outline: "none"
@@ -5599,7 +5611,7 @@ class EditorView {
5599
5611
  spellcheck: "false",
5600
5612
  autocorrect: "off",
5601
5613
  autocapitalize: "off",
5602
- contenteditable: String(this.state.facet(editable)),
5614
+ contenteditable: !this.state.facet(editable) ? "false" : contentEditablePlainTextSupported() ? "plaintext-only" : "true",
5603
5615
  class: "cm-content",
5604
5616
  style: `${browser.tabSize}: ${this.state.tabSize}`,
5605
5617
  role: "textbox",
package/dist/index.js CHANGED
@@ -213,6 +213,19 @@ function dispatchKey(elt, name, code) {
213
213
  elt.dispatchEvent(up);
214
214
  return down.defaultPrevented || up.defaultPrevented;
215
215
  }
216
+ let _plainTextSupported = null;
217
+ function contentEditablePlainTextSupported() {
218
+ if (_plainTextSupported == null) {
219
+ _plainTextSupported = false;
220
+ let dummy = document.createElement("div");
221
+ try {
222
+ dummy.contentEditable = "plaintext-only";
223
+ _plainTextSupported = dummy.contentEditable == "plaintext-only";
224
+ }
225
+ catch (_) { }
226
+ }
227
+ return _plainTextSupported;
228
+ }
216
229
 
217
230
  class DOMPos {
218
231
  constructor(node, offset, precise = true) {
@@ -4661,7 +4674,6 @@ const baseTheme = /*@__PURE__*/buildTheme("." + baseThemeID, {
4661
4674
  display: "block",
4662
4675
  whiteSpace: "pre",
4663
4676
  wordWrap: "normal",
4664
- WebkitUserModify: "read-write-plaintext-only",
4665
4677
  boxSizing: "border-box",
4666
4678
  padding: "4px 0",
4667
4679
  outline: "none"
@@ -5593,7 +5605,7 @@ class EditorView {
5593
5605
  spellcheck: "false",
5594
5606
  autocorrect: "off",
5595
5607
  autocapitalize: "off",
5596
- contenteditable: String(this.state.facet(editable)),
5608
+ contenteditable: !this.state.facet(editable) ? "false" : contentEditablePlainTextSupported() ? "plaintext-only" : "true",
5597
5609
  class: "cm-content",
5598
5610
  style: `${browser.tabSize}: ${this.state.tabSize}`,
5599
5611
  role: "textbox",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "0.18.18",
3
+ "version": "0.18.19",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",