@wordpress/editor 14.45.0 → 14.45.2-next.v.202605131032.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +12 -0
- package/build/components/collab-sidebar/index.cjs +42 -25
- package/build/components/collab-sidebar/index.cjs.map +2 -2
- package/build/components/collab-sidebar/note-thread.cjs +19 -9
- package/build/components/collab-sidebar/note-thread.cjs.map +2 -2
- package/build/components/collab-sidebar/notes.cjs +8 -6
- package/build/components/collab-sidebar/notes.cjs.map +2 -2
- package/build/components/collab-sidebar/utils.cjs +24 -9
- package/build/components/collab-sidebar/utils.cjs.map +2 -2
- package/build/components/collaborators-presence/index.cjs +0 -10
- package/build/components/collaborators-presence/index.cjs.map +3 -3
- package/build/components/collaborators-presence/list.cjs +0 -10
- package/build/components/collaborators-presence/list.cjs.map +3 -3
- package/build/components/post-last-revision/index.cjs +5 -0
- package/build/components/post-last-revision/index.cjs.map +2 -2
- package/build/components/post-publish-panel/index.cjs +112 -124
- package/build/components/post-publish-panel/index.cjs.map +3 -3
- package/build/components/post-revisions-preview/block-diff.cjs +91 -23
- package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
- package/build/components/post-revisions-preview/diff-markers.cjs +3 -2
- package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
- package/build/components/post-revisions-preview/revisions-slider.cjs +98 -50
- package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
- package/build/store/private-actions.cjs +21 -0
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +93 -42
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +15 -0
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/components/collab-sidebar/index.mjs +42 -25
- package/build-module/components/collab-sidebar/index.mjs.map +2 -2
- package/build-module/components/collab-sidebar/note-thread.mjs +24 -10
- package/build-module/components/collab-sidebar/note-thread.mjs.map +2 -2
- package/build-module/components/collab-sidebar/notes.mjs +8 -6
- package/build-module/components/collab-sidebar/notes.mjs.map +2 -2
- package/build-module/components/collab-sidebar/utils.mjs +22 -8
- package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
- package/build-module/components/collaborators-presence/index.mjs +0 -10
- package/build-module/components/collaborators-presence/index.mjs.map +3 -3
- package/build-module/components/collaborators-presence/list.mjs +0 -10
- package/build-module/components/collaborators-presence/list.mjs.map +3 -3
- package/build-module/components/post-last-revision/index.mjs +5 -0
- package/build-module/components/post-last-revision/index.mjs.map +2 -2
- package/build-module/components/post-publish-panel/index.mjs +120 -129
- package/build-module/components/post-publish-panel/index.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/block-diff.mjs +91 -23
- package/build-module/components/post-revisions-preview/block-diff.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/diff-markers.mjs +3 -2
- package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/revisions-slider.mjs +101 -53
- package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +20 -0
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +95 -43
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +14 -0
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/style-rtl.css +398 -33
- package/build-style/style.css +398 -33
- package/build-types/bindings/api.d.ts +1 -1
- package/build-types/bindings/api.d.ts.map +1 -1
- package/build-types/bindings/pattern-overrides.d.ts +8 -5
- package/build-types/bindings/pattern-overrides.d.ts.map +1 -1
- package/build-types/bindings/post-data.d.ts +8 -5
- package/build-types/bindings/post-data.d.ts.map +1 -1
- package/build-types/bindings/post-meta.d.ts +10 -7
- package/build-types/bindings/post-meta.d.ts.map +1 -1
- package/build-types/bindings/term-data.d.ts +9 -6
- package/build-types/bindings/term-data.d.ts.map +1 -1
- package/build-types/components/autocompleters/index.d.ts +2 -2
- package/build-types/components/autocompleters/index.d.ts.map +1 -1
- package/build-types/components/autocompleters/link.d.ts +6 -10
- package/build-types/components/autocompleters/link.d.ts.map +1 -1
- package/build-types/components/autocompleters/user.d.ts +7 -12
- package/build-types/components/autocompleters/user.d.ts.map +1 -1
- package/build-types/components/autosave-monitor/index.d.ts +28 -4
- package/build-types/components/autosave-monitor/index.d.ts.map +1 -1
- package/build-types/components/block-removal-warnings/index.d.ts +3 -0
- package/build-types/components/block-removal-warnings/index.d.ts.map +1 -1
- package/build-types/components/block-settings-menu/plugin-block-settings-menu-item.d.ts +7 -7
- package/build-types/components/block-settings-menu/plugin-block-settings-menu-item.d.ts.map +1 -1
- package/build-types/components/block-visibility/index.d.ts.map +1 -1
- package/build-types/components/blog-title/index.d.ts.map +1 -1
- package/build-types/components/character-count/index.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/add-note-menu-item.d.ts +2 -2
- package/build-types/components/collab-sidebar/add-note-menu-item.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/add-note.d.ts +2 -2
- package/build-types/components/collab-sidebar/add-note.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/board-store.d.ts +1 -1
- package/build-types/components/collab-sidebar/board-store.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/constants.d.ts +3 -3
- package/build-types/components/collab-sidebar/constants.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/floating-container.d.ts +3 -3
- package/build-types/components/collab-sidebar/floating-container.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/hooks.d.ts +7 -7
- package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/note-byline.d.ts +2 -2
- package/build-types/components/collab-sidebar/note-byline.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/note-card.d.ts +3 -3
- package/build-types/components/collab-sidebar/note-card.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/note-form.d.ts +4 -4
- package/build-types/components/collab-sidebar/note-form.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts +2 -2
- package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/note-thread.d.ts +5 -5
- package/build-types/components/collab-sidebar/note-thread.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/note.d.ts +4 -4
- package/build-types/components/collab-sidebar/note.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/notes.d.ts +2 -2
- package/build-types/components/collab-sidebar/notes.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/utils.d.ts +17 -24
- package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/cursor-dom-utils.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/cursor-registry.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/index.d.ts +4 -1
- package/build-types/components/collaborators-overlay/index.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/overlay.d.ts +1 -1
- package/build-types/components/collaborators-overlay/overlay.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/avatar/component.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/avatar-group/component.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/index.d.ts +1 -2
- package/build-types/components/collaborators-presence/index.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/list.d.ts +1 -2
- package/build-types/components/collaborators-presence/list.d.ts.map +1 -1
- package/build-types/components/collapsible-block-toolbar/index.d.ts.map +1 -1
- package/build-types/components/commands/index.d.ts.map +1 -1
- package/build-types/components/deprecated.d.ts +82 -53
- package/build-types/components/deprecated.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts +3 -3
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- package/build-types/components/document-bar/useEditedSectionDetails.d.ts.map +1 -1
- package/build-types/components/document-outline/check.d.ts +2 -2
- package/build-types/components/document-outline/check.d.ts.map +1 -1
- package/build-types/components/document-outline/index.d.ts +2 -2
- package/build-types/components/document-outline/index.d.ts.map +1 -1
- package/build-types/components/document-outline/item.d.ts +5 -5
- package/build-types/components/document-outline/item.d.ts.map +1 -1
- package/build-types/components/document-tools/index.d.ts +1 -1
- package/build-types/components/document-tools/index.d.ts.map +1 -1
- package/build-types/components/editor/index.d.ts +7 -7
- package/build-types/components/editor/index.d.ts.map +1 -1
- package/build-types/components/editor-history/redo.d.ts +11 -2
- package/build-types/components/editor-history/redo.d.ts.map +1 -1
- package/build-types/components/editor-history/undo.d.ts +11 -2
- package/build-types/components/editor-history/undo.d.ts.map +1 -1
- package/build-types/components/editor-interface/index.d.ts +5 -5
- package/build-types/components/editor-interface/index.d.ts.map +1 -1
- package/build-types/components/editor-notices/index.d.ts +1 -1
- package/build-types/components/editor-notices/index.d.ts.map +1 -1
- package/build-types/components/editor-snackbars/index.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/entity-record-item.d.ts +1 -1
- package/build-types/components/entities-saved-states/entity-record-item.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/entity-type-list.d.ts +2 -2
- package/build-types/components/entities-saved-states/entity-type-list.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/hooks/use-is-dirty.d.ts +10 -1
- package/build-types/components/entities-saved-states/hooks/use-is-dirty.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/index.d.ts +4 -4
- package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
- package/build-types/components/error-boundary/index.d.ts +18 -8
- package/build-types/components/error-boundary/index.d.ts.map +1 -1
- package/build-types/components/global-keyboard-shortcuts/index.d.ts.map +1 -1
- package/build-types/components/global-keyboard-shortcuts/register-shortcuts.d.ts +1 -1
- package/build-types/components/global-keyboard-shortcuts/register-shortcuts.d.ts.map +1 -1
- package/build-types/components/global-styles/block-link.d.ts +1 -1
- package/build-types/components/global-styles/block-link.d.ts.map +1 -1
- package/build-types/components/global-styles/header.d.ts +2 -2
- package/build-types/components/global-styles/header.d.ts.map +1 -1
- package/build-types/components/global-styles/hooks.d.ts +3 -3
- package/build-types/components/global-styles/hooks.d.ts.map +1 -1
- package/build-types/components/global-styles/index.d.ts +3 -3
- package/build-types/components/global-styles/index.d.ts.map +1 -1
- package/build-types/components/global-styles/menu.d.ts +2 -2
- package/build-types/components/global-styles/menu.d.ts.map +1 -1
- package/build-types/components/global-styles-provider/index.d.ts +1 -1
- package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
- package/build-types/components/global-styles-renderer/index.d.ts +1 -1
- package/build-types/components/global-styles-renderer/index.d.ts.map +1 -1
- package/build-types/components/global-styles-sidebar/default-sidebar.d.ts +6 -6
- package/build-types/components/global-styles-sidebar/default-sidebar.d.ts.map +1 -1
- package/build-types/components/global-styles-sidebar/index.d.ts.map +1 -1
- package/build-types/components/global-styles-sidebar/welcome-guide-image.d.ts +1 -1
- package/build-types/components/global-styles-sidebar/welcome-guide-image.d.ts.map +1 -1
- package/build-types/components/global-styles-sidebar/welcome-guide.d.ts.map +1 -1
- package/build-types/components/header/back-button.d.ts +3 -3
- package/build-types/components/header/back-button.d.ts.map +1 -1
- package/build-types/components/header/header-skeleton.d.ts +5 -5
- package/build-types/components/header/header-skeleton.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts +2 -2
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/index.d.ts +94 -91
- package/build-types/components/index.d.ts.map +1 -1
- package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
- package/build-types/components/keyboard-shortcut-help-modal/config.d.ts +3 -3
- package/build-types/components/keyboard-shortcut-help-modal/config.d.ts.map +1 -1
- package/build-types/components/keyboard-shortcut-help-modal/dynamic-shortcut.d.ts +1 -1
- package/build-types/components/keyboard-shortcut-help-modal/dynamic-shortcut.d.ts.map +1 -1
- package/build-types/components/keyboard-shortcut-help-modal/index.d.ts +1 -1
- package/build-types/components/keyboard-shortcut-help-modal/index.d.ts.map +1 -1
- package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts +3 -3
- package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts.map +1 -1
- package/build-types/components/list-view-sidebar/index.d.ts.map +1 -1
- package/build-types/components/list-view-sidebar/list-view-outline.d.ts.map +1 -1
- package/build-types/components/local-autosave-monitor/index.d.ts +12 -0
- package/build-types/components/local-autosave-monitor/index.d.ts.map +1 -1
- package/build-types/components/media/index.d.ts +2 -2
- package/build-types/components/media/index.d.ts.map +1 -1
- package/build-types/components/media/media-editor-modal.d.ts.map +1 -1
- package/build-types/components/media/metadata-panel.d.ts.map +1 -1
- package/build-types/components/media/preview.d.ts.map +1 -1
- package/build-types/components/media-categories/index.d.ts +11 -4
- package/build-types/components/media-categories/index.d.ts.map +1 -1
- package/build-types/components/mode-switcher/index.d.ts +1 -1
- package/build-types/components/mode-switcher/index.d.ts.map +1 -1
- package/build-types/components/more-menu/copy-content-menu-item.d.ts.map +1 -1
- package/build-types/components/more-menu/index.d.ts.map +1 -1
- package/build-types/components/more-menu/tools-more-menu-group.d.ts +2 -2
- package/build-types/components/more-menu/tools-more-menu-group.d.ts.map +1 -1
- package/build-types/components/more-menu/view-more-menu-group.d.ts +2 -2
- package/build-types/components/more-menu/view-more-menu-group.d.ts.map +1 -1
- package/build-types/components/page-attributes/check.d.ts +3 -3
- package/build-types/components/page-attributes/check.d.ts.map +1 -1
- package/build-types/components/page-attributes/order.d.ts +1 -1
- package/build-types/components/page-attributes/order.d.ts.map +1 -1
- package/build-types/components/page-attributes/panel.d.ts +1 -1
- package/build-types/components/page-attributes/panel.d.ts.map +1 -1
- package/build-types/components/page-attributes/parent.d.ts +3 -3
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/pattern-duplicate-modal/index.d.ts +1 -1
- package/build-types/components/pattern-duplicate-modal/index.d.ts.map +1 -1
- package/build-types/components/pattern-overrides-panel/index.d.ts.map +1 -1
- package/build-types/components/pattern-rename-modal/index.d.ts +1 -1
- package/build-types/components/pattern-rename-modal/index.d.ts.map +1 -1
- package/build-types/components/plugin-document-setting-panel/index.d.ts +8 -61
- package/build-types/components/plugin-document-setting-panel/index.d.ts.map +1 -1
- package/build-types/components/plugin-more-menu-item/index.d.ts +5 -5
- package/build-types/components/plugin-more-menu-item/index.d.ts.map +1 -1
- package/build-types/components/plugin-post-publish-panel/index.d.ts +9 -40
- package/build-types/components/plugin-post-publish-panel/index.d.ts.map +1 -1
- package/build-types/components/plugin-post-status-info/index.d.ts +6 -47
- package/build-types/components/plugin-post-status-info/index.d.ts.map +1 -1
- package/build-types/components/plugin-pre-publish-panel/index.d.ts +9 -43
- package/build-types/components/plugin-pre-publish-panel/index.d.ts.map +1 -1
- package/build-types/components/plugin-preview-menu-item/index.d.ts +5 -5
- package/build-types/components/plugin-preview-menu-item/index.d.ts.map +1 -1
- package/build-types/components/plugin-sidebar/index.d.ts +4 -4
- package/build-types/components/plugin-sidebar/index.d.ts.map +1 -1
- package/build-types/components/plugin-sidebar-more-menu-item/index.d.ts +3 -3
- package/build-types/components/plugin-sidebar-more-menu-item/index.d.ts.map +1 -1
- package/build-types/components/post-actions/actions.d.ts +3 -3
- package/build-types/components/post-actions/actions.d.ts.map +1 -1
- package/build-types/components/post-actions/index.d.ts +4 -4
- package/build-types/components/post-actions/index.d.ts.map +1 -1
- package/build-types/components/post-actions/set-as-homepage.d.ts +2 -2
- package/build-types/components/post-actions/set-as-homepage.d.ts.map +1 -1
- package/build-types/components/post-actions/set-as-posts-page.d.ts +2 -2
- package/build-types/components/post-actions/set-as-posts-page.d.ts.map +1 -1
- package/build-types/components/post-author/check.d.ts +2 -2
- package/build-types/components/post-author/check.d.ts.map +1 -1
- package/build-types/components/post-author/combobox.d.ts.map +1 -1
- package/build-types/components/post-author/constants.d.ts +10 -8
- package/build-types/components/post-author/constants.d.ts.map +1 -1
- package/build-types/components/post-author/hook.d.ts +1 -1
- package/build-types/components/post-author/hook.d.ts.map +1 -1
- package/build-types/components/post-author/index.d.ts +2 -2
- package/build-types/components/post-author/index.d.ts.map +1 -1
- package/build-types/components/post-author/panel.d.ts +1 -1
- package/build-types/components/post-author/panel.d.ts.map +1 -1
- package/build-types/components/post-author/select.d.ts.map +1 -1
- package/build-types/components/post-card-panel/index.d.ts +7 -7
- package/build-types/components/post-card-panel/index.d.ts.map +1 -1
- package/build-types/components/post-comments/index.d.ts +6 -1
- package/build-types/components/post-comments/index.d.ts.map +1 -1
- package/build-types/components/post-content-information/index.d.ts +1 -1
- package/build-types/components/post-content-information/index.d.ts.map +1 -1
- package/build-types/components/post-discussion/panel.d.ts +1 -1
- package/build-types/components/post-discussion/panel.d.ts.map +1 -1
- package/build-types/components/post-excerpt/check.d.ts +3 -3
- package/build-types/components/post-excerpt/check.d.ts.map +1 -1
- package/build-types/components/post-excerpt/index.d.ts +3 -3
- package/build-types/components/post-excerpt/index.d.ts.map +1 -1
- package/build-types/components/post-excerpt/panel.d.ts +2 -2
- package/build-types/components/post-excerpt/panel.d.ts.map +1 -1
- package/build-types/components/post-excerpt/plugin.d.ts +6 -43
- package/build-types/components/post-excerpt/plugin.d.ts.map +1 -1
- package/build-types/components/post-featured-image/check.d.ts +3 -3
- package/build-types/components/post-featured-image/check.d.ts.map +1 -1
- package/build-types/components/post-featured-image/index.d.ts +15 -0
- package/build-types/components/post-featured-image/index.d.ts.map +1 -1
- package/build-types/components/post-featured-image/panel.d.ts +1 -1
- package/build-types/components/post-featured-image/panel.d.ts.map +1 -1
- package/build-types/components/post-fields/index.d.ts +1 -1
- package/build-types/components/post-fields/index.d.ts.map +1 -1
- package/build-types/components/post-format/check.d.ts +2 -2
- package/build-types/components/post-format/check.d.ts.map +1 -1
- package/build-types/components/post-format/index.d.ts +12 -12
- package/build-types/components/post-format/index.d.ts.map +1 -1
- package/build-types/components/post-format/panel.d.ts +2 -2
- package/build-types/components/post-format/panel.d.ts.map +1 -1
- package/build-types/components/post-last-edited-panel/index.d.ts.map +1 -1
- package/build-types/components/post-last-revision/check.d.ts +3 -3
- package/build-types/components/post-last-revision/check.d.ts.map +1 -1
- package/build-types/components/post-last-revision/index.d.ts +3 -3
- package/build-types/components/post-last-revision/index.d.ts.map +1 -1
- package/build-types/components/post-last-revision/panel.d.ts +2 -2
- package/build-types/components/post-last-revision/panel.d.ts.map +1 -1
- package/build-types/components/post-locked-modal/index.d.ts +11 -5
- package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
- package/build-types/components/post-panel-row/index.d.ts +1 -1
- package/build-types/components/post-panel-row/index.d.ts.map +1 -1
- package/build-types/components/post-panel-section/index.d.ts +2 -2
- package/build-types/components/post-panel-section/index.d.ts.map +1 -1
- package/build-types/components/post-pending-status/check.d.ts +3 -3
- package/build-types/components/post-pending-status/check.d.ts.map +1 -1
- package/build-types/components/post-pending-status/index.d.ts +1 -1
- package/build-types/components/post-pending-status/index.d.ts.map +1 -1
- package/build-types/components/post-pingbacks/index.d.ts +7 -1
- package/build-types/components/post-pingbacks/index.d.ts.map +1 -1
- package/build-types/components/post-preview-button/index.d.ts +2 -2
- package/build-types/components/post-preview-button/index.d.ts.map +1 -1
- package/build-types/components/post-publish-button/index.d.ts +5 -5
- package/build-types/components/post-publish-button/index.d.ts.map +1 -1
- package/build-types/components/post-publish-button/label.d.ts.map +1 -1
- package/build-types/components/post-publish-button/post-publish-button-or-toggle.d.ts +1 -1
- package/build-types/components/post-publish-button/post-publish-button-or-toggle.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/index.d.ts +17 -13
- package/build-types/components/post-publish-panel/index.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-category-panel.d.ts +1 -1
- package/build-types/components/post-publish-panel/maybe-category-panel.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-post-format-panel.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-tags-panel.d.ts +1 -1
- package/build-types/components/post-publish-panel/maybe-tags-panel.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-upload-media.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/media-util.d.ts +2 -2
- package/build-types/components/post-publish-panel/media-util.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/postpublish.d.ts +2 -2
- package/build-types/components/post-publish-panel/postpublish.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/prepublish.d.ts +1 -1
- package/build-types/components/post-publish-panel/prepublish.d.ts.map +1 -1
- package/build-types/components/post-revisions-panel/index.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/block-diff.d.ts +1 -1
- package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/diff-format-types.d.ts +2 -2
- package/build-types/components/post-revisions-preview/diff-format-types.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/diff-markers.d.ts +1 -1
- package/build-types/components/post-revisions-preview/diff-markers.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/index.d.ts +2 -2
- package/build-types/components/post-revisions-preview/index.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/preserve-client-ids.d.ts +1 -1
- package/build-types/components/post-revisions-preview/preserve-client-ids.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/revisions-canvas.d.ts +1 -1
- package/build-types/components/post-revisions-preview/revisions-canvas.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/revisions-header.d.ts +2 -2
- package/build-types/components/post-revisions-preview/revisions-header.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/revisions-slider.d.ts +3 -3
- package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
- package/build-types/components/post-saved-state/index.d.ts +1 -1
- package/build-types/components/post-saved-state/index.d.ts.map +1 -1
- package/build-types/components/post-schedule/check.d.ts +2 -2
- package/build-types/components/post-schedule/check.d.ts.map +1 -1
- package/build-types/components/post-schedule/index.d.ts +3 -3
- package/build-types/components/post-schedule/index.d.ts.map +1 -1
- package/build-types/components/post-schedule/label.d.ts +4 -4
- package/build-types/components/post-schedule/label.d.ts.map +1 -1
- package/build-types/components/post-schedule/panel.d.ts +1 -1
- package/build-types/components/post-schedule/panel.d.ts.map +1 -1
- package/build-types/components/post-status/index.d.ts +2 -2
- package/build-types/components/post-status/index.d.ts.map +1 -1
- package/build-types/components/post-sticky/check.d.ts +2 -2
- package/build-types/components/post-sticky/check.d.ts.map +1 -1
- package/build-types/components/post-sticky/index.d.ts +1 -1
- package/build-types/components/post-sticky/index.d.ts.map +1 -1
- package/build-types/components/post-sticky/panel.d.ts +1 -1
- package/build-types/components/post-sticky/panel.d.ts.map +1 -1
- package/build-types/components/post-switch-to-draft-button/index.d.ts +1 -1
- package/build-types/components/post-switch-to-draft-button/index.d.ts.map +1 -1
- package/build-types/components/post-sync-status/index.d.ts +1 -1
- package/build-types/components/post-sync-status/index.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/check.d.ts +2 -2
- package/build-types/components/post-taxonomies/check.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts +4 -4
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +6 -6
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/index.d.ts +9 -1
- package/build-types/components/post-taxonomies/index.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/most-used-terms.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/panel.d.ts +1 -1
- package/build-types/components/post-taxonomies/panel.d.ts.map +1 -1
- package/build-types/components/post-template/block-theme.d.ts.map +1 -1
- package/build-types/components/post-template/classic-theme.d.ts +8 -1
- package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
- package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
- package/build-types/components/post-template/create-new-template.d.ts.map +1 -1
- package/build-types/components/post-template/hooks.d.ts +5 -5
- package/build-types/components/post-template/hooks.d.ts.map +1 -1
- package/build-types/components/post-template/panel.d.ts +1 -1
- package/build-types/components/post-template/panel.d.ts.map +1 -1
- package/build-types/components/post-template/reset-default-template.d.ts.map +1 -1
- package/build-types/components/post-template/swap-template-button.d.ts +1 -1
- package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
- package/build-types/components/post-text-editor/index.d.ts +1 -1
- package/build-types/components/post-text-editor/index.d.ts.map +1 -1
- package/build-types/components/post-title/constants.d.ts +2 -2
- package/build-types/components/post-title/constants.d.ts.map +1 -1
- package/build-types/components/post-title/index.d.ts +9 -1
- package/build-types/components/post-title/index.d.ts.map +1 -1
- package/build-types/components/post-title/post-title-raw.d.ts +1 -1
- package/build-types/components/post-title/use-post-title-focus.d.ts.map +1 -1
- package/build-types/components/post-title/use-post-title.d.ts.map +1 -1
- package/build-types/components/post-transform-panel/hooks.d.ts +1 -1
- package/build-types/components/post-transform-panel/hooks.d.ts.map +1 -1
- package/build-types/components/post-transform-panel/index.d.ts.map +1 -1
- package/build-types/components/post-trash/check.d.ts +2 -2
- package/build-types/components/post-trash/check.d.ts.map +1 -1
- package/build-types/components/post-trash/index.d.ts +1 -1
- package/build-types/components/post-trash/index.d.ts.map +1 -1
- package/build-types/components/post-type-support-check/index.d.ts +3 -3
- package/build-types/components/post-type-support-check/index.d.ts.map +1 -1
- package/build-types/components/post-url/check.d.ts +2 -2
- package/build-types/components/post-url/check.d.ts.map +1 -1
- package/build-types/components/post-url/index.d.ts +1 -1
- package/build-types/components/post-url/index.d.ts.map +1 -1
- package/build-types/components/post-url/label.d.ts +2 -2
- package/build-types/components/post-url/label.d.ts.map +1 -1
- package/build-types/components/post-url/panel.d.ts +1 -1
- package/build-types/components/post-url/panel.d.ts.map +1 -1
- package/build-types/components/post-view-link/index.d.ts.map +1 -1
- package/build-types/components/post-visibility/check.d.ts +1 -1
- package/build-types/components/post-visibility/check.d.ts.map +1 -1
- package/build-types/components/post-visibility/index.d.ts +1 -1
- package/build-types/components/post-visibility/index.d.ts.map +1 -1
- package/build-types/components/post-visibility/label.d.ts +1 -1
- package/build-types/components/post-visibility/label.d.ts.map +1 -1
- package/build-types/components/post-visibility/utils.d.ts +1 -1
- package/build-types/components/post-visibility/utils.d.ts.map +1 -1
- package/build-types/components/posts-per-page/index.d.ts.map +1 -1
- package/build-types/components/preferences-modal/enable-panel.d.ts.map +1 -1
- package/build-types/components/preferences-modal/enable-plugin-document-setting-panel.d.ts +4 -5
- package/build-types/components/preferences-modal/enable-plugin-document-setting-panel.d.ts.map +1 -1
- package/build-types/components/preferences-modal/enable-publish-sidebar.d.ts.map +1 -1
- package/build-types/components/preferences-modal/index.d.ts +3 -0
- package/build-types/components/preferences-modal/index.d.ts.map +1 -1
- package/build-types/components/preview-dropdown/index.d.ts +1 -1
- package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
- package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts +33 -33
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/provider/navigation-block-editing-mode.d.ts.map +1 -1
- package/build-types/components/provider/use-auto-switch-editor-sidebars.d.ts +1 -1
- package/build-types/components/provider/use-auto-switch-editor-sidebars.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/provider/use-hide-blocks-from-inserter.d.ts +1 -1
- package/build-types/components/provider/use-hide-blocks-from-inserter.d.ts.map +1 -1
- package/build-types/components/provider/use-post-content-block-types.d.ts.map +1 -1
- package/build-types/components/provider/use-revision-blocks.d.ts +1 -1
- package/build-types/components/provider/use-revision-blocks.d.ts.map +1 -1
- package/build-types/components/provider/use-upload-save-lock.d.ts.map +1 -1
- package/build-types/components/provider/with-registry-provider.d.ts +1 -1
- package/build-types/components/provider/with-registry-provider.d.ts.map +1 -1
- package/build-types/components/resizable-editor/index.d.ts +2 -2
- package/build-types/components/resizable-editor/index.d.ts.map +1 -1
- package/build-types/components/resizable-editor/resize-handle.d.ts.map +1 -1
- package/build-types/components/revision-author-panel/index.d.ts.map +1 -1
- package/build-types/components/revision-block-diff/index.d.ts.map +1 -1
- package/build-types/components/revision-created-panel/index.d.ts.map +1 -1
- package/build-types/components/revision-diff-panel/index.d.ts.map +1 -1
- package/build-types/components/revision-fields-diff/index.d.ts.map +1 -1
- package/build-types/components/save-publish-panels/index.d.ts +7 -7
- package/build-types/components/save-publish-panels/index.d.ts.map +1 -1
- package/build-types/components/sidebar/constants.d.ts +4 -4
- package/build-types/components/sidebar/constants.d.ts.map +1 -1
- package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
- package/build-types/components/sidebar/header.d.ts +1 -1
- package/build-types/components/sidebar/index.d.ts +3 -3
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/components/sidebar/post-revision-summary.d.ts.map +1 -1
- package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
- package/build-types/components/site-discussion/index.d.ts.map +1 -1
- package/build-types/components/start-page-options/index.d.ts +1 -1
- package/build-types/components/start-page-options/index.d.ts.map +1 -1
- package/build-types/components/start-template-options/index.d.ts.map +1 -1
- package/build-types/components/style-book/categories.d.ts +3 -0
- package/build-types/components/style-book/categories.d.ts.map +1 -1
- package/build-types/components/style-book/color-examples.d.ts.map +1 -1
- package/build-types/components/style-book/duotone-examples.d.ts.map +1 -1
- package/build-types/components/style-book/index.d.ts +19 -8
- package/build-types/components/style-book/index.d.ts.map +1 -1
- package/build-types/components/styles-canvas/index.d.ts +2 -2
- package/build-types/components/styles-canvas/index.d.ts.map +1 -1
- package/build-types/components/styles-canvas/revisions.d.ts +1 -1
- package/build-types/components/styles-canvas/style-book.d.ts +1 -1
- package/build-types/components/table-of-contents/index.d.ts +11 -1
- package/build-types/components/table-of-contents/index.d.ts.map +1 -1
- package/build-types/components/table-of-contents/panel.d.ts +1 -1
- package/build-types/components/table-of-contents/panel.d.ts.map +1 -1
- package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -1
- package/build-types/components/template-actions-panel/classic-theme-content.d.ts.map +1 -1
- package/build-types/components/template-actions-panel/index.d.ts.map +1 -1
- package/build-types/components/template-content-panel/index.d.ts.map +1 -1
- package/build-types/components/template-part-content-panel/index.d.ts.map +1 -1
- package/build-types/components/template-part-menu-items/convert-to-regular.d.ts.map +1 -1
- package/build-types/components/template-part-menu-items/convert-to-template-part.d.ts +1 -1
- package/build-types/components/template-part-menu-items/convert-to-template-part.d.ts.map +1 -1
- package/build-types/components/template-part-menu-items/index.d.ts.map +1 -1
- package/build-types/components/template-validation-notice/index.d.ts.map +1 -1
- package/build-types/components/text-editor/index.d.ts.map +1 -1
- package/build-types/components/theme-support-check/index.d.ts +2 -2
- package/build-types/components/theme-support-check/index.d.ts.map +1 -1
- package/build-types/components/time-to-read/index.d.ts +1 -1
- package/build-types/components/time-to-read/index.d.ts.map +1 -1
- package/build-types/components/unsaved-changes-warning/index.d.ts +1 -1
- package/build-types/components/unsaved-changes-warning/index.d.ts.map +1 -1
- package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts +1 -1
- package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts.map +1 -1
- package/build-types/components/visual-editor/index.d.ts +4 -4
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/components/visual-editor/use-edit-content-only-section-exit.d.ts +1 -1
- package/build-types/components/visual-editor/use-edit-content-only-section-exit.d.ts.map +1 -1
- package/build-types/components/visual-editor/use-padding-appender.d.ts +1 -1
- package/build-types/components/visual-editor/use-padding-appender.d.ts.map +1 -1
- package/build-types/components/visual-editor/use-select-nearest-editable-block.d.ts +1 -1
- package/build-types/components/visual-editor/use-select-nearest-editable-block.d.ts.map +1 -1
- package/build-types/components/visual-editor/use-zoom-out-mode-exit.d.ts +1 -1
- package/build-types/components/visual-editor/use-zoom-out-mode-exit.d.ts.map +1 -1
- package/build-types/components/word-count/index.d.ts +1 -1
- package/build-types/components/word-count/index.d.ts.map +1 -1
- package/build-types/components/zoom-out-toggle/index.d.ts +3 -3
- package/build-types/components/zoom-out-toggle/index.d.ts.map +1 -1
- package/build-types/dataviews/api.d.ts +6 -6
- package/build-types/dataviews/api.d.ts.map +1 -1
- package/build-types/dataviews/fields/content-preview/index.d.ts.map +1 -1
- package/build-types/dataviews/store/private-actions.d.ts +5 -5
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/dataviews/store/reducer.d.ts +2 -2
- package/build-types/dataviews/store/reducer.d.ts.map +1 -1
- package/build-types/hooks/custom-sources-backwards-compatibility.d.ts +3 -9
- package/build-types/hooks/custom-sources-backwards-compatibility.d.ts.map +1 -1
- package/build-types/hooks/index.d.ts +10 -1
- package/build-types/hooks/index.d.ts.map +1 -1
- package/build-types/hooks/pattern-overrides.d.ts +1 -1
- package/build-types/hooks/pattern-overrides.d.ts.map +1 -1
- package/build-types/hooks/use-global-styles-output.d.ts +2 -2
- package/build-types/hooks/use-global-styles-output.d.ts.map +1 -1
- package/build-types/index.d.ts +10 -5
- package/build-types/index.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts +1 -2
- package/build-types/lock-unlock.d.ts.map +1 -1
- package/build-types/private-apis.d.ts +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/store/actions.d.ts +330 -116
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/constants.d.ts.map +1 -1
- package/build-types/store/defaults.d.ts +1 -1
- package/build-types/store/defaults.d.ts.map +1 -1
- package/build-types/store/index.d.ts +77 -9
- package/build-types/store/index.d.ts.map +1 -1
- package/build-types/store/local-autosave.d.ts +3 -3
- package/build-types/store/local-autosave.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +106 -46
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +96 -68
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +47 -52
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +422 -429
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/store/utils/is-template-revertable.d.ts.map +1 -1
- package/build-types/store/utils/notice-builder.d.ts +3 -3
- package/build-types/store/utils/notice-builder.d.ts.map +1 -1
- package/build-types/utils/get-item-title.d.ts +1 -1
- package/build-types/utils/get-item-title.d.ts.map +1 -1
- package/build-types/utils/get-template-info.d.ts +11 -4
- package/build-types/utils/get-template-info.d.ts.map +1 -1
- package/build-types/utils/get-template-part-icon.d.ts +1 -1
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
- package/build-types/utils/index.d.ts +6 -3
- package/build-types/utils/index.d.ts.map +1 -1
- package/build-types/utils/media-finalize/index.d.ts.map +1 -1
- package/build-types/utils/media-sideload/index.d.ts +1 -1
- package/build-types/utils/media-sideload/index.d.ts.map +1 -1
- package/build-types/utils/media-upload/index.d.ts +1 -1
- package/build-types/utils/media-upload/index.d.ts.map +1 -1
- package/build-types/utils/media-upload/on-success.d.ts.map +1 -1
- package/build-types/utils/pageTypeBadge.d.ts.map +1 -1
- package/build-types/utils/search-templates.d.ts +1 -1
- package/build-types/utils/search-templates.d.ts.map +1 -1
- package/build-types/utils/set-nested-value.d.ts.map +1 -1
- package/build-types/utils/terms.d.ts +19 -4
- package/build-types/utils/terms.d.ts.map +1 -1
- package/build-types/utils/url.d.ts +1 -1
- package/build-types/utils/url.d.ts.map +1 -1
- package/package.json +48 -48
- package/src/components/block-visibility/style.scss +2 -2
- package/src/components/collab-sidebar/index.js +48 -36
- package/src/components/collab-sidebar/note-thread.js +28 -10
- package/src/components/collab-sidebar/notes.js +9 -6
- package/src/components/collab-sidebar/style.scss +4 -0
- package/src/components/collab-sidebar/utils.js +41 -14
- package/src/components/collaborators-presence/index.tsx +0 -2
- package/src/components/collaborators-presence/list.tsx +0 -2
- package/src/components/post-last-revision/index.js +5 -0
- package/src/components/post-publish-panel/index.js +149 -156
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +11 -26
- package/src/components/post-publish-panel/test/index.js +41 -23
- package/src/components/post-revisions-preview/block-diff.js +165 -41
- package/src/components/post-revisions-preview/diff-markers.js +12 -9
- package/src/components/post-revisions-preview/revisions-slider.js +130 -71
- package/src/components/post-revisions-preview/style.scss +3 -3
- package/src/components/post-revisions-preview/test/block-diff.js +133 -4
- package/src/components/post-template/style.scss +1 -1
- package/src/components/start-page-options/style.scss +2 -2
- package/src/components/start-template-options/style.scss +2 -2
- package/src/store/private-actions.js +34 -0
- package/src/store/private-selectors.js +127 -51
- package/src/store/reducer.js +21 -0
- package/src/store/selectors.js +6 -0
- package/src/store/test/private-selectors.js +107 -1
- package/src/style.scss +2 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-revisions-preview/block-diff.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { diffArrays } from 'diff/lib/diff/array';\nimport { diffWords } from 'diff/lib/diff/word';\n\n/**\n * WordPress dependencies\n */\nimport { parse as grammarParse } from '@wordpress/block-serialization-default-parser';\nimport {\n\tprivateApis as blocksPrivateApis,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport {\n\tRichTextData,\n\tcreate,\n\tslice,\n\tconcat,\n\tapplyFormat,\n} from '@wordpress/rich-text';\nimport { __, _n, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { parseRawBlock } = unlock( blocksPrivateApis );\n\n/**\n * Safely stringifies a value for display and comparison.\n *\n * @param {*} value The value to stringify.\n * @return {string} The stringified value.\n */\nfunction stringifyValue( value ) {\n\tif ( value === null || value === undefined ) {\n\t\treturn '';\n\t}\n\tif ( typeof value === 'object' ) {\n\t\treturn JSON.stringify( value, null, 2 );\n\t}\n\treturn String( value );\n}\n\n/**\n * Calculate text similarity using word diff (semantically meaningful).\n * Returns ratio of unchanged words to total words.\n *\n * @param {string} text1 First text to compare.\n * @param {string} text2 Second text to compare.\n * @return {number} Similarity score between 0 and 1.\n */\nfunction textSimilarity( text1, text2 ) {\n\tif ( ! text1 && ! text2 ) {\n\t\treturn 1;\n\t}\n\tif ( ! text1 || ! text2 ) {\n\t\treturn 0;\n\t}\n\n\tconst changes = diffWords( text1, text2 );\n\tconst unchanged = changes\n\t\t.filter( ( c ) => ! c.added && ! c.removed )\n\t\t.reduce( ( sum, c ) => sum + c.value.length, 0 );\n\tconst total = Math.max( text1.length, text2.length );\n\treturn total > 0 ? unchanged / total : 0;\n}\n\n/**\n * Post-process diff result to pair similar removed/added blocks as modifications.\n * This catches modifications that LCS missed due to content changes.\n *\n * @param {Array} blocks Raw blocks with diff status.\n * @return {Array} Blocks with similar pairs converted to modifications.\n */\nfunction pairSimilarBlocks( blocks ) {\n\tconst removed = [];\n\tconst added = [];\n\n\t// Separate blocks by status, tracking original indices.\n\tblocks.forEach( ( block, index ) => {\n\t\tconst status = block.__revisionDiffStatus?.status;\n\t\tif ( status === 'removed' ) {\n\t\t\tremoved.push( { block, index } );\n\t\t} else if ( status === 'added' ) {\n\t\t\tadded.push( { block, index } );\n\t\t}\n\t} );\n\n\t// If no removed or no added, nothing to pair.\n\tif ( removed.length === 0 || added.length === 0 ) {\n\t\treturn blocks;\n\t}\n\n\tconst pairedRemoved = new Set(); // Indices of removed blocks that were paired.\n\tconst modifications = new Map(); // Map from added block index to modified block.\n\tconst SIMILARITY_THRESHOLD = 0.3;\n\n\t// For each removed block, find best matching added block.\n\tfor ( const rem of removed ) {\n\t\tlet bestMatch = null;\n\t\tlet bestScore = 0;\n\n\t\tfor ( const add of added ) {\n\t\t\tif ( modifications.has( add.index ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( add.block.blockName !== rem.block.blockName ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst score = textSimilarity(\n\t\t\t\trem.block.innerHTML || '',\n\t\t\t\tadd.block.innerHTML || ''\n\t\t\t);\n\t\t\t// If content is identical (score=1), only pair if attrs differ.\n\t\t\t// Otherwise identical blocks are just position swaps, not modifications.\n\t\t\tconst attrsMatch =\n\t\t\t\tJSON.stringify( rem.block.attrs ) ===\n\t\t\t\tJSON.stringify( add.block.attrs );\n\t\t\tif (\n\t\t\t\tscore > bestScore &&\n\t\t\t\tscore > SIMILARITY_THRESHOLD &&\n\t\t\t\t( score < 1 || ! attrsMatch )\n\t\t\t) {\n\t\t\t\tbestScore = score;\n\t\t\t\tbestMatch = add;\n\t\t\t}\n\t\t}\n\n\t\tif ( bestMatch ) {\n\t\t\tpairedRemoved.add( rem.index );\n\n\t\t\t// Create modified block with previous content stored.\n\t\t\tmodifications.set( bestMatch.index, {\n\t\t\t\t...bestMatch.block,\n\t\t\t\t__revisionDiffStatus: { status: 'modified' },\n\t\t\t\t__previousRawBlock: rem.block,\n\t\t\t} );\n\t\t}\n\t}\n\n\t// Rebuild result: filter out paired removed, replace paired added with modified.\n\treturn blocks\n\t\t.map( ( block, index ) => {\n\t\t\t// Skip paired removed blocks.\n\t\t\tif ( pairedRemoved.has( index ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t// Replace paired added blocks with modified version.\n\t\t\tif ( modifications.has( index ) ) {\n\t\t\t\treturn modifications.get( index );\n\t\t\t}\n\t\t\treturn block;\n\t\t} )\n\t\t.filter( Boolean );\n}\n\n/**\n * Diff raw block arrays using LCS, recursively handling innerBlocks.\n * Detects modifications when exactly 1 block is removed and 1 is added\n * with the same blockName (1:1 replacement = modification).\n *\n * @param {Array} currentRaw Current revision's raw blocks.\n * @param {Array} previousRaw Previous revision's raw blocks.\n * @return {Array} Merged raw blocks with diff status injected.\n */\nfunction diffRawBlocks( currentRaw, previousRaw ) {\n\tconst createBlockSignature = ( rawBlock ) =>\n\t\tJSON.stringify( {\n\t\t\tname: rawBlock.blockName,\n\t\t\tattrs: rawBlock.attrs,\n\t\t\t// Use innerContent filtered to non-null and non-whitespace-only strings.\n\t\t\t// This excludes whitespace between inner blocks which changes based on count.\n\t\t\thtml: ( rawBlock.innerContent || [] ).filter(\n\t\t\t\t( c ) => c !== null && c.trim() !== ''\n\t\t\t),\n\t\t} );\n\tconst currentSigs = currentRaw.map( createBlockSignature );\n\tconst previousSigs = previousRaw.map( createBlockSignature );\n\n\tconst diff = diffArrays( previousSigs, currentSigs );\n\n\tconst result = [];\n\tlet currIdx = 0;\n\tlet prevIdx = 0;\n\n\tfor ( const part of diff ) {\n\t\tif ( part.added ) {\n\t\t\tfor ( let i = 0; i < part.count; i++ ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\t...currentRaw[ currIdx++ ],\n\t\t\t\t\t__revisionDiffStatus: { status: 'added' },\n\t\t\t\t} );\n\t\t\t}\n\t\t} else if ( part.removed ) {\n\t\t\tfor ( let i = 0; i < part.count; i++ ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\t...previousRaw[ prevIdx++ ],\n\t\t\t\t\t__revisionDiffStatus: { status: 'removed' },\n\t\t\t\t} );\n\t\t\t}\n\t\t} else {\n\t\t\t// Matched blocks - recursively diff their innerBlocks.\n\t\t\tfor ( let i = 0; i < part.count; i++ ) {\n\t\t\t\tconst currBlock = currentRaw[ currIdx++ ];\n\t\t\t\tconst prevBlock = previousRaw[ prevIdx++ ];\n\n\t\t\t\t// Recursively diff inner blocks.\n\t\t\t\tconst diffedInnerBlocks = diffRawBlocks(\n\t\t\t\t\tcurrBlock.innerBlocks || [],\n\t\t\t\t\tprevBlock.innerBlocks || []\n\t\t\t\t);\n\n\t\t\t\tresult.push( {\n\t\t\t\t\t...currBlock,\n\t\t\t\t\tinnerBlocks: diffedInnerBlocks,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n\n\t// Post-process to pair similar removed/added blocks as modifications.\n\treturn pairSimilarBlocks( result );\n}\n\n/**\n * Check if formatting has changed at specific character indices.\n *\n * @param {Array} currentFormats Current formats array.\n * @param {Array} previousFormats Previous formats array.\n * @param {number} currentIndex Character index in current.\n * @param {number} previousIndex Character index in previous.\n * @return {boolean} True if formatting changed at these indices.\n */\nfunction hasFormatChangedAtIndex(\n\tcurrentFormats,\n\tpreviousFormats,\n\tcurrentIndex,\n\tpreviousIndex\n) {\n\tconst currFmts = currentFormats[ currentIndex ] || [];\n\tconst prevFmts = previousFormats[ previousIndex ] || [];\n\n\tif ( currFmts.length !== prevFmts.length ) {\n\t\treturn true;\n\t}\n\n\t// Check if each format in current exists in previous\n\tfor ( const fmt of currFmts ) {\n\t\tconst match = prevFmts.find(\n\t\t\t( pf ) =>\n\t\t\t\tpf.type === fmt.type &&\n\t\t\t\tJSON.stringify( pf.attributes ) ===\n\t\t\t\t\tJSON.stringify( fmt.attributes )\n\t\t);\n\t\tif ( ! match ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Analyze what formatting changed between two character positions.\n * Returns both the change type (for styling) and a description (for tooltip).\n *\n * @param {Array} currentFormats Current formats array.\n * @param {Array} previousFormats Previous formats array.\n * @param {number} currIdx Character index in current.\n * @param {number} prevIdx Character index in previous.\n * @return {{ type: 'added'|'removed'|'changed', description: string }} Change info.\n */\nfunction describeFormatChange(\n\tcurrentFormats,\n\tpreviousFormats,\n\tcurrIdx,\n\tprevIdx\n) {\n\tconst currFmts = currentFormats[ currIdx ] || [];\n\tconst prevFmts = previousFormats[ prevIdx ] || [];\n\n\tlet addedCount = 0;\n\tlet removedCount = 0;\n\tlet changedCount = 0;\n\n\t// Find added formats and attribute changes\n\tfor ( const fmt of currFmts ) {\n\t\tconst match = prevFmts.find( ( pf ) => pf.type === fmt.type );\n\t\tif ( ! match ) {\n\t\t\taddedCount++;\n\t\t} else if (\n\t\t\tJSON.stringify( fmt.attributes ) !==\n\t\t\tJSON.stringify( match.attributes )\n\t\t) {\n\t\t\tchangedCount++;\n\t\t}\n\t}\n\n\t// Find removed formats\n\tfor ( const fmt of prevFmts ) {\n\t\tconst match = currFmts.find( ( cf ) => cf.type === fmt.type );\n\t\tif ( ! match ) {\n\t\t\tremovedCount++;\n\t\t}\n\t}\n\n\t// Determine primary change type for styling\n\tif ( addedCount > 0 && removedCount === 0 && changedCount === 0 ) {\n\t\treturn {\n\t\t\ttype: 'added',\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %d: number of formats added */\n\t\t\t\t_n( '%d format added', '%d formats added', addedCount ),\n\t\t\t\taddedCount\n\t\t\t),\n\t\t};\n\t}\n\tif ( removedCount > 0 && addedCount === 0 && changedCount === 0 ) {\n\t\treturn {\n\t\t\ttype: 'removed',\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %d: number of formats removed */\n\t\t\t\t_n( '%d format removed', '%d formats removed', removedCount ),\n\t\t\t\tremovedCount\n\t\t\t),\n\t\t};\n\t}\n\n\t// Mixed or attribute-only changes\n\tconst parts = [];\n\tif ( addedCount > 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of formats added */\n\t\t\t\t_n( '%d format added', '%d formats added', addedCount ),\n\t\t\t\taddedCount\n\t\t\t)\n\t\t);\n\t}\n\tif ( removedCount > 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of formats removed */\n\t\t\t\t_n( '%d format removed', '%d formats removed', removedCount ),\n\t\t\t\tremovedCount\n\t\t\t)\n\t\t);\n\t}\n\tif ( changedCount > 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of formats changed */\n\t\t\t\t_n( '%d format changed', '%d formats changed', changedCount ),\n\t\t\t\tchangedCount\n\t\t\t)\n\t\t);\n\t}\n\treturn {\n\t\ttype: 'changed',\n\t\tdescription: parts.join( ', ' ) || __( 'Formatting changed' ),\n\t};\n}\n\n/**\n * Apply inline diff formatting comparing two RichTextData values.\n * - Text changes: apply revision/diff-removed and revision/diff-added formats\n * - Format-only changes (text unchanged): apply revision/diff-format-changed format\n *\n * @param {RichTextData} currentRichText Current revision's rich text.\n * @param {RichTextData} previousRichText Previous revision's rich text.\n * @return {RichTextData} New rich text with diff formatting applied.\n */\nfunction applyRichTextDiff( currentRichText, previousRichText ) {\n\tconst currentText = currentRichText.toPlainText();\n\tconst previousText = previousRichText.toPlainText();\n\n\t// Diff the plain text (words for cleaner output)\n\tconst textDiff = diffWords( previousText, currentText );\n\n\tlet result = create( { text: '' } );\n\tlet currentIdx = 0;\n\tlet previousIdx = 0;\n\n\tfor ( const part of textDiff ) {\n\t\tif ( part.removed ) {\n\t\t\t// Text deleted - slice from PREVIOUS, apply <del>\n\t\t\tconst removedSlice = slice(\n\t\t\t\tpreviousRichText,\n\t\t\t\tpreviousIdx,\n\t\t\t\tpreviousIdx + part.value.length\n\t\t\t);\n\t\t\tconst formatted = applyFormat(\n\t\t\t\tremovedSlice,\n\t\t\t\t{\n\t\t\t\t\ttype: 'revision/diff-removed',\n\t\t\t\t\tattributes: { title: __( 'Removed' ) },\n\t\t\t\t},\n\t\t\t\t0,\n\t\t\t\tpart.value.length\n\t\t\t);\n\t\t\tresult = concat( result, formatted );\n\t\t\tpreviousIdx += part.value.length;\n\t\t} else if ( part.added ) {\n\t\t\t// Text added - slice from CURRENT, apply <ins>\n\t\t\tconst addedSlice = slice(\n\t\t\t\tcurrentRichText,\n\t\t\t\tcurrentIdx,\n\t\t\t\tcurrentIdx + part.value.length\n\t\t\t);\n\t\t\tconst formatted = applyFormat(\n\t\t\t\taddedSlice,\n\t\t\t\t{\n\t\t\t\t\ttype: 'revision/diff-added',\n\t\t\t\t\tattributes: { title: __( 'Added' ) },\n\t\t\t\t},\n\t\t\t\t0,\n\t\t\t\tpart.value.length\n\t\t\t);\n\t\t\tresult = concat( result, formatted );\n\t\t\tcurrentIdx += part.value.length;\n\t\t} else {\n\t\t\t// Text unchanged - check formatting at each character position.\n\t\t\t// Only apply <mark> to specific ranges where formatting differs.\n\t\t\tconst currentFormats = currentRichText.formats || [];\n\t\t\tconst previousFormats = previousRichText.formats || [];\n\t\t\tconst len = part.value.length;\n\n\t\t\t// Helper to check format change at offset within this unchanged part.\n\t\t\tconst checkFormatChanged = ( offset ) =>\n\t\t\t\thasFormatChangedAtIndex(\n\t\t\t\t\tcurrentFormats,\n\t\t\t\t\tpreviousFormats,\n\t\t\t\t\tcurrentIdx + offset,\n\t\t\t\t\tpreviousIdx + offset\n\t\t\t\t);\n\n\t\t\t// Find ranges of characters grouped by whether format changed.\n\t\t\tlet rangeStart = 0;\n\t\t\tlet rangeFormatChanged = checkFormatChanged( 0 );\n\n\t\t\tfor ( let i = 1; i <= len; i++ ) {\n\t\t\t\tconst formatChanged = i < len && checkFormatChanged( i );\n\n\t\t\t\t// When format-changed status changes or we reach the end, emit range.\n\t\t\t\tif ( i === len || formatChanged !== rangeFormatChanged ) {\n\t\t\t\t\tconst rangeSlice = slice(\n\t\t\t\t\t\tcurrentRichText,\n\t\t\t\t\t\tcurrentIdx + rangeStart,\n\t\t\t\t\t\tcurrentIdx + i\n\t\t\t\t\t);\n\n\t\t\t\t\tif ( rangeFormatChanged ) {\n\t\t\t\t\t\t// Get type and description of what changed\n\t\t\t\t\t\tconst { type, description } = describeFormatChange(\n\t\t\t\t\t\t\tcurrentFormats,\n\t\t\t\t\t\t\tpreviousFormats,\n\t\t\t\t\t\t\tcurrentIdx + rangeStart,\n\t\t\t\t\t\t\tpreviousIdx + rangeStart\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Map change type to format type for styling\n\t\t\t\t\t\tconst formatType = {\n\t\t\t\t\t\t\tadded: 'revision/diff-format-added',\n\t\t\t\t\t\t\tremoved: 'revision/diff-format-removed',\n\t\t\t\t\t\t\tchanged: 'revision/diff-format-changed',\n\t\t\t\t\t\t}[ type ];\n\n\t\t\t\t\t\tconst marked = applyFormat(\n\t\t\t\t\t\t\trangeSlice,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: formatType,\n\t\t\t\t\t\t\t\tattributes: { title: description },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\ti - rangeStart\n\t\t\t\t\t\t);\n\t\t\t\t\t\tresult = concat( result, marked );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult = concat( result, rangeSlice );\n\t\t\t\t\t}\n\n\t\t\t\t\trangeStart = i;\n\t\t\t\t\trangeFormatChanged = formatChanged;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcurrentIdx += part.value.length;\n\t\t\tpreviousIdx += part.value.length;\n\t\t}\n\t}\n\n\treturn new RichTextData( result );\n}\n\n/**\n * Apply diffs to a modified block's attributes.\n * - Rich-text attributes: applies inline diff formatting (ins/del marks).\n * - Other attributes: computes word-level diffs for the sidebar panel.\n *\n * @param {Object} currentBlock Current parsed block.\n * @param {Object} previousBlock Previous parsed block.\n * @param {Object} diffStatus The __revisionDiffStatus object to attach changedAttributes to.\n */\nfunction applyDiffToBlock( currentBlock, previousBlock, diffStatus ) {\n\tconst blockType = getBlockType( currentBlock.name );\n\tif ( ! blockType ) {\n\t\treturn;\n\t}\n\n\tconst changedAttributes = {};\n\n\tfor ( const [ attrName, attrDef ] of Object.entries(\n\t\tblockType.attributes\n\t) ) {\n\t\tif ( attrDef.source === 'rich-text' ) {\n\t\t\tconst currentRichText = currentBlock.attributes[ attrName ];\n\t\t\tconst previousRichText = previousBlock.attributes[ attrName ];\n\t\t\tif (\n\t\t\t\tcurrentRichText instanceof RichTextData &&\n\t\t\t\tpreviousRichText instanceof RichTextData\n\t\t\t) {\n\t\t\t\tcurrentBlock.attributes[ attrName ] = applyRichTextDiff(\n\t\t\t\t\tcurrentRichText,\n\t\t\t\t\tpreviousRichText\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tconst currStr = stringifyValue(\n\t\t\t\tcurrentBlock.attributes[ attrName ]\n\t\t\t);\n\t\t\tconst prevStr = stringifyValue(\n\t\t\t\tpreviousBlock.attributes[ attrName ]\n\t\t\t);\n\t\t\tif ( currStr !== prevStr ) {\n\t\t\t\tchangedAttributes[ attrName ] = diffWords( prevStr, currStr );\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( Object.keys( changedAttributes ).length > 0 ) {\n\t\tdiffStatus.changedAttributes = changedAttributes;\n\t}\n}\n\n/**\n * Recursively apply diff status and rich text diff to blocks in the tree.\n * Copies __revisionDiffStatus from raw blocks to parsed blocks and applies\n * rich text diffs to modified blocks.\n *\n * @param {Object} parsedBlock Parsed block (with inner blocks).\n * @param {Object} rawBlock Raw block (with __revisionDiffStatus and __previousRawBlock).\n */\nfunction applyDiffRecursively( parsedBlock, rawBlock ) {\n\t// Copy diff status from raw block to parsed block.\n\tif ( rawBlock.__revisionDiffStatus ) {\n\t\t// Apply diffs if this block is modified and has a previous raw block.\n\t\tif (\n\t\t\trawBlock.__revisionDiffStatus.status === 'modified' &&\n\t\t\trawBlock.__previousRawBlock\n\t\t) {\n\t\t\tconst previousParsed = parseRawBlock( rawBlock.__previousRawBlock );\n\t\t\tif ( previousParsed ) {\n\t\t\t\tapplyDiffToBlock(\n\t\t\t\t\tparsedBlock,\n\t\t\t\t\tpreviousParsed,\n\t\t\t\t\trawBlock.__revisionDiffStatus\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tparsedBlock.__revisionDiffStatus = rawBlock.__revisionDiffStatus;\n\t\t// Also store in attributes so it survives block-editor store normalization.\n\t\tparsedBlock.attributes.__revisionDiffStatus =\n\t\t\trawBlock.__revisionDiffStatus;\n\t}\n\n\t// Recursively process inner blocks.\n\tif ( parsedBlock.innerBlocks && rawBlock.innerBlocks ) {\n\t\tfor ( let i = 0; i < parsedBlock.innerBlocks.length; i++ ) {\n\t\t\tconst parsedInner = parsedBlock.innerBlocks[ i ];\n\t\t\tconst rawInner = rawBlock.innerBlocks[ i ];\n\t\t\tif ( parsedInner && rawInner ) {\n\t\t\t\tapplyDiffRecursively( parsedInner, rawInner );\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Diff two revision contents at the grammar level.\n *\n * @param {string} currentContent Current revision's raw content.\n * @param {string} previousContent Previous revision's raw content.\n * @return {Array} Array of parsed blocks with diff status attributes.\n */\nexport function diffRevisionContent( currentContent, previousContent ) {\n\t// Grammar parse both contents.\n\tconst currentRaw = grammarParse( currentContent || '' );\n\tconst previousRaw = grammarParse( previousContent || '' );\n\n\t// Diff the raw block arrays.\n\tconst mergedRaw = diffRawBlocks( currentRaw, previousRaw );\n\n\t// Parse each raw block and apply diff status.\n\treturn mergedRaw\n\t\t.map( ( rawBlock ) => {\n\t\t\tconst parsed = parseRawBlock( rawBlock );\n\t\t\tif ( parsed ) {\n\t\t\t\tapplyDiffRecursively( parsed, rawBlock );\n\t\t\t}\n\t\t\treturn parsed;\n\t\t} )\n\t\t.filter( Boolean );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA2B;AAC3B,kBAA0B;AAK1B,gDAAsC;AACtC,oBAGO;AACP,uBAMO;AACP,kBAAgC;AAKhC,yBAAuB;AAEvB,IAAM,EAAE,cAAc,QAAI,2BAAQ,cAAAA,WAAkB;AAQpD,SAAS,eAAgB,OAAQ;AAChC,MAAK,UAAU,QAAQ,UAAU,QAAY;AAC5C,WAAO;AAAA,EACR;AACA,MAAK,OAAO,UAAU,UAAW;AAChC,WAAO,KAAK,UAAW,OAAO,MAAM,CAAE;AAAA,EACvC;AACA,SAAO,OAAQ,KAAM;AACtB;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { diffArrays } from 'diff/lib/diff/array';\nimport { diffWords } from 'diff/lib/diff/word';\n\n/**\n * WordPress dependencies\n */\nimport { parse as grammarParse } from '@wordpress/block-serialization-default-parser';\nimport {\n\tprivateApis as blocksPrivateApis,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport {\n\tRichTextData,\n\tcreate,\n\tslice,\n\tconcat,\n\tapplyFormat,\n} from '@wordpress/rich-text';\nimport { __, _n, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { parseRawBlock } = unlock( blocksPrivateApis );\n\n/**\n * Safely stringifies a value for display and comparison.\n *\n * @param {*} value The value to stringify.\n * @return {string} The stringified value.\n */\nfunction stringifyValue( value ) {\n\tif ( value === null || value === undefined ) {\n\t\treturn '';\n\t}\n\tif ( typeof value === 'object' ) {\n\t\treturn JSON.stringify( value, null, 2 );\n\t}\n\treturn String( value );\n}\n\n/**\n * Calculate text similarity using word-set overlap.\n *\n * Uses a variant of the Jaccard index (https://en.wikipedia.org/wiki/Jaccard_index)\n * called the overlap coefficient (https://en.wikipedia.org/wiki/Overlap_coefficient)\n * where we divide by the larger set size rather than the union. This ensures that\n * a small edit to a long paragraph scores high \u2014 the few changed words don't\n * dilute the score.\n *\n * This replaces the previous diffWords-based similarity which was O(n*m) per pair.\n * The word-set approach is O(n) where n is the number of words.\n *\n * Words are extracted using Intl.Segmenter for proper multilingual support\n * (CJK, Thai, etc.) rather than splitting on whitespace.\n *\n * @param {string} text1 First text to compare.\n * @param {string} text2 Second text to compare.\n * @return {number} Similarity score between 0 and 1.\n */\nfunction textSimilarity( text1, text2 ) {\n\tif ( ! text1 && ! text2 ) {\n\t\treturn 1;\n\t}\n\tif ( ! text1 || ! text2 ) {\n\t\treturn 0;\n\t}\n\n\tconst segmenter = new Intl.Segmenter( undefined, {\n\t\tgranularity: 'word',\n\t} );\n\t// Safari's Intl.Segmenter returns isWordLike: false for numeric segments,\n\t// so fall back to a Unicode-aware regex for letters and numbers.\n\tconst wordLikeRegex = /[\\p{L}\\p{N}]/u;\n\tconst getWords = ( text ) => {\n\t\tconst words = [];\n\t\tfor ( const { segment, isWordLike } of segmenter.segment( text ) ) {\n\t\t\tif ( isWordLike || wordLikeRegex.test( segment ) ) {\n\t\t\t\twords.push( segment );\n\t\t\t}\n\t\t}\n\t\treturn words;\n\t};\n\tconst words1 = getWords( text1 );\n\tconst words2 = getWords( text2 );\n\n\tif ( words1.length === 0 && words2.length === 0 ) {\n\t\treturn 1;\n\t}\n\n\tconst set1 = new Set( words1 );\n\tlet intersection = 0;\n\tfor ( const word of words2 ) {\n\t\tif ( set1.has( word ) ) {\n\t\t\tintersection++;\n\t\t}\n\t}\n\n\tconst total = Math.max( words1.length, words2.length );\n\treturn total > 0 ? intersection / total : 0;\n}\n\n/**\n * Post-process diff result to pair similar removed/added blocks as modifications.\n *\n * After LCS diffing, a block whose content changed appears as a separate \"removed\"\n * and \"added\" entry (since the full block signature differs). This function detects\n * such pairs and merges them into a single \"modified\" block with inline diff.\n *\n * Two pairing strategies are used:\n * 1. When exactly one block of a given type was removed and one was added,\n * they are paired directly \u2014 no ambiguity, no similarity check needed.\n * 2. When multiple candidates exist, textSimilarity (overlap coefficient) is\n * used to find the best match. Blocks must share at least 50% of their\n * words to be paired, preventing unrelated paragraphs from being merged.\n *\n * @param {Array} blocks Raw blocks with diff status.\n * @return {Array} Blocks with similar pairs converted to modifications.\n */\nfunction pairSimilarBlocks( blocks ) {\n\tconst removed = [];\n\tconst added = [];\n\n\t// Separate blocks by status, tracking original indices.\n\tblocks.forEach( ( block, index ) => {\n\t\tconst status = block.__revisionDiffStatus?.status;\n\t\tif ( status === 'removed' ) {\n\t\t\tremoved.push( { block, index } );\n\t\t} else if ( status === 'added' ) {\n\t\t\tadded.push( { block, index } );\n\t\t}\n\t} );\n\n\t// If no removed or no added, nothing to pair.\n\tif ( removed.length === 0 || added.length === 0 ) {\n\t\treturn blocks;\n\t}\n\n\tconst pairedRemoved = new Set(); // Indices of removed blocks filtered out.\n\tconst pairedAdded = new Set(); // Indices of added blocks filtered out.\n\tconst modifications = new Map(); // Index \u2192 modified block.\n\tconst SIMILARITY_THRESHOLD = 0.5;\n\n\t// Group candidates by block name for efficient lookup.\n\tconst addedByName = new Map();\n\tfor ( const add of added ) {\n\t\tconst name = add.block.blockName;\n\t\tif ( ! addedByName.has( name ) ) {\n\t\t\taddedByName.set( name, [] );\n\t\t}\n\t\taddedByName.get( name ).push( add );\n\t}\n\tconst removedByName = new Map();\n\tfor ( const rem of removed ) {\n\t\tconst name = rem.block.blockName;\n\t\tif ( ! removedByName.has( name ) ) {\n\t\t\tremovedByName.set( name, [] );\n\t\t}\n\t\tremovedByName.get( name ).push( rem );\n\t}\n\n\t// For each removed block, find best matching added block.\n\t// Track the highest added index paired so far \u2014 new pairings must\n\t// not go backwards, or the removed/added text order would break.\n\tlet maxPairedAddedIndex = -1;\n\n\tfor ( const rem of removed ) {\n\t\tconst candidates = addedByName.get( rem.block.blockName ) || [];\n\t\tconst sameNameRemoved = removedByName.get( rem.block.blockName ) || [];\n\t\tconst unpaired = candidates.filter(\n\t\t\t( add ) =>\n\t\t\t\t! modifications.has( add.index ) &&\n\t\t\t\tadd.index > maxPairedAddedIndex\n\t\t);\n\n\t\tif ( unpaired.length === 0 ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet bestMatch = null;\n\n\t\t// If there's exactly one removed and one added of this type,\n\t\t// pair them directly \u2014 no ambiguity, no similarity check needed.\n\t\tif ( sameNameRemoved.length === 1 && unpaired.length === 1 ) {\n\t\t\tconst add = unpaired[ 0 ];\n\t\t\tconst attrsMatch =\n\t\t\t\tJSON.stringify( rem.block.attrs ) ===\n\t\t\t\tJSON.stringify( add.block.attrs );\n\t\t\t// Only skip pairing if both content and attrs are identical\n\t\t\t// (position swap, not a modification).\n\t\t\tconst contentMatch =\n\t\t\t\t( rem.block.innerHTML || '' ) === ( add.block.innerHTML || '' );\n\t\t\tif ( ! contentMatch || ! attrsMatch ) {\n\t\t\t\tbestMatch = add;\n\t\t\t}\n\t\t} else {\n\t\t\t// Multiple candidates \u2014 use similarity to find best match.\n\t\t\tlet bestScore = 0;\n\t\t\tfor ( const add of unpaired ) {\n\t\t\t\tconst score = textSimilarity(\n\t\t\t\t\trem.block.innerHTML || '',\n\t\t\t\t\tadd.block.innerHTML || ''\n\t\t\t\t);\n\t\t\t\t// Skip identical blocks (score=1 with same attrs) \u2014 those\n\t\t\t\t// are position swaps, not modifications. They should show\n\t\t\t\t// as separate removed + added, not as a no-op \"modified\".\n\t\t\t\tconst attrsMatch =\n\t\t\t\t\tJSON.stringify( rem.block.attrs ) ===\n\t\t\t\t\tJSON.stringify( add.block.attrs );\n\t\t\t\tif (\n\t\t\t\t\tscore > bestScore &&\n\t\t\t\t\tscore > SIMILARITY_THRESHOLD &&\n\t\t\t\t\t( score < 1 || ! attrsMatch )\n\t\t\t\t) {\n\t\t\t\t\tbestScore = score;\n\t\t\t\t\tbestMatch = add;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( bestMatch ) {\n\t\t\tmaxPairedAddedIndex = bestMatch.index;\n\n\t\t\tconst modifiedBlock = {\n\t\t\t\t...bestMatch.block,\n\t\t\t\t__revisionDiffStatus: { status: 'modified' },\n\t\t\t\t__previousRawBlock: rem.block,\n\t\t\t};\n\n\t\t\t// Decide where to place the modified block by checking\n\t\t\t// what's between the removed and added positions.\n\t\t\t// If there are unpaired added blocks between them,\n\t\t\t// placing at the removed position would put the modified\n\t\t\t// block before content that comes before it in the\n\t\t\t// current revision \u2014 so use the added position.\n\t\t\t// Otherwise, use the removed position to keep the\n\t\t\t// previous revision's order intact.\n\t\t\tconst lo = Math.min( rem.index, bestMatch.index );\n\t\t\tconst hi = Math.max( rem.index, bestMatch.index );\n\t\t\tlet hasAddedBetween = false;\n\t\t\tfor ( let i = lo + 1; i < hi; i++ ) {\n\t\t\t\tif (\n\t\t\t\t\tblocks[ i ].__revisionDiffStatus?.status === 'added' &&\n\t\t\t\t\t! pairedAdded.has( i )\n\t\t\t\t) {\n\t\t\t\t\thasAddedBetween = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( hasAddedBetween ) {\n\t\t\t\t// Use the added position \u2014 don't jump before\n\t\t\t\t// current-revision content.\n\t\t\t\tmodifications.set( bestMatch.index, modifiedBlock );\n\t\t\t\tpairedRemoved.add( rem.index );\n\t\t\t} else {\n\t\t\t\t// Use the removed position \u2014 keep the previous\n\t\t\t\t// revision's reading order.\n\t\t\t\tmodifications.set( rem.index, modifiedBlock );\n\t\t\t\tpairedAdded.add( bestMatch.index );\n\t\t\t}\n\t\t}\n\t}\n\n\t// Rebuild result: replace modification targets, filter out\n\t// their paired counterparts.\n\treturn blocks\n\t\t.map( ( block, index ) => {\n\t\t\tif ( pairedRemoved.has( index ) || pairedAdded.has( index ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif ( modifications.has( index ) ) {\n\t\t\t\treturn modifications.get( index );\n\t\t\t}\n\t\t\treturn block;\n\t\t} )\n\t\t.filter( Boolean );\n}\n\n/**\n * Diff raw block arrays using LCS, recursively handling innerBlocks.\n * Detects modifications when exactly 1 block is removed and 1 is added\n * with the same blockName (1:1 replacement = modification).\n *\n * @param {Array} currentRaw Current revision's raw blocks.\n * @param {Array} previousRaw Previous revision's raw blocks.\n * @return {Array} Merged raw blocks with diff status injected.\n */\nfunction diffRawBlocks( currentRaw, previousRaw ) {\n\tconst createBlockSignature = ( rawBlock ) =>\n\t\tJSON.stringify( {\n\t\t\tname: rawBlock.blockName,\n\t\t\tattrs: rawBlock.attrs,\n\t\t\t// Use innerContent filtered to non-null and non-whitespace-only strings.\n\t\t\t// This excludes whitespace between inner blocks which changes based on count.\n\t\t\thtml: ( rawBlock.innerContent || [] ).filter(\n\t\t\t\t( c ) => c !== null && c.trim() !== ''\n\t\t\t),\n\t\t} );\n\tconst currentSigs = currentRaw.map( createBlockSignature );\n\tconst previousSigs = previousRaw.map( createBlockSignature );\n\n\tconst diff = diffArrays( previousSigs, currentSigs );\n\n\tconst result = [];\n\tlet currIdx = 0;\n\tlet prevIdx = 0;\n\n\tfor ( const part of diff ) {\n\t\tif ( part.added ) {\n\t\t\tfor ( let i = 0; i < part.count; i++ ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\t...currentRaw[ currIdx++ ],\n\t\t\t\t\t__revisionDiffStatus: { status: 'added' },\n\t\t\t\t} );\n\t\t\t}\n\t\t} else if ( part.removed ) {\n\t\t\tfor ( let i = 0; i < part.count; i++ ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\t...previousRaw[ prevIdx++ ],\n\t\t\t\t\t__revisionDiffStatus: { status: 'removed' },\n\t\t\t\t} );\n\t\t\t}\n\t\t} else {\n\t\t\t// Matched blocks - recursively diff their innerBlocks.\n\t\t\tfor ( let i = 0; i < part.count; i++ ) {\n\t\t\t\tconst currBlock = currentRaw[ currIdx++ ];\n\t\t\t\tconst prevBlock = previousRaw[ prevIdx++ ];\n\n\t\t\t\t// Recursively diff inner blocks.\n\t\t\t\tconst diffedInnerBlocks = diffRawBlocks(\n\t\t\t\t\tcurrBlock.innerBlocks || [],\n\t\t\t\t\tprevBlock.innerBlocks || []\n\t\t\t\t);\n\n\t\t\t\tresult.push( {\n\t\t\t\t\t...currBlock,\n\t\t\t\t\tinnerBlocks: diffedInnerBlocks,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n\n\t// Post-process to pair similar removed/added blocks as modifications.\n\treturn pairSimilarBlocks( result );\n}\n\n/**\n * Check if formatting has changed at specific character indices.\n *\n * @param {Array} currentFormats Current formats array.\n * @param {Array} previousFormats Previous formats array.\n * @param {number} currentIndex Character index in current.\n * @param {number} previousIndex Character index in previous.\n * @return {boolean} True if formatting changed at these indices.\n */\nfunction hasFormatChangedAtIndex(\n\tcurrentFormats,\n\tpreviousFormats,\n\tcurrentIndex,\n\tpreviousIndex\n) {\n\tconst currFmts = currentFormats[ currentIndex ] || [];\n\tconst prevFmts = previousFormats[ previousIndex ] || [];\n\n\tif ( currFmts.length !== prevFmts.length ) {\n\t\treturn true;\n\t}\n\n\t// Check if each format in current exists in previous\n\tfor ( const fmt of currFmts ) {\n\t\tconst match = prevFmts.find(\n\t\t\t( pf ) =>\n\t\t\t\tpf.type === fmt.type &&\n\t\t\t\tJSON.stringify( pf.attributes ) ===\n\t\t\t\t\tJSON.stringify( fmt.attributes )\n\t\t);\n\t\tif ( ! match ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Analyze what formatting changed between two character positions.\n * Returns both the change type (for styling) and a description (for tooltip).\n *\n * @param {Array} currentFormats Current formats array.\n * @param {Array} previousFormats Previous formats array.\n * @param {number} currIdx Character index in current.\n * @param {number} prevIdx Character index in previous.\n * @return {{ type: 'added'|'removed'|'changed', description: string }} Change info.\n */\nfunction describeFormatChange(\n\tcurrentFormats,\n\tpreviousFormats,\n\tcurrIdx,\n\tprevIdx\n) {\n\tconst currFmts = currentFormats[ currIdx ] || [];\n\tconst prevFmts = previousFormats[ prevIdx ] || [];\n\n\tlet addedCount = 0;\n\tlet removedCount = 0;\n\tlet changedCount = 0;\n\n\t// Find added formats and attribute changes\n\tfor ( const fmt of currFmts ) {\n\t\tconst match = prevFmts.find( ( pf ) => pf.type === fmt.type );\n\t\tif ( ! match ) {\n\t\t\taddedCount++;\n\t\t} else if (\n\t\t\tJSON.stringify( fmt.attributes ) !==\n\t\t\tJSON.stringify( match.attributes )\n\t\t) {\n\t\t\tchangedCount++;\n\t\t}\n\t}\n\n\t// Find removed formats\n\tfor ( const fmt of prevFmts ) {\n\t\tconst match = currFmts.find( ( cf ) => cf.type === fmt.type );\n\t\tif ( ! match ) {\n\t\t\tremovedCount++;\n\t\t}\n\t}\n\n\t// Determine primary change type for styling\n\tif ( addedCount > 0 && removedCount === 0 && changedCount === 0 ) {\n\t\treturn {\n\t\t\ttype: 'added',\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %d: number of formats added */\n\t\t\t\t_n( '%d format added', '%d formats added', addedCount ),\n\t\t\t\taddedCount\n\t\t\t),\n\t\t};\n\t}\n\tif ( removedCount > 0 && addedCount === 0 && changedCount === 0 ) {\n\t\treturn {\n\t\t\ttype: 'removed',\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %d: number of formats removed */\n\t\t\t\t_n( '%d format removed', '%d formats removed', removedCount ),\n\t\t\t\tremovedCount\n\t\t\t),\n\t\t};\n\t}\n\n\t// Mixed or attribute-only changes\n\tconst parts = [];\n\tif ( addedCount > 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of formats added */\n\t\t\t\t_n( '%d format added', '%d formats added', addedCount ),\n\t\t\t\taddedCount\n\t\t\t)\n\t\t);\n\t}\n\tif ( removedCount > 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of formats removed */\n\t\t\t\t_n( '%d format removed', '%d formats removed', removedCount ),\n\t\t\t\tremovedCount\n\t\t\t)\n\t\t);\n\t}\n\tif ( changedCount > 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of formats changed */\n\t\t\t\t_n( '%d format changed', '%d formats changed', changedCount ),\n\t\t\t\tchangedCount\n\t\t\t)\n\t\t);\n\t}\n\treturn {\n\t\ttype: 'changed',\n\t\tdescription: parts.join( ', ' ) || __( 'Formatting changed' ),\n\t};\n}\n\n/**\n * Apply inline diff formatting comparing two RichTextData values.\n * - Text changes: apply revision/diff-removed and revision/diff-added formats\n * - Format-only changes (text unchanged): apply revision/diff-format-changed format\n *\n * @param {RichTextData} currentRichText Current revision's rich text.\n * @param {RichTextData} previousRichText Previous revision's rich text.\n * @return {RichTextData} New rich text with diff formatting applied.\n */\nfunction applyRichTextDiff( currentRichText, previousRichText ) {\n\tconst currentText = currentRichText.toPlainText();\n\tconst previousText = previousRichText.toPlainText();\n\n\t// Diff the plain text (words for cleaner output)\n\tconst textDiff = diffWords( previousText, currentText );\n\n\tlet result = create( { text: '' } );\n\tlet currentIdx = 0;\n\tlet previousIdx = 0;\n\n\tfor ( const part of textDiff ) {\n\t\tif ( part.removed ) {\n\t\t\t// Text deleted - slice from PREVIOUS, apply <del>\n\t\t\tconst removedSlice = slice(\n\t\t\t\tpreviousRichText,\n\t\t\t\tpreviousIdx,\n\t\t\t\tpreviousIdx + part.value.length\n\t\t\t);\n\t\t\tconst formatted = applyFormat(\n\t\t\t\tremovedSlice,\n\t\t\t\t{\n\t\t\t\t\ttype: 'revision/diff-removed',\n\t\t\t\t\tattributes: { title: __( 'Removed' ) },\n\t\t\t\t},\n\t\t\t\t0,\n\t\t\t\tpart.value.length\n\t\t\t);\n\t\t\tresult = concat( result, formatted );\n\t\t\tpreviousIdx += part.value.length;\n\t\t} else if ( part.added ) {\n\t\t\t// Text added - slice from CURRENT, apply <ins>\n\t\t\tconst addedSlice = slice(\n\t\t\t\tcurrentRichText,\n\t\t\t\tcurrentIdx,\n\t\t\t\tcurrentIdx + part.value.length\n\t\t\t);\n\t\t\tconst formatted = applyFormat(\n\t\t\t\taddedSlice,\n\t\t\t\t{\n\t\t\t\t\ttype: 'revision/diff-added',\n\t\t\t\t\tattributes: { title: __( 'Added' ) },\n\t\t\t\t},\n\t\t\t\t0,\n\t\t\t\tpart.value.length\n\t\t\t);\n\t\t\tresult = concat( result, formatted );\n\t\t\tcurrentIdx += part.value.length;\n\t\t} else {\n\t\t\t// Text unchanged - check formatting at each character position.\n\t\t\t// Only apply <mark> to specific ranges where formatting differs.\n\t\t\tconst currentFormats = currentRichText.formats || [];\n\t\t\tconst previousFormats = previousRichText.formats || [];\n\t\t\tconst len = part.value.length;\n\n\t\t\t// Helper to check format change at offset within this unchanged part.\n\t\t\tconst checkFormatChanged = ( offset ) =>\n\t\t\t\thasFormatChangedAtIndex(\n\t\t\t\t\tcurrentFormats,\n\t\t\t\t\tpreviousFormats,\n\t\t\t\t\tcurrentIdx + offset,\n\t\t\t\t\tpreviousIdx + offset\n\t\t\t\t);\n\n\t\t\t// Find ranges of characters grouped by whether format changed.\n\t\t\tlet rangeStart = 0;\n\t\t\tlet rangeFormatChanged = checkFormatChanged( 0 );\n\n\t\t\tfor ( let i = 1; i <= len; i++ ) {\n\t\t\t\tconst formatChanged = i < len && checkFormatChanged( i );\n\n\t\t\t\t// When format-changed status changes or we reach the end, emit range.\n\t\t\t\tif ( i === len || formatChanged !== rangeFormatChanged ) {\n\t\t\t\t\tconst rangeSlice = slice(\n\t\t\t\t\t\tcurrentRichText,\n\t\t\t\t\t\tcurrentIdx + rangeStart,\n\t\t\t\t\t\tcurrentIdx + i\n\t\t\t\t\t);\n\n\t\t\t\t\tif ( rangeFormatChanged ) {\n\t\t\t\t\t\t// Get type and description of what changed\n\t\t\t\t\t\tconst { type, description } = describeFormatChange(\n\t\t\t\t\t\t\tcurrentFormats,\n\t\t\t\t\t\t\tpreviousFormats,\n\t\t\t\t\t\t\tcurrentIdx + rangeStart,\n\t\t\t\t\t\t\tpreviousIdx + rangeStart\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Map change type to format type for styling\n\t\t\t\t\t\tconst formatType = {\n\t\t\t\t\t\t\tadded: 'revision/diff-format-added',\n\t\t\t\t\t\t\tremoved: 'revision/diff-format-removed',\n\t\t\t\t\t\t\tchanged: 'revision/diff-format-changed',\n\t\t\t\t\t\t}[ type ];\n\n\t\t\t\t\t\tconst marked = applyFormat(\n\t\t\t\t\t\t\trangeSlice,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: formatType,\n\t\t\t\t\t\t\t\tattributes: { title: description },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\ti - rangeStart\n\t\t\t\t\t\t);\n\t\t\t\t\t\tresult = concat( result, marked );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult = concat( result, rangeSlice );\n\t\t\t\t\t}\n\n\t\t\t\t\trangeStart = i;\n\t\t\t\t\trangeFormatChanged = formatChanged;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcurrentIdx += part.value.length;\n\t\t\tpreviousIdx += part.value.length;\n\t\t}\n\t}\n\n\treturn new RichTextData( result );\n}\n\n/**\n * Apply diffs to a modified block's attributes.\n * - Rich-text attributes: applies inline diff formatting (ins/del marks).\n * - Other attributes: computes word-level diffs for the sidebar panel.\n *\n * @param {Object} currentBlock Current parsed block.\n * @param {Object} previousBlock Previous parsed block.\n * @param {Object} diffStatus The __revisionDiffStatus object to attach changedAttributes to.\n */\nfunction applyDiffToBlock( currentBlock, previousBlock, diffStatus ) {\n\tconst blockType = getBlockType( currentBlock.name );\n\tif ( ! blockType ) {\n\t\treturn;\n\t}\n\n\tconst changedAttributes = {};\n\n\tfor ( const [ attrName, attrDef ] of Object.entries(\n\t\tblockType.attributes\n\t) ) {\n\t\tif ( attrDef.source === 'rich-text' ) {\n\t\t\tconst currentRichText = currentBlock.attributes[ attrName ];\n\t\t\tconst previousRichText = previousBlock.attributes[ attrName ];\n\t\t\tif (\n\t\t\t\tcurrentRichText instanceof RichTextData &&\n\t\t\t\tpreviousRichText instanceof RichTextData\n\t\t\t) {\n\t\t\t\tcurrentBlock.attributes[ attrName ] = applyRichTextDiff(\n\t\t\t\t\tcurrentRichText,\n\t\t\t\t\tpreviousRichText\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tconst currStr = stringifyValue(\n\t\t\t\tcurrentBlock.attributes[ attrName ]\n\t\t\t);\n\t\t\tconst prevStr = stringifyValue(\n\t\t\t\tpreviousBlock.attributes[ attrName ]\n\t\t\t);\n\t\t\tif ( currStr !== prevStr ) {\n\t\t\t\tchangedAttributes[ attrName ] = diffWords( prevStr, currStr );\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( Object.keys( changedAttributes ).length > 0 ) {\n\t\tdiffStatus.changedAttributes = changedAttributes;\n\t}\n}\n\n/**\n * Recursively apply diff status and rich text diff to blocks in the tree.\n * Copies __revisionDiffStatus from raw blocks to parsed blocks and applies\n * rich text diffs to modified blocks.\n *\n * @param {Object} parsedBlock Parsed block (with inner blocks).\n * @param {Object} rawBlock Raw block (with __revisionDiffStatus and __previousRawBlock).\n */\nfunction applyDiffRecursively( parsedBlock, rawBlock ) {\n\t// Copy diff status from raw block to parsed block.\n\tif ( rawBlock.__revisionDiffStatus ) {\n\t\t// Apply diffs if this block is modified and has a previous raw block.\n\t\tif (\n\t\t\trawBlock.__revisionDiffStatus.status === 'modified' &&\n\t\t\trawBlock.__previousRawBlock\n\t\t) {\n\t\t\tconst previousParsed = parseRawBlock( rawBlock.__previousRawBlock );\n\t\t\tif ( previousParsed ) {\n\t\t\t\tapplyDiffToBlock(\n\t\t\t\t\tparsedBlock,\n\t\t\t\t\tpreviousParsed,\n\t\t\t\t\trawBlock.__revisionDiffStatus\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tparsedBlock.__revisionDiffStatus = rawBlock.__revisionDiffStatus;\n\t\t// Also store in attributes so it survives block-editor store normalization.\n\t\tparsedBlock.attributes.__revisionDiffStatus =\n\t\t\trawBlock.__revisionDiffStatus;\n\t}\n\n\t// Recursively process inner blocks.\n\tif ( parsedBlock.innerBlocks && rawBlock.innerBlocks ) {\n\t\tfor ( let i = 0; i < parsedBlock.innerBlocks.length; i++ ) {\n\t\t\tconst parsedInner = parsedBlock.innerBlocks[ i ];\n\t\t\tconst rawInner = rawBlock.innerBlocks[ i ];\n\t\t\tif ( parsedInner && rawInner ) {\n\t\t\t\tapplyDiffRecursively( parsedInner, rawInner );\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Diff two revision contents at the grammar level.\n *\n * @param {string} currentContent Current revision's raw content.\n * @param {string} previousContent Previous revision's raw content.\n * @return {Array} Array of parsed blocks with diff status attributes.\n */\nexport function diffRevisionContent( currentContent, previousContent ) {\n\t// Grammar parse both contents.\n\tconst currentRaw = grammarParse( currentContent || '' );\n\tconst previousRaw = grammarParse( previousContent || '' );\n\n\t// Diff the raw block arrays.\n\tconst mergedRaw = diffRawBlocks( currentRaw, previousRaw );\n\n\t// Parse each raw block and apply diff status.\n\treturn mergedRaw\n\t\t.map( ( rawBlock ) => {\n\t\t\tconst parsed = parseRawBlock( rawBlock );\n\t\t\tif ( parsed ) {\n\t\t\t\tapplyDiffRecursively( parsed, rawBlock );\n\t\t\t}\n\t\t\treturn parsed;\n\t\t} )\n\t\t.filter( Boolean );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA2B;AAC3B,kBAA0B;AAK1B,gDAAsC;AACtC,oB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B,0BAAmB,QAAS,QAAI,uBAAW,SAAS,OAAQ;AAAA,MAC7D;AAAA,IACD;AAAA,EACD;AAEA,MAAK,OAAO,KAAM,iBAAkB,EAAE,SAAS,GAAI;AAClD,eAAW,oBAAoB;AAAA,EAChC;AACD;AAUA,SAAS,qBAAsB,aAAa,UAAW;AAEtD,MAAK,SAAS,sBAAuB;AAEpC,QACC,SAAS,qBAAqB,WAAW,cACzC,SAAS,oBACR;AACD,YAAM,iBAAiB,cAAe,SAAS,kBAAmB;AAClE,UAAK,gBAAiB;AACrB;AAAA,UACC;AAAA,UACA;AAAA,UACA,SAAS;AAAA,QACV;AAAA,MACD;AAAA,IACD;AAEA,gBAAY,uBAAuB,SAAS;AAE5C,gBAAY,WAAW,uBACtB,SAAS;AAAA,EACX;AAGA,MAAK,YAAY,eAAe,SAAS,aAAc;AACtD,aAAU,IAAI,GAAG,IAAI,YAAY,YAAY,QAAQ,KAAM;AAC1D,YAAM,cAAc,YAAY,YAAa,CAAE;AAC/C,YAAM,WAAW,SAAS,YAAa,CAAE;AACzC,UAAK,eAAe,UAAW;AAC9B,6BAAsB,aAAa,QAAS;AAAA,MAC7C;AAAA,IACD;AAAA,EACD;AACD;AASO,SAAS,oBAAqB,gBAAgB,iBAAkB;AAEtE,QAAM,iBAAa,0CAAAC,OAAc,kBAAkB,EAAG;AACtD,QAAM,kBAAc,0CAAAA,OAAc,mBAAmB,EAAG;AAGxD,QAAM,YAAY,cAAe,YAAY,WAAY;AAGzD,SAAO,UACL,IAAK,CAAE,aAAc;AACrB,UAAM,SAAS,cAAe,QAAS;AACvC,QAAK,QAAS;AACb,2BAAsB,QAAQ,QAAS;AAAA,IACxC;AACA,WAAO;AAAA,EACR,CAAE,EACD,OAAQ,OAAQ;AACnB;",
|
|
6
6
|
"names": ["blocksPrivateApis", "grammarParse"]
|
|
7
7
|
}
|
|
@@ -28,6 +28,7 @@ var import_compose = require("@wordpress/compose");
|
|
|
28
28
|
var import_data = require("@wordpress/data");
|
|
29
29
|
var import_block_editor = require("@wordpress/block-editor");
|
|
30
30
|
var import_i18n = require("@wordpress/i18n");
|
|
31
|
+
var import_components = require("@wordpress/components");
|
|
31
32
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
32
33
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
34
|
var { useBlockElementRef } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
|
|
@@ -82,7 +83,7 @@ function DiffMarkerButton({ clientId, status, subscribe }) {
|
|
|
82
83
|
if (!position) {
|
|
83
84
|
return null;
|
|
84
85
|
}
|
|
85
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
86
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Tooltip, { text: STATUS_LABELS[status], children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
86
87
|
"button",
|
|
87
88
|
{
|
|
88
89
|
className: `revision-diff-marker is-${status}`,
|
|
@@ -93,7 +94,7 @@ function DiffMarkerButton({ clientId, status, subscribe }) {
|
|
|
93
94
|
onClick: () => blockRef.current?.focus(),
|
|
94
95
|
"aria-label": STATUS_LABELS[status]
|
|
95
96
|
}
|
|
96
|
-
);
|
|
97
|
+
) });
|
|
97
98
|
}
|
|
98
99
|
function useDiffMarkers() {
|
|
99
100
|
const [isMounted, setIsMounted] = (0, import_element.useState)(false);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-revisions-preview/diff-markers.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseMemo,\n\tuseRef,\n\tuseCallback,\n\tuseEffect,\n} from '@wordpress/element';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useBlockElementRef } = unlock( blockEditorPrivateApis );\n\n/**\n * Recursively collect blocks with diff status.\n *\n * @param {Array} blocks The blocks to search.\n * @return {Array} Blocks with __revisionDiffStatus.\n */\nfunction collectDiffBlocks( blocks ) {\n\tconst result = [];\n\tfor ( const block of blocks ) {\n\t\tif ( block.__revisionDiffStatus?.status ) {\n\t\t\tresult.push( {\n\t\t\t\tclientId: block.clientId,\n\t\t\t\tstatus: block.__revisionDiffStatus.status,\n\t\t\t} );\n\t\t}\n\t\tif ( block.innerBlocks?.length ) {\n\t\t\tresult.push( ...collectDiffBlocks( block.innerBlocks ) );\n\t\t}\n\t}\n\treturn result;\n}\n\nconst STATUS_LABELS = {\n\tadded: __( 'Go to added block' ),\n\tremoved: __( 'Go to removed block' ),\n\tmodified: __( 'Go to modified block' ),\n};\n\nfunction calculatePosition( el ) {\n\tif ( ! el ) {\n\t\treturn null;\n\t}\n\tconst doc = el.ownerDocument;\n\tconst scrollHeight = doc.documentElement.scrollHeight;\n\tconst rect = el.getBoundingClientRect();\n\tconst scrollTop = doc.documentElement.scrollTop;\n\tconst top = rect.top + scrollTop;\n\treturn {\n\t\ttop: ( top / scrollHeight ) * 100,\n\t\theight: ( rect.height / scrollHeight ) * 100,\n\t};\n}\n\n/**\n * Button component for a single diff marker.\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId The block client ID.\n * @param {string} props.status The diff status (added/removed/modified).\n * @param {Function} props.subscribe Function to subscribe to position updates.\n * @return {React.JSX.Element} The diff marker button or null if position not calculated.\n */\nfunction DiffMarkerButton( { clientId, status, subscribe } ) {\n\tconst blockRef = useRef();\n\tuseBlockElementRef( clientId, blockRef );\n\tconst [ position, setPosition ] = useState( () =>\n\t\tcalculatePosition( blockRef.current )\n\t);\n\n\tuseEffect( () => {\n\t\treturn subscribe( () => {\n\t\t\tsetPosition( calculatePosition( blockRef.current ) );\n\t\t} );\n\t}, [ subscribe ] );\n\n\tuseEffect( () => {\n\t\tsetPosition( calculatePosition( blockRef.current ) );\n\t}, [ status ] );\n\n\tif ( ! position ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<button\n\t\t\tclassName={ `revision-diff-marker is-${ status }` }\n\t\t\tstyle={ {\n\t\t\t\ttop: `${ position.top }%`,\n\t\t\t\theight: `${ Math.max( position.height, 0.5 ) }%`,\n\t\t\t} }\n\t\t\tonClick={ () => blockRef.current?.focus() }\n\t\t\taria-label={ STATUS_LABELS[ status ] }\n\t\t/>\n\t);\n}\n\n/**\n * Hook that provides diff markers functionality.\n * Returns a ref callback for the content element and a DiffMarkers component.\n * Must be used inside a BlockEditorProvider context.\n *\n * @return {Array} Tuple of [contentRef, DiffMarkersComponent].\n */\nexport function useDiffMarkers() {\n\tconst [ isMounted, setIsMounted ] = useState( false );\n\tconst subscribersRef = useRef( new Set() );\n\tconst blocks = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlocks(),\n\t\t[]\n\t);\n\tconst diffBlocks = useMemo( () => collectDiffBlocks( blocks ), [ blocks ] );\n\tconst subscribe = useCallback( ( callback ) => {\n\t\tsubscribersRef.current.add( callback );\n\t\treturn () => subscribersRef.current.delete( callback );\n\t}, [] );\n\tconst contentRef = useRefEffect( ( element ) => {\n\t\tconst { ownerDocument } = element;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst resizeObserver = new defaultView.ResizeObserver( () => {\n\t\t\tsubscribersRef.current.forEach( ( cb ) => cb() );\n\t\t} );\n\t\tresizeObserver.observe( ownerDocument.body );\n\t\treturn () => {\n\t\t\tresizeObserver.disconnect();\n\t\t};\n\t}, [] );\n\treturn [\n\t\tuseMergeRefs( [ contentRef, setIsMounted ] ),\n\t\t<div\n\t\t\tkey=\"diff-markers\"\n\t\t\tclassName=\"revision-diff-markers\"\n\t\t\trole=\"navigation\"\n\t\t\taria-label={ __( 'Document changes' ) }\n\t\t>\n\t\t\t{ isMounted &&\n\t\t\t\tdiffBlocks.map( ( { clientId, status } ) => (\n\t\t\t\t\t<DiffMarkerButton\n\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tstatus={ status }\n\t\t\t\t\t\tsubscribe={ subscribe }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t</div>,\n\t];\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAMO;AACP,qBAA2C;AAC3C,kBAA0B;AAC1B,0BAGO;AACP,kBAAmB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseMemo,\n\tuseRef,\n\tuseCallback,\n\tuseEffect,\n} from '@wordpress/element';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { Tooltip } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useBlockElementRef } = unlock( blockEditorPrivateApis );\n\n/**\n * Recursively collect blocks with diff status.\n *\n * @param {Array} blocks The blocks to search.\n * @return {Array} Blocks with __revisionDiffStatus.\n */\nfunction collectDiffBlocks( blocks ) {\n\tconst result = [];\n\tfor ( const block of blocks ) {\n\t\tif ( block.__revisionDiffStatus?.status ) {\n\t\t\tresult.push( {\n\t\t\t\tclientId: block.clientId,\n\t\t\t\tstatus: block.__revisionDiffStatus.status,\n\t\t\t} );\n\t\t}\n\t\tif ( block.innerBlocks?.length ) {\n\t\t\tresult.push( ...collectDiffBlocks( block.innerBlocks ) );\n\t\t}\n\t}\n\treturn result;\n}\n\nconst STATUS_LABELS = {\n\tadded: __( 'Go to added block' ),\n\tremoved: __( 'Go to removed block' ),\n\tmodified: __( 'Go to modified block' ),\n};\n\nfunction calculatePosition( el ) {\n\tif ( ! el ) {\n\t\treturn null;\n\t}\n\tconst doc = el.ownerDocument;\n\tconst scrollHeight = doc.documentElement.scrollHeight;\n\tconst rect = el.getBoundingClientRect();\n\tconst scrollTop = doc.documentElement.scrollTop;\n\tconst top = rect.top + scrollTop;\n\treturn {\n\t\ttop: ( top / scrollHeight ) * 100,\n\t\theight: ( rect.height / scrollHeight ) * 100,\n\t};\n}\n\n/**\n * Button component for a single diff marker.\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId The block client ID.\n * @param {string} props.status The diff status (added/removed/modified).\n * @param {Function} props.subscribe Function to subscribe to position updates.\n * @return {React.JSX.Element} The diff marker button or null if position not calculated.\n */\nfunction DiffMarkerButton( { clientId, status, subscribe } ) {\n\tconst blockRef = useRef();\n\tuseBlockElementRef( clientId, blockRef );\n\tconst [ position, setPosition ] = useState( () =>\n\t\tcalculatePosition( blockRef.current )\n\t);\n\n\tuseEffect( () => {\n\t\treturn subscribe( () => {\n\t\t\tsetPosition( calculatePosition( blockRef.current ) );\n\t\t} );\n\t}, [ subscribe ] );\n\n\tuseEffect( () => {\n\t\tsetPosition( calculatePosition( blockRef.current ) );\n\t}, [ status ] );\n\n\tif ( ! position ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Tooltip text={ STATUS_LABELS[ status ] }>\n\t\t\t<button\n\t\t\t\tclassName={ `revision-diff-marker is-${ status }` }\n\t\t\t\tstyle={ {\n\t\t\t\t\ttop: `${ position.top }%`,\n\t\t\t\t\theight: `${ Math.max( position.height, 0.5 ) }%`,\n\t\t\t\t} }\n\t\t\t\tonClick={ () => blockRef.current?.focus() }\n\t\t\t\taria-label={ STATUS_LABELS[ status ] }\n\t\t\t/>\n\t\t</Tooltip>\n\t);\n}\n\n/**\n * Hook that provides diff markers functionality.\n * Returns a ref callback for the content element and a DiffMarkers component.\n * Must be used inside a BlockEditorProvider context.\n *\n * @return {Array} Tuple of [contentRef, DiffMarkersComponent].\n */\nexport function useDiffMarkers() {\n\tconst [ isMounted, setIsMounted ] = useState( false );\n\tconst subscribersRef = useRef( new Set() );\n\tconst blocks = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlocks(),\n\t\t[]\n\t);\n\tconst diffBlocks = useMemo( () => collectDiffBlocks( blocks ), [ blocks ] );\n\tconst subscribe = useCallback( ( callback ) => {\n\t\tsubscribersRef.current.add( callback );\n\t\treturn () => subscribersRef.current.delete( callback );\n\t}, [] );\n\tconst contentRef = useRefEffect( ( element ) => {\n\t\tconst { ownerDocument } = element;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst resizeObserver = new defaultView.ResizeObserver( () => {\n\t\t\tsubscribersRef.current.forEach( ( cb ) => cb() );\n\t\t} );\n\t\tresizeObserver.observe( ownerDocument.body );\n\t\treturn () => {\n\t\t\tresizeObserver.disconnect();\n\t\t};\n\t}, [] );\n\treturn [\n\t\tuseMergeRefs( [ contentRef, setIsMounted ] ),\n\t\t<div\n\t\t\tkey=\"diff-markers\"\n\t\t\tclassName=\"revision-diff-markers\"\n\t\t\trole=\"navigation\"\n\t\t\taria-label={ __( 'Document changes' ) }\n\t\t>\n\t\t\t{ isMounted &&\n\t\t\t\tdiffBlocks.map( ( { clientId, status } ) => (\n\t\t\t\t\t<DiffMarkerButton\n\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tstatus={ status }\n\t\t\t\t\t\tsubscribe={ subscribe }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t</div>,\n\t];\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAMO;AACP,qBAA2C;AAC3C,kBAA0B;AAC1B,0BAGO;AACP,kBAAmB;AACnB,wBAAwB;AAKxB,yBAAuB;AA+EpB;AA7EH,IAAM,EAAE,mBAAmB,QAAI,2BAAQ,oBAAAA,WAAuB;AAQ9D,SAAS,kBAAmB,QAAS;A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AAI,kBAAmB;AAAA,QAElC,uBACD,WAAW,IAAK,CAAE,EAAE,UAAU,OAAO,MACpC;AAAA,UAAC;AAAA;AAAA,YAEA;AAAA,YACA;AAAA,YACA;AAAA;AAAA,UAHM;AAAA,QAIP,CACC;AAAA;AAAA,MAbC;AAAA,IAcL;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["blockEditorPrivateApis", "blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -28,57 +28,55 @@ var import_components = require("@wordpress/components");
|
|
|
28
28
|
var import_core_data = require("@wordpress/core-data");
|
|
29
29
|
var import_i18n = require("@wordpress/i18n");
|
|
30
30
|
var import_date = require("@wordpress/date");
|
|
31
|
+
var import_element = require("@wordpress/element");
|
|
32
|
+
var import_icons = require("@wordpress/icons");
|
|
33
|
+
var import_ui = require("@wordpress/ui");
|
|
31
34
|
var import_store = require("../../store/index.cjs");
|
|
32
35
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
33
36
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
37
|
function RevisionsSlider() {
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
revisionKey: _revisionKey
|
|
77
|
-
};
|
|
78
|
-
},
|
|
79
|
-
[]
|
|
38
|
+
const {
|
|
39
|
+
revisions: rawRevisions,
|
|
40
|
+
perPage,
|
|
41
|
+
currentRevisionId,
|
|
42
|
+
revisionKey,
|
|
43
|
+
revisionPage,
|
|
44
|
+
totalRevisions
|
|
45
|
+
} = (0, import_data.useSelect)((select) => {
|
|
46
|
+
const {
|
|
47
|
+
getCurrentRevisionId,
|
|
48
|
+
getRevisionPage,
|
|
49
|
+
getPageRevisions,
|
|
50
|
+
getRevisionsPerPage
|
|
51
|
+
} = (0, import_lock_unlock.unlock)(select(import_store.store));
|
|
52
|
+
const postType = select(import_store.store).getCurrentPostType();
|
|
53
|
+
if (!postType) {
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
const entityConfig = select(import_core_data.store).getEntityConfig(
|
|
57
|
+
"postType",
|
|
58
|
+
postType
|
|
59
|
+
);
|
|
60
|
+
const _revisionKey = entityConfig?.revisionKey || "id";
|
|
61
|
+
const _revisionPage = getRevisionPage();
|
|
62
|
+
return {
|
|
63
|
+
revisions: getPageRevisions(_revisionPage),
|
|
64
|
+
perPage: getRevisionsPerPage(),
|
|
65
|
+
currentRevisionId: getCurrentRevisionId(),
|
|
66
|
+
revisionKey: _revisionKey,
|
|
67
|
+
revisionPage: _revisionPage,
|
|
68
|
+
totalRevisions: select(import_store.store).getCurrentPostRevisionsCount()
|
|
69
|
+
};
|
|
70
|
+
}, []);
|
|
71
|
+
const { setCurrentRevisionId, setRevisionPage } = (0, import_lock_unlock.unlock)(
|
|
72
|
+
(0, import_data.useDispatch)(import_store.store)
|
|
73
|
+
);
|
|
74
|
+
const isLoading = !rawRevisions;
|
|
75
|
+
const totalPages = Math.ceil(totalRevisions / perPage) || 1;
|
|
76
|
+
const revisions = (0, import_element.useMemo)(
|
|
77
|
+
() => rawRevisions && [...rawRevisions].reverse(),
|
|
78
|
+
[rawRevisions]
|
|
80
79
|
);
|
|
81
|
-
const { setCurrentRevisionId } = (0, import_lock_unlock.unlock)((0, import_data.useDispatch)(import_store.store));
|
|
82
80
|
const selectedIndex = revisions?.findIndex(
|
|
83
81
|
(r) => r[revisionKey] === currentRevisionId
|
|
84
82
|
);
|
|
@@ -96,16 +94,27 @@ function RevisionsSlider() {
|
|
|
96
94
|
}
|
|
97
95
|
return (0, import_date.dateI18n)(dateSettings.formats.datetime, revision.date);
|
|
98
96
|
};
|
|
99
|
-
|
|
97
|
+
const showPagination = totalPages > 1;
|
|
98
|
+
if (isLoading && !showPagination) {
|
|
100
99
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {});
|
|
101
100
|
}
|
|
102
|
-
if (!revisions?.length) {
|
|
101
|
+
if (!isLoading && !revisions?.length) {
|
|
103
102
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "editor-revisions-header__no-revisions", children: (0, import_i18n.__)("No revisions found.") });
|
|
104
103
|
}
|
|
105
|
-
if (
|
|
104
|
+
if (totalRevisions <= 1) {
|
|
106
105
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "editor-revisions-header__no-revisions", children: (0, import_i18n.__)("Only one revision found.") });
|
|
107
106
|
}
|
|
108
|
-
|
|
107
|
+
const getPageRangeLabel = (page) => {
|
|
108
|
+
const end = totalRevisions - (page - 1) * perPage;
|
|
109
|
+
const start = Math.max(1, end - perPage + 1);
|
|
110
|
+
return (0, import_i18n.sprintf)(
|
|
111
|
+
/* translators: 1: first revision number, 2: last revision number */
|
|
112
|
+
(0, import_i18n.__)("Revisions %1$s\u2013%2$s"),
|
|
113
|
+
start,
|
|
114
|
+
end
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
const sliderOrSpinner = isLoading || selectedIndex === -1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
109
118
|
import_components.RangeControl,
|
|
110
119
|
{
|
|
111
120
|
__next40pxDefaultSize: true,
|
|
@@ -122,6 +131,45 @@ function RevisionsSlider() {
|
|
|
122
131
|
withInputField: false
|
|
123
132
|
}
|
|
124
133
|
);
|
|
134
|
+
if (!showPagination) {
|
|
135
|
+
return sliderOrSpinner;
|
|
136
|
+
}
|
|
137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Stack, { direction: "row", gap: "sm", align: "center", style: { flex: 1 }, children: [
|
|
138
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
139
|
+
import_components.Button,
|
|
140
|
+
{
|
|
141
|
+
icon: import_icons.chevronLeft,
|
|
142
|
+
label: revisionPage < totalPages ? getPageRangeLabel(revisionPage + 1) : (0, import_i18n.__)("No older revisions"),
|
|
143
|
+
onClick: () => setRevisionPage(revisionPage + 1),
|
|
144
|
+
disabled: isLoading || revisionPage >= totalPages,
|
|
145
|
+
size: "compact",
|
|
146
|
+
accessibleWhenDisabled: true
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
150
|
+
"div",
|
|
151
|
+
{
|
|
152
|
+
style: {
|
|
153
|
+
flex: 1,
|
|
154
|
+
minWidth: 0,
|
|
155
|
+
display: "flex",
|
|
156
|
+
justifyContent: "center"
|
|
157
|
+
},
|
|
158
|
+
children: sliderOrSpinner
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
162
|
+
import_components.Button,
|
|
163
|
+
{
|
|
164
|
+
icon: import_icons.chevronRight,
|
|
165
|
+
label: revisionPage > 1 ? getPageRangeLabel(revisionPage - 1) : (0, import_i18n.__)("No newer revisions"),
|
|
166
|
+
onClick: () => setRevisionPage(revisionPage - 1),
|
|
167
|
+
disabled: isLoading || revisionPage <= 1,
|
|
168
|
+
size: "compact",
|
|
169
|
+
accessibleWhenDisabled: true
|
|
170
|
+
}
|
|
171
|
+
)
|
|
172
|
+
] });
|
|
125
173
|
}
|
|
126
174
|
var revisions_slider_default = RevisionsSlider;
|
|
127
175
|
//# sourceMappingURL=revisions-slider.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-revisions-preview/revisions-slider.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { RangeControl, Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { dateI18n, getSettings as getDateSettings } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Slider component for navigating revisions.\n *\n * @return {React.JSX.Element} The revisions slider component.\n */\nfunction RevisionsSlider() {\n\tconst {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { RangeControl, Spinner, Button } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { dateI18n, getSettings as getDateSettings } from '@wordpress/date';\nimport { useMemo } from '@wordpress/element';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Slider component for navigating revisions with pagination.\n *\n * @return {React.JSX.Element} The revisions slider component.\n */\nfunction RevisionsSlider() {\n\tconst {\n\t\trevisions: rawRevisions,\n\t\tperPage,\n\t\tcurrentRevisionId,\n\t\trevisionKey,\n\t\trevisionPage,\n\t\ttotalRevisions,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetCurrentRevisionId,\n\t\t\tgetRevisionPage,\n\t\t\tgetPageRevisions,\n\t\t\tgetRevisionsPerPage,\n\t\t} = unlock( select( editorStore ) );\n\n\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\tif ( ! postType ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst entityConfig = select( coreStore ).getEntityConfig(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tconst _revisionKey = entityConfig?.revisionKey || 'id';\n\t\tconst _revisionPage = getRevisionPage();\n\n\t\treturn {\n\t\t\trevisions: getPageRevisions( _revisionPage ),\n\t\t\tperPage: getRevisionsPerPage(),\n\t\t\tcurrentRevisionId: getCurrentRevisionId(),\n\t\t\trevisionKey: _revisionKey,\n\t\t\trevisionPage: _revisionPage,\n\t\t\ttotalRevisions:\n\t\t\t\tselect( editorStore ).getCurrentPostRevisionsCount(),\n\t\t};\n\t}, [] );\n\n\tconst { setCurrentRevisionId, setRevisionPage } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\n\n\tconst isLoading = ! rawRevisions;\n\tconst totalPages = Math.ceil( totalRevisions / perPage ) || 1;\n\n\t// Reverse desc\u2192asc so the slider reads oldest (left) \u2192 newest (right).\n\tconst revisions = useMemo(\n\t\t() => rawRevisions && [ ...rawRevisions ].reverse(),\n\t\t[ rawRevisions ]\n\t);\n\n\tconst selectedIndex = revisions?.findIndex(\n\t\t( r ) => r[ revisionKey ] === currentRevisionId\n\t);\n\n\tconst handleSliderChange = ( index ) => {\n\t\tconst revision = revisions?.[ index ];\n\t\tif ( revision ) {\n\t\t\tsetCurrentRevisionId( revision[ revisionKey ] );\n\t\t}\n\t};\n\n\t// Format date for tooltip.\n\tconst dateSettings = getDateSettings();\n\tconst renderTooltipContent = ( index ) => {\n\t\tconst revision = revisions?.[ index ];\n\t\tif ( ! revision ) {\n\t\t\treturn index;\n\t\t}\n\t\treturn dateI18n( dateSettings.formats.datetime, revision.date );\n\t};\n\n\tconst showPagination = totalPages > 1;\n\n\tif ( isLoading && ! showPagination ) {\n\t\treturn <Spinner />;\n\t}\n\n\tif ( ! isLoading && ! revisions?.length ) {\n\t\treturn (\n\t\t\t<span className=\"editor-revisions-header__no-revisions\">\n\t\t\t\t{ __( 'No revisions found.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\tif ( totalRevisions <= 1 ) {\n\t\treturn (\n\t\t\t<span className=\"editor-revisions-header__no-revisions\">\n\t\t\t\t{ __( 'Only one revision found.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\tconst getPageRangeLabel = ( page ) => {\n\t\tconst end = totalRevisions - ( page - 1 ) * perPage;\n\t\tconst start = Math.max( 1, end - perPage + 1 );\n\t\treturn sprintf(\n\t\t\t/* translators: 1: first revision number, 2: last revision number */\n\t\t\t__( 'Revisions %1$s\u2013%2$s' ),\n\t\t\tstart,\n\t\t\tend\n\t\t);\n\t};\n\n\tconst sliderOrSpinner =\n\t\tisLoading || selectedIndex === -1 ? (\n\t\t\t<Spinner />\n\t\t) : (\n\t\t\t<RangeControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\taria-valuetext={ renderTooltipContent( selectedIndex ) }\n\t\t\t\tclassName=\"editor-revisions-header__slider\"\n\t\t\t\thideLabelFromVision\n\t\t\t\tlabel={ __( 'Revision' ) }\n\t\t\t\tmax={ revisions?.length - 1 }\n\t\t\t\tmin={ 0 }\n\t\t\t\tmarks\n\t\t\t\tonChange={ handleSliderChange }\n\t\t\t\trenderTooltipContent={ renderTooltipContent }\n\t\t\t\tvalue={ selectedIndex }\n\t\t\t\twithInputField={ false }\n\t\t\t/>\n\t\t);\n\n\tif ( ! showPagination ) {\n\t\treturn sliderOrSpinner;\n\t}\n\n\treturn (\n\t\t<Stack direction=\"row\" gap=\"sm\" align=\"center\" style={ { flex: 1 } }>\n\t\t\t<Button\n\t\t\t\ticon={ chevronLeft }\n\t\t\t\tlabel={\n\t\t\t\t\trevisionPage < totalPages\n\t\t\t\t\t\t? getPageRangeLabel( revisionPage + 1 )\n\t\t\t\t\t\t: __( 'No older revisions' )\n\t\t\t\t}\n\t\t\t\tonClick={ () => setRevisionPage( revisionPage + 1 ) }\n\t\t\t\tdisabled={ isLoading || revisionPage >= totalPages }\n\t\t\t\tsize=\"compact\"\n\t\t\t\taccessibleWhenDisabled\n\t\t\t/>\n\t\t\t<div\n\t\t\t\tstyle={ {\n\t\t\t\t\tflex: 1,\n\t\t\t\t\tminWidth: 0,\n\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ sliderOrSpinner }\n\t\t\t</div>\n\t\t\t<Button\n\t\t\t\ticon={ chevronRight }\n\t\t\t\tlabel={\n\t\t\t\t\trevisionPage > 1\n\t\t\t\t\t\t? getPageRangeLabel( revisionPage - 1 )\n\t\t\t\t\t\t: __( 'No newer revisions' )\n\t\t\t\t}\n\t\t\t\tonClick={ () => setRevisionPage( revisionPage - 1 ) }\n\t\t\t\tdisabled={ isLoading || revisionPage <= 1 }\n\t\t\t\tsize=\"compact\"\n\t\t\t\taccessibleWhenDisabled\n\t\t\t/>\n\t\t</Stack>\n\t);\n}\n\nexport default RevisionsSlider;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,wBAA8C;AAC9C,uBAAmC;AACnC,kBAA4B;AAC5B,kBAAyD;AACzD,qBAAwB;AACxB,mBAA0C;AAC1C,gBAAsB;AAKtB,mBAAqC;AACrC,yBAAuB;AAmFd;AA5ET,SAAS,kBAAkB;AAC1B,QAAM;AAAA,IACL,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,uBAAW,CAAE,WAAY;AAC5B,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,QAAI,2BAAQ,OAAQ,aAAAA,KAAY,CAAE;AAElC,UAAM,WAAW,OAAQ,aAAAA,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ACP,MAAM;AAAA,UACN,UAAU;AAAA,UACV,SAAS;AAAA,UACT,gBAAgB;AAAA,QACjB;AAAA,QAEE;AAAA;AAAA,IACH;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAO;AAAA,QACP,OACC,eAAe,IACZ,kBAAmB,eAAe,CAAE,QACpC,gBAAI,oBAAqB;AAAA,QAE7B,SAAU,MAAM,gBAAiB,eAAe,CAAE;AAAA,QAClD,UAAW,aAAa,gBAAgB;AAAA,QACxC,MAAK;AAAA,QACL,wBAAsB;AAAA;AAAA,IACvB;AAAA,KACD;AAEF;AAEA,IAAO,2BAAQ;",
|
|
6
6
|
"names": ["editorStore", "coreStore", "getDateSettings"]
|
|
7
7
|
}
|
|
@@ -42,6 +42,7 @@ __export(private_actions_exports, {
|
|
|
42
42
|
setCurrentRevisionId: () => setCurrentRevisionId,
|
|
43
43
|
setCurrentTemplateId: () => setCurrentTemplateId,
|
|
44
44
|
setDefaultRenderingMode: () => setDefaultRenderingMode,
|
|
45
|
+
setRevisionPage: () => setRevisionPage,
|
|
45
46
|
setShowRevisionDiff: () => setShowRevisionDiff,
|
|
46
47
|
setShowStylebook: () => setShowStylebook,
|
|
47
48
|
setStylesPath: () => setStylesPath,
|
|
@@ -59,6 +60,7 @@ var import_blocks = require("@wordpress/blocks");
|
|
|
59
60
|
var import_html_entities = require("@wordpress/html-entities");
|
|
60
61
|
var import_date = require("@wordpress/date");
|
|
61
62
|
var import_is_template_revertable = __toESM(require("./utils/is-template-revertable.cjs"));
|
|
63
|
+
var import_private_selectors = require("./private-selectors.cjs");
|
|
62
64
|
__reExport(private_actions_exports, require("../dataviews/store/private-actions.cjs"), module.exports);
|
|
63
65
|
function setCurrentTemplateId(id) {
|
|
64
66
|
return {
|
|
@@ -411,6 +413,24 @@ function setCurrentRevisionId(revisionId) {
|
|
|
411
413
|
revisionId
|
|
412
414
|
};
|
|
413
415
|
}
|
|
416
|
+
var setRevisionPage = (page) => async ({ dispatch, select, registry }) => {
|
|
417
|
+
const postType = select.getCurrentPostType();
|
|
418
|
+
const postId = select.getCurrentPostId();
|
|
419
|
+
const entityConfig = registry.select(import_core_data.store).getEntityConfig("postType", postType);
|
|
420
|
+
const revisionKey = entityConfig?.revisionKey || "id";
|
|
421
|
+
const revisions = await registry.resolveSelect(import_core_data.store).getRevisions(
|
|
422
|
+
"postType",
|
|
423
|
+
postType,
|
|
424
|
+
postId,
|
|
425
|
+
(0, import_private_selectors.buildRevisionsPageQuery)(revisionKey, page)
|
|
426
|
+
);
|
|
427
|
+
registry.batch(() => {
|
|
428
|
+
dispatch({ type: "SET_REVISION_PAGE", page });
|
|
429
|
+
if (revisions?.length) {
|
|
430
|
+
dispatch.setCurrentRevisionId(revisions[0][revisionKey]);
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
};
|
|
414
434
|
function setShowRevisionDiff(showDiff) {
|
|
415
435
|
return {
|
|
416
436
|
type: "SET_SHOW_REVISION_DIFF",
|
|
@@ -489,6 +509,7 @@ function selectNote(noteId, options = { focus: false }) {
|
|
|
489
509
|
setCurrentRevisionId,
|
|
490
510
|
setCurrentTemplateId,
|
|
491
511
|
setDefaultRenderingMode,
|
|
512
|
+
setRevisionPage,
|
|
492
513
|
setShowRevisionDiff,
|
|
493
514
|
setShowStylebook,
|
|
494
515
|
setStylesPath,
|