@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
package/build/fetch/index.js
CHANGED
|
@@ -1,41 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var fetch_exports = {};
|
|
30
|
+
__export(fetch_exports, {
|
|
31
|
+
__experimentalFetchLinkSuggestions: () => import_experimental_fetch_link_suggestions.default,
|
|
32
|
+
__experimentalFetchUrlData: () => import_experimental_fetch_url_data.default,
|
|
33
|
+
fetchBlockPatterns: () => fetchBlockPatterns
|
|
18
34
|
});
|
|
19
|
-
exports
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
/**
|
|
25
|
-
* External dependencies
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* WordPress dependencies
|
|
30
|
-
*/
|
|
31
|
-
|
|
35
|
+
module.exports = __toCommonJS(fetch_exports);
|
|
36
|
+
var import_change_case = require("change-case");
|
|
37
|
+
var import_api_fetch = __toESM(require("@wordpress/api-fetch"));
|
|
38
|
+
var import_experimental_fetch_link_suggestions = __toESM(require("./__experimental-fetch-link-suggestions"));
|
|
39
|
+
var import_experimental_fetch_url_data = __toESM(require("./__experimental-fetch-url-data"));
|
|
32
40
|
async function fetchBlockPatterns() {
|
|
33
|
-
const restPatterns = await (0,
|
|
34
|
-
path:
|
|
41
|
+
const restPatterns = await (0, import_api_fetch.default)({
|
|
42
|
+
path: "/wp/v2/block-patterns/patterns"
|
|
35
43
|
});
|
|
36
44
|
if (!restPatterns) {
|
|
37
45
|
return [];
|
|
38
46
|
}
|
|
39
|
-
return restPatterns.map(
|
|
47
|
+
return restPatterns.map(
|
|
48
|
+
(pattern) => Object.fromEntries(
|
|
49
|
+
Object.entries(pattern).map(([key, value]) => [
|
|
50
|
+
(0, import_change_case.camelCase)(key),
|
|
51
|
+
value
|
|
52
|
+
])
|
|
53
|
+
)
|
|
54
|
+
);
|
|
40
55
|
}
|
|
41
|
-
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
__experimentalFetchLinkSuggestions,
|
|
59
|
+
__experimentalFetchUrlData,
|
|
60
|
+
fetchBlockPatterns
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
package/build/fetch/index.js.map
CHANGED
|
@@ -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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAA0B;AAK1B,uBAAqB;AAErB,iDAA8D;AAC9D,yCAAsD;AAEtD,eAAsB,qBAAqB;AAC1C,QAAM,eAAe,UAAM,iBAAAA,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,YACpD,8BAAW,GAAI;AAAA,QACf;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AACD;",
|
|
6
|
+
"names": ["apiFetch"]
|
|
7
|
+
}
|
|
@@ -1,31 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var get_footnotes_order_exports = {};
|
|
30
|
+
__export(get_footnotes_order_exports, {
|
|
31
|
+
default: () => getFootnotesOrder
|
|
6
32
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const cache = new WeakMap();
|
|
33
|
+
module.exports = __toCommonJS(get_footnotes_order_exports);
|
|
34
|
+
var import_get_rich_text_values_cached = __toESM(require("./get-rich-text-values-cached"));
|
|
35
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
14
36
|
function getBlockFootnotesOrder(block) {
|
|
15
37
|
if (!cache.has(block)) {
|
|
16
38
|
const order = [];
|
|
17
|
-
for (const value of (0,
|
|
39
|
+
for (const value of (0, import_get_rich_text_values_cached.default)(block)) {
|
|
18
40
|
if (!value) {
|
|
19
41
|
continue;
|
|
20
42
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
type,
|
|
25
|
-
attributes
|
|
26
|
-
}) => {
|
|
27
|
-
if (type === 'core/footnote') {
|
|
28
|
-
order.push(attributes['data-fn']);
|
|
43
|
+
value.replacements.forEach(({ type, attributes }) => {
|
|
44
|
+
if (type === "core/footnote") {
|
|
45
|
+
order.push(attributes["data-fn"]);
|
|
29
46
|
}
|
|
30
47
|
});
|
|
31
48
|
}
|
|
@@ -34,10 +51,6 @@ function getBlockFootnotesOrder(block) {
|
|
|
34
51
|
return cache.get(block);
|
|
35
52
|
}
|
|
36
53
|
function getFootnotesOrder(blocks) {
|
|
37
|
-
// We can only separate getting order from blocks at the root level. For
|
|
38
|
-
// deeper inner blocks, this will not work since it's possible to have both
|
|
39
|
-
// inner blocks and block attributes, so order needs to be computed from the
|
|
40
|
-
// Edit functions as a whole.
|
|
41
54
|
return blocks.flatMap(getBlockFootnotesOrder);
|
|
42
55
|
}
|
|
43
|
-
//# sourceMappingURL=get-footnotes-order.js.map
|
|
56
|
+
//# 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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yCAAoC;AAEpC,MAAM,QAAQ,oBAAI,QAAQ;AAE1B,SAAS,uBAAwB,OAAQ;AACxC,MAAK,CAAE,MAAM,IAAK,KAAM,GAAI;AAC3B,UAAM,QAAQ,CAAC;AACf,eAAY,aAAS,mCAAAA,SAAyB,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": ["getRichTextValuesCached"]
|
|
7
|
+
}
|
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var get_rich_text_values_cached_exports = {};
|
|
20
|
+
__export(get_rich_text_values_cached_exports, {
|
|
21
|
+
default: () => getRichTextValuesCached
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
/**
|
|
10
|
-
* WordPress dependencies
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
// TODO: The following line should have been:
|
|
18
|
-
//
|
|
19
|
-
// const unlockedApis = unlock( blockEditorPrivateApis );
|
|
20
|
-
//
|
|
21
|
-
// But there are hidden circular dependencies in RNMobile code, specifically in
|
|
22
|
-
// certain native components in the `components` package that depend on
|
|
23
|
-
// `block-editor`. What follows is a workaround that defers the `unlock` call
|
|
24
|
-
// to prevent native code from failing.
|
|
25
|
-
//
|
|
26
|
-
// Fix once https://github.com/WordPress/gutenberg/issues/52692 is closed.
|
|
23
|
+
module.exports = __toCommonJS(get_rich_text_values_cached_exports);
|
|
24
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
25
|
+
var import_lock_unlock = require("../lock-unlock");
|
|
27
26
|
let unlockedApis;
|
|
28
|
-
const cache = new WeakMap();
|
|
27
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
29
28
|
function getRichTextValuesCached(block) {
|
|
30
29
|
if (!unlockedApis) {
|
|
31
|
-
unlockedApis = (0,
|
|
30
|
+
unlockedApis = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
|
|
32
31
|
}
|
|
33
32
|
if (!cache.has(block)) {
|
|
34
33
|
const values = unlockedApis.getRichTextValues([block]);
|
|
@@ -36,4 +35,4 @@ function getRichTextValuesCached(block) {
|
|
|
36
35
|
}
|
|
37
36
|
return cache.get(block);
|
|
38
37
|
}
|
|
39
|
-
//# sourceMappingURL=get-rich-text-values-cached.js.map
|
|
38
|
+
//# 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": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAsD;AAKtD,yBAAuB;AAYvB,IAAI;AAEJ,MAAM,QAAQ,oBAAI,QAAQ;AAEX,SAAR,wBAA0C,OAAQ;AACxD,MAAK,CAAE,cAAe;AACrB,uBAAe,2BAAQ,oBAAAA,WAAuB;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": ["blockEditorPrivateApis"]
|
|
7
|
+
}
|
package/build/footnotes/index.js
CHANGED
|
@@ -1,93 +1,105 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var footnotes_exports = {};
|
|
30
|
+
__export(footnotes_exports, {
|
|
31
|
+
updateFootnotesFromMeta: () => updateFootnotesFromMeta
|
|
6
32
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
/**
|
|
11
|
-
* WordPress dependencies
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Internal dependencies
|
|
16
|
-
*/
|
|
17
|
-
|
|
33
|
+
module.exports = __toCommonJS(footnotes_exports);
|
|
34
|
+
var import_rich_text = require("@wordpress/rich-text");
|
|
35
|
+
var import_get_footnotes_order = __toESM(require("./get-footnotes-order"));
|
|
18
36
|
let oldFootnotes = {};
|
|
19
37
|
function updateFootnotesFromMeta(blocks, meta) {
|
|
20
|
-
const output = {
|
|
21
|
-
blocks
|
|
22
|
-
};
|
|
38
|
+
const output = { blocks };
|
|
23
39
|
if (!meta) {
|
|
24
40
|
return output;
|
|
25
41
|
}
|
|
26
|
-
|
|
27
|
-
// If meta.footnotes is empty, it means the meta is not registered.
|
|
28
|
-
if (meta.footnotes === undefined) {
|
|
42
|
+
if (meta.footnotes === void 0) {
|
|
29
43
|
return output;
|
|
30
44
|
}
|
|
31
|
-
const newOrder = (0,
|
|
45
|
+
const newOrder = (0, import_get_footnotes_order.default)(blocks);
|
|
32
46
|
const footnotes = meta.footnotes ? JSON.parse(meta.footnotes) : [];
|
|
33
|
-
const currentOrder = footnotes.map(fn => fn.id);
|
|
34
|
-
if (currentOrder.join(
|
|
47
|
+
const currentOrder = footnotes.map((fn) => fn.id);
|
|
48
|
+
if (currentOrder.join("") === newOrder.join("")) {
|
|
35
49
|
return output;
|
|
36
50
|
}
|
|
37
|
-
const newFootnotes = newOrder.map(
|
|
38
|
-
id
|
|
39
|
-
|
|
40
|
-
|
|
51
|
+
const newFootnotes = newOrder.map(
|
|
52
|
+
(fnId) => footnotes.find((fn) => fn.id === fnId) || oldFootnotes[fnId] || {
|
|
53
|
+
id: fnId,
|
|
54
|
+
content: ""
|
|
55
|
+
}
|
|
56
|
+
);
|
|
41
57
|
function updateAttributes(attributes) {
|
|
42
|
-
|
|
43
|
-
if (!attributes || Array.isArray(attributes) || typeof attributes !== 'object') {
|
|
58
|
+
if (!attributes || Array.isArray(attributes) || typeof attributes !== "object") {
|
|
44
59
|
return attributes;
|
|
45
60
|
}
|
|
46
|
-
attributes = {
|
|
47
|
-
...attributes
|
|
48
|
-
};
|
|
61
|
+
attributes = { ...attributes };
|
|
49
62
|
for (const key in attributes) {
|
|
50
63
|
const value = attributes[key];
|
|
51
64
|
if (Array.isArray(value)) {
|
|
52
65
|
attributes[key] = value.map(updateAttributes);
|
|
53
66
|
continue;
|
|
54
67
|
}
|
|
55
|
-
|
|
56
|
-
// To do, remove support for string values?
|
|
57
|
-
if (typeof value !== 'string' && !(value instanceof _richText.RichTextData)) {
|
|
68
|
+
if (typeof value !== "string" && !(value instanceof import_rich_text.RichTextData)) {
|
|
58
69
|
continue;
|
|
59
70
|
}
|
|
60
|
-
const richTextValue = typeof value ===
|
|
71
|
+
const richTextValue = typeof value === "string" ? import_rich_text.RichTextData.fromHTMLString(value) : new import_rich_text.RichTextData(value);
|
|
61
72
|
let hasFootnotes = false;
|
|
62
|
-
richTextValue.replacements.forEach(replacement => {
|
|
63
|
-
if (replacement.type ===
|
|
64
|
-
const id = replacement.attributes[
|
|
73
|
+
richTextValue.replacements.forEach((replacement) => {
|
|
74
|
+
if (replacement.type === "core/footnote") {
|
|
75
|
+
const id = replacement.attributes["data-fn"];
|
|
65
76
|
const index = newOrder.indexOf(id);
|
|
66
|
-
|
|
67
|
-
const countValue = (0, _richText.create)({
|
|
77
|
+
const countValue = (0, import_rich_text.create)({
|
|
68
78
|
html: replacement.innerHTML
|
|
69
79
|
});
|
|
70
80
|
countValue.text = String(index + 1);
|
|
71
|
-
countValue.formats = Array.from(
|
|
72
|
-
length: countValue.text.length
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
countValue.formats = Array.from(
|
|
82
|
+
{ length: countValue.text.length },
|
|
83
|
+
() => countValue.formats[0]
|
|
84
|
+
);
|
|
85
|
+
countValue.replacements = Array.from(
|
|
86
|
+
{ length: countValue.text.length },
|
|
87
|
+
() => countValue.replacements[0]
|
|
88
|
+
);
|
|
89
|
+
replacement.innerHTML = (0, import_rich_text.toHTMLString)({
|
|
78
90
|
value: countValue
|
|
79
91
|
});
|
|
80
92
|
hasFootnotes = true;
|
|
81
93
|
}
|
|
82
94
|
});
|
|
83
95
|
if (hasFootnotes) {
|
|
84
|
-
attributes[key] = typeof value ===
|
|
96
|
+
attributes[key] = typeof value === "string" ? richTextValue.toHTMLString() : richTextValue;
|
|
85
97
|
}
|
|
86
98
|
}
|
|
87
99
|
return attributes;
|
|
88
100
|
}
|
|
89
101
|
function updateBlocksAttributes(__blocks) {
|
|
90
|
-
return __blocks.map(block => {
|
|
102
|
+
return __blocks.map((block) => {
|
|
91
103
|
return {
|
|
92
104
|
...block,
|
|
93
105
|
attributes: updateAttributes(block.attributes),
|
|
@@ -95,9 +107,6 @@ function updateFootnotesFromMeta(blocks, meta) {
|
|
|
95
107
|
};
|
|
96
108
|
});
|
|
97
109
|
}
|
|
98
|
-
|
|
99
|
-
// We need to go through all block attributes deeply and update the
|
|
100
|
-
// footnote anchor numbering (textContent) to match the new order.
|
|
101
110
|
const newBlocks = updateBlocksAttributes(blocks);
|
|
102
111
|
oldFootnotes = {
|
|
103
112
|
...oldFootnotes,
|
|
@@ -116,4 +125,8 @@ function updateFootnotesFromMeta(blocks, meta) {
|
|
|
116
125
|
blocks: newBlocks
|
|
117
126
|
};
|
|
118
127
|
}
|
|
119
|
-
|
|
128
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
129
|
+
0 && (module.exports = {
|
|
130
|
+
updateFootnotesFromMeta
|
|
131
|
+
});
|
|
132
|
+
//# 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": ["getFootnotesOrder"]
|
|
7
|
+
}
|
package/build/hooks/constants.js
CHANGED
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var constants_exports = {};
|
|
20
|
+
__export(constants_exports, {
|
|
21
|
+
Status: () => Status
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return
|
|
13
|
-
}({});
|
|
14
|
-
|
|
23
|
+
module.exports = __toCommonJS(constants_exports);
|
|
24
|
+
var Status = /* @__PURE__ */ ((Status2) => {
|
|
25
|
+
Status2["Idle"] = "IDLE";
|
|
26
|
+
Status2["Resolving"] = "RESOLVING";
|
|
27
|
+
Status2["Error"] = "ERROR";
|
|
28
|
+
Status2["Success"] = "SUCCESS";
|
|
29
|
+
return Status2;
|
|
30
|
+
})(Status || {});
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
Status
|
|
34
|
+
});
|
|
35
|
+
//# 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": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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
|
+
}
|