@blocknote/core 0.54.1 → 0.55.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.
- package/dist/BlockNoteExtension-BJCLnwrE.cjs.map +1 -1
- package/dist/BlockNoteExtension-CbvDA0F7.js.map +1 -1
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +6 -6
- package/dist/blocks-DLgTreVu.cjs +12 -0
- package/dist/blocks-DLgTreVu.cjs.map +1 -0
- package/dist/{blocks-Dol85hpH.js → blocks-DaEUT0O1.js} +346 -340
- package/dist/blocks-DaEUT0O1.js.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +1 -1
- package/dist/comments.cjs +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +62 -36
- package/dist/comments.js.map +1 -1
- package/dist/{en-uzHzj6eH.js → en-BAn9gxr-.js} +5 -2
- package/dist/{en-uzHzj6eH.js.map → en-BAn9gxr-.js.map} +1 -1
- package/dist/{en-BuzSuuTq.cjs → en-CHnrV5l8.cjs} +2 -2
- package/dist/{en-BuzSuuTq.cjs.map → en-CHnrV5l8.cjs.map} +1 -1
- package/dist/{extensions-D6JcJCwd.js → extensions-B1JQURVF.js} +221 -221
- package/dist/extensions-B1JQURVF.js.map +1 -0
- package/dist/{extensions-B7Rsp_Ft.cjs → extensions-CZkqKzJO.cjs} +3 -3
- package/dist/extensions-CZkqKzJO.cjs.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +2 -2
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +89 -23
- package/dist/locales.js.map +1 -1
- package/dist/{src-Buuo5l7X.js → src-D5w0XAHX.js} +702 -640
- package/dist/src-D5w0XAHX.js.map +1 -0
- package/dist/{src-C54Ok9E0.cjs → src-th5uZEvx.cjs} +8 -8
- package/dist/src-th5uZEvx.cjs.map +1 -0
- package/dist/webpack-stats.json +1 -1
- package/dist/y.cjs +1 -1
- package/dist/y.js +3 -3
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.js +1 -1
- package/package.json +12 -12
- package/src/comments/CommentEditorSubmitExtension.test.ts +141 -0
- package/src/comments/CommentEditorSubmitExtension.ts +56 -0
- package/src/comments/extension.ts +8 -0
- package/src/comments/index.ts +1 -0
- package/src/editor/BlockNoteEditor.ts +94 -41
- package/src/editor/BlockNoteExtension.ts +6 -1
- package/src/editor/managers/EventManager.browser.test.ts +334 -0
- package/src/editor/managers/EventManager.ts +128 -31
- package/src/editor/managers/ExtensionManager/ExtensionManager.test.ts +88 -1
- package/src/editor/managers/ExtensionManager/index.ts +30 -7
- package/src/editor/managers/StyleManager.browser.test.ts +122 -0
- package/src/editor/managers/StyleManager.test.ts +98 -0
- package/src/editor/managers/StyleManager.ts +31 -15
- package/src/editor/managers/index.ts +1 -0
- package/src/extensions/FormattingToolbar/FormattingToolbar.ts +23 -0
- package/src/extensions/SideMenu/SideMenu.ts +15 -0
- package/src/extensions/TableHandles/TableHandles.browser.test.ts +3 -1
- package/src/i18n/locales/ar.ts +1 -0
- package/src/i18n/locales/de.ts +1 -0
- package/src/i18n/locales/en.ts +1 -0
- package/src/i18n/locales/es.ts +1 -0
- package/src/i18n/locales/fa.ts +1 -0
- package/src/i18n/locales/fr.ts +1 -0
- package/src/i18n/locales/he.ts +1 -0
- package/src/i18n/locales/hr.ts +1 -0
- package/src/i18n/locales/is.ts +1 -0
- package/src/i18n/locales/it.ts +1 -0
- package/src/i18n/locales/ja.ts +1 -0
- package/src/i18n/locales/ko.ts +1 -0
- package/src/i18n/locales/nl.ts +1 -0
- package/src/i18n/locales/no.ts +1 -0
- package/src/i18n/locales/pl.ts +1 -0
- package/src/i18n/locales/pt.ts +1 -0
- package/src/i18n/locales/ru.ts +1 -0
- package/src/i18n/locales/sk.ts +1 -0
- package/src/i18n/locales/uk.ts +1 -0
- package/src/i18n/locales/uz.ts +1 -0
- package/src/i18n/locales/vi.ts +1 -0
- package/src/i18n/locales/zh-tw.ts +1 -0
- package/src/i18n/locales/zh.ts +1 -0
- package/src/index.ts +1 -0
- package/src/util/browser.ts +24 -0
- package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +4 -0
- package/types/src/comments/CommentEditorSubmitExtension.d.ts +19 -0
- package/types/src/comments/CommentEditorSubmitExtension.test.d.ts +1 -0
- package/types/src/comments/extension.d.ts +7 -0
- package/types/src/comments/index.d.ts +1 -0
- package/types/src/editor/BlockNoteEditor.d.ts +52 -19
- package/types/src/editor/BlockNoteExtension.d.ts +3 -0
- package/types/src/editor/managers/EventManager.browser.test.d.ts +1 -0
- package/types/src/editor/managers/EventManager.d.ts +55 -0
- package/types/src/editor/managers/StyleManager.browser.test.d.ts +1 -0
- package/types/src/editor/managers/StyleManager.d.ts +4 -2
- package/types/src/editor/managers/StyleManager.test.d.ts +1 -0
- package/types/src/editor/managers/index.d.ts +1 -0
- package/types/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.d.ts +3 -0
- package/types/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.d.ts +1 -0
- package/types/src/i18n/locales/en.d.ts +1 -0
- package/types/src/i18n/locales/fa.d.ts +1 -0
- package/types/src/i18n/locales/sk.d.ts +1 -0
- package/types/src/index.d.ts +1 -0
- package/types/src/util/browser.d.ts +2 -0
- package/dist/blocks-CTB_5Vyj.cjs +0 -12
- package/dist/blocks-CTB_5Vyj.cjs.map +0 -1
- package/dist/blocks-Dol85hpH.js.map +0 -1
- package/dist/extensions-B7Rsp_Ft.cjs.map +0 -1
- package/dist/extensions-D6JcJCwd.js.map +0 -1
- package/dist/src-Buuo5l7X.js.map +0 -1
- package/dist/src-C54Ok9E0.cjs.map +0 -1
package/src/util/browser.ts
CHANGED
|
@@ -28,3 +28,27 @@ export function mergeCSSClasses(...classes: (string | false | undefined)[]) {
|
|
|
28
28
|
|
|
29
29
|
export const isSafari = () =>
|
|
30
30
|
/^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
31
|
+
|
|
32
|
+
export const isAndroid = () =>
|
|
33
|
+
typeof navigator !== "undefined" && /android/i.test(navigator.userAgent);
|
|
34
|
+
|
|
35
|
+
// Cached lazily on first call in a browser environment. Touch capability
|
|
36
|
+
// doesn't change during a session, so there's no need to re-run `matchMedia` on
|
|
37
|
+
// every call. We only cache once `navigator`/`window` are available, so a
|
|
38
|
+
// `false` computed during SSR isn't frozen and carried onto the client.
|
|
39
|
+
let isTouchDeviceCache: boolean | undefined;
|
|
40
|
+
|
|
41
|
+
export const isTouchDevice = () => {
|
|
42
|
+
if (typeof navigator === "undefined" || typeof window === "undefined") {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (isTouchDeviceCache === undefined) {
|
|
47
|
+
isTouchDeviceCache =
|
|
48
|
+
navigator.maxTouchPoints > 0 &&
|
|
49
|
+
typeof window.matchMedia === "function" &&
|
|
50
|
+
window.matchMedia("(pointer: coarse)").matches;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return isTouchDeviceCache;
|
|
54
|
+
};
|
|
@@ -4,15 +4,19 @@ export declare const CodeKeyboardShortcutsExtension: (options: CodeBlockOptions)
|
|
|
4
4
|
readonly keyboardShortcuts: {
|
|
5
5
|
readonly Delete: ({ editor }: {
|
|
6
6
|
editor: import("../../../../index.js").BlockNoteEditor<any, any, any>;
|
|
7
|
+
event: KeyboardEvent;
|
|
7
8
|
}) => boolean;
|
|
8
9
|
readonly Tab: ({ editor }: {
|
|
9
10
|
editor: import("../../../../index.js").BlockNoteEditor<any, any, any>;
|
|
11
|
+
event: KeyboardEvent;
|
|
10
12
|
}) => boolean;
|
|
11
13
|
readonly Enter: ({ editor }: {
|
|
12
14
|
editor: import("../../../../index.js").BlockNoteEditor<any, any, any>;
|
|
15
|
+
event: KeyboardEvent;
|
|
13
16
|
}) => boolean;
|
|
14
17
|
readonly "Shift-Enter": ({ editor }: {
|
|
15
18
|
editor: import("../../../../index.js").BlockNoteEditor<any, any, any>;
|
|
19
|
+
event: KeyboardEvent;
|
|
16
20
|
}) => boolean;
|
|
17
21
|
};
|
|
18
22
|
readonly inputRules: readonly [{
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ExtensionOptions } from "../editor/BlockNoteExtension.js";
|
|
2
|
+
/** Keyboard submission for a comment editor. */
|
|
3
|
+
export declare const CommentEditorSubmitExtension: (options: {
|
|
4
|
+
/** Submit on plain Enter. Mod-Enter always submits. @default true */
|
|
5
|
+
submitOnEnter?: boolean;
|
|
6
|
+
onSubmit: (editor: ExtensionOptions["editor"]) => void | Promise<void>;
|
|
7
|
+
}) => import("../index.js").ExtensionFactoryInstance<{
|
|
8
|
+
key: string;
|
|
9
|
+
submit: () => Promise<void>;
|
|
10
|
+
runsBefore: string[];
|
|
11
|
+
keyboardShortcuts: {
|
|
12
|
+
"Mod-Enter": ({ event }: {
|
|
13
|
+
event: KeyboardEvent;
|
|
14
|
+
}) => boolean;
|
|
15
|
+
Enter?: (({ event }: {
|
|
16
|
+
event: KeyboardEvent;
|
|
17
|
+
}) => boolean) | undefined;
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -38,6 +38,12 @@ export declare const CommentsExtension: (options: {
|
|
|
38
38
|
* @default true
|
|
39
39
|
*/
|
|
40
40
|
confirmBeforeDiscard?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Submit comments, replies, and edits on Enter. Shift-Enter inserts a line
|
|
43
|
+
* break, and Mod-Enter always submits, regardless of this setting.
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
submitOnEnter?: boolean;
|
|
41
47
|
}) => import("../index.js").ExtensionFactoryInstance<{
|
|
42
48
|
readonly key: "comments";
|
|
43
49
|
readonly store: import("../index.js").Store<{
|
|
@@ -66,5 +72,6 @@ export declare const CommentsExtension: (options: {
|
|
|
66
72
|
}) => Promise<void>;
|
|
67
73
|
readonly commentEditorSchema: CustomBlockNoteSchema<any, any, any> | undefined;
|
|
68
74
|
readonly confirmBeforeDiscard: boolean;
|
|
75
|
+
readonly submitOnEnter: boolean;
|
|
69
76
|
}>;
|
|
70
77
|
export {};
|
|
@@ -11,7 +11,7 @@ import { EventEmitter } from "../util/EventEmitter.js";
|
|
|
11
11
|
import type { NoInfer } from "../util/typescript.js";
|
|
12
12
|
import { Extension, ExtensionFactory, ExtensionFactoryInstance } from "./BlockNoteExtension.js";
|
|
13
13
|
import type { TextCursorPosition } from "./cursorPositionTypes.js";
|
|
14
|
-
import { ExtensionManager } from "./managers/index.js";
|
|
14
|
+
import { EditorFocusOptions, ExtensionManager } from "./managers/index.js";
|
|
15
15
|
import type { Selection } from "./selectionTypes.js";
|
|
16
16
|
export type BlockCache<BSchema extends BlockSchema = any, ISchema extends InlineContentSchema = any, SSchema extends StyleSchema = any> = WeakMap<Node, Block<BSchema, ISchema, SSchema>>;
|
|
17
17
|
export interface BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema> {
|
|
@@ -393,17 +393,14 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
393
393
|
* Mount the editor to a DOM element.
|
|
394
394
|
*
|
|
395
395
|
* @param element The DOM element to mount the editor's contenteditable into.
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
* the surrounding shadow root when no parent is available.
|
|
396
|
+
*
|
|
397
|
+
* Floating UI rendered next to the contenteditable counts as within the
|
|
398
|
+
* editor already; UI rendered outside its DOM tree has to be registered with
|
|
399
|
+
* {@link registerPortalElement} so {@link isWithinEditor} recognizes it.
|
|
401
400
|
*
|
|
402
401
|
* @warning Not needed to call manually when using React, use BlockNoteView to take care of mounting
|
|
403
402
|
*/
|
|
404
|
-
mount: (element: HTMLElement
|
|
405
|
-
portalTarget?: HTMLElement | null;
|
|
406
|
-
}) => void;
|
|
403
|
+
mount: (element: HTMLElement) => void;
|
|
407
404
|
/**
|
|
408
405
|
* Unmount the editor from the DOM element it is bound to
|
|
409
406
|
*/
|
|
@@ -420,20 +417,39 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
420
417
|
*/
|
|
421
418
|
get prosemirrorView(): import("prosemirror-view").EditorView;
|
|
422
419
|
get domElement(): HTMLDivElement | undefined;
|
|
423
|
-
private
|
|
420
|
+
private _portalElements;
|
|
424
421
|
/**
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
422
|
+
* Registers an element as a portal element for this editor's floating UI, so
|
|
423
|
+
* {@link isWithinEditor} treats its contents as part of the editor. The view
|
|
424
|
+
* layer calls this for each portal element it designates (see
|
|
425
|
+
* `PortalElementOverride` in `@blocknote/react`) — without it, UI portalled outside
|
|
426
|
+
* the editor's DOM tree would be considered outside the editor.
|
|
427
|
+
* Registrations are reference-counted; release with
|
|
428
|
+
* {@link unregisterPortalElement}.
|
|
428
429
|
*/
|
|
429
|
-
|
|
430
|
+
registerPortalElement: (element: HTMLElement) => void;
|
|
430
431
|
/**
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
432
|
+
* Releases a registration made with {@link registerPortalElement}. The element
|
|
433
|
+
* stops counting as part of the editor once every registration for it has
|
|
434
|
+
* been released.
|
|
435
|
+
*/
|
|
436
|
+
unregisterPortalElement: (element: HTMLElement) => void;
|
|
437
|
+
/**
|
|
438
|
+
* Checks whether a DOM element belongs to this editor — inside the editor's
|
|
439
|
+
* DOM tree, or inside any portal element registered via
|
|
440
|
+
* {@link registerPortalElement} (used for floating UI elements like menus and
|
|
441
|
+
* toolbars, which may portal outside the editor's DOM tree).
|
|
442
|
+
*
|
|
443
|
+
* The DOM-tree check starts at the content area's *parent*, so that UI the
|
|
444
|
+
* host app renders as `BlockNoteView` children counts too — React places
|
|
445
|
+
* those beside the content (see the "Static Formatting Toolbar" example).
|
|
446
|
+
* The boundary is whatever the element passed to `editor.mount()` has as
|
|
447
|
+
* its parent: `BlockNoteView` always provides a wrapper; mounting bare into
|
|
448
|
+
* `<body>`, as the vanilla-JS docs do, makes the whole page count as within
|
|
449
|
+
* the editor.
|
|
434
450
|
*/
|
|
435
451
|
isWithinEditor: (element: Element) => boolean;
|
|
436
|
-
isFocused(): boolean;
|
|
452
|
+
isFocused(options?: EditorFocusOptions): boolean;
|
|
437
453
|
headless: boolean;
|
|
438
454
|
/**
|
|
439
455
|
* Focus on the editor
|
|
@@ -642,7 +658,8 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
642
658
|
*/
|
|
643
659
|
getSelectedText(): string;
|
|
644
660
|
/**
|
|
645
|
-
* Gets the URL of the
|
|
661
|
+
* Gets the URL of the link the current selection starts in, or `undefined`
|
|
662
|
+
* if it does not start in one.
|
|
646
663
|
*/
|
|
647
664
|
getSelectedLinkUrl(): string | undefined;
|
|
648
665
|
/**
|
|
@@ -770,6 +787,22 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
770
787
|
* @returns A function to remove the callback.
|
|
771
788
|
*/
|
|
772
789
|
onSelectionChange(callback: (editor: BlockNoteEditor<BSchema, ISchema, SSchema>) => void, includeSelectionChangedByRemote?: boolean): import("./managers/EventManager.js").Unsubscribe;
|
|
790
|
+
/**
|
|
791
|
+
* A callback function that runs when focus changes. By default, this reports
|
|
792
|
+
* when the editor's content area gains or loses DOM focus.
|
|
793
|
+
*
|
|
794
|
+
* Note that `focused: false` only means the content area itself blurred —
|
|
795
|
+
* focus may have moved into the editor's own UI (e.g. a toolbar
|
|
796
|
+
* popover's input). Pass `includeEditorUI: true` to report changes to
|
|
797
|
+
* combined content and UI focus, allowing focus handoffs to settle.
|
|
798
|
+
*
|
|
799
|
+
* @param callback The callback to execute.
|
|
800
|
+
* @returns A function to remove the callback.
|
|
801
|
+
*/
|
|
802
|
+
onFocusChange(callback: (editor: BlockNoteEditor<BSchema, ISchema, SSchema>, context: {
|
|
803
|
+
focused: boolean;
|
|
804
|
+
event: FocusEvent;
|
|
805
|
+
}) => void, options?: EditorFocusOptions): import("./managers/EventManager.js").Unsubscribe;
|
|
773
806
|
/**
|
|
774
807
|
* A callback function that runs when the editor has been mounted.
|
|
775
808
|
*
|
|
@@ -47,6 +47,8 @@ export interface Extension<State = any, Key extends string = string> {
|
|
|
47
47
|
readonly inputRules?: ReadonlyArray<InputRule>;
|
|
48
48
|
/**
|
|
49
49
|
* A mapping of a keyboard shortcut to a function that will be called when the shortcut is pressed
|
|
50
|
+
* The callback receives the editor and the original keyboard event. Return
|
|
51
|
+
* true to consume the shortcut, or false to let other handlers run.
|
|
50
52
|
*
|
|
51
53
|
* The keys are in the format:
|
|
52
54
|
* - Key names may be strings like `Shift-Ctrl-Enter`—a key identifier prefixed with zero or more modifiers
|
|
@@ -69,6 +71,7 @@ export interface Extension<State = any, Key extends string = string> {
|
|
|
69
71
|
*/
|
|
70
72
|
readonly keyboardShortcuts?: Record<string, (ctx: {
|
|
71
73
|
editor: BlockNoteEditor<any, any, any>;
|
|
74
|
+
event: KeyboardEvent;
|
|
72
75
|
}) => boolean>;
|
|
73
76
|
/**
|
|
74
77
|
* Add additional prosemirror plugins to the editor.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,6 +7,23 @@ import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema/inde
|
|
|
7
7
|
* A function that can be used to unsubscribe from an event.
|
|
8
8
|
*/
|
|
9
9
|
export type Unsubscribe = () => void;
|
|
10
|
+
/**
|
|
11
|
+
* Options shared by the focus APIs (`isFocused`, `onFocusChange`).
|
|
12
|
+
*/
|
|
13
|
+
export type EditorFocusOptions = {
|
|
14
|
+
/**
|
|
15
|
+
* When true, the editor's own UI - toolbars, menus and popovers inside
|
|
16
|
+
* its DOM boundary or registered portal elements - counts as focused,
|
|
17
|
+
* answering "is the user still interacting with this editor?" rather than
|
|
18
|
+
* "does the content area hold DOM focus?".
|
|
19
|
+
*
|
|
20
|
+
* Events then fire only when that combined state changes, and only once
|
|
21
|
+
* focus movement has settled, so a handoff from the content area into a
|
|
22
|
+
* popover's input reports no blur at all. The default reports raw
|
|
23
|
+
* content-area focus.
|
|
24
|
+
*/
|
|
25
|
+
includeEditorUI?: boolean;
|
|
26
|
+
};
|
|
10
27
|
/**
|
|
11
28
|
* EventManager is a class which manages the events of the editor
|
|
12
29
|
*/
|
|
@@ -24,6 +41,20 @@ export declare class EventManager<BSchema extends BlockSchema, I extends InlineC
|
|
|
24
41
|
transaction: Transaction;
|
|
25
42
|
}
|
|
26
43
|
];
|
|
44
|
+
onFocusChange: [
|
|
45
|
+
ctx: {
|
|
46
|
+
editor: BlockNoteEditor<BSchema, I, S>;
|
|
47
|
+
focused: boolean;
|
|
48
|
+
event: FocusEvent;
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
onFocusChangeWithinUI: [
|
|
52
|
+
ctx: {
|
|
53
|
+
editor: BlockNoteEditor<BSchema, I, S>;
|
|
54
|
+
focused: boolean;
|
|
55
|
+
event: FocusEvent;
|
|
56
|
+
}
|
|
57
|
+
];
|
|
27
58
|
onMount: [ctx: {
|
|
28
59
|
editor: BlockNoteEditor<BSchema, I, S>;
|
|
29
60
|
}];
|
|
@@ -33,6 +64,17 @@ export declare class EventManager<BSchema extends BlockSchema, I extends InlineC
|
|
|
33
64
|
}> {
|
|
34
65
|
private editor;
|
|
35
66
|
constructor(editor: BlockNoteEditor<BSchema, I, S>);
|
|
67
|
+
/**
|
|
68
|
+
* Settled focus-within-UI tracking. Document-level listeners (attached on
|
|
69
|
+
* editor mount, detached on unmount — a no-op per focus event is too
|
|
70
|
+
* cheap to be worth gating on subscribers) cover the case tiptap events
|
|
71
|
+
* can't: focus moving from the editor's own UI outside the content area
|
|
72
|
+
* (including registered portal elements) to somewhere else entirely.
|
|
73
|
+
* Blur-side changes are re-checked after the current task because
|
|
74
|
+
* `document.activeElement` transiently becomes `<body>` during focus
|
|
75
|
+
* handoffs (and `relatedTarget` is unreliable on mobile).
|
|
76
|
+
*/
|
|
77
|
+
private attachUIFocusTracker;
|
|
36
78
|
/**
|
|
37
79
|
* Register a callback that will be called when the editor changes.
|
|
38
80
|
*/
|
|
@@ -52,6 +94,19 @@ export declare class EventManager<BSchema extends BlockSchema, I extends InlineC
|
|
|
52
94
|
* If true, the callback will be triggered when the selection changes due to a yjs sync (i.e.: other user was typing)
|
|
53
95
|
*/
|
|
54
96
|
includeSelectionChangedByRemote?: boolean): Unsubscribe;
|
|
97
|
+
/**
|
|
98
|
+
* Register a callback for focus changes. By default, this reports when the
|
|
99
|
+
* editor's content area gains or loses DOM focus.
|
|
100
|
+
*
|
|
101
|
+
* Note that `focused: false` only means the content area itself blurred —
|
|
102
|
+
* focus may have moved into the editor's own UI (e.g. a toolbar
|
|
103
|
+
* popover's input). Pass `includeEditorUI: true` to report changes to
|
|
104
|
+
* combined content and UI focus, allowing focus handoffs to settle.
|
|
105
|
+
*/
|
|
106
|
+
onFocusChange(callback: (editor: BlockNoteEditor<BSchema, I, S>, ctx: {
|
|
107
|
+
focused: boolean;
|
|
108
|
+
event: FocusEvent;
|
|
109
|
+
}) => void, options?: EditorFocusOptions): Unsubscribe;
|
|
55
110
|
/**
|
|
56
111
|
* Register a callback that will be called when the editor is mounted.
|
|
57
112
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -36,7 +36,8 @@ export declare class StyleManager<BSchema extends BlockSchema = DefaultBlockSche
|
|
|
36
36
|
*/
|
|
37
37
|
getSelectedText(): string;
|
|
38
38
|
/**
|
|
39
|
-
* Find the link mark and its range at the given position
|
|
39
|
+
* Find the link mark and its range at the given position, including at
|
|
40
|
+
* either edge of the link.
|
|
40
41
|
* Returns undefined if there is no link at that position.
|
|
41
42
|
*/
|
|
42
43
|
getLinkMarkAtPos(pos: number): {
|
|
@@ -46,7 +47,8 @@ export declare class StyleManager<BSchema extends BlockSchema = DefaultBlockSche
|
|
|
46
47
|
text: string;
|
|
47
48
|
} | undefined;
|
|
48
49
|
/**
|
|
49
|
-
* Gets the URL of the
|
|
50
|
+
* Gets the URL of the link the current selection starts in, or `undefined`
|
|
51
|
+
* if it does not start in one.
|
|
50
52
|
*/
|
|
51
53
|
getSelectedLinkUrl(): string | undefined;
|
|
52
54
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { BlockManager } from "./BlockManager.js";
|
|
2
2
|
export { EventManager } from "./EventManager.js";
|
|
3
|
+
export type { EditorFocusOptions } from "./EventManager.js";
|
|
3
4
|
export { ExportManager } from "./ExportManager.js";
|
|
4
5
|
export { ExtensionManager } from "./ExtensionManager/index.js";
|
|
5
6
|
export { SelectionManager } from "./SelectionManager.js";
|
|
@@ -17,12 +17,15 @@ export declare const SourceBlockWithPreviewExtension: () => import("../..").Exte
|
|
|
17
17
|
keyboardShortcuts: {
|
|
18
18
|
Enter: ({ editor }: {
|
|
19
19
|
editor: BlockNoteEditor<any, any, any>;
|
|
20
|
+
event: KeyboardEvent;
|
|
20
21
|
}) => boolean;
|
|
21
22
|
Escape: ({ editor }: {
|
|
22
23
|
editor: BlockNoteEditor<any, any, any>;
|
|
24
|
+
event: KeyboardEvent;
|
|
23
25
|
}) => boolean;
|
|
24
26
|
"Mod-a": ({ editor }: {
|
|
25
27
|
editor: BlockNoteEditor<any, any, any>;
|
|
28
|
+
event: KeyboardEvent;
|
|
26
29
|
}) => boolean;
|
|
27
30
|
ArrowUp: ({ editor }: {
|
|
28
31
|
editor: BlockNoteEditor<any>;
|
package/types/src/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./api/nodeUtil.js";
|
|
|
11
11
|
export * from "./api/pmUtil.js";
|
|
12
12
|
export * from "./blocks/index.js";
|
|
13
13
|
export * from "./editor/BlockNoteEditor.js";
|
|
14
|
+
export type { EditorFocusOptions } from "./editor/managers/EventManager.js";
|
|
14
15
|
export * from "./editor/BlockNoteExtension.js";
|
|
15
16
|
export * from "./editor/defaultColors.js";
|
|
16
17
|
export * from "./editor/selectionTypes.js";
|
|
@@ -2,3 +2,5 @@ export declare const isAppleOS: () => boolean;
|
|
|
2
2
|
export declare function formatKeyboardShortcut(shortcut: string, ctrlText?: string): string;
|
|
3
3
|
export declare function mergeCSSClasses(...classes: (string | false | undefined)[]): string;
|
|
4
4
|
export declare const isSafari: () => boolean;
|
|
5
|
+
export declare const isAndroid: () => boolean;
|
|
6
|
+
export declare const isTouchDevice: () => boolean;
|