refactor: single source of truths with editor interface (#10178)

* refactor device to editor interface and derive styles panel

* allow host app to control form factor and ui mode

* add editor interface event listener

* put new props inside UIOptions

* refactor: move related apis into one file

* expose getFormFactor

* privatize the setting of desktop mode and fix snapshots

* refactor and fix test

* remove unimplemented code

* export getFormFactor()

* replace `getFormFactor` with `getEditorInterface`

* remove dead & useless

* comment

* fix ts

---------

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
Ryan Di
2025-11-03 23:34:17 +01:00
committed by GitHub
co-authored by dwelle
parent 8fd970320e
commit 47cbb5b6fb
56 changed files with 914 additions and 908 deletions
@@ -985,7 +985,6 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -1181,7 +1180,6 @@ exports[`contextMenu element > selecting 'Add to library' in context menu adds e
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": {
@@ -1398,7 +1396,6 @@ exports[`contextMenu element > selecting 'Bring forward' in context menu brings
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -1732,7 +1729,6 @@ exports[`contextMenu element > selecting 'Bring to front' in context menu brings
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -2066,7 +2062,6 @@ exports[`contextMenu element > selecting 'Copy styles' in context menu copies st
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": {
@@ -2281,7 +2276,6 @@ exports[`contextMenu element > selecting 'Delete' in context menu deletes elemen
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -2527,7 +2521,6 @@ exports[`contextMenu element > selecting 'Duplicate' in context menu duplicates
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -2833,7 +2826,6 @@ exports[`contextMenu element > selecting 'Group selection' in context menu group
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -3203,7 +3195,6 @@ exports[`contextMenu element > selecting 'Paste styles' in context menu pastes s
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": {
@@ -3699,7 +3690,6 @@ exports[`contextMenu element > selecting 'Send backward' in context menu sends e
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -4025,7 +4015,6 @@ exports[`contextMenu element > selecting 'Send to back' in context menu sends el
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -4354,7 +4343,6 @@ exports[`contextMenu element > selecting 'Ungroup selection' in context menu ung
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -5642,7 +5630,6 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -6864,7 +6851,6 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -7798,7 +7784,6 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -8800,7 +8785,6 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -9797,7 +9781,6 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -104,7 +104,6 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -723,7 +722,6 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -1211,7 +1209,6 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -1578,7 +1575,6 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -1948,7 +1944,6 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -2213,7 +2208,6 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -2659,7 +2653,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -2965,7 +2958,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -3287,7 +3279,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -3584,7 +3575,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -3873,7 +3863,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -4111,7 +4100,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -4371,7 +4359,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -4645,7 +4632,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -4877,7 +4863,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -5109,7 +5094,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -5359,7 +5343,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -5618,7 +5601,6 @@ exports[`history > multiplayer undo/redo > conflicts in frames and their childre
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -5878,7 +5860,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -6210,7 +6191,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -6643,7 +6623,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -7026,7 +7005,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -7330,7 +7308,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -7649,7 +7626,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -7882,7 +7858,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -8237,7 +8212,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -8598,7 +8572,6 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -9001,7 +8974,6 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -9293,7 +9265,6 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -9560,7 +9531,6 @@ exports[`history > multiplayer undo/redo > should not override remote changes on
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -9828,7 +9798,6 @@ exports[`history > multiplayer undo/redo > should not override remote changes on
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -10064,7 +10033,6 @@ exports[`history > multiplayer undo/redo > should override remotely added groups
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -10363,7 +10331,6 @@ exports[`history > multiplayer undo/redo > should override remotely added points
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -10713,7 +10680,6 @@ exports[`history > multiplayer undo/redo > should redistribute deltas when eleme
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -10955,7 +10921,6 @@ exports[`history > multiplayer undo/redo > should redraw arrows on undo > [end o
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -11405,7 +11370,6 @@ exports[`history > multiplayer undo/redo > should update history entries after r
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -11666,7 +11630,6 @@ exports[`history > singleplayer undo/redo > remounting undo/redo buttons should
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -11906,7 +11869,6 @@ exports[`history > singleplayer undo/redo > should clear the redo stack on eleme
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -12144,7 +12106,6 @@ exports[`history > singleplayer undo/redo > should create entry when selecting f
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -12555,7 +12516,6 @@ exports[`history > singleplayer undo/redo > should create new history entry on e
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -12765,7 +12725,6 @@ exports[`history > singleplayer undo/redo > should create new history entry on e
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -12979,7 +12938,6 @@ exports[`history > singleplayer undo/redo > should create new history entry on i
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -13280,7 +13238,6 @@ exports[`history > singleplayer undo/redo > should create new history entry on i
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -13581,7 +13538,6 @@ exports[`history > singleplayer undo/redo > should create new history entry on s
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -13828,7 +13784,6 @@ exports[`history > singleplayer undo/redo > should disable undo/redo buttons whe
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -14068,7 +14023,6 @@ exports[`history > singleplayer undo/redo > should end up with no history entry
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -14308,7 +14262,6 @@ exports[`history > singleplayer undo/redo > should iterate through the history w
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -14558,7 +14511,6 @@ exports[`history > singleplayer undo/redo > should not clear the redo stack on s
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -14893,7 +14845,6 @@ exports[`history > singleplayer undo/redo > should not collapse when applying co
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -15068,7 +15019,6 @@ exports[`history > singleplayer undo/redo > should not end up with history entry
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -15353,7 +15303,6 @@ exports[`history > singleplayer undo/redo > should not end up with history entry
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -15619,7 +15568,6 @@ exports[`history > singleplayer undo/redo > should not modify anything on unrela
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -15776,7 +15724,6 @@ exports[`history > singleplayer undo/redo > should not override appstate changes
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -16060,7 +16007,6 @@ exports[`history > singleplayer undo/redo > should support appstate name or view
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -16226,7 +16172,6 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -16934,7 +16879,6 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -17572,7 +17516,6 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -18208,7 +18151,6 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -18933,7 +18875,6 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -19687,7 +19628,6 @@ exports[`history > singleplayer undo/redo > should support changes in elements'
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -20172,7 +20112,6 @@ exports[`history > singleplayer undo/redo > should support duplication of groups
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -20681,7 +20620,6 @@ exports[`history > singleplayer undo/redo > should support element creation, del
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -21145,7 +21083,6 @@ exports[`history > singleplayer undo/redo > should support linear element creati
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
@@ -112,14 +112,13 @@ exports[`given element A and group of elements B and given both are selected whe
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -543,14 +542,13 @@ exports[`given element A and group of elements B and given both are selected whe
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -953,14 +951,13 @@ exports[`regression tests > Cmd/Ctrl-click exclusively select element under poin
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -1522,14 +1519,13 @@ exports[`regression tests > Drags selected element when hitting only bounding bo
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -1737,14 +1733,13 @@ exports[`regression tests > adjusts z order when grouping > [end of test] appSta
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -2121,14 +2116,13 @@ exports[`regression tests > alt-drag duplicates an element > [end of test] appSt
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -2367,14 +2361,13 @@ exports[`regression tests > arrow keys > [end of test] appState 1`] = `
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -2552,14 +2545,13 @@ exports[`regression tests > can drag element that covers another element, while
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -2878,14 +2870,13 @@ exports[`regression tests > change the properties of a shape > [end of test] app
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -3138,14 +3129,13 @@ exports[`regression tests > click on an element and drag it > [dragged] appState
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -3382,14 +3372,13 @@ exports[`regression tests > click on an element and drag it > [end of test] appS
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -3621,14 +3610,13 @@ exports[`regression tests > click to select a shape > [end of test] appState 1`]
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -3883,14 +3871,13 @@ exports[`regression tests > click-drag to select a group > [end of test] appStat
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -4199,14 +4186,13 @@ exports[`regression tests > deleting last but one element in editing group shoul
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -4665,14 +4651,13 @@ exports[`regression tests > deselects group of selected elements on pointer down
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -4923,14 +4908,13 @@ exports[`regression tests > deselects group of selected elements on pointer up w
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -5229,14 +5213,13 @@ exports[`regression tests > deselects selected element on pointer down when poin
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -5412,14 +5395,13 @@ exports[`regression tests > deselects selected element, on pointer up, when clic
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -5615,14 +5597,13 @@ exports[`regression tests > double click to edit a group > [end of test] appStat
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -6015,14 +5996,13 @@ exports[`regression tests > drags selected elements from point inside common bou
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -6309,14 +6289,13 @@ exports[`regression tests > draw every type of shape > [end of test] appState 1`
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -7173,14 +7152,13 @@ exports[`regression tests > given a group of selected elements with an element t
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -7510,14 +7488,13 @@ exports[`regression tests > given a selected element A and a not selected elemen
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -7791,14 +7768,13 @@ exports[`regression tests > given selected element A with lower z-index than uns
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -8029,14 +8005,13 @@ exports[`regression tests > given selected element A with lower z-index than uns
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -8270,14 +8245,13 @@ exports[`regression tests > key 2 selects rectangle tool > [end of test] appStat
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -8453,14 +8427,13 @@ exports[`regression tests > key 3 selects diamond tool > [end of test] appState
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -8636,14 +8609,13 @@ exports[`regression tests > key 4 selects ellipse tool > [end of test] appState
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -8846,14 +8818,13 @@ exports[`regression tests > key 5 selects arrow tool > [end of test] appState 1`
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -9079,14 +9050,13 @@ exports[`regression tests > key 6 selects line tool > [end of test] appState 1`]
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -9281,14 +9251,13 @@ exports[`regression tests > key 7 selects freedraw tool > [end of test] appState
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -9509,14 +9478,13 @@ exports[`regression tests > key a selects arrow tool > [end of test] appState 1`
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -9715,14 +9683,13 @@ exports[`regression tests > key d selects diamond tool > [end of test] appState
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -9925,14 +9892,13 @@ exports[`regression tests > key l selects line tool > [end of test] appState 1`]
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -10129,14 +10095,13 @@ exports[`regression tests > key o selects ellipse tool > [end of test] appState
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -10310,14 +10275,13 @@ exports[`regression tests > key p selects freedraw tool > [end of test] appState
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -10511,14 +10475,13 @@ exports[`regression tests > key r selects rectangle tool > [end of test] appStat
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -10702,14 +10665,13 @@ exports[`regression tests > make a group and duplicate it > [end of test] appSta
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -11230,14 +11192,13 @@ exports[`regression tests > noop interaction after undo shouldn't create history
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -11509,14 +11470,13 @@ exports[`regression tests > pinch-to-zoom works > [end of test] appState 1`] = `
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -11637,14 +11597,13 @@ exports[`regression tests > shift click on selected element should deselect it o
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -11844,14 +11803,13 @@ exports[`regression tests > shift-click to multiselect, then drag > [end of test
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -12168,14 +12126,13 @@ exports[`regression tests > should group elements and ungroup them > [end of tes
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -12604,14 +12561,13 @@ exports[`regression tests > single-clicking on a subgroup of a selected group sh
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -13238,14 +13194,13 @@ exports[`regression tests > spacebar + drag scrolls the canvas > [end of test] a
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -13368,14 +13323,13 @@ exports[`regression tests > supports nested groups > [end of test] appState 1`]
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -14031,14 +13985,13 @@ exports[`regression tests > switches from group of selected elements to another
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -14372,14 +14325,13 @@ exports[`regression tests > switches selected element on pointer down > [end of
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -14607,14 +14559,13 @@ exports[`regression tests > two-finger scroll works > [end of test] appState 1`]
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -14735,14 +14686,13 @@ exports[`regression tests > undo/redo drawing an element > [end of test] appStat
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -15128,14 +15078,13 @@ exports[`regression tests > updates fontSize & fontFamily appState > [end of tes
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -15257,14 +15206,13 @@ exports[`regression tests > zoom hotkeys > [end of test] appState 1`] = `
"open": false,
"panels": 3,
},
"stylesPanelMode": "full",
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"width": 1024,
"width": 1440,
"zenModeEnabled": false,
"zoom": {
"value": 1,
@@ -1,7 +1,13 @@
import React from "react";
import { vi } from "vitest";
import { FONT_FAMILY, CODES, KEYS, reseed } from "@excalidraw/common";
import {
FONT_FAMILY,
CODES,
KEYS,
reseed,
MQ_MIN_WIDTH_DESKTOP,
} from "@excalidraw/common";
import { setDateTimeForTests } from "@excalidraw/common";
@@ -60,7 +66,7 @@ beforeEach(async () => {
finger2.reset();
await render(<Excalidraw handleKeyboardGlobally={true} />);
API.setAppState({ height: 768, width: 1024 });
API.setAppState({ height: 768, width: MQ_MIN_WIDTH_DESKTOP });
});
afterEach(() => {
+6 -10
View File
@@ -189,24 +189,20 @@ export const withExcalidrawDimensions = async (
dimensions: { width: number; height: number },
cb: () => void,
) => {
const { h } = window;
mockBoundingClientRect(dimensions);
act(() => {
// @ts-ignore
h.app.refreshViewportBreakpoints();
// @ts-ignore
h.app.refreshEditorBreakpoints();
window.h.app.refresh();
h.app.refreshEditorInterface();
h.app.refresh();
});
await cb();
restoreOriginalGetBoundingClientRect();
act(() => {
// @ts-ignore
h.app.refreshViewportBreakpoints();
// @ts-ignore
h.app.refreshEditorBreakpoints();
window.h.app.refresh();
h.app.refreshEditorInterface();
h.app.refresh();
});
};