@portabletext/editor 1.0.9 → 1.0.10
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.d.mts +17 -5
- package/lib/index.d.ts +17 -5
- package/lib/index.esm.js +4 -4
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +4 -4
- package/lib/index.mjs.map +1 -1
- package/package.json +19 -20
- package/src/editor/PortableTextEditor.tsx +1 -6
- package/src/editor/hooks/usePortableTextEditor.ts +1 -0
- package/src/editor/hooks/usePortableTextEditorKeyGenerator.ts +3 -0
- package/src/editor/hooks/usePortableTextEditorSelection.tsx +1 -0
- package/src/editor/plugins/createWithHotKeys.ts +5 -1
- package/src/types/editor.ts +7 -0
- package/src/types/options.ts +6 -0
- package/src/utils/bufferUntil.ts +0 -15
package/lib/index.js
CHANGED
|
@@ -3031,7 +3031,7 @@ function createWithHotkeys(types$1, portableTextEditor, hotkeysFromOptions) {
|
|
|
3031
3031
|
const reservedHotkeys = ["enter", "tab", "shift", "delete", "end"], activeHotkeys = hotkeysFromOptions || DEFAULT_HOTKEYS;
|
|
3032
3032
|
return function(editor) {
|
|
3033
3033
|
return editor.pteWithHotKeys = (event) => {
|
|
3034
|
-
var _a, _b, _c, _d;
|
|
3034
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3035
3035
|
Object.keys(activeHotkeys).forEach((cat) => {
|
|
3036
3036
|
if (cat === "marks")
|
|
3037
3037
|
for (const hotkey in activeHotkeys[cat]) {
|
|
@@ -3104,8 +3104,8 @@ function createWithHotkeys(types$1, portableTextEditor, hotkeysFromOptions) {
|
|
|
3104
3104
|
const nextBlock = slate.Node.descendant(
|
|
3105
3105
|
editor,
|
|
3106
3106
|
slate.Path.next(editor.selection.focus.path.slice(0, 1))
|
|
3107
|
-
), focusBlockPath = editor.selection.focus.path.slice(0, 1), focusBlock = slate.Node.descendant(editor, focusBlockPath);
|
|
3108
|
-
if (nextBlock && focusBlock && !slate.Editor.isVoid(editor, focusBlock) && slate.Editor.isVoid(editor, nextBlock)) {
|
|
3107
|
+
), focusBlockPath = editor.selection.focus.path.slice(0, 1), focusBlock = slate.Node.descendant(editor, focusBlockPath), isEmptyFocusBlock = types.isPortableTextTextBlock(focusBlock) && focusBlock.children.length === 1 && ((_f = (_e = focusBlock.children) == null ? void 0 : _e[0]) == null ? void 0 : _f.text) === "";
|
|
3108
|
+
if (nextBlock && focusBlock && !slate.Editor.isVoid(editor, focusBlock) && slate.Editor.isVoid(editor, nextBlock) && isEmptyFocusBlock) {
|
|
3109
3109
|
debug$8("Preventing deleting void block below"), event.preventDefault(), event.stopPropagation(), slate.Transforms.removeNodes(editor, { match: (n) => n === focusBlock }), slate.Transforms.select(editor, focusBlockPath), editor.onChange();
|
|
3110
3110
|
return;
|
|
3111
3111
|
}
|
|
@@ -3984,7 +3984,7 @@ class PortableTextEditor extends react.Component {
|
|
|
3984
3984
|
if (this.editable)
|
|
3985
3985
|
return this.editable.getValue();
|
|
3986
3986
|
}), !props.schemaType)
|
|
3987
|
-
throw new Error('PortableTextEditor: missing "
|
|
3987
|
+
throw new Error('PortableTextEditor: missing "schemaType" property');
|
|
3988
3988
|
props.incomingPatches$ && console.warn("The prop 'incomingPatches$' is deprecated and renamed to 'patches$'"), this.change$.next({ type: "loading", isLoading: !0 }), this.schemaTypes = getPortableTextMemberSchemaTypes(
|
|
3989
3989
|
props.schemaType.hasOwnProperty("jsonType") ? props.schemaType : compileType(props.schemaType)
|
|
3990
3990
|
);
|