fix!: refactor comment icon (#7128)

* fix: add basic comment icon

* fix: add using comment icon

* chore: delete old comment icon

* chore: add docs to the comment icon

* chore: move Comment to icons.CommentIcon

* chore: mode properties to module level

* chore: properly override and call super

* chore: remove .comment and .commentIcon_

* chore: cleanup test

* chore: deprecate getCommentIcon and getCommentText

* chore: change imports to import type

* chore: refactor code for paren peace

* chore: fix lint and make it error

* chore: remove change to block JS file

* chore: fix css

* chore: add renamings

* chore: format
This commit is contained in:
Beka Westberg
2023-06-02 09:53:05 -07:00
committed by GitHub
parent f4e378d096
commit 50d9474db5
19 changed files with 518 additions and 617 deletions

View File

@@ -6,6 +6,7 @@
import {Bubble} from './bubble.js';
import {Coordinate} from '../utils/coordinate.js';
import * as Css from '../css.js';
import * as dom from '../utils/dom.js';
import {Rect} from '../utils/rect.js';
import {Size} from '../utils/size.js';
@@ -39,6 +40,9 @@ export class TextInputBubble extends Bubble {
/** Functions listening for changes to the text of this bubble. */
private textChangeListeners: (() => void)[] = [];
/** Functions listening for changes to the size of this bubble. */
private sizeChangeListeners: (() => void)[] = [];
/** The text of this bubble. */
private text = '';
@@ -91,6 +95,11 @@ export class TextInputBubble extends Bubble {
this.textChangeListeners.push(listener);
}
/** Adds a change listener to be notified when this bubble's size changes. */
addSizeChangeListener(listener: () => void) {
this.sizeChangeListeners.push(listener);
}
/** Creates the editor UI for this bubble. */
private createEditor(container: SVGGElement): {
inputRoot: SVGForeignObjectElement;
@@ -224,6 +233,7 @@ export class TextInputBubble extends Bubble {
}
super.setSize(size, relayout);
this.onSizeChange();
}
/** @returns the size of this bubble. */
@@ -285,6 +295,7 @@ export class TextInputBubble extends Bubble {
new Size(this.workspace.RTL ? -delta.x : delta.x, delta.y),
false
);
this.onSizeChange();
}
/**
@@ -305,4 +316,24 @@ export class TextInputBubble extends Bubble {
listener();
}
}
/** Handles a size change event for the text area. Calls event listeners. */
private onSizeChange() {
for (const listener of this.sizeChangeListeners) {
listener();
}
}
}
Css.register(`
.blocklyCommentTextarea {
background-color: #fef49c;
border: 0;
display: block;
margin: 0;
outline: 0;
padding: 3px;
resize: none;
text-overflow: hidden;
}
`);