@wordpress/editor 14.40.2-next.v.202602271551.0 → 14.41.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 +2 -0
- package/build/components/collaborators-presence/index.cjs +2 -2
- package/build/components/collaborators-presence/index.cjs.map +1 -1
- package/build/components/collaborators-presence/list.cjs +2 -2
- package/build/components/collaborators-presence/list.cjs.map +1 -1
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs +174 -0
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +7 -0
- package/build/components/editor-interface/index.cjs +2 -0
- package/build/components/editor-interface/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/panel.cjs +0 -1
- package/build/components/post-author/panel.cjs.map +2 -2
- package/build/components/post-locked-modal/index.cjs +30 -14
- package/build/components/post-locked-modal/index.cjs.map +3 -3
- package/build/components/post-url/panel.cjs +0 -1
- package/build/components/post-url/panel.cjs.map +2 -2
- package/build/components/sync-connection-modal/index.cjs +78 -27
- package/build/components/sync-connection-modal/index.cjs.map +3 -3
- package/build/components/sync-connection-modal/use-retry-countdown.cjs +74 -0
- package/build/components/sync-connection-modal/use-retry-countdown.cjs.map +7 -0
- package/build/store/selectors.cjs +3 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/sync-error-messages.cjs +16 -12
- package/build/utils/sync-error-messages.cjs.map +2 -2
- package/build-module/components/collaborators-presence/index.mjs +2 -2
- package/build-module/components/collaborators-presence/index.mjs.map +1 -1
- package/build-module/components/collaborators-presence/list.mjs +2 -2
- package/build-module/components/collaborators-presence/list.mjs.map +1 -1
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +151 -0
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +7 -0
- package/build-module/components/editor-interface/index.mjs +2 -0
- package/build-module/components/editor-interface/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/panel.mjs +0 -1
- package/build-module/components/post-author/panel.mjs.map +2 -2
- package/build-module/components/post-locked-modal/index.mjs +30 -14
- package/build-module/components/post-locked-modal/index.mjs.map +2 -2
- package/build-module/components/post-url/panel.mjs +0 -1
- package/build-module/components/post-url/panel.mjs.map +2 -2
- package/build-module/components/sync-connection-modal/index.mjs +83 -30
- package/build-module/components/sync-connection-modal/index.mjs.map +2 -2
- package/build-module/components/sync-connection-modal/use-retry-countdown.mjs +49 -0
- package/build-module/components/sync-connection-modal/use-retry-countdown.mjs.map +7 -0
- package/build-module/store/selectors.mjs +3 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/sync-error-messages.mjs +16 -12
- package/build-module/utils/sync-error-messages.mjs.map +2 -2
- package/build-style/style-rtl.css +6 -22
- package/build-style/style.css +6 -22
- package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts +9 -0
- package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -0
- package/build-types/components/editor-interface/index.d.ts.map +1 -1
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/post-author/panel.d.ts.map +1 -1
- package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
- package/build-types/components/sync-connection-modal/index.d.ts.map +1 -1
- package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts +9 -0
- package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts.map +1 -0
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/utils/sync-error-messages.d.ts +1 -1
- package/build-types/utils/sync-error-messages.d.ts.map +1 -1
- package/package.json +44 -44
- package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +454 -0
- package/src/components/collaborators-presence/use-collaborator-notifications.ts +258 -0
- package/src/components/editor-interface/index.js +5 -0
- package/src/components/page-attributes/parent.js +0 -1
- package/src/components/post-author/panel.js +0 -1
- package/src/components/post-locked-modal/index.js +46 -23
- package/src/components/post-url/panel.js +0 -1
- package/src/components/post-url/style.scss +0 -5
- package/src/components/sync-connection-modal/index.js +97 -37
- package/src/components/sync-connection-modal/style.scss +6 -8
- package/src/components/sync-connection-modal/use-retry-countdown.js +70 -0
- package/src/store/selectors.js +5 -0
- package/src/utils/sync-error-messages.js +17 -12
- package/src/utils/test/sync-error-messages.js +57 -0
package/CHANGELOG.md
CHANGED
|
@@ -33,9 +33,9 @@ var import_get_avatar_url = require("../collaborators-overlay/get-avatar-url.cjs
|
|
|
33
33
|
var import_utils = require("../collab-sidebar/utils.cjs");
|
|
34
34
|
|
|
35
35
|
// packages/editor/src/components/collaborators-presence/styles/collaborators-presence.scss
|
|
36
|
-
if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='
|
|
36
|
+
if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='75307c1ddf']")) {
|
|
37
37
|
const style = document.createElement("style");
|
|
38
|
-
style.setAttribute("data-wp-hash", "
|
|
38
|
+
style.setAttribute("data-wp-hash", "75307c1ddf");
|
|
39
39
|
style.appendChild(document.createTextNode(".editor-collaborators-presence{align-items:center;background:#f0f0f0;border-radius:4px;display:flex;flex-shrink:0;height:32px;margin-right:8px}.editor-collaborators-presence:hover{background-color:#e0e0e0}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button{align-items:center;background:#0000;border-radius:4px;box-sizing:border-box;color:#2f2f2f;cursor:pointer;display:flex;height:100%;padding:4px;position:relative}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:hover{background:#0000;color:#2f2f2f}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed,.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed:hover{background:#ddd;color:#2f2f2f}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:focus:not(:active){box-shadow:inset 0 0 0 var(--wp-admin-border-width-focus,2px) var(--wp-admin-theme-color,#007cba);outline:none}"));
|
|
40
40
|
document.head.appendChild(style);
|
|
41
41
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/collaborators-presence/index.tsx", "../../../src/components/collaborators-presence/styles/collaborators-presence.scss"],
|
|
4
|
-
"sourcesContent": ["import {\n\tButton,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport {\n\tprivateApis,\n\ttype PostEditorAwarenessState,\n} from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\n\nimport { CollaboratorsList } from './list';\nimport { unlock } from '../../lock-unlock';\nimport { getAvatarUrl } from '../collaborators-overlay/get-avatar-url';\nimport { getAvatarBorderColor } from '../collab-sidebar/utils';\n\nimport './styles/collaborators-presence.scss';\nimport { CollaboratorsOverlay } from '../collaborators-overlay';\n\nconst { useActiveCollaborators } = unlock( privateApis );\nconst { Avatar, AvatarGroup } = unlock( componentsPrivateApis );\n\ninterface CollaboratorsPresenceProps {\n\tpostId: number | null;\n\tpostType: string | null;\n}\n\n/**\n * Renders a list of avatars for the active collaborators, with a maximum of 3 visible avatars.\n * Shows a popover with all collaborators on hover.\n *\n * @param props CollaboratorsPresence component props\n * @param props.postId ID of the post\n * @param props.postType Type of the post\n */\nexport function CollaboratorsPresence( {\n\tpostId,\n\tpostType,\n}: CollaboratorsPresenceProps ) {\n\tconst activeCollaborators = useActiveCollaborators(\n\t\tpostId,\n\t\tpostType\n\t) as PostEditorAwarenessState[];\n\n\t// Filter out current user - we never show ourselves in the list\n\tconst otherActiveCollaborators = activeCollaborators.filter(\n\t\t( collaborator ) => ! collaborator.isMe\n\t);\n\n\tconst [ isPopoverVisible, setIsPopoverVisible ] = useState( false );\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState< HTMLElement | null >(\n\t\tnull\n\t);\n\n\t// When there are no other collaborators, this component should not render\n\t// at all. This will always be the case when collaboration is not enabled, but\n\t// also when the current user is the only editor with the post open.\n\tif ( otherActiveCollaborators.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"editor-collaborators-presence\">\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tclassName=\"editor-collaborators-presence__button\"\n\t\t\t\t\tonClick={ () => setIsPopoverVisible( ! isPopoverVisible ) }\n\t\t\t\t\tisPressed={ isPopoverVisible }\n\t\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t// translators: %d: number of online collaborators.\n\t\t\t\t\t\t__( 'Collaborators list, %d online' ),\n\t\t\t\t\t\totherActiveCollaborators.length\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<AvatarGroup max={ 3 }>\n\t\t\t\t\t\t{ otherActiveCollaborators.map(\n\t\t\t\t\t\t\t( collaboratorState ) => (\n\t\t\t\t\t\t\t\t<Avatar\n\t\t\t\t\t\t\t\t\tkey={ collaboratorState.clientId }\n\t\t\t\t\t\t\t\t\tsrc={ getAvatarUrl(\n\t\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo\n\t\t\t\t\t\t\t\t\t\t\t.avatar_urls\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tname={\n\t\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo.name\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tborderColor={ getAvatarBorderColor(\n\t\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo.id\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</AvatarGroup>\n\t\t\t\t</Button>\n\t\t\t\t{ isPopoverVisible && (\n\t\t\t\t\t<CollaboratorsList\n\t\t\t\t\t\tactiveCollaborators={ otherActiveCollaborators }\n\t\t\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\t\t\tsetIsPopoverVisible={ setIsPopoverVisible }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<CollaboratorsOverlay postId={ postId } postType={ postType } />\n\t\t</>\n\t);\n}\n", "if (typeof document !== 'undefined' && process.env.NODE_ENV !== 'test' && !document.head.querySelector(\"style[data-wp-hash='
|
|
4
|
+
"sourcesContent": ["import {\n\tButton,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport {\n\tprivateApis,\n\ttype PostEditorAwarenessState,\n} from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\n\nimport { CollaboratorsList } from './list';\nimport { unlock } from '../../lock-unlock';\nimport { getAvatarUrl } from '../collaborators-overlay/get-avatar-url';\nimport { getAvatarBorderColor } from '../collab-sidebar/utils';\n\nimport './styles/collaborators-presence.scss';\nimport { CollaboratorsOverlay } from '../collaborators-overlay';\n\nconst { useActiveCollaborators } = unlock( privateApis );\nconst { Avatar, AvatarGroup } = unlock( componentsPrivateApis );\n\ninterface CollaboratorsPresenceProps {\n\tpostId: number | null;\n\tpostType: string | null;\n}\n\n/**\n * Renders a list of avatars for the active collaborators, with a maximum of 3 visible avatars.\n * Shows a popover with all collaborators on hover.\n *\n * @param props CollaboratorsPresence component props\n * @param props.postId ID of the post\n * @param props.postType Type of the post\n */\nexport function CollaboratorsPresence( {\n\tpostId,\n\tpostType,\n}: CollaboratorsPresenceProps ) {\n\tconst activeCollaborators = useActiveCollaborators(\n\t\tpostId,\n\t\tpostType\n\t) as PostEditorAwarenessState[];\n\n\t// Filter out current user - we never show ourselves in the list\n\tconst otherActiveCollaborators = activeCollaborators.filter(\n\t\t( collaborator ) => ! collaborator.isMe\n\t);\n\n\tconst [ isPopoverVisible, setIsPopoverVisible ] = useState( false );\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState< HTMLElement | null >(\n\t\tnull\n\t);\n\n\t// When there are no other collaborators, this component should not render\n\t// at all. This will always be the case when collaboration is not enabled, but\n\t// also when the current user is the only editor with the post open.\n\tif ( otherActiveCollaborators.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"editor-collaborators-presence\">\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tclassName=\"editor-collaborators-presence__button\"\n\t\t\t\t\tonClick={ () => setIsPopoverVisible( ! isPopoverVisible ) }\n\t\t\t\t\tisPressed={ isPopoverVisible }\n\t\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t// translators: %d: number of online collaborators.\n\t\t\t\t\t\t__( 'Collaborators list, %d online' ),\n\t\t\t\t\t\totherActiveCollaborators.length\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<AvatarGroup max={ 3 }>\n\t\t\t\t\t\t{ otherActiveCollaborators.map(\n\t\t\t\t\t\t\t( collaboratorState ) => (\n\t\t\t\t\t\t\t\t<Avatar\n\t\t\t\t\t\t\t\t\tkey={ collaboratorState.clientId }\n\t\t\t\t\t\t\t\t\tsrc={ getAvatarUrl(\n\t\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo\n\t\t\t\t\t\t\t\t\t\t\t.avatar_urls\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tname={\n\t\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo.name\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tborderColor={ getAvatarBorderColor(\n\t\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo.id\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</AvatarGroup>\n\t\t\t\t</Button>\n\t\t\t\t{ isPopoverVisible && (\n\t\t\t\t\t<CollaboratorsList\n\t\t\t\t\t\tactiveCollaborators={ otherActiveCollaborators }\n\t\t\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\t\t\tsetIsPopoverVisible={ setIsPopoverVisible }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<CollaboratorsOverlay postId={ postId } postType={ postType } />\n\t\t</>\n\t);\n}\n", "if (typeof document !== 'undefined' && process.env.NODE_ENV !== 'test' && !document.head.querySelector(\"style[data-wp-hash='75307c1ddf']\")) {\n\tconst style = document.createElement(\"style\");\n\tstyle.setAttribute(\"data-wp-hash\", \"75307c1ddf\");\n\tstyle.appendChild(document.createTextNode(\".editor-collaborators-presence{align-items:center;background:#f0f0f0;border-radius:4px;display:flex;flex-shrink:0;height:32px;margin-right:8px}.editor-collaborators-presence:hover{background-color:#e0e0e0}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button{align-items:center;background:#0000;border-radius:4px;box-sizing:border-box;color:#2f2f2f;cursor:pointer;display:flex;height:100%;padding:4px;position:relative}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:hover{background:#0000;color:#2f2f2f}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed,.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed:hover{background:#ddd;color:#2f2f2f}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:focus:not(:active){box-shadow:inset 0 0 0 var(--wp-admin-border-width-focus,2px) var(--wp-admin-theme-color,#007cba);outline:none}\"));\n\tdocument.head.appendChild(style);\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAGO;AACP,qBAAyB;AACzB,uBAGO;AACP,kBAA4B;AAE5B,kBAAkC;AAClC,yBAAuB;AACvB,4BAA6B;AAC7B,m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AEpC,iBAAc;AAAA,kBACb,kBAAkB,iBAAiB;AAAA,gBACpC;AAAA,gBACA,MAAK;AAAA;AAAA,cAXC,kBAAkB;AAAA,YAYzB;AAAA,UAEF,GACD;AAAA;AAAA,MACD;AAAA,MACE,oBACD;AAAA,QAAC;AAAA;AAAA,UACA,qBAAsB;AAAA,UACtB;AAAA,UACA;AAAA;AAAA,MACD;AAAA,OAEF;AAAA,IACA,4CAAC,qDAAqB,QAAkB,UAAsB;AAAA,KAC/D;AAEF;",
|
|
6
6
|
"names": ["componentsPrivateApis"]
|
|
7
7
|
}
|
|
@@ -31,9 +31,9 @@ var import_get_avatar_url = require("../collaborators-overlay/get-avatar-url.cjs
|
|
|
31
31
|
var import_utils = require("../collab-sidebar/utils.cjs");
|
|
32
32
|
|
|
33
33
|
// packages/editor/src/components/collaborators-presence/styles/collaborators-list.scss
|
|
34
|
-
if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='
|
|
34
|
+
if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='0d3429a67b']")) {
|
|
35
35
|
const style = document.createElement("style");
|
|
36
|
-
style.setAttribute("data-wp-hash", "
|
|
36
|
+
style.setAttribute("data-wp-hash", "0d3429a67b");
|
|
37
37
|
style.appendChild(document.createTextNode(".editor-collaborators-presence__list.components-popover .components-popover__content{background:#fff;border:1px solid #ddd;border-radius:8px;border-width:1px 0 0 1px;box-shadow:0 1px 2px #0000000d,0 2px 3px #0000000a,0 6px 6px #00000008,0 8px 8px #00000005}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-content{min-width:280px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header{align-items:center;display:flex;justify-content:space-between;padding:0 16px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-title{font-size:13px;font-weight:499;line-height:20px;padding:14px 0;text-transform:uppercase}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-title span{color:#757575}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-action{padding:8px 0}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-action button{color:#1e1e1e;height:24px;padding:0;width:24px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-items{display:flex;flex-direction:column;padding:0 10px 16px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item{all:unset;align-items:center;border-radius:12px;box-sizing:border-box;cursor:pointer;display:flex;gap:8px;padding:6px;transition:background-color .2s ease;width:100%}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:hover:not(:disabled){background-color:#0000000d}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:active:not(:disabled){background-color:#00000014}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:focus-visible{outline:2px solid var(--wp-admin-theme-color,#007cba);outline-offset:-2px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:disabled{cursor:default}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item-info{display:flex;flex:1;flex-direction:column;font-size:12px;line-height:16px}"));
|
|
38
38
|
document.head.appendChild(style);
|
|
39
39
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/collaborators-presence/list.tsx", "../../../src/components/collaborators-presence/styles/collaborators-list.scss"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport {\n\tPopover,\n\tButton,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { close } from '@wordpress/icons';\nimport { type PostEditorAwarenessState } from '@wordpress/core-data';\n\nimport { unlock } from '../../lock-unlock';\nimport { getAvatarUrl } from '../collaborators-overlay/get-avatar-url';\nimport { getAvatarBorderColor } from '../collab-sidebar/utils';\n\nimport './styles/collaborators-list.scss';\n\nconst { Avatar } = unlock( componentsPrivateApis );\n\ninterface CollaboratorsListProps {\n\tactiveCollaborators: PostEditorAwarenessState[];\n\tpopoverAnchor?: HTMLElement | null;\n\tsetIsPopoverVisible: ( isVisible: boolean ) => void;\n}\n\n/**\n * Renders a list showing all active collaborators with their details.\n * Note: activeUsers should already exclude the current user (filtered by parent component).\n * @param props Component props\n * @param props.activeCollaborators List of active collaborators\n * @param props.popoverAnchor Anchor element for the popover\n * @param props.setIsPopoverVisible Callback to set the visibility of the popover\n */\nexport function CollaboratorsList( {\n\tactiveCollaborators,\n\tpopoverAnchor,\n\tsetIsPopoverVisible,\n}: CollaboratorsListProps ) {\n\treturn (\n\t\t<Popover\n\t\t\tanchor={ popoverAnchor }\n\t\t\tplacement=\"bottom\"\n\t\t\toffset={ 8 }\n\t\t\tclassName=\"editor-collaborators-presence__list\"\n\t\t\tonClose={ () => setIsPopoverVisible( false ) }\n\t\t>\n\t\t\t<div className=\"editor-collaborators-presence__list-content\">\n\t\t\t\t<div className=\"editor-collaborators-presence__list-header\">\n\t\t\t\t\t<div className=\"editor-collaborators-presence__list-header-title\">\n\t\t\t\t\t\t{ __( 'Collaborators' ) }\n\t\t\t\t\t\t<span> { activeCollaborators.length } </span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"editor-collaborators-presence__list-header-action\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\t\ticonSize={ 16 }\n\t\t\t\t\t\t\tlabel={ __( 'Close Collaborators List' ) }\n\t\t\t\t\t\t\tonClick={ () => setIsPopoverVisible( false ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"editor-collaborators-presence__list-items\">\n\t\t\t\t\t{ activeCollaborators.map( ( collaboratorState ) => (\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tkey={ collaboratorState.clientId }\n\t\t\t\t\t\t\tclassName=\"editor-collaborators-presence__list-item\"\n\t\t\t\t\t\t\tdisabled\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\topacity: collaboratorState.isConnected\n\t\t\t\t\t\t\t\t\t? 1\n\t\t\t\t\t\t\t\t\t: 0.5,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Avatar\n\t\t\t\t\t\t\t\tsrc={ getAvatarUrl(\n\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo\n\t\t\t\t\t\t\t\t\t\t.avatar_urls\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tname={ collaboratorState.collaboratorInfo.name }\n\t\t\t\t\t\t\t\tborderColor={ getAvatarBorderColor(\n\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo.id\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<div className=\"editor-collaborators-presence__list-item-info\">\n\t\t\t\t\t\t\t\t<div className=\"editor-collaborators-presence__list-item-name\">\n\t\t\t\t\t\t\t\t\t{ collaboratorState.collaboratorInfo.name }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t) ) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</Popover>\n\t);\n}\n", "if (typeof document !== 'undefined' && process.env.NODE_ENV !== 'test' && !document.head.querySelector(\"style[data-wp-hash='
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport {\n\tPopover,\n\tButton,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { close } from '@wordpress/icons';\nimport { type PostEditorAwarenessState } from '@wordpress/core-data';\n\nimport { unlock } from '../../lock-unlock';\nimport { getAvatarUrl } from '../collaborators-overlay/get-avatar-url';\nimport { getAvatarBorderColor } from '../collab-sidebar/utils';\n\nimport './styles/collaborators-list.scss';\n\nconst { Avatar } = unlock( componentsPrivateApis );\n\ninterface CollaboratorsListProps {\n\tactiveCollaborators: PostEditorAwarenessState[];\n\tpopoverAnchor?: HTMLElement | null;\n\tsetIsPopoverVisible: ( isVisible: boolean ) => void;\n}\n\n/**\n * Renders a list showing all active collaborators with their details.\n * Note: activeUsers should already exclude the current user (filtered by parent component).\n * @param props Component props\n * @param props.activeCollaborators List of active collaborators\n * @param props.popoverAnchor Anchor element for the popover\n * @param props.setIsPopoverVisible Callback to set the visibility of the popover\n */\nexport function CollaboratorsList( {\n\tactiveCollaborators,\n\tpopoverAnchor,\n\tsetIsPopoverVisible,\n}: CollaboratorsListProps ) {\n\treturn (\n\t\t<Popover\n\t\t\tanchor={ popoverAnchor }\n\t\t\tplacement=\"bottom\"\n\t\t\toffset={ 8 }\n\t\t\tclassName=\"editor-collaborators-presence__list\"\n\t\t\tonClose={ () => setIsPopoverVisible( false ) }\n\t\t>\n\t\t\t<div className=\"editor-collaborators-presence__list-content\">\n\t\t\t\t<div className=\"editor-collaborators-presence__list-header\">\n\t\t\t\t\t<div className=\"editor-collaborators-presence__list-header-title\">\n\t\t\t\t\t\t{ __( 'Collaborators' ) }\n\t\t\t\t\t\t<span> { activeCollaborators.length } </span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"editor-collaborators-presence__list-header-action\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\t\ticonSize={ 16 }\n\t\t\t\t\t\t\tlabel={ __( 'Close Collaborators List' ) }\n\t\t\t\t\t\t\tonClick={ () => setIsPopoverVisible( false ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"editor-collaborators-presence__list-items\">\n\t\t\t\t\t{ activeCollaborators.map( ( collaboratorState ) => (\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tkey={ collaboratorState.clientId }\n\t\t\t\t\t\t\tclassName=\"editor-collaborators-presence__list-item\"\n\t\t\t\t\t\t\tdisabled\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\topacity: collaboratorState.isConnected\n\t\t\t\t\t\t\t\t\t? 1\n\t\t\t\t\t\t\t\t\t: 0.5,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Avatar\n\t\t\t\t\t\t\t\tsrc={ getAvatarUrl(\n\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo\n\t\t\t\t\t\t\t\t\t\t.avatar_urls\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tname={ collaboratorState.collaboratorInfo.name }\n\t\t\t\t\t\t\t\tborderColor={ getAvatarBorderColor(\n\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo.id\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<div className=\"editor-collaborators-presence__list-item-info\">\n\t\t\t\t\t\t\t\t<div className=\"editor-collaborators-presence__list-item-name\">\n\t\t\t\t\t\t\t\t\t{ collaboratorState.collaboratorInfo.name }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t) ) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</Popover>\n\t);\n}\n", "if (typeof document !== 'undefined' && process.env.NODE_ENV !== 'test' && !document.head.querySelector(\"style[data-wp-hash='0d3429a67b']\")) {\n\tconst style = document.createElement(\"style\");\n\tstyle.setAttribute(\"data-wp-hash\", \"0d3429a67b\");\n\tstyle.appendChild(document.createTextNode(\".editor-collaborators-presence__list.components-popover .components-popover__content{background:#fff;border:1px solid #ddd;border-radius:8px;border-width:1px 0 0 1px;box-shadow:0 1px 2px #0000000d,0 2px 3px #0000000a,0 6px 6px #00000008,0 8px 8px #00000005}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-content{min-width:280px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header{align-items:center;display:flex;justify-content:space-between;padding:0 16px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-title{font-size:13px;font-weight:499;line-height:20px;padding:14px 0;text-transform:uppercase}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-title span{color:#757575}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-action{padding:8px 0}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-action button{color:#1e1e1e;height:24px;padding:0;width:24px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-items{display:flex;flex-direction:column;padding:0 10px 16px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item{all:unset;align-items:center;border-radius:12px;box-sizing:border-box;cursor:pointer;display:flex;gap:8px;padding:6px;transition:background-color .2s ease;width:100%}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:hover:not(:disabled){background-color:#0000000d}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:active:not(:disabled){background-color:#00000014}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:focus-visible{outline:2px solid var(--wp-admin-theme-color,#007cba);outline-offset:-2px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:disabled{cursor:default}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item-info{display:flex;flex:1;flex-direction:column;font-size:12px;line-height:16px}\"));\n\tdocument.head.appendChild(style);\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,wBAIO;AACP,mBAAsB;AAGtB,yBAAuB;AACvB,4BAA6B;AAC7B,mBAAqC;;;ACXrC,IAAI,OAAO,aAAa,eAAe,QAAQ,IAAI,aAAa,UAAU,CAAC,SAAS,KAAK,cAAc,kCAAkC,GAAG;AAC3I,QAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,aAAa,gBAAgB,YAAY;AAC/C,QAAM,YAAY,SAAS,eAAe,8yEAA8yE,CAAC;AACz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A,UAvBM,kBAAkB;AAAA,QAwBzB,CACC,GACH;AAAA,SACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": ["componentsPrivateApis"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/editor/src/components/collaborators-presence/use-collaborator-notifications.ts
|
|
21
|
+
var use_collaborator_notifications_exports = {};
|
|
22
|
+
__export(use_collaborator_notifications_exports, {
|
|
23
|
+
useCollaboratorNotifications: () => useCollaboratorNotifications
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(use_collaborator_notifications_exports);
|
|
26
|
+
var import_compose = require("@wordpress/compose");
|
|
27
|
+
var import_data = require("@wordpress/data");
|
|
28
|
+
var import_element = require("@wordpress/element");
|
|
29
|
+
var import_i18n = require("@wordpress/i18n");
|
|
30
|
+
var import_notices = require("@wordpress/notices");
|
|
31
|
+
var import_core_data = require("@wordpress/core-data");
|
|
32
|
+
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
33
|
+
var import_store = require("../../store/index.cjs");
|
|
34
|
+
var { useActiveCollaborators, useLastPostSave } = (0, import_lock_unlock.unlock)(import_core_data.privateApis);
|
|
35
|
+
var NOTIFICATION_TYPE = {
|
|
36
|
+
COLLAB_POST_UPDATED: "collab-post-updated",
|
|
37
|
+
COLLAB_USER_ENTERED: "collab-user-entered",
|
|
38
|
+
COLLAB_USER_EXITED: "collab-user-exited"
|
|
39
|
+
};
|
|
40
|
+
var NOTIFICATIONS_CONFIG = {
|
|
41
|
+
userEntered: true,
|
|
42
|
+
userExited: true,
|
|
43
|
+
postUpdated: true
|
|
44
|
+
};
|
|
45
|
+
var PUBLISHED_STATUSES = ["publish", "private", "future"];
|
|
46
|
+
function getPostUpdatedMessage(name, status, isFirstPublish) {
|
|
47
|
+
if (isFirstPublish) {
|
|
48
|
+
return (0, import_i18n.sprintf)((0, import_i18n.__)("Post published by %s."), name);
|
|
49
|
+
}
|
|
50
|
+
if (PUBLISHED_STATUSES.includes(status)) {
|
|
51
|
+
return (0, import_i18n.sprintf)((0, import_i18n.__)("Post updated by %s."), name);
|
|
52
|
+
}
|
|
53
|
+
return (0, import_i18n.sprintf)((0, import_i18n.__)("Draft saved by %s."), name);
|
|
54
|
+
}
|
|
55
|
+
function useCollaboratorNotifications(postId, postType) {
|
|
56
|
+
const activeCollaborators = useActiveCollaborators(
|
|
57
|
+
postId,
|
|
58
|
+
postType
|
|
59
|
+
);
|
|
60
|
+
const lastPostSave = useLastPostSave(postId, postType);
|
|
61
|
+
const { postStatus, isCollaborationEnabled } = (0, import_data.useSelect)((select) => {
|
|
62
|
+
const editorSel = select(import_store.store);
|
|
63
|
+
return {
|
|
64
|
+
postStatus: editorSel.getCurrentPostAttribute("status"),
|
|
65
|
+
isCollaborationEnabled: editorSel.isCollaborationEnabledForCurrentPost()
|
|
66
|
+
};
|
|
67
|
+
}, []);
|
|
68
|
+
const { createNotice } = (0, import_data.useDispatch)(import_notices.store);
|
|
69
|
+
const prevCollaborators = (0, import_compose.usePrevious)(activeCollaborators);
|
|
70
|
+
const prevPostSave = (0, import_compose.usePrevious)(lastPostSave);
|
|
71
|
+
(0, import_element.useEffect)(() => {
|
|
72
|
+
if (!isCollaborationEnabled) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (!prevCollaborators || prevCollaborators.length === 0) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
function notify(noticeId, message) {
|
|
79
|
+
void createNotice("info", message, {
|
|
80
|
+
id: noticeId,
|
|
81
|
+
type: "snackbar",
|
|
82
|
+
isDismissible: false
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const prevMap = new Map(
|
|
86
|
+
prevCollaborators.map((c) => [c.clientId, c])
|
|
87
|
+
);
|
|
88
|
+
const newMap = new Map(
|
|
89
|
+
activeCollaborators.map((c) => [c.clientId, c])
|
|
90
|
+
);
|
|
91
|
+
if (NOTIFICATIONS_CONFIG.userEntered) {
|
|
92
|
+
const me = activeCollaborators.find((c) => c.isMe);
|
|
93
|
+
for (const [clientId, collaborator] of newMap) {
|
|
94
|
+
if (prevMap.has(clientId) || collaborator.isMe) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (me && collaborator.collaboratorInfo.enteredAt < me.collaboratorInfo.enteredAt) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
notify(
|
|
101
|
+
`${NOTIFICATION_TYPE.COLLAB_USER_ENTERED}-${collaborator.collaboratorInfo.id}`,
|
|
102
|
+
(0, import_i18n.sprintf)(
|
|
103
|
+
/* translators: %s: collaborator display name */
|
|
104
|
+
(0, import_i18n.__)("%s has joined the post."),
|
|
105
|
+
collaborator.collaboratorInfo.name
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (NOTIFICATIONS_CONFIG.userExited) {
|
|
111
|
+
for (const [clientId, prevCollab] of prevMap) {
|
|
112
|
+
if (prevCollab.isMe || !prevCollab.isConnected) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const newCollab = newMap.get(clientId);
|
|
116
|
+
if (newCollab?.isConnected) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
notify(
|
|
120
|
+
`${NOTIFICATION_TYPE.COLLAB_USER_EXITED}-${prevCollab.collaboratorInfo.id}`,
|
|
121
|
+
(0, import_i18n.sprintf)(
|
|
122
|
+
/* translators: %s: collaborator display name */
|
|
123
|
+
(0, import_i18n.__)("%s has left the post."),
|
|
124
|
+
prevCollab.collaboratorInfo.name
|
|
125
|
+
)
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}, [
|
|
130
|
+
activeCollaborators,
|
|
131
|
+
prevCollaborators,
|
|
132
|
+
isCollaborationEnabled,
|
|
133
|
+
createNotice
|
|
134
|
+
]);
|
|
135
|
+
(0, import_element.useEffect)(() => {
|
|
136
|
+
if (!isCollaborationEnabled || !NOTIFICATIONS_CONFIG.postUpdated || !lastPostSave || !postStatus) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (prevPostSave && lastPostSave.savedAt === prevPostSave.savedAt) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const saver = activeCollaborators.find(
|
|
143
|
+
(c) => c.clientId === lastPostSave.savedByClientId && !c.isMe
|
|
144
|
+
);
|
|
145
|
+
if (!saver) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const effectiveStatus = lastPostSave.postStatus ?? postStatus ?? "draft";
|
|
149
|
+
const prevStatus = prevPostSave?.postStatus ?? postStatus;
|
|
150
|
+
const isFirstPublish = !(prevStatus && PUBLISHED_STATUSES.includes(prevStatus)) && PUBLISHED_STATUSES.includes(effectiveStatus);
|
|
151
|
+
const message = getPostUpdatedMessage(
|
|
152
|
+
saver.collaboratorInfo.name,
|
|
153
|
+
effectiveStatus,
|
|
154
|
+
isFirstPublish
|
|
155
|
+
);
|
|
156
|
+
void createNotice("info", message, {
|
|
157
|
+
id: `${NOTIFICATION_TYPE.COLLAB_POST_UPDATED}-${saver.collaboratorInfo.id}`,
|
|
158
|
+
type: "snackbar",
|
|
159
|
+
isDismissible: false
|
|
160
|
+
});
|
|
161
|
+
}, [
|
|
162
|
+
lastPostSave,
|
|
163
|
+
prevPostSave,
|
|
164
|
+
activeCollaborators,
|
|
165
|
+
isCollaborationEnabled,
|
|
166
|
+
postStatus,
|
|
167
|
+
createNotice
|
|
168
|
+
]);
|
|
169
|
+
}
|
|
170
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
171
|
+
0 && (module.exports = {
|
|
172
|
+
useCollaboratorNotifications
|
|
173
|
+
});
|
|
174
|
+
//# sourceMappingURL=use-collaborator-notifications.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/collaborators-presence/use-collaborator-notifications.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport {\n\tprivateApis,\n\ttype PostEditorAwarenessState,\n} from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst { useActiveCollaborators, useLastPostSave } = unlock( 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 NOTIFICATIONS_CONFIG = {\n\tuserEntered: true,\n\tuserExited: true,\n\tpostUpdated: true,\n};\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 activeCollaborators = useActiveCollaborators(\n\t\tpostId,\n\t\tpostType\n\t) as PostEditorAwarenessState[];\n\n\tconst lastPostSave = useLastPostSave( postId, postType );\n\n\tconst { postStatus, isCollaborationEnabled } = useSelect( ( select ) => {\n\t\tconst editorSel = select( editorStore );\n\t\treturn {\n\t\t\tpostStatus: editorSel.getCurrentPostAttribute( 'status' ) as\n\t\t\t\t| string\n\t\t\t\t| undefined,\n\t\t\tisCollaborationEnabled:\n\t\t\t\teditorSel.isCollaborationEnabledForCurrentPost(),\n\t\t};\n\t}, [] );\n\n\tconst { createNotice } = useDispatch( noticesStore );\n\n\tconst prevCollaborators = usePrevious( activeCollaborators );\n\tconst prevPostSave = usePrevious( lastPostSave );\n\n\t/*\n\t * Detect collaborator joins and leaves.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isCollaborationEnabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * On first render usePrevious returns undefined. On subsequent renders\n\t\t * the list may still be empty while the store hydrates. In both cases,\n\t\t * skip to avoid spurious \"X joined\" toasts for users already present.\n\t\t */\n\t\tif ( ! prevCollaborators || prevCollaborators.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction notify( noticeId: string, message: string ) {\n\t\t\tvoid createNotice( 'info', message, {\n\t\t\t\tid: noticeId,\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: false,\n\t\t\t} );\n\t\t}\n\n\t\tconst prevMap = new Map< number, PostEditorAwarenessState >(\n\t\t\tprevCollaborators.map( ( c ) => [ c.clientId, c ] )\n\t\t);\n\t\tconst newMap = new Map< number, PostEditorAwarenessState >(\n\t\t\tactiveCollaborators.map( ( c ) => [ c.clientId, c ] )\n\t\t);\n\n\t\t/*\n\t\t * Detect joins: new clientIds that weren't in the previous state.\n\t\t */\n\t\tif ( NOTIFICATIONS_CONFIG.userEntered ) {\n\t\t\tconst me = activeCollaborators.find( ( c ) => c.isMe );\n\n\t\t\tfor ( const [ clientId, collaborator ] of newMap ) {\n\t\t\t\tif ( prevMap.has( clientId ) || collaborator.isMe ) {\n\t\t\t\t\tcontinue;\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\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tnotify(\n\t\t\t\t\t`${ NOTIFICATION_TYPE.COLLAB_USER_ENTERED }-${ collaborator.collaboratorInfo.id }`,\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);\n\t\t\t}\n\t\t}\n\n\t\t/*\n\t\t * Detect leaves by iterating the previous collaborator list. A leave\n\t\t * notification fires when a previously-connected collaborator either:\n\t\t * - transitions to isConnected=false (greyed-out in the UI), or\n\t\t * - disappears from the list entirely while still connected.\n\t\t * Already-disconnected collaborators that are later removed from the\n\t\t * list (after the 5 s delay) are silently ignored.\n\t\t */\n\t\tif ( NOTIFICATIONS_CONFIG.userExited ) {\n\t\t\tfor ( const [ clientId, prevCollab ] of prevMap ) {\n\t\t\t\tif ( prevCollab.isMe || ! prevCollab.isConnected ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst newCollab = newMap.get( clientId );\n\t\t\t\tif ( newCollab?.isConnected ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tnotify(\n\t\t\t\t\t`${ NOTIFICATION_TYPE.COLLAB_USER_EXITED }-${ prevCollab.collaboratorInfo.id }`,\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\tprevCollab.collaboratorInfo.name\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}, [\n\t\tactiveCollaborators,\n\t\tprevCollaborators,\n\t\tisCollaborationEnabled,\n\t\tcreateNotice,\n\t] );\n\n\t/*\n\t * Detect remote save events via the CRDT state map. The savedByClientId\n\t * is a Y.Doc client ID which maps to a collaborator via clientId.\n\t */\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! isCollaborationEnabled ||\n\t\t\t! NOTIFICATIONS_CONFIG.postUpdated ||\n\t\t\t! lastPostSave ||\n\t\t\t! postStatus\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( prevPostSave && lastPostSave.savedAt === prevPostSave.savedAt ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst saver = activeCollaborators.find(\n\t\t\t( c ) => c.clientId === lastPostSave.savedByClientId && ! c.isMe\n\t\t);\n\n\t\tif ( ! saver ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Prefer the remote status from Y.Doc (accurate at save time) over\n\t\t// the local Redux value, which may not have synced yet.\n\t\tconst effectiveStatus =\n\t\t\tlastPostSave.postStatus ?? postStatus ?? 'draft';\n\n\t\t// prevPostSave is null on the first save this session, so fall back\n\t\t// to the Redux status (still pre-save when the notification fires).\n\t\tconst prevStatus = prevPostSave?.postStatus ?? postStatus;\n\t\tconst isFirstPublish =\n\t\t\t! ( prevStatus && PUBLISHED_STATUSES.includes( prevStatus ) ) &&\n\t\t\tPUBLISHED_STATUSES.includes( effectiveStatus );\n\n\t\tconst message = getPostUpdatedMessage(\n\t\t\tsaver.collaboratorInfo.name,\n\t\t\teffectiveStatus,\n\t\t\tisFirstPublish\n\t\t);\n\n\t\tvoid createNotice( 'info', message, {\n\t\t\tid: `${ NOTIFICATION_TYPE.COLLAB_POST_UPDATED }-${ saver.collaboratorInfo.id }`,\n\t\t\ttype: 'snackbar',\n\t\t\tisDismissible: false,\n\t\t} );\n\t}, [\n\t\tlastPostSave,\n\t\tprevPostSave,\n\t\tactiveCollaborators,\n\t\tisCollaborationEnabled,\n\t\tpostStatus,\n\t\tcreateNotice,\n\t] );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4B;AAC5B,kBAAuC;AACvC,qBAA0B;AAC1B,kBAA4B;AAC5B,qBAAsC;AACtC,uBAGO;AAKP,yBAAuB;AACvB,mBAAqC;AAErC,IAAM,EAAE,wBAAwB,gBAAgB,QAAI,2BAAQ,4BAAY;AAMxE,IAAM,oBAAoB;AAAA,EACzB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,oBAAoB;AACrB;AAEA,IAAM,uBAAuB;AAAA,EAC5B,aAAa;AAAA,EACb,YAAY;AA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7D;AAEA,QAAK,CAAE,OAAQ;AACd;AAAA,IACD;AAIA,UAAM,kBACL,aAAa,cAAc,cAAc;AAI1C,UAAM,aAAa,cAAc,cAAc;AAC/C,UAAM,iBACL,EAAI,cAAc,mBAAmB,SAAU,UAAW,MAC1D,mBAAmB,SAAU,eAAgB;AAE9C,UAAM,UAAU;AAAA,MACf,MAAM,iBAAiB;AAAA,MACvB;AAAA,MACA;AAAA,IACD;AAEA,SAAK,aAAc,QAAQ,SAAS;AAAA,MACnC,IAAI,GAAI,kBAAkB,mBAAoB,IAAK,MAAM,iBAAiB,EAAG;AAAA,MAC7E,MAAM;AAAA,MACN,eAAe;AAAA,IAChB,CAAE;AAAA,EACH,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
|
|
6
|
+
"names": ["editorStore", "noticesStore"]
|
|
7
|
+
}
|
|
@@ -51,6 +51,7 @@ var import_inserter_sidebar = __toESM(require("../inserter-sidebar/index.cjs"));
|
|
|
51
51
|
var import_list_view_sidebar = __toESM(require("../list-view-sidebar/index.cjs"));
|
|
52
52
|
var import_post_revisions_preview = require("../post-revisions-preview/index.cjs");
|
|
53
53
|
var import_collaborators_overlay = require("../collaborators-overlay/index.cjs");
|
|
54
|
+
var import_use_collaborator_notifications = require("../collaborators-presence/use-collaborator-notifications.cjs");
|
|
54
55
|
var import_save_publish_panels = __toESM(require("../save-publish-panels/index.cjs"));
|
|
55
56
|
var import_text_editor = __toESM(require("../text-editor/index.cjs"));
|
|
56
57
|
var import_visual_editor = __toESM(require("../visual-editor/index.cjs"));
|
|
@@ -140,6 +141,7 @@ function EditorInterface({
|
|
|
140
141
|
isRevisionsMode: _isRevisionsMode()
|
|
141
142
|
};
|
|
142
143
|
}, []);
|
|
144
|
+
(0, import_use_collaborator_notifications.useCollaboratorNotifications)(postId, postType);
|
|
143
145
|
const isLargeViewport = (0, import_compose.useViewportMatch)("medium");
|
|
144
146
|
const secondarySidebarLabel = isListViewOpened ? (0, import_i18n.__)("Document Overview") : (0, import_i18n.__)("Block Library");
|
|
145
147
|
const shouldShowMediaEditor = !!isAttachment;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/editor-interface/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { InterfaceSkeleton, ComplementaryArea } from '@wordpress/interface';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { BlockBreadcrumb, BlockToolbar } from '@wordpress/block-editor';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useState, useCallback } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { InlineNotices } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport TemplateValidationNotice from '../template-validation-notice';\nimport Header from '../header';\nimport InserterSidebar from '../inserter-sidebar';\nimport ListViewSidebar from '../list-view-sidebar';\nimport { RevisionsHeader, RevisionsCanvas } from '../post-revisions-preview';\nimport { CollaboratorsOverlay } from '../collaborators-overlay';\nimport SavePublishPanels from '../save-publish-panels';\nimport TextEditor from '../text-editor';\nimport VisualEditor from '../visual-editor';\nimport StylesCanvas from '../styles-canvas';\nimport { MediaPreview } from '../media';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the editor top bar landmark region. */\n\theader: __( 'Editor top bar' ),\n\t/* translators: accessibility text for the editor content landmark region. */\n\tbody: __( 'Editor content' ),\n\t/* translators: accessibility text for the editor settings landmark region. */\n\tsidebar: __( 'Editor settings' ),\n\t/* translators: accessibility text for the editor publish landmark region. */\n\tactions: __( 'Editor publish' ),\n\t/* translators: accessibility text for the editor footer landmark region. */\n\tfooter: __( 'Editor footer' ),\n};\n\nconst Notices = () => (\n\t<InlineNotices\n\t\tpinnedNoticesClassName=\"editor-notices__pinned\"\n\t\tdismissibleNoticesClassName=\"editor-notices__dismissible\"\n\t>\n\t\t<TemplateValidationNotice />\n\t</InlineNotices>\n);\n\nexport default function EditorInterface( {\n\tclassName,\n\tchildren,\n\tforceIsDirty,\n\tcontentRef,\n\tdisableIframe,\n\tautoFocus,\n\tcustomSaveButton,\n\tcustomSavePanel,\n\tforceDisableBlockTools,\n\tiframeProps,\n} ) {\n\tconst {\n\t\tmode,\n\t\tpostId,\n\t\tpostType,\n\t\tisAttachment,\n\t\tisInserterOpened,\n\t\tisListViewOpened,\n\t\tisDistractionFree,\n\t\tisPreviewMode,\n\t\tshowBlockBreadcrumbs,\n\t\tpostTypeLabel,\n\t\tstylesPath,\n\t\tshowStylebook,\n\t\tisRevisionsMode,\n\t} = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst {\n\t\t\tgetEditorSettings,\n\t\t\tgetPostTypeLabel,\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentPostId,\n\t\t} = select( editorStore );\n\t\tconst {\n\t\t\tgetStylesPath,\n\t\t\tgetShowStylebook,\n\t\t\tisRevisionsMode: _isRevisionsMode,\n\t\t} = unlock( select( editorStore ) );\n\t\tconst editorSettings = getEditorSettings();\n\n\t\tlet _mode = select( editorStore ).getEditorMode();\n\t\tif ( ! editorSettings.richEditingEnabled && _mode === 'visual' ) {\n\t\t\t_mode = 'text';\n\t\t}\n\t\tif ( ! editorSettings.codeEditingEnabled && _mode === 'text' ) {\n\t\t\t_mode = 'visual';\n\t\t}\n\n\t\treturn {\n\t\t\tmode: _mode,\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tisInserterOpened: select( editorStore ).isInserterOpened(),\n\t\t\tisListViewOpened: select( editorStore ).isListViewOpened(),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\tisPreviewMode: editorSettings.isPreviewMode,\n\t\t\tshowBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),\n\t\t\tpostTypeLabel: getPostTypeLabel(),\n\t\t\tstylesPath: getStylesPath(),\n\t\t\tshowStylebook: getShowStylebook(),\n\t\t\tisAttachment:\n\t\t\t\tgetCurrentPostType() === 'attachment' &&\n\t\t\t\twindow?.__experimentalMediaEditor,\n\t\t\tisRevisionsMode: _isRevisionsMode(),\n\t\t};\n\t}, [] );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst secondarySidebarLabel = isListViewOpened\n\t\t? __( 'Document Overview' )\n\t\t: __( 'Block Library' );\n\tconst shouldShowMediaEditor = !! isAttachment;\n\tconst shouldShowStylesCanvas =\n\t\t! isAttachment &&\n\t\t( showStylebook || stylesPath?.startsWith( '/revisions' ) );\n\tconst shouldShowBlockEditor =\n\t\t! shouldShowMediaEditor && ! shouldShowStylesCanvas;\n\n\t// Local state for save panel.\n\t// Note 'truthy' callback implies an open panel.\n\tconst [ entitiesSavedStatesCallback, setEntitiesSavedStatesCallback ] =\n\t\tuseState( false );\n\tconst closeEntitiesSavedStates = useCallback(\n\t\t( arg ) => {\n\t\t\tif ( typeof entitiesSavedStatesCallback === 'function' ) {\n\t\t\t\tentitiesSavedStatesCallback( arg );\n\t\t\t}\n\t\t\tsetEntitiesSavedStatesCallback( false );\n\t\t},\n\t\t[ entitiesSavedStatesCallback ]\n\t);\n\n\t// Local state for diff toggle in revisions mode.\n\tconst [ showDiff, setShowDiff ] = useState( true );\n\n\t// When in revisions mode, render the revisions interface.\n\tif ( isRevisionsMode ) {\n\t\treturn (\n\t\t\t<InterfaceSkeleton\n\t\t\t\tclassName={ clsx( 'editor-editor-interface', className ) }\n\t\t\t\tlabels={ interfaceLabels }\n\t\t\t\theader={\n\t\t\t\t\t<RevisionsHeader\n\t\t\t\t\t\tshowDiff={ showDiff }\n\t\t\t\t\t\tonToggleDiff={ () => setShowDiff( ! showDiff ) }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\tcontent={ <RevisionsCanvas showDiff={ showDiff } /> }\n\t\t\t\tsidebar={ <ComplementaryArea.Slot scope=\"core\" /> }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tisDistractionFree={ isDistractionFree }\n\t\t\tclassName={ clsx( 'editor-editor-interface', className, {\n\t\t\t\t'is-entity-save-view-open': !! entitiesSavedStatesCallback,\n\t\t\t\t'is-distraction-free': isDistractionFree && ! isPreviewMode,\n\t\t\t} ) }\n\t\t\tlabels={ {\n\t\t\t\t...interfaceLabels,\n\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t} }\n\t\t\theader={\n\t\t\t\t! isPreviewMode && (\n\t\t\t\t\t<Header\n\t\t\t\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcustomSaveButton={ customSaveButton }\n\t\t\t\t\t\tforceDisableBlockTools={ forceDisableBlockTools }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\teditorNotices={ <Notices /> }\n\t\t\tsecondarySidebar={\n\t\t\t\t! isAttachment &&\n\t\t\t\t! isPreviewMode &&\n\t\t\t\tmode === 'visual' &&\n\t\t\t\t( ( isInserterOpened && <InserterSidebar /> ) ||\n\t\t\t\t\t( isListViewOpened && <ListViewSidebar /> ) )\n\t\t\t}\n\t\t\tsidebar={\n\t\t\t\t! isPreviewMode &&\n\t\t\t\t! isDistractionFree && <ComplementaryArea.Slot scope=\"core\" />\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t{ ! isDistractionFree && ! isPreviewMode && <Notices /> }\n\t\t\t\t\t{ shouldShowMediaEditor && (\n\t\t\t\t\t\t<MediaPreview { ...iframeProps } />\n\t\t\t\t\t) }\n\t\t\t\t\t{ shouldShowStylesCanvas && <StylesCanvas /> }\n\t\t\t\t\t{ shouldShowBlockEditor && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isPreviewMode && mode === 'text' && (\n\t\t\t\t\t\t\t\t<TextEditor\n\t\t\t\t\t\t\t\t\t// We should auto-focus the canvas (title) on load.\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\t\t\t\t\t\tautoFocus={ autoFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ! isPreviewMode &&\n\t\t\t\t\t\t\t\t! isLargeViewport &&\n\t\t\t\t\t\t\t\tmode === 'visual' && (\n\t\t\t\t\t\t\t\t\t<BlockToolbar hideDragHandle />\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ( isPreviewMode || mode === 'visual' ) && (\n\t\t\t\t\t\t\t\t<VisualEditor\n\t\t\t\t\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t\t\t\t\t\tdisableIframe={ disableIframe }\n\t\t\t\t\t\t\t\t\t// We should auto-focus the canvas (title) on load.\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\t\t\t\t\t\tautoFocus={ autoFocus }\n\t\t\t\t\t\t\t\t\tiframeProps={ iframeProps }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t<CollaboratorsOverlay\n\t\t\t\t\t\t\t\tpostId={ postId }\n\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t\tfooter={\n\t\t\t\t! isPreviewMode &&\n\t\t\t\t! isDistractionFree &&\n\t\t\t\tisLargeViewport &&\n\t\t\t\tshowBlockBreadcrumbs &&\n\t\t\t\tmode === 'visual' && (\n\t\t\t\t\t<BlockBreadcrumb\n\t\t\t\t\t\trootLabelText={\n\t\t\t\t\t\t\tpostTypeLabel\n\t\t\t\t\t\t\t\t? decodeEntities( postTypeLabel )\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\tactions={\n\t\t\t\t! isPreviewMode\n\t\t\t\t\t? customSavePanel || (\n\t\t\t\t\t\t\t<SavePublishPanels\n\t\t\t\t\t\t\t\tcloseEntitiesSavedStates={\n\t\t\t\t\t\t\t\t\tcloseEntitiesSavedStates\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tisEntitiesSavedStatesOpen={\n\t\t\t\t\t\t\t\t\tentitiesSavedStatesCallback\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tforceIsDirtyPublishPanel={ forceIsDirty }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t/>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,uBAAqD;AACrD,kBAA0B;AAC1B,kBAAmB;AACnB,yBAA0C;AAC1C,0BAA8C;AAC9C,qBAAiC;AACjC,qBAAsC;AACtC,2BAA+B;AAC/B,qBAA8B;AAK9B,mBAAqC;AACrC,yBAAuB;AACvB,wCAAqC;AACrC,oBAAmB;AACnB,8BAA4B;AAC5B,+BAA4B;AAC5B,oCAAiD;AACjD,mCAAqC;AACrC,iCAA8B;AAC9B,yBAAuB;AACvB,2BAAyB;AACzB,2BAAyB;AACzB,mBAA6B;AAoB3B;AAlBF,IAAM,kBAAkB;AAAA;AAAA,EAEvB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B,OAAQ,aAAAA,KAAY,EAAE,iBAAiB;AAAA,MACzD,kBAAkB,OAAQ,aAAAA,KAAY,EAAE,iBAAiB;AAAA,MACzD,mBAAmB,IAAK,QAAQ,iBAAkB;AAAA,MAClD,eAAe,eAAe;AAAA,MAC9B,sBAAsB,IAAK,QAAQ,sBAAuB;AAAA,MAC1D,eAAe,iBAAiB;AAAA,MAChC,YAAY,cAAc;AAAA,MAC1B,eAAe,iBAAiB;AAAA,MAChC,cACC,mBAAmB,MAAM,gBACzB,QAAQ;AAAA,MACT,iBAAiB,iBAAiB;AAAA,IACnC;AAAA,EACD,GAAG,CAAC,CAAE;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { InterfaceSkeleton, ComplementaryArea } from '@wordpress/interface';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { BlockBreadcrumb, BlockToolbar } from '@wordpress/block-editor';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useState, useCallback } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { InlineNotices } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport TemplateValidationNotice from '../template-validation-notice';\nimport Header from '../header';\nimport InserterSidebar from '../inserter-sidebar';\nimport ListViewSidebar from '../list-view-sidebar';\nimport { RevisionsHeader, RevisionsCanvas } from '../post-revisions-preview';\nimport { CollaboratorsOverlay } from '../collaborators-overlay';\nimport { useCollaboratorNotifications } from '../collaborators-presence/use-collaborator-notifications';\nimport SavePublishPanels from '../save-publish-panels';\nimport TextEditor from '../text-editor';\nimport VisualEditor from '../visual-editor';\nimport StylesCanvas from '../styles-canvas';\nimport { MediaPreview } from '../media';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the editor top bar landmark region. */\n\theader: __( 'Editor top bar' ),\n\t/* translators: accessibility text for the editor content landmark region. */\n\tbody: __( 'Editor content' ),\n\t/* translators: accessibility text for the editor settings landmark region. */\n\tsidebar: __( 'Editor settings' ),\n\t/* translators: accessibility text for the editor publish landmark region. */\n\tactions: __( 'Editor publish' ),\n\t/* translators: accessibility text for the editor footer landmark region. */\n\tfooter: __( 'Editor footer' ),\n};\n\nconst Notices = () => (\n\t<InlineNotices\n\t\tpinnedNoticesClassName=\"editor-notices__pinned\"\n\t\tdismissibleNoticesClassName=\"editor-notices__dismissible\"\n\t>\n\t\t<TemplateValidationNotice />\n\t</InlineNotices>\n);\n\nexport default function EditorInterface( {\n\tclassName,\n\tchildren,\n\tforceIsDirty,\n\tcontentRef,\n\tdisableIframe,\n\tautoFocus,\n\tcustomSaveButton,\n\tcustomSavePanel,\n\tforceDisableBlockTools,\n\tiframeProps,\n} ) {\n\tconst {\n\t\tmode,\n\t\tpostId,\n\t\tpostType,\n\t\tisAttachment,\n\t\tisInserterOpened,\n\t\tisListViewOpened,\n\t\tisDistractionFree,\n\t\tisPreviewMode,\n\t\tshowBlockBreadcrumbs,\n\t\tpostTypeLabel,\n\t\tstylesPath,\n\t\tshowStylebook,\n\t\tisRevisionsMode,\n\t} = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst {\n\t\t\tgetEditorSettings,\n\t\t\tgetPostTypeLabel,\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentPostId,\n\t\t} = select( editorStore );\n\t\tconst {\n\t\t\tgetStylesPath,\n\t\t\tgetShowStylebook,\n\t\t\tisRevisionsMode: _isRevisionsMode,\n\t\t} = unlock( select( editorStore ) );\n\t\tconst editorSettings = getEditorSettings();\n\n\t\tlet _mode = select( editorStore ).getEditorMode();\n\t\tif ( ! editorSettings.richEditingEnabled && _mode === 'visual' ) {\n\t\t\t_mode = 'text';\n\t\t}\n\t\tif ( ! editorSettings.codeEditingEnabled && _mode === 'text' ) {\n\t\t\t_mode = 'visual';\n\t\t}\n\n\t\treturn {\n\t\t\tmode: _mode,\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tisInserterOpened: select( editorStore ).isInserterOpened(),\n\t\t\tisListViewOpened: select( editorStore ).isListViewOpened(),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\tisPreviewMode: editorSettings.isPreviewMode,\n\t\t\tshowBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),\n\t\t\tpostTypeLabel: getPostTypeLabel(),\n\t\t\tstylesPath: getStylesPath(),\n\t\t\tshowStylebook: getShowStylebook(),\n\t\t\tisAttachment:\n\t\t\t\tgetCurrentPostType() === 'attachment' &&\n\t\t\t\twindow?.__experimentalMediaEditor,\n\t\t\tisRevisionsMode: _isRevisionsMode(),\n\t\t};\n\t}, [] );\n\t// Runs unconditionally so join/leave/save notifications are dispatched\n\t// regardless of viewport width or whether the header centre area is visible.\n\tuseCollaboratorNotifications( postId, postType );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst secondarySidebarLabel = isListViewOpened\n\t\t? __( 'Document Overview' )\n\t\t: __( 'Block Library' );\n\tconst shouldShowMediaEditor = !! isAttachment;\n\tconst shouldShowStylesCanvas =\n\t\t! isAttachment &&\n\t\t( showStylebook || stylesPath?.startsWith( '/revisions' ) );\n\tconst shouldShowBlockEditor =\n\t\t! shouldShowMediaEditor && ! shouldShowStylesCanvas;\n\n\t// Local state for save panel.\n\t// Note 'truthy' callback implies an open panel.\n\tconst [ entitiesSavedStatesCallback, setEntitiesSavedStatesCallback ] =\n\t\tuseState( false );\n\tconst closeEntitiesSavedStates = useCallback(\n\t\t( arg ) => {\n\t\t\tif ( typeof entitiesSavedStatesCallback === 'function' ) {\n\t\t\t\tentitiesSavedStatesCallback( arg );\n\t\t\t}\n\t\t\tsetEntitiesSavedStatesCallback( false );\n\t\t},\n\t\t[ entitiesSavedStatesCallback ]\n\t);\n\n\t// Local state for diff toggle in revisions mode.\n\tconst [ showDiff, setShowDiff ] = useState( true );\n\n\t// When in revisions mode, render the revisions interface.\n\tif ( isRevisionsMode ) {\n\t\treturn (\n\t\t\t<InterfaceSkeleton\n\t\t\t\tclassName={ clsx( 'editor-editor-interface', className ) }\n\t\t\t\tlabels={ interfaceLabels }\n\t\t\t\theader={\n\t\t\t\t\t<RevisionsHeader\n\t\t\t\t\t\tshowDiff={ showDiff }\n\t\t\t\t\t\tonToggleDiff={ () => setShowDiff( ! showDiff ) }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\tcontent={ <RevisionsCanvas showDiff={ showDiff } /> }\n\t\t\t\tsidebar={ <ComplementaryArea.Slot scope=\"core\" /> }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tisDistractionFree={ isDistractionFree }\n\t\t\tclassName={ clsx( 'editor-editor-interface', className, {\n\t\t\t\t'is-entity-save-view-open': !! entitiesSavedStatesCallback,\n\t\t\t\t'is-distraction-free': isDistractionFree && ! isPreviewMode,\n\t\t\t} ) }\n\t\t\tlabels={ {\n\t\t\t\t...interfaceLabels,\n\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t} }\n\t\t\theader={\n\t\t\t\t! isPreviewMode && (\n\t\t\t\t\t<Header\n\t\t\t\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcustomSaveButton={ customSaveButton }\n\t\t\t\t\t\tforceDisableBlockTools={ forceDisableBlockTools }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\teditorNotices={ <Notices /> }\n\t\t\tsecondarySidebar={\n\t\t\t\t! isAttachment &&\n\t\t\t\t! isPreviewMode &&\n\t\t\t\tmode === 'visual' &&\n\t\t\t\t( ( isInserterOpened && <InserterSidebar /> ) ||\n\t\t\t\t\t( isListViewOpened && <ListViewSidebar /> ) )\n\t\t\t}\n\t\t\tsidebar={\n\t\t\t\t! isPreviewMode &&\n\t\t\t\t! isDistractionFree && <ComplementaryArea.Slot scope=\"core\" />\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t{ ! isDistractionFree && ! isPreviewMode && <Notices /> }\n\t\t\t\t\t{ shouldShowMediaEditor && (\n\t\t\t\t\t\t<MediaPreview { ...iframeProps } />\n\t\t\t\t\t) }\n\t\t\t\t\t{ shouldShowStylesCanvas && <StylesCanvas /> }\n\t\t\t\t\t{ shouldShowBlockEditor && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isPreviewMode && mode === 'text' && (\n\t\t\t\t\t\t\t\t<TextEditor\n\t\t\t\t\t\t\t\t\t// We should auto-focus the canvas (title) on load.\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\t\t\t\t\t\tautoFocus={ autoFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ! isPreviewMode &&\n\t\t\t\t\t\t\t\t! isLargeViewport &&\n\t\t\t\t\t\t\t\tmode === 'visual' && (\n\t\t\t\t\t\t\t\t\t<BlockToolbar hideDragHandle />\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ( isPreviewMode || mode === 'visual' ) && (\n\t\t\t\t\t\t\t\t<VisualEditor\n\t\t\t\t\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t\t\t\t\t\tdisableIframe={ disableIframe }\n\t\t\t\t\t\t\t\t\t// We should auto-focus the canvas (title) on load.\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\t\t\t\t\t\tautoFocus={ autoFocus }\n\t\t\t\t\t\t\t\t\tiframeProps={ iframeProps }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t<CollaboratorsOverlay\n\t\t\t\t\t\t\t\tpostId={ postId }\n\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t\tfooter={\n\t\t\t\t! isPreviewMode &&\n\t\t\t\t! isDistractionFree &&\n\t\t\t\tisLargeViewport &&\n\t\t\t\tshowBlockBreadcrumbs &&\n\t\t\t\tmode === 'visual' && (\n\t\t\t\t\t<BlockBreadcrumb\n\t\t\t\t\t\trootLabelText={\n\t\t\t\t\t\t\tpostTypeLabel\n\t\t\t\t\t\t\t\t? decodeEntities( postTypeLabel )\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\tactions={\n\t\t\t\t! isPreviewMode\n\t\t\t\t\t? customSavePanel || (\n\t\t\t\t\t\t\t<SavePublishPanels\n\t\t\t\t\t\t\t\tcloseEntitiesSavedStates={\n\t\t\t\t\t\t\t\t\tcloseEntitiesSavedStates\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tisEntitiesSavedStatesOpen={\n\t\t\t\t\t\t\t\t\tentitiesSavedStatesCallback\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tforceIsDirtyPublishPanel={ forceIsDirty }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,uBAAqD;AACrD,kBAA0B;AAC1B,kBAAmB;AACnB,yBAA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C,mBAAAC;AAAA,YAAA;AAAA,cAGA;AAAA;AAAA,UACD;AAAA,UAEC,CAAE,iBACH,CAAE,mBACF,SAAS,YACR,4CAAC,oCAAa,gBAAc,MAAC;AAAA,WAE3B,iBAAiB,SAAS,aAC7B;AAAA,YAAC,qBAAAC;AAAA,YAAA;AAAA,cACA;AAAA,cACA;AAAA,cAGA;AAAA,cACA;AAAA;AAAA,UACD;AAAA,UAEC;AAAA,UACF;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD;AAAA,WACD;AAAA,SAEF;AAAA,MAED,QACC,CAAE,iBACF,CAAE,qBACF,mBACA,wBACA,SAAS,YACR;AAAA,QAAC;AAAA;AAAA,UACA,eACC,oBACG,qCAAgB,aAAc,IAC9B;AAAA;AAAA,MAEL;AAAA,MAGF,SACC,CAAE,gBACC,mBACA;AAAA,QAAC,2BAAAC;AAAA,QAAA;AAAA,UACA;AAAA,UAGA,2BACC;AAAA,UAED;AAAA,UAGA,0BAA2B;AAAA;AAAA,MAC5B,IAEA;AAAA;AAAA,EAEL;AAEF;",
|
|
6
6
|
"names": ["TemplateValidationNotice", "preferencesStore", "editorStore", "clsx", "Header", "InserterSidebar", "ListViewSidebar", "StylesCanvas", "TextEditor", "VisualEditor", "SavePublishPanels"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/page-attributes/parent.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tDropdown,\n\tComboboxControl,\n\tExternalLink,\n} from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport {\n\tcreateInterpolateElement,\n\tuseState,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\n/**\n * Renders the Page Attributes Parent component. A dropdown menu in an editor interface\n * for selecting the parent page of a given page.\n *\n * @return {React.ReactNode} The component to be rendered. Return null if post type is not hierarchical.\n */\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( false );\n\tconst {\n\t\tisHierarchical,\n\t\tparentPostId,\n\t\tparentPostTitle,\n\t\tpageItems,\n\t\tisLoading,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetPostType,\n\t\t\t\tgetEntityRecords,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tisResolving,\n\t\t\t} = select( coreStore );\n\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst postIsHierarchical = pType?.hierarchical ?? false;\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t};\n\n\t\t\t// Perform a search by relevance when the field is changed.\n\t\t\tif ( !! fieldValue ) {\n\t\t\t\tquery.search = fieldValue;\n\t\t\t\tquery.orderby = 'relevance';\n\t\t\t}\n\n\t\t\tconst parentPost = pageId\n\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t: null;\n\n\t\t\treturn {\n\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\tparentPostId: pageId,\n\t\t\t\tparentPostTitle: parentPost ? getTitle( parentPost ) : '',\n\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t: null,\n\t\t\t\tisLoading: postIsHierarchical\n\t\t\t\t\t? isResolving( 'getEntityRecords', [\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\t\tquery,\n\t\t\t\t\t ] )\n\t\t\t\t\t: false,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue ]\n\t);\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'\u2014 '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find(\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue, parentPostTitle, parentPostId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"editor-page-attributes__parent\"\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\thelp={ __( 'Choose a parent page.' ) }\n\t\t\tvalue={ parentPostId }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleChange }\n\t\t\thideLabelFromVision\n\t\t\tisLoading={ isLoading }\n\t\t/>\n\t);\n}\n\nfunction PostParentToggle( { isOpen, onClick } ) {\n\tconst parentPost = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst parentPostId = getEditedPostAttribute( 'parent' );\n\t\tif ( ! parentPostId ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\treturn getEntityRecord( 'postType', postTypeSlug, parentPostId );\n\t}, [] );\n\tconst parentTitle = useMemo(\n\t\t() => ( ! parentPost ? __( 'None' ) : getTitle( parentPost ) ),\n\t\t[ parentPost ]\n\t);\n\treturn (\n\t\t<Button\n\t\t\tsize=\"compact\"\n\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,4BAA0B;AAK1B,kBAA4B;AAC5B,wBAKO;AACP,qBAAyB;AACzB,qBAIO;AACP,kBAAuC;AACvC,2BAA+B;AAC/B,uBAAmC;AACnC,0BAA+E;AAC/E,iBAAoC;AAKpC,4BAAyB;AACzB,mBAA+B;AAC/B,mBAAqC;AAmKnC;AAjKF,SAAS,SAAU,MAAO;AACzB,SAAO,MAAM,OAAO,eACjB,qCAAgB,KAAK,MAAM,QAAS,IACpC,IAAK,KAAK,EAAG,SAAM,gBAAI,UAAW,CAAE;AACxC;AAEO,IAAM,kBAAkB,CAAE,MAAM,gBAAiB;AACvD,QAAM,qBAAiB,sBAAAA,SAAe,QAAQ,EAAG,EAAE,YAAY;AAC/D,QAAM,uBAAmB,sBAAAA,SAAe,eAAe,EAAG,EAAE,YAAY;AACxE,MAAK,mBAAmB,kBAAmB;AAC1C,WAAO;AAAA,EACR;AAEA,MAAK,eAAe,WAAY,gBAAiB,GAAI;AACpD,WAAO,eAAe;AAAA,EACvB;AAEA,SAAO;AACR;AAQO,SAAS,uBAAuB;AACtC,QAAM,EAAE,SAAS,QAAI,yBA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,gBAAI,QAAS;AAAA,MACrB,UAAO,gBAAI,uBAAwB;AAAA,MACnC,OAAQ;AAAA,MACR,SAAU;AAAA,MACV,yBAAsB,yBAAU,eAAe,GAAI;AAAA,MACnD,UAAW;AAAA,MACX,qBAAmB;AAAA,MACnB;AAAA;AAAA,EACD;AAEF;AAEA,SAAS,iBAAkB,EAAE,QAAQ,QAAQ,GAAI;AAChD,QAAM,iBAAa,uBAAW,CAAE,WAAY;AAC3C,UAAM,EAAE,uBAAuB,IAAI,OAAQ,aAAAF,KAAY;AACvD,UAAM,eAAe,uBAAwB,QAAS;AACtD,QAAK,CAAE,cAAe;AACrB,aAAO;AAAA,IACR;AACA,UAAM,EAAE,gBAAgB,IAAI,OAAQ,iBAAAC,KAAU;AAC9C,UAAM,eAAe,uBAAwB,MAAO;AACpD,WAAO,gBAAiB,YAAY,cAAc,YAAa;AAAA,EAChE,GAAG,CAAC,CAAE;AACN,QAAM,kBAAc;AAAA,IACnB,MAAQ,CAAE,iBAAa,gBAAI,MAAO,IAAI,SAAU,UAAW;AAAA,IAC3D,CAAE,UAAW;AAAA,EACd;AACA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAK;AAAA,MACL,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tDropdown,\n\tComboboxControl,\n\tExternalLink,\n} from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport {\n\tcreateInterpolateElement,\n\tuseState,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\n/**\n * Renders the Page Attributes Parent component. A dropdown menu in an editor interface\n * for selecting the parent page of a given page.\n *\n * @return {React.ReactNode} The component to be rendered. Return null if post type is not hierarchical.\n */\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( false );\n\tconst {\n\t\tisHierarchical,\n\t\tparentPostId,\n\t\tparentPostTitle,\n\t\tpageItems,\n\t\tisLoading,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetPostType,\n\t\t\t\tgetEntityRecords,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tisResolving,\n\t\t\t} = select( coreStore );\n\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst postIsHierarchical = pType?.hierarchical ?? false;\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t};\n\n\t\t\t// Perform a search by relevance when the field is changed.\n\t\t\tif ( !! fieldValue ) {\n\t\t\t\tquery.search = fieldValue;\n\t\t\t\tquery.orderby = 'relevance';\n\t\t\t}\n\n\t\t\tconst parentPost = pageId\n\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t: null;\n\n\t\t\treturn {\n\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\tparentPostId: pageId,\n\t\t\t\tparentPostTitle: parentPost ? getTitle( parentPost ) : '',\n\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t: null,\n\t\t\t\tisLoading: postIsHierarchical\n\t\t\t\t\t? isResolving( 'getEntityRecords', [\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\t\tquery,\n\t\t\t\t\t ] )\n\t\t\t\t\t: false,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue ]\n\t);\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'\u2014 '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find(\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue, parentPostTitle, parentPostId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"editor-page-attributes__parent\"\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\thelp={ __( 'Choose a parent page.' ) }\n\t\t\tvalue={ parentPostId }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleChange }\n\t\t\thideLabelFromVision\n\t\t\tisLoading={ isLoading }\n\t\t/>\n\t);\n}\n\nfunction PostParentToggle( { isOpen, onClick } ) {\n\tconst parentPost = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst parentPostId = getEditedPostAttribute( 'parent' );\n\t\tif ( ! parentPostId ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\treturn getEntityRecord( 'postType', postTypeSlug, parentPostId );\n\t}, [] );\n\tconst parentTitle = useMemo(\n\t\t() => ( ! parentPost ? __( 'None' ) : getTitle( parentPost ) ),\n\t\t[ parentPost ]\n\t);\n\treturn (\n\t\t<Button\n\t\t\tsize=\"compact\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={\n\t\t\t\t// translators: %s: Current post parent.\n\t\t\t\tsprintf( __( 'Change parent: %s' ), parentTitle )\n\t\t\t}\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ parentTitle }\n\t\t</Button>\n\t);\n}\n\nexport function ParentRow() {\n\tconst homeUrl = useSelect( ( select ) => {\n\t\t// Site index.\n\t\treturn select( coreStore ).getEntityRecord( 'root', '__unstableBase' )\n\t\t\t?.home;\n\t}, [] );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\treturn (\n\t\t<PostPanelRow label={ __( 'Parent' ) } ref={ setPopoverAnchor }>\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tclassName=\"editor-post-parent__panel-dropdown\"\n\t\t\t\tcontentClassName=\"editor-post-parent__panel-dialog\"\n\t\t\t\tfocusOnMount\n\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t<PostParentToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<div className=\"editor-post-parent\">\n\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\ttitle={ __( 'Parent' ) }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: The home URL of the WordPress installation without the scheme. */\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Child pages inherit characteristics from their parent, such as URL structure. For instance, if \"Pricing\" is a child of \"Services\", its URL would be %s<wbr />/services<wbr />/pricing.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tfilterURLForDisplay( homeUrl ).replace(\n\t\t\t\t\t\t\t\t\t\t/([/.])/g,\n\t\t\t\t\t\t\t\t\t\t'<wbr />$1'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\twbr: <wbr />,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\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AE,EAAE,QAAQ,SAAS,MACnC,4CAAC,oBAAiB,QAAkB,SAAU,UAAW;AAAA,MAE1D,eAAgB,CAAE,EAAE,QAAQ,MAC3B,6CAAC,SAAI,WAAU,sBACd;AAAA;AAAA,UAAC,oBAAAC;AAAA,UAAA;AAAA,YACA,WAAQ,gBAAI,QAAS;AAAA,YACrB;AAAA;AAAA,QACD;AAAA,QACA,6CAAC,SACE;AAAA;AAAA,gBACD;AAAA;AAAA,kBAEC;AAAA,gBACC;AAAA,cACD;AAAA,kBACA,gCAAqB,OAAQ,EAAE;AAAA,gBAC9B;AAAA,gBACA;AAAA,cACD;AAAA,YACD;AAAA,YACA;AAAA,cACC,KAAK,4CAAC,SAAI;AAAA,YACX;AAAA,UACD;AAAA,UACA,4CAAC,OACE;AAAA,gBACD;AAAA,cACC;AAAA,YACD;AAAA,YACA;AAAA,cACC,GACC;AAAA,gBAAC;AAAA;AAAA,kBACA,UAAO;AAAA,oBACN;AAAA,kBACD;AAAA;AAAA,cACD;AAAA,YAEF;AAAA,UACD,GACD;AAAA,WACD;AAAA,QACA,4CAAC,wBAAqB;AAAA,SACvB;AAAA;AAAA,EAEF,GACD;AAEF;AAEA,IAAO,iBAAQ;",
|
|
6
6
|
"names": ["removeAccents", "editorStore", "coreStore", "tree", "PostPanelRow", "InspectorPopoverHeader"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-author/panel.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button, Dropdown } from '@wordpress/components';\nimport { useState, useMemo } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostAuthorCheck from './check';\nimport PostAuthorForm from './index';\nimport PostPanelRow from '../post-panel-row';\nimport { BASE_QUERY } from './constants';\nimport { store as editorStore } from '../../store';\n\nfunction PostAuthorToggle( { isOpen, onClick } ) {\n\tconst { postAuthor } = useSelect( ( select ) => {\n\t\tconst id = select( editorStore ).getEditedPostAttribute( 'author' );\n\t\treturn {\n\t\t\tpostAuthor: select( coreStore ).getUser( id, BASE_QUERY ),\n\t\t};\n\t}, [] );\n\tconst authorName =\n\t\tdecodeEntities( postAuthor?.name ) || __( '(No author)' );\n\treturn (\n\t\t<Button\n\t\t\tsize=\"compact\"\n\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,wBAAiC;AACjC,qBAAkC;AAClC,2BAA+B;AAC/B,0BAA+E;AAC/E,kBAA0B;AAC1B,uBAAmC;AAKnC,mBAA4B;AAC5B,mBAA2B;AAC3B,4BAAyB;AACzB,uBAA2B;AAC3B,mBAAqC;AAYnC;AAVF,SAAS,iBAAkB,EAAE,QAAQ,QAAQ,GAAI;AAChD,QAAM,EAAE,WAAW,QAAI,uBAAW,CAAE,WAAY;AAC/C,UAAM,KAAK,OAAQ,aAAAA,KAAY,EAAE,uBAAwB,QAAS;AAClE,WAAO;AAAA,MACN,YAAY,OAAQ,iBAAAC,KAAU,EAAE,QAAS,IAAI,2BAAW;AAAA,IACzD;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,iBACL,qCAAgB,YAAY,IAAK,SAAK,gBAAI,aAAc;AACzD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAK;AAAA,MACL,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button, Dropdown } from '@wordpress/components';\nimport { useState, useMemo } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostAuthorCheck from './check';\nimport PostAuthorForm from './index';\nimport PostPanelRow from '../post-panel-row';\nimport { BASE_QUERY } from './constants';\nimport { store as editorStore } from '../../store';\n\nfunction PostAuthorToggle( { isOpen, onClick } ) {\n\tconst { postAuthor } = useSelect( ( select ) => {\n\t\tconst id = select( editorStore ).getEditedPostAttribute( 'author' );\n\t\treturn {\n\t\t\tpostAuthor: select( coreStore ).getUser( id, BASE_QUERY ),\n\t\t};\n\t}, [] );\n\tconst authorName =\n\t\tdecodeEntities( postAuthor?.name ) || __( '(No author)' );\n\treturn (\n\t\t<Button\n\t\t\tsize=\"compact\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={\n\t\t\t\t// translators: %s: Author name.\n\t\t\t\tsprintf( __( 'Change author: %s' ), authorName )\n\t\t\t}\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ authorName }\n\t\t</Button>\n\t);\n}\n\n/**\n * Renders the Post Author Panel component.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport function PostAuthor() {\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\treturn (\n\t\t<PostAuthorCheck>\n\t\t\t<PostPanelRow label={ __( 'Author' ) } ref={ setPopoverAnchor }>\n\t\t\t\t<Dropdown\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tcontentClassName=\"editor-post-author__panel-dialog\"\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<PostAuthorToggle\n\t\t\t\t\t\t\tisOpen={ isOpen }\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<div className=\"editor-post-author\">\n\t\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\t\ttitle={ __( 'Author' ) }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<PostAuthorForm onClose={ onClose } />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</PostPanelRow>\n\t\t</PostAuthorCheck>\n\t);\n}\n\nexport default PostAuthor;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,wBAAiC;AACjC,qBAAkC;AAClC,2BAA+B;AAC/B,0BAA+E;AAC/E,kBAA0B;AAC1B,uBAAmC;AAKnC,mBAA4B;AAC5B,mBAA2B;AAC3B,4BAAyB;AACzB,uBAA2B;AAC3B,mBAAqC;AAYnC;AAVF,SAAS,iBAAkB,EAAE,QAAQ,QAAQ,GAAI;AAChD,QAAM,EAAE,WAAW,QAAI,uBAAW,CAAE,WAAY;AAC/C,UAAM,KAAK,OAAQ,aAAAA,KAAY,EAAE,uBAAwB,QAAS;AAClE,WAAO;AAAA,MACN,YAAY,OAAQ,iBAAAC,KAAU,EAAE,QAAS,IAAI,2BAAW;AAAA,IACzD;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,iBACL,qCAAgB,YAAY,IAAK,SAAK,gBAAI,aA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