From 1280f2a2ed04807ce174a2a0f1375dc8a8d8db18 Mon Sep 17 00:00:00 2001 From: yanmao <55792257+yanmao-cc@users.noreply.github.com> Date: Fri, 24 Dec 2021 10:47:29 +0800 Subject: [PATCH] fix: the cursor cannot be restored after paintformat is executed --- plugins/paintformat/src/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/paintformat/src/index.ts b/plugins/paintformat/src/index.ts index c1d8d0f8..a9c9d2fc 100644 --- a/plugins/paintformat/src/index.ts +++ b/plugins/paintformat/src/index.ts @@ -6,6 +6,8 @@ import { Plugin, RangeInterface, PluginOptions, + DATA_ELEMENT, + UI, } from '@aomao/engine'; import './index.css'; @@ -99,7 +101,9 @@ export default class extends Plugin { const removeCommand = this.options.removeCommand || 'removeformat'; // 选择范围为折叠状态,应用在整个段落,包括段落自己的样式 if (range.collapsed) { - const dummy = $(''); + let dummy = $( + ``, + ); range.insertNode(dummy[0]); const currentBlock = block.closest(range.startNode); range.select(currentBlock, true); @@ -114,6 +118,7 @@ export default class extends Plugin { this.paintBlocks(block, activeBlocks); }); } + dummy = currentBlock.find(`img[role="format-dummy"]`); range.select(dummy); range.collapse(true); dummy.remove();