@tiptap/core 2.0.0-beta.170 → 2.0.0-beta.174

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.
@@ -506,21 +506,20 @@
506
506
  if (!position) {
507
507
  return null;
508
508
  }
509
+ const selectionAtStart = prosemirrorState.Selection.atStart(doc);
510
+ const selectionAtEnd = prosemirrorState.Selection.atEnd(doc);
509
511
  if (position === 'start' || position === true) {
510
- return prosemirrorState.Selection.atStart(doc);
512
+ return selectionAtStart;
511
513
  }
512
514
  if (position === 'end') {
513
- return prosemirrorState.Selection.atEnd(doc);
515
+ return selectionAtEnd;
514
516
  }
517
+ const minPos = selectionAtStart.from;
518
+ const maxPos = selectionAtEnd.to;
515
519
  if (position === 'all') {
516
- return prosemirrorState.TextSelection.create(doc, 0, doc.content.size);
517
- }
518
- // Check if `position` is in bounds of the doc if `position` is a number.
519
- const minPos = prosemirrorState.Selection.atStart(doc).from;
520
- const maxPos = prosemirrorState.Selection.atEnd(doc).to;
521
- const resolvedFrom = minMax(position, minPos, maxPos);
522
- const resolvedEnd = minMax(position, minPos, maxPos);
523
- return prosemirrorState.TextSelection.create(doc, resolvedFrom, resolvedEnd);
520
+ return prosemirrorState.TextSelection.create(doc, minMax(0, minPos, maxPos), minMax(doc.content.size, minPos, maxPos));
521
+ }
522
+ return prosemirrorState.TextSelection.create(doc, minMax(position, minPos, maxPos), minMax(position, minPos, maxPos));
524
523
  }
525
524
 
526
525
  const focus = (position = null, options) => ({ editor, view, tr, dispatch, }) => {
@@ -1191,8 +1190,8 @@
1191
1190
  const { from, to } = typeof position === 'number'
1192
1191
  ? { from: position, to: position }
1193
1192
  : position;
1194
- const minPos = 0;
1195
- const maxPos = tr.doc.content.size;
1193
+ const minPos = prosemirrorState.TextSelection.atStart(doc).from;
1194
+ const maxPos = prosemirrorState.TextSelection.atEnd(doc).to;
1196
1195
  const resolvedFrom = minMax(from, minPos, maxPos);
1197
1196
  const resolvedEnd = minMax(to, minPos, maxPos);
1198
1197
  const selection = prosemirrorState.TextSelection.create(doc, resolvedFrom, resolvedEnd);
@@ -2166,8 +2165,12 @@
2166
2165
  new prosemirrorState.Plugin({
2167
2166
  key: new prosemirrorState.PluginKey('tabindex'),
2168
2167
  props: {
2169
- attributes: {
2170
- tabindex: '0',
2168
+ attributes: () => {
2169
+ if (this.editor.isEditable) {
2170
+ return {
2171
+ tabindex: '0',
2172
+ };
2173
+ }
2171
2174
  },
2172
2175
  },
2173
2176
  }),