@portabletext/editor 1.14.2 → 1.15.0

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 (30) hide show
  1. package/lib/index.cjs +30 -21
  2. package/lib/index.cjs.map +1 -1
  3. package/lib/index.d.cts +15 -15
  4. package/lib/index.d.ts +15 -15
  5. package/lib/index.js +30 -21
  6. package/lib/index.js.map +1 -1
  7. package/package.json +7 -7
  8. package/src/editor/__tests__/PortableTextEditor.test.tsx +6 -6
  9. package/src/editor/__tests__/RangeDecorations.test.tsx +1 -1
  10. package/src/editor/__tests__/handleClick.test.tsx +4 -4
  11. package/src/editor/__tests__/insert-block.test.tsx +3 -3
  12. package/src/editor/__tests__/pteWarningsSelfSolving.test.tsx +6 -6
  13. package/src/editor/__tests__/self-solving.test.tsx +1 -1
  14. package/src/editor/components/DraggableBlock.tsx +1 -1
  15. package/src/editor/components/Element.tsx +8 -2
  16. package/src/editor/components/Leaf.tsx +1 -1
  17. package/src/editor/create-editor.ts +18 -29
  18. package/src/editor/hooks/useSyncValue.test.tsx +2 -2
  19. package/src/editor/hooks/useSyncValue.ts +2 -2
  20. package/src/editor/nodes/DefaultObject.tsx +1 -0
  21. package/src/editor/plugins/__tests__/withEditableAPIDelete.test.tsx +4 -4
  22. package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +2 -2
  23. package/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx +7 -7
  24. package/src/editor/plugins/__tests__/withEditableAPISelectionsOverlapping.test.tsx +4 -4
  25. package/src/editor/plugins/__tests__/withPortableTextLists.test.tsx +1 -1
  26. package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +9 -9
  27. package/src/editor/plugins/__tests__/withPortableTextSelections.test.tsx +1 -1
  28. package/src/editor/plugins/__tests__/withUndoRedo.test.tsx +2 -2
  29. package/src/types/editor.ts +14 -13
  30. package/src/utils/__tests__/valueNormalization.test.tsx +1 -1
@@ -45,7 +45,7 @@ const initialSelection = {
45
45
 
46
46
  describe('plugin:withUndoRedo', () => {
47
47
  it('preserves the keys when undoing ', async () => {
48
- const editorRef: RefObject<PortableTextEditor> = createRef()
48
+ const editorRef: RefObject<PortableTextEditor | null> = createRef()
49
49
  const onChange = vi.fn()
50
50
  render(
51
51
  <PortableTextEditorTester
@@ -102,7 +102,7 @@ describe('plugin:withUndoRedo', () => {
102
102
  })
103
103
  })
104
104
  it('preserves the keys when redoing ', async () => {
105
- const editorRef: RefObject<PortableTextEditor> = createRef()
105
+ const editorRef: RefObject<PortableTextEditor | null> = createRef()
106
106
  const onChange = vi.fn()
107
107
 
108
108
  render(
@@ -17,6 +17,7 @@ import type {
17
17
  import type {
18
18
  ClipboardEvent,
19
19
  FocusEvent,
20
+ JSX,
20
21
  KeyboardEvent,
21
22
  PropsWithChildren,
22
23
  ReactElement,
@@ -374,8 +375,8 @@ export type PatchObservable = Observable<{
374
375
 
375
376
  /** @beta */
376
377
  export interface BlockRenderProps {
377
- children: ReactElement
378
- editorElementRef: RefObject<HTMLElement>
378
+ children: ReactElement<any>
379
+ editorElementRef: RefObject<HTMLElement | null>
379
380
  focused: boolean
380
381
  level?: number
381
382
  listItem?: string
@@ -391,8 +392,8 @@ export interface BlockRenderProps {
391
392
  /** @beta */
392
393
  export interface BlockChildRenderProps {
393
394
  annotations: PortableTextObject[]
394
- children: ReactElement
395
- editorElementRef: RefObject<HTMLElement>
395
+ children: ReactElement<any>
396
+ editorElementRef: RefObject<HTMLElement | null>
396
397
  focused: boolean
397
398
  path: Path
398
399
  selected: boolean
@@ -405,8 +406,8 @@ export interface BlockChildRenderProps {
405
406
  /** @beta */
406
407
  export interface BlockAnnotationRenderProps {
407
408
  block: PortableTextBlock
408
- children: ReactElement
409
- editorElementRef: RefObject<HTMLElement>
409
+ children: ReactElement<any>
410
+ editorElementRef: RefObject<HTMLElement | null>
410
411
  focused: boolean
411
412
  path: Path
412
413
  schemaType: ObjectSchemaType
@@ -417,8 +418,8 @@ export interface BlockAnnotationRenderProps {
417
418
  }
418
419
  /** @beta */
419
420
  export interface BlockDecoratorRenderProps {
420
- children: ReactElement
421
- editorElementRef: RefObject<HTMLElement>
421
+ children: ReactElement<any>
422
+ editorElementRef: RefObject<HTMLElement | null>
422
423
  focused: boolean
423
424
  path: Path
424
425
  schemaType: BlockDecoratorDefinition
@@ -430,8 +431,8 @@ export interface BlockDecoratorRenderProps {
430
431
  /** @beta */
431
432
  export interface BlockListItemRenderProps {
432
433
  block: PortableTextTextBlock
433
- children: ReactElement
434
- editorElementRef: RefObject<HTMLElement>
434
+ children: ReactElement<any>
435
+ editorElementRef: RefObject<HTMLElement | null>
435
436
  focused: boolean
436
437
  level: number
437
438
  path: Path
@@ -465,8 +466,8 @@ export type RenderStyleFunction = (props: BlockStyleRenderProps) => JSX.Element
465
466
  /** @beta */
466
467
  export interface BlockStyleRenderProps {
467
468
  block: PortableTextTextBlock
468
- children: ReactElement
469
- editorElementRef: RefObject<HTMLElement>
469
+ children: ReactElement<any>
470
+ editorElementRef: RefObject<HTMLElement | null>
470
471
  focused: boolean
471
472
  path: Path
472
473
  selected: boolean
@@ -517,7 +518,7 @@ export interface RangeDecoration {
517
518
  * )
518
519
  * ```
519
520
  */
520
- component: (props: PropsWithChildren) => ReactElement
521
+ component: (props: PropsWithChildren) => ReactElement<any>
521
522
  /**
522
523
  * The editor content selection range
523
524
  */
@@ -9,7 +9,7 @@ import {PortableTextEditor} from '../../editor/PortableTextEditor'
9
9
 
10
10
  describe('values: normalization', () => {
11
11
  it("accepts incoming value with blocks without a style or markDefs prop, but doesn't leave them without them when editing them", async () => {
12
- const editorRef: RefObject<PortableTextEditor> = createRef()
12
+ const editorRef: RefObject<PortableTextEditor | null> = createRef()
13
13
  const initialValue = [
14
14
  {
15
15
  _key: '5fc57af23597',