@portabletext/editor 1.41.0 → 1.41.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/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +19 -5
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +19 -5
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/behaviors/index.d.cts +3093 -3071
- package/lib/behaviors/index.d.ts +3093 -3071
- package/lib/index.cjs +9 -71
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2795 -2772
- package/lib/index.d.ts +2795 -2772
- package/lib/index.js +9 -71
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.cts +2795 -2772
- package/lib/plugins/index.d.ts +2795 -2772
- package/lib/selectors/index.d.cts +2782 -2759
- package/lib/selectors/index.d.ts +2782 -2759
- package/lib/utils/index.d.cts +2782 -2759
- package/lib/utils/index.d.ts +2782 -2759
- package/package.json +3 -3
- package/src/behaviors/behavior.types.ts +151 -108
- package/src/editor/Editable.tsx +0 -41
- package/src/editor/create-editor.ts +2 -2
- package/src/editor/editor-machine.ts +16 -6
- package/src/internal-utils/slate-utils.ts +7 -3
|
@@ -21,9 +21,9 @@ import {
|
|
|
21
21
|
isMouseBehaviorEvent,
|
|
22
22
|
type Behavior,
|
|
23
23
|
type CustomBehaviorEvent,
|
|
24
|
-
type
|
|
25
|
-
type ExternalBehaviorEvent,
|
|
24
|
+
type ExternalSyntheticBehaviorEvent,
|
|
26
25
|
type InternalBehaviorAction,
|
|
26
|
+
type InternalBehaviorEvent,
|
|
27
27
|
type NativeBehaviorEvent,
|
|
28
28
|
type SyntheticBehaviorEvent,
|
|
29
29
|
} from '../behaviors/behavior.types'
|
|
@@ -190,7 +190,7 @@ export type InternalEditorEvent =
|
|
|
190
190
|
| {
|
|
191
191
|
type: 'behavior event'
|
|
192
192
|
behaviorEvent:
|
|
193
|
-
|
|
|
193
|
+
| InternalBehaviorEvent
|
|
194
194
|
| SyntheticBehaviorEvent
|
|
195
195
|
| NativeBehaviorEvent
|
|
196
196
|
editor: PortableTextSlateEditor
|
|
@@ -204,7 +204,7 @@ export type InternalEditorEvent =
|
|
|
204
204
|
nativeEvent?: {preventDefault: () => void}
|
|
205
205
|
}
|
|
206
206
|
| CustomBehaviorEvent
|
|
207
|
-
|
|
|
207
|
+
| ExternalSyntheticBehaviorEvent
|
|
208
208
|
| ExternalEditorEvent
|
|
209
209
|
| MutationEvent
|
|
210
210
|
| InternalPatchEvent
|
|
@@ -224,7 +224,7 @@ export type InternalEditorEvent =
|
|
|
224
224
|
*/
|
|
225
225
|
export type InternalEditorEmittedEvent =
|
|
226
226
|
| EditorEmittedEvent
|
|
227
|
-
|
|
|
227
|
+
| ExternalSyntheticBehaviorEvent
|
|
228
228
|
| InternalPatchEvent
|
|
229
229
|
| PatchesEvent
|
|
230
230
|
| UnsetEvent
|
|
@@ -741,7 +741,17 @@ export const editorMachine = setup({
|
|
|
741
741
|
exit: [
|
|
742
742
|
({context}) => {
|
|
743
743
|
if (context.internalDrag?.ghost) {
|
|
744
|
-
|
|
744
|
+
try {
|
|
745
|
+
context.internalDrag.ghost.parentNode?.removeChild(
|
|
746
|
+
context.internalDrag.ghost,
|
|
747
|
+
)
|
|
748
|
+
} catch (error) {
|
|
749
|
+
console.error(
|
|
750
|
+
new Error(
|
|
751
|
+
`Removing the internal drag ghost failed due to: ${error.message}`,
|
|
752
|
+
),
|
|
753
|
+
)
|
|
754
|
+
}
|
|
745
755
|
}
|
|
746
756
|
},
|
|
747
757
|
assign({internalDrag: undefined}),
|
|
@@ -79,7 +79,7 @@ export function getNodeBlock({
|
|
|
79
79
|
return undefined
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
if (isBlockElement(schema, node)) {
|
|
82
|
+
if (isBlockElement({editor, schema}, node)) {
|
|
83
83
|
return elementToBlock({schema, element: node})
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -88,7 +88,7 @@ export function getNodeBlock({
|
|
|
88
88
|
mode: 'highest',
|
|
89
89
|
at: [],
|
|
90
90
|
match: (n) =>
|
|
91
|
-
isBlockElement(schema, n) &&
|
|
91
|
+
isBlockElement({editor, schema}, n) &&
|
|
92
92
|
n.children.some((child) => child._key === node._key),
|
|
93
93
|
}),
|
|
94
94
|
)
|
|
@@ -113,9 +113,13 @@ function elementToBlock({
|
|
|
113
113
|
return fromSlateValue([element], schema.block.name)?.at(0)
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
function isBlockElement(
|
|
116
|
+
function isBlockElement(
|
|
117
|
+
{editor, schema}: {editor: PortableTextSlateEditor; schema: EditorSchema},
|
|
118
|
+
node: Node,
|
|
119
|
+
): node is Element {
|
|
117
120
|
return (
|
|
118
121
|
Element.isElement(node) &&
|
|
122
|
+
!editor.isInline(node) &&
|
|
119
123
|
(schema.block.name === node._type ||
|
|
120
124
|
schema.blockObjects.some(
|
|
121
125
|
(blockObject) => blockObject.name === node._type,
|