From 77d2badd2ccd35acb6a66a148c466598c2f97b94 Mon Sep 17 00:00:00 2001 From: zgh Date: Wed, 12 Jan 2022 15:40:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(plugin-embed):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=8F=92=E5=85=A5=E7=BD=91=E5=9D=80=E6=8F=92=E4=BB=B6=E5=9C=A8?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E6=A8=A1=E5=BC=8F=E4=B8=8B=E8=BF=98=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E5=A4=8D=E5=88=B6=E3=80=81=E5=88=A0=E9=99=A4=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/embed/src/component/index.ts | 81 ++++++++++++++++------------ 1 file changed, 46 insertions(+), 35 deletions(-) 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) {