@codemirror/view 6.35.1 → 6.35.2

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
+ ## 6.35.2 (2024-12-07)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix an issue on Chrome where typing at the end of the document would insert a character after the cursor.
6
+
1
7
  ## 6.35.1 (2024-12-06)
2
8
 
3
9
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -7180,8 +7180,10 @@ class EditContextManager {
7180
7180
  if (change.from == change.to && !change.insert.length)
7181
7181
  return;
7182
7182
  this.pendingContextChange = change;
7183
- if (!view.state.readOnly)
7184
- applyDOMChangeInner(view, change, state.EditorSelection.single(this.toEditorPos(e.selectionStart), this.toEditorPos(e.selectionEnd)));
7183
+ if (!view.state.readOnly) {
7184
+ let newLen = this.to - this.from + (change.to - change.from + change.insert.length);
7185
+ applyDOMChangeInner(view, change, state.EditorSelection.single(this.toEditorPos(e.selectionStart, newLen), this.toEditorPos(e.selectionEnd, newLen)));
7186
+ }
7185
7187
  // If the transaction didn't flush our change, revert it so
7186
7188
  // that the context is in sync with the editor state again.
7187
7189
  if (this.pendingContextChange) {
@@ -7320,8 +7322,8 @@ class EditContextManager {
7320
7322
  this.to < state.doc.length && this.to - head < 500 /* CxVp.MinMargin */ ||
7321
7323
  this.to - this.from > 10000 /* CxVp.Margin */ * 3);
7322
7324
  }
7323
- toEditorPos(contextPos) {
7324
- contextPos = Math.min(contextPos, this.to - this.from);
7325
+ toEditorPos(contextPos, clipLen = this.to - this.from) {
7326
+ contextPos = Math.min(contextPos, clipLen);
7325
7327
  let c = this.composing;
7326
7328
  return c && c.drifted ? c.editorBase + (contextPos - c.contextBase) : contextPos + this.from;
7327
7329
  }
package/dist/index.js CHANGED
@@ -7175,8 +7175,10 @@ class EditContextManager {
7175
7175
  if (change.from == change.to && !change.insert.length)
7176
7176
  return;
7177
7177
  this.pendingContextChange = change;
7178
- if (!view.state.readOnly)
7179
- applyDOMChangeInner(view, change, EditorSelection.single(this.toEditorPos(e.selectionStart), this.toEditorPos(e.selectionEnd)));
7178
+ if (!view.state.readOnly) {
7179
+ let newLen = this.to - this.from + (change.to - change.from + change.insert.length);
7180
+ applyDOMChangeInner(view, change, EditorSelection.single(this.toEditorPos(e.selectionStart, newLen), this.toEditorPos(e.selectionEnd, newLen)));
7181
+ }
7180
7182
  // If the transaction didn't flush our change, revert it so
7181
7183
  // that the context is in sync with the editor state again.
7182
7184
  if (this.pendingContextChange) {
@@ -7315,8 +7317,8 @@ class EditContextManager {
7315
7317
  this.to < state.doc.length && this.to - head < 500 /* CxVp.MinMargin */ ||
7316
7318
  this.to - this.from > 10000 /* CxVp.Margin */ * 3);
7317
7319
  }
7318
- toEditorPos(contextPos) {
7319
- contextPos = Math.min(contextPos, this.to - this.from);
7320
+ toEditorPos(contextPos, clipLen = this.to - this.from) {
7321
+ contextPos = Math.min(contextPos, clipLen);
7320
7322
  let c = this.composing;
7321
7323
  return c && c.drifted ? c.editorBase + (contextPos - c.contextBase) : contextPos + this.from;
7322
7324
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "6.35.1",
3
+ "version": "6.35.2",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",