@r-zubkov/ngx-blocknote 0.0.0-stage → 0.1.0-next.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.
@@ -0,0 +1,157 @@
1
+ import * as i0 from "@angular/core";
2
+ import { EnvironmentInjector, Injector, InputSignal, Signal, Type, ValueEqualityFn } from "@angular/core";
3
+ import { Block, BlockConfig, BlockFromConfig, BlockImplementation, BlockNoteEditor, BlockSchema, CustomInlineContentConfig, CustomInlineContentImplementation, CustomStyleImplementation, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, InlineContentFromConfig, InlineContentSchema, InlineContentSpec, PartialBlockFromConfig, PartialCustomInlineContentFromConfig, PropSchema, Store, StyleConfig, StyleSchema, StyleSpec } from "@blocknote/core";
4
+ type ContentMode = "inline" | "plain" | "none";
5
+ type AngularBlockConfig = BlockConfig<string, PropSchema, ContentMode>;
6
+ type AngularBlockContext<Config extends AngularBlockConfig, B extends BlockSchema = Record<Config["type"], Config>, I extends InlineContentSchema = DefaultInlineContentSchema, S extends StyleSchema = DefaultStyleSchema> = Readonly<{
7
+ block: Omit<BlockFromConfig<Config, I, S>, "children"> & Pick<Block<B, I, S>, "children">;
8
+ editor: BlockNoteEditor<B, I, S>;
9
+ }> & (Readonly<{
10
+ renderMode: "live";
11
+ updateBlock: (update: Pick<PartialBlockFromConfig<Config, I, S>, "props" | "content">) => void;
12
+ }> | Readonly<{
13
+ renderMode: "external";
14
+ }>);
15
+ interface AngularBlockFrameOptions<Config extends AngularBlockConfig, B extends BlockSchema = Record<Config["type"], Config>, I extends InlineContentSchema = DefaultInlineContentSchema, S extends StyleSchema = DefaultStyleSchema> {
16
+ readonly component: Type<{
17
+ readonly context: InputSignal<AngularBlockContext<Config, B, I, S>>;
18
+ }>;
19
+ /** Resolves a stable descendant for the block and its children. Defaults to `[data-frame-slot]`. */
20
+ readonly findFrameSlot?: (host: HTMLElement) => HTMLElement | null;
21
+ }
22
+ interface AngularBlockSpecOptions<Config extends AngularBlockConfig, B extends BlockSchema = Record<Config["type"], Config>, I extends InlineContentSchema = DefaultInlineContentSchema, S extends StyleSchema = DefaultStyleSchema> {
23
+ readonly environmentInjector: EnvironmentInjector;
24
+ readonly component: Type<{
25
+ readonly context: InputSignal<AngularBlockContext<Config, B, I, S>>;
26
+ }>;
27
+ /** Resolves the stable editable descendant. Defaults to `[data-content-dom]`. */
28
+ readonly findContentDOM?: (host: HTMLElement) => HTMLElement | null;
29
+ /** Resolves the frame slot for a layout-only block. Defaults to [data-frame-slot]. */
30
+ readonly findFrameSlot?: (host: HTMLElement) => HTMLElement | null;
31
+ /** An Angular frame around the block content and its children. */
32
+ readonly frame?: AngularBlockFrameOptions<Config, B, I, S>;
33
+ readonly parse?: BlockImplementation<Config["type"], Config["propSchema"], Config["content"]>["parse"];
34
+ /** Returning undefined uses the Angular content and frame snapshots. */
35
+ readonly toExternalHTML?: (context: {
36
+ readonly block: AngularBlockContext<Config, B, I, S>["block"];
37
+ readonly editor: BlockNoteEditor<B, I, S>;
38
+ readonly renderMode: "external";
39
+ readonly nestingLevel: number;
40
+ }) => {
41
+ dom: HTMLElement | DocumentFragment;
42
+ contentDOM?: HTMLElement;
43
+ childrenDOM?: HTMLElement;
44
+ } | undefined;
45
+ }
46
+ export declare function createAngularBlockSpec<const Name extends string, const Props extends PropSchema, const Content extends ContentMode, B extends BlockSchema = Record<Name, BlockConfig<Name, Props, Content>>, I extends InlineContentSchema = DefaultInlineContentSchema, S extends StyleSchema = DefaultStyleSchema>(config: BlockConfig<Name, Props, Content>, { environmentInjector, component, findContentDOM, findFrameSlot, frame, parse, toExternalHTML }: AngularBlockSpecOptions<NoInfer<BlockConfig<Name, Props, Content>>, B, I, S>): import("@blocknote/core").BlockSpec<Name, Props, Content>;
47
+ type InlineNode<Config extends CustomInlineContentConfig, S extends StyleSchema> = Parameters<CustomInlineContentImplementation<Config, S>["render"]>[3];
48
+ type AngularInlineContentContext<Config extends CustomInlineContentConfig, B extends BlockSchema = DefaultBlockSchema, I extends InlineContentSchema = DefaultInlineContentSchema, S extends StyleSchema = DefaultStyleSchema> = Readonly<{
49
+ inlineContent: InlineContentFromConfig<Config, S>;
50
+ editor: BlockNoteEditor<B, I, S>;
51
+ }> & (Readonly<{
52
+ renderMode: "live";
53
+ node: InlineNode<Config, S>;
54
+ getPos: () => number | undefined;
55
+ /** Replaces this inline element with the supplied content and props. */
56
+ updateInlineContent: (update: PartialCustomInlineContentFromConfig<Config, S>) => void;
57
+ }> | Readonly<{
58
+ renderMode: "external";
59
+ }>);
60
+ interface AngularInlineContentSpecOptions<Config extends CustomInlineContentConfig, B extends BlockSchema = DefaultBlockSchema, I extends InlineContentSchema = DefaultInlineContentSchema, S extends StyleSchema = DefaultStyleSchema> {
61
+ readonly environmentInjector: EnvironmentInjector;
62
+ readonly component: Type<{
63
+ readonly context: InputSignal<AngularInlineContentContext<Config, B, I, S>>;
64
+ }>;
65
+ /** Resolves the stable editable descendant. Defaults to `[data-content-dom]`. */
66
+ readonly findContentDOM?: (host: HTMLElement) => HTMLElement | null;
67
+ readonly parse?: CustomInlineContentImplementation<Config, S>["parse"];
68
+ /** Returning undefined uses a synchronous snapshot of the component. */
69
+ readonly toExternalHTML?: (context: Extract<AngularInlineContentContext<Config, B, I, S>, {
70
+ renderMode: "external";
71
+ }>) => {
72
+ dom: HTMLElement | DocumentFragment;
73
+ contentDOM?: HTMLElement;
74
+ } | undefined;
75
+ }
76
+ /** Creates a BlockNote inline spec backed by an Angular component. */
77
+ export declare function createAngularInlineContentSpec<const Config extends CustomInlineContentConfig, B extends BlockSchema = DefaultBlockSchema, I extends InlineContentSchema = DefaultInlineContentSchema, S extends StyleSchema = DefaultStyleSchema>(config: Config, { component, environmentInjector, findContentDOM, parse, toExternalHTML }: AngularInlineContentSpecOptions<NoInfer<Config>, B, I, S>): InlineContentSpec<Config>;
78
+ /**
79
+ * Reads the nearest host's editor as a signal from an Angular injection context.
80
+ * For a custom schema, pass the same schema types as the host's editor.
81
+ */
82
+ export declare function injectBlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema>(): Signal<BlockNoteEditor<BSchema, ISchema, SSchema>>;
83
+ type StyleValues = {
84
+ boolean: true;
85
+ string: string;
86
+ };
87
+ type AngularStyleContext<Config extends StyleConfig, B extends BlockSchema = DefaultBlockSchema, I extends InlineContentSchema = DefaultInlineContentSchema, S extends StyleSchema = DefaultStyleSchema> = Readonly<{
88
+ value: StyleValues[Config["propSchema"]];
89
+ editor: BlockNoteEditor<B, I, S>;
90
+ renderMode: "live" | "external";
91
+ }>;
92
+ interface AngularStyleSpecOptions<Config extends StyleConfig, B extends BlockSchema = DefaultBlockSchema, I extends InlineContentSchema = DefaultInlineContentSchema, S extends StyleSchema = DefaultStyleSchema> {
93
+ readonly environmentInjector: EnvironmentInjector;
94
+ readonly component: Type<{
95
+ readonly context: InputSignal<AngularStyleContext<Config, B, I, S>>;
96
+ }>;
97
+ /** Resolves the stable inline descendant. Defaults to `[data-content-dom]`. */
98
+ readonly findContentDOM?: (host: HTMLElement) => HTMLElement | null;
99
+ readonly parse?: CustomStyleImplementation<Config>["parse"];
100
+ /** Returning undefined uses a synchronous snapshot of the component. */
101
+ readonly toExternalHTML?: (context: AngularStyleContext<Config, B, I, S> & {
102
+ renderMode: "external";
103
+ }) => {
104
+ dom: HTMLElement;
105
+ contentDOM: HTMLElement;
106
+ } | undefined;
107
+ }
108
+ /** Creates a BlockNote text style backed by an Angular component. */
109
+ export declare function createAngularStyleSpec<const Config extends StyleConfig, B extends BlockSchema = DefaultBlockSchema, I extends InlineContentSchema = DefaultInlineContentSchema, S extends StyleSchema = DefaultStyleSchema>(config: Config, { component, environmentInjector, findContentDOM, parse, toExternalHTML }: AngularStyleSpecOptions<NoInfer<Config>, B, I, S>): StyleSpec<Config>;
110
+ /** A document change with BlockNote's lazy, transaction-specific getChanges callback. */
111
+ type NgxBlockNoteChangeEvent<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema> = NgxBlockNoteSelectionChangeEvent<BSchema, ISchema, SSchema> & Parameters<Parameters<BlockNoteEditor<BSchema, ISchema, SSchema>["onChange"]>[0]>[1];
112
+ /** A cursor or selection change in the supplied editor. */
113
+ interface NgxBlockNoteSelectionChangeEvent<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema> {
114
+ editor: BlockNoteEditor<BSchema, ISchema, SSchema>;
115
+ }
116
+ /** A DOM focus change in the editor's content area. */
117
+ type NgxBlockNoteFocusChangeEvent<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema> = NgxBlockNoteSelectionChangeEvent<BSchema, ISchema, SSchema> & Parameters<Parameters<BlockNoteEditor<BSchema, ISchema, SSchema>["onFocusChange"]>[0]>[1];
118
+ /** Hosts the currently supplied caller-owned BlockNote editor. */
119
+ export declare class NgxBlockNoteComponent<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> {
120
+ readonly editor: import("@angular/core").InputSignal<BlockNoteEditor<BSchema, ISchema, SSchema>>;
121
+ /** When undefined, leaves the caller's editable state as it is. */
122
+ readonly editable: import("@angular/core").InputSignal<boolean | undefined>;
123
+ /** Emits on document changes with a lazy getChanges callback. */
124
+ readonly contentChange: import("@angular/core").OutputEmitterRef<NgxBlockNoteChangeEvent<BSchema, ISchema, SSchema>>;
125
+ /** Emits when the cursor or selection changes. */
126
+ readonly selectionChange: import("@angular/core").OutputEmitterRef<NgxBlockNoteSelectionChangeEvent<BSchema, ISchema, SSchema>>;
127
+ /** Emits when the editor's content area gains or loses DOM focus. */
128
+ readonly focusChange: import("@angular/core").OutputEmitterRef<NgxBlockNoteFocusChangeEvent<BSchema, ISchema, SSchema>>;
129
+ private readonly mountPoint;
130
+ constructor();
131
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxBlockNoteComponent<any, any, any>, never>;
132
+ static ɵcmp: i0.ɵɵComponentDeclaration<NgxBlockNoteComponent<any, any, any>, "ngx-blocknote", never, {
133
+ "editor": {
134
+ "alias": "editor";
135
+ "required": true;
136
+ "isSignal": true;
137
+ };
138
+ "editable": {
139
+ "alias": "editable";
140
+ "required": false;
141
+ "isSignal": true;
142
+ };
143
+ }, {
144
+ "contentChange": "contentChange";
145
+ "selectionChange": "selectionChange";
146
+ "focusChange": "focusChange";
147
+ }, never, ["*"], true, never>;
148
+ }
149
+ type ReadableBlockNoteStore<State> = Readonly<Pick<Store<State>, "state" | "subscribe">>;
150
+ interface BlockNoteSignalOptions<State, Selected> {
151
+ selector: (state: State) => Selected;
152
+ equal?: ValueEqualityFn<Selected>;
153
+ injector?: Injector;
154
+ }
155
+ /** Reads a BlockNote store as a signal scoped to the Angular injection context. */
156
+ export declare function toBlockNoteSignal<State, Selected>(store: ReadableBlockNoteStore<State>, { selector, equal, injector }: BlockNoteSignalOptions<State, Selected>): Signal<Selected>;
157
+ export type { AngularBlockContext, AngularBlockFrameOptions, AngularBlockSpecOptions, AngularInlineContentContext, AngularInlineContentSpecOptions, AngularStyleContext, AngularStyleSpecOptions, BlockNoteSignalOptions, NgxBlockNoteChangeEvent, NgxBlockNoteFocusChangeEvent, NgxBlockNoteSelectionChangeEvent, ReadableBlockNoteStore };