@wordpress/editor 13.13.0 → 13.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/components/entities-saved-states/entity-record-item.js +3 -37
- package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build/components/entities-saved-states/entity-type-list.js +2 -4
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/entities-saved-states/index.js +0 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/{save-shortcut.js → index.js} +13 -25
- package/build/components/global-keyboard-shortcuts/index.js.map +1 -0
- package/build/components/index.js +32 -19
- package/build/components/index.js.map +1 -1
- package/build/components/media-categories/index.js +1 -22
- package/build/components/media-categories/index.js.map +1 -1
- package/build/components/post-preview-button/index.js +62 -157
- package/build/components/post-preview-button/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +4 -9
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-button/label.js +2 -4
- package/build/components/post-publish-button/label.js.map +1 -1
- package/build/components/post-publish-panel/index.js +3 -4
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-saved-state/index.js +2 -5
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/label.js +4 -4
- package/build/components/post-schedule/label.js.map +1 -1
- package/build/components/post-switch-to-draft-button/index.js +3 -5
- package/build/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build/components/post-sync-status/index.js +82 -22
- package/build/components/post-sync-status/index.js.map +1 -1
- package/build/components/post-text-editor/index.js +51 -58
- package/build/components/post-text-editor/index.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +1 -1
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/store/actions.js +37 -3
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +53 -61
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js +6 -40
- package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js +2 -4
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +0 -1
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/{save-shortcut.js → index.js} +12 -23
- package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -0
- package/build-module/components/index.js +9 -4
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/media-categories/index.js +1 -22
- package/build-module/components/media-categories/index.js.map +1 -1
- package/build-module/components/post-preview-button/index.js +63 -149
- package/build-module/components/post-preview-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +4 -9
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/label.js +2 -4
- package/build-module/components/post-publish-button/label.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +3 -4
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +2 -5
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/label.js +4 -4
- package/build-module/components/post-schedule/label.js.map +1 -1
- package/build-module/components/post-switch-to-draft-button/index.js +5 -7
- package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build-module/components/post-sync-status/index.js +81 -24
- package/build-module/components/post-sync-status/index.js.map +1 -1
- package/build-module/components/post-text-editor/index.js +48 -56
- package/build-module/components/post-text-editor/index.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +1 -1
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/store/actions.js +31 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +46 -55
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +4 -22
- package/build-style/style.css +4 -22
- package/package.json +30 -30
- package/src/components/entities-saved-states/entity-record-item.js +3 -61
- package/src/components/entities-saved-states/entity-type-list.js +0 -2
- package/src/components/entities-saved-states/index.js +0 -1
- package/src/components/entities-saved-states/style.scss +0 -15
- package/src/components/global-keyboard-shortcuts/index.js +49 -0
- package/src/components/index.js +12 -3
- package/src/components/media-categories/index.js +1 -21
- package/src/components/post-preview-button/index.js +73 -156
- package/src/components/post-preview-button/test/index.js +94 -158
- package/src/components/post-publish-button/index.js +2 -7
- package/src/components/post-publish-button/label.js +2 -2
- package/src/components/post-publish-button/test/index.js +0 -10
- package/src/components/post-publish-panel/index.js +3 -4
- package/src/components/post-saved-state/index.js +2 -5
- package/src/components/post-schedule/label.js +4 -4
- package/src/components/post-switch-to-draft-button/index.js +3 -4
- package/src/components/post-sync-status/index.js +100 -27
- package/src/components/post-sync-status/style.scss +2 -2
- package/src/components/post-text-editor/index.js +34 -57
- package/src/components/post-title/style.native.scss +5 -5
- package/src/components/post-trash/style.scss +2 -2
- package/src/components/provider/use-block-editor-settings.js +1 -0
- package/src/store/actions.js +34 -2
- package/src/store/selectors.js +45 -41
- package/src/store/test/selectors.js +36 -25
- package/build/components/global-keyboard-shortcuts/save-shortcut.js.map +0 -1
- package/build/components/global-keyboard-shortcuts/text-editor-shortcuts.js +0 -22
- package/build/components/global-keyboard-shortcuts/text-editor-shortcuts.js.map +0 -1
- package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -45
- package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +0 -1
- package/build-module/components/global-keyboard-shortcuts/save-shortcut.js.map +0 -1
- package/build-module/components/global-keyboard-shortcuts/text-editor-shortcuts.js +0 -12
- package/build-module/components/global-keyboard-shortcuts/text-editor-shortcuts.js.map +0 -1
- package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -32
- package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +0 -1
- package/src/components/global-keyboard-shortcuts/save-shortcut.js +0 -55
- package/src/components/global-keyboard-shortcuts/text-editor-shortcuts.js +0 -8
- package/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -29
- package/src/components/post-text-editor/test/index.js +0 -156
|
@@ -75,10 +75,6 @@ selectorNames.forEach( ( name ) => {
|
|
|
75
75
|
};
|
|
76
76
|
},
|
|
77
77
|
|
|
78
|
-
isSavingEntityRecord() {
|
|
79
|
-
return state.saving && state.saving.requesting;
|
|
80
|
-
},
|
|
81
|
-
|
|
82
78
|
getLastEntitySaveError() {
|
|
83
79
|
const saving = state.saving;
|
|
84
80
|
const successful = saving && saving.successful;
|
|
@@ -1254,7 +1250,7 @@ describe( 'selectors', () => {
|
|
|
1254
1250
|
title: 'sassel',
|
|
1255
1251
|
},
|
|
1256
1252
|
saving: {
|
|
1257
|
-
|
|
1253
|
+
pending: true,
|
|
1258
1254
|
},
|
|
1259
1255
|
};
|
|
1260
1256
|
|
|
@@ -1320,7 +1316,9 @@ describe( 'selectors', () => {
|
|
|
1320
1316
|
},
|
|
1321
1317
|
],
|
|
1322
1318
|
},
|
|
1323
|
-
edits: {
|
|
1319
|
+
edits: {
|
|
1320
|
+
content: () => {},
|
|
1321
|
+
},
|
|
1324
1322
|
},
|
|
1325
1323
|
},
|
|
1326
1324
|
initialEdits: {},
|
|
@@ -1403,9 +1401,8 @@ describe( 'selectors', () => {
|
|
|
1403
1401
|
currentPost: {
|
|
1404
1402
|
title: 'sassel',
|
|
1405
1403
|
},
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
},
|
|
1404
|
+
postAutosavingLock: {},
|
|
1405
|
+
saving: {},
|
|
1409
1406
|
getCurrentUser() {},
|
|
1410
1407
|
hasFetchedAutosaves() {
|
|
1411
1408
|
return false;
|
|
@@ -1434,9 +1431,8 @@ describe( 'selectors', () => {
|
|
|
1434
1431
|
currentPost: {
|
|
1435
1432
|
title: 'sassel',
|
|
1436
1433
|
},
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
},
|
|
1434
|
+
postAutosavingLock: {},
|
|
1435
|
+
saving: {},
|
|
1440
1436
|
getCurrentUser() {},
|
|
1441
1437
|
hasFetchedAutosaves() {
|
|
1442
1438
|
return true;
|
|
@@ -1597,14 +1593,13 @@ describe( 'selectors', () => {
|
|
|
1597
1593
|
const state = {
|
|
1598
1594
|
editor: {
|
|
1599
1595
|
present: {
|
|
1600
|
-
blocks: {
|
|
1601
|
-
value: [],
|
|
1602
|
-
},
|
|
1603
1596
|
edits: {},
|
|
1604
1597
|
},
|
|
1605
1598
|
},
|
|
1606
1599
|
initialEdits: {},
|
|
1607
|
-
currentPost: {
|
|
1600
|
+
currentPost: {
|
|
1601
|
+
content: '',
|
|
1602
|
+
},
|
|
1608
1603
|
};
|
|
1609
1604
|
|
|
1610
1605
|
expect( isEditedPostEmpty( state ) ).toBe( true );
|
|
@@ -1626,7 +1621,9 @@ describe( 'selectors', () => {
|
|
|
1626
1621
|
},
|
|
1627
1622
|
],
|
|
1628
1623
|
},
|
|
1629
|
-
edits: {
|
|
1624
|
+
edits: {
|
|
1625
|
+
content: () => {},
|
|
1626
|
+
},
|
|
1630
1627
|
},
|
|
1631
1628
|
},
|
|
1632
1629
|
initialEdits: {},
|
|
@@ -1656,7 +1653,9 @@ describe( 'selectors', () => {
|
|
|
1656
1653
|
},
|
|
1657
1654
|
],
|
|
1658
1655
|
},
|
|
1659
|
-
edits: {
|
|
1656
|
+
edits: {
|
|
1657
|
+
content: () => {},
|
|
1658
|
+
},
|
|
1660
1659
|
},
|
|
1661
1660
|
},
|
|
1662
1661
|
initialEdits: {},
|
|
@@ -1666,7 +1665,7 @@ describe( 'selectors', () => {
|
|
|
1666
1665
|
expect( isEditedPostEmpty( state ) ).toBe( true );
|
|
1667
1666
|
} );
|
|
1668
1667
|
|
|
1669
|
-
it( 'should return
|
|
1668
|
+
it( 'should return true if blocks, but empty content edit', () => {
|
|
1670
1669
|
const state = {
|
|
1671
1670
|
editor: {
|
|
1672
1671
|
present: {
|
|
@@ -1693,7 +1692,7 @@ describe( 'selectors', () => {
|
|
|
1693
1692
|
},
|
|
1694
1693
|
};
|
|
1695
1694
|
|
|
1696
|
-
expect( isEditedPostEmpty( state ) ).toBe(
|
|
1695
|
+
expect( isEditedPostEmpty( state ) ).toBe( true );
|
|
1697
1696
|
} );
|
|
1698
1697
|
|
|
1699
1698
|
it( 'should return true if the post has an empty content property', () => {
|
|
@@ -1715,7 +1714,7 @@ describe( 'selectors', () => {
|
|
|
1715
1714
|
expect( isEditedPostEmpty( state ) ).toBe( true );
|
|
1716
1715
|
} );
|
|
1717
1716
|
|
|
1718
|
-
it( 'should return
|
|
1717
|
+
it( 'should return false if edits include a non-empty content property', () => {
|
|
1719
1718
|
const state = {
|
|
1720
1719
|
editor: {
|
|
1721
1720
|
present: {
|
|
@@ -1731,7 +1730,7 @@ describe( 'selectors', () => {
|
|
|
1731
1730
|
currentPost: {},
|
|
1732
1731
|
};
|
|
1733
1732
|
|
|
1734
|
-
expect( isEditedPostEmpty( state ) ).toBe(
|
|
1733
|
+
expect( isEditedPostEmpty( state ) ).toBe( false );
|
|
1735
1734
|
} );
|
|
1736
1735
|
|
|
1737
1736
|
it( 'should return true if empty classic block', () => {
|
|
@@ -1750,7 +1749,9 @@ describe( 'selectors', () => {
|
|
|
1750
1749
|
},
|
|
1751
1750
|
],
|
|
1752
1751
|
},
|
|
1753
|
-
edits: {
|
|
1752
|
+
edits: {
|
|
1753
|
+
content: () => {},
|
|
1754
|
+
},
|
|
1754
1755
|
},
|
|
1755
1756
|
},
|
|
1756
1757
|
initialEdits: {},
|
|
@@ -2017,7 +2018,7 @@ describe( 'selectors', () => {
|
|
|
2017
2018
|
it( 'should return true if the post is currently being saved', () => {
|
|
2018
2019
|
const state = {
|
|
2019
2020
|
saving: {
|
|
2020
|
-
|
|
2021
|
+
pending: true,
|
|
2021
2022
|
},
|
|
2022
2023
|
};
|
|
2023
2024
|
|
|
@@ -2027,7 +2028,7 @@ describe( 'selectors', () => {
|
|
|
2027
2028
|
it( 'should return false if the post is not currently being saved', () => {
|
|
2028
2029
|
const state = {
|
|
2029
2030
|
saving: {
|
|
2030
|
-
|
|
2031
|
+
pending: false,
|
|
2031
2032
|
},
|
|
2032
2033
|
};
|
|
2033
2034
|
|
|
@@ -2156,6 +2157,7 @@ describe( 'selectors', () => {
|
|
|
2156
2157
|
attributes: {
|
|
2157
2158
|
providerNameSlug: 'instagram',
|
|
2158
2159
|
},
|
|
2160
|
+
innerBlocks: [],
|
|
2159
2161
|
},
|
|
2160
2162
|
],
|
|
2161
2163
|
},
|
|
@@ -2178,6 +2180,7 @@ describe( 'selectors', () => {
|
|
|
2178
2180
|
clientId: 567,
|
|
2179
2181
|
name: 'core/embed',
|
|
2180
2182
|
attributes: {},
|
|
2183
|
+
innerBlocks: [],
|
|
2181
2184
|
},
|
|
2182
2185
|
],
|
|
2183
2186
|
},
|
|
@@ -2200,11 +2203,13 @@ describe( 'selectors', () => {
|
|
|
2200
2203
|
clientId: 123,
|
|
2201
2204
|
name: 'core/image',
|
|
2202
2205
|
attributes: {},
|
|
2206
|
+
innerBlocks: [],
|
|
2203
2207
|
},
|
|
2204
2208
|
{
|
|
2205
2209
|
clientId: 456,
|
|
2206
2210
|
name: 'core/quote',
|
|
2207
2211
|
attributes: {},
|
|
2212
|
+
innerBlocks: [],
|
|
2208
2213
|
},
|
|
2209
2214
|
],
|
|
2210
2215
|
},
|
|
@@ -2228,6 +2233,7 @@ describe( 'selectors', () => {
|
|
|
2228
2233
|
clientId: 123,
|
|
2229
2234
|
name: 'core/image',
|
|
2230
2235
|
attributes: {},
|
|
2236
|
+
innerBlocks: [],
|
|
2231
2237
|
},
|
|
2232
2238
|
],
|
|
2233
2239
|
},
|
|
@@ -2251,6 +2257,7 @@ describe( 'selectors', () => {
|
|
|
2251
2257
|
clientId: 456,
|
|
2252
2258
|
name: 'core/quote',
|
|
2253
2259
|
attributes: {},
|
|
2260
|
+
innerBlocks: [],
|
|
2254
2261
|
},
|
|
2255
2262
|
],
|
|
2256
2263
|
},
|
|
@@ -2276,6 +2283,7 @@ describe( 'selectors', () => {
|
|
|
2276
2283
|
attributes: {
|
|
2277
2284
|
providerNameSlug: 'youtube',
|
|
2278
2285
|
},
|
|
2286
|
+
innerBlocks: [],
|
|
2279
2287
|
},
|
|
2280
2288
|
],
|
|
2281
2289
|
},
|
|
@@ -2301,6 +2309,7 @@ describe( 'selectors', () => {
|
|
|
2301
2309
|
attributes: {
|
|
2302
2310
|
providerNameSlug: 'soundcloud',
|
|
2303
2311
|
},
|
|
2312
|
+
innerBlocks: [],
|
|
2304
2313
|
},
|
|
2305
2314
|
],
|
|
2306
2315
|
},
|
|
@@ -2324,11 +2333,13 @@ describe( 'selectors', () => {
|
|
|
2324
2333
|
clientId: 456,
|
|
2325
2334
|
name: 'core/quote',
|
|
2326
2335
|
attributes: {},
|
|
2336
|
+
innerBlocks: [],
|
|
2327
2337
|
},
|
|
2328
2338
|
{
|
|
2329
2339
|
clientId: 789,
|
|
2330
2340
|
name: 'core/paragraph',
|
|
2331
2341
|
attributes: {},
|
|
2342
|
+
innerBlocks: [],
|
|
2332
2343
|
},
|
|
2333
2344
|
],
|
|
2334
2345
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/save-shortcut.js"],"names":["SaveShortcut","resetBlocksOnSave","resetEditorBlocks","savePost","editorStore","isEditedPostDirty","getPostEdits","isPostSavingLocked","event","preventDefault","postEdits","content","blocks"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGA,SAASA,YAAT,CAAuB;AAAEC,EAAAA;AAAF,CAAvB,EAA+C;AAC9C,QAAM;AAAEC,IAAAA,iBAAF;AAAqBC,IAAAA;AAArB,MAAkC,uBAAaC,YAAb,CAAxC;AACA,QAAM;AAAEC,IAAAA,iBAAF;AAAqBC,IAAAA,YAArB;AAAmCC,IAAAA;AAAnC,MACL,qBAAWH,YAAX,CADD;AAGA,sCAAa,kBAAb,EAAmCI,KAAF,IAAa;AAC7CA,IAAAA,KAAK,CAACC,cAAN;AAEA;AACF;AACA;;AACE,QAAKF,kBAAkB,EAAvB,EAA4B;AAC3B;AACA,KAR4C,CAU7C;AACA;AACA;AACA;AACA;;;AACA,QAAK,CAAEF,iBAAiB,EAAxB,EAA6B;AAC5B;AACA,KAjB4C,CAmB7C;AACA;AACA;AACA;;;AACA,QAAKJ,iBAAL,EAAyB;AACxB,YAAMS,SAAS,GAAGJ,YAAY,EAA9B;;AACA,UAAKI,SAAS,CAACC,OAAV,IAAqB,OAAOD,SAAS,CAACC,OAAjB,KAA6B,QAAvD,EAAkE;AACjE,cAAMC,MAAM,GAAG,mBAAOF,SAAS,CAACC,OAAjB,CAAf;AACAT,QAAAA,iBAAiB,CAAEU,MAAF,CAAjB;AACA;AACD;;AAEDT,IAAAA,QAAQ;AACR,GAhCD;AAkCA,SAAO,IAAP;AACA;;eAEcH,Y","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction SaveShortcut( { resetBlocksOnSave } ) {\n\tconst { resetEditorBlocks, savePost } = useDispatch( editorStore );\n\tconst { isEditedPostDirty, getPostEdits, isPostSavingLocked } =\n\t\tuseSelect( editorStore );\n\n\tuseShortcut( 'core/editor/save', ( event ) => {\n\t\tevent.preventDefault();\n\n\t\t/**\n\t\t * Do not save the post if post saving is locked.\n\t\t */\n\t\tif ( isPostSavingLocked() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// TODO: This should be handled in the `savePost` effect in\n\t\t// considering `isSaveable`. See note on `isEditedPostSaveable`\n\t\t// selector about dirtiness and meta-boxes.\n\t\t//\n\t\t// See: `isEditedPostSaveable`\n\t\tif ( ! isEditedPostDirty() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// The text editor requires that editor blocks are updated for a\n\t\t// save to work correctly. Usually this happens when the textarea\n\t\t// for the code editors blurs, but the shortcut can be used without\n\t\t// blurring the textarea.\n\t\tif ( resetBlocksOnSave ) {\n\t\t\tconst postEdits = getPostEdits();\n\t\t\tif ( postEdits.content && typeof postEdits.content === 'string' ) {\n\t\t\t\tconst blocks = parse( postEdits.content );\n\t\t\t\tresetEditorBlocks( blocks );\n\t\t\t}\n\t\t}\n\n\t\tsavePost();\n\t} );\n\n\treturn null;\n}\n\nexport default SaveShortcut;\n"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = TextEditorGlobalKeyboardShortcuts;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _saveShortcut = _interopRequireDefault(require("./save-shortcut"));
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Internal dependencies
|
|
16
|
-
*/
|
|
17
|
-
function TextEditorGlobalKeyboardShortcuts() {
|
|
18
|
-
return (0, _element.createElement)(_saveShortcut.default, {
|
|
19
|
-
resetBlocksOnSave: true
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=text-editor-shortcuts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/text-editor-shortcuts.js"],"names":["TextEditorGlobalKeyboardShortcuts"],"mappings":";;;;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGe,SAASA,iCAAT,GAA6C;AAC3D,SAAO,4BAAC,qBAAD;AAAc,IAAA,iBAAiB;AAA/B,IAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport SaveShortcut from './save-shortcut';\n\nexport default function TextEditorGlobalKeyboardShortcuts() {\n\treturn <SaveShortcut resetBlocksOnSave />;\n}\n"]}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
13
|
-
|
|
14
|
-
var _data = require("@wordpress/data");
|
|
15
|
-
|
|
16
|
-
var _saveShortcut = _interopRequireDefault(require("./save-shortcut"));
|
|
17
|
-
|
|
18
|
-
var _store = require("../../store");
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* WordPress dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Internal dependencies
|
|
26
|
-
*/
|
|
27
|
-
function VisualEditorGlobalKeyboardShortcuts() {
|
|
28
|
-
const {
|
|
29
|
-
redo,
|
|
30
|
-
undo
|
|
31
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
32
|
-
(0, _keyboardShortcuts.useShortcut)('core/editor/undo', event => {
|
|
33
|
-
undo();
|
|
34
|
-
event.preventDefault();
|
|
35
|
-
});
|
|
36
|
-
(0, _keyboardShortcuts.useShortcut)('core/editor/redo', event => {
|
|
37
|
-
redo();
|
|
38
|
-
event.preventDefault();
|
|
39
|
-
});
|
|
40
|
-
return (0, _element.createElement)(_saveShortcut.default, null);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
var _default = VisualEditorGlobalKeyboardShortcuts;
|
|
44
|
-
exports.default = _default;
|
|
45
|
-
//# sourceMappingURL=visual-editor-shortcuts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js"],"names":["VisualEditorGlobalKeyboardShortcuts","redo","undo","editorStore","event","preventDefault"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIA,SAASA,mCAAT,GAA+C;AAC9C,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAiB,uBAAaC,YAAb,CAAvB;AAEA,sCAAa,kBAAb,EAAmCC,KAAF,IAAa;AAC7CF,IAAAA,IAAI;AACJE,IAAAA,KAAK,CAACC,cAAN;AACA,GAHD;AAKA,sCAAa,kBAAb,EAAmCD,KAAF,IAAa;AAC7CH,IAAAA,IAAI;AACJG,IAAAA,KAAK,CAACC,cAAN;AACA,GAHD;AAKA,SAAO,4BAAC,qBAAD,OAAP;AACA;;eAEcL,mC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport SaveShortcut from './save-shortcut';\nimport { store as editorStore } from '../../store';\n\nfunction VisualEditorGlobalKeyboardShortcuts() {\n\tconst { redo, undo } = useDispatch( editorStore );\n\n\tuseShortcut( 'core/editor/undo', ( event ) => {\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/editor/redo', ( event ) => {\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\treturn <SaveShortcut />;\n}\n\nexport default VisualEditorGlobalKeyboardShortcuts;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/save-shortcut.js"],"names":["useShortcut","useDispatch","useSelect","parse","store","editorStore","SaveShortcut","resetBlocksOnSave","resetEditorBlocks","savePost","isEditedPostDirty","getPostEdits","isPostSavingLocked","event","preventDefault","postEdits","content","blocks"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,+BAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,KAAT,QAAsB,mBAAtB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;;AAEA,SAASC,YAAT,CAAuB;AAAEC,EAAAA;AAAF,CAAvB,EAA+C;AAC9C,QAAM;AAAEC,IAAAA,iBAAF;AAAqBC,IAAAA;AAArB,MAAkCR,WAAW,CAAEI,WAAF,CAAnD;AACA,QAAM;AAAEK,IAAAA,iBAAF;AAAqBC,IAAAA,YAArB;AAAmCC,IAAAA;AAAnC,MACLV,SAAS,CAAEG,WAAF,CADV;AAGAL,EAAAA,WAAW,CAAE,kBAAF,EAAwBa,KAAF,IAAa;AAC7CA,IAAAA,KAAK,CAACC,cAAN;AAEA;AACF;AACA;;AACE,QAAKF,kBAAkB,EAAvB,EAA4B;AAC3B;AACA,KAR4C,CAU7C;AACA;AACA;AACA;AACA;;;AACA,QAAK,CAAEF,iBAAiB,EAAxB,EAA6B;AAC5B;AACA,KAjB4C,CAmB7C;AACA;AACA;AACA;;;AACA,QAAKH,iBAAL,EAAyB;AACxB,YAAMQ,SAAS,GAAGJ,YAAY,EAA9B;;AACA,UAAKI,SAAS,CAACC,OAAV,IAAqB,OAAOD,SAAS,CAACC,OAAjB,KAA6B,QAAvD,EAAkE;AACjE,cAAMC,MAAM,GAAGd,KAAK,CAAEY,SAAS,CAACC,OAAZ,CAApB;AACAR,QAAAA,iBAAiB,CAAES,MAAF,CAAjB;AACA;AACD;;AAEDR,IAAAA,QAAQ;AACR,GAhCU,CAAX;AAkCA,SAAO,IAAP;AACA;;AAED,eAAeH,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction SaveShortcut( { resetBlocksOnSave } ) {\n\tconst { resetEditorBlocks, savePost } = useDispatch( editorStore );\n\tconst { isEditedPostDirty, getPostEdits, isPostSavingLocked } =\n\t\tuseSelect( editorStore );\n\n\tuseShortcut( 'core/editor/save', ( event ) => {\n\t\tevent.preventDefault();\n\n\t\t/**\n\t\t * Do not save the post if post saving is locked.\n\t\t */\n\t\tif ( isPostSavingLocked() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// TODO: This should be handled in the `savePost` effect in\n\t\t// considering `isSaveable`. See note on `isEditedPostSaveable`\n\t\t// selector about dirtiness and meta-boxes.\n\t\t//\n\t\t// See: `isEditedPostSaveable`\n\t\tif ( ! isEditedPostDirty() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// The text editor requires that editor blocks are updated for a\n\t\t// save to work correctly. Usually this happens when the textarea\n\t\t// for the code editors blurs, but the shortcut can be used without\n\t\t// blurring the textarea.\n\t\tif ( resetBlocksOnSave ) {\n\t\t\tconst postEdits = getPostEdits();\n\t\t\tif ( postEdits.content && typeof postEdits.content === 'string' ) {\n\t\t\t\tconst blocks = parse( postEdits.content );\n\t\t\t\tresetEditorBlocks( blocks );\n\t\t\t}\n\t\t}\n\n\t\tsavePost();\n\t} );\n\n\treturn null;\n}\n\nexport default SaveShortcut;\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Internal dependencies
|
|
5
|
-
*/
|
|
6
|
-
import SaveShortcut from './save-shortcut';
|
|
7
|
-
export default function TextEditorGlobalKeyboardShortcuts() {
|
|
8
|
-
return createElement(SaveShortcut, {
|
|
9
|
-
resetBlocksOnSave: true
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=text-editor-shortcuts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/text-editor-shortcuts.js"],"names":["SaveShortcut","TextEditorGlobalKeyboardShortcuts"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,YAAP,MAAyB,iBAAzB;AAEA,eAAe,SAASC,iCAAT,GAA6C;AAC3D,SAAO,cAAC,YAAD;AAAc,IAAA,iBAAiB;AAA/B,IAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport SaveShortcut from './save-shortcut';\n\nexport default function TextEditorGlobalKeyboardShortcuts() {\n\treturn <SaveShortcut resetBlocksOnSave />;\n}\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
7
|
-
import { useDispatch } from '@wordpress/data';
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import SaveShortcut from './save-shortcut';
|
|
13
|
-
import { store as editorStore } from '../../store';
|
|
14
|
-
|
|
15
|
-
function VisualEditorGlobalKeyboardShortcuts() {
|
|
16
|
-
const {
|
|
17
|
-
redo,
|
|
18
|
-
undo
|
|
19
|
-
} = useDispatch(editorStore);
|
|
20
|
-
useShortcut('core/editor/undo', event => {
|
|
21
|
-
undo();
|
|
22
|
-
event.preventDefault();
|
|
23
|
-
});
|
|
24
|
-
useShortcut('core/editor/redo', event => {
|
|
25
|
-
redo();
|
|
26
|
-
event.preventDefault();
|
|
27
|
-
});
|
|
28
|
-
return createElement(SaveShortcut, null);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default VisualEditorGlobalKeyboardShortcuts;
|
|
32
|
-
//# sourceMappingURL=visual-editor-shortcuts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js"],"names":["useShortcut","useDispatch","SaveShortcut","store","editorStore","VisualEditorGlobalKeyboardShortcuts","redo","undo","event","preventDefault"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,+BAA5B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;;AAEA,SAASC,mCAAT,GAA+C;AAC9C,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAiBN,WAAW,CAAEG,WAAF,CAAlC;AAEAJ,EAAAA,WAAW,CAAE,kBAAF,EAAwBQ,KAAF,IAAa;AAC7CD,IAAAA,IAAI;AACJC,IAAAA,KAAK,CAACC,cAAN;AACA,GAHU,CAAX;AAKAT,EAAAA,WAAW,CAAE,kBAAF,EAAwBQ,KAAF,IAAa;AAC7CF,IAAAA,IAAI;AACJE,IAAAA,KAAK,CAACC,cAAN;AACA,GAHU,CAAX;AAKA,SAAO,cAAC,YAAD,OAAP;AACA;;AAED,eAAeJ,mCAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport SaveShortcut from './save-shortcut';\nimport { store as editorStore } from '../../store';\n\nfunction VisualEditorGlobalKeyboardShortcuts() {\n\tconst { redo, undo } = useDispatch( editorStore );\n\n\tuseShortcut( 'core/editor/undo', ( event ) => {\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/editor/redo', ( event ) => {\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\treturn <SaveShortcut />;\n}\n\nexport default VisualEditorGlobalKeyboardShortcuts;\n"]}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
5
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
-
import { parse } from '@wordpress/blocks';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import { store as editorStore } from '../../store';
|
|
12
|
-
|
|
13
|
-
function SaveShortcut( { resetBlocksOnSave } ) {
|
|
14
|
-
const { resetEditorBlocks, savePost } = useDispatch( editorStore );
|
|
15
|
-
const { isEditedPostDirty, getPostEdits, isPostSavingLocked } =
|
|
16
|
-
useSelect( editorStore );
|
|
17
|
-
|
|
18
|
-
useShortcut( 'core/editor/save', ( event ) => {
|
|
19
|
-
event.preventDefault();
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Do not save the post if post saving is locked.
|
|
23
|
-
*/
|
|
24
|
-
if ( isPostSavingLocked() ) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// TODO: This should be handled in the `savePost` effect in
|
|
29
|
-
// considering `isSaveable`. See note on `isEditedPostSaveable`
|
|
30
|
-
// selector about dirtiness and meta-boxes.
|
|
31
|
-
//
|
|
32
|
-
// See: `isEditedPostSaveable`
|
|
33
|
-
if ( ! isEditedPostDirty() ) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// The text editor requires that editor blocks are updated for a
|
|
38
|
-
// save to work correctly. Usually this happens when the textarea
|
|
39
|
-
// for the code editors blurs, but the shortcut can be used without
|
|
40
|
-
// blurring the textarea.
|
|
41
|
-
if ( resetBlocksOnSave ) {
|
|
42
|
-
const postEdits = getPostEdits();
|
|
43
|
-
if ( postEdits.content && typeof postEdits.content === 'string' ) {
|
|
44
|
-
const blocks = parse( postEdits.content );
|
|
45
|
-
resetEditorBlocks( blocks );
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
savePost();
|
|
50
|
-
} );
|
|
51
|
-
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export default SaveShortcut;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
5
|
-
import { useDispatch } from '@wordpress/data';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import SaveShortcut from './save-shortcut';
|
|
11
|
-
import { store as editorStore } from '../../store';
|
|
12
|
-
|
|
13
|
-
function VisualEditorGlobalKeyboardShortcuts() {
|
|
14
|
-
const { redo, undo } = useDispatch( editorStore );
|
|
15
|
-
|
|
16
|
-
useShortcut( 'core/editor/undo', ( event ) => {
|
|
17
|
-
undo();
|
|
18
|
-
event.preventDefault();
|
|
19
|
-
} );
|
|
20
|
-
|
|
21
|
-
useShortcut( 'core/editor/redo', ( event ) => {
|
|
22
|
-
redo();
|
|
23
|
-
event.preventDefault();
|
|
24
|
-
} );
|
|
25
|
-
|
|
26
|
-
return <SaveShortcut />;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default VisualEditorGlobalKeyboardShortcuts;
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { act, render, screen } from '@testing-library/react';
|
|
5
|
-
import userEvent from '@testing-library/user-event';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { useSelect } from '@wordpress/data';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import PostTextEditor from '../';
|
|
16
|
-
|
|
17
|
-
// "Downgrade" ReactAutosizeTextarea to a regular textarea. Assumes aligned
|
|
18
|
-
// props interface.
|
|
19
|
-
jest.mock( 'react-autosize-textarea', () => ( props ) => (
|
|
20
|
-
<textarea { ...props } />
|
|
21
|
-
) );
|
|
22
|
-
|
|
23
|
-
jest.mock( '@wordpress/data/src/components/use-select', () => {
|
|
24
|
-
// This allows us to tweak the returned value on each test.
|
|
25
|
-
const mock = jest.fn();
|
|
26
|
-
return mock;
|
|
27
|
-
} );
|
|
28
|
-
|
|
29
|
-
let mockEditPost = jest.fn();
|
|
30
|
-
let mockResetEditorBlocks = jest.fn();
|
|
31
|
-
|
|
32
|
-
jest.mock( '@wordpress/data/src/components/use-dispatch', () => {
|
|
33
|
-
return {
|
|
34
|
-
useDispatch: () => ( {
|
|
35
|
-
editPost: mockEditPost,
|
|
36
|
-
resetEditorBlocks: mockResetEditorBlocks,
|
|
37
|
-
} ),
|
|
38
|
-
};
|
|
39
|
-
} );
|
|
40
|
-
|
|
41
|
-
describe( 'PostTextEditor', () => {
|
|
42
|
-
beforeEach( () => {
|
|
43
|
-
useSelect.mockImplementation( () => 'Hello World' );
|
|
44
|
-
|
|
45
|
-
mockEditPost = jest.fn();
|
|
46
|
-
mockResetEditorBlocks = jest.fn();
|
|
47
|
-
} );
|
|
48
|
-
|
|
49
|
-
it( 'should render via the value from useSelect', () => {
|
|
50
|
-
render( <PostTextEditor /> );
|
|
51
|
-
|
|
52
|
-
expect( screen.getByLabelText( 'Type text or HTML' ) ).toHaveValue(
|
|
53
|
-
'Hello World'
|
|
54
|
-
);
|
|
55
|
-
} );
|
|
56
|
-
|
|
57
|
-
it( 'should render via the state value when edits made', async () => {
|
|
58
|
-
const user = userEvent.setup();
|
|
59
|
-
render( <PostTextEditor /> );
|
|
60
|
-
|
|
61
|
-
const textarea = screen.getByLabelText( 'Type text or HTML' );
|
|
62
|
-
|
|
63
|
-
await user.clear( textarea );
|
|
64
|
-
await user.type( textarea, 'Hello Chicken' );
|
|
65
|
-
|
|
66
|
-
expect( textarea ).toHaveValue( 'Hello Chicken' );
|
|
67
|
-
expect( mockEditPost ).toHaveBeenCalledWith( {
|
|
68
|
-
content: 'Hello Chicken',
|
|
69
|
-
} );
|
|
70
|
-
} );
|
|
71
|
-
|
|
72
|
-
it( 'should render via the state value when edits made, even if prop value changes', async () => {
|
|
73
|
-
const user = userEvent.setup();
|
|
74
|
-
const { rerender } = render( <PostTextEditor /> );
|
|
75
|
-
|
|
76
|
-
const textarea = screen.getByLabelText( 'Type text or HTML' );
|
|
77
|
-
|
|
78
|
-
await user.clear( textarea );
|
|
79
|
-
await user.type( textarea, 'Hello Chicken' );
|
|
80
|
-
|
|
81
|
-
useSelect.mockImplementation( () => 'Goodbye World' );
|
|
82
|
-
|
|
83
|
-
rerender( <PostTextEditor /> );
|
|
84
|
-
|
|
85
|
-
expect( textarea ).toHaveValue( 'Hello Chicken' );
|
|
86
|
-
expect( mockEditPost ).toHaveBeenCalledWith( {
|
|
87
|
-
content: 'Hello Chicken',
|
|
88
|
-
} );
|
|
89
|
-
} );
|
|
90
|
-
|
|
91
|
-
it( 'should render via the state value when edits made, even if prop value changes and state value empty', async () => {
|
|
92
|
-
const user = userEvent.setup();
|
|
93
|
-
const { rerender } = render( <PostTextEditor /> );
|
|
94
|
-
|
|
95
|
-
const textarea = screen.getByLabelText( 'Type text or HTML' );
|
|
96
|
-
|
|
97
|
-
await user.clear( textarea );
|
|
98
|
-
|
|
99
|
-
useSelect.mockImplementation( () => 'Goodbye World' );
|
|
100
|
-
|
|
101
|
-
rerender( <PostTextEditor /> );
|
|
102
|
-
|
|
103
|
-
expect( textarea ).toHaveValue( '' );
|
|
104
|
-
expect( mockEditPost ).toHaveBeenCalledWith( {
|
|
105
|
-
content: '',
|
|
106
|
-
} );
|
|
107
|
-
} );
|
|
108
|
-
|
|
109
|
-
it( 'calls onPersist after changes made and user stops editing', async () => {
|
|
110
|
-
const user = userEvent.setup();
|
|
111
|
-
render( <PostTextEditor /> );
|
|
112
|
-
|
|
113
|
-
const textarea = screen.getByLabelText( 'Type text or HTML' );
|
|
114
|
-
|
|
115
|
-
await user.clear( textarea );
|
|
116
|
-
|
|
117
|
-
// Stop editing.
|
|
118
|
-
act( () => {
|
|
119
|
-
textarea.blur();
|
|
120
|
-
} );
|
|
121
|
-
|
|
122
|
-
expect( mockResetEditorBlocks ).toHaveBeenCalledWith( [] );
|
|
123
|
-
} );
|
|
124
|
-
|
|
125
|
-
it( 'does not call onPersist after user stops editing without changes', () => {
|
|
126
|
-
render( <PostTextEditor /> );
|
|
127
|
-
|
|
128
|
-
// Stop editing.
|
|
129
|
-
screen.getByLabelText( 'Type text or HTML' ).blur();
|
|
130
|
-
|
|
131
|
-
expect( mockResetEditorBlocks ).not.toHaveBeenCalled();
|
|
132
|
-
} );
|
|
133
|
-
|
|
134
|
-
it( 'resets to prop value after user stops editing', async () => {
|
|
135
|
-
// This isn't the most realistic case, since typically we'd assume the
|
|
136
|
-
// parent renderer to pass the value as it had received onPersist. The
|
|
137
|
-
// test here is more an edge case to stress that it's intentionally
|
|
138
|
-
// differentiating between state and prop values.
|
|
139
|
-
const user = userEvent.setup();
|
|
140
|
-
const { rerender } = render( <PostTextEditor /> );
|
|
141
|
-
|
|
142
|
-
const textarea = screen.getByLabelText( 'Type text or HTML' );
|
|
143
|
-
|
|
144
|
-
await user.clear( textarea );
|
|
145
|
-
|
|
146
|
-
useSelect.mockImplementation( () => 'Goodbye World' );
|
|
147
|
-
|
|
148
|
-
rerender( <PostTextEditor /> );
|
|
149
|
-
|
|
150
|
-
act( () => {
|
|
151
|
-
textarea.blur();
|
|
152
|
-
} );
|
|
153
|
-
|
|
154
|
-
expect( textarea ).toHaveValue( 'Goodbye World' );
|
|
155
|
-
} );
|
|
156
|
-
} );
|