@portabletext/editor 1.47.1 → 1.47.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/index.cjs +9 -11
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +9 -11
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
- package/src/editor/Editable.tsx +9 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/editor",
|
|
3
|
-
"version": "1.47.
|
|
3
|
+
"version": "1.47.2",
|
|
4
4
|
"description": "Portable Text Editor made in React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"slate-react": "0.112.1",
|
|
80
80
|
"use-effect-event": "^1.0.2",
|
|
81
81
|
"xstate": "^5.19.2",
|
|
82
|
-
"@portabletext/
|
|
83
|
-
"@portabletext/
|
|
82
|
+
"@portabletext/patches": "1.1.3",
|
|
83
|
+
"@portabletext/block-tools": "1.1.18"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@portabletext/toolkit": "^2.0.17",
|
package/src/editor/Editable.tsx
CHANGED
|
@@ -170,14 +170,13 @@ export const PortableTextEditable = forwardRef<
|
|
|
170
170
|
const readOnly = useSelector(editorActor, (s) =>
|
|
171
171
|
s.matches({'edit mode': 'read only'}),
|
|
172
172
|
)
|
|
173
|
-
const schemaTypes = useSelector(editorActor, (s) => s.context.schema)
|
|
174
173
|
const slateEditor = useSlate()
|
|
175
174
|
|
|
176
175
|
const rangeDecorationsActor = useActorRef(rangeDecorationsMachine, {
|
|
177
176
|
input: {
|
|
178
177
|
rangeDecorations: rangeDecorations ?? [],
|
|
179
178
|
readOnly,
|
|
180
|
-
schema:
|
|
179
|
+
schema: editorActor.getSnapshot().context.schema,
|
|
181
180
|
slateEditor,
|
|
182
181
|
skipSetup: !editorActor.getSnapshot().matches({setup: 'setting up'}),
|
|
183
182
|
},
|
|
@@ -202,8 +201,6 @@ export const PortableTextEditable = forwardRef<
|
|
|
202
201
|
})
|
|
203
202
|
}, [rangeDecorationsActor, rangeDecorations])
|
|
204
203
|
|
|
205
|
-
const blockTypeName = schemaTypes.block.name
|
|
206
|
-
|
|
207
204
|
// Output a minimal React editor inside Editable when in readOnly mode.
|
|
208
205
|
// NOTE: make sure all the plugins used here can be safely run over again at any point.
|
|
209
206
|
// There will be a problem if they redefine editor methods and then calling the original method within themselves.
|
|
@@ -289,7 +286,7 @@ export const PortableTextEditable = forwardRef<
|
|
|
289
286
|
},
|
|
290
287
|
[
|
|
291
288
|
editorActor,
|
|
292
|
-
portableTextEditor
|
|
289
|
+
portableTextEditor,
|
|
293
290
|
readOnly,
|
|
294
291
|
renderAnnotation,
|
|
295
292
|
renderChild,
|
|
@@ -303,7 +300,10 @@ export const PortableTextEditable = forwardRef<
|
|
|
303
300
|
debug(`Selection from props ${JSON.stringify(propsSelection)}`)
|
|
304
301
|
const normalizedSelection = normalizeSelection(
|
|
305
302
|
propsSelection,
|
|
306
|
-
fromSlateValue(
|
|
303
|
+
fromSlateValue(
|
|
304
|
+
slateEditor.children,
|
|
305
|
+
editorActor.getSnapshot().context.schema.block.name,
|
|
306
|
+
),
|
|
307
307
|
)
|
|
308
308
|
if (normalizedSelection !== null) {
|
|
309
309
|
debug(
|
|
@@ -324,7 +324,7 @@ export const PortableTextEditable = forwardRef<
|
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
-
}, [
|
|
327
|
+
}, [editorActor, propsSelection, slateEditor])
|
|
328
328
|
|
|
329
329
|
// Restore selection from props when the editor has been initialized properly with it's value
|
|
330
330
|
useEffect(() => {
|
|
@@ -447,7 +447,7 @@ export const PortableTextEditable = forwardRef<
|
|
|
447
447
|
const value = PortableTextEditor.getValue(portableTextEditor)
|
|
448
448
|
const ptRange = slateEditor.selection
|
|
449
449
|
? slateRangeToSelection({
|
|
450
|
-
schema:
|
|
450
|
+
schema: editorActor.getSnapshot().context.schema,
|
|
451
451
|
editor: slateEditor,
|
|
452
452
|
range: slateEditor.selection,
|
|
453
453
|
})
|
|
@@ -557,7 +557,7 @@ export const PortableTextEditable = forwardRef<
|
|
|
557
557
|
|
|
558
558
|
debug('No result from custom paste handler, pasting normally')
|
|
559
559
|
},
|
|
560
|
-
[editorActor, onPaste, portableTextEditor,
|
|
560
|
+
[editorActor, onPaste, portableTextEditor, slateEditor],
|
|
561
561
|
)
|
|
562
562
|
|
|
563
563
|
const handleOnFocus: FocusEventHandler<HTMLDivElement> = useCallback(
|