Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public onPluginEvent(event: PluginEvent) {
if (event.eventType == PluginEventType.KeyUp || event.eventType == PluginEventType.MouseUp || event.eventType == PluginEventType.ContentChanged) {
let formatState = getFormatState(this.editor);
if (formatState) {
let result = '';
if (formatState.fontName) {
result += ' <b>fontName:</b> ' + formatState.fontName;
}
if (formatState.fontSize) {
result += ' <b>fontSize:</b> ' + formatState.fontSize;
}
if (formatState.backgroundColor) {
result += ' <b>backgroundColor:</b> ' + formatState.backgroundColor;
}
if (formatState.textColor) {
result += ' <b>textColor:</b> ' + formatState.textColor;
}
if (formatState.isBold) {
result += ' <b>Bold</b> ';
private getFormatState() {
let format = this.editor && getFormatState(this.editor);
let rect = this.editor && this.editor.getCursorRect();
return {
format,
inIME: this.editor && this.editor.isInIME(),
x: rect ? rect.left : 0,
y: rect ? rect.top : 0,
};
}
}
private _updateFormatState = (): void => {
const { roosterCommandBarPlugin } = this.props;
const editor: Editor = roosterCommandBarPlugin.getEditor();
const formatState = editor ? getFormatState(editor) : null;
if (formatState && this._hasFormatStateChanged(formatState)) {
this.setState({ formatState });
}
};
render() {
let plugin = this.props.plugin;
let editor = plugin.getEditor();
let format = editor && getFormatState(editor);
return (
<div>
{Object.keys(ribbonButtons).map(key => (
))}
<button>
Export
</button>
<button>
Clear
</button></div>
private updateRibbonState = () => {
this.ribbonStateJobId = null;
let editor = this.props.ribbonPlugin.getEditor();
let formatState = editor ? getFormatState(editor) : null;
if (formatState && this.isFormatStateChanged(formatState)) {
this.setFormatState(formatState);
}
};