New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Copy event and add/refactor tests #8777
Conversation
@sprocketc Should I QA anything besides copy on the search input? Unclear if whiteboard copy behavior is changing |
@logseq-cldwalker Yeah, copy/pasting shapes on whiteboards should now create a clone element instead of pasting a reference of the item. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sprocketc Works as described! 👍 🚢
} else { | ||
await page.keyboard.press('Control+c') | ||
} | ||
await page.keyboard.press(modKey + '+c') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactor. Makes tests easier to read
@@ -88,6 +88,63 @@ test('draw a rectangle', async ({ page }) => { | |||
).not.toHaveCount(0) | |||
}) | |||
|
|||
test('copy/paste url to create an iFrame shape', async ({ page }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great! 👍
While trying to change the copy/paste functionality as discussed on #8636, I realized that I can't handle this by modifying
usePaste.ts
. The root cause seems to be the fact that(js/document.execCommand "copy")
is firing twice onmod+c
.:misc/copy
always executes a document copy and then:editor/copy
callseditor-handler/shortcut-copy
, which also executes(js/document.execCommand "copy")
on certain conditions.As far as I understand,
mod+c
was introduced here 57d0436 to handle copying on the search panel on this PR #1191. If we remove this binding, usingmod+c
on the search input stops working. The changes on shortcut-copy were introduced on the same PR here e218ef7. I believe we can revert those changes, and just leteditor-handler/shortcut-copy
overwrite the clipboard when needed.mod+shift+c
worked as expected in #8636, because(js/document.execCommand "copy")
was called byshortcut-copy-text
only.Another cause of minor inconsistencies was calling
navigator.clipboard.write
directly, instead of usingutil/copy-to-clipboard!
that handles some scenarios gracefully.I added some copy/paste tests related to whiteboards. I also used
modKey
when possible to simplify some of our existing tests. Worth noting that there is no clipboard isolation between tests in playwright yet, so we may need to keep an eye on those tests. Also note that we cannot copy whiteboard shapes on CI, becauseClipboardItem
is not supported (see #5033).