@portabletext/editor 2.10.0 → 2.11.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.
@@ -1,5 +1,5 @@
1
1
  import { Behavior, Editor, EditorEmittedEvent, EditorSchema } from "../_chunks-dts/behavior.types.action.cjs";
2
- import * as react12 from "react";
2
+ import * as react22 from "react";
3
3
  import React from "react";
4
4
  /**
5
5
  * @beta
@@ -181,7 +181,7 @@ type MarkdownPluginConfig = MarkdownBehaviorsConfig & {
181
181
  */
182
182
  declare function MarkdownPlugin(props: {
183
183
  config: MarkdownPluginConfig;
184
- }): react12.JSX.Element;
184
+ }): react22.JSX.Element;
185
185
  /**
186
186
  * @beta
187
187
  * Restrict the editor to one line. The plugin takes care of blocking
@@ -192,5 +192,5 @@ declare function MarkdownPlugin(props: {
192
192
  *
193
193
  * @deprecated Install the plugin from `@portabletext/plugin-one-line`
194
194
  */
195
- declare function OneLinePlugin(): react12.JSX.Element;
195
+ declare function OneLinePlugin(): react22.JSX.Element;
196
196
  export { BehaviorPlugin, DecoratorShortcutPlugin, EditorRefPlugin, EventListenerPlugin, MarkdownPlugin, type MarkdownPluginConfig, OneLinePlugin };
@@ -1,5 +1,5 @@
1
1
  import { Behavior, Editor, EditorEmittedEvent, EditorSchema } from "../_chunks-dts/behavior.types.action.js";
2
- import * as react22 from "react";
2
+ import * as react21 from "react";
3
3
  import React from "react";
4
4
  /**
5
5
  * @beta
@@ -181,7 +181,7 @@ type MarkdownPluginConfig = MarkdownBehaviorsConfig & {
181
181
  */
182
182
  declare function MarkdownPlugin(props: {
183
183
  config: MarkdownPluginConfig;
184
- }): react22.JSX.Element;
184
+ }): react21.JSX.Element;
185
185
  /**
186
186
  * @beta
187
187
  * Restrict the editor to one line. The plugin takes care of blocking
@@ -192,5 +192,5 @@ declare function MarkdownPlugin(props: {
192
192
  *
193
193
  * @deprecated Install the plugin from `@portabletext/plugin-one-line`
194
194
  */
195
- declare function OneLinePlugin(): react22.JSX.Element;
195
+ declare function OneLinePlugin(): react21.JSX.Element;
196
196
  export { BehaviorPlugin, DecoratorShortcutPlugin, EditorRefPlugin, EventListenerPlugin, MarkdownPlugin, type MarkdownPluginConfig, OneLinePlugin };
@@ -1,5 +1,5 @@
1
1
  import { BlockOffset, BlockPath, ChildPath, EditorContext, EditorSelection, EditorSelectionPoint } from "../_chunks-dts/behavior.types.action.cjs";
2
- import * as _sanity_types9 from "@sanity/types";
2
+ import * as _sanity_types8 from "@sanity/types";
3
3
  import { KeyedSegment, PortableTextBlock, PortableTextTextBlock } from "@sanity/types";
4
4
  import { isSpan, isTextBlock } from "@portabletext/schema";
5
5
  /**
@@ -143,7 +143,7 @@ declare function mergeTextBlocks({
143
143
  context: Pick<EditorContext, 'keyGenerator' | 'schema'>;
144
144
  targetBlock: PortableTextTextBlock;
145
145
  incomingBlock: PortableTextTextBlock;
146
- }): PortableTextTextBlock<_sanity_types9.PortableTextObject | _sanity_types9.PortableTextSpan>;
146
+ }): PortableTextTextBlock<_sanity_types8.PortableTextObject | _sanity_types8.PortableTextSpan>;
147
147
  /**
148
148
  * @public
149
149
  */
@@ -1,5 +1,5 @@
1
1
  import { BlockOffset, BlockPath, ChildPath, EditorContext, EditorSelection, EditorSelectionPoint } from "../_chunks-dts/behavior.types.action.js";
2
- import * as _sanity_types8 from "@sanity/types";
2
+ import * as _sanity_types9 from "@sanity/types";
3
3
  import { KeyedSegment, PortableTextBlock, PortableTextTextBlock } from "@sanity/types";
4
4
  import { isSpan, isTextBlock } from "@portabletext/schema";
5
5
  /**
@@ -143,7 +143,7 @@ declare function mergeTextBlocks({
143
143
  context: Pick<EditorContext, 'keyGenerator' | 'schema'>;
144
144
  targetBlock: PortableTextTextBlock;
145
145
  incomingBlock: PortableTextTextBlock;
146
- }): PortableTextTextBlock<_sanity_types8.PortableTextObject | _sanity_types8.PortableTextSpan>;
146
+ }): PortableTextTextBlock<_sanity_types9.PortableTextObject | _sanity_types9.PortableTextSpan>;
147
147
  /**
148
148
  * @public
149
149
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
@@ -80,9 +80,9 @@
80
80
  "slate-react": "0.117.4",
81
81
  "xstate": "^5.21.0",
82
82
  "@portabletext/block-tools": "^3.5.6",
83
- "@portabletext/keyboard-shortcuts": "^1.1.1",
84
83
  "@portabletext/patches": "^1.1.8",
85
- "@portabletext/schema": "^1.2.0"
84
+ "@portabletext/schema": "^1.2.0",
85
+ "@portabletext/keyboard-shortcuts": "^1.1.1"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@sanity/diff-match-patch": "^3.2.0",
@@ -55,8 +55,7 @@ export type ExternalBehaviorEvent =
55
55
  value?: {[prop: string]: unknown}
56
56
  }
57
57
  }
58
- | SyntheticBehaviorEvent
59
- | CustomBehaviorEvent
58
+ | BehaviorEvent
60
59
 
61
60
  /**************************************
62
61
  * Synthetic events
@@ -6,18 +6,13 @@ import React from 'react'
6
6
  import {expect, vi} from 'vitest'
7
7
  import {render} from 'vitest-browser-react'
8
8
  import type {Context} from '../../gherkin-tests-v2/step-context'
9
- import type {NativeBehaviorEvent} from '../behaviors'
10
9
  import type {Editor} from '../editor'
11
10
  import {
12
11
  PortableTextEditable,
13
12
  type PortableTextEditableProps,
14
13
  } from '../editor/Editable'
15
- import type {EditorActor} from '../editor/editor-machine'
16
14
  import {EditorProvider} from '../editor/editor-provider'
17
15
  import {EditorRefPlugin} from '../plugins/plugin.editor-ref'
18
- import {InternalEditorAfterRefPlugin} from '../plugins/plugin.internal.editor-actor-ref'
19
- import {InternalSlateEditorRefPlugin} from '../plugins/plugin.internal.slate-editor-ref'
20
- import type {PortableTextSlateEditor} from '../types/editor'
21
16
 
22
17
  type CreateTestEditorOptions = {
23
18
  initialValue?: Array<PortableTextBlock>
@@ -35,8 +30,6 @@ export async function createTestEditor(
35
30
  }
36
31
  > {
37
32
  const editorRef = React.createRef<Editor>()
38
- const editorActorRef = React.createRef<EditorActor>()
39
- const slateRef = React.createRef<PortableTextSlateEditor>()
40
33
  const keyGenerator = options.keyGenerator ?? createTestKeyGenerator()
41
34
 
42
35
  const renderResult = render(
@@ -48,8 +41,6 @@ export async function createTestEditor(
48
41
  }}
49
42
  >
50
43
  <EditorRefPlugin ref={editorRef} />
51
- <InternalEditorAfterRefPlugin ref={editorActorRef} />
52
- <InternalSlateEditorRefPlugin ref={slateRef} />
53
44
  <PortableTextEditable {...options.editableProps} />
54
45
  {options.children}
55
46
  </EditorProvider>,
@@ -66,8 +57,6 @@ export async function createTestEditor(
66
57
  }}
67
58
  >
68
59
  <EditorRefPlugin ref={editorRef} />
69
- <InternalEditorAfterRefPlugin ref={editorActorRef} />
70
- <InternalSlateEditorRefPlugin ref={slateRef} />
71
60
  <PortableTextEditable {...newOptions.editableProps} />
72
61
  {newOptions.children}
73
62
  </EditorProvider>,
@@ -81,8 +70,6 @@ export async function createTestEditor(
81
70
  }}
82
71
  >
83
72
  <EditorRefPlugin ref={editorRef} />
84
- <InternalEditorAfterRefPlugin ref={editorActorRef} />
85
- <InternalSlateEditorRefPlugin ref={slateRef} />
86
73
  <PortableTextEditable {...options.editableProps} />
87
74
  {options.children}
88
75
  </EditorProvider>,
@@ -93,19 +80,8 @@ export async function createTestEditor(
93
80
 
94
81
  await vi.waitFor(() => expect.element(locator).toBeInTheDocument())
95
82
 
96
- function sendNativeEvent(event: NativeBehaviorEvent) {
97
- editorActorRef.current?.send({
98
- type: 'behavior event',
99
- behaviorEvent: event,
100
- editor: slateRef.current!,
101
- })
102
- }
103
-
104
83
  return {
105
- editor: {
106
- ...editorRef.current!,
107
- sendNativeEvent,
108
- },
84
+ editor: editorRef.current!,
109
85
  locator,
110
86
  rerender,
111
87
  }
@@ -1,15 +0,0 @@
1
- import React, {useContext} from 'react'
2
- import {EditorActorContext} from '../editor/editor-actor-context'
3
- import type {EditorActor} from '../editor/editor-machine'
4
-
5
- export const InternalEditorAfterRefPlugin =
6
- React.forwardRef<EditorActor | null>((_, ref) => {
7
- const editorActor = useContext(EditorActorContext)
8
-
9
- const editorActorRef = React.useRef(editorActor)
10
-
11
- React.useImperativeHandle(ref, () => editorActorRef.current, [])
12
-
13
- return null
14
- })
15
- InternalEditorAfterRefPlugin.displayName = 'InternalEditorAfterRefPlugin'