editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

fix: can't replace text when paste command with multi selected blocks(#1705)

Open kaaaaaaaaaaai opened this issue 3 years ago • 5 comments

issue:(#1705)

I always use products. And I was stressed about this issue, so I tried a fix. And I'm here to discuss solutions.

Maybe a caret issue...? and it did not work without _deley

If you think you can figure out the cause, please let me know and I will fix it.

Tasks

  • Writing Tests
     _.delay(() => {
        document.execCommand(
          'insertHTML',
          false,
          clean(content.innerHTML, currentToolSanitizeConfig)
        );
      }, 20)();

kaaaaaaaaaaai avatar Mar 11 '22 05:03 kaaaaaaaaaaai

hello, anybody here?

hiepxanh avatar Apr 08 '22 05:04 hiepxanh

@kaaaaaaaaaaai, Thanks for creating the PR for the issue and sorry for the late response. Can you pls update the test case according to your pr so we can go for merge. I guess you just need to increase this time.

robonetphy avatar Apr 21 '22 03:04 robonetphy

@robonetphy @neSpecc thank you response.

i try! I'll do my best to contribute!

kaaaaaaaaaaai avatar May 09 '22 12:05 kaaaaaaaaaaai

@neSpecc about the promise we added into the caret.ts, if you check here Currently, there is a delay during the caret set process since we are trying to replace the entire or partial content of the editor we need to do the following steps:

  1. Remove all the selected blocks.
  2. add a new empty default block.
  3. set the caret to it (need a promise to wait for the caret to set).
  4. add all the clipboard contents

robonetphy avatar May 23 '22 10:05 robonetphy

That's right! That's what I wanted to say :)))))

kaaaaaaaaaaai avatar May 25 '22 15:05 kaaaaaaaaaaai

Lack of tests

neSpecc avatar Feb 18 '23 02:02 neSpecc