Skip to content

Commit 7e2f167

Browse files
committed
feat: add consistent file naming to buttons
1 parent 89b8307 commit 7e2f167

File tree

15 files changed

+65
-89
lines changed

15 files changed

+65
-89
lines changed

docs/src/pages/examples/ui-components/adding-side-menu-drag-handle-items/adding-side-menu-drag-handle-items.example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { CommonModule } from '@angular/common';
22
import { Component } from '@angular/core';
33
import { PartialBlock } from '@blocknote/core';
44
import {
5-
BasicTextStyleButtonComponent,
65
BnaAddBlockButtonComponent,
6+
BnaBasicTextStyleButtonComponent,
77
BnaDeleteBlockItemComponent,
88
BnaDragHandleMenuComponent,
99
BnaEditorComponent,
@@ -19,7 +19,7 @@ import { ResetBlockButtonComponent } from './reset-block-button.component';
1919
imports: [
2020
CommonModule,
2121
BnaEditorComponent,
22-
BasicTextStyleButtonComponent,
22+
BnaBasicTextStyleButtonComponent,
2323
HlmButtonDirective,
2424
BnaSideMenuControllerDirective,
2525
BnaSideMenuComponent,

docs/src/pages/examples/ui-components/formatting-side-menu-buttons/formatting-side-menu-buttons.example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { CommonModule } from '@angular/common';
22
import { Component } from '@angular/core';
33
import { PartialBlock } from '@blocknote/core';
44
import {
5-
BasicTextStyleButtonComponent,
5+
BnaBasicTextStyleButtonComponent,
66
BnaDragHandleMenuComponent,
77
BnaEditorComponent,
88
BnaSideMenuComponent,
@@ -17,7 +17,7 @@ import { RemoveBlockButtonComponent } from './remove-block-button.component';
1717
imports: [
1818
CommonModule,
1919
BnaEditorComponent,
20-
BasicTextStyleButtonComponent,
20+
BnaBasicTextStyleButtonComponent,
2121
HlmButtonDirective,
2222
BnaSideMenuControllerDirective,
2323
BnaSideMenuComponent,

docs/src/pages/examples/ui-components/formatting-toolbar-buttons/formatting-toolbar-buttons.example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { CommonModule } from '@angular/common';
22
import { Component } from '@angular/core';
33
import { PartialBlock } from '@blocknote/core';
44
import {
5-
BasicTextStyleButtonComponent,
5+
BnaBasicTextStyleButtonComponent,
66
BnaEditorComponent,
77
BnaFormattingToolbarComponent,
88
BnaFormattingToolbarControllerDirective,
@@ -17,7 +17,7 @@ import { BlueButtonComponent } from './blue-button.component';
1717
CommonModule,
1818
BnaEditorComponent,
1919
BnaFormattingToolbarControllerDirective,
20-
BasicTextStyleButtonComponent,
20+
BnaBasicTextStyleButtonComponent,
2121
BnaFormattingToolbarComponent,
2222
HlmButtonDirective,
2323
BlueButtonComponent,

libs/block-note-angular/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export * from './lib/services/block-note-angular.service';
33
export * from './lib/interfaces/block-note-editor-options.type';
44
export * from './lib/components/bna-formatting-toolbar/bna-formatting-toolbar-controller.directive';
55
export * from './lib/components/bna-formatting-toolbar/bna-formatting-toolbar.component';
6-
export * from './lib/components/buttons/basic-text-style-button/basic-text-style-button.component';
6+
export * from './lib/components/buttons/basic-text-style-button/bna-basic-text-style-button.component';
77
export * from './lib/components/bna-side-menu/bna-side-menu.component';
88
export * from './lib/components/bna-side-menu/bna-side-menu-controller.directive';
99
export * from './lib/components/bna-side-menu/default-buttons/drag-handle-menu/bna-drag-handle-menu.component';

libs/block-note-angular/src/lib/block-note-editor/bna-editor.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ import { BnaAddBlockButtonComponent } from '../components/bna-side-menu/default-
3333
import { BnaDragHandleMenuComponent } from '../components/bna-side-menu/default-buttons/drag-handle-menu/bna-drag-handle-menu.component';
3434
import { BnaSuggestionsMenuControllerDirective } from '../components/bna-suggestions-menu/bna-suggestions-menu-controller.directive';
3535
import { BnaViewControllerDirective } from '../components/bna-view/bna-view-controller.directive';
36-
import { BasicTextStyleButtonComponent } from '../components/buttons/basic-text-style-button/basic-text-style-button.component';
37-
import { TextAlignButtonComponent } from '../components/buttons/text-align-button/text-align-button.component';
36+
import { BnaBasicTextStyleButtonComponent } from '../components/buttons/basic-text-style-button/bna-basic-text-style-button.component';
37+
import { BnaTextAlignButtonComponent } from '../components/buttons/text-align-button/bna-text-align-button.component';
3838
import { BlockNoteEditorOptionsType } from '../interfaces/block-note-editor-options.type';
3939
import { BlockNoteAngularService } from '../services/block-note-angular.service';
4040
import {
@@ -61,15 +61,15 @@ import {
6161
BnaFormattingToolbarControllerDirective,
6262
HlmCardDirective,
6363
HlmButtonDirective,
64-
BasicTextStyleButtonComponent,
64+
BnaBasicTextStyleButtonComponent,
6565
HlmMenuComponent,
6666
HlmMenuLabelComponent,
6767
HlmMenuSeparatorComponent,
6868
HlmMenuGroupComponent,
6969
HlmMenuItemDirective,
7070
HlmMenuShortcutComponent,
7171
HlmMenuItemSubIndicatorComponent,
72-
TextAlignButtonComponent,
72+
BnaTextAlignButtonComponent,
7373
BnaFilePanelComponent,
7474
HlmInputDirective,
7575
BnaFilePanelControllerDirective,

libs/block-note-angular/src/lib/components/bna-side-menu/default-buttons/bna-delete-block-item/bna-delete-block-item.component.ts

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CommonModule } from '@angular/common';
2-
import { Component, effect } from '@angular/core';
2+
import { Component, effect, OnInit } from '@angular/core';
33
import { Block } from '@blocknote/core';
44
import { BlockNoteAngularService } from '../../../../services/block-note-angular.service';
55
import { HlmButtonDirective, HlmMenuItemDirective } from '../../../../ui';
@@ -14,8 +14,9 @@ import { HlmButtonDirective, HlmMenuItemDirective } from '../../../../ui';
1414
class: 'block',
1515
},
1616
})
17-
export class BnaDeleteBlockItemComponent {
17+
export class BnaDeleteBlockItemComponent implements OnInit {
1818
dragBlock?: Block<any, any, any>;
19+
selectedBlocks: Block<any, any, any>[] = [];
1920

2021
constructor(public blockNoteAngularService: BlockNoteAngularService) {
2122
effect(() => {
@@ -29,14 +30,39 @@ export class BnaDeleteBlockItemComponent {
2930
});
3031
}
3132

33+
ngOnInit() {
34+
const editor = this.blockNoteAngularService.editor();
35+
if (!editor) {
36+
return;
37+
}
38+
const selection = editor.getSelection();
39+
//Todo: create type
40+
// Get the blocks in the current selection and store on the state. If
41+
// the selection is empty, store the block containing the text cursor
42+
// instead.
43+
let selectedBlocks: Block<any, any, any>[] = [];
44+
if (selection !== undefined) {
45+
selectedBlocks = selection.blocks;
46+
} else {
47+
selectedBlocks = [editor.getTextCursorPosition().block];
48+
}
49+
if (
50+
this.dragBlock &&
51+
selectedBlocks.find(
52+
(selectedBlock) => this.dragBlock!.id === selectedBlock.id
53+
) === undefined
54+
) {
55+
selectedBlocks = [this.dragBlock];
56+
}
57+
this.selectedBlocks = selectedBlocks;
58+
}
59+
3260
deleteBlock() {
3361
const editor = this.blockNoteAngularService.editor();
3462
if (!editor) {
3563
return;
3664
}
37-
console.log('delete block');
38-
// console.log('delete block', this.selectedBlocks);
39-
// editor.removeBlocks(this.selectedBlocks);
40-
// editor.sideMenu.unfreezeMenu();
65+
editor.removeBlocks(this.selectedBlocks);
66+
editor.sideMenu.unfreezeMenu();
4167
}
4268
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { CommonModule } from '@angular/common';
2-
import { Component, effect } from '@angular/core';
3-
import { Block } from '@blocknote/core';
2+
import { Component } from '@angular/core';
43
import { provideIcons } from '@ng-icons/core';
54
import { lucideGripVertical } from '@ng-icons/lucide';
65
import { BrnMenuTriggerDirective } from '@spartan-ng/ui-menu-brain';
@@ -19,8 +18,8 @@ import {
1918
} from '../../../../ui';
2019
import { BnaFormattingToolbarControllerDirective } from '../../../bna-formatting-toolbar/bna-formatting-toolbar-controller.directive';
2120
import { BnaFormattingToolbarComponent } from '../../../bna-formatting-toolbar/bna-formatting-toolbar.component';
22-
import { BasicTextStyleButtonComponent } from '../../../buttons/basic-text-style-button/basic-text-style-button.component';
23-
import { TextAlignButtonComponent } from '../../../buttons/text-align-button/text-align-button.component';
21+
import { BnaBasicTextStyleButtonComponent } from '../../../buttons/basic-text-style-button/bna-basic-text-style-button.component';
22+
import { BnaTextAlignButtonComponent } from '../../../buttons/text-align-button/bna-text-align-button.component';
2423
import { BnaDeleteBlockItemComponent } from '../bna-delete-block-item/bna-delete-block-item.component';
2524

2625
@Component({
@@ -39,70 +38,31 @@ import { BnaDeleteBlockItemComponent } from '../bna-delete-block-item/bna-delete
3938
HlmMenuShortcutComponent,
4039
HlmMenuSeparatorComponent,
4140
HlmMenuGroupComponent,
42-
BasicTextStyleButtonComponent,
41+
BnaBasicTextStyleButtonComponent,
4342
BnaFormattingToolbarComponent,
4443
BnaFormattingToolbarControllerDirective,
45-
TextAlignButtonComponent,
44+
BnaTextAlignButtonComponent,
4645
BnaDeleteBlockItemComponent,
4746
],
4847
templateUrl: './bna-drag-handle-menu.component.html',
4948
styleUrl: './bna-drag-handle-menu.component.css',
5049
providers: [provideIcons({ lucideGripVertical })],
5150
})
5251
export class BnaDragHandleMenuComponent {
53-
dragMenuShown = false;
54-
selectedBlocks: Block<any, any, any>[] = [];
55-
dragBlock?: Block<any, any, any>;
56-
57-
constructor(public blockNoteAngularService: BlockNoteAngularService) {
58-
effect(() => {
59-
const editor = blockNoteAngularService.editor();
60-
if (!editor) {
61-
return;
62-
}
63-
editor.sideMenu.onUpdate((state) => {
64-
this.dragBlock = state.block;
65-
});
66-
});
67-
}
52+
constructor(public blockNoteAngularService: BlockNoteAngularService) {}
6853

6954
openDragMenu() {
7055
const editor = this.blockNoteAngularService.editor();
7156
if (!editor) {
7257
return;
7358
}
74-
const selection = editor.getSelection();
75-
//Todo: create type
76-
// Get the blocks in the current selection and store on the state. If
77-
// the selection is empty, store the block containing the text cursor
78-
// instead.
79-
let selectedBlocks: Block<any, any, any>[] = [];
80-
if (selection !== undefined) {
81-
selectedBlocks = selection.blocks;
82-
} else {
83-
selectedBlocks = [editor.getTextCursorPosition().block];
84-
}
85-
if (
86-
this.dragBlock &&
87-
selectedBlocks.find(
88-
(selectedBlock) => this.dragBlock!.id === selectedBlock.id
89-
) === undefined
90-
) {
91-
selectedBlocks = [this.dragBlock];
92-
}
93-
this.selectedBlocks = selectedBlocks;
94-
this.dragMenuShown = !this.dragMenuShown;
95-
if (this.dragMenuShown) {
96-
editor.sideMenu.freezeMenu();
97-
}
9859
}
9960

10061
dragStart($event: DragEvent) {
10162
const editor = this.blockNoteAngularService.editor();
10263
if (!editor) {
10364
return;
10465
}
105-
console.log('drag start', $event);
10666
editor.sideMenu.blockDragStart($event);
10767
}
10868

@@ -113,14 +73,4 @@ export class BnaDragHandleMenuComponent {
11373
}
11474
editor.sideMenu.blockDragEnd();
11575
}
116-
117-
deleteBlock() {
118-
const editor = this.blockNoteAngularService.editor();
119-
if (!editor) {
120-
return;
121-
}
122-
console.log('delete block', this.selectedBlocks);
123-
editor.removeBlocks(this.selectedBlocks);
124-
editor.sideMenu.unfreezeMenu();
125-
}
12676
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
2-
import { BasicTextStyleButtonComponent } from './basic-text-style-button.component';
2+
import { BnaBasicTextStyleButtonComponent } from './bna-basic-text-style-button.component';
33

44
describe('BnaBasicTextStyleButtonComponent', () => {
5-
let component: BasicTextStyleButtonComponent;
6-
let fixture: ComponentFixture<BasicTextStyleButtonComponent>;
5+
let component: BnaBasicTextStyleButtonComponent;
6+
let fixture: ComponentFixture<BnaBasicTextStyleButtonComponent>;
77

88
beforeEach(async () => {
99
await TestBed.configureTestingModule({
10-
imports: [BasicTextStyleButtonComponent],
10+
imports: [BnaBasicTextStyleButtonComponent],
1111
}).compileComponents();
1212

13-
fixture = TestBed.createComponent(BasicTextStyleButtonComponent);
13+
fixture = TestBed.createComponent(BnaBasicTextStyleButtonComponent);
1414
component = fixture.componentInstance;
1515
fixture.detectChanges();
1616
});
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ type BasicTextStyle = 'bold' | 'italic' | 'underline' | 'strike' | 'code';
1919
selector: 'bna-basic-text-style-button',
2020
standalone: true,
2121
imports: [CommonModule, HlmButtonDirective, HlmIconComponent],
22-
templateUrl: './basic-text-style-button.component.html',
23-
styleUrl: './basic-text-style-button.component.css',
22+
templateUrl: './bna-basic-text-style-button.component.html',
23+
styleUrl: './bna-basic-text-style-button.component.css',
2424
providers: [provideIcons({ lucideBold, lucideItalic, lucideUnderline })],
2525
})
26-
export class BasicTextStyleButtonComponent {
26+
export class BnaBasicTextStyleButtonComponent {
2727
basicTextStyle = input.required<BasicTextStyle>();
2828
icon = computed(() => {
2929
return icons[this.basicTextStyle()];
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
2-
import { TextAlignButtonComponent } from './text-align-button.component';
2+
import { BnaTextAlignButtonComponent } from './bna-text-align-button.component';
33

44
describe('TextAlignButtonComponent', () => {
5-
let component: TextAlignButtonComponent;
6-
let fixture: ComponentFixture<TextAlignButtonComponent>;
5+
let component: BnaTextAlignButtonComponent;
6+
let fixture: ComponentFixture<BnaTextAlignButtonComponent>;
77

88
beforeEach(async () => {
99
await TestBed.configureTestingModule({
10-
imports: [TextAlignButtonComponent],
10+
imports: [BnaTextAlignButtonComponent],
1111
}).compileComponents();
1212

13-
fixture = TestBed.createComponent(TextAlignButtonComponent);
13+
fixture = TestBed.createComponent(BnaTextAlignButtonComponent);
1414
component = fixture.componentInstance;
1515
fixture.detectChanges();
1616
});

libs/block-note-angular/src/lib/components/buttons/text-align-button/text-align-button.component.ts renamed to libs/block-note-angular/src/lib/components/buttons/text-align-button/bna-text-align-button.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ type Alignments = 'left' | 'center' | 'right';
2525
selector: 'bna-text-align-button',
2626
standalone: true,
2727
imports: [CommonModule, HlmButtonDirective, HlmIconComponent],
28-
templateUrl: './text-align-button.component.html',
29-
styleUrl: './text-align-button.component.css',
28+
templateUrl: './bna-text-align-button.component.html',
29+
styleUrl: './bna-text-align-button.component.css',
3030
providers: [
3131
provideIcons({ lucideAlignLeft, lucideAlignCenter, lucideAlignRight }),
3232
],
3333
})
34-
export class TextAlignButtonComponent {
34+
export class BnaTextAlignButtonComponent {
3535
alignment = input.required<Alignments>();
3636
icon = computed(() => {
3737
return icons[this.alignment()];

0 commit comments

Comments
 (0)