feat(editor): 图片右键换精简专用菜单(docs/31)
用户要求去掉多余菜单。右键命中图片时只出:超链接…/调整图片 大小…/上传到 S3(未上传图才有)/剪切/复制/粘贴;加粗、斜体、 删除线、行内代码等文本格式项与全选、源码模式对图片没意义, 不再出现(文本右键菜单不变)。配套:右键图片先把它设为节点 选区,描边/手柄随之出现,剪切/复制/Delete 都作用在这张图上。 vitest 153+2、构建通过。
This commit is contained in:
@@ -52,6 +52,20 @@ describe('编辑区右键菜单', () => {
|
||||
remote.container.remove()
|
||||
})
|
||||
|
||||
it('命中图片时是精简专用菜单:无格式项/全选/源码模式,有超链接与调整大小', async () => {
|
||||
const { container, root, actions } = await renderMenu({ imageSrc: 'https://cdn.example.com/a.png', hasSelection: true })
|
||||
for (const t of ['加粗', '斜体', '删除线', '行内代码', '全选', '源码模式', '上传到 S3']) {
|
||||
expect(btn(container, t)).toBeUndefined()
|
||||
}
|
||||
for (const t of ['超链接…', '调整图片大小…', '剪切', '复制', '粘贴']) {
|
||||
expect(btn(container, t)).toBeTruthy()
|
||||
}
|
||||
await act(async () => { btn(container, '调整图片大小…')?.dispatchEvent(new MouseEvent('click', { bubbles: true })) })
|
||||
expect(actions).toEqual(['imageSize'])
|
||||
await act(async () => { root.unmount() })
|
||||
container.remove()
|
||||
})
|
||||
|
||||
it('源码模式只出编辑命令与「即时渲染」', async () => {
|
||||
const { container, root } = await renderMenu({ sourceMode: true, hasSelection: true })
|
||||
expect(btn(container, '加粗')).toBeUndefined()
|
||||
|
||||
Reference in New Issue
Block a user