@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.d.mts
CHANGED
|
@@ -136,6 +136,9 @@ export declare type ConnectionChange = {
|
|
|
136
136
|
value: 'online' | 'offline'
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
139
142
|
export declare type createEditorOptions = {
|
|
140
143
|
keyGenerator: () => string
|
|
141
144
|
patches$?: PatchObservable
|
|
@@ -223,6 +226,9 @@ export declare type EditorChange =
|
|
|
223
226
|
| UnsetChange
|
|
224
227
|
| ValueChange
|
|
225
228
|
|
|
229
|
+
/**
|
|
230
|
+
* @beta
|
|
231
|
+
*/
|
|
226
232
|
export declare type EditorChanges = Subject<EditorChange>
|
|
227
233
|
|
|
228
234
|
/** @internal */
|
|
@@ -276,6 +282,9 @@ export declare type HistoryItem = {
|
|
|
276
282
|
timestamp: Date
|
|
277
283
|
}
|
|
278
284
|
|
|
285
|
+
/**
|
|
286
|
+
* @beta
|
|
287
|
+
*/
|
|
279
288
|
export declare type HotkeyOptions = {
|
|
280
289
|
marks?: Record<string, string>
|
|
281
290
|
custom?: Record<string, (event: BaseSyntheticEvent, editor: PortableTextEditor) => void>
|
|
@@ -313,6 +322,9 @@ export declare type InvalidValueResolution = {
|
|
|
313
322
|
}
|
|
314
323
|
}
|
|
315
324
|
|
|
325
|
+
/**
|
|
326
|
+
* @public
|
|
327
|
+
*/
|
|
316
328
|
export declare const keyGenerator: () => string
|
|
317
329
|
|
|
318
330
|
/**
|
|
@@ -357,6 +369,9 @@ export declare type OnPasteResult =
|
|
|
357
369
|
}
|
|
358
370
|
| undefined
|
|
359
371
|
|
|
372
|
+
/**
|
|
373
|
+
* @beta
|
|
374
|
+
*/
|
|
360
375
|
export declare type OnPasteResultOrPromise = OnPasteResult | Promise<OnPasteResult>
|
|
361
376
|
|
|
362
377
|
/** @beta */
|
|
@@ -545,11 +560,6 @@ export declare class PortableTextEditor extends Component<PortableTextEditorProp
|
|
|
545
560
|
) => boolean | undefined
|
|
546
561
|
}
|
|
547
562
|
|
|
548
|
-
/**
|
|
549
|
-
* Props for the PortableTextEditor component
|
|
550
|
-
*
|
|
551
|
-
* @public
|
|
552
|
-
*/
|
|
553
563
|
/**
|
|
554
564
|
* Props for the PortableTextEditor component
|
|
555
565
|
*
|
|
@@ -822,11 +832,13 @@ export declare type UnsetChange = {
|
|
|
822
832
|
}
|
|
823
833
|
|
|
824
834
|
/**
|
|
835
|
+
* @public
|
|
825
836
|
* Get the current editor object from the React context.
|
|
826
837
|
*/
|
|
827
838
|
export declare const usePortableTextEditor: () => PortableTextEditor
|
|
828
839
|
|
|
829
840
|
/**
|
|
841
|
+
* @public
|
|
830
842
|
* Get the current editor selection from the React context.
|
|
831
843
|
*/
|
|
832
844
|
export declare const usePortableTextEditorSelection: () => EditorSelection
|
package/lib/index.d.ts
CHANGED
|
@@ -136,6 +136,9 @@ export declare type ConnectionChange = {
|
|
|
136
136
|
value: 'online' | 'offline'
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
139
142
|
export declare type createEditorOptions = {
|
|
140
143
|
keyGenerator: () => string
|
|
141
144
|
patches$?: PatchObservable
|
|
@@ -223,6 +226,9 @@ export declare type EditorChange =
|
|
|
223
226
|
| UnsetChange
|
|
224
227
|
| ValueChange
|
|
225
228
|
|
|
229
|
+
/**
|
|
230
|
+
* @beta
|
|
231
|
+
*/
|
|
226
232
|
export declare type EditorChanges = Subject<EditorChange>
|
|
227
233
|
|
|
228
234
|
/** @internal */
|
|
@@ -276,6 +282,9 @@ export declare type HistoryItem = {
|
|
|
276
282
|
timestamp: Date
|
|
277
283
|
}
|
|
278
284
|
|
|
285
|
+
/**
|
|
286
|
+
* @beta
|
|
287
|
+
*/
|
|
279
288
|
export declare type HotkeyOptions = {
|
|
280
289
|
marks?: Record<string, string>
|
|
281
290
|
custom?: Record<string, (event: BaseSyntheticEvent, editor: PortableTextEditor) => void>
|
|
@@ -313,6 +322,9 @@ export declare type InvalidValueResolution = {
|
|
|
313
322
|
}
|
|
314
323
|
}
|
|
315
324
|
|
|
325
|
+
/**
|
|
326
|
+
* @public
|
|
327
|
+
*/
|
|
316
328
|
export declare const keyGenerator: () => string
|
|
317
329
|
|
|
318
330
|
/**
|
|
@@ -357,6 +369,9 @@ export declare type OnPasteResult =
|
|
|
357
369
|
}
|
|
358
370
|
| undefined
|
|
359
371
|
|
|
372
|
+
/**
|
|
373
|
+
* @beta
|
|
374
|
+
*/
|
|
360
375
|
export declare type OnPasteResultOrPromise = OnPasteResult | Promise<OnPasteResult>
|
|
361
376
|
|
|
362
377
|
/** @beta */
|
|
@@ -545,11 +560,6 @@ export declare class PortableTextEditor extends Component<PortableTextEditorProp
|
|
|
545
560
|
) => boolean | undefined
|
|
546
561
|
}
|
|
547
562
|
|
|
548
|
-
/**
|
|
549
|
-
* Props for the PortableTextEditor component
|
|
550
|
-
*
|
|
551
|
-
* @public
|
|
552
|
-
*/
|
|
553
563
|
/**
|
|
554
564
|
* Props for the PortableTextEditor component
|
|
555
565
|
*
|
|
@@ -822,11 +832,13 @@ export declare type UnsetChange = {
|
|
|
822
832
|
}
|
|
823
833
|
|
|
824
834
|
/**
|
|
835
|
+
* @public
|
|
825
836
|
* Get the current editor object from the React context.
|
|
826
837
|
*/
|
|
827
838
|
export declare const usePortableTextEditor: () => PortableTextEditor
|
|
828
839
|
|
|
829
840
|
/**
|
|
841
|
+
* @public
|
|
830
842
|
* Get the current editor selection from the React context.
|
|
831
843
|
*/
|
|
832
844
|
export declare const usePortableTextEditorSelection: () => EditorSelection
|
package/lib/index.esm.js
CHANGED
|
@@ -3047,7 +3047,7 @@ function createWithHotkeys(types, portableTextEditor, hotkeysFromOptions) {
|
|
|
3047
3047
|
const reservedHotkeys = ["enter", "tab", "shift", "delete", "end"], activeHotkeys = hotkeysFromOptions || DEFAULT_HOTKEYS;
|
|
3048
3048
|
return function(editor) {
|
|
3049
3049
|
return editor.pteWithHotKeys = (event) => {
|
|
3050
|
-
var _a, _b, _c, _d;
|
|
3050
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3051
3051
|
Object.keys(activeHotkeys).forEach((cat) => {
|
|
3052
3052
|
if (cat === "marks")
|
|
3053
3053
|
for (const hotkey in activeHotkeys[cat]) {
|
|
@@ -3120,8 +3120,8 @@ function createWithHotkeys(types, portableTextEditor, hotkeysFromOptions) {
|
|
|
3120
3120
|
const nextBlock = Node.descendant(
|
|
3121
3121
|
editor,
|
|
3122
3122
|
Path.next(editor.selection.focus.path.slice(0, 1))
|
|
3123
|
-
), focusBlockPath = editor.selection.focus.path.slice(0, 1), focusBlock = Node.descendant(editor, focusBlockPath);
|
|
3124
|
-
if (nextBlock && focusBlock && !Editor.isVoid(editor, focusBlock) && Editor.isVoid(editor, nextBlock)) {
|
|
3123
|
+
), focusBlockPath = editor.selection.focus.path.slice(0, 1), focusBlock = Node.descendant(editor, focusBlockPath), isEmptyFocusBlock = isPortableTextTextBlock(focusBlock) && focusBlock.children.length === 1 && ((_f = (_e = focusBlock.children) == null ? void 0 : _e[0]) == null ? void 0 : _f.text) === "";
|
|
3124
|
+
if (nextBlock && focusBlock && !Editor.isVoid(editor, focusBlock) && Editor.isVoid(editor, nextBlock) && isEmptyFocusBlock) {
|
|
3125
3125
|
debug$8("Preventing deleting void block below"), event.preventDefault(), event.stopPropagation(), Transforms.removeNodes(editor, { match: (n) => n === focusBlock }), Transforms.select(editor, focusBlockPath), editor.onChange();
|
|
3126
3126
|
return;
|
|
3127
3127
|
}
|
|
@@ -4000,7 +4000,7 @@ class PortableTextEditor extends Component {
|
|
|
4000
4000
|
if (this.editable)
|
|
4001
4001
|
return this.editable.getValue();
|
|
4002
4002
|
}), !props.schemaType)
|
|
4003
|
-
throw new Error('PortableTextEditor: missing "
|
|
4003
|
+
throw new Error('PortableTextEditor: missing "schemaType" property');
|
|
4004
4004
|
props.incomingPatches$ && console.warn("The prop 'incomingPatches$' is deprecated and renamed to 'patches$'"), this.change$.next({ type: "loading", isLoading: !0 }), this.schemaTypes = getPortableTextMemberSchemaTypes(
|
|
4005
4005
|
props.schemaType.hasOwnProperty("jsonType") ? props.schemaType : compileType(props.schemaType)
|
|
4006
4006
|
);
|