@wordpress/core-data 7.32.0 → 7.32.1-next.ff1cebbba.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/build/actions.js +375 -632
- package/build/actions.js.map +7 -1
- package/build/batch/create-batch.js +49 -62
- package/build/batch/create-batch.js.map +7 -1
- package/build/batch/default-processor.js +43 -39
- package/build/batch/default-processor.js.map +7 -1
- package/build/batch/index.js +38 -17
- package/build/batch/index.js.map +7 -1
- package/build/dynamic-entities.js +30 -32
- package/build/dynamic-entities.js.map +7 -1
- package/build/entities.js +298 -410
- package/build/entities.js.map +7 -1
- package/build/entity-context.js +29 -12
- package/build/entity-context.js.map +7 -1
- package/build/entity-provider.js +38 -46
- package/build/entity-provider.js.map +7 -1
- package/build/entity-types/attachment.js +16 -5
- package/build/entity-types/attachment.js.map +7 -1
- package/build/entity-types/base-entity-records.js +16 -42
- package/build/entity-types/base-entity-records.js.map +7 -1
- package/build/entity-types/base.js +16 -5
- package/build/entity-types/base.js.map +7 -1
- package/build/entity-types/comment.js +16 -5
- package/build/entity-types/comment.js.map +7 -1
- package/build/entity-types/global-styles-revision.js +16 -5
- package/build/entity-types/global-styles-revision.js.map +7 -1
- package/build/entity-types/helpers.js +16 -5
- package/build/entity-types/helpers.js.map +7 -1
- package/build/entity-types/index.js +16 -5
- package/build/entity-types/index.js.map +7 -1
- package/build/entity-types/menu-location.js +16 -5
- package/build/entity-types/menu-location.js.map +7 -1
- package/build/entity-types/nav-menu-item.js +16 -5
- package/build/entity-types/nav-menu-item.js.map +7 -1
- package/build/entity-types/nav-menu.js +16 -5
- package/build/entity-types/nav-menu.js.map +7 -1
- package/build/entity-types/page.js +16 -5
- package/build/entity-types/page.js.map +7 -1
- package/build/entity-types/plugin.js +16 -5
- package/build/entity-types/plugin.js.map +7 -1
- package/build/entity-types/post-revision.js +16 -5
- package/build/entity-types/post-revision.js.map +7 -1
- package/build/entity-types/post-status.js +16 -5
- package/build/entity-types/post-status.js.map +7 -1
- package/build/entity-types/post.js +16 -5
- package/build/entity-types/post.js.map +7 -1
- package/build/entity-types/settings.js +16 -5
- package/build/entity-types/settings.js.map +7 -1
- package/build/entity-types/sidebar.js +16 -5
- package/build/entity-types/sidebar.js.map +7 -1
- package/build/entity-types/taxonomy.js +16 -5
- package/build/entity-types/taxonomy.js.map +7 -1
- package/build/entity-types/term.js +16 -5
- package/build/entity-types/term.js.map +7 -1
- package/build/entity-types/theme.js +16 -5
- package/build/entity-types/theme.js.map +7 -1
- package/build/entity-types/type.js +16 -5
- package/build/entity-types/type.js.map +7 -1
- package/build/entity-types/user.js +16 -5
- package/build/entity-types/user.js.map +7 -1
- package/build/entity-types/widget-type.js +16 -5
- package/build/entity-types/widget-type.js.map +7 -1
- package/build/entity-types/widget.js +16 -5
- package/build/entity-types/widget.js.map +7 -1
- package/build/entity-types/wp-template-part.js +16 -5
- package/build/entity-types/wp-template-part.js.map +7 -1
- package/build/entity-types/wp-template.js +16 -5
- package/build/entity-types/wp-template.js.map +7 -1
- package/build/fetch/__experimental-fetch-link-suggestions.js +141 -154
- package/build/fetch/__experimental-fetch-link-suggestions.js.map +7 -1
- package/build/fetch/__experimental-fetch-url-data.js +47 -59
- package/build/fetch/__experimental-fetch-url-data.js.map +7 -1
- package/build/fetch/index.js +53 -32
- package/build/fetch/index.js.map +7 -1
- package/build/footnotes/get-footnotes-order.js +38 -25
- package/build/footnotes/get-footnotes-order.js.map +7 -1
- package/build/footnotes/get-rich-text-values-cached.js +26 -27
- package/build/footnotes/get-rich-text-values-cached.js.map +7 -1
- package/build/footnotes/index.js +68 -55
- package/build/footnotes/index.js.map +7 -1
- package/build/hooks/constants.js +33 -12
- package/build/hooks/constants.js.map +7 -1
- package/build/hooks/index.js +59 -68
- package/build/hooks/index.js.map +7 -1
- package/build/hooks/memoize.js +34 -12
- package/build/hooks/memoize.js.map +7 -1
- package/build/hooks/use-entity-block-editor.js +111 -119
- package/build/hooks/use-entity-block-editor.js.map +7 -1
- package/build/hooks/use-entity-id.js +25 -23
- package/build/hooks/use-entity-id.js.map +7 -1
- package/build/hooks/use-entity-prop.js +59 -60
- package/build/hooks/use-entity-prop.js.map +7 -1
- package/build/hooks/use-entity-record.js +95 -155
- package/build/hooks/use-entity-record.js.map +7 -1
- package/build/hooks/use-entity-records.js +131 -139
- package/build/hooks/use-entity-records.js.map +7 -1
- package/build/hooks/use-query-select.js +65 -84
- package/build/hooks/use-query-select.js.map +7 -1
- package/build/hooks/use-resource-permissions.js +92 -145
- package/build/hooks/use-resource-permissions.js.map +7 -1
- package/build/index.js +96 -153
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -14
- package/build/lock-unlock.js.map +7 -1
- package/build/locks/actions.js +36 -19
- package/build/locks/actions.js.map +7 -1
- package/build/locks/engine.js +48 -47
- package/build/locks/engine.js.map +7 -1
- package/build/locks/reducer.js +54 -63
- package/build/locks/reducer.js.map +7 -1
- package/build/locks/selectors.js +35 -30
- package/build/locks/selectors.js.map +7 -1
- package/build/locks/utils.js +37 -16
- package/build/locks/utils.js.map +7 -1
- package/build/name.js +27 -12
- package/build/name.js.map +7 -1
- package/build/private-actions.js +67 -75
- package/build/private-actions.js.map +7 -1
- package/build/private-apis.js +33 -16
- package/build/private-apis.js.map +7 -1
- package/build/private-selectors.js +204 -184
- package/build/private-selectors.js.map +7 -1
- package/build/queried-data/actions.js +32 -41
- package/build/queried-data/actions.js.map +7 -1
- package/build/queried-data/get-query-parts.js +41 -79
- package/build/queried-data/get-query-parts.js.map +7 -1
- package/build/queried-data/index.js +39 -36
- package/build/queried-data/index.js.map +7 -1
- package/build/queried-data/reducer.js +162 -193
- package/build/queried-data/reducer.js.map +7 -1
- package/build/queried-data/selectors.js +57 -85
- package/build/queried-data/selectors.js.map +7 -1
- package/build/reducer.js +279 -404
- package/build/reducer.js.map +7 -1
- package/build/resolvers.js +553 -600
- package/build/resolvers.js.map +7 -1
- package/build/selectors.js +456 -981
- package/build/selectors.js.map +7 -1
- package/build/sync.js +34 -22
- package/build/sync.js.map +7 -1
- package/build/types.js +16 -5
- package/build/types.js.map +7 -1
- package/build/utils/conservative-map-item.js +34 -27
- package/build/utils/conservative-map-item.js.map +7 -1
- package/build/utils/crdt-blocks.js +289 -0
- package/build/utils/crdt-blocks.js.map +7 -0
- package/build/utils/crdt.js +202 -0
- package/build/utils/crdt.js.map +7 -0
- package/build/utils/forward-resolver.js +24 -16
- package/build/utils/forward-resolver.js.map +7 -1
- package/build/utils/get-nested-value.js +26 -21
- package/build/utils/get-nested-value.js.map +7 -1
- package/build/utils/get-normalized-comma-separable.js +25 -17
- package/build/utils/get-normalized-comma-separable.js.map +7 -1
- package/build/utils/if-matching-action.js +25 -19
- package/build/utils/if-matching-action.js.map +7 -1
- package/build/utils/index.js +77 -108
- package/build/utils/index.js.map +7 -1
- package/build/utils/is-numeric-id.js +22 -12
- package/build/utils/is-numeric-id.js.map +7 -1
- package/build/utils/is-raw-attribute.js +22 -13
- package/build/utils/is-raw-attribute.js.map +7 -1
- package/build/utils/log-entity-deprecation.js +37 -38
- package/build/utils/log-entity-deprecation.js.map +7 -1
- package/build/utils/on-sub-key.js +30 -24
- package/build/utils/on-sub-key.js.map +7 -1
- package/build/utils/receive-intermediate-results.js +29 -6
- package/build/utils/receive-intermediate-results.js.map +7 -1
- package/build/utils/replace-action.js +24 -17
- package/build/utils/replace-action.js.map +7 -1
- package/build/utils/set-nested-value.js +25 -30
- package/build/utils/set-nested-value.js.map +7 -1
- package/build/utils/user-permissions.js +41 -13
- package/build/utils/user-permissions.js.map +7 -1
- package/build/utils/with-weak-map-cache.js +26 -22
- package/build/utils/with-weak-map-cache.js.map +7 -1
- package/build-module/actions.js +322 -601
- package/build-module/actions.js.map +7 -1
- package/build-module/batch/create-batch.js +21 -57
- package/build-module/batch/create-batch.js.map +7 -1
- package/build-module/batch/default-processor.js +14 -33
- package/build-module/batch/default-processor.js.map +7 -1
- package/build-module/batch/index.js +7 -3
- package/build-module/batch/index.js.map +7 -1
- package/build-module/dynamic-entities.js +7 -28
- package/build-module/dynamic-entities.js.map +7 -1
- package/build-module/entities.js +263 -399
- package/build-module/entities.js.map +7 -1
- package/build-module/entity-context.js +7 -7
- package/build-module/entity-context.js.map +7 -1
- package/build-module/entity-provider.js +19 -42
- package/build-module/entity-provider.js.map +7 -1
- package/build-module/entity-types/attachment.js +1 -2
- package/build-module/entity-types/attachment.js.map +7 -1
- package/build-module/entity-types/base-entity-records.js +1 -37
- package/build-module/entity-types/base-entity-records.js.map +7 -1
- package/build-module/entity-types/base.js +1 -2
- package/build-module/entity-types/base.js.map +7 -1
- package/build-module/entity-types/comment.js +1 -2
- package/build-module/entity-types/comment.js.map +7 -1
- package/build-module/entity-types/global-styles-revision.js +1 -2
- package/build-module/entity-types/global-styles-revision.js.map +7 -1
- package/build-module/entity-types/helpers.js +1 -2
- package/build-module/entity-types/helpers.js.map +7 -1
- package/build-module/entity-types/index.js +1 -2
- package/build-module/entity-types/index.js.map +7 -1
- package/build-module/entity-types/menu-location.js +1 -2
- package/build-module/entity-types/menu-location.js.map +7 -1
- package/build-module/entity-types/nav-menu-item.js +1 -2
- package/build-module/entity-types/nav-menu-item.js.map +7 -1
- package/build-module/entity-types/nav-menu.js +1 -2
- package/build-module/entity-types/nav-menu.js.map +7 -1
- package/build-module/entity-types/page.js +1 -2
- package/build-module/entity-types/page.js.map +7 -1
- package/build-module/entity-types/plugin.js +1 -2
- package/build-module/entity-types/plugin.js.map +7 -1
- package/build-module/entity-types/post-revision.js +1 -2
- package/build-module/entity-types/post-revision.js.map +7 -1
- package/build-module/entity-types/post-status.js +1 -2
- package/build-module/entity-types/post-status.js.map +7 -1
- package/build-module/entity-types/post.js +1 -2
- package/build-module/entity-types/post.js.map +7 -1
- package/build-module/entity-types/settings.js +1 -2
- package/build-module/entity-types/settings.js.map +7 -1
- package/build-module/entity-types/sidebar.js +1 -2
- package/build-module/entity-types/sidebar.js.map +7 -1
- package/build-module/entity-types/taxonomy.js +1 -2
- package/build-module/entity-types/taxonomy.js.map +7 -1
- package/build-module/entity-types/term.js +1 -2
- package/build-module/entity-types/term.js.map +7 -1
- package/build-module/entity-types/theme.js +1 -2
- package/build-module/entity-types/theme.js.map +7 -1
- package/build-module/entity-types/type.js +1 -2
- package/build-module/entity-types/type.js.map +7 -1
- package/build-module/entity-types/user.js +1 -2
- package/build-module/entity-types/user.js.map +7 -1
- package/build-module/entity-types/widget-type.js +1 -2
- package/build-module/entity-types/widget-type.js.map +7 -1
- package/build-module/entity-types/widget.js +1 -2
- package/build-module/entity-types/widget.js.map +7 -1
- package/build-module/entity-types/wp-template-part.js +1 -2
- package/build-module/entity-types/wp-template-part.js.map +7 -1
- package/build-module/entity-types/wp-template.js +1 -2
- package/build-module/entity-types/wp-template.js.map +7 -1
- package/build-module/fetch/__experimental-fetch-link-suggestions.js +111 -149
- package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +7 -1
- package/build-module/fetch/__experimental-fetch-url-data.js +20 -49
- package/build-module/fetch/__experimental-fetch-url-data.js.map +7 -1
- package/build-module/fetch/index.js +20 -15
- package/build-module/fetch/index.js.map +7 -1
- package/build-module/footnotes/get-footnotes-order.js +10 -19
- package/build-module/footnotes/get-footnotes-order.js.map +7 -1
- package/build-module/footnotes/get-rich-text-values-cached.js +8 -23
- package/build-module/footnotes/get-rich-text-values-cached.js.map +7 -1
- package/build-module/footnotes/index.js +34 -47
- package/build-module/footnotes/index.js.map +7 -1
- package/build-module/hooks/constants.js +11 -8
- package/build-module/hooks/constants.js.map +7 -1
- package/build-module/hooks/index.js +27 -15
- package/build-module/hooks/index.js.map +7 -1
- package/build-module/hooks/memoize.js +6 -8
- package/build-module/hooks/memoize.js.map +7 -1
- package/build-module/hooks/use-entity-block-editor.js +80 -110
- package/build-module/hooks/use-entity-block-editor.js.map +7 -1
- package/build-module/hooks/use-entity-id.js +7 -19
- package/build-module/hooks/use-entity-id.js.map +7 -1
- package/build-module/hooks/use-entity-prop.js +31 -55
- package/build-module/hooks/use-entity-prop.js.map +7 -1
- package/build-module/hooks/use-entity-record.js +63 -148
- package/build-module/hooks/use-entity-record.js.map +7 -1
- package/build-module/hooks/use-entity-records.js +98 -131
- package/build-module/hooks/use-entity-records.js.map +7 -1
- package/build-module/hooks/use-query-select.js +27 -71
- package/build-module/hooks/use-query-select.js.map +7 -1
- package/build-module/hooks/use-resource-permissions.js +57 -136
- package/build-module/hooks/use-resource-permissions.js.map +7 -1
- package/build-module/index.js +49 -71
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/locks/actions.js +8 -13
- package/build-module/locks/actions.js.map +7 -1
- package/build-module/locks/engine.js +17 -38
- package/build-module/locks/engine.js.map +7 -1
- package/build-module/locks/reducer.js +37 -59
- package/build-module/locks/reducer.js.map +7 -1
- package/build-module/locks/selectors.js +16 -23
- package/build-module/locks/selectors.js.map +7 -1
- package/build-module/locks/utils.js +15 -12
- package/build-module/locks/utils.js.map +7 -1
- package/build-module/name.js +5 -8
- package/build-module/name.js.map +7 -1
- package/build-module/private-actions.js +35 -69
- package/build-module/private-actions.js.map +7 -1
- package/build-module/private-apis.js +8 -8
- package/build-module/private-apis.js.map +7 -1
- package/build-module/private-selectors.js +167 -174
- package/build-module/private-selectors.js.map +7 -1
- package/build-module/queried-data/actions.js +11 -38
- package/build-module/queried-data/actions.js.map +7 -1
- package/build-module/queried-data/get-query-parts.js +20 -75
- package/build-module/queried-data/get-query-parts.js.map +7 -1
- package/build-module/queried-data/index.js +7 -4
- package/build-module/queried-data/index.js.map +7 -1
- package/build-module/queried-data/reducer.js +134 -185
- package/build-module/queried-data/reducer.js.map +7 -1
- package/build-module/queried-data/selectors.js +23 -78
- package/build-module/queried-data/selectors.js.map +7 -1
- package/build-module/reducer.js +243 -393
- package/build-module/reducer.js.map +7 -1
- package/build-module/resolvers.js +478 -549
- package/build-module/resolvers.js.map +7 -1
- package/build-module/selectors.js +410 -953
- package/build-module/selectors.js.map +7 -1
- package/build-module/sync.js +14 -17
- package/build-module/sync.js.map +7 -1
- package/build-module/types.js +1 -2
- package/build-module/types.js.map +7 -1
- package/build-module/utils/conservative-map-item.js +6 -22
- package/build-module/utils/conservative-map-item.js.map +7 -1
- package/build-module/utils/crdt-blocks.js +255 -0
- package/build-module/utils/crdt-blocks.js.map +7 -0
- package/build-module/utils/crdt.js +167 -0
- package/build-module/utils/crdt.js.map +7 -0
- package/build-module/utils/forward-resolver.js +6 -12
- package/build-module/utils/forward-resolver.js.map +7 -1
- package/build-module/utils/get-nested-value.js +9 -18
- package/build-module/utils/get-nested-value.js.map +7 -1
- package/build-module/utils/get-normalized-comma-separable.js +7 -13
- package/build-module/utils/get-normalized-comma-separable.js.map +7 -1
- package/build-module/utils/if-matching-action.js +7 -15
- package/build-module/utils/if-matching-action.js.map +7 -1
- package/build-module/utils/index.js +35 -14
- package/build-module/utils/index.js.map +7 -1
- package/build-module/utils/is-numeric-id.js +5 -9
- package/build-module/utils/is-numeric-id.js.map +7 -1
- package/build-module/utils/is-raw-attribute.js +5 -10
- package/build-module/utils/is-raw-attribute.js.map +7 -1
- package/build-module/utils/log-entity-deprecation.js +8 -31
- package/build-module/utils/log-entity-deprecation.js.map +7 -1
- package/build-module/utils/on-sub-key.js +8 -19
- package/build-module/utils/on-sub-key.js.map +7 -1
- package/build-module/utils/receive-intermediate-results.js +7 -2
- package/build-module/utils/receive-intermediate-results.js.map +7 -1
- package/build-module/utils/replace-action.js +6 -13
- package/build-module/utils/replace-action.js.map +7 -1
- package/build-module/utils/set-nested-value.js +8 -27
- package/build-module/utils/set-nested-value.js.map +7 -1
- package/build-module/utils/user-permissions.js +19 -9
- package/build-module/utils/user-permissions.js.map +7 -1
- package/build-module/utils/with-weak-map-cache.js +8 -18
- package/build-module/utils/with-weak-map-cache.js.map +7 -1
- package/build-types/actions.d.ts.map +1 -1
- package/build-types/entities.d.ts +0 -56
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/private-selectors.d.ts.map +1 -1
- package/build-types/resolvers.d.ts +3 -0
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/selectors.d.ts.map +1 -1
- package/build-types/sync.d.ts +6 -1
- package/build-types/sync.d.ts.map +1 -1
- package/build-types/types.d.ts +9 -0
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils/crdt-blocks.d.ts +30 -0
- package/build-types/utils/crdt-blocks.d.ts.map +1 -0
- package/build-types/utils/crdt.d.ts +49 -0
- package/build-types/utils/crdt.d.ts.map +1 -0
- package/package.json +26 -19
- package/src/actions.js +56 -74
- package/src/entities.js +59 -113
- package/src/private-selectors.ts +32 -7
- package/src/resolvers.js +173 -120
- package/src/selectors.ts +0 -13
- package/src/sync.ts +12 -0
- package/src/test/resolvers.js +183 -0
- package/src/types.ts +12 -0
- package/src/utils/crdt-blocks.ts +503 -0
- package/src/utils/crdt.ts +310 -0
- package/src/utils/test/crdt-blocks.ts +375 -0
- package/src/utils/test/crdt.ts +254 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/sync.js +0 -27
|
@@ -1,57 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* for those wishing to preserve low-bandwidth.
|
|
11
|
-
*/
|
|
12
|
-
const CACHE = new Map();
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @typedef WPRemoteUrlData
|
|
16
|
-
*
|
|
17
|
-
* @property {string} title contents of the remote URL's `<title>` tag.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Fetches data about a remote URL.
|
|
22
|
-
* eg: <title> tag, favicon...etc.
|
|
23
|
-
*
|
|
24
|
-
* @async
|
|
25
|
-
* @param {string} url the URL to request details from.
|
|
26
|
-
* @param {?Object} options any options to pass to the underlying fetch.
|
|
27
|
-
* @example
|
|
28
|
-
* ```js
|
|
29
|
-
* import { __experimentalFetchUrlData as fetchUrlData } from '@wordpress/core-data';
|
|
30
|
-
*
|
|
31
|
-
* //...
|
|
32
|
-
*
|
|
33
|
-
* export function initialize( id, settings ) {
|
|
34
|
-
*
|
|
35
|
-
* settings.__experimentalFetchUrlData = (
|
|
36
|
-
* url
|
|
37
|
-
* ) => fetchUrlData( url );
|
|
38
|
-
* ```
|
|
39
|
-
* @return {Promise< WPRemoteUrlData[] >} Remote URL data.
|
|
40
|
-
*/
|
|
1
|
+
import apiFetch from "@wordpress/api-fetch";
|
|
2
|
+
import {
|
|
3
|
+
addQueryArgs,
|
|
4
|
+
prependHTTP,
|
|
5
|
+
isURL,
|
|
6
|
+
getProtocol,
|
|
7
|
+
isValidProtocol
|
|
8
|
+
} from "@wordpress/url";
|
|
9
|
+
const CACHE = /* @__PURE__ */ new Map();
|
|
41
10
|
const fetchUrlData = async (url, options = {}) => {
|
|
42
|
-
const endpoint =
|
|
11
|
+
const endpoint = "/wp-block-editor/v1/url-details";
|
|
43
12
|
const args = {
|
|
44
13
|
url: prependHTTP(url)
|
|
45
14
|
};
|
|
46
15
|
if (!isURL(url)) {
|
|
47
16
|
return Promise.reject(`${url} is not a valid URL.`);
|
|
48
17
|
}
|
|
49
|
-
|
|
50
|
-
// Test for "http" based URL as it is possible for valid
|
|
51
|
-
// yet unusable URLs such as `tel:123456` to be passed.
|
|
52
18
|
const protocol = getProtocol(url);
|
|
53
|
-
if (!protocol || !isValidProtocol(protocol) || !protocol.startsWith(
|
|
54
|
-
return Promise.reject(
|
|
19
|
+
if (!protocol || !isValidProtocol(protocol) || !protocol.startsWith("http") || !/^https?:\/\/[^\/\s]/i.test(url)) {
|
|
20
|
+
return Promise.reject(
|
|
21
|
+
`${url} does not have a valid protocol. URLs must be "http" based`
|
|
22
|
+
);
|
|
55
23
|
}
|
|
56
24
|
if (CACHE.has(url)) {
|
|
57
25
|
return CACHE.get(url);
|
|
@@ -59,10 +27,13 @@ const fetchUrlData = async (url, options = {}) => {
|
|
|
59
27
|
return apiFetch({
|
|
60
28
|
path: addQueryArgs(endpoint, args),
|
|
61
29
|
...options
|
|
62
|
-
}).then(res => {
|
|
30
|
+
}).then((res) => {
|
|
63
31
|
CACHE.set(url, res);
|
|
64
32
|
return res;
|
|
65
33
|
});
|
|
66
34
|
};
|
|
67
|
-
|
|
68
|
-
|
|
35
|
+
var experimental_fetch_url_data_default = fetchUrlData;
|
|
36
|
+
export {
|
|
37
|
+
experimental_fetch_url_data_default as default
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=__experimental-fetch-url-data.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/fetch/__experimental-fetch-url-data.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport {\n\taddQueryArgs,\n\tprependHTTP,\n\tisURL,\n\tgetProtocol,\n\tisValidProtocol,\n} from '@wordpress/url';\n\n/**\n * A simple in-memory cache for requests.\n * This avoids repeat HTTP requests which may be beneficial\n * for those wishing to preserve low-bandwidth.\n */\nconst CACHE = new Map();\n\n/**\n * @typedef WPRemoteUrlData\n *\n * @property {string} title contents of the remote URL's `<title>` tag.\n */\n\n/**\n * Fetches data about a remote URL.\n * eg: <title> tag, favicon...etc.\n *\n * @async\n * @param {string} url the URL to request details from.\n * @param {?Object} options any options to pass to the underlying fetch.\n * @example\n * ```js\n * import { __experimentalFetchUrlData as fetchUrlData } from '@wordpress/core-data';\n *\n * //...\n *\n * export function initialize( id, settings ) {\n *\n * settings.__experimentalFetchUrlData = (\n * url\n * ) => fetchUrlData( url );\n * ```\n * @return {Promise< WPRemoteUrlData[] >} Remote URL data.\n */\nconst fetchUrlData = async ( url, options = {} ) => {\n\tconst endpoint = '/wp-block-editor/v1/url-details';\n\n\tconst args = {\n\t\turl: prependHTTP( url ),\n\t};\n\n\tif ( ! isURL( url ) ) {\n\t\treturn Promise.reject( `${ url } is not a valid URL.` );\n\t}\n\n\t// Test for \"http\" based URL as it is possible for valid\n\t// yet unusable URLs such as `tel:123456` to be passed.\n\tconst protocol = getProtocol( url );\n\n\tif (\n\t\t! protocol ||\n\t\t! isValidProtocol( protocol ) ||\n\t\t! protocol.startsWith( 'http' ) ||\n\t\t! /^https?:\\/\\/[^\\/\\s]/i.test( url )\n\t) {\n\t\treturn Promise.reject(\n\t\t\t`${ url } does not have a valid protocol. URLs must be \"http\" based`\n\t\t);\n\t}\n\n\tif ( CACHE.has( url ) ) {\n\t\treturn CACHE.get( url );\n\t}\n\n\treturn apiFetch( {\n\t\tpath: addQueryArgs( endpoint, args ),\n\t\t...options,\n\t} ).then( ( res ) => {\n\t\tCACHE.set( url, res );\n\t\treturn res;\n\t} );\n};\n\nexport default fetchUrlData;\n"],
|
|
5
|
+
"mappings": "AAGA,OAAO,cAAc;AACrB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAOP,MAAM,QAAQ,oBAAI,IAAI;AA6BtB,MAAM,eAAe,OAAQ,KAAK,UAAU,CAAC,MAAO;AACnD,QAAM,WAAW;AAEjB,QAAM,OAAO;AAAA,IACZ,KAAK,YAAa,GAAI;AAAA,EACvB;AAEA,MAAK,CAAE,MAAO,GAAI,GAAI;AACrB,WAAO,QAAQ,OAAQ,GAAI,GAAI,sBAAuB;AAAA,EACvD;AAIA,QAAM,WAAW,YAAa,GAAI;AAElC,MACC,CAAE,YACF,CAAE,gBAAiB,QAAS,KAC5B,CAAE,SAAS,WAAY,MAAO,KAC9B,CAAE,uBAAuB,KAAM,GAAI,GAClC;AACD,WAAO,QAAQ;AAAA,MACd,GAAI,GAAI;AAAA,IACT;AAAA,EACD;AAEA,MAAK,MAAM,IAAK,GAAI,GAAI;AACvB,WAAO,MAAM,IAAK,GAAI;AAAA,EACvB;AAEA,SAAO,SAAU;AAAA,IAChB,MAAM,aAAc,UAAU,IAAK;AAAA,IACnC,GAAG;AAAA,EACJ,CAAE,EAAE,KAAM,CAAE,QAAS;AACpB,UAAM,IAAK,KAAK,GAAI;AACpB,WAAO;AAAA,EACR,CAAE;AACH;AAEA,IAAO,sCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import apiFetch from '@wordpress/api-fetch';
|
|
10
|
-
export { default as __experimentalFetchLinkSuggestions } from './__experimental-fetch-link-suggestions';
|
|
11
|
-
export { default as __experimentalFetchUrlData } from './__experimental-fetch-url-data';
|
|
12
|
-
export async function fetchBlockPatterns() {
|
|
1
|
+
import { camelCase } from "change-case";
|
|
2
|
+
import apiFetch from "@wordpress/api-fetch";
|
|
3
|
+
import { default as default2 } from "./__experimental-fetch-link-suggestions";
|
|
4
|
+
import { default as default3 } from "./__experimental-fetch-url-data";
|
|
5
|
+
async function fetchBlockPatterns() {
|
|
13
6
|
const restPatterns = await apiFetch({
|
|
14
|
-
path:
|
|
7
|
+
path: "/wp/v2/block-patterns/patterns"
|
|
15
8
|
});
|
|
16
9
|
if (!restPatterns) {
|
|
17
10
|
return [];
|
|
18
11
|
}
|
|
19
|
-
return restPatterns.map(
|
|
12
|
+
return restPatterns.map(
|
|
13
|
+
(pattern) => Object.fromEntries(
|
|
14
|
+
Object.entries(pattern).map(([key, value]) => [
|
|
15
|
+
camelCase(key),
|
|
16
|
+
value
|
|
17
|
+
])
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
export {
|
|
22
|
+
default2 as __experimentalFetchLinkSuggestions,
|
|
23
|
+
default3 as __experimentalFetchUrlData,
|
|
24
|
+
fetchBlockPatterns
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/fetch/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\nexport { default as __experimentalFetchLinkSuggestions } from './__experimental-fetch-link-suggestions';\nexport { default as __experimentalFetchUrlData } from './__experimental-fetch-url-data';\n\nexport async function fetchBlockPatterns() {\n\tconst restPatterns = await apiFetch( {\n\t\tpath: '/wp/v2/block-patterns/patterns',\n\t} );\n\tif ( ! restPatterns ) {\n\t\treturn [];\n\t}\n\treturn restPatterns.map( ( pattern ) =>\n\t\tObject.fromEntries(\n\t\t\tObject.entries( pattern ).map( ( [ key, value ] ) => [\n\t\t\t\tcamelCase( key ),\n\t\t\t\tvalue,\n\t\t\t] )\n\t\t)\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,iBAAiB;AAK1B,OAAO,cAAc;AAErB,SAAoB,WAAXA,gBAAqD;AAC9D,SAAoB,WAAXA,gBAA6C;AAEtD,eAAsB,qBAAqB;AAC1C,QAAM,eAAe,MAAM,SAAU;AAAA,IACpC,MAAM;AAAA,EACP,CAAE;AACF,MAAK,CAAE,cAAe;AACrB,WAAO,CAAC;AAAA,EACT;AACA,SAAO,aAAa;AAAA,IAAK,CAAE,YAC1B,OAAO;AAAA,MACN,OAAO,QAAS,OAAQ,EAAE,IAAK,CAAE,CAAE,KAAK,KAAM,MAAO;AAAA,QACpD,UAAW,GAAI;AAAA,QACf;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AACD;",
|
|
6
|
+
"names": ["default"]
|
|
7
|
+
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import getRichTextValuesCached from './get-rich-text-values-cached';
|
|
5
|
-
const cache = new WeakMap();
|
|
1
|
+
import getRichTextValuesCached from "./get-rich-text-values-cached";
|
|
2
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
6
3
|
function getBlockFootnotesOrder(block) {
|
|
7
4
|
if (!cache.has(block)) {
|
|
8
5
|
const order = [];
|
|
@@ -10,14 +7,9 @@ function getBlockFootnotesOrder(block) {
|
|
|
10
7
|
if (!value) {
|
|
11
8
|
continue;
|
|
12
9
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
type,
|
|
17
|
-
attributes
|
|
18
|
-
}) => {
|
|
19
|
-
if (type === 'core/footnote') {
|
|
20
|
-
order.push(attributes['data-fn']);
|
|
10
|
+
value.replacements.forEach(({ type, attributes }) => {
|
|
11
|
+
if (type === "core/footnote") {
|
|
12
|
+
order.push(attributes["data-fn"]);
|
|
21
13
|
}
|
|
22
14
|
});
|
|
23
15
|
}
|
|
@@ -25,11 +17,10 @@ function getBlockFootnotesOrder(block) {
|
|
|
25
17
|
}
|
|
26
18
|
return cache.get(block);
|
|
27
19
|
}
|
|
28
|
-
|
|
29
|
-
// We can only separate getting order from blocks at the root level. For
|
|
30
|
-
// deeper inner blocks, this will not work since it's possible to have both
|
|
31
|
-
// inner blocks and block attributes, so order needs to be computed from the
|
|
32
|
-
// Edit functions as a whole.
|
|
20
|
+
function getFootnotesOrder(blocks) {
|
|
33
21
|
return blocks.flatMap(getBlockFootnotesOrder);
|
|
34
22
|
}
|
|
35
|
-
|
|
23
|
+
export {
|
|
24
|
+
getFootnotesOrder as default
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=get-footnotes-order.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/footnotes/get-footnotes-order.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport getRichTextValuesCached from './get-rich-text-values-cached';\n\nconst cache = new WeakMap();\n\nfunction getBlockFootnotesOrder( block ) {\n\tif ( ! cache.has( block ) ) {\n\t\tconst order = [];\n\t\tfor ( const value of getRichTextValuesCached( block ) ) {\n\t\t\tif ( ! value ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// replacements is a sparse array, use forEach to skip empty slots.\n\t\t\tvalue.replacements.forEach( ( { type, attributes } ) => {\n\t\t\t\tif ( type === 'core/footnote' ) {\n\t\t\t\t\torder.push( attributes[ 'data-fn' ] );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t\tcache.set( block, order );\n\t}\n\n\treturn cache.get( block );\n}\n\nexport default function getFootnotesOrder( blocks ) {\n\t// We can only separate getting order from blocks at the root level. For\n\t// deeper inner blocks, this will not work since it's possible to have both\n\t// inner blocks and block attributes, so order needs to be computed from the\n\t// Edit functions as a whole.\n\treturn blocks.flatMap( getBlockFootnotesOrder );\n}\n"],
|
|
5
|
+
"mappings": "AAGA,OAAO,6BAA6B;AAEpC,MAAM,QAAQ,oBAAI,QAAQ;AAE1B,SAAS,uBAAwB,OAAQ;AACxC,MAAK,CAAE,MAAM,IAAK,KAAM,GAAI;AAC3B,UAAM,QAAQ,CAAC;AACf,eAAY,SAAS,wBAAyB,KAAM,GAAI;AACvD,UAAK,CAAE,OAAQ;AACd;AAAA,MACD;AAGA,YAAM,aAAa,QAAS,CAAE,EAAE,MAAM,WAAW,MAAO;AACvD,YAAK,SAAS,iBAAkB;AAC/B,gBAAM,KAAM,WAAY,SAAU,CAAE;AAAA,QACrC;AAAA,MACD,CAAE;AAAA,IACH;AACA,UAAM,IAAK,OAAO,KAAM;AAAA,EACzB;AAEA,SAAO,MAAM,IAAK,KAAM;AACzB;AAEe,SAAR,kBAAoC,QAAS;AAKnD,SAAO,OAAO,QAAS,sBAAuB;AAC/C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { unlock } from '../lock-unlock';
|
|
10
|
-
|
|
11
|
-
// TODO: The following line should have been:
|
|
12
|
-
//
|
|
13
|
-
// const unlockedApis = unlock( blockEditorPrivateApis );
|
|
14
|
-
//
|
|
15
|
-
// But there are hidden circular dependencies in RNMobile code, specifically in
|
|
16
|
-
// certain native components in the `components` package that depend on
|
|
17
|
-
// `block-editor`. What follows is a workaround that defers the `unlock` call
|
|
18
|
-
// to prevent native code from failing.
|
|
19
|
-
//
|
|
20
|
-
// Fix once https://github.com/WordPress/gutenberg/issues/52692 is closed.
|
|
1
|
+
import { privateApis as blockEditorPrivateApis } from "@wordpress/block-editor";
|
|
2
|
+
import { unlock } from "../lock-unlock";
|
|
21
3
|
let unlockedApis;
|
|
22
|
-
const cache = new WeakMap();
|
|
23
|
-
|
|
4
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
function getRichTextValuesCached(block) {
|
|
24
6
|
if (!unlockedApis) {
|
|
25
7
|
unlockedApis = unlock(blockEditorPrivateApis);
|
|
26
8
|
}
|
|
@@ -30,4 +12,7 @@ export default function getRichTextValuesCached(block) {
|
|
|
30
12
|
}
|
|
31
13
|
return cache.get(block);
|
|
32
14
|
}
|
|
33
|
-
|
|
15
|
+
export {
|
|
16
|
+
getRichTextValuesCached as default
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=get-rich-text-values-cached.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/footnotes/get-rich-text-values-cached.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\n// TODO: The following line should have been:\n//\n// const unlockedApis = unlock( blockEditorPrivateApis );\n//\n// But there are hidden circular dependencies in RNMobile code, specifically in\n// certain native components in the `components` package that depend on\n// `block-editor`. What follows is a workaround that defers the `unlock` call\n// to prevent native code from failing.\n//\n// Fix once https://github.com/WordPress/gutenberg/issues/52692 is closed.\nlet unlockedApis;\n\nconst cache = new WeakMap();\n\nexport default function getRichTextValuesCached( block ) {\n\tif ( ! unlockedApis ) {\n\t\tunlockedApis = unlock( blockEditorPrivateApis );\n\t}\n\n\tif ( ! cache.has( block ) ) {\n\t\tconst values = unlockedApis.getRichTextValues( [ block ] );\n\t\tcache.set( block, values );\n\t}\n\treturn cache.get( block );\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,eAAe,8BAA8B;AAKtD,SAAS,cAAc;AAYvB,IAAI;AAEJ,MAAM,QAAQ,oBAAI,QAAQ;AAEX,SAAR,wBAA0C,OAAQ;AACxD,MAAK,CAAE,cAAe;AACrB,mBAAe,OAAQ,sBAAuB;AAAA,EAC/C;AAEA,MAAK,CAAE,MAAM,IAAK,KAAM,GAAI;AAC3B,UAAM,SAAS,aAAa,kBAAmB,CAAE,KAAM,CAAE;AACzD,UAAM,IAAK,OAAO,MAAO;AAAA,EAC1B;AACA,SAAO,MAAM,IAAK,KAAM;AACzB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,71 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { RichTextData, create, toHTMLString } from '@wordpress/rich-text';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import getFootnotesOrder from './get-footnotes-order';
|
|
1
|
+
import { RichTextData, create, toHTMLString } from "@wordpress/rich-text";
|
|
2
|
+
import getFootnotesOrder from "./get-footnotes-order";
|
|
10
3
|
let oldFootnotes = {};
|
|
11
|
-
|
|
12
|
-
const output = {
|
|
13
|
-
blocks
|
|
14
|
-
};
|
|
4
|
+
function updateFootnotesFromMeta(blocks, meta) {
|
|
5
|
+
const output = { blocks };
|
|
15
6
|
if (!meta) {
|
|
16
7
|
return output;
|
|
17
8
|
}
|
|
18
|
-
|
|
19
|
-
// If meta.footnotes is empty, it means the meta is not registered.
|
|
20
|
-
if (meta.footnotes === undefined) {
|
|
9
|
+
if (meta.footnotes === void 0) {
|
|
21
10
|
return output;
|
|
22
11
|
}
|
|
23
12
|
const newOrder = getFootnotesOrder(blocks);
|
|
24
13
|
const footnotes = meta.footnotes ? JSON.parse(meta.footnotes) : [];
|
|
25
|
-
const currentOrder = footnotes.map(fn => fn.id);
|
|
26
|
-
if (currentOrder.join(
|
|
14
|
+
const currentOrder = footnotes.map((fn) => fn.id);
|
|
15
|
+
if (currentOrder.join("") === newOrder.join("")) {
|
|
27
16
|
return output;
|
|
28
17
|
}
|
|
29
|
-
const newFootnotes = newOrder.map(
|
|
30
|
-
id
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
const newFootnotes = newOrder.map(
|
|
19
|
+
(fnId) => footnotes.find((fn) => fn.id === fnId) || oldFootnotes[fnId] || {
|
|
20
|
+
id: fnId,
|
|
21
|
+
content: ""
|
|
22
|
+
}
|
|
23
|
+
);
|
|
33
24
|
function updateAttributes(attributes) {
|
|
34
|
-
|
|
35
|
-
if (!attributes || Array.isArray(attributes) || typeof attributes !== 'object') {
|
|
25
|
+
if (!attributes || Array.isArray(attributes) || typeof attributes !== "object") {
|
|
36
26
|
return attributes;
|
|
37
27
|
}
|
|
38
|
-
attributes = {
|
|
39
|
-
...attributes
|
|
40
|
-
};
|
|
28
|
+
attributes = { ...attributes };
|
|
41
29
|
for (const key in attributes) {
|
|
42
30
|
const value = attributes[key];
|
|
43
31
|
if (Array.isArray(value)) {
|
|
44
32
|
attributes[key] = value.map(updateAttributes);
|
|
45
33
|
continue;
|
|
46
34
|
}
|
|
47
|
-
|
|
48
|
-
// To do, remove support for string values?
|
|
49
|
-
if (typeof value !== 'string' && !(value instanceof RichTextData)) {
|
|
35
|
+
if (typeof value !== "string" && !(value instanceof RichTextData)) {
|
|
50
36
|
continue;
|
|
51
37
|
}
|
|
52
|
-
const richTextValue = typeof value ===
|
|
38
|
+
const richTextValue = typeof value === "string" ? RichTextData.fromHTMLString(value) : new RichTextData(value);
|
|
53
39
|
let hasFootnotes = false;
|
|
54
|
-
richTextValue.replacements.forEach(replacement => {
|
|
55
|
-
if (replacement.type ===
|
|
56
|
-
const id = replacement.attributes[
|
|
40
|
+
richTextValue.replacements.forEach((replacement) => {
|
|
41
|
+
if (replacement.type === "core/footnote") {
|
|
42
|
+
const id = replacement.attributes["data-fn"];
|
|
57
43
|
const index = newOrder.indexOf(id);
|
|
58
|
-
// The innerHTML contains the count wrapped in a link.
|
|
59
44
|
const countValue = create({
|
|
60
45
|
html: replacement.innerHTML
|
|
61
46
|
});
|
|
62
47
|
countValue.text = String(index + 1);
|
|
63
|
-
countValue.formats = Array.from(
|
|
64
|
-
length: countValue.text.length
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
48
|
+
countValue.formats = Array.from(
|
|
49
|
+
{ length: countValue.text.length },
|
|
50
|
+
() => countValue.formats[0]
|
|
51
|
+
);
|
|
52
|
+
countValue.replacements = Array.from(
|
|
53
|
+
{ length: countValue.text.length },
|
|
54
|
+
() => countValue.replacements[0]
|
|
55
|
+
);
|
|
69
56
|
replacement.innerHTML = toHTMLString({
|
|
70
57
|
value: countValue
|
|
71
58
|
});
|
|
@@ -73,13 +60,13 @@ export function updateFootnotesFromMeta(blocks, meta) {
|
|
|
73
60
|
}
|
|
74
61
|
});
|
|
75
62
|
if (hasFootnotes) {
|
|
76
|
-
attributes[key] = typeof value ===
|
|
63
|
+
attributes[key] = typeof value === "string" ? richTextValue.toHTMLString() : richTextValue;
|
|
77
64
|
}
|
|
78
65
|
}
|
|
79
66
|
return attributes;
|
|
80
67
|
}
|
|
81
68
|
function updateBlocksAttributes(__blocks) {
|
|
82
|
-
return __blocks.map(block => {
|
|
69
|
+
return __blocks.map((block) => {
|
|
83
70
|
return {
|
|
84
71
|
...block,
|
|
85
72
|
attributes: updateAttributes(block.attributes),
|
|
@@ -87,9 +74,6 @@ export function updateFootnotesFromMeta(blocks, meta) {
|
|
|
87
74
|
};
|
|
88
75
|
});
|
|
89
76
|
}
|
|
90
|
-
|
|
91
|
-
// We need to go through all block attributes deeply and update the
|
|
92
|
-
// footnote anchor numbering (textContent) to match the new order.
|
|
93
77
|
const newBlocks = updateBlocksAttributes(blocks);
|
|
94
78
|
oldFootnotes = {
|
|
95
79
|
...oldFootnotes,
|
|
@@ -108,4 +92,7 @@ export function updateFootnotesFromMeta(blocks, meta) {
|
|
|
108
92
|
blocks: newBlocks
|
|
109
93
|
};
|
|
110
94
|
}
|
|
111
|
-
|
|
95
|
+
export {
|
|
96
|
+
updateFootnotesFromMeta
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/footnotes/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { RichTextData, create, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport getFootnotesOrder from './get-footnotes-order';\n\nlet oldFootnotes = {};\n\nexport function updateFootnotesFromMeta( blocks, meta ) {\n\tconst output = { blocks };\n\tif ( ! meta ) {\n\t\treturn output;\n\t}\n\n\t// If meta.footnotes is empty, it means the meta is not registered.\n\tif ( meta.footnotes === undefined ) {\n\t\treturn output;\n\t}\n\n\tconst newOrder = getFootnotesOrder( blocks );\n\n\tconst footnotes = meta.footnotes ? JSON.parse( meta.footnotes ) : [];\n\tconst currentOrder = footnotes.map( ( fn ) => fn.id );\n\n\tif ( currentOrder.join( '' ) === newOrder.join( '' ) ) {\n\t\treturn output;\n\t}\n\n\tconst newFootnotes = newOrder.map(\n\t\t( fnId ) =>\n\t\t\tfootnotes.find( ( fn ) => fn.id === fnId ) ||\n\t\t\toldFootnotes[ fnId ] || {\n\t\t\t\tid: fnId,\n\t\t\t\tcontent: '',\n\t\t\t}\n\t);\n\n\tfunction updateAttributes( attributes ) {\n\t\t// Only attempt to update attributes, if attributes is an object.\n\t\tif (\n\t\t\t! attributes ||\n\t\t\tArray.isArray( attributes ) ||\n\t\t\ttypeof attributes !== 'object'\n\t\t) {\n\t\t\treturn attributes;\n\t\t}\n\n\t\tattributes = { ...attributes };\n\n\t\tfor ( const key in attributes ) {\n\t\t\tconst value = attributes[ key ];\n\n\t\t\tif ( Array.isArray( value ) ) {\n\t\t\t\tattributes[ key ] = value.map( updateAttributes );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// To do, remove support for string values?\n\t\t\tif (\n\t\t\t\ttypeof value !== 'string' &&\n\t\t\t\t! ( value instanceof RichTextData )\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst richTextValue =\n\t\t\t\ttypeof value === 'string'\n\t\t\t\t\t? RichTextData.fromHTMLString( value )\n\t\t\t\t\t: new RichTextData( value );\n\n\t\t\tlet hasFootnotes = false;\n\n\t\t\trichTextValue.replacements.forEach( ( replacement ) => {\n\t\t\t\tif ( replacement.type === 'core/footnote' ) {\n\t\t\t\t\tconst id = replacement.attributes[ 'data-fn' ];\n\t\t\t\t\tconst index = newOrder.indexOf( id );\n\t\t\t\t\t// The innerHTML contains the count wrapped in a link.\n\t\t\t\t\tconst countValue = create( {\n\t\t\t\t\t\thtml: replacement.innerHTML,\n\t\t\t\t\t} );\n\t\t\t\t\tcountValue.text = String( index + 1 );\n\t\t\t\t\tcountValue.formats = Array.from(\n\t\t\t\t\t\t{ length: countValue.text.length },\n\t\t\t\t\t\t() => countValue.formats[ 0 ]\n\t\t\t\t\t);\n\t\t\t\t\tcountValue.replacements = Array.from(\n\t\t\t\t\t\t{ length: countValue.text.length },\n\t\t\t\t\t\t() => countValue.replacements[ 0 ]\n\t\t\t\t\t);\n\t\t\t\t\treplacement.innerHTML = toHTMLString( {\n\t\t\t\t\t\tvalue: countValue,\n\t\t\t\t\t} );\n\t\t\t\t\thasFootnotes = true;\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tif ( hasFootnotes ) {\n\t\t\t\tattributes[ key ] =\n\t\t\t\t\ttypeof value === 'string'\n\t\t\t\t\t\t? richTextValue.toHTMLString()\n\t\t\t\t\t\t: richTextValue;\n\t\t\t}\n\t\t}\n\n\t\treturn attributes;\n\t}\n\n\tfunction updateBlocksAttributes( __blocks ) {\n\t\treturn __blocks.map( ( block ) => {\n\t\t\treturn {\n\t\t\t\t...block,\n\t\t\t\tattributes: updateAttributes( block.attributes ),\n\t\t\t\tinnerBlocks: updateBlocksAttributes( block.innerBlocks ),\n\t\t\t};\n\t\t} );\n\t}\n\n\t// We need to go through all block attributes deeply and update the\n\t// footnote anchor numbering (textContent) to match the new order.\n\tconst newBlocks = updateBlocksAttributes( blocks );\n\n\toldFootnotes = {\n\t\t...oldFootnotes,\n\t\t...footnotes.reduce( ( acc, fn ) => {\n\t\t\tif ( ! newOrder.includes( fn.id ) ) {\n\t\t\t\tacc[ fn.id ] = fn;\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, {} ),\n\t};\n\n\treturn {\n\t\tmeta: {\n\t\t\t...meta,\n\t\t\tfootnotes: JSON.stringify( newFootnotes ),\n\t\t},\n\t\tblocks: newBlocks,\n\t};\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return
|
|
7
|
-
}({});
|
|
8
|
-
|
|
1
|
+
var Status = /* @__PURE__ */ ((Status2) => {
|
|
2
|
+
Status2["Idle"] = "IDLE";
|
|
3
|
+
Status2["Resolving"] = "RESOLVING";
|
|
4
|
+
Status2["Error"] = "ERROR";
|
|
5
|
+
Status2["Success"] = "SUCCESS";
|
|
6
|
+
return Status2;
|
|
7
|
+
})(Status || {});
|
|
8
|
+
export {
|
|
9
|
+
Status
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/hooks/constants.ts"],
|
|
4
|
+
"sourcesContent": ["export const enum Status {\n\tIdle = 'IDLE',\n\tResolving = 'RESOLVING',\n\tError = 'ERROR',\n\tSuccess = 'SUCCESS',\n}\n"],
|
|
5
|
+
"mappings": "AAAO,IAAW,SAAX,kBAAWA,YAAX;AACN,EAAAA,QAAA,UAAO;AACP,EAAAA,QAAA,eAAY;AACZ,EAAAA,QAAA,WAAQ;AACR,EAAAA,QAAA,aAAU;AAJO,SAAAA;AAAA,GAAA;",
|
|
6
|
+
"names": ["Status"]
|
|
7
|
+
}
|
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import {
|
|
2
|
+
default as default2,
|
|
3
|
+
__experimentalUseEntityRecord
|
|
4
|
+
} from "./use-entity-record";
|
|
5
|
+
import {
|
|
6
|
+
default as default3,
|
|
7
|
+
__experimentalUseEntityRecords
|
|
8
|
+
} from "./use-entity-records";
|
|
9
|
+
import {
|
|
10
|
+
default as default4,
|
|
11
|
+
__experimentalUseResourcePermissions
|
|
12
|
+
} from "./use-resource-permissions";
|
|
13
|
+
import { default as default5 } from "./use-entity-block-editor";
|
|
14
|
+
import { default as default6 } from "./use-entity-id";
|
|
15
|
+
import { default as default7 } from "./use-entity-prop";
|
|
16
|
+
export {
|
|
17
|
+
__experimentalUseEntityRecord,
|
|
18
|
+
__experimentalUseEntityRecords,
|
|
19
|
+
__experimentalUseResourcePermissions,
|
|
20
|
+
default5 as useEntityBlockEditor,
|
|
21
|
+
default6 as useEntityId,
|
|
22
|
+
default7 as useEntityProp,
|
|
23
|
+
default2 as useEntityRecord,
|
|
24
|
+
default3 as useEntityRecords,
|
|
25
|
+
default4 as useResourcePermissions
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/hooks/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { WithPermissions } from './use-entity-records';\n\n/**\n * Utility type that adds permissions to any record type.\n */\nexport type { WithPermissions };\nexport {\n\tdefault as useEntityRecord,\n\t__experimentalUseEntityRecord,\n} from './use-entity-record';\nexport {\n\tdefault as useEntityRecords,\n\t__experimentalUseEntityRecords,\n} from './use-entity-records';\nexport {\n\tdefault as useResourcePermissions,\n\t__experimentalUseResourcePermissions,\n} from './use-resource-permissions';\nexport { default as useEntityBlockEditor } from './use-entity-block-editor';\nexport { default as useEntityId } from './use-entity-id';\nexport { default as useEntityProp } from './use-entity-prop';\n"],
|
|
5
|
+
"mappings": "AASA;AAAA,EACY,WAAXA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACY,WAAXA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACY,WAAXA;AAAA,EACA;AAAA,OACM;AACP,SAAoB,WAAXA,gBAAuC;AAChD,SAAoB,WAAXA,gBAA8B;AACvC,SAAoB,WAAXA,gBAAgC;",
|
|
6
|
+
"names": ["default"]
|
|
7
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export default memoize;
|
|
8
|
-
//# sourceMappingURL=memoize.js.map
|
|
1
|
+
import memoize from "memize";
|
|
2
|
+
var memoize_default = memoize;
|
|
3
|
+
export {
|
|
4
|
+
memoize_default as default
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=memoize.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/hooks/memoize.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n// re-export due to restrictive esModuleInterop setting\nexport default memoize;\n"],
|
|
5
|
+
"mappings": "AAGA,OAAO,aAAa;AAGpB,IAAO,kBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|