@portabletext/editor 1.1.0 → 1.1.1

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.
Files changed (64) hide show
  1. package/lib/index.d.mts +13 -12
  2. package/lib/index.d.ts +13 -12
  3. package/lib/index.esm.js +6 -10
  4. package/lib/index.esm.js.map +1 -1
  5. package/lib/index.js +6 -10
  6. package/lib/index.js.map +1 -1
  7. package/lib/index.mjs +6 -10
  8. package/lib/index.mjs.map +1 -1
  9. package/package.json +3 -17
  10. package/src/editor/Editable.tsx +21 -19
  11. package/src/editor/PortableTextEditor.tsx +19 -20
  12. package/src/editor/__tests__/PortableTextEditor.test.tsx +2 -3
  13. package/src/editor/__tests__/RangeDecorations.test.tsx +4 -5
  14. package/src/editor/__tests__/insert-block.test.tsx +2 -2
  15. package/src/editor/__tests__/pteWarningsSelfSolving.test.tsx +1 -1
  16. package/src/editor/__tests__/utils.ts +0 -1
  17. package/src/editor/components/Element.tsx +15 -17
  18. package/src/editor/components/Leaf.tsx +12 -12
  19. package/src/editor/components/SlateContainer.tsx +2 -2
  20. package/src/editor/components/Synchronizer.tsx +3 -3
  21. package/src/editor/hooks/usePortableTextEditor.ts +1 -1
  22. package/src/editor/hooks/usePortableTextEditorSelection.tsx +1 -1
  23. package/src/editor/hooks/useSyncValue.ts +3 -7
  24. package/src/editor/nodes/DefaultAnnotation.tsx +1 -2
  25. package/src/editor/nodes/DefaultObject.tsx +1 -1
  26. package/src/editor/plugins/__tests__/createWithInsertData.test.tsx +1 -4
  27. package/src/editor/plugins/__tests__/withEditableAPISelectionsOverlapping.test.tsx +1 -1
  28. package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +1 -3
  29. package/src/editor/plugins/createWithEditableAPI.ts +8 -8
  30. package/src/editor/plugins/createWithHotKeys.ts +8 -12
  31. package/src/editor/plugins/createWithInsertBreak.ts +4 -4
  32. package/src/editor/plugins/createWithInsertData.ts +7 -8
  33. package/src/editor/plugins/createWithMaxBlocks.ts +1 -1
  34. package/src/editor/plugins/createWithObjectKeys.ts +3 -3
  35. package/src/editor/plugins/createWithPatches.ts +6 -8
  36. package/src/editor/plugins/createWithPlaceholderBlock.ts +2 -2
  37. package/src/editor/plugins/createWithPortableTextBlockStyle.ts +3 -3
  38. package/src/editor/plugins/createWithPortableTextLists.ts +3 -4
  39. package/src/editor/plugins/createWithPortableTextMarkModel.ts +6 -8
  40. package/src/editor/plugins/createWithPortableTextSelections.ts +7 -7
  41. package/src/editor/plugins/createWithSchemaTypes.ts +4 -4
  42. package/src/editor/plugins/createWithUndoRedo.ts +3 -7
  43. package/src/editor/plugins/createWithUtils.ts +6 -6
  44. package/src/editor/plugins/index.ts +3 -3
  45. package/src/types/editor.ts +33 -33
  46. package/src/types/options.ts +3 -3
  47. package/src/types/slate.ts +4 -4
  48. package/src/utils/__tests__/dmpToOperations.test.ts +3 -3
  49. package/src/utils/__tests__/operationToPatches.test.ts +1 -1
  50. package/src/utils/__tests__/patchToOperations.test.ts +1 -1
  51. package/src/utils/__tests__/ranges.test.ts +1 -1
  52. package/src/utils/applyPatch.ts +10 -12
  53. package/src/utils/getPortableTextMemberSchemaTypes.ts +8 -8
  54. package/src/utils/operationToPatches.ts +5 -9
  55. package/src/utils/paths.ts +5 -5
  56. package/src/utils/ranges.ts +4 -5
  57. package/src/utils/selection.ts +2 -2
  58. package/src/utils/ucs2Indices.ts +2 -2
  59. package/src/utils/validateValue.ts +3 -3
  60. package/src/utils/values.ts +7 -8
  61. package/src/utils/weakMaps.ts +2 -2
  62. package/src/utils/withChanges.ts +1 -1
  63. package/src/utils/withUndoRedo.ts +1 -1
  64. package/src/utils/withoutPatching.ts +1 -1
@@ -1,6 +1,5 @@
1
- /* eslint-disable max-nested-callbacks */
2
1
  import {insert, setIfMissing, unset, type Patch} from '@portabletext/patches'
3
- import {type Subject} from 'rxjs'
2
+ import type {Subject} from 'rxjs'
4
3
  import {
5
4
  Editor,
6
5
  type Descendant,
@@ -14,11 +13,11 @@ import {
14
13
  type SetNodeOperation,
15
14
  type SplitNodeOperation,
16
15
  } from 'slate'
17
- import {
18
- type EditorChange,
19
- type PatchObservable,
20
- type PortableTextMemberSchemaTypes,
21
- type PortableTextSlateEditor,
16
+ import type {
17
+ EditorChange,
18
+ PatchObservable,
19
+ PortableTextMemberSchemaTypes,
20
+ PortableTextSlateEditor,
22
21
  } from '../../types/editor'
23
22
  import {createApplyPatch} from '../../utils/applyPatch'
24
23
  import {debugWithName} from '../../utils/debug'
@@ -269,7 +268,6 @@ export function createWithPatches({
269
268
  ),
270
269
  ]
271
270
  break
272
- case 'set_selection':
273
271
  default:
274
272
  // Do nothing
275
273
  }
@@ -1,6 +1,6 @@
1
1
  import {Editor, Path} from 'slate'
2
- import {type PortableTextSlateEditor} from '../../types/editor'
3
- import {type SlateTextBlock, type VoidElement} from '../../types/slate'
2
+ import type {PortableTextSlateEditor} from '../../types/editor'
3
+ import type {SlateTextBlock, VoidElement} from '../../types/slate'
4
4
  import {debugWithName} from '../../utils/debug'
5
5
  import {isChangingRemotely} from '../../utils/withChanges'
6
6
  import {isRedoing, isUndoing} from '../../utils/withUndoRedo'
@@ -1,7 +1,7 @@
1
1
  import {Editor, Path, Text as SlateText, Transforms, type Node} from 'slate'
2
- import {
3
- type PortableTextMemberSchemaTypes,
4
- type PortableTextSlateEditor,
2
+ import type {
3
+ PortableTextMemberSchemaTypes,
4
+ PortableTextSlateEditor,
5
5
  } from '../../types/editor'
6
6
  import {debugWithName} from '../../utils/debug'
7
7
 
@@ -1,7 +1,7 @@
1
1
  import {Editor, Element, Text, Transforms, type Node} from 'slate'
2
- import {
3
- type PortableTextMemberSchemaTypes,
4
- type PortableTextSlateEditor,
2
+ import type {
3
+ PortableTextMemberSchemaTypes,
4
+ PortableTextSlateEditor,
5
5
  } from '../../types/editor'
6
6
  import {debugWithName} from '../../utils/debug'
7
7
 
@@ -38,7 +38,6 @@ export function createWithPortableTextLists(
38
38
  ]
39
39
  selectedBlocks.forEach(([node, path]) => {
40
40
  if (editor.isListBlock(node)) {
41
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
42
41
  const {listItem, level, ...rest} = node
43
42
  const newNode = {
44
43
  ...rest,
@@ -1,5 +1,3 @@
1
- /* eslint-disable max-statements */
2
- /* eslint-disable complexity */
3
1
  /**
4
2
  *
5
3
  * This plugin will change Slate's default marks model (every prop is a mark) with the Portable Text model (marks is an array of strings on prop .marks).
@@ -7,9 +5,9 @@
7
5
  */
8
6
 
9
7
  import {isPortableTextBlock, isPortableTextSpan} from '@portabletext/toolkit'
10
- import {type PortableTextObject} from '@sanity/types'
8
+ import type {PortableTextObject} from '@sanity/types'
11
9
  import {isEqual, uniq} from 'lodash'
12
- import {type Subject} from 'rxjs'
10
+ import type {Subject} from 'rxjs'
13
11
  import {
14
12
  Editor,
15
13
  Element,
@@ -20,10 +18,10 @@ import {
20
18
  Transforms,
21
19
  type Descendant,
22
20
  } from 'slate'
23
- import {
24
- type EditorChange,
25
- type PortableTextMemberSchemaTypes,
26
- type PortableTextSlateEditor,
21
+ import type {
22
+ EditorChange,
23
+ PortableTextMemberSchemaTypes,
24
+ PortableTextSlateEditor,
27
25
  } from '../../types/editor'
28
26
  import {debugWithName} from '../../utils/debug'
29
27
  import {toPortableTextRange} from '../../utils/ranges'
@@ -1,10 +1,10 @@
1
- import {type Subject} from 'rxjs'
2
- import {type BaseRange} from 'slate'
3
- import {
4
- type EditorChange,
5
- type EditorSelection,
6
- type PortableTextMemberSchemaTypes,
7
- type PortableTextSlateEditor,
1
+ import type {Subject} from 'rxjs'
2
+ import type {BaseRange} from 'slate'
3
+ import type {
4
+ EditorChange,
5
+ EditorSelection,
6
+ PortableTextMemberSchemaTypes,
7
+ PortableTextSlateEditor,
8
8
  } from '../../types/editor'
9
9
  import {debugWithName} from '../../utils/debug'
10
10
  import {
@@ -7,9 +7,9 @@ import {
7
7
  type PortableTextTextBlock,
8
8
  } from '@sanity/types'
9
9
  import {Transforms, type Element} from 'slate'
10
- import {
11
- type PortableTextMemberSchemaTypes,
12
- type PortableTextSlateEditor,
10
+ import type {
11
+ PortableTextMemberSchemaTypes,
12
+ PortableTextSlateEditor,
13
13
  } from '../../types/editor'
14
14
  import {debugWithName} from '../../utils/debug'
15
15
 
@@ -34,7 +34,7 @@ export function createWithSchemaTypes({
34
34
  )
35
35
  }
36
36
  editor.isTextSpan = (value: unknown): value is PortableTextSpan => {
37
- return isPortableTextSpan(value) && value._type == schemaTypes.span.name
37
+ return isPortableTextSpan(value) && value._type === schemaTypes.span.name
38
38
  }
39
39
  editor.isListBlock = (value: unknown): value is PortableTextListBlock => {
40
40
  return (
@@ -3,14 +3,14 @@
3
3
  * The undo/redo steps are rebased against incoming patches since the step occurred.
4
4
  */
5
5
 
6
- import {type Patch} from '@portabletext/patches'
6
+ import type {Patch} from '@portabletext/patches'
7
7
  import {
8
8
  DIFF_DELETE,
9
9
  DIFF_EQUAL,
10
10
  DIFF_INSERT,
11
11
  parsePatch,
12
12
  } from '@sanity/diff-match-patch'
13
- import {type ObjectSchemaType, type PortableTextBlock} from '@sanity/types'
13
+ import type {ObjectSchemaType, PortableTextBlock} from '@sanity/types'
14
14
  import {flatten, isEqual} from 'lodash'
15
15
  import {
16
16
  Editor,
@@ -20,10 +20,7 @@ import {
20
20
  type Descendant,
21
21
  type SelectionOperation,
22
22
  } from 'slate'
23
- import {
24
- type PatchObservable,
25
- type PortableTextSlateEditor,
26
- } from '../../types/editor'
23
+ import type {PatchObservable, PortableTextSlateEditor} from '../../types/editor'
27
24
  import {debugWithName} from '../../utils/debug'
28
25
  import {fromSlateValue} from '../../utils/values'
29
26
  import {
@@ -248,7 +245,6 @@ export function createWithUndoRedo(
248
245
  Editor.withoutNormalizing(editor, () => {
249
246
  withRedoing(editor, () => {
250
247
  withoutSaving(editor, () => {
251
- // eslint-disable-next-line max-nested-callbacks
252
248
  transformedOperations.forEach((op) => {
253
249
  editor.apply(op)
254
250
  })
@@ -1,11 +1,11 @@
1
1
  import {Editor, Range, Text, Transforms} from 'slate'
2
- import {
3
- type PortableTextMemberSchemaTypes,
4
- type PortableTextSlateEditor,
2
+ import type {
3
+ PortableTextMemberSchemaTypes,
4
+ PortableTextSlateEditor,
5
5
  } from '../../types/editor'
6
6
  import {debugWithName} from '../../utils/debug'
7
7
  import {toSlateValue} from '../../utils/values'
8
- import {type PortableTextEditor} from '../PortableTextEditor'
8
+ import type {PortableTextEditor} from '../PortableTextEditor'
9
9
 
10
10
  const debug = debugWithName('plugin:withUtils')
11
11
 
@@ -59,8 +59,8 @@ export function createWithUtils({
59
59
  if (
60
60
  !(
61
61
  newStartOffset === newEndOffset ||
62
- isNaN(newStartOffset) ||
63
- isNaN(newEndOffset)
62
+ Number.isNaN(newStartOffset) ||
63
+ Number.isNaN(newEndOffset)
64
64
  )
65
65
  ) {
66
66
  debug('pteExpandToWord: Expanding to focused word')
@@ -1,7 +1,7 @@
1
1
  import {noop} from 'lodash'
2
- import {type BaseOperation, type Editor, type Node, type NodeEntry} from 'slate'
3
- import {type PortableTextSlateEditor} from '../../types/editor'
4
- import {type createEditorOptions} from '../../types/options'
2
+ import type {BaseOperation, Editor, Node, NodeEntry} from 'slate'
3
+ import type {PortableTextSlateEditor} from '../../types/editor'
4
+ import type {createEditorOptions} from '../../types/options'
5
5
  import {createOperationToPatches} from '../../utils/operationToPatches'
6
6
  import {createWithEditableAPI} from './createWithEditableAPI'
7
7
  import {createWithInsertBreak} from './createWithInsertBreak'
@@ -1,39 +1,39 @@
1
- import {type Patch} from '@portabletext/patches'
2
- import {
3
- type ArraySchemaType,
4
- type BlockDecoratorDefinition,
5
- type BlockListDefinition,
6
- type BlockSchemaType,
7
- type BlockStyleDefinition,
8
- type ObjectSchemaType,
9
- type Path,
10
- type PortableTextBlock,
11
- type PortableTextChild,
12
- type PortableTextListBlock,
13
- type PortableTextObject,
14
- type PortableTextSpan,
15
- type PortableTextTextBlock,
16
- type SpanSchemaType,
17
- type TypedObject,
1
+ import type {Patch} from '@portabletext/patches'
2
+ import type {
3
+ ArraySchemaType,
4
+ BlockDecoratorDefinition,
5
+ BlockListDefinition,
6
+ BlockSchemaType,
7
+ BlockStyleDefinition,
8
+ ObjectSchemaType,
9
+ Path,
10
+ PortableTextBlock,
11
+ PortableTextChild,
12
+ PortableTextListBlock,
13
+ PortableTextObject,
14
+ PortableTextSpan,
15
+ PortableTextTextBlock,
16
+ SpanSchemaType,
17
+ TypedObject,
18
18
  } from '@sanity/types'
19
- import {
20
- type ClipboardEvent,
21
- type FocusEvent,
22
- type KeyboardEvent,
23
- type PropsWithChildren,
24
- type ReactElement,
25
- type RefObject,
19
+ import type {
20
+ ClipboardEvent,
21
+ FocusEvent,
22
+ KeyboardEvent,
23
+ PropsWithChildren,
24
+ ReactElement,
25
+ RefObject,
26
26
  } from 'react'
27
- import {type Observable, type Subject} from 'rxjs'
28
- import {
29
- type Descendant,
30
- type Node as SlateNode,
31
- type Operation as SlateOperation,
27
+ import type {Observable, Subject} from 'rxjs'
28
+ import type {
29
+ Descendant,
30
+ Node as SlateNode,
31
+ Operation as SlateOperation,
32
32
  } from 'slate'
33
- import {type ReactEditor} from 'slate-react'
34
- import {type DOMNode} from 'slate-react/dist/utils/dom'
35
- import {type PortableTextEditableProps} from '../editor/Editable'
36
- import {type PortableTextEditor} from '../editor/PortableTextEditor'
33
+ import type {ReactEditor} from 'slate-react'
34
+ import type {DOMNode} from 'slate-react/dist/utils/dom'
35
+ import type {PortableTextEditableProps} from '../editor/Editable'
36
+ import type {PortableTextEditor} from '../editor/PortableTextEditor'
37
37
 
38
38
  /** @beta */
39
39
  export interface EditableAPIDeleteOptions {
@@ -1,6 +1,6 @@
1
- import {type BaseSyntheticEvent} from 'react'
2
- import {type PortableTextEditor} from '../editor/PortableTextEditor'
3
- import {type PatchObservable} from './editor'
1
+ import type {BaseSyntheticEvent} from 'react'
2
+ import type {PortableTextEditor} from '../editor/PortableTextEditor'
3
+ import type {PatchObservable} from './editor'
4
4
 
5
5
  /**
6
6
  * @internal
@@ -1,7 +1,7 @@
1
- import {type PortableTextSpan, type PortableTextTextBlock} from '@sanity/types'
2
- import {type BaseEditor, type Descendant} from 'slate'
3
- import {type ReactEditor} from 'slate-react'
4
- import {type PortableTextSlateEditor} from '..'
1
+ import type {PortableTextSpan, PortableTextTextBlock} from '@sanity/types'
2
+ import type {BaseEditor, Descendant} from 'slate'
3
+ import type {ReactEditor} from 'slate-react'
4
+ import type {PortableTextSlateEditor} from '..'
5
5
 
6
6
  export interface VoidElement {
7
7
  _type: string
@@ -1,5 +1,5 @@
1
1
  import {describe, expect, test} from '@jest/globals'
2
- import {type DiffMatchPatch} from '@portabletext/patches'
2
+ import type {DiffMatchPatch} from '@portabletext/patches'
3
3
  import {makeDiff, makePatches, stringifyPatches} from '@sanity/diff-match-patch'
4
4
  import {
5
5
  isPortableTextSpan,
@@ -9,8 +9,8 @@ import {
9
9
  type PortableTextSpan,
10
10
  type PortableTextTextBlock,
11
11
  } from '@sanity/types'
12
- import {type Descendant, type Operation} from 'slate'
13
- import {type PortableTextSlateEditor} from '../../types/editor'
12
+ import type {Descendant, Operation} from 'slate'
13
+ import type {PortableTextSlateEditor} from '../../types/editor'
14
14
  import {diffMatchPatch} from '../applyPatch'
15
15
 
16
16
  describe('operationToPatches: diffMatchPatch', () => {
@@ -1,5 +1,5 @@
1
1
  import {beforeEach, describe, expect, it} from '@jest/globals'
2
- import {type PortableTextTextBlock} from '@sanity/types'
2
+ import type {PortableTextTextBlock} from '@sanity/types'
3
3
  import {createEditor, type Descendant} from 'slate'
4
4
  import {PortableTextEditor, type PortableTextEditorProps} from '../..'
5
5
  import {schemaType} from '../../editor/__tests__/PortableTextEditorTester'
@@ -1,5 +1,5 @@
1
1
  import {beforeEach, describe, expect, it} from '@jest/globals'
2
- import {type Patch} from '@portabletext/patches'
2
+ import type {Patch} from '@portabletext/patches'
3
3
  import {noop} from 'lodash'
4
4
  import {createEditor, type Descendant} from 'slate'
5
5
  import {keyGenerator, PortableTextEditor} from '../..'
@@ -1,5 +1,5 @@
1
1
  import {describe, expect, it} from '@jest/globals'
2
- import {type InsertTextOperation, type Range} from 'slate'
2
+ import type {InsertTextOperation, Range} from 'slate'
3
3
  import {moveRangeByOperation} from '../ranges'
4
4
 
5
5
  describe('moveRangeByOperation', () => {
@@ -1,4 +1,3 @@
1
- /* eslint-disable max-statements */
2
1
  import {
3
2
  applyAll,
4
3
  type DiffMatchPatch,
@@ -16,12 +15,12 @@ import {
16
15
  makeDiff,
17
16
  parsePatch,
18
17
  } from '@sanity/diff-match-patch'
19
- import {
20
- type KeyedSegment,
21
- type Path,
22
- type PathSegment,
23
- type PortableTextBlock,
24
- type PortableTextChild,
18
+ import type {
19
+ KeyedSegment,
20
+ Path,
21
+ PathSegment,
22
+ PortableTextBlock,
23
+ PortableTextChild,
25
24
  } from '@sanity/types'
26
25
  import {
27
26
  Element,
@@ -31,9 +30,9 @@ import {
31
30
  type Node,
32
31
  type Path as SlatePath,
33
32
  } from 'slate'
34
- import {
35
- type PortableTextMemberSchemaTypes,
36
- type PortableTextSlateEditor,
33
+ import type {
34
+ PortableTextMemberSchemaTypes,
35
+ PortableTextSlateEditor,
37
36
  } from '../types/editor'
38
37
  import {debugWithName} from './debug'
39
38
  import {toSlateValue} from './values'
@@ -50,7 +49,7 @@ export function createApplyPatch(
50
49
  ): (editor: PortableTextSlateEditor, patch: Patch) => boolean {
51
50
  let previousPatch: Patch | undefined
52
51
 
53
- return function (editor: PortableTextSlateEditor, patch: Patch): boolean {
52
+ return (editor: PortableTextSlateEditor, patch: Patch): boolean => {
54
53
  let changed = false
55
54
 
56
55
  // Save some CPU cycles by not stringifying unless enabled
@@ -273,7 +272,6 @@ function setPatch(editor: PortableTextSlateEditor, patch: SetPatch) {
273
272
  } else if (Element.isElement(block) && patch.path.length === 1 && blockPath) {
274
273
  debug('Setting block property')
275
274
  const {children, ...nextRest} = value as unknown as PortableTextBlock
276
- // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-vars
277
275
  const {children: prevChildren, ...prevRest} = block || {children: undefined}
278
276
  // Set any block properties
279
277
  editor.apply({
@@ -1,12 +1,12 @@
1
- import {
2
- type ArraySchemaType,
3
- type BlockSchemaType,
4
- type ObjectSchemaType,
5
- type PortableTextBlock,
6
- type SchemaType,
7
- type SpanSchemaType,
1
+ import type {
2
+ ArraySchemaType,
3
+ BlockSchemaType,
4
+ ObjectSchemaType,
5
+ PortableTextBlock,
6
+ SchemaType,
7
+ SpanSchemaType,
8
8
  } from '@sanity/types'
9
- import {type PortableTextMemberSchemaTypes} from '../types/editor'
9
+ import type {PortableTextMemberSchemaTypes} from '../types/editor'
10
10
 
11
11
  export function getPortableTextMemberSchemaTypes(
12
12
  portableTextType: ArraySchemaType<PortableTextBlock>,
@@ -7,11 +7,7 @@ import {
7
7
  type InsertPosition,
8
8
  type Patch,
9
9
  } from '@portabletext/patches'
10
- import {
11
- type Path,
12
- type PortableTextSpan,
13
- type PortableTextTextBlock,
14
- } from '@sanity/types'
10
+ import type {Path, PortableTextSpan, PortableTextTextBlock} from '@sanity/types'
15
11
  import {get, isUndefined, omitBy} from 'lodash'
16
12
  import {
17
13
  Text,
@@ -25,10 +21,10 @@ import {
25
21
  type SetNodeOperation,
26
22
  type SplitNodeOperation,
27
23
  } from 'slate'
28
- import {type PatchFunctions} from '../editor/plugins/createWithPatches'
29
- import {
30
- type PortableTextMemberSchemaTypes,
31
- type PortableTextSlateEditor,
24
+ import type {PatchFunctions} from '../editor/plugins/createWithPatches'
25
+ import type {
26
+ PortableTextMemberSchemaTypes,
27
+ PortableTextSlateEditor,
32
28
  } from '../types/editor'
33
29
  import {debugWithName} from './debug'
34
30
  import {fromSlateValue} from './values'
@@ -7,11 +7,11 @@ import {
7
7
  type Point,
8
8
  type Path as SlatePath,
9
9
  } from 'slate'
10
- import {
11
- type EditorSelectionPoint,
12
- type PortableTextMemberSchemaTypes,
10
+ import type {
11
+ EditorSelectionPoint,
12
+ PortableTextMemberSchemaTypes,
13
13
  } from '../types/editor'
14
- import {type ObjectWithKeyAndType} from './ranges'
14
+ import type {ObjectWithKeyAndType} from './ranges'
15
15
 
16
16
  export function createKeyedPath(
17
17
  point: Point,
@@ -30,7 +30,7 @@ export function createKeyedPath(
30
30
  if (block._type !== types.block.name) {
31
31
  return keyedBlockPath as Path
32
32
  }
33
- let keyedChildPath
33
+ let keyedChildPath: Path | undefined
34
34
  const childPath = point.path.slice(0, 2)
35
35
  const child = Array.isArray(block.children) && block.children[childPath[1]]
36
36
  if (child) {
@@ -1,9 +1,8 @@
1
- /* eslint-disable complexity */
2
1
  import {Point, Range, type BaseRange, type Editor, type Operation} from 'slate'
3
- import {
4
- type EditorSelection,
5
- type EditorSelectionPoint,
6
- type PortableTextMemberSchemaTypes,
2
+ import type {
3
+ EditorSelection,
4
+ EditorSelectionPoint,
5
+ PortableTextMemberSchemaTypes,
7
6
  } from '../types/editor'
8
7
  import {createArrayedPath, createKeyedPath} from './paths'
9
8
 
@@ -1,6 +1,6 @@
1
- import {type Path, type PortableTextBlock} from '@sanity/types'
1
+ import type {Path, PortableTextBlock} from '@sanity/types'
2
2
  import {isEqual} from 'lodash'
3
- import {type EditorSelection, type EditorSelectionPoint} from '../types/editor'
3
+ import type {EditorSelection, EditorSelectionPoint} from '../types/editor'
4
4
 
5
5
  export function normalizePoint(
6
6
  point: EditorSelectionPoint,
@@ -1,4 +1,4 @@
1
- import {type Patch} from '@sanity/diff-match-patch'
1
+ import type {Patch} from '@sanity/diff-match-patch'
2
2
 
3
3
  /**
4
4
  * Takes a `patches` array as produced by diff-match-patch and adjusts the
@@ -15,7 +15,7 @@ export function adjustIndiciesToUcs2(patches: Patch[], base: string): Patch[] {
15
15
  let idx = 0 // index into the input.
16
16
 
17
17
  function advanceTo(target: number) {
18
- for (; byteOffset < target; ) {
18
+ while (byteOffset < target) {
19
19
  const codePoint = base.codePointAt(idx)
20
20
  if (typeof codePoint === 'undefined') {
21
21
  // Reached the end of the base string - the indicies won't be correct,
@@ -6,9 +6,9 @@ import {
6
6
  type PortableTextTextBlock,
7
7
  } from '@sanity/types'
8
8
  import {flatten, isPlainObject, uniq} from 'lodash'
9
- import {
10
- type InvalidValueResolution,
11
- type PortableTextMemberSchemaTypes,
9
+ import type {
10
+ InvalidValueResolution,
11
+ PortableTextMemberSchemaTypes,
12
12
  } from '../types/editor'
13
13
  import {EMPTY_MARKDEFS} from './values'
14
14
 
@@ -1,13 +1,13 @@
1
- import {
2
- type PathSegment,
3
- type PortableTextBlock,
4
- type PortableTextChild,
5
- type PortableTextObject,
6
- type PortableTextTextBlock,
1
+ import type {
2
+ PathSegment,
3
+ PortableTextBlock,
4
+ PortableTextChild,
5
+ PortableTextObject,
6
+ PortableTextTextBlock,
7
7
  } from '@sanity/types'
8
8
  import {isEqual} from 'lodash'
9
9
  import {Element, Text, type Descendant, type Node} from 'slate'
10
- import {type PortableTextMemberSchemaTypes} from '../types/editor'
10
+ import type {PortableTextMemberSchemaTypes} from '../types/editor'
11
11
 
12
12
  export const EMPTY_MARKDEFS: PortableTextObject[] = []
13
13
 
@@ -123,7 +123,6 @@ export function fromSlateValue(
123
123
  const {_type: _cType} = child
124
124
  if ('value' in child && _cType !== 'span') {
125
125
  hasInlines = true
126
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
127
126
  const {
128
127
  value: v,
129
128
  _key: k,
@@ -1,5 +1,5 @@
1
- import {type Editor, type Element, type Range} from 'slate'
2
- import {type EditorSelection} from '..'
1
+ import type {Editor, Element, Range} from 'slate'
2
+ import type {EditorSelection} from '..'
3
3
 
4
4
  // Is the editor currently receiving remote changes that are being applied to the content?
5
5
  export const IS_PROCESSING_REMOTE_CHANGES: WeakMap<Editor, boolean> =
@@ -1,4 +1,4 @@
1
- import {type Editor} from 'slate'
1
+ import type {Editor} from 'slate'
2
2
  import {
3
3
  IS_PROCESSING_LOCAL_CHANGES,
4
4
  IS_PROCESSING_REMOTE_CHANGES,
@@ -1,4 +1,4 @@
1
- import {type Editor} from 'slate'
1
+ import type {Editor} from 'slate'
2
2
 
3
3
  const IS_UDOING: WeakMap<Editor, boolean | undefined> = new WeakMap()
4
4
  const IS_REDOING: WeakMap<Editor, boolean | undefined> = new WeakMap()
@@ -1,4 +1,4 @@
1
- import {type Editor} from 'slate'
1
+ import type {Editor} from 'slate'
2
2
 
3
3
  export const PATCHING: WeakMap<Editor, boolean | undefined> = new WeakMap()
4
4