fix(plugin-embed): 修复插入网址插件在查看模式下还可以复制、删除的bug
This commit is contained in:
parent
c2742bd908
commit
77d2badd2c
|
@ -9,6 +9,7 @@ import {
|
||||||
CardToolbarItemOptions,
|
CardToolbarItemOptions,
|
||||||
ToolbarItemOptions,
|
ToolbarItemOptions,
|
||||||
sanitizeUrl,
|
sanitizeUrl,
|
||||||
|
isEngine,
|
||||||
} from '@aomao/engine';
|
} from '@aomao/engine';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
|
@ -82,27 +83,19 @@ class EmbedComponent extends Card<EmbedValue> {
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbar() {
|
toolbar() {
|
||||||
const items: Array<CardToolbarItemOptions | ToolbarItemOptions> = [
|
if (isEngine(this.editor)) {
|
||||||
{
|
const items: Array<CardToolbarItemOptions | ToolbarItemOptions> =
|
||||||
type: 'dnd',
|
[];
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'copy',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'delete',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const value = this.getValue();
|
const value = this.getValue();
|
||||||
if (value?.url) {
|
if (value?.url) {
|
||||||
items.push(
|
items.push(
|
||||||
{
|
|
||||||
type: 'separator',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
content: '<span class="data-icon data-icon-expand" />',
|
content: '<span class="data-icon data-icon-expand" />',
|
||||||
title: this.editor.language.get<string>('embed', 'expand'),
|
title: this.editor.language.get<string>(
|
||||||
|
'embed',
|
||||||
|
'expand',
|
||||||
|
),
|
||||||
onClick: () => this.expand(),
|
onClick: () => this.expand(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -117,8 +110,26 @@ class EmbedComponent extends Card<EmbedValue> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (!this.editor.readonly) {
|
||||||
|
items.unshift(
|
||||||
|
{
|
||||||
|
type: 'dnd',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'copy',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'delete',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'separator',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
handleInputKeydown(e: KeyboardEvent) {
|
handleInputKeydown(e: KeyboardEvent) {
|
||||||
if (isHotkey('enter', e)) this.handleSubmit();
|
if (isHotkey('enter', e)) this.handleSubmit();
|
||||||
|
|
Loading…
Reference in New Issue