diff --git a/plugins/embed/src/component/index.ts b/plugins/embed/src/component/index.ts index e47ae6c5..06d638d1 100644 --- a/plugins/embed/src/component/index.ts +++ b/plugins/embed/src/component/index.ts @@ -9,6 +9,7 @@ import { CardToolbarItemOptions, ToolbarItemOptions, sanitizeUrl, + isEngine, } from '@aomao/engine'; import './index.css'; @@ -82,42 +83,52 @@ class EmbedComponent extends Card { } toolbar() { - const items: Array = [ - { - type: 'dnd', - }, - { - type: 'copy', - }, - { - type: 'delete', - }, - ]; - const value = this.getValue(); - if (value?.url) { - items.push( - { - type: 'separator', - }, - { - type: 'button', - content: '', - title: this.editor.language.get('embed', 'expand'), - onClick: () => this.expand(), - }, - { - type: 'button', - content: - '', - title: this.editor.language.get( - 'embed', - 'collapse', - ), - onClick: () => this.collapse(), - }, - ); + if (isEngine(this.editor)) { + const items: Array = + []; + const value = this.getValue(); + if (value?.url) { + items.push( + { + type: 'button', + content: '', + title: this.editor.language.get( + 'embed', + 'expand', + ), + onClick: () => this.expand(), + }, + { + type: 'button', + content: + '', + title: this.editor.language.get( + 'embed', + 'collapse', + ), + onClick: () => this.collapse(), + }, + ); + } + if (!this.editor.readonly) { + items.unshift( + { + type: 'dnd', + }, + { + type: 'copy', + }, + { + type: 'delete', + }, + { + type: 'separator', + }, + ); + } + return items; } - return items; + return []; } handleInputKeydown(e: KeyboardEvent) {