fix: disable partial contextmenu in readonly mode
This commit is contained in:
@@ -6,7 +6,7 @@ export const controlMenus: IRegisterContextMenu[] = [
|
|||||||
{
|
{
|
||||||
i18nPath: 'contextmenu.control.delete',
|
i18nPath: 'contextmenu.control.delete',
|
||||||
when: (payload) => {
|
when: (payload) => {
|
||||||
return !payload.editorHasSelection && payload.startElement?.type === ElementType.CONTROL
|
return !payload.isReadonly && !payload.editorHasSelection && payload.startElement?.type === ElementType.CONTROL
|
||||||
},
|
},
|
||||||
callback: (command: Command) => {
|
callback: (command: Command) => {
|
||||||
command.executeRemoveControl()
|
command.executeRemoveControl()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export const hyperlinkMenus: IRegisterContextMenu[] = [
|
|||||||
{
|
{
|
||||||
i18nPath: 'contextmenu.hyperlink.delete',
|
i18nPath: 'contextmenu.hyperlink.delete',
|
||||||
when: (payload) => {
|
when: (payload) => {
|
||||||
return payload.startElement?.type === ElementType.HYPERLINK
|
return !payload.isReadonly && payload.startElement?.type === ElementType.HYPERLINK
|
||||||
},
|
},
|
||||||
callback: (command: Command) => {
|
callback: (command: Command) => {
|
||||||
command.executeDeleteHyperlink()
|
command.executeDeleteHyperlink()
|
||||||
@@ -15,7 +15,7 @@ export const hyperlinkMenus: IRegisterContextMenu[] = [
|
|||||||
{
|
{
|
||||||
i18nPath: 'contextmenu.hyperlink.cancel',
|
i18nPath: 'contextmenu.hyperlink.cancel',
|
||||||
when: (payload) => {
|
when: (payload) => {
|
||||||
return payload.startElement?.type === ElementType.HYPERLINK
|
return !payload.isReadonly && payload.startElement?.type === ElementType.HYPERLINK
|
||||||
},
|
},
|
||||||
callback: (command: Command) => {
|
callback: (command: Command) => {
|
||||||
command.executeCancelHyperlink()
|
command.executeCancelHyperlink()
|
||||||
@@ -24,7 +24,7 @@ export const hyperlinkMenus: IRegisterContextMenu[] = [
|
|||||||
{
|
{
|
||||||
i18nPath: 'contextmenu.hyperlink.edit',
|
i18nPath: 'contextmenu.hyperlink.edit',
|
||||||
when: (payload) => {
|
when: (payload) => {
|
||||||
return payload.startElement?.type === ElementType.HYPERLINK
|
return !payload.isReadonly && payload.startElement?.type === ElementType.HYPERLINK
|
||||||
},
|
},
|
||||||
callback: (command: Command, context: IContextMenuContext) => {
|
callback: (command: Command, context: IContextMenuContext) => {
|
||||||
const url = window.prompt('编辑链接', context.startElement?.url)
|
const url = window.prompt('编辑链接', context.startElement?.url)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export const imageMenus: IRegisterContextMenu[] = [
|
|||||||
i18nPath: 'contextmenu.image.change',
|
i18nPath: 'contextmenu.image.change',
|
||||||
icon: 'image-change',
|
icon: 'image-change',
|
||||||
when: (payload) => {
|
when: (payload) => {
|
||||||
return !payload.editorHasSelection && payload.startElement?.type === ElementType.IMAGE
|
return !payload.isReadonly && !payload.editorHasSelection && payload.startElement?.type === ElementType.IMAGE
|
||||||
},
|
},
|
||||||
callback: (command: Command) => {
|
callback: (command: Command) => {
|
||||||
// 创建代理元素
|
// 创建代理元素
|
||||||
@@ -41,7 +41,7 @@ export const imageMenus: IRegisterContextMenu[] = [
|
|||||||
{
|
{
|
||||||
i18nPath: 'contextmenu.image.textWrap',
|
i18nPath: 'contextmenu.image.textWrap',
|
||||||
when: (payload) => {
|
when: (payload) => {
|
||||||
return !payload.editorHasSelection && payload.startElement?.type === ElementType.IMAGE
|
return !payload.isReadonly && !payload.editorHasSelection && payload.startElement?.type === ElementType.IMAGE
|
||||||
},
|
},
|
||||||
childMenus: [
|
childMenus: [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user