|
1 | 1 | import { CommonModule } from '@angular/common';
|
2 | 2 | import { Component } from '@angular/core';
|
3 |
| -import { BnaEditorComponent } from '@dytab/block-note-angular'; |
| 3 | +import { BlockNoteSchema, defaultBlockSpecs } from '@blocknote/core'; |
| 4 | +import { |
| 5 | + BlockNoteEditorOptionsType, |
| 6 | + BnaEditorComponent, |
| 7 | +} from '@dytab/block-note-angular'; |
4 | 8 | import { HlmButtonDirective } from '@spartan-ng/ui-button-helm';
|
5 |
| -import { BlockSpecs, defaultBlockSpecs } from '@blocknote/core'; |
6 | 9 |
|
7 | 10 | @Component({
|
8 | 11 | selector: 'bna-removing-default-blocks-example',
|
9 | 12 | standalone: true,
|
10 | 13 | imports: [CommonModule, BnaEditorComponent, HlmButtonDirective],
|
11 | 14 | template: `
|
12 |
| - <bna-editor [initialContent]="initialContent" [blockSpecs]="blockSpecs" /> |
| 15 | + <bna-editor [initialContent]="initialContent" [options]="options" /> |
13 | 16 | `,
|
14 | 17 | })
|
15 |
| -export class RemovingDefaultBlocksExample{ |
| 18 | +export class RemovingDefaultBlocksExample { |
16 | 19 | initialContent = undefined;
|
17 |
| - |
18 |
| - blockSpecs: BlockSpecs = { |
19 |
| - ...defaultBlockSpecs, |
20 |
| - audio: undefined as never, |
21 |
| - image: undefined as never, |
| 20 | + options: BlockNoteEditorOptionsType = { |
| 21 | + schema: BlockNoteSchema.create({ |
| 22 | + blockSpecs: { |
| 23 | + ...defaultBlockSpecs, |
| 24 | + audio: undefined as never, |
| 25 | + image: undefined as never, |
| 26 | + }, |
| 27 | + }), |
22 | 28 | };
|
23 | 29 | }
|
24 | 30 |
|
25 | 31 | export const removingDefaultBlocksExampleCode = `import { CommonModule } from '@angular/common';
|
26 | 32 | import { Component } from '@angular/core';
|
27 |
| -import { BnaEditorComponent } from '@dytab/block-note-angular'; |
| 33 | +import { BlockNoteSchema, defaultBlockSpecs } from '@blocknote/core'; |
| 34 | +import { |
| 35 | + BlockNoteEditorOptionsType, |
| 36 | + BnaEditorComponent, |
| 37 | +} from '@dytab/block-note-angular'; |
28 | 38 | import { HlmButtonDirective } from '@spartan-ng/ui-button-helm';
|
29 |
| -import { BlockNoteEditor } from '@blocknote/core'; |
30 | 39 |
|
31 | 40 | @Component({
|
32 |
| - selector: 'bna-manipulating-blocks-example', |
| 41 | + selector: 'bna-removing-default-blocks-example', |
33 | 42 | standalone: true,
|
34 | 43 | imports: [CommonModule, BnaEditorComponent, HlmButtonDirective],
|
35 |
| - template: \` |
36 |
| - <div class="flex gap-2"> |
37 |
| - <button hlmBtn size="sm" type="button" (click)="insertFirstBlock()">Insert First Block</button> |
38 |
| - <button hlmBtn size="sm" type="button" (click)="updateFirstBlock()">Update First Block</button> |
39 |
| - <button hlmBtn size="sm" type="button" (click)="removeFirstBlock()">Remove First Block</button> |
40 |
| - <button hlmBtn size="sm" type="button" (click)="replaceFirstBlock()">Replace First Block</button> |
41 |
| - </div> |
42 |
| - <bna-editor [initialContent]="initialContent" (onEditorReady)="editorReady($event)" /> |
43 |
| - \`, |
| 44 | + template: \` <bna-editor [initialContent]="initialContent" [options]="options"/> \`, |
44 | 45 | })
|
45 |
| -export class ManipulatingBlocksExample{ |
| 46 | +export class RemovingDefaultBlocksExample { |
46 | 47 | initialContent = undefined;
|
47 |
| - editor!: BlockNoteEditor; |
48 |
| -
|
49 |
| - async editorReady(editor: BlockNoteEditor) { |
50 |
| - this.editor = editor; |
51 |
| - } |
52 |
| -
|
53 |
| - insertFirstBlock(){ |
54 |
| - this.editor.insertBlocks( |
55 |
| - [ |
56 |
| - { |
57 |
| - content: |
58 |
| - "This block was inserted at " + |
59 |
| - new Date().toLocaleTimeString(), |
60 |
| - }, |
61 |
| - ], |
62 |
| - this.editor.document[0], |
63 |
| - "before" |
64 |
| - ) |
65 |
| - } |
66 |
| -
|
67 |
| - updateFirstBlock(){ |
68 |
| - this.editor.updateBlock(this.editor.document[0], { |
69 |
| - content: |
70 |
| - "This block was updated at " + new Date().toLocaleTimeString(), |
71 |
| - }) |
72 |
| - } |
73 |
| -
|
74 |
| - removeFirstBlock(){ |
75 |
| - this.editor.removeBlocks([this.editor.document[0]]) |
76 |
| - } |
77 |
| -
|
78 |
| - replaceFirstBlock(){ |
79 |
| - this.editor.replaceBlocks( |
80 |
| - [this.editor.document[0]], |
81 |
| - [ |
82 |
| - { |
83 |
| - content: |
84 |
| - "This block was replaced at " + |
85 |
| - new Date().toLocaleTimeString(), |
86 |
| - }, |
87 |
| - ] |
88 |
| - ) |
89 |
| - } |
| 48 | + options: BlockNoteEditorOptionsType = { |
| 49 | + schema: BlockNoteSchema.create({ |
| 50 | + blockSpecs: { |
| 51 | + ...defaultBlockSpecs, |
| 52 | + audio: undefined as never, |
| 53 | + image: undefined as never, |
| 54 | + }, |
| 55 | + }), |
| 56 | + }; |
90 | 57 | }`;
|
0 commit comments