Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): global copy paste (#6856)
* feat(form): copy paste of document and fields prototype edx-1263 Signed-off-by: Fred Carlsen <[email protected]> * feat(core): add global copy paste provider Signed-off-by: Fred Carlsen <[email protected]> * refactor(dev): use new copy paste api in actions Signed-off-by: Fred Carlsen <[email protected]> * refactor(core): move value transfer to own function (tbc) * test(core): add value transfer test for global copy/paste * refactor: prepare for using clipboard insted of LS Signed-off-by: Fred Carlsen <[email protected]> * refactor(core): use clipboard when handling onCopy/onPaste Signed-off-by: Fred Carlsen <[email protected]> * feat(core): add resolveSchemaTypeForPath utility Signed-off-by: Fred Carlsen <[email protected]> * fix(core): pass onChange as props instead of importing from structure Signed-off-by: Fred Carlsen <[email protected]> * test(core): add missing _type to test Signed-off-by: Fred Carlsen <[email protected]> * feat(core): add support for copy/paste via ctrl-c/v Signed-off-by: Fred Carlsen <[email protected]> * refactor(test-studio): use new copy paste signature in doc actions Signed-off-by: Fred Carlsen <[email protected]> * feat(structure): add copy/paste actions into structure Signed-off-by: Fred Carlsen <[email protected]> * refactor(core): use new value transfer function for copy/paste + tests (#6878) * refactor(core): support multiple sources and targets for copy/paste * fix(core): change copy on copy/paste messaging This will use the correct field name in the copy confirmation message * fix(core): set new keys on object for copy/paste Create new _key (if exists) for transferred object value * feat(core): add focus handling to reference previews fixes edx-1450 Signed-off-by: Fred Carlsen <[email protected]> * feat(core): allow focus on objects Signed-off-by: Fred Carlsen <[email protected]> * fix(core): skip handling copy event on selections Signed-off-by: Fred Carlsen <[email protected]> * feat(core): highlight border on focused objects Signed-off-by: Fred Carlsen <[email protected]> * fix(form): remove focus terminator from cdr focuspath fixes edx-1510 Signed-off-by: Fred Carlsen <[email protected]> * feat(core): move copy paste field actions to core fixes edx-1512 fixes edx-1513 Signed-off-by: Fred Carlsen <[email protected]> * fix(core): fix imports in actions Signed-off-by: Fred Carlsen <[email protected]> * feat(core): add telemetry to copy paste hook fixes EDX-1508 Signed-off-by: Fred Carlsen <[email protected]> * fix(core): limit object focus to children incld in array modals Signed-off-by: Fred Carlsen <[email protected]> * test(form): add tests for copy pasting fields Signed-off-by: Fred Carlsen <[email protected]> * refactor(core): don't interfere with native editable elements + use clipboardItem (#6931) * fix(core): don't show paste field action on readonly fields * fix(core): copy paste string field must account for string lists * fix(core): don't iterate on target schemaType if sourceValue is empty * fix(core): quote copied fields in toast msg * fix(core): adjust for weak/hard refs when pasting ref. values * fix(core): fallback to text/plain clipboard item for Webkit * fix(core): add check for non-browser env in helper Signed-off-by: Fred Carlsen <[email protected]> * test(form): add e2e tests for copy paste Signed-off-by: Fred Carlsen <[email protected]> * feat(form): add test ids to field actions Signed-off-by: Fred Carlsen <[email protected]> * fix(form): remove blur handling from object Signed-off-by: Fred Carlsen <[email protected]> * fix(form): trigger keypress on object wrapper Signed-off-by: Fred Carlsen <[email protected]> * test(form): attempt to stabilise e2e tests for copy paste Signed-off-by: Fred Carlsen <[email protected]> * chore: upgrade playwright deps Signed-off-by: Fred Carlsen <[email protected]> Signed-off-by: Fred Carlsen <[email protected]> Signed-off-by: Fred Carlsen <[email protected]> * test(form): add component tests for copy paste Signed-off-by: Fred Carlsen <[email protected]> * fix(test): make sure fixure awaits setup Signed-off-by: Fred Carlsen <[email protected]> * fix(test): allow. copy pasting permissions in playwright-ct config Signed-off-by: Fred Carlsen <[email protected]> * test(form): stabilise copy paste e2e tests Signed-off-by: Fred Carlsen <[email protected]> * fix(test): fix clipboard.writeText mock Signed-off-by: Fred Carlsen <[email protected]> * refactor(test): remove e2e copypaste test in favour of component test Signed-off-by: Fred Carlsen <[email protected]> * fix(test): fix assertion texts Signed-off-by: Fred Carlsen <[email protected]> * refactor(form): align updated toast msg with the copy toast Signed-off-by: Fred Carlsen <[email protected]> * fix(test): await filling out string inputs Signed-off-by: Fred Carlsen <[email protected]> * chore(test): enable trace/video on retries in CI Signed-off-by: Fred Carlsen <[email protected]> * feat(playwright-ct): add debug fixture Signed-off-by: Fred Carlsen <[email protected]> * fix(test): more work to stabilise object tests Signed-off-by: Fred Carlsen <[email protected]> * fix(form): filter out epmty ref objects fixes edx-1532 Signed-off-by: Fred Carlsen <[email protected]> * fix(form): ignore copy event on text selection fixes edx-1534 Signed-off-by: Fred Carlsen <[email protected]> * refactor(form): move copy/paste into document field action fixes edx-1451 Signed-off-by: Fred Carlsen <[email protected]> * fix(form): prevent pasting image/file into the opposite type fixes edx-1531 Signed-off-by: Fred Carlsen <[email protected]> * fix(form): validate option.accept on paste fixes edx-1518 Signed-off-by: Fred Carlsen <[email protected]> * fix(form): fix styled import Signed-off-by: Fred Carlsen <[email protected]> * fix(core): added suite of tests + fixes for coercions fixes edx-1517 fixes edx-1525 Signed-off-by: Fred Carlsen <[email protected]> * feat(core): translate copy-paste * feat(core): translate MIME type copy-paste validation messages * test(core): update `valueTransfer` test * fix(core): copy-paste unknown copy error translation * fix(form): transform error path to string with path utils fixes edx-1543 Signed-off-by: Fred Carlsen <[email protected]> * fix(form): handle deeply nested paths in arrays Signed-off-by: Fred Carlsen <[email protected]> * test(form): add failing test for deeply nested arrays Signed-off-by: Fred Carlsen <[email protected]> * refactor(core): split out test schema Signed-off-by: Fred Carlsen <[email protected]> * test(core): add test for copying documents with booleans Signed-off-by: Fred Carlsen <[email protected]> * refactor(form): only copy and paste defined focus path fixes edx-1548 Signed-off-by: Fred Carlsen <[email protected]> * chore(form): rename valueTransfer -> transferValue Signed-off-by: Fred Carlsen <[email protected]> * fix(core): pass client options to remove notice Signed-off-by: Fred Carlsen <[email protected]> * refactor(core): make reference type and image mime checks for copy/paste recursive * test(core): update tests for copy/paste Client must be mocked for ref. type checks * test(core): validate schema before test runs Signed-off-by: Fred Carlsen <[email protected]> * fix(core): skip pasting on empty focus path Signed-off-by: Fred Carlsen <[email protected]> * refactor(core): only check read-only on root level schema also allow empty fixes edx-1556 fixes edx-1555 Signed-off-by: Fred Carlsen <[email protected]> * fix(core): fix type validation for primitive array target fixes edx-1554 Signed-off-by: Fred Carlsen <[email protected]> * fix(form): fix asset schema compatibility check on root Signed-off-by: Fred Carlsen <[email protected]> * fix(core): fix potential race condition when setting document meta touches edx-1553 Signed-off-by: Fred Carlsen <[email protected]> * fix(core): make a reference weak if _strengthenOnPublish is set fixes edx-1558 Signed-off-by: Fred Carlsen <[email protected]> * fix(core): retain relationship between marks and markDefs fixes edx-1555 Signed-off-by: Fred Carlsen <[email protected]> * feat(core): validate pasted reference against filter fixes edx-1560 Signed-off-by: Fred Carlsen <[email protected]> * refactor(core): clean up document pane event handler Signed-off-by: Fred Carlsen <[email protected]> * refactor(form): add subtle transition on object focus Signed-off-by: Fred Carlsen <[email protected]> * refactor(core): serialize clipboard into HTML for safari and firefox * refactor(core): rename and simplify `CopyActionResult` to `SanityClipboardItem` * refactor(core): remove unused `copyResult` * refactor(core): lift onCopy and onPaste into Provider * refactor(core): remove unexpected cases * fix(core): update tests * fix: add missing return * test: skip copy/paste tests for now * refactor: remove unused interface * test: update field to prevent collisions * test: update component test timeouts --------- Signed-off-by: Fred Carlsen <[email protected]> Co-authored-by: Per-Kristian Nordnes <[email protected]> Co-authored-by: Herman Wikner <[email protected]> Co-authored-by: Rico Kahler <[email protected]>
- Loading branch information