@wordpress/editor 14.49.1 → 14.51.1-next.v.202607070741.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 +12 -0
- package/build/components/collab-sidebar/format.cjs +83 -0
- package/build/components/collab-sidebar/format.cjs.map +7 -0
- package/build/components/collab-sidebar/hooks.cjs +117 -16
- package/build/components/collab-sidebar/hooks.cjs.map +2 -2
- package/build/components/collab-sidebar/index.cjs +18 -2
- package/build/components/collab-sidebar/index.cjs.map +2 -2
- package/build/components/collab-sidebar/note-highlight-styles.cjs +67 -0
- package/build/components/collab-sidebar/note-highlight-styles.cjs.map +7 -0
- package/build/components/collab-sidebar/utils.cjs +139 -0
- package/build/components/collab-sidebar/utils.cjs.map +2 -2
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs +55 -30
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +2 -2
- package/build/components/commands/index.cjs +99 -3
- package/build/components/commands/index.cjs.map +2 -2
- package/build/components/document-bar/index.cjs +28 -34
- package/build/components/document-bar/index.cjs.map +2 -2
- package/build/components/entities-saved-states/index.cjs +1 -4
- package/build/components/entities-saved-states/index.cjs.map +2 -2
- package/build/components/header/index.cjs +1 -8
- package/build/components/header/index.cjs.map +2 -2
- package/build/components/media-categories/index.cjs +92 -6
- package/build/components/media-categories/index.cjs.map +2 -2
- package/build/components/page-attributes/parent.cjs +0 -1
- package/build/components/page-attributes/parent.cjs.map +2 -2
- package/build/components/post-author/combobox.cjs +0 -1
- package/build/components/post-author/combobox.cjs.map +2 -2
- package/build/components/post-author/select.cjs +0 -1
- package/build/components/post-author/select.cjs.map +2 -2
- package/build/components/post-preview-button/index.cjs +29 -2
- package/build/components/post-preview-button/index.cjs.map +2 -2
- package/build/components/post-publish-panel/maybe-upload-media.cjs +15 -26
- package/build/components/post-publish-panel/maybe-upload-media.cjs.map +3 -3
- package/build/components/post-revisions-preview/revisions-slider.cjs +3 -1
- package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
- package/build/components/post-taxonomies/flat-term-selector.cjs +0 -1
- package/build/components/post-taxonomies/flat-term-selector.cjs.map +2 -2
- package/build/components/post-taxonomies/hierarchical-term-selector.cjs +0 -2
- package/build/components/post-taxonomies/hierarchical-term-selector.cjs.map +2 -2
- package/build/components/post-template/classic-theme.cjs +0 -1
- package/build/components/post-template/classic-theme.cjs.map +2 -2
- package/build/components/preferences-modal/index.cjs +54 -28
- package/build/components/preferences-modal/index.cjs.map +2 -2
- package/build/components/preview-dropdown/index.cjs +38 -9
- package/build/components/preview-dropdown/index.cjs.map +3 -3
- package/build/components/provider/use-block-editor-settings.cjs +23 -9
- package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
- package/build/components/resizable-editor/index.cjs +54 -9
- package/build/components/resizable-editor/index.cjs.map +3 -3
- package/build/components/sidebar/dataform-post-summary.cjs +5 -1
- package/build/components/sidebar/dataform-post-summary.cjs.map +3 -3
- package/build/components/sidebar/index.cjs +29 -38
- package/build/components/sidebar/index.cjs.map +3 -3
- package/build/components/sidebar/post-summary.cjs +0 -13
- package/build/components/sidebar/post-summary.cjs.map +3 -3
- package/build/components/visual-editor/index.cjs +15 -11
- package/build/components/visual-editor/index.cjs.map +3 -3
- package/build/dataviews/store/private-actions.cjs +24 -19
- package/build/dataviews/store/private-actions.cjs.map +2 -2
- package/build/store/actions.cjs +5 -3
- package/build/store/actions.cjs.map +2 -2
- package/build/store/constants.cjs +26 -0
- package/build/store/constants.cjs.map +2 -2
- package/build/store/private-actions.cjs +25 -18
- package/build/store/private-actions.cjs.map +3 -3
- package/build/store/private-selectors.cjs +5 -0
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +6 -6
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +3 -1
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/device-type.cjs +52 -0
- package/build/utils/device-type.cjs.map +7 -0
- package/build/utils/media-sideload-from-url/index.cjs +63 -0
- package/build/utils/media-sideload-from-url/index.cjs.map +7 -0
- package/build-module/components/collab-sidebar/format.mjs +57 -0
- package/build-module/components/collab-sidebar/format.mjs.map +7 -0
- package/build-module/components/collab-sidebar/hooks.mjs +121 -16
- package/build-module/components/collab-sidebar/hooks.mjs.map +2 -2
- package/build-module/components/collab-sidebar/index.mjs +21 -5
- package/build-module/components/collab-sidebar/index.mjs.map +2 -2
- package/build-module/components/collab-sidebar/note-highlight-styles.mjs +41 -0
- package/build-module/components/collab-sidebar/note-highlight-styles.mjs.map +7 -0
- package/build-module/components/collab-sidebar/utils.mjs +133 -0
- package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +55 -30
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +2 -2
- package/build-module/components/commands/index.mjs +99 -3
- package/build-module/components/commands/index.mjs.map +2 -2
- package/build-module/components/document-bar/index.mjs +28 -34
- package/build-module/components/document-bar/index.mjs.map +2 -2
- package/build-module/components/entities-saved-states/index.mjs +1 -4
- package/build-module/components/entities-saved-states/index.mjs.map +2 -2
- package/build-module/components/header/index.mjs +1 -13
- package/build-module/components/header/index.mjs.map +2 -2
- package/build-module/components/media-categories/index.mjs +93 -7
- package/build-module/components/media-categories/index.mjs.map +2 -2
- package/build-module/components/page-attributes/parent.mjs +0 -1
- package/build-module/components/page-attributes/parent.mjs.map +2 -2
- package/build-module/components/post-author/combobox.mjs +0 -1
- package/build-module/components/post-author/combobox.mjs.map +2 -2
- package/build-module/components/post-author/select.mjs +0 -1
- package/build-module/components/post-author/select.mjs.map +2 -2
- package/build-module/components/post-preview-button/index.mjs +29 -2
- package/build-module/components/post-preview-button/index.mjs.map +2 -2
- package/build-module/components/post-publish-panel/maybe-upload-media.mjs +19 -27
- package/build-module/components/post-publish-panel/maybe-upload-media.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/revisions-slider.mjs +3 -1
- package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
- package/build-module/components/post-taxonomies/flat-term-selector.mjs +0 -1
- package/build-module/components/post-taxonomies/flat-term-selector.mjs.map +2 -2
- package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs +0 -2
- package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs.map +2 -2
- package/build-module/components/post-template/classic-theme.mjs +0 -1
- package/build-module/components/post-template/classic-theme.mjs.map +2 -2
- package/build-module/components/preferences-modal/index.mjs +54 -28
- package/build-module/components/preferences-modal/index.mjs.map +2 -2
- package/build-module/components/preview-dropdown/index.mjs +38 -9
- package/build-module/components/preview-dropdown/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.mjs +23 -9
- package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
- package/build-module/components/resizable-editor/index.mjs +55 -10
- package/build-module/components/resizable-editor/index.mjs.map +2 -2
- package/build-module/components/sidebar/dataform-post-summary.mjs +6 -2
- package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +29 -42
- package/build-module/components/sidebar/index.mjs.map +2 -2
- package/build-module/components/sidebar/post-summary.mjs +0 -13
- package/build-module/components/sidebar/post-summary.mjs.map +2 -2
- package/build-module/components/visual-editor/index.mjs +16 -13
- package/build-module/components/visual-editor/index.mjs.map +2 -2
- package/build-module/dataviews/store/private-actions.mjs +26 -19
- package/build-module/dataviews/store/private-actions.mjs.map +2 -2
- package/build-module/store/actions.mjs +5 -3
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/constants.mjs +25 -0
- package/build-module/store/constants.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +27 -17
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +4 -0
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +5 -5
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +3 -1
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/device-type.mjs +25 -0
- package/build-module/utils/device-type.mjs.map +7 -0
- package/build-module/utils/media-sideload-from-url/index.mjs +32 -0
- package/build-module/utils/media-sideload-from-url/index.mjs.map +7 -0
- package/build-style/style-rtl.css +84 -39
- package/build-style/style.css +84 -39
- package/build-types/components/collab-sidebar/format.d.ts +17 -0
- package/build-types/components/collab-sidebar/format.d.ts.map +1 -0
- 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-highlight-styles.d.ts +31 -0
- package/build-types/components/collab-sidebar/note-highlight-styles.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/utils.d.ts +82 -2
- package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -1
- package/build-types/components/commands/index.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/media-categories/index.d.ts +12 -3
- package/build-types/components/media-categories/index.d.ts.map +1 -1
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/post-author/combobox.d.ts.map +1 -1
- package/build-types/components/post-author/select.d.ts.map +1 -1
- package/build-types/components/post-preview-button/index.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-revisions-preview/revisions-slider.d.ts.map +1 -1
- 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.map +1 -1
- package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
- package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/resizable-editor/index.d.ts.map +1 -1
- package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/constants.d.ts +6 -0
- package/build-types/store/constants.d.ts.map +1 -1
- package/build-types/store/index.d.ts +2 -2
- package/build-types/store/private-actions.d.ts +9 -15
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +7 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +6 -7
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +1 -1
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/utils/device-type.d.ts +23 -0
- package/build-types/utils/device-type.d.ts.map +1 -0
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
- package/build-types/utils/media-sideload-from-url/index.d.ts +18 -0
- package/build-types/utils/media-sideload-from-url/index.d.ts.map +1 -0
- package/package.json +48 -46
- package/src/components/collab-sidebar/format.js +72 -0
- package/src/components/collab-sidebar/hooks.js +203 -22
- package/src/components/collab-sidebar/index.js +19 -5
- package/src/components/collab-sidebar/note-highlight-styles.js +83 -0
- package/src/components/collab-sidebar/style.scss +9 -0
- package/src/components/collab-sidebar/test/note-highlight-styles.js +106 -0
- package/src/components/collab-sidebar/test/utils.js +471 -0
- package/src/components/collab-sidebar/utils.js +225 -2
- package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +265 -262
- package/src/components/collaborators-presence/use-collaborator-notifications.ts +70 -34
- package/src/components/commands/index.js +142 -0
- package/src/components/document-bar/index.js +0 -9
- package/src/components/document-bar/style.scss +0 -17
- package/src/components/entities-saved-states/index.js +1 -5
- package/src/components/header/index.js +1 -15
- package/src/components/header/style.scss +7 -3
- package/src/components/media-categories/index.js +160 -6
- package/src/components/media-categories/test/index.js +202 -0
- package/src/components/page-attributes/parent.js +0 -1
- package/src/components/post-author/combobox.js +0 -1
- package/src/components/post-author/select.js +0 -1
- package/src/components/post-preview-button/index.js +68 -2
- package/src/components/post-publish-panel/maybe-upload-media.js +25 -30
- package/src/components/post-publish-panel/style.scss +1 -1
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +11 -127
- package/src/components/post-revisions-preview/revisions-slider.js +4 -1
- package/src/components/post-revisions-preview/test/block-diff.js +2 -2
- package/src/components/post-taxonomies/flat-term-selector.js +0 -1
- package/src/components/post-taxonomies/hierarchical-term-selector.js +0 -2
- package/src/components/post-template/classic-theme.js +0 -1
- package/src/components/preferences-modal/index.js +40 -22
- package/src/components/preferences-modal/test/index.js +83 -0
- package/src/components/preview-dropdown/index.js +42 -3
- package/src/components/provider/use-block-editor-settings.js +42 -7
- package/src/components/resizable-editor/index.js +71 -9
- package/src/components/resizable-editor/style.scss +7 -0
- package/src/components/sidebar/dataform-post-summary.js +13 -1
- package/src/components/sidebar/index.js +32 -47
- package/src/components/sidebar/post-summary.js +0 -17
- package/src/components/styles-canvas/style.scss +1 -2
- package/src/components/visual-editor/index.js +19 -15
- package/src/components/visual-editor/style.scss +11 -4
- package/src/dataviews/store/private-actions.ts +30 -26
- package/src/store/actions.js +6 -3
- package/src/store/constants.ts +45 -0
- package/src/store/private-actions.js +38 -28
- package/src/store/private-selectors.js +10 -0
- package/src/store/reducer.js +7 -9
- package/src/store/selectors.js +3 -1
- package/src/store/test/actions.js +31 -22
- package/src/utils/device-type.js +46 -0
- package/src/utils/media-sideload-from-url/index.js +54 -0
- package/src/utils/media-sideload-from-url/test/index.js +162 -0
- package/build/components/post-publish-panel/media-util.cjs +0 -72
- package/build/components/post-publish-panel/media-util.cjs.map +0 -7
- package/build-module/components/post-publish-panel/media-util.mjs +0 -46
- package/build-module/components/post-publish-panel/media-util.mjs.map +0 -7
- package/build-types/components/post-publish-panel/media-util.d.ts +0 -20
- package/build-types/components/post-publish-panel/media-util.d.ts.map +0 -1
- package/src/components/post-publish-panel/media-util.js +0 -87
- package/src/components/post-publish-panel/test/media-util.js +0 -118
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/collab-sidebar/note-highlight-styles.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useStyleOverride } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { getAvatarBorderColor } from './utils';\n\n// Hex alpha suffixes for the rest / active states. Kept low so the marker\n// reads as a soft tint at rest and gets noticeably stronger when focused or\n// hovered. (0x40 ≈ 25%, 0x80 ≈ 50%.)\nconst REST_ALPHA = '40';\nconst ACTIVE_ALPHA = '80';\n\n// Reset the browser's default `<mark>` styling so the per-author rules below\n// are what readers actually see (without it, `mark` ships with a bright yellow\n// background in every browser). The `core/note` anchor marker serializes as a\n// `<mark>` and would otherwise inherit the yellow default in the editor canvas.\nconst BASE_RESET = 'mark.wp-note{background-color:transparent;color:inherit;}';\n\n/**\n * Build the CSS rule set that tints each inline-note marker with its author's\n * avatar color. Pure helper extracted so it can be unit-tested without React.\n *\n * @param {Array} threads Unresolved note threads (each with `id` and `author`).\n * @param {string|null} selectedId ID of the currently selected note, if any.\n * @return {string} A serialized CSS string targeting the in-content note markers.\n */\nexport function buildHighlightCss( threads, selectedId = null ) {\n\tconst rules = [ BASE_RESET ];\n\tfor ( const thread of threads ?? [] ) {\n\t\tif ( ! thread?.id ) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst color = getAvatarBorderColor( thread.author ?? 0 );\n\t\t// The `core/note` format serializes the id into `data-id`, so the marker\n\t\t// can be targeted directly without a separate annotation layer.\n\t\t// `thread.id` is a server comment ID (always a positive integer), but\n\t\t// escape `\"`/`\\` defensively since it composes a quoted attribute value\n\t\t// from stored data.\n\t\tconst escapedId = String( thread.id ).replace( /[\"\\\\]/g, '\\\\$&' );\n\t\tconst sel = `mark.wp-note[data-id=\"${ escapedId }\"]`;\n\t\trules.push( `${ sel }{background-color:${ color }${ REST_ALPHA };}` );\n\t\trules.push(\n\t\t\t`${ sel }:hover,${ sel }:focus-within{background-color:${ color }${ ACTIVE_ALPHA };}`\n\t\t);\n\t\tif ( selectedId && String( selectedId ) === String( thread.id ) ) {\n\t\t\trules.push(\n\t\t\t\t`${ sel }{background-color:${ color }${ ACTIVE_ALPHA };}`\n\t\t\t);\n\t\t}\n\t}\n\treturn rules.join( '' );\n}\n\n/**\n * Injects per-note background rules into the editor canvas so inline-note\n * markers carry their author's avatar color. The `core/note` format serializes\n * each marker as `<mark class=\"wp-note\" data-id=\"{noteId}\">`, which we target\n * directly.\n *\n * Uses `useStyleOverride` so the styles reach the iframed canvas; a plain\n * `<style>` element rendered in the sidebar would only affect the parent doc.\n *\n * Opacity boosts on `:hover`, `:focus-within`, and when the matching thread is\n * the editor's selected note.\n *\n * @param {Object} props\n * @param {Array} props.threads Unresolved note threads.\n * @param {string|null} [props.selectedId] ID of the currently selected note.\n * @return {null} Renders nothing; styles are applied via `useStyleOverride`.\n */\nexport function NoteHighlightStyles( { threads, selectedId } ) {\n\tconst css = useMemo(\n\t\t() => buildHighlightCss( threads, selectedId ),\n\t\t[ threads, selectedId ]\n\t);\n\tuseStyleOverride( { id: 'core-note-highlights', css } );\n\treturn null;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AACxB,0BAAiC;AAKjC,mBAAqC;AAKrC,IAAM,aAAa;AACnB,IAAM,eAAe;AAMrB,IAAM,aAAa;AAUZ,SAAS,kBAAmB,SAAS,aAAa,MAAO;AAC/D,QAAM,QAAQ,CAAE,UAAW;AAC3B,aAAY,UAAU,WAAW,CAAC,GAAI;AACrC,QAAK,CAAE,QAAQ,IAAK;AACnB;AAAA,IACD;AACA,UAAM,YAAQ,mCAAsB,OAAO,UAAU,CAAE;AAMvD,UAAM,YAAY,OAAQ,OAAO,EAAG,EAAE,QAAS,UAAU,MAAO;AAChE,UAAM,MAAM,yBAA0B,SAAU;AAChD,UAAM,KAAM,GAAI,GAAI,qBAAsB,KAAM,GAAI,UAAW,IAAK;AACpE,UAAM;AAAA,MACL,GAAI,GAAI,UAAW,GAAI,kCAAmC,KAAM,GAAI,YAAa;AAAA,IAClF;AACA,QAAK,cAAc,OAAQ,UAAW,MAAM,OAAQ,OAAO,EAAG,GAAI;AACjE,YAAM;AAAA,QACL,GAAI,GAAI,qBAAsB,KAAM,GAAI,YAAa;AAAA,MACtD;AAAA,IACD;AAAA,EACD;AACA,SAAO,MAAM,KAAM,EAAG;AACvB;AAmBO,SAAS,oBAAqB,EAAE,SAAS,WAAW,GAAI;AAC9D,QAAM,UAAM;AAAA,IACX,MAAM,kBAAmB,SAAS,UAAW;AAAA,IAC7C,CAAE,SAAS,UAAW;AAAA,EACvB;AACA,4CAAkB,EAAE,IAAI,wBAAwB,IAAI,CAAE;AACtD,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -20,19 +20,26 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// packages/editor/src/components/collab-sidebar/utils.js
|
|
21
21
|
var utils_exports = {};
|
|
22
22
|
__export(utils_exports, {
|
|
23
|
+
BLOCK_LEVEL_NOTE_START: () => BLOCK_LEVEL_NOTE_START,
|
|
23
24
|
addNoteIdToMetadata: () => addNoteIdToMetadata,
|
|
25
|
+
applyNoteFormat: () => applyNoteFormat,
|
|
24
26
|
calculateNotePositions: () => calculateNotePositions,
|
|
27
|
+
findNoteInBlock: () => findNoteInBlock,
|
|
28
|
+
findNoteRange: () => findNoteRange,
|
|
25
29
|
focusNoteThread: () => focusNoteThread,
|
|
26
30
|
getAvatarBorderColor: () => getAvatarBorderColor,
|
|
31
|
+
getInlineMarkerStart: () => getInlineMarkerStart,
|
|
27
32
|
getNoteExcerpt: () => getNoteExcerpt,
|
|
28
33
|
getNoteIdsFromMetadata: () => getNoteIdsFromMetadata,
|
|
29
34
|
pickPrimaryNote: () => pickPrimaryNote,
|
|
35
|
+
removeNoteFormat: () => removeNoteFormat,
|
|
30
36
|
removeNoteIdFromMetadata: () => removeNoteIdFromMetadata,
|
|
31
37
|
sanitizeNoteContent: () => sanitizeNoteContent,
|
|
32
38
|
scrollNoteThreadIntoView: () => scrollNoteThreadIntoView
|
|
33
39
|
});
|
|
34
40
|
module.exports = __toCommonJS(utils_exports);
|
|
35
41
|
var import_i18n = require("@wordpress/i18n");
|
|
42
|
+
var import_rich_text = require("@wordpress/rich-text");
|
|
36
43
|
function sanitizeNoteContent(str) {
|
|
37
44
|
return str.trim();
|
|
38
45
|
}
|
|
@@ -98,6 +105,132 @@ function addNoteIdToMetadata(metadata, noteId) {
|
|
|
98
105
|
ids.add(id);
|
|
99
106
|
return { ...metadata, noteId: [...ids] };
|
|
100
107
|
}
|
|
108
|
+
var NOTE_FORMAT_TYPE = "core/note";
|
|
109
|
+
function findNoteRange(value, noteId) {
|
|
110
|
+
if (noteId === void 0 || noteId === null) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
let html = null;
|
|
114
|
+
if (value instanceof import_rich_text.RichTextData) {
|
|
115
|
+
html = value.toHTMLString();
|
|
116
|
+
} else if (typeof value === "string") {
|
|
117
|
+
html = value;
|
|
118
|
+
}
|
|
119
|
+
if (!html || html.indexOf("wp-note") === -1) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const target = String(noteId);
|
|
123
|
+
const record = (0, import_rich_text.create)({ html });
|
|
124
|
+
const formats = record.formats;
|
|
125
|
+
let start = -1;
|
|
126
|
+
for (let i = 0; i < formats.length; i++) {
|
|
127
|
+
const stack = formats[i];
|
|
128
|
+
const hit = stack?.find(
|
|
129
|
+
(f) => f.type === NOTE_FORMAT_TYPE && f.attributes && f.attributes["data-id"] === target
|
|
130
|
+
);
|
|
131
|
+
if (hit) {
|
|
132
|
+
if (start === -1) {
|
|
133
|
+
start = i;
|
|
134
|
+
}
|
|
135
|
+
} else if (start !== -1) {
|
|
136
|
+
return { start, end: i };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (start !== -1) {
|
|
140
|
+
return { start, end: formats.length };
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
function findNoteInBlock(attributes, noteId) {
|
|
145
|
+
if (!attributes) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
for (const attributeKey of Object.keys(attributes)) {
|
|
149
|
+
const range = findNoteRange(attributes[attributeKey], noteId);
|
|
150
|
+
if (range) {
|
|
151
|
+
return { attributeKey, start: range.start, end: range.end };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
var BLOCK_LEVEL_NOTE_START = -1;
|
|
157
|
+
function getInlineMarkerStart(thread, attributes) {
|
|
158
|
+
const found = findNoteInBlock(attributes, thread?.id);
|
|
159
|
+
return found ? found.start : BLOCK_LEVEL_NOTE_START;
|
|
160
|
+
}
|
|
161
|
+
function applyNoteFormat(record, format, start, end) {
|
|
162
|
+
const formats = record.formats.slice();
|
|
163
|
+
for (let i = start; i < end; i++) {
|
|
164
|
+
const stack = formats[i] ? formats[i].slice() : [];
|
|
165
|
+
stack.push(format);
|
|
166
|
+
formats[i] = stack;
|
|
167
|
+
}
|
|
168
|
+
const spans = /* @__PURE__ */ new Map();
|
|
169
|
+
for (let i = 0; i < formats.length; i++) {
|
|
170
|
+
const stack = formats[i];
|
|
171
|
+
if (!stack) {
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
for (const fmt of stack) {
|
|
175
|
+
if (fmt.type !== NOTE_FORMAT_TYPE) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
const id = fmt.attributes?.["data-id"];
|
|
179
|
+
const span = spans.get(id);
|
|
180
|
+
if (span) {
|
|
181
|
+
span.end = i;
|
|
182
|
+
} else {
|
|
183
|
+
spans.set(id, { start: i, end: i });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const sizeOf = (id) => {
|
|
188
|
+
const span = spans.get(id);
|
|
189
|
+
return span ? span.end - span.start : 0;
|
|
190
|
+
};
|
|
191
|
+
for (let i = 0; i < formats.length; i++) {
|
|
192
|
+
const stack = formats[i];
|
|
193
|
+
if (!stack || stack.length < 2) {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const notes = stack.filter((fmt) => fmt.type === NOTE_FORMAT_TYPE);
|
|
197
|
+
if (notes.length === 0) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
if (notes.length > 1) {
|
|
201
|
+
notes.sort(
|
|
202
|
+
(a, b) => sizeOf(b.attributes?.["data-id"]) - sizeOf(a.attributes?.["data-id"])
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
const others = stack.filter((fmt) => fmt.type !== NOTE_FORMAT_TYPE);
|
|
206
|
+
formats[i] = [...notes, ...others];
|
|
207
|
+
}
|
|
208
|
+
return { ...record, formats };
|
|
209
|
+
}
|
|
210
|
+
function removeNoteFormat(value, noteId) {
|
|
211
|
+
if (!(value instanceof import_rich_text.RichTextData)) {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
const target = String(noteId);
|
|
215
|
+
const record = (0, import_rich_text.create)({ html: value.toHTMLString() });
|
|
216
|
+
let changed = false;
|
|
217
|
+
const formats = record.formats.map((stack) => {
|
|
218
|
+
if (!stack) {
|
|
219
|
+
return stack;
|
|
220
|
+
}
|
|
221
|
+
const filtered = stack.filter(
|
|
222
|
+
(format) => !(format.type === NOTE_FORMAT_TYPE && format.attributes?.["data-id"] === target)
|
|
223
|
+
);
|
|
224
|
+
if (filtered.length === stack.length) {
|
|
225
|
+
return stack;
|
|
226
|
+
}
|
|
227
|
+
changed = true;
|
|
228
|
+
return filtered.length ? filtered : void 0;
|
|
229
|
+
});
|
|
230
|
+
return changed ? import_rich_text.RichTextData.fromHTMLString(
|
|
231
|
+
new import_rich_text.RichTextData({ ...record, formats }).toHTMLString()
|
|
232
|
+
) : null;
|
|
233
|
+
}
|
|
101
234
|
function pickPrimaryNote(threads) {
|
|
102
235
|
return threads.find((thread) => thread.status === "hold") ?? threads[0] ?? null;
|
|
103
236
|
}
|
|
@@ -217,13 +350,19 @@ function scrollNoteThreadIntoView(noteId, container) {
|
|
|
217
350
|
}
|
|
218
351
|
// Annotate the CommonJS export names for ESM import in node:
|
|
219
352
|
0 && (module.exports = {
|
|
353
|
+
BLOCK_LEVEL_NOTE_START,
|
|
220
354
|
addNoteIdToMetadata,
|
|
355
|
+
applyNoteFormat,
|
|
221
356
|
calculateNotePositions,
|
|
357
|
+
findNoteInBlock,
|
|
358
|
+
findNoteRange,
|
|
222
359
|
focusNoteThread,
|
|
223
360
|
getAvatarBorderColor,
|
|
361
|
+
getInlineMarkerStart,
|
|
224
362
|
getNoteExcerpt,
|
|
225
363
|
getNoteIdsFromMetadata,
|
|
226
364
|
pickPrimaryNote,
|
|
365
|
+
removeNoteFormat,
|
|
227
366
|
removeNoteIdFromMetadata,
|
|
228
367
|
sanitizeNoteContent,
|
|
229
368
|
scrollNoteThreadIntoView
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/collab-sidebar/utils.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Sanitizes a note string by removing non-printable ASCII characters.\n *\n * @param {string} str - The note string to sanitize.\n * @return {string} - The sanitized note string.\n */\nexport function sanitizeNoteContent( str ) {\n\treturn str.trim();\n}\n\nconst THREAD_ALIGN_OFFSET = -16;\nconst THREAD_GAP = 16;\nconst OVERLAP_MARGIN = 20;\n\n/**\n * Avatar border colors chosen to be visually distinct from each other and from\n * the editor's semantic UI colors (Delta E > 10 between all pairs).\n */\nconst AVATAR_BORDER_COLORS = [\n\t'#C36EFF', // Purple\n\t'#D94145', // Red\n\t'#E4780A', // Orange\n\t'#FF35EE', // Magenta\n\t'#879F11', // Olive\n\t'#46A494', // Teal\n\t'#00A2C3', // Cyan\n];\n\n/**\n * Gets the border color for an avatar based on the user ID.\n *\n * @param {number} userId - The user ID.\n * @return {string} - The border color.\n */\nexport function getAvatarBorderColor( userId ) {\n\treturn AVATAR_BORDER_COLORS[ userId % AVATAR_BORDER_COLORS.length ];\n}\n\n/**\n * Generates a note excerpt from text based on word count type and length.\n *\n * @param {string} text - The note text to generate excerpt from.\n * @param {number} excerptLength - The maximum length for the note excerpt.\n * @return {string} - The generated note excerpt.\n */\nexport function getNoteExcerpt( text, excerptLength = 10 ) {\n\tif ( ! text ) {\n\t\treturn '';\n\t}\n\n\t/*\n\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t * Do not translate into your own language.\n\t */\n\tconst wordCountType = _x( 'words', 'Word count type. Do not translate!' );\n\n\tconst rawText = text.trim();\n\tlet trimmedExcerpt = '';\n\n\tif ( wordCountType === 'words' ) {\n\t\ttrimmedExcerpt = rawText.split( ' ', excerptLength ).join( ' ' );\n\t} else if ( wordCountType === 'characters_excluding_spaces' ) {\n\t\t/*\n\t\t * 1. Split the text at the character limit,\n\t\t * then join the substrings back into one string.\n\t\t * 2. Count the number of spaces in the text\n\t\t * by comparing the lengths of the string with and without spaces.\n\t\t * 3. Add the number to the length of the visible excerpt,\n\t\t * so that the spaces are excluded from the word count.\n\t\t */\n\t\tconst textWithSpaces = rawText.split( '', excerptLength ).join( '' );\n\n\t\tconst numberOfSpaces =\n\t\t\ttextWithSpaces.length - textWithSpaces.replaceAll( ' ', '' ).length;\n\n\t\ttrimmedExcerpt = rawText\n\t\t\t.split( '', excerptLength + numberOfSpaces )\n\t\t\t.join( '' );\n\t} else if ( wordCountType === 'characters_including_spaces' ) {\n\t\ttrimmedExcerpt = rawText.split( '', excerptLength ).join( '' );\n\t}\n\n\tconst isTrimmed = trimmedExcerpt !== rawText;\n\treturn isTrimmed ? trimmedExcerpt + '…' : trimmedExcerpt;\n}\n\n/**\n * Normalizes noteId metadata to always return an array of unique numeric ids,\n * preserving insertion order. Handles both scalar (legacy, possibly\n * string-typed) and array (new) values.\n *\n * @param {Object} metadata Block metadata object\n * @return {number[]} Array of note IDs (may be empty)\n */\nexport function getNoteIdsFromMetadata( metadata ) {\n\tconst noteId = metadata?.noteId;\n\tconst raw = Array.isArray( noteId ) ? noteId : [ noteId ];\n\tconst ids = new Set();\n\tfor ( const value of raw ) {\n\t\tconst id = Number( value );\n\t\tif ( Number.isFinite( id ) && id > 0 ) {\n\t\t\tids.add( id );\n\t\t}\n\t}\n\treturn [ ...ids ];\n}\n\n/**\n * Adds a note ID to the metadata.\n * Converts scalar to array if needed, otherwise appends.\n *\n * @param {Object} metadata Existing block metadata\n * @param {number} noteId Note ID to add\n * @return {Object} Updated metadata object\n */\nexport function addNoteIdToMetadata( metadata, noteId ) {\n\tconst ids = new Set( getNoteIdsFromMetadata( metadata ) );\n\tconst id = Number( noteId );\n\tif ( ids.has( id ) ) {\n\t\treturn metadata;\n\t}\n\tids.add( id );\n\treturn { ...metadata, noteId: [ ...ids ] };\n}\n\n/**\n * Picks the most relevant thread from a list: first unresolved, else first.\n *\n * @param {Array} threads Ordered list of thread objects.\n * @return {Object|null} Selected thread or null when the list is empty.\n */\nexport function pickPrimaryNote( threads ) {\n\treturn (\n\t\tthreads.find( ( thread ) => thread.status === 'hold' ) ??\n\t\tthreads[ 0 ] ??\n\t\tnull\n\t);\n}\n\n/**\n * Removes a note ID from the metadata.\n *\n * @param {Object} metadata Existing block metadata\n * @param {number} noteId Note ID to remove\n * @return {Object} Updated metadata object\n */\nexport function removeNoteIdFromMetadata( metadata, noteId ) {\n\tconst ids = new Set( getNoteIdsFromMetadata( metadata ) );\n\tids.delete( Number( noteId ) );\n\treturn {\n\t\t...metadata,\n\t\tnoteId: ids.size > 0 ? [ ...ids ] : undefined,\n\t};\n}\n\n/**\n * Calculate final top positions for all floating note threads in the\n * editor's content coordinate space. Adjusts positions to prevent overlapping\n * by pushing threads above the selected one upward and threads below it downward.\n *\n * @param {Object} params\n * @param {Array} params.threads Ordered list of thread objects.\n * @param {string|number|undefined} params.selectedNoteId ID of the currently selected thread.\n * @param {Object<string,DOMRect>} params.blockRects Pre-read bounding rects keyed by thread ID.\n * @param {Object<string,number>} params.heights Rendered heights keyed by thread ID.\n * @param {number} params.scrollTop Current scroll offset of the editor content.\n * @return {{ positions: Object<string,number> }} Computed top positions.\n */\nexport function calculateNotePositions( {\n\tthreads,\n\tselectedNoteId,\n\tblockRects,\n\theights,\n\tscrollTop = 0,\n} ) {\n\tconst offsets = {};\n\n\tconst anchorIndex = Math.max(\n\t\t0,\n\t\tthreads.findIndex( ( thread ) => thread.id === selectedNoteId )\n\t);\n\n\tconst anchorThread = threads[ anchorIndex ];\n\n\tif ( ! anchorThread || ! blockRects[ anchorThread.id ] ) {\n\t\treturn { positions: {} };\n\t}\n\n\tconst anchorRect = blockRects[ anchorThread.id ];\n\tconst anchorTop = anchorRect.top || 0;\n\tconst anchorHeight = heights[ anchorThread.id ] || 0;\n\n\toffsets[ anchorThread.id ] = THREAD_ALIGN_OFFSET;\n\n\t// Process threads after the anchor, offsetting overlapping threads downward.\n\tlet prevAdjustedTop = anchorTop + THREAD_ALIGN_OFFSET;\n\tlet prevHeight = anchorHeight;\n\n\tfor ( let i = anchorIndex + 1; i < threads.length; i++ ) {\n\t\tconst thread = threads[ i ];\n\t\tconst threadRect = blockRects[ thread.id ];\n\t\tif ( ! threadRect ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst threadTop = threadRect.top || 0;\n\t\tconst threadHeight = heights[ thread.id ] || 0;\n\n\t\tlet offset = THREAD_ALIGN_OFFSET;\n\n\t\tconst prevBottom = prevAdjustedTop + prevHeight;\n\t\tif ( threadTop < prevBottom + THREAD_GAP ) {\n\t\t\toffset = prevBottom - threadTop + OVERLAP_MARGIN;\n\t\t}\n\n\t\toffsets[ thread.id ] = offset;\n\n\t\tprevAdjustedTop = threadTop + offset;\n\t\tprevHeight = threadHeight;\n\t}\n\n\t// Process threads before the anchor, offsetting overlapping threads upward.\n\tlet belowAdjustedTop = anchorTop + THREAD_ALIGN_OFFSET;\n\n\tfor ( let i = anchorIndex - 1; i >= 0; i-- ) {\n\t\tconst thread = threads[ i ];\n\t\tconst threadRect = blockRects[ thread.id ];\n\t\tif ( ! threadRect ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst threadTop = threadRect.top || 0;\n\t\tconst threadHeight = heights[ thread.id ] || 0;\n\n\t\tlet offset = THREAD_ALIGN_OFFSET;\n\n\t\tconst threadBottom = threadTop + threadHeight;\n\n\t\tif ( threadBottom > belowAdjustedTop ) {\n\t\t\toffset =\n\t\t\t\tbelowAdjustedTop - threadTop - threadHeight - OVERLAP_MARGIN;\n\t\t}\n\n\t\toffsets[ thread.id ] = offset;\n\n\t\tbelowAdjustedTop = threadTop + offset;\n\t}\n\n\t// blockRect.top + scrollTop is the block's absolute y within the editor's\n\t// scroll content; CSS translates each thread by -scrollTop at render time.\n\tconst positions = {};\n\tfor ( const thread of threads ) {\n\t\tconst blockRect = blockRects[ thread.id ];\n\t\tif ( blockRect && offsets[ thread.id ] !== undefined ) {\n\t\t\tpositions[ thread.id ] =\n\t\t\t\tblockRect.top + scrollTop + offsets[ thread.id ];\n\t\t}\n\t}\n\n\treturn { positions };\n}\n\n/**\n * Resolve the DOM element for a note thread once it's mounted,\n * or `null` if not found within 3 seconds.\n *\n * @param {string} noteId Note thread ID.\n * @param {?HTMLElement} container Container to search within.\n * @param {string} additionalSelector Optional descendant selector.\n * @return {Promise<HTMLElement|null>} Resolved element, or `null` on timeout.\n */\nfunction findNoteThread( noteId, container, additionalSelector ) {\n\tif ( ! container ) {\n\t\treturn Promise.resolve( null );\n\t}\n\n\t// A thread without a noteId is a new note thread.\n\tconst threadSelector =\n\t\tnoteId && noteId !== 'new'\n\t\t\t? `[role=treeitem][id=\"note-thread-${ noteId }\"]`\n\t\t\t: '[role=treeitem]:not([id])';\n\tconst selector = additionalSelector\n\t\t? `${ threadSelector } ${ additionalSelector }`\n\t\t: threadSelector;\n\n\treturn new Promise( ( resolve ) => {\n\t\tif ( container.querySelector( selector ) ) {\n\t\t\treturn resolve( container.querySelector( selector ) );\n\t\t}\n\n\t\tlet timer = null;\n\t\t// Wait for the element to be added to the DOM.\n\t\tconst observer = new window.MutationObserver( () => {\n\t\t\tif ( container.querySelector( selector ) ) {\n\t\t\t\tclearTimeout( timer );\n\t\t\t\tobserver.disconnect();\n\t\t\t\tresolve( container.querySelector( selector ) );\n\t\t\t}\n\t\t} );\n\n\t\tobserver.observe( container, { childList: true, subtree: true } );\n\n\t\t// Stop trying after 3 seconds.\n\t\ttimer = setTimeout( () => {\n\t\t\tobserver.disconnect();\n\t\t\tresolve( null );\n\t\t}, 3000 );\n\t} );\n}\n\n/**\n * Focus a note thread (or a descendant) and scroll it into view.\n *\n * @param {string} noteId Note thread ID.\n * @param {?HTMLElement} container Container to search within.\n * @param {string} additionalSelector Optional descendant selector.\n */\nexport function focusNoteThread( noteId, container, additionalSelector ) {\n\treturn findNoteThread( noteId, container, additionalSelector ).then(\n\t\t( element ) => {\n\t\t\tif ( ! element ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telement.focus();\n\t\t\telement.scrollIntoView( { block: 'nearest' } );\n\t\t}\n\t);\n}\n\n/**\n * Scroll a note thread into view without changing focus.\n *\n * @param {string} noteId Note thread ID.\n * @param {?HTMLElement} container Container to search within.\n */\nexport function scrollNoteThreadIntoView( noteId, container ) {\n\treturn findNoteThread( noteId, container ).then( ( element ) => {\n\t\telement?.scrollIntoView( { block: 'nearest' } );\n\t} );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { create, RichTextData } from '@wordpress/rich-text';\n\n/**\n * Sanitizes a note string by trimming leading and trailing whitespace.\n *\n * @param {string} str - The note string to sanitize.\n * @return {string} - The sanitized note string.\n */\nexport function sanitizeNoteContent( str ) {\n\treturn str.trim();\n}\n\nconst THREAD_ALIGN_OFFSET = -16;\nconst THREAD_GAP = 16;\nconst OVERLAP_MARGIN = 20;\n\n/**\n * Avatar border colors chosen to be visually distinct from each other and from\n * the editor's semantic UI colors (Delta E > 10 between all pairs).\n */\nconst AVATAR_BORDER_COLORS = [\n\t'#C36EFF', // Purple\n\t'#D94145', // Red\n\t'#E4780A', // Orange\n\t'#FF35EE', // Magenta\n\t'#879F11', // Olive\n\t'#46A494', // Teal\n\t'#00A2C3', // Cyan\n];\n\n/**\n * Gets the border color for an avatar based on the user ID.\n *\n * Always returns a 6-digit `#RRGGBB` hex string; callers (e.g. the highlight\n * styles) rely on this format to append alpha suffixes.\n *\n * @param {number} userId - The user ID.\n * @return {string} - The border color as a `#RRGGBB` hex string.\n */\nexport function getAvatarBorderColor( userId ) {\n\treturn AVATAR_BORDER_COLORS[ userId % AVATAR_BORDER_COLORS.length ];\n}\n\n/**\n * Generates a note excerpt from text based on word count type and length.\n *\n * @param {string} text - The note text to generate excerpt from.\n * @param {number} excerptLength - The maximum length for the note excerpt.\n * @return {string} - The generated note excerpt.\n */\nexport function getNoteExcerpt( text, excerptLength = 10 ) {\n\tif ( ! text ) {\n\t\treturn '';\n\t}\n\n\t/*\n\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t * Do not translate into your own language.\n\t */\n\tconst wordCountType = _x( 'words', 'Word count type. Do not translate!' );\n\n\tconst rawText = text.trim();\n\tlet trimmedExcerpt = '';\n\n\tif ( wordCountType === 'words' ) {\n\t\ttrimmedExcerpt = rawText.split( ' ', excerptLength ).join( ' ' );\n\t} else if ( wordCountType === 'characters_excluding_spaces' ) {\n\t\t/*\n\t\t * 1. Split the text at the character limit,\n\t\t * then join the substrings back into one string.\n\t\t * 2. Count the number of spaces in the text\n\t\t * by comparing the lengths of the string with and without spaces.\n\t\t * 3. Add the number to the length of the visible excerpt,\n\t\t * so that the spaces are excluded from the word count.\n\t\t */\n\t\tconst textWithSpaces = rawText.split( '', excerptLength ).join( '' );\n\n\t\tconst numberOfSpaces =\n\t\t\ttextWithSpaces.length - textWithSpaces.replaceAll( ' ', '' ).length;\n\n\t\ttrimmedExcerpt = rawText\n\t\t\t.split( '', excerptLength + numberOfSpaces )\n\t\t\t.join( '' );\n\t} else if ( wordCountType === 'characters_including_spaces' ) {\n\t\ttrimmedExcerpt = rawText.split( '', excerptLength ).join( '' );\n\t}\n\n\tconst isTrimmed = trimmedExcerpt !== rawText;\n\treturn isTrimmed ? trimmedExcerpt + '…' : trimmedExcerpt;\n}\n\n/**\n * Normalizes noteId metadata to always return an array of unique numeric ids,\n * preserving insertion order. Handles both scalar (legacy, possibly\n * string-typed) and array (new) values.\n *\n * @param {Object} metadata Block metadata object\n * @return {number[]} Array of note IDs (may be empty)\n */\nexport function getNoteIdsFromMetadata( metadata ) {\n\tconst noteId = metadata?.noteId;\n\tconst raw = Array.isArray( noteId ) ? noteId : [ noteId ];\n\tconst ids = new Set();\n\tfor ( const value of raw ) {\n\t\tconst id = Number( value );\n\t\tif ( Number.isFinite( id ) && id > 0 ) {\n\t\t\tids.add( id );\n\t\t}\n\t}\n\treturn [ ...ids ];\n}\n\n/**\n * Adds a note ID to the metadata.\n * Converts scalar to array if needed, otherwise appends.\n *\n * @param {Object} metadata Existing block metadata\n * @param {number} noteId Note ID to add\n * @return {Object} Updated metadata object\n */\nexport function addNoteIdToMetadata( metadata, noteId ) {\n\tconst ids = new Set( getNoteIdsFromMetadata( metadata ) );\n\tconst id = Number( noteId );\n\tif ( ids.has( id ) ) {\n\t\treturn metadata;\n\t}\n\tids.add( id );\n\treturn { ...metadata, noteId: [ ...ids ] };\n}\n\nconst NOTE_FORMAT_TYPE = 'core/note';\n\n/**\n * Search a rich-text value for a `core/note` marker matching `noteId` and\n * return its character range. Used to derive an inline note's anchor from\n * the in-content marker (resilient to edits) rather than stale offset meta.\n *\n * @param {*} value Block attribute value (RichTextData, string, or other).\n * @param {number|string} noteId Note id to search for.\n * @return {?{start: number, end: number}} Range or null when no marker is found.\n */\nexport function findNoteRange( value, noteId ) {\n\tif ( noteId === undefined || noteId === null ) {\n\t\treturn null;\n\t}\n\tlet html = null;\n\tif ( value instanceof RichTextData ) {\n\t\thtml = value.toHTMLString();\n\t} else if ( typeof value === 'string' ) {\n\t\thtml = value;\n\t}\n\tif ( ! html || html.indexOf( 'wp-note' ) === -1 ) {\n\t\treturn null;\n\t}\n\tconst target = String( noteId );\n\tconst record = create( { html } );\n\tconst formats = record.formats;\n\tlet start = -1;\n\tfor ( let i = 0; i < formats.length; i++ ) {\n\t\tconst stack = formats[ i ];\n\t\tconst hit = stack?.find(\n\t\t\t( f ) =>\n\t\t\t\tf.type === NOTE_FORMAT_TYPE &&\n\t\t\t\tf.attributes &&\n\t\t\t\tf.attributes[ 'data-id' ] === target\n\t\t);\n\t\tif ( hit ) {\n\t\t\tif ( start === -1 ) {\n\t\t\t\tstart = i;\n\t\t\t}\n\t\t} else if ( start !== -1 ) {\n\t\t\treturn { start, end: i };\n\t\t}\n\t}\n\tif ( start !== -1 ) {\n\t\treturn { start, end: formats.length };\n\t}\n\treturn null;\n}\n\n/**\n * Locate a note's in-content `core/note` marker across all of a block's\n * attributes. The marker (carrying `data-id`) is the single source of truth for\n * an inline note's anchor: a note is inline iff a marker with its id exists in\n * the block, and the attribute that holds it is discovered here rather than\n * stored separately. Returns the matching attribute key and the marker range.\n *\n * @param {?Object} attributes Block attributes, or null/undefined when unloaded.\n * @param {number|string} noteId Note id to search for.\n * @return {?{attributeKey: string, start: number, end: number}} Anchor or null when no marker is found.\n */\nexport function findNoteInBlock( attributes, noteId ) {\n\tif ( ! attributes ) {\n\t\treturn null;\n\t}\n\tfor ( const attributeKey of Object.keys( attributes ) ) {\n\t\tconst range = findNoteRange( attributes[ attributeKey ], noteId );\n\t\tif ( range ) {\n\t\t\treturn { attributeKey, start: range.start, end: range.end };\n\t\t}\n\t}\n\treturn null;\n}\n\n// Sentinel that sorts a block-level (whole-block) note before any inline note\n// within the same block. Negative so any real character offset (>= 0) ranks\n// after it. Number.NEGATIVE_INFINITY would work too; -1 is enough and keeps\n// the diff arithmetic in safe integers.\nexport const BLOCK_LEVEL_NOTE_START = -1;\n\n/**\n * Resolve an inline note's character offset in its block so threads can be\n * sorted by reading order. A note is inline iff an in-content `core/note`\n * marker carries its id; block-level notes (no marker) sort first within their\n * block via a sentinel.\n *\n * @param {Object} thread Materialized thread record (with `.id`).\n * @param {?Object} attributes Block attributes for the thread's block.\n * @return {number} Marker start offset, or `BLOCK_LEVEL_NOTE_START` when there is no inline anchor.\n */\nexport function getInlineMarkerStart( thread, attributes ) {\n\tconst found = findNoteInBlock( attributes, thread?.id );\n\treturn found ? found.start : BLOCK_LEVEL_NOTE_START;\n}\n\n/**\n * Apply a `core/note` marker across `[start, end)` without removing notes\n * already present in that range.\n *\n * Rich-text's `applyFormat` strips any existing format of the same type before\n * applying, so two `core/note` markers can't coexist - a note drawn over an\n * existing one would wipe it in the overlap. This keeps every overlapping note\n * and orders the markers outermost-first by span, so a note fully contained in\n * another nests inside it (`<mark><mark>…</mark></mark>`). Crossing (partial)\n * overlaps can't nest in HTML and serialize as split runs, but each note keeps\n * its full range. The returned record is not normalised; callers should\n * round-trip it (e.g. through `RichTextData`) before storing.\n *\n * @param {Object} record A rich-text record (`{ text, formats, … }`).\n * @param {Object} format The `core/note` format to add (`{ type, attributes }`).\n * @param {number} start Range start (inclusive).\n * @param {number} end Range end (exclusive).\n * @return {Object} A new record with the note applied.\n */\nexport function applyNoteFormat( record, format, start, end ) {\n\tconst formats = record.formats.slice();\n\tfor ( let i = start; i < end; i++ ) {\n\t\tconst stack = formats[ i ] ? formats[ i ].slice() : [];\n\t\tstack.push( format );\n\t\tformats[ i ] = stack;\n\t}\n\n\t// Measure each note's full span so containment can order the markers.\n\tconst spans = new Map();\n\tfor ( let i = 0; i < formats.length; i++ ) {\n\t\tconst stack = formats[ i ];\n\t\tif ( ! stack ) {\n\t\t\tcontinue;\n\t\t}\n\t\tfor ( const fmt of stack ) {\n\t\t\tif ( fmt.type !== NOTE_FORMAT_TYPE ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst id = fmt.attributes?.[ 'data-id' ];\n\t\t\tconst span = spans.get( id );\n\t\t\tif ( span ) {\n\t\t\t\tspan.end = i;\n\t\t\t} else {\n\t\t\t\tspans.set( id, { start: i, end: i } );\n\t\t\t}\n\t\t}\n\t}\n\tconst sizeOf = ( id ) => {\n\t\tconst span = spans.get( id );\n\t\treturn span ? span.end - span.start : 0;\n\t};\n\n\t// Order markers outermost-first (widest span) so `toTree` nests them rather\n\t// than splitting an outer note around an inner one. Notes sort ahead of\n\t// other formats so a note wraps the formatted text it spans.\n\tfor ( let i = 0; i < formats.length; i++ ) {\n\t\tconst stack = formats[ i ];\n\t\tif ( ! stack || stack.length < 2 ) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst notes = stack.filter( ( fmt ) => fmt.type === NOTE_FORMAT_TYPE );\n\t\tif ( notes.length === 0 ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( notes.length > 1 ) {\n\t\t\tnotes.sort(\n\t\t\t\t( a, b ) =>\n\t\t\t\t\tsizeOf( b.attributes?.[ 'data-id' ] ) -\n\t\t\t\t\tsizeOf( a.attributes?.[ 'data-id' ] )\n\t\t\t);\n\t\t}\n\t\tconst others = stack.filter( ( fmt ) => fmt.type !== NOTE_FORMAT_TYPE );\n\t\tformats[ i ] = [ ...notes, ...others ];\n\t}\n\n\treturn { ...record, formats };\n}\n\n/**\n * Remove a single note's `core/note` marker from a rich-text value, leaving any\n * other notes nested or overlapping with it intact. Used when a note is deleted\n * or resolved so its highlight does not linger in the content.\n *\n * Rich-text's `removeFormat` strips every `core/note` marker in a range, so it\n * would wipe co-located notes; this filters by `data-id` to drop only the target\n * marker.\n *\n * @param {*} value Block attribute value (RichTextData or other).\n * @param {number|string} noteId Note id whose marker should be removed.\n * @return {?RichTextData} A new value with the marker removed, or null when the\n * attribute isn't rich text or carries no such marker.\n */\nexport function removeNoteFormat( value, noteId ) {\n\tif ( ! ( value instanceof RichTextData ) ) {\n\t\treturn null;\n\t}\n\tconst target = String( noteId );\n\tconst record = create( { html: value.toHTMLString() } );\n\tlet changed = false;\n\tconst formats = record.formats.map( ( stack ) => {\n\t\tif ( ! stack ) {\n\t\t\treturn stack;\n\t\t}\n\t\tconst filtered = stack.filter(\n\t\t\t( format ) =>\n\t\t\t\t! (\n\t\t\t\t\tformat.type === NOTE_FORMAT_TYPE &&\n\t\t\t\t\tformat.attributes?.[ 'data-id' ] === target\n\t\t\t\t)\n\t\t);\n\t\tif ( filtered.length === stack.length ) {\n\t\t\treturn stack;\n\t\t}\n\t\tchanged = true;\n\t\treturn filtered.length ? filtered : undefined;\n\t} );\n\t// Round-trip through HTML so the stored value matches a fresh reload.\n\treturn changed\n\t\t? RichTextData.fromHTMLString(\n\t\t\t\tnew RichTextData( { ...record, formats } ).toHTMLString()\n\t\t )\n\t\t: null;\n}\n\n/**\n * Picks the most relevant thread from a list: first unresolved, else first.\n *\n * @param {Array} threads Ordered list of thread objects.\n * @return {Object|null} Selected thread or null when the list is empty.\n */\nexport function pickPrimaryNote( threads ) {\n\treturn (\n\t\tthreads.find( ( thread ) => thread.status === 'hold' ) ??\n\t\tthreads[ 0 ] ??\n\t\tnull\n\t);\n}\n\n/**\n * Removes a note ID from the metadata.\n *\n * @param {Object} metadata Existing block metadata\n * @param {number} noteId Note ID to remove\n * @return {Object} Updated metadata object\n */\nexport function removeNoteIdFromMetadata( metadata, noteId ) {\n\tconst ids = new Set( getNoteIdsFromMetadata( metadata ) );\n\tids.delete( Number( noteId ) );\n\treturn {\n\t\t...metadata,\n\t\tnoteId: ids.size > 0 ? [ ...ids ] : undefined,\n\t};\n}\n\n/**\n * Calculate final top positions for all floating note threads in the\n * editor's content coordinate space. Adjusts positions to prevent overlapping\n * by pushing threads above the selected one upward and threads below it downward.\n *\n * @param {Object} params\n * @param {Array} params.threads Ordered list of thread objects.\n * @param {string|number|undefined} params.selectedNoteId ID of the currently selected thread.\n * @param {Object<string,DOMRect>} params.blockRects Pre-read bounding rects keyed by thread ID.\n * @param {Object<string,number>} params.heights Rendered heights keyed by thread ID.\n * @param {number} params.scrollTop Current scroll offset of the editor content.\n * @return {{ positions: Object<string,number> }} Computed top positions.\n */\nexport function calculateNotePositions( {\n\tthreads,\n\tselectedNoteId,\n\tblockRects,\n\theights,\n\tscrollTop = 0,\n} ) {\n\tconst offsets = {};\n\n\tconst anchorIndex = Math.max(\n\t\t0,\n\t\tthreads.findIndex( ( thread ) => thread.id === selectedNoteId )\n\t);\n\n\tconst anchorThread = threads[ anchorIndex ];\n\n\tif ( ! anchorThread || ! blockRects[ anchorThread.id ] ) {\n\t\treturn { positions: {} };\n\t}\n\n\tconst anchorRect = blockRects[ anchorThread.id ];\n\tconst anchorTop = anchorRect.top || 0;\n\tconst anchorHeight = heights[ anchorThread.id ] || 0;\n\n\toffsets[ anchorThread.id ] = THREAD_ALIGN_OFFSET;\n\n\t// Process threads after the anchor, offsetting overlapping threads downward.\n\tlet prevAdjustedTop = anchorTop + THREAD_ALIGN_OFFSET;\n\tlet prevHeight = anchorHeight;\n\n\tfor ( let i = anchorIndex + 1; i < threads.length; i++ ) {\n\t\tconst thread = threads[ i ];\n\t\tconst threadRect = blockRects[ thread.id ];\n\t\tif ( ! threadRect ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst threadTop = threadRect.top || 0;\n\t\tconst threadHeight = heights[ thread.id ] || 0;\n\n\t\tlet offset = THREAD_ALIGN_OFFSET;\n\n\t\tconst prevBottom = prevAdjustedTop + prevHeight;\n\t\tif ( threadTop < prevBottom + THREAD_GAP ) {\n\t\t\toffset = prevBottom - threadTop + OVERLAP_MARGIN;\n\t\t}\n\n\t\toffsets[ thread.id ] = offset;\n\n\t\tprevAdjustedTop = threadTop + offset;\n\t\tprevHeight = threadHeight;\n\t}\n\n\t// Process threads before the anchor, offsetting overlapping threads upward.\n\tlet belowAdjustedTop = anchorTop + THREAD_ALIGN_OFFSET;\n\n\tfor ( let i = anchorIndex - 1; i >= 0; i-- ) {\n\t\tconst thread = threads[ i ];\n\t\tconst threadRect = blockRects[ thread.id ];\n\t\tif ( ! threadRect ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst threadTop = threadRect.top || 0;\n\t\tconst threadHeight = heights[ thread.id ] || 0;\n\n\t\tlet offset = THREAD_ALIGN_OFFSET;\n\n\t\tconst threadBottom = threadTop + threadHeight;\n\n\t\tif ( threadBottom > belowAdjustedTop ) {\n\t\t\toffset =\n\t\t\t\tbelowAdjustedTop - threadTop - threadHeight - OVERLAP_MARGIN;\n\t\t}\n\n\t\toffsets[ thread.id ] = offset;\n\n\t\tbelowAdjustedTop = threadTop + offset;\n\t}\n\n\t// blockRect.top + scrollTop is the block's absolute y within the editor's\n\t// scroll content; CSS translates each thread by -scrollTop at render time.\n\tconst positions = {};\n\tfor ( const thread of threads ) {\n\t\tconst blockRect = blockRects[ thread.id ];\n\t\tif ( blockRect && offsets[ thread.id ] !== undefined ) {\n\t\t\tpositions[ thread.id ] =\n\t\t\t\tblockRect.top + scrollTop + offsets[ thread.id ];\n\t\t}\n\t}\n\n\treturn { positions };\n}\n\n/**\n * Resolve the DOM element for a note thread once it's mounted,\n * or `null` if not found within 3 seconds.\n *\n * @param {string} noteId Note thread ID.\n * @param {?HTMLElement} container Container to search within.\n * @param {string} additionalSelector Optional descendant selector.\n * @return {Promise<HTMLElement|null>} Resolved element, or `null` on timeout.\n */\nfunction findNoteThread( noteId, container, additionalSelector ) {\n\tif ( ! container ) {\n\t\treturn Promise.resolve( null );\n\t}\n\n\t// A thread without a noteId is a new note thread.\n\tconst threadSelector =\n\t\tnoteId && noteId !== 'new'\n\t\t\t? `[role=treeitem][id=\"note-thread-${ noteId }\"]`\n\t\t\t: '[role=treeitem]:not([id])';\n\tconst selector = additionalSelector\n\t\t? `${ threadSelector } ${ additionalSelector }`\n\t\t: threadSelector;\n\n\treturn new Promise( ( resolve ) => {\n\t\tif ( container.querySelector( selector ) ) {\n\t\t\treturn resolve( container.querySelector( selector ) );\n\t\t}\n\n\t\tlet timer = null;\n\t\t// Wait for the element to be added to the DOM.\n\t\tconst observer = new window.MutationObserver( () => {\n\t\t\tif ( container.querySelector( selector ) ) {\n\t\t\t\tclearTimeout( timer );\n\t\t\t\tobserver.disconnect();\n\t\t\t\tresolve( container.querySelector( selector ) );\n\t\t\t}\n\t\t} );\n\n\t\tobserver.observe( container, { childList: true, subtree: true } );\n\n\t\t// Stop trying after 3 seconds.\n\t\ttimer = setTimeout( () => {\n\t\t\tobserver.disconnect();\n\t\t\tresolve( null );\n\t\t}, 3000 );\n\t} );\n}\n\n/**\n * Focus a note thread (or a descendant) and scroll it into view.\n *\n * @param {string} noteId Note thread ID.\n * @param {?HTMLElement} container Container to search within.\n * @param {string} additionalSelector Optional descendant selector.\n */\nexport function focusNoteThread( noteId, container, additionalSelector ) {\n\treturn findNoteThread( noteId, container, additionalSelector ).then(\n\t\t( element ) => {\n\t\t\tif ( ! element ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telement.focus();\n\t\t\telement.scrollIntoView( { block: 'nearest' } );\n\t\t}\n\t);\n}\n\n/**\n * Scroll a note thread into view without changing focus.\n *\n * @param {string} noteId Note thread ID.\n * @param {?HTMLElement} container Container to search within.\n */\nexport function scrollNoteThreadIntoView( noteId, container ) {\n\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mCAAoC,MAAO,OAC3C;AACJ,QAAM,WAAW,qBACd,GAAI,cAAe,IAAK,kBAAmB,KAC3C;AAEH,SAAO,IAAI,QAAS,CAAE,YAAa;AAClC,QAAK,UAAU,cAAe,QAAS,GAAI;AAC1C,aAAO,QAAS,UAAU,cAAe,QAAS,CAAE;AAAA,IACrD;AAEA,QAAI,QAAQ;AAEZ,UAAM,WAAW,IAAI,OAAO,iBAAkB,MAAM;AACnD,UAAK,UAAU,cAAe,QAAS,GAAI;AAC1C,qBAAc,KAAM;AACpB,iBAAS,WAAW;AACpB,gBAAS,UAAU,cAAe,QAAS,CAAE;AAAA,MAC9C;AAAA,IACD,CAAE;AAEF,aAAS,QAAS,WAAW,EAAE,WAAW,MAAM,SAAS,KAAK,CAAE;AAGhE,YAAQ,WAAY,MAAM;AACzB,eAAS,WAAW;AACpB,cAAS,IAAK;AAAA,IACf,GAAG,GAAK;AAAA,EACT,CAAE;AACH;AASO,SAAS,gBAAiB,QAAQ,WAAW,oBAAqB;AACxE,SAAO,eAAgB,QAAQ,WAAW,kBAAmB,EAAE;AAAA,IAC9D,CAAE,YAAa;AACd,UAAK,CAAE,SAAU;AAChB;AAAA,MACD;AACA,cAAQ,MAAM;AACd,cAAQ,eAAgB,EAAE,OAAO,UAAU,CAAE;AAAA,IAC9C;AAAA,EACD;AACD;AAQO,SAAS,yBAA0B,QAAQ,WAAY;AAC7D,SAAO,eAAgB,QAAQ,SAAU,EAAE,KAAM,CAAE,YAAa;AAC/D,aAAS,eAAgB,EAAE,OAAO,UAAU,CAAE;AAAA,EAC/C,CAAE;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -48,32 +48,54 @@ function getPostUpdatedMessage(name, status, isFirstPublish) {
|
|
|
48
48
|
return (0, import_i18n.sprintf)((0, import_i18n.__)("Draft saved by %s."), name);
|
|
49
49
|
}
|
|
50
50
|
function useCollaboratorNotifications(postId, postType) {
|
|
51
|
-
const {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
51
|
+
const {
|
|
52
|
+
postStatus,
|
|
53
|
+
isCollaborationEnabled,
|
|
54
|
+
showJoinNotifications,
|
|
55
|
+
showLeaveNotifications,
|
|
56
|
+
showPostSaveNotifications
|
|
57
|
+
} = (0, import_data.useSelect)((select) => {
|
|
58
|
+
const {
|
|
59
|
+
getCurrentPostAttribute,
|
|
60
|
+
isCollaborationEnabledForCurrentPost
|
|
61
|
+
} = (0, import_lock_unlock.unlock)(select(import_store.store));
|
|
62
|
+
const getNotificationPreference = (name) => select(import_preferences.store).get("core", name) ?? true;
|
|
63
|
+
return {
|
|
64
|
+
postStatus: getCurrentPostAttribute("status"),
|
|
65
|
+
isCollaborationEnabled: isCollaborationEnabledForCurrentPost(),
|
|
66
|
+
showJoinNotifications: getNotificationPreference(
|
|
67
|
+
"showCollaborationJoinNotifications"
|
|
68
|
+
),
|
|
69
|
+
showLeaveNotifications: getNotificationPreference(
|
|
70
|
+
"showCollaborationLeaveNotifications"
|
|
71
|
+
),
|
|
72
|
+
showPostSaveNotifications: getNotificationPreference(
|
|
73
|
+
"showCollaborationPostSaveNotifications"
|
|
74
|
+
)
|
|
75
|
+
};
|
|
76
|
+
}, []);
|
|
68
77
|
const { createNotice } = (0, import_data.useDispatch)(import_notices.store);
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
78
|
+
const shouldShowJoinNotifications = isCollaborationEnabled && showJoinNotifications;
|
|
79
|
+
const shouldShowLeaveNotifications = isCollaborationEnabled && showLeaveNotifications;
|
|
80
|
+
const shouldShowPostSaveNotifications = isCollaborationEnabled && showPostSaveNotifications;
|
|
81
|
+
const effectiveTarget = (shouldShow) => shouldShow ? [postId, postType] : [null, null];
|
|
82
|
+
const [joinPostId, joinPostType] = effectiveTarget(
|
|
83
|
+
shouldShowJoinNotifications
|
|
84
|
+
);
|
|
85
|
+
const [leavePostId, leavePostType] = effectiveTarget(
|
|
86
|
+
shouldShowLeaveNotifications
|
|
87
|
+
);
|
|
88
|
+
const [postSavePostId, postSavePostType] = effectiveTarget(
|
|
89
|
+
shouldShowPostSaveNotifications
|
|
90
|
+
);
|
|
72
91
|
useOnCollaboratorJoin(
|
|
73
|
-
|
|
74
|
-
|
|
92
|
+
joinPostId,
|
|
93
|
+
joinPostType,
|
|
75
94
|
(0, import_element.useCallback)(
|
|
76
95
|
(collaborator, me) => {
|
|
96
|
+
if (!shouldShowJoinNotifications) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
77
99
|
if (me && collaborator.collaboratorInfo.enteredAt < me.collaboratorInfo.enteredAt) {
|
|
78
100
|
return;
|
|
79
101
|
}
|
|
@@ -91,14 +113,17 @@ function useCollaboratorNotifications(postId, postType) {
|
|
|
91
113
|
}
|
|
92
114
|
);
|
|
93
115
|
},
|
|
94
|
-
[createNotice]
|
|
116
|
+
[createNotice, shouldShowJoinNotifications]
|
|
95
117
|
)
|
|
96
118
|
);
|
|
97
119
|
useOnCollaboratorLeave(
|
|
98
|
-
|
|
99
|
-
|
|
120
|
+
leavePostId,
|
|
121
|
+
leavePostType,
|
|
100
122
|
(0, import_element.useCallback)(
|
|
101
123
|
(collaborator) => {
|
|
124
|
+
if (!shouldShowLeaveNotifications) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
102
127
|
void createNotice(
|
|
103
128
|
"info",
|
|
104
129
|
(0, import_i18n.sprintf)(
|
|
@@ -113,15 +138,15 @@ function useCollaboratorNotifications(postId, postType) {
|
|
|
113
138
|
}
|
|
114
139
|
);
|
|
115
140
|
},
|
|
116
|
-
[createNotice]
|
|
141
|
+
[createNotice, shouldShowLeaveNotifications]
|
|
117
142
|
)
|
|
118
143
|
);
|
|
119
144
|
useOnPostSave(
|
|
120
|
-
|
|
121
|
-
|
|
145
|
+
postSavePostId,
|
|
146
|
+
postSavePostType,
|
|
122
147
|
(0, import_element.useCallback)(
|
|
123
148
|
(saveEvent, saver, prevEvent) => {
|
|
124
|
-
if (!postStatus) {
|
|
149
|
+
if (!shouldShowPostSaveNotifications || !postStatus) {
|
|
125
150
|
return;
|
|
126
151
|
}
|
|
127
152
|
const effectiveStatus = saveEvent.postStatus ?? postStatus ?? "draft";
|
|
@@ -138,7 +163,7 @@ function useCollaboratorNotifications(postId, postType) {
|
|
|
138
163
|
isDismissible: false
|
|
139
164
|
});
|
|
140
165
|
},
|
|
141
|
-
[createNotice, postStatus]
|
|
166
|
+
[createNotice, postStatus, shouldShowPostSaveNotifications]
|
|
142
167
|
)
|
|
143
168
|
);
|
|
144
169
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/collaborators-presence/use-collaborator-notifications.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport {\n\tprivateApis,\n\ttype PostEditorAwarenessState,\n\ttype PostSaveEvent,\n} from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst { useOnCollaboratorJoin, useOnCollaboratorLeave, useOnPostSave } =\n\tunlock( privateApis );\n\n/**\n * Notice IDs for each notification type. Using stable IDs prevents duplicate\n * notices if the same event is processed more than once.\n */\nconst NOTIFICATION_TYPE = {\n\tCOLLAB_POST_UPDATED: 'collab-post-updated',\n\tCOLLAB_USER_ENTERED: 'collab-user-entered',\n\tCOLLAB_USER_EXITED: 'collab-user-exited',\n} as const;\n\nconst PUBLISHED_STATUSES = [ 'publish', 'private', 'future' ];\n\n/**\n * Returns the snackbar message for a post updated notification.\n *\n * @param name Display name of the collaborator who saved.\n * @param status WordPress post status at the time of save.\n * @param isFirstPublish Whether this save transitioned the post to published.\n */\nfunction getPostUpdatedMessage(\n\tname: string,\n\tstatus: string,\n\tisFirstPublish: boolean\n): string {\n\tif ( isFirstPublish ) {\n\t\t/* translators: %s: collaborator display name */\n\t\treturn sprintf( __( 'Post published by %s.' ), name );\n\t}\n\tif ( PUBLISHED_STATUSES.includes( status ) ) {\n\t\t/* translators: %s: collaborator display name */\n\t\treturn sprintf( __( 'Post updated by %s.' ), name );\n\t}\n\t/* translators: %s: collaborator display name */\n\treturn sprintf( __( 'Draft saved by %s.' ), name );\n}\n\n/**\n * Hook that watches for collaborator join/leave events and remote save events,\n * dispatching snackbar notices accordingly.\n *\n * @param postId The ID of the post being edited.\n * @param postType The post type of the post being edited.\n */\nexport function useCollaboratorNotifications(\n\tpostId: number | null,\n\tpostType: string | null\n): void {\n\tconst {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,qBAA4B;AAC5B,kBAA4B;AAC5B,qBAAsC;AACtC,uBAIO;AACP,yBAA0C;AAK1C,yBAAuB;AACvB,mBAAqC;AAErC,IAAM,EAAE,uBAAuB,wBAAwB,cAAc,QACpE,2BAAQ,4BAAY;AAMrB,IAAM,oBAAoB;AAAA,EACzB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,oBAAoB;AACrB;AAEA,IAAM,qBAAqB,CAAE,WAAW,WAAW,QAAS;AAS5D,SAAS,sBACR,MACA,QACA,gBACS;AACT,MAAK,gBAAiB;AAErB,eAAO,yBAAS,gBAAI,uBAAwB,GAAG,IAAK;AAAA,EACrD;AACA,MAAK,mBAAmB,SAAU,MAAO,GAAI;AAE5C,eAAO,yBAAS,gBAAI,qBAAsB,GAAG,IAAK;AAAA,EACnD;AAEA,aAAO,yBAAS,gBAAI,oBAAqB,GAAG,IAAK;AAClD;AASO,SAAS,6BACf,QACA,UACO;AACP,QAAM,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport {\n\tprivateApis,\n\ttype PostEditorAwarenessState,\n\ttype PostSaveEvent,\n} from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst { useOnCollaboratorJoin, useOnCollaboratorLeave, useOnPostSave } =\n\tunlock( privateApis );\n\n/**\n * Notice IDs for each notification type. Using stable IDs prevents duplicate\n * notices if the same event is processed more than once.\n */\nconst NOTIFICATION_TYPE = {\n\tCOLLAB_POST_UPDATED: 'collab-post-updated',\n\tCOLLAB_USER_ENTERED: 'collab-user-entered',\n\tCOLLAB_USER_EXITED: 'collab-user-exited',\n} as const;\n\nconst PUBLISHED_STATUSES = [ 'publish', 'private', 'future' ];\n\n/**\n * Returns the snackbar message for a post updated notification.\n *\n * @param name Display name of the collaborator who saved.\n * @param status WordPress post status at the time of save.\n * @param isFirstPublish Whether this save transitioned the post to published.\n */\nfunction getPostUpdatedMessage(\n\tname: string,\n\tstatus: string,\n\tisFirstPublish: boolean\n): string {\n\tif ( isFirstPublish ) {\n\t\t/* translators: %s: collaborator display name */\n\t\treturn sprintf( __( 'Post published by %s.' ), name );\n\t}\n\tif ( PUBLISHED_STATUSES.includes( status ) ) {\n\t\t/* translators: %s: collaborator display name */\n\t\treturn sprintf( __( 'Post updated by %s.' ), name );\n\t}\n\t/* translators: %s: collaborator display name */\n\treturn sprintf( __( 'Draft saved by %s.' ), name );\n}\n\n/**\n * Hook that watches for collaborator join/leave events and remote save events,\n * dispatching snackbar notices accordingly.\n *\n * @param postId The ID of the post being edited.\n * @param postType The post type of the post being edited.\n */\nexport function useCollaboratorNotifications(\n\tpostId: number | null,\n\tpostType: string | null\n): void {\n\tconst {\n\t\tpostStatus,\n\t\tisCollaborationEnabled,\n\t\tshowJoinNotifications,\n\t\tshowLeaveNotifications,\n\t\tshowPostSaveNotifications,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetCurrentPostAttribute,\n\t\t\tisCollaborationEnabledForCurrentPost,\n\t\t} = unlock( select( editorStore ) );\n\t\t// Notification preferences default to enabled when unset.\n\t\tconst getNotificationPreference = ( name: string ) =>\n\t\t\tselect( preferencesStore ).get( 'core', name ) ?? true;\n\t\treturn {\n\t\t\tpostStatus: getCurrentPostAttribute( 'status' ) as\n\t\t\t\t| string\n\t\t\t\t| undefined,\n\t\t\tisCollaborationEnabled: isCollaborationEnabledForCurrentPost(),\n\t\t\tshowJoinNotifications: getNotificationPreference(\n\t\t\t\t'showCollaborationJoinNotifications'\n\t\t\t),\n\t\t\tshowLeaveNotifications: getNotificationPreference(\n\t\t\t\t'showCollaborationLeaveNotifications'\n\t\t\t),\n\t\t\tshowPostSaveNotifications: getNotificationPreference(\n\t\t\t\t'showCollaborationPostSaveNotifications'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst { createNotice } = useDispatch( noticesStore );\n\n\t// Pass null when collaboration is disabled or a notification type is\n\t// turned off to prevent the hooks from subscribing to awareness state.\n\tconst shouldShowJoinNotifications =\n\t\tisCollaborationEnabled && showJoinNotifications;\n\tconst shouldShowLeaveNotifications =\n\t\tisCollaborationEnabled && showLeaveNotifications;\n\tconst shouldShowPostSaveNotifications =\n\t\tisCollaborationEnabled && showPostSaveNotifications;\n\t// A disabled notification type passes null, which unsubscribes its hook;\n\t// callback guards handle any events already queued before then.\n\tconst effectiveTarget = (\n\t\tshouldShow: boolean\n\t): [ number | null, string | null ] =>\n\t\tshouldShow ? [ postId, postType ] : [ null, null ];\n\tconst [ joinPostId, joinPostType ] = effectiveTarget(\n\t\tshouldShowJoinNotifications\n\t);\n\tconst [ leavePostId, leavePostType ] = effectiveTarget(\n\t\tshouldShowLeaveNotifications\n\t);\n\tconst [ postSavePostId, postSavePostType ] = effectiveTarget(\n\t\tshouldShowPostSaveNotifications\n\t);\n\n\tuseOnCollaboratorJoin(\n\t\tjoinPostId,\n\t\tjoinPostType,\n\t\tuseCallback(\n\t\t\t(\n\t\t\t\tcollaborator: PostEditorAwarenessState,\n\t\t\t\tme?: PostEditorAwarenessState\n\t\t\t) => {\n\t\t\t\tif ( ! shouldShowJoinNotifications ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t/*\n\t\t\t\t * Skip collaborators who were present before the current user\n\t\t\t\t * joined. Their enteredAt is earlier than ours, meaning we're\n\t\t\t\t * the newcomer.\n\t\t\t\t */\n\t\t\t\tif (\n\t\t\t\t\tme &&\n\t\t\t\t\tcollaborator.collaboratorInfo.enteredAt <\n\t\t\t\t\t\tme.collaboratorInfo.enteredAt\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvoid createNotice(\n\t\t\t\t\t'info',\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s: collaborator display name */\n\t\t\t\t\t\t__( '%s has joined the post.' ),\n\t\t\t\t\t\tcollaborator.collaboratorInfo.name\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${ NOTIFICATION_TYPE.COLLAB_USER_ENTERED }-${ collaborator.collaboratorInfo.id }`,\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tisDismissible: false,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ createNotice, shouldShowJoinNotifications ]\n\t\t)\n\t);\n\n\tuseOnCollaboratorLeave(\n\t\tleavePostId,\n\t\tleavePostType,\n\t\tuseCallback(\n\t\t\t( collaborator: PostEditorAwarenessState ) => {\n\t\t\t\tif ( ! shouldShowLeaveNotifications ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvoid createNotice(\n\t\t\t\t\t'info',\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s: collaborator display name */\n\t\t\t\t\t\t__( '%s has left the post.' ),\n\t\t\t\t\t\tcollaborator.collaboratorInfo.name\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${ NOTIFICATION_TYPE.COLLAB_USER_EXITED }-${ collaborator.collaboratorInfo.id }`,\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tisDismissible: false,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ createNotice, shouldShowLeaveNotifications ]\n\t\t)\n\t);\n\n\tuseOnPostSave(\n\t\tpostSavePostId,\n\t\tpostSavePostType,\n\t\tuseCallback(\n\t\t\t(\n\t\t\t\tsaveEvent: PostSaveEvent,\n\t\t\t\tsaver: PostEditorAwarenessState,\n\t\t\t\tprevEvent: PostSaveEvent | null\n\t\t\t) => {\n\t\t\t\tif ( ! shouldShowPostSaveNotifications || ! postStatus ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Prefer the remote status from Y.Doc (accurate at save time)\n\t\t\t\t// over the local Redux value, which may not have synced yet.\n\t\t\t\tconst effectiveStatus =\n\t\t\t\t\tsaveEvent.postStatus ?? postStatus ?? 'draft';\n\n\t\t\t\t// Use the previous save event's status when available for\n\t\t\t\t// accurate first-publish detection across rapid saves.\n\t\t\t\tconst prevStatus = prevEvent?.postStatus ?? postStatus;\n\t\t\t\tconst isFirstPublish =\n\t\t\t\t\t! (\n\t\t\t\t\t\tprevStatus && PUBLISHED_STATUSES.includes( prevStatus )\n\t\t\t\t\t) && PUBLISHED_STATUSES.includes( effectiveStatus );\n\n\t\t\t\tconst message = getPostUpdatedMessage(\n\t\t\t\t\tsaver.collaboratorInfo.name,\n\t\t\t\t\teffectiveStatus,\n\t\t\t\t\tisFirstPublish\n\t\t\t\t);\n\n\t\t\t\tvoid createNotice( 'info', message, {\n\t\t\t\t\tid: `${ NOTIFICATION_TYPE.COLLAB_POST_UPDATED }-${ saver.collaboratorInfo.id }`,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: false,\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[ createNotice, postStatus, shouldShowPostSaveNotifications ]\n\t\t)\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,qBAA4B;AAC5B,kBAA4B;AAC5B,qBAAsC;AACtC,uBAIO;AACP,yBAA0C;AAK1C,yBAAuB;AACvB,mBAAqC;AAErC,IAAM,EAAE,uBAAuB,wBAAwB,cAAc,QACpE,2BAAQ,4BAAY;AAMrB,IAAM,oBAAoB;AAAA,EACzB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,oBAAoB;AACrB;AAEA,IAAM,qBAAqB,CAAE,WAAW,WAAW,QAAS;AAS5D,SAAS,sBACR,MACA,QACA,gBACS;AACT,MAAK,gBAAiB;AAErB,eAAO,yBAAS,gBAAI,uBAAwB,GAAG,IAAK;AAAA,EACrD;AACA,MAAK,mBAAmB,SAAU,MAAO,GAAI;AAE5C,eAAO,yBAAS,gBAAI,qBAAsB,GAAG,IAAK;AAAA,EACnD;AAEA,aAAO,yBAAS,gBAAI,oBAAqB,GAAG,IAAK;AAClD;AASO,SAAS,6BACf,QACA,UACO;AACP,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,uBAAW,CAAE,WAAY;AAC5B,UAAM;AAAA,MACL;AAAA,MACA;AAAA,IACD,QAAI,2BAAQ,OAAQ,aAAAA,KAAY,CAAE;AAElC,UAAM,4BAA4B,CAAE,SACnC,OAAQ,mBAAAC,KAAiB,EAAE,IAAK,QAAQ,IAAK,KAAK;AACnD,WAAO;AAAA,MACN,YAAY,wBAAyB,QAAS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AAAA;AAAA,gBAEC,gBAAI,uBAAwB;AAAA,YAC5B,aAAa,iBAAiB;AAAA,UAC/B;AAAA,UACA;AAAA,YACC,IAAI,GAAI,kBAAkB,kBAAmB,IAAK,aAAa,iBAAiB,EAAG;AAAA,YACnF,MAAM;AAAA,YACN,eAAe;AAAA,UAChB;AAAA,QACD;AAAA,MACD;AAAA,MACA,CAAE,cAAc,4BAA6B;AAAA,IAC9C;AAAA,EACD;AAEA;AAAA,IACC;AAAA,IACA;AAAA,QACA;AAAA,MACC,CACC,WACA,OACA,cACI;AACJ,YAAK,CAAE,mCAAmC,CAAE,YAAa;AACxD;AAAA,QACD;AAIA,cAAM,kBACL,UAAU,cAAc,cAAc;AAIvC,cAAM,aAAa,WAAW,cAAc;AAC5C,cAAM,iBACL,EACC,cAAc,mBAAmB,SAAU,UAAW,MAClD,mBAAmB,SAAU,eAAgB;AAEnD,cAAM,UAAU;AAAA,UACf,MAAM,iBAAiB;AAAA,UACvB;AAAA,UACA;AAAA,QACD;AAEA,aAAK,aAAc,QAAQ,SAAS;AAAA,UACnC,IAAI,GAAI,kBAAkB,mBAAoB,IAAK,MAAM,iBAAiB,EAAG;AAAA,UAC7E,MAAM;AAAA,UACN,eAAe;AAAA,QAChB,CAAE;AAAA,MACH;AAAA,MACA,CAAE,cAAc,YAAY,+BAAgC;AAAA,IAC7D;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["editorStore", "preferencesStore", "noticesStore"]
|
|
7
7
|
}
|
|
@@ -49,6 +49,30 @@ var import_constants = require("../../store/constants.cjs");
|
|
|
49
49
|
var import_pattern_rename_modal = require("../pattern-rename-modal/index.cjs");
|
|
50
50
|
var import_pattern_duplicate_modal = require("../pattern-duplicate-modal/index.cjs");
|
|
51
51
|
var import_is_template_revertable = __toESM(require("../../store/utils/is-template-revertable.cjs"));
|
|
52
|
+
function getTogglePatternEditingCommand({
|
|
53
|
+
disableContentOnlyForPatternsAndTemplateParts,
|
|
54
|
+
stopEditingContentOnlySection,
|
|
55
|
+
updateEditorSettings
|
|
56
|
+
}) {
|
|
57
|
+
return {
|
|
58
|
+
name: "core/toggle-pattern-editing",
|
|
59
|
+
label: disableContentOnlyForPatternsAndTemplateParts ? (0, import_i18n.__)("Disable editing all patterns") : (0, import_i18n.__)("Enable editing all patterns"),
|
|
60
|
+
icon: import_icons.symbol,
|
|
61
|
+
category: "command",
|
|
62
|
+
callback: ({ close }) => {
|
|
63
|
+
const disableContentOnly = !disableContentOnlyForPatternsAndTemplateParts;
|
|
64
|
+
stopEditingContentOnlySection();
|
|
65
|
+
updateEditorSettings({
|
|
66
|
+
disableContentOnlyForUnsyncedPatterns: disableContentOnly,
|
|
67
|
+
disableContentOnlyForTemplateParts: disableContentOnly
|
|
68
|
+
});
|
|
69
|
+
close();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function isPatternOrTemplatePartBlock(blockName, attributes) {
|
|
74
|
+
return !!attributes?.metadata?.patternName || blockName === "core/template-part";
|
|
75
|
+
}
|
|
52
76
|
var getEditorCommandLoader = () => function useEditorCommandLoader() {
|
|
53
77
|
const {
|
|
54
78
|
editorMode,
|
|
@@ -60,7 +84,9 @@ var getEditorCommandLoader = () => function useEditorCommandLoader() {
|
|
|
60
84
|
isViewable,
|
|
61
85
|
isCodeEditingEnabled,
|
|
62
86
|
isRichEditingEnabled,
|
|
63
|
-
isPublishSidebarEnabled
|
|
87
|
+
isPublishSidebarEnabled,
|
|
88
|
+
disableContentOnlyForUnsyncedPatterns,
|
|
89
|
+
disableContentOnlyForTemplateParts
|
|
64
90
|
} = (0, import_data.useSelect)((select) => {
|
|
65
91
|
const { get } = select(import_preferences.store);
|
|
66
92
|
const { isListViewOpened, getCurrentPostType, getEditorSettings } = select(import_store.store);
|
|
@@ -76,7 +102,9 @@ var getEditorCommandLoader = () => function useEditorCommandLoader() {
|
|
|
76
102
|
isViewable: getPostType(getCurrentPostType())?.viewable ?? false,
|
|
77
103
|
isCodeEditingEnabled: getEditorSettings().codeEditingEnabled,
|
|
78
104
|
isRichEditingEnabled: getEditorSettings().richEditingEnabled,
|
|
79
|
-
isPublishSidebarEnabled: select(import_store.store).isPublishSidebarEnabled()
|
|
105
|
+
isPublishSidebarEnabled: select(import_store.store).isPublishSidebarEnabled(),
|
|
106
|
+
disableContentOnlyForUnsyncedPatterns: !!getEditorSettings().disableContentOnlyForUnsyncedPatterns,
|
|
107
|
+
disableContentOnlyForTemplateParts: !!getEditorSettings().disableContentOnlyForTemplateParts
|
|
80
108
|
};
|
|
81
109
|
}, []);
|
|
82
110
|
const { getActiveComplementaryArea } = (0, import_data.useSelect)(import_interface.store);
|
|
@@ -88,8 +116,12 @@ var getEditorCommandLoader = () => function useEditorCommandLoader() {
|
|
|
88
116
|
switchEditorMode,
|
|
89
117
|
toggleDistractionFree,
|
|
90
118
|
toggleSpotlightMode,
|
|
91
|
-
toggleTopToolbar
|
|
119
|
+
toggleTopToolbar,
|
|
120
|
+
updateEditorSettings
|
|
92
121
|
} = (0, import_data.useDispatch)(import_store.store);
|
|
122
|
+
const { stopEditingContentOnlySection } = (0, import_lock_unlock.unlock)(
|
|
123
|
+
(0, import_data.useDispatch)(import_block_editor.store)
|
|
124
|
+
);
|
|
93
125
|
const { openModal, enableComplementaryArea, disableComplementaryArea } = (0, import_data.useDispatch)(import_interface.store);
|
|
94
126
|
const { getCurrentPostId } = (0, import_data.useSelect)(import_store.store);
|
|
95
127
|
const allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;
|
|
@@ -97,6 +129,7 @@ var getEditorCommandLoader = () => function useEditorCommandLoader() {
|
|
|
97
129
|
return { commands: [], isLoading: false };
|
|
98
130
|
}
|
|
99
131
|
const commands = [];
|
|
132
|
+
const disableContentOnlyForPatternsAndTemplateParts = disableContentOnlyForUnsyncedPatterns && disableContentOnlyForTemplateParts;
|
|
100
133
|
commands.push({
|
|
101
134
|
name: "core/open-shortcut-help",
|
|
102
135
|
label: (0, import_i18n.__)("Keyboard shortcuts"),
|
|
@@ -160,6 +193,13 @@ var getEditorCommandLoader = () => function useEditorCommandLoader() {
|
|
|
160
193
|
close();
|
|
161
194
|
}
|
|
162
195
|
});
|
|
196
|
+
commands.push(
|
|
197
|
+
getTogglePatternEditingCommand({
|
|
198
|
+
disableContentOnlyForPatternsAndTemplateParts,
|
|
199
|
+
stopEditingContentOnlySection,
|
|
200
|
+
updateEditorSettings
|
|
201
|
+
})
|
|
202
|
+
);
|
|
163
203
|
if (allowSwitchEditorMode) {
|
|
164
204
|
commands.push({
|
|
165
205
|
name: "core/toggle-code-editor",
|
|
@@ -256,6 +296,57 @@ var getEditorCommandLoader = () => function useEditorCommandLoader() {
|
|
|
256
296
|
isLoading: false
|
|
257
297
|
};
|
|
258
298
|
};
|
|
299
|
+
var getPatternEditingContextualCommands = () => function usePatternEditingContextualCommands({ search }) {
|
|
300
|
+
const {
|
|
301
|
+
disableContentOnlyForPatternsAndTemplateParts,
|
|
302
|
+
hasPatternOrTemplatePartSelection,
|
|
303
|
+
isPreviewMode
|
|
304
|
+
} = (0, import_data.useSelect)((select) => {
|
|
305
|
+
const {
|
|
306
|
+
getBlockAttributes,
|
|
307
|
+
getBlockName,
|
|
308
|
+
getBlockParents,
|
|
309
|
+
getSelectedBlockClientId,
|
|
310
|
+
getSelectedBlockClientIds,
|
|
311
|
+
getSettings
|
|
312
|
+
} = select(import_block_editor.store);
|
|
313
|
+
const { getEditorSettings } = select(import_store.store);
|
|
314
|
+
const editorSettings = getEditorSettings();
|
|
315
|
+
const selectedBlockClientId = getSelectedBlockClientId();
|
|
316
|
+
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
317
|
+
const clientIdsToCheck = selectedBlockClientId && selectedBlockClientIds.length === 1 ? [
|
|
318
|
+
selectedBlockClientId,
|
|
319
|
+
...getBlockParents(selectedBlockClientId, true)
|
|
320
|
+
] : [];
|
|
321
|
+
return {
|
|
322
|
+
disableContentOnlyForPatternsAndTemplateParts: !!editorSettings.disableContentOnlyForUnsyncedPatterns && !!editorSettings.disableContentOnlyForTemplateParts,
|
|
323
|
+
hasPatternOrTemplatePartSelection: clientIdsToCheck.some(
|
|
324
|
+
(clientId) => isPatternOrTemplatePartBlock(
|
|
325
|
+
getBlockName(clientId),
|
|
326
|
+
getBlockAttributes(clientId)
|
|
327
|
+
)
|
|
328
|
+
),
|
|
329
|
+
isPreviewMode: getSettings().isPreviewMode
|
|
330
|
+
};
|
|
331
|
+
}, []);
|
|
332
|
+
const { updateEditorSettings } = (0, import_data.useDispatch)(import_store.store);
|
|
333
|
+
const { stopEditingContentOnlySection } = (0, import_lock_unlock.unlock)(
|
|
334
|
+
(0, import_data.useDispatch)(import_block_editor.store)
|
|
335
|
+
);
|
|
336
|
+
if (search || !hasPatternOrTemplatePartSelection && !disableContentOnlyForPatternsAndTemplateParts || isPreviewMode) {
|
|
337
|
+
return { isLoading: false, commands: [] };
|
|
338
|
+
}
|
|
339
|
+
return {
|
|
340
|
+
isLoading: false,
|
|
341
|
+
commands: [
|
|
342
|
+
getTogglePatternEditingCommand({
|
|
343
|
+
disableContentOnlyForPatternsAndTemplateParts,
|
|
344
|
+
stopEditingContentOnlySection,
|
|
345
|
+
updateEditorSettings
|
|
346
|
+
})
|
|
347
|
+
]
|
|
348
|
+
};
|
|
349
|
+
};
|
|
259
350
|
var getEditedEntityContextualCommands = () => function useEditedEntityContextualCommands() {
|
|
260
351
|
const { postType } = (0, import_data.useSelect)((select) => {
|
|
261
352
|
const { getCurrentPostType } = select(import_store.store);
|
|
@@ -416,6 +507,11 @@ function useCommands() {
|
|
|
416
507
|
hook: getEditedEntityContextualCommands(),
|
|
417
508
|
context: "entity-edit"
|
|
418
509
|
});
|
|
510
|
+
(0, import_commands.useCommandLoader)({
|
|
511
|
+
name: "core/editor/pattern-editing-contextual-commands",
|
|
512
|
+
hook: getPatternEditingContextualCommands(),
|
|
513
|
+
context: "block-selection-edit"
|
|
514
|
+
});
|
|
419
515
|
(0, import_commands.useCommandLoader)({
|
|
420
516
|
name: "core/editor/page-content-focus",
|
|
421
517
|
hook: getPageContentFocusCommands(),
|