Skip to content

Commit

Permalink
feat(common): remove the some logic in ImageBaseComponent and MindEmo…
Browse files Browse the repository at this point in the history
…jiBaseComponent to try remove base class
  • Loading branch information
pubuzhixing8 committed Jun 25, 2024
1 parent 5522ec6 commit bdfbe31
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 31 deletions.
6 changes: 6 additions & 0 deletions .changeset/khaki-wasps-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@plait/common': minor
'@plait/mind': minor
---

remove the some logic in ImageBaseComponent and MindEmojiBaseComponent to try remove base class
25 changes: 0 additions & 25 deletions packages/common/src/image/image-base.component.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
import { PlaitBoard, PlaitElement } from '@plait/core';
import { CommonImageItem } from '../utils';

export abstract class ImageBaseComponent {
_imageItem!: CommonImageItem;

_isFocus!: boolean;

initialized = false;

element!: PlaitElement;

set imageItem(value: CommonImageItem) {
this._imageItem = value;
if (this.initialized) {
this.afterImageItemChange(this._imageItem, value);
}
}

get imageItem() {
return this._imageItem;
}

board!: PlaitBoard;

set isFocus(value: boolean) {
Expand All @@ -31,14 +15,5 @@ export abstract class ImageBaseComponent {
return this._isFocus;
}

abstract afterImageItemChange(previous: CommonImageItem, current: CommonImageItem): void;

abstract nativeElement(): HTMLElement;

initialize(): void {
this.initialized = true;
}

destroy(): void {
}
}
5 changes: 0 additions & 5 deletions packages/mind/src/emoji/emoji-base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,4 @@ export abstract class MindEmojiBaseComponent {
element!: MindElement<EmojiData>;

abstract nativeElement(): HTMLElement;

initialize(): void {
this.nativeElement().style.fontSize = `${this.fontSize}px`;
this.nativeElement().classList.add('mind-node-emoji');
}
}
2 changes: 1 addition & 1 deletion src/app/editor/emoji/emoji.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class MindEmojiComponent extends MindEmojiBaseComponent implements OnInit
}

ngOnInit(): void {
super.initialize();
this.nativeElement().innerHTML = this.emojiItem.name;
this.nativeElement().style.fontSize = `${this.fontSize}px`;
}
}

0 comments on commit bdfbe31

Please sign in to comment.