@wordpress/editor 14.33.3-next.36001005c.0 → 14.34.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/bindings/post-data.js +10 -17
- package/build/bindings/post-data.js.map +2 -2
- package/build/bindings/post-meta.js +7 -14
- package/build/bindings/post-meta.js.map +2 -2
- package/build/bindings/term-data.js +6 -16
- package/build/bindings/term-data.js.map +2 -2
- package/build/components/collab-sidebar/add-comment.js +26 -3
- package/build/components/collab-sidebar/add-comment.js.map +3 -3
- package/build/components/collab-sidebar/comment-author-info.js +26 -14
- package/build/components/collab-sidebar/comment-author-info.js.map +2 -2
- package/build/components/collab-sidebar/comment-indicator-toolbar.js +6 -22
- package/build/components/collab-sidebar/comment-indicator-toolbar.js.map +3 -3
- package/build/components/collab-sidebar/comments.js +105 -28
- package/build/components/collab-sidebar/comments.js.map +3 -3
- package/build/components/collab-sidebar/hooks.js +3 -4
- package/build/components/collab-sidebar/hooks.js.map +2 -2
- package/build/components/collab-sidebar/index.js +42 -57
- package/build/components/collab-sidebar/index.js.map +3 -3
- package/build/components/document-bar/index.js +16 -3
- package/build/components/document-bar/index.js.map +2 -2
- package/build/components/editor/index.js +25 -4
- package/build/components/editor/index.js.map +3 -3
- package/build/components/editor-interface/index.js +15 -10
- package/build/components/editor-interface/index.js.map +3 -3
- package/build/components/entities-saved-states/entity-type-list.js +19 -15
- package/build/components/entities-saved-states/entity-type-list.js.map +3 -3
- package/build/components/global-styles/block-link.js +70 -0
- package/build/components/global-styles/block-link.js.map +7 -0
- package/build/components/global-styles/header.js +54 -0
- package/build/components/global-styles/header.js.map +7 -0
- package/build/components/global-styles/hooks.js +176 -0
- package/build/components/global-styles/hooks.js.map +7 -0
- package/build/components/global-styles/index.js +138 -0
- package/build/components/global-styles/index.js.map +7 -0
- package/build/components/global-styles/menu.js +95 -0
- package/build/components/global-styles/menu.js.map +7 -0
- package/build/components/global-styles-provider/index.js +3 -49
- package/build/components/global-styles-provider/index.js.map +3 -3
- package/build/components/global-styles-renderer/index.js +55 -0
- package/build/components/global-styles-renderer/index.js.map +7 -0
- package/build/components/global-styles-sidebar/default-sidebar.js +66 -0
- package/build/components/global-styles-sidebar/default-sidebar.js.map +7 -0
- package/build/components/global-styles-sidebar/index.js +182 -0
- package/build/components/global-styles-sidebar/index.js.map +7 -0
- package/build/components/global-styles-sidebar/welcome-guide-image.js +37 -0
- package/build/components/global-styles-sidebar/welcome-guide-image.js.map +7 -0
- package/build/components/global-styles-sidebar/welcome-guide.js +143 -0
- package/build/components/global-styles-sidebar/welcome-guide.js.map +7 -0
- package/build/components/header/index.js +12 -12
- package/build/components/header/index.js.map +3 -3
- package/build/components/post-featured-image/index.js +32 -1
- package/build/components/post-featured-image/index.js.map +3 -3
- package/build/components/post-template/hooks.js +7 -38
- package/build/components/post-template/hooks.js.map +2 -2
- package/build/components/provider/index.js +1 -1
- package/build/components/provider/index.js.map +2 -2
- package/build/components/style-book/categories.js +86 -0
- package/build/components/style-book/categories.js.map +7 -0
- package/build/components/style-book/color-examples.js +64 -0
- package/build/components/style-book/color-examples.js.map +7 -0
- package/build/components/style-book/constants.js +319 -0
- package/build/components/style-book/constants.js.map +7 -0
- package/build/components/style-book/duotone-examples.js +68 -0
- package/build/components/style-book/duotone-examples.js.map +7 -0
- package/build/components/style-book/examples.js +237 -0
- package/build/components/style-book/examples.js.map +7 -0
- package/build/components/style-book/index.js +627 -0
- package/build/components/style-book/index.js.map +7 -0
- package/build/components/style-book/types.js +17 -0
- package/build/components/style-book/types.js.map +7 -0
- package/build/components/styles-canvas/index.js +138 -0
- package/build/components/styles-canvas/index.js.map +7 -0
- package/build/components/styles-canvas/revisions.js +121 -0
- package/build/components/styles-canvas/revisions.js.map +7 -0
- package/build/components/styles-canvas/style-book.js +68 -0
- package/build/components/styles-canvas/style-book.js.map +7 -0
- package/build/components/visual-editor/index.js +4 -3
- package/build/components/visual-editor/index.js.map +2 -2
- package/build/dataviews/fields/content-preview/content-preview-view.js.map +2 -2
- package/build/hooks/index.js +1 -0
- package/build/hooks/index.js.map +2 -2
- package/build/hooks/media-upload.js +15 -4
- package/build/hooks/media-upload.js.map +3 -3
- package/build/hooks/push-changes-to-global-styles/index.js +322 -0
- package/build/hooks/push-changes-to-global-styles/index.js.map +7 -0
- package/build/hooks/use-global-styles-output.js +74 -0
- package/build/hooks/use-global-styles-output.js.map +7 -0
- package/build/private-apis.js +10 -5
- package/build/private-apis.js.map +3 -3
- package/build/store/actions.js +1 -1
- package/build/store/actions.js.map +2 -2
- package/build/store/private-actions.js +23 -0
- package/build/store/private-actions.js.map +2 -2
- package/build/store/private-selectors.js +10 -0
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/reducer.js +24 -0
- package/build/store/reducer.js.map +2 -2
- package/build/{components/editor-interface/content-slot-fill.js → utils/set-nested-value.js} +24 -10
- package/build/utils/set-nested-value.js.map +7 -0
- package/build-module/bindings/post-data.js +10 -17
- package/build-module/bindings/post-data.js.map +2 -2
- package/build-module/bindings/post-meta.js +7 -14
- package/build-module/bindings/post-meta.js.map +2 -2
- package/build-module/bindings/term-data.js +6 -16
- package/build-module/bindings/term-data.js.map +2 -2
- package/build-module/components/collab-sidebar/add-comment.js +27 -4
- package/build-module/components/collab-sidebar/add-comment.js.map +2 -2
- package/build-module/components/collab-sidebar/comment-author-info.js +26 -14
- package/build-module/components/collab-sidebar/comment-author-info.js.map +2 -2
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.js +6 -12
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.js.map +2 -2
- package/build-module/components/collab-sidebar/comments.js +114 -31
- package/build-module/components/collab-sidebar/comments.js.map +2 -2
- package/build-module/components/collab-sidebar/hooks.js +3 -4
- package/build-module/components/collab-sidebar/hooks.js.map +2 -2
- package/build-module/components/collab-sidebar/index.js +42 -57
- package/build-module/components/collab-sidebar/index.js.map +2 -2
- package/build-module/components/document-bar/index.js +16 -3
- package/build-module/components/document-bar/index.js.map +2 -2
- package/build-module/components/editor/index.js +25 -4
- package/build-module/components/editor/index.js.map +2 -2
- package/build-module/components/editor-interface/index.js +15 -10
- package/build-module/components/editor-interface/index.js.map +2 -2
- package/build-module/components/entities-saved-states/entity-type-list.js +18 -14
- package/build-module/components/entities-saved-states/entity-type-list.js.map +2 -2
- package/build-module/components/global-styles/block-link.js +46 -0
- package/build-module/components/global-styles/block-link.js.map +7 -0
- package/build-module/components/global-styles/header.js +41 -0
- package/build-module/components/global-styles/header.js.map +7 -0
- package/build-module/components/global-styles/hooks.js +154 -0
- package/build-module/components/global-styles/hooks.js.map +7 -0
- package/build-module/components/global-styles/index.js +112 -0
- package/build-module/components/global-styles/index.js.map +7 -0
- package/build-module/components/global-styles/menu.js +71 -0
- package/build-module/components/global-styles/menu.js.map +7 -0
- package/build-module/components/global-styles-provider/index.js +3 -37
- package/build-module/components/global-styles-provider/index.js.map +2 -2
- package/build-module/components/global-styles-renderer/index.js +31 -0
- package/build-module/components/global-styles-renderer/index.js.map +7 -0
- package/build-module/components/global-styles-sidebar/default-sidebar.js +49 -0
- package/build-module/components/global-styles-sidebar/default-sidebar.js.map +7 -0
- package/build-module/components/global-styles-sidebar/index.js +152 -0
- package/build-module/components/global-styles-sidebar/index.js.map +7 -0
- package/build-module/components/global-styles-sidebar/welcome-guide-image.js +17 -0
- package/build-module/components/global-styles-sidebar/welcome-guide-image.js.map +7 -0
- package/build-module/components/global-styles-sidebar/welcome-guide.js +113 -0
- package/build-module/components/global-styles-sidebar/welcome-guide.js.map +7 -0
- package/build-module/components/header/index.js +12 -12
- package/build-module/components/header/index.js.map +2 -2
- package/build-module/components/post-featured-image/index.js +35 -3
- package/build-module/components/post-featured-image/index.js.map +2 -2
- package/build-module/components/post-template/hooks.js +7 -38
- package/build-module/components/post-template/hooks.js.map +2 -2
- package/build-module/components/provider/index.js +1 -1
- package/build-module/components/provider/index.js.map +2 -2
- package/build-module/components/style-book/categories.js +64 -0
- package/build-module/components/style-book/categories.js.map +7 -0
- package/build-module/components/style-book/color-examples.js +37 -0
- package/build-module/components/style-book/color-examples.js.map +7 -0
- package/build-module/components/style-book/constants.js +290 -0
- package/build-module/components/style-book/constants.js.map +7 -0
- package/build-module/components/style-book/duotone-examples.js +48 -0
- package/build-module/components/style-book/duotone-examples.js.map +7 -0
- package/build-module/components/style-book/examples.js +208 -0
- package/build-module/components/style-book/examples.js.map +7 -0
- package/build-module/components/style-book/index.js +618 -0
- package/build-module/components/style-book/index.js.map +7 -0
- package/build-module/components/style-book/types.js +1 -0
- package/build-module/components/style-book/types.js.map +7 -0
- package/build-module/components/styles-canvas/index.js +104 -0
- package/build-module/components/styles-canvas/index.js.map +7 -0
- package/build-module/components/styles-canvas/revisions.js +107 -0
- package/build-module/components/styles-canvas/revisions.js.map +7 -0
- package/build-module/components/styles-canvas/style-book.js +38 -0
- package/build-module/components/styles-canvas/style-book.js.map +7 -0
- package/build-module/components/visual-editor/index.js +4 -3
- package/build-module/components/visual-editor/index.js.map +2 -2
- package/build-module/dataviews/fields/content-preview/content-preview-view.js.map +2 -2
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +2 -2
- package/build-module/hooks/media-upload.js +19 -5
- package/build-module/hooks/media-upload.js.map +2 -2
- package/build-module/hooks/push-changes-to-global-styles/index.js +309 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +7 -0
- package/build-module/hooks/use-global-styles-output.js +49 -0
- package/build-module/hooks/use-global-styles-output.js.map +7 -0
- package/build-module/private-apis.js +10 -8
- package/build-module/private-apis.js.map +2 -2
- package/build-module/store/actions.js +1 -1
- package/build-module/store/actions.js.map +2 -2
- package/build-module/store/private-actions.js +20 -0
- package/build-module/store/private-actions.js.map +2 -2
- package/build-module/store/private-selectors.js +8 -0
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/reducer.js +22 -0
- package/build-module/store/reducer.js.map +2 -2
- package/build-module/utils/set-nested-value.js +23 -0
- package/build-module/utils/set-nested-value.js.map +7 -0
- package/build-style/style-rtl.css +3011 -16
- package/build-style/style.css +3012 -16
- package/build-types/bindings/post-data.d.ts +6 -16
- package/build-types/bindings/post-meta.d.ts +6 -13
- package/build-types/bindings/term-data.d.ts +6 -16
- package/build-types/components/collab-sidebar/add-comment.d.ts +6 -1
- package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-author-info.d.ts +5 -16
- package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +1 -2
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comments.d.ts +12 -26
- package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/hooks.d.ts +0 -1
- package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/index.d.ts +1 -4
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts +2 -2
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- package/build-types/components/editor/index.d.ts.map +1 -1
- package/build-types/components/editor-interface/index.d.ts +1 -3
- package/build-types/components/editor-interface/index.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/entity-type-list.d.ts.map +1 -1
- package/build-types/components/global-styles/block-link.d.ts +12 -0
- package/build-types/components/global-styles/block-link.d.ts.map +1 -0
- package/build-types/components/global-styles/header.d.ts +7 -0
- package/build-types/components/global-styles/header.d.ts.map +1 -0
- package/build-types/components/global-styles/hooks.d.ts +24 -0
- package/build-types/components/global-styles/hooks.d.ts.map +1 -0
- package/build-types/components/global-styles/index.d.ts +6 -0
- package/build-types/components/global-styles/index.d.ts.map +1 -0
- package/build-types/components/global-styles/menu.d.ts +13 -0
- package/build-types/components/global-styles/menu.d.ts.map +1 -0
- package/build-types/components/global-styles-provider/index.d.ts +1 -5
- package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
- package/build-types/components/global-styles-renderer/index.d.ts +4 -0
- package/build-types/components/global-styles-renderer/index.d.ts.map +1 -0
- package/build-types/components/global-styles-sidebar/default-sidebar.d.ts +13 -0
- package/build-types/components/global-styles-sidebar/default-sidebar.d.ts.map +1 -0
- package/build-types/components/global-styles-sidebar/index.d.ts +2 -0
- package/build-types/components/global-styles-sidebar/index.d.ts.map +1 -0
- package/build-types/components/global-styles-sidebar/welcome-guide-image.d.ts +5 -0
- package/build-types/components/global-styles-sidebar/welcome-guide-image.d.ts.map +1 -0
- package/build-types/components/global-styles-sidebar/welcome-guide.d.ts +2 -0
- package/build-types/components/global-styles-sidebar/welcome-guide.d.ts.map +1 -0
- package/build-types/components/header/index.d.ts +1 -3
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/post-template/hooks.d.ts +1 -1
- package/build-types/components/post-template/hooks.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/style-book/categories.d.ts +18 -0
- package/build-types/components/style-book/categories.d.ts.map +1 -0
- package/build-types/components/style-book/color-examples.d.ts +7 -0
- package/build-types/components/style-book/color-examples.d.ts.map +1 -0
- package/build-types/components/style-book/constants.d.ts +11 -0
- package/build-types/components/style-book/constants.d.ts.map +1 -0
- package/build-types/components/style-book/duotone-examples.d.ts +9 -0
- package/build-types/components/style-book/duotone-examples.d.ts.map +1 -0
- package/build-types/components/style-book/examples.d.ts +12 -0
- package/build-types/components/style-book/examples.d.ts.map +1 -0
- package/build-types/components/style-book/index.d.ts +31 -0
- package/build-types/components/style-book/index.d.ts.map +1 -0
- package/build-types/components/style-book/types.d.ts +72 -0
- package/build-types/components/style-book/types.d.ts.map +1 -0
- package/build-types/components/styles-canvas/index.d.ts +16 -0
- package/build-types/components/styles-canvas/index.d.ts.map +1 -0
- package/build-types/components/styles-canvas/revisions.d.ts +5 -0
- package/build-types/components/styles-canvas/revisions.d.ts.map +1 -0
- package/build-types/components/styles-canvas/style-book.d.ts +6 -0
- package/build-types/components/styles-canvas/style-book.d.ts.map +1 -0
- package/build-types/components/visual-editor/index.d.ts +1 -2
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/dataviews/fields/content-preview/content-preview-view.d.ts.map +1 -1
- package/build-types/hooks/push-changes-to-global-styles/index.d.ts +2 -0
- package/build-types/hooks/push-changes-to-global-styles/index.d.ts.map +1 -0
- package/build-types/hooks/use-global-styles-output.d.ts +18 -0
- package/build-types/hooks/use-global-styles-output.d.ts.map +1 -0
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +20 -0
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +14 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +20 -0
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/utils/set-nested-value.d.ts +20 -0
- package/build-types/utils/set-nested-value.d.ts.map +1 -0
- package/package.json +40 -40
- package/src/bindings/post-data.js +9 -20
- package/src/bindings/post-meta.js +6 -17
- package/src/bindings/term-data.js +6 -21
- package/src/components/collab-sidebar/add-comment.js +31 -3
- package/src/components/collab-sidebar/comment-author-info.js +32 -25
- package/src/components/collab-sidebar/comment-indicator-toolbar.js +6 -22
- package/src/components/collab-sidebar/comments.js +108 -35
- package/src/components/collab-sidebar/hooks.js +3 -4
- package/src/components/collab-sidebar/index.js +34 -42
- package/src/components/collab-sidebar/style.scss +1 -22
- package/src/components/document-bar/index.js +18 -3
- package/src/components/editor/index.js +27 -1
- package/src/components/editor-interface/index.js +40 -39
- package/src/components/entities-saved-states/entity-type-list.js +19 -17
- package/src/components/global-styles/block-link.js +65 -0
- package/src/components/global-styles/header.js +48 -0
- package/src/components/global-styles/hooks.js +216 -0
- package/src/components/global-styles/index.js +125 -0
- package/src/components/global-styles/menu.js +101 -0
- package/src/components/global-styles/style.scss +11 -0
- package/src/components/global-styles-provider/index.js +3 -45
- package/src/components/global-styles-renderer/index.js +39 -0
- package/src/components/global-styles-sidebar/default-sidebar.js +46 -0
- package/src/components/global-styles-sidebar/index.js +177 -0
- package/src/components/global-styles-sidebar/style.scss +119 -0
- package/src/components/global-styles-sidebar/welcome-guide-image.js +11 -0
- package/src/components/global-styles-sidebar/welcome-guide.js +136 -0
- package/src/components/header/index.js +11 -13
- package/src/components/post-featured-image/index.js +44 -1
- package/src/components/post-template/hooks.js +10 -51
- package/src/components/provider/index.js +1 -4
- package/src/components/style-book/categories.ts +97 -0
- package/src/components/style-book/color-examples.tsx +56 -0
- package/src/components/style-book/constants.ts +308 -0
- package/src/components/style-book/duotone-examples.tsx +56 -0
- package/src/components/style-book/examples.tsx +273 -0
- package/src/components/style-book/index.js +794 -0
- package/src/components/style-book/style.scss +44 -0
- package/src/components/style-book/test/categories.js +166 -0
- package/src/components/style-book/types.ts +80 -0
- package/src/components/styles-canvas/index.js +126 -0
- package/src/components/styles-canvas/revisions.js +144 -0
- package/src/components/styles-canvas/style-book.js +57 -0
- package/src/components/styles-canvas/style.scss +40 -0
- package/src/components/visual-editor/index.js +2 -1
- package/src/dataviews/fields/content-preview/content-preview-view.tsx +2 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/media-upload.js +25 -5
- package/src/hooks/push-changes-to-global-styles/index.js +391 -0
- package/src/hooks/push-changes-to-global-styles/style.scss +4 -0
- package/src/hooks/use-global-styles-output.js +76 -0
- package/src/private-apis.js +10 -8
- package/src/store/actions.js +4 -1
- package/src/store/private-actions.js +37 -0
- package/src/store/private-selectors.js +20 -0
- package/src/store/reducer.js +36 -0
- package/src/style.scss +7 -0
- package/src/utils/set-nested-value.js +39 -0
- package/tsconfig.json +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/editor-interface/content-slot-fill.js.map +0 -7
- package/build-module/components/editor-interface/content-slot-fill.js +0 -9
- package/build-module/components/editor-interface/content-slot-fill.js.map +0 -7
- package/build-types/components/editor-interface/content-slot-fill.d.ts +0 -14
- package/build-types/components/editor-interface/content-slot-fill.d.ts.map +0 -1
- package/src/components/editor-interface/content-slot-fill.js +0 -10
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
1
5
|
/**
|
|
2
6
|
* WordPress dependencies
|
|
3
7
|
*/
|
|
@@ -18,7 +22,7 @@ import {
|
|
|
18
22
|
import { unlock } from '../../lock-unlock';
|
|
19
23
|
import CommentAuthorInfo from './comment-author-info';
|
|
20
24
|
import CommentForm from './comment-form';
|
|
21
|
-
import { focusCommentThread } from './utils';
|
|
25
|
+
import { focusCommentThread, noop } from './utils';
|
|
22
26
|
|
|
23
27
|
const { useBlockElement } = unlock( blockEditorPrivateApis );
|
|
24
28
|
|
|
@@ -27,6 +31,10 @@ export function AddComment( {
|
|
|
27
31
|
showCommentBoard,
|
|
28
32
|
setShowCommentBoard,
|
|
29
33
|
commentSidebarRef,
|
|
34
|
+
reflowComments = noop,
|
|
35
|
+
isFloating = false,
|
|
36
|
+
y,
|
|
37
|
+
refs,
|
|
30
38
|
} ) {
|
|
31
39
|
const { clientId, blockCommentId } = useSelect( ( select ) => {
|
|
32
40
|
const { getSelectedBlock } = select( blockEditorStore );
|
|
@@ -44,10 +52,29 @@ export function AddComment( {
|
|
|
44
52
|
|
|
45
53
|
return (
|
|
46
54
|
<VStack
|
|
47
|
-
className=
|
|
55
|
+
className={ clsx(
|
|
56
|
+
'editor-collab-sidebar-panel__thread is-selected',
|
|
57
|
+
{
|
|
58
|
+
'is-floating': isFloating,
|
|
59
|
+
}
|
|
60
|
+
) }
|
|
48
61
|
spacing="3"
|
|
49
62
|
tabIndex={ 0 }
|
|
63
|
+
aria-label={ __( 'New note' ) }
|
|
50
64
|
role="listitem"
|
|
65
|
+
ref={ isFloating ? refs.setFloating : undefined }
|
|
66
|
+
style={
|
|
67
|
+
isFloating
|
|
68
|
+
? // Delay showing the floating note box until a Y position is known to prevent blink.
|
|
69
|
+
{ top: y, opacity: ! y ? 0 : undefined }
|
|
70
|
+
: undefined
|
|
71
|
+
}
|
|
72
|
+
onBlur={ ( event ) => {
|
|
73
|
+
if ( event.currentTarget.contains( event.relatedTarget ) ) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
setShowCommentBoard( false );
|
|
77
|
+
} }
|
|
51
78
|
>
|
|
52
79
|
<HStack alignment="left" spacing="3">
|
|
53
80
|
<CommentAuthorInfo />
|
|
@@ -62,8 +89,9 @@ export function AddComment( {
|
|
|
62
89
|
setShowCommentBoard( false );
|
|
63
90
|
blockElement?.focus();
|
|
64
91
|
} }
|
|
92
|
+
reflowComments={ reflowComments }
|
|
65
93
|
submitButtonText={ __( 'Add note' ) }
|
|
66
|
-
labelText={ __( 'New
|
|
94
|
+
labelText={ __( 'New note' ) }
|
|
67
95
|
/>
|
|
68
96
|
</VStack>
|
|
69
97
|
);
|
|
@@ -18,38 +18,45 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
|
18
18
|
*/
|
|
19
19
|
import { getAvatarBorderColor } from './utils';
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* Render author information for a comment.
|
|
23
|
-
*
|
|
24
|
-
* @param {Object} props - Component properties.
|
|
25
|
-
* @param {string} props.avatar - URL of the author's avatar.
|
|
26
|
-
* @param {string} props.name - Name of the author.
|
|
27
|
-
* @param {string} props.date - Date of the comment.
|
|
28
|
-
* @param {string} props.userId - User ID of the author.
|
|
29
|
-
*
|
|
30
|
-
* @return {React.ReactNode} The JSX element representing the author's information.
|
|
31
|
-
*/
|
|
32
21
|
function CommentAuthorInfo( { avatar, name, date, userId } ) {
|
|
22
|
+
const hasAvatar = !! avatar;
|
|
33
23
|
const dateSettings = getDateSettings();
|
|
34
24
|
const {
|
|
35
25
|
currentUserAvatar,
|
|
36
26
|
currentUserName,
|
|
37
27
|
currentUserId,
|
|
38
28
|
dateFormat = dateSettings.formats.date,
|
|
39
|
-
} = useSelect(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
29
|
+
} = useSelect(
|
|
30
|
+
( select ) => {
|
|
31
|
+
const { canUser, getCurrentUser, getEntityRecord } =
|
|
32
|
+
select( coreStore );
|
|
33
|
+
const siteSettings = canUser( 'read', {
|
|
34
|
+
kind: 'root',
|
|
35
|
+
name: 'site',
|
|
36
|
+
} )
|
|
37
|
+
? getEntityRecord( 'root', 'site' )
|
|
38
|
+
: undefined;
|
|
39
|
+
|
|
40
|
+
if ( hasAvatar ) {
|
|
41
|
+
return {
|
|
42
|
+
dateFormat: siteSettings?.date_format,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const { getSettings } = select( blockEditorStore );
|
|
47
|
+
const { __experimentalDiscussionSettings } = getSettings();
|
|
48
|
+
const defaultAvatar = __experimentalDiscussionSettings?.avatarURL;
|
|
49
|
+
const userData = getCurrentUser();
|
|
50
|
+
return {
|
|
51
|
+
currentUserAvatar:
|
|
52
|
+
userData?.avatar_urls?.[ 48 ] ?? defaultAvatar,
|
|
53
|
+
currentUserName: userData?.name,
|
|
54
|
+
currentUserId: userData?.id,
|
|
55
|
+
dateFormat: siteSettings?.date_format,
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
[ hasAvatar ]
|
|
59
|
+
);
|
|
53
60
|
|
|
54
61
|
const commentDate = getDate( date );
|
|
55
62
|
const commentDateTime = dateI18n( 'c', commentDate );
|
|
@@ -6,11 +6,6 @@ import { __, _n, sprintf } from '@wordpress/i18n';
|
|
|
6
6
|
import { useMemo } from '@wordpress/element';
|
|
7
7
|
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* External dependencies
|
|
11
|
-
*/
|
|
12
|
-
import clsx from 'clsx';
|
|
13
|
-
|
|
14
9
|
/**
|
|
15
10
|
* Internal dependencies
|
|
16
11
|
*/
|
|
@@ -19,7 +14,7 @@ import { getAvatarBorderColor } from './utils';
|
|
|
19
14
|
|
|
20
15
|
const { CommentIconToolbarSlotFill } = unlock( blockEditorPrivateApis );
|
|
21
16
|
|
|
22
|
-
const CommentAvatarIndicator = ( { onClick, thread
|
|
17
|
+
const CommentAvatarIndicator = ( { onClick, thread } ) => {
|
|
23
18
|
const threadParticipants = useMemo( () => {
|
|
24
19
|
if ( ! thread ) {
|
|
25
20
|
return [];
|
|
@@ -34,15 +29,13 @@ const CommentAvatarIndicator = ( { onClick, thread, hasMoreComments } ) => {
|
|
|
34
29
|
allComments.forEach( ( comment ) => {
|
|
35
30
|
// Track thread participants (original commenter + repliers).
|
|
36
31
|
if ( comment.author_name && comment.author_avatar_urls ) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
participantsMap.set( authorKey, {
|
|
32
|
+
if ( ! participantsMap.has( comment.author ) ) {
|
|
33
|
+
participantsMap.set( comment.author, {
|
|
40
34
|
name: comment.author_name,
|
|
41
35
|
avatar:
|
|
42
36
|
comment.author_avatar_urls?.[ '48' ] ||
|
|
43
37
|
comment.author_avatar_urls?.[ '96' ],
|
|
44
38
|
id: comment.author,
|
|
45
|
-
isOriginalCommenter: comment.id === thread.id,
|
|
46
39
|
date: comment.date,
|
|
47
40
|
} );
|
|
48
41
|
}
|
|
@@ -52,14 +45,6 @@ const CommentAvatarIndicator = ( { onClick, thread, hasMoreComments } ) => {
|
|
|
52
45
|
return Array.from( participantsMap.values() );
|
|
53
46
|
}, [ thread ] );
|
|
54
47
|
|
|
55
|
-
const hasUnresolved = thread?.status !== 'approved';
|
|
56
|
-
|
|
57
|
-
// Check if this specific thread has more participants due to pagination.
|
|
58
|
-
// If we have pagination AND this thread + its replies equals or exceeds the API limit,
|
|
59
|
-
// then this thread likely has more participants that weren't loaded.
|
|
60
|
-
const threadHasMoreParticipants =
|
|
61
|
-
hasMoreComments && thread?.reply && 1 + thread.reply.length >= 100;
|
|
62
|
-
|
|
63
48
|
if ( ! threadParticipants.length ) {
|
|
64
49
|
return null;
|
|
65
50
|
}
|
|
@@ -68,6 +53,7 @@ const CommentAvatarIndicator = ( { onClick, thread, hasMoreComments } ) => {
|
|
|
68
53
|
const maxAvatars = 3;
|
|
69
54
|
const visibleParticipants = threadParticipants.slice( 0, maxAvatars );
|
|
70
55
|
const overflowCount = Math.max( 0, threadParticipants.length - maxAvatars );
|
|
56
|
+
const threadHasMoreParticipants = threadParticipants.length > 100;
|
|
71
57
|
|
|
72
58
|
// If we hit the comment limit, show "100+" instead of exact overflow count.
|
|
73
59
|
const overflowText =
|
|
@@ -95,9 +81,7 @@ const CommentAvatarIndicator = ( { onClick, thread, hasMoreComments } ) => {
|
|
|
95
81
|
return (
|
|
96
82
|
<CommentIconToolbarSlotFill.Fill>
|
|
97
83
|
<ToolbarButton
|
|
98
|
-
className=
|
|
99
|
-
'has-unresolved': hasUnresolved,
|
|
100
|
-
} ) }
|
|
84
|
+
className="comment-avatar-indicator"
|
|
101
85
|
label={ __( 'View notes' ) }
|
|
102
86
|
onClick={ onClick }
|
|
103
87
|
showTooltip
|
|
@@ -105,7 +89,7 @@ const CommentAvatarIndicator = ( { onClick, thread, hasMoreComments } ) => {
|
|
|
105
89
|
<div className="comment-avatar-stack">
|
|
106
90
|
{ visibleParticipants.map( ( participant, index ) => (
|
|
107
91
|
<img
|
|
108
|
-
key={ participant.
|
|
92
|
+
key={ participant.id }
|
|
109
93
|
src={ participant.avatar }
|
|
110
94
|
alt={ participant.name }
|
|
111
95
|
className="comment-avatar"
|
|
@@ -6,7 +6,13 @@ import clsx from 'clsx';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
useState,
|
|
11
|
+
RawHTML,
|
|
12
|
+
useEffect,
|
|
13
|
+
useCallback,
|
|
14
|
+
useMemo,
|
|
15
|
+
} from '@wordpress/element';
|
|
10
16
|
import {
|
|
11
17
|
__experimentalText as Text,
|
|
12
18
|
__experimentalHStack as HStack,
|
|
@@ -33,32 +39,19 @@ import {
|
|
|
33
39
|
import { unlock } from '../../lock-unlock';
|
|
34
40
|
import CommentAuthorInfo from './comment-author-info';
|
|
35
41
|
import CommentForm from './comment-form';
|
|
36
|
-
import {
|
|
42
|
+
import { focusCommentThread, getCommentExcerpt } from './utils';
|
|
37
43
|
import { useFloatingThread } from './hooks';
|
|
44
|
+
import { AddComment } from './add-comment';
|
|
38
45
|
|
|
39
46
|
const { useBlockElement } = unlock( blockEditorPrivateApis );
|
|
40
47
|
const { Menu } = unlock( componentsPrivateApis );
|
|
41
48
|
|
|
42
|
-
/**
|
|
43
|
-
* Renders the Comments component.
|
|
44
|
-
*
|
|
45
|
-
* @param {Object} props - The component props.
|
|
46
|
-
* @param {Array} props.threads - The array of comment threads.
|
|
47
|
-
* @param {Function} props.onEditComment - The function to handle comment editing.
|
|
48
|
-
* @param {Function} props.onAddReply - The function to add a reply to a comment.
|
|
49
|
-
* @param {Function} props.onCommentDelete - The function to delete a comment.
|
|
50
|
-
* @param {Function} props.setShowCommentBoard - The function to set the comment board visibility.
|
|
51
|
-
* @param {Ref} props.commentSidebarRef - The ref to the comment sidebar.
|
|
52
|
-
* @param {Function} props.reflowComments - The function to call indicating a comment is updated.
|
|
53
|
-
* @param {boolean} props.isFloating - Whether the comment thread is floating.
|
|
54
|
-
* @param {number} props.commentLastUpdated - Timestamp of the last comment update.
|
|
55
|
-
* @return {React.ReactNode} The rendered Comments component.
|
|
56
|
-
*/
|
|
57
49
|
export function Comments( {
|
|
58
|
-
threads,
|
|
50
|
+
threads: noteThreads,
|
|
59
51
|
onEditComment,
|
|
60
52
|
onAddReply,
|
|
61
53
|
onCommentDelete,
|
|
54
|
+
showCommentBoard,
|
|
62
55
|
setShowCommentBoard,
|
|
63
56
|
commentSidebarRef,
|
|
64
57
|
reflowComments,
|
|
@@ -70,20 +63,62 @@ export function Comments( {
|
|
|
70
63
|
const [ boardOffsets, setBoardOffsets ] = useState( {} );
|
|
71
64
|
const [ blockRefs, setBlockRefs ] = useState( {} );
|
|
72
65
|
|
|
73
|
-
const { blockCommentId, selectedBlockClientId } =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
66
|
+
const { blockCommentId, selectedBlockClientId, orderedBlockIds } =
|
|
67
|
+
useSelect( ( select ) => {
|
|
68
|
+
const { getBlockAttributes, getSelectedBlockClientId } =
|
|
69
|
+
select( blockEditorStore );
|
|
70
|
+
const clientId = getSelectedBlockClientId();
|
|
71
|
+
return {
|
|
72
|
+
blockCommentId: clientId
|
|
73
|
+
? getBlockAttributes( clientId )?.metadata?.noteId
|
|
74
|
+
: null,
|
|
75
|
+
selectedBlockClientId: clientId,
|
|
76
|
+
orderedBlockIds: select( blockEditorStore ).getBlockOrder(),
|
|
77
|
+
};
|
|
78
|
+
}, [] );
|
|
84
79
|
|
|
85
80
|
const relatedBlockElement = useBlockElement( selectedBlockClientId );
|
|
86
81
|
|
|
82
|
+
const threads = useMemo( () => {
|
|
83
|
+
const t = [ ...noteThreads ];
|
|
84
|
+
const orderedThreads = [];
|
|
85
|
+
// In floating mode, when the note board is shown, and as long
|
|
86
|
+
// as the selected block doesn't have an existing note attached -
|
|
87
|
+
// add a "new note" entry to the threads. This special thread type
|
|
88
|
+
// gets sorted and floated like regular threads, but shows an AddComment
|
|
89
|
+
// component instead of a regular comment thread.
|
|
90
|
+
if ( isFloating && showCommentBoard && undefined === blockCommentId ) {
|
|
91
|
+
// Insert the new note entry at the correct location for its blockId.
|
|
92
|
+
const newNoteThread = {
|
|
93
|
+
id: 'new-note-thread',
|
|
94
|
+
blockClientId: selectedBlockClientId,
|
|
95
|
+
content: { rendered: '' },
|
|
96
|
+
};
|
|
97
|
+
// Insert the new comment block at the right order within the threads.
|
|
98
|
+
orderedBlockIds.forEach( ( blockId ) => {
|
|
99
|
+
if ( blockId === selectedBlockClientId ) {
|
|
100
|
+
orderedThreads.push( newNoteThread );
|
|
101
|
+
} else {
|
|
102
|
+
const threadForBlock = t.find(
|
|
103
|
+
( thread ) => thread.blockClientId === blockId
|
|
104
|
+
);
|
|
105
|
+
if ( threadForBlock ) {
|
|
106
|
+
orderedThreads.push( threadForBlock );
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
} );
|
|
110
|
+
return orderedThreads;
|
|
111
|
+
}
|
|
112
|
+
return t;
|
|
113
|
+
}, [
|
|
114
|
+
noteThreads,
|
|
115
|
+
isFloating,
|
|
116
|
+
showCommentBoard,
|
|
117
|
+
blockCommentId,
|
|
118
|
+
selectedBlockClientId,
|
|
119
|
+
orderedBlockIds,
|
|
120
|
+
] );
|
|
121
|
+
|
|
87
122
|
const handleDelete = async ( comment ) => {
|
|
88
123
|
const currentIndex = threads.findIndex( ( t ) => t.id === comment.id );
|
|
89
124
|
const nextThread = threads[ currentIndex + 1 ];
|
|
@@ -247,17 +282,33 @@ export function Comments( {
|
|
|
247
282
|
const hasThreads = Array.isArray( threads ) && threads.length > 0;
|
|
248
283
|
if ( ! hasThreads && ! isFloating ) {
|
|
249
284
|
return (
|
|
250
|
-
|
|
285
|
+
<>
|
|
286
|
+
<AddComment
|
|
287
|
+
onSubmit={ onAddReply }
|
|
288
|
+
showCommentBoard={ showCommentBoard }
|
|
289
|
+
setShowCommentBoard={ setShowCommentBoard }
|
|
290
|
+
commentSidebarRef={ commentSidebarRef }
|
|
291
|
+
/>
|
|
251
292
|
<Text as="p">{ __( 'No notes available.' ) }</Text>
|
|
252
293
|
<Text as="p" variant="muted">
|
|
253
294
|
{ __( 'Only logged in users can see Notes.' ) }
|
|
254
295
|
</Text>
|
|
255
|
-
|
|
296
|
+
</>
|
|
256
297
|
);
|
|
257
298
|
}
|
|
258
299
|
|
|
259
300
|
return (
|
|
260
|
-
|
|
301
|
+
<>
|
|
302
|
+
{ ! isFloating &&
|
|
303
|
+
showCommentBoard &&
|
|
304
|
+
undefined === blockCommentId && (
|
|
305
|
+
<AddComment
|
|
306
|
+
onSubmit={ onAddReply }
|
|
307
|
+
showCommentBoard={ showCommentBoard }
|
|
308
|
+
setShowCommentBoard={ setShowCommentBoard }
|
|
309
|
+
commentSidebarRef={ commentSidebarRef }
|
|
310
|
+
/>
|
|
311
|
+
) }
|
|
261
312
|
{ threads.map( ( thread ) => (
|
|
262
313
|
<Thread
|
|
263
314
|
key={ thread.id }
|
|
@@ -276,9 +327,10 @@ export function Comments( {
|
|
|
276
327
|
setBlockRef={ setBlockRef }
|
|
277
328
|
selectedThread={ selectedThread }
|
|
278
329
|
commentLastUpdated={ commentLastUpdated }
|
|
330
|
+
showCommentBoard={ showCommentBoard }
|
|
279
331
|
/>
|
|
280
332
|
) ) }
|
|
281
|
-
|
|
333
|
+
</>
|
|
282
334
|
);
|
|
283
335
|
}
|
|
284
336
|
|
|
@@ -298,6 +350,7 @@ function Thread( {
|
|
|
298
350
|
setSelectedThread,
|
|
299
351
|
selectedThread,
|
|
300
352
|
commentLastUpdated,
|
|
353
|
+
showCommentBoard,
|
|
301
354
|
} ) {
|
|
302
355
|
const { toggleBlockHighlight, selectBlock, toggleBlockSpotlight } = unlock(
|
|
303
356
|
useDispatch( blockEditorStore )
|
|
@@ -347,7 +400,7 @@ function Thread( {
|
|
|
347
400
|
const restReplies = allReplies.length > 0 ? allReplies.slice( 0, -1 ) : [];
|
|
348
401
|
|
|
349
402
|
const commentExcerpt = getCommentExcerpt(
|
|
350
|
-
stripHTML( thread.content
|
|
403
|
+
stripHTML( thread.content?.rendered ),
|
|
351
404
|
10
|
|
352
405
|
);
|
|
353
406
|
const ariaLabel = !! thread.blockClientId
|
|
@@ -362,6 +415,21 @@ function Thread( {
|
|
|
362
415
|
commentExcerpt
|
|
363
416
|
);
|
|
364
417
|
|
|
418
|
+
if ( 'new-note-thread' === thread.id && showCommentBoard && isFloating ) {
|
|
419
|
+
return (
|
|
420
|
+
<AddComment
|
|
421
|
+
onSubmit={ onAddReply }
|
|
422
|
+
showCommentBoard={ showCommentBoard }
|
|
423
|
+
setShowCommentBoard={ setShowCommentBoard }
|
|
424
|
+
commentSidebarRef={ commentSidebarRef }
|
|
425
|
+
reflowComments={ reflowComments }
|
|
426
|
+
isFloating={ isFloating }
|
|
427
|
+
y={ y }
|
|
428
|
+
refs={ refs }
|
|
429
|
+
/>
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
|
|
365
433
|
return (
|
|
366
434
|
// Disable reason: role="listitem" does in fact support aria-expanded.
|
|
367
435
|
// eslint-disable-next-line jsx-a11y/role-supports-aria-props
|
|
@@ -378,6 +446,9 @@ function Thread( {
|
|
|
378
446
|
onFocus={ onMouseEnter }
|
|
379
447
|
onBlur={ onMouseLeave }
|
|
380
448
|
onKeyDown={ ( event ) => {
|
|
449
|
+
if ( event.defaultPrevented ) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
381
452
|
// Expand or Collapse thread.
|
|
382
453
|
if (
|
|
383
454
|
event.key === 'Enter' &&
|
|
@@ -745,7 +816,9 @@ const CommentBoard = ( {
|
|
|
745
816
|
onCancel={ handleCancel }
|
|
746
817
|
confirmButtonText={ __( 'Delete' ) }
|
|
747
818
|
>
|
|
748
|
-
{ __(
|
|
819
|
+
{ __(
|
|
820
|
+
"Are you sure you want to delete this note? This will also delete all of this note's replies."
|
|
821
|
+
) }
|
|
749
822
|
</ConfirmDialog>
|
|
750
823
|
) }
|
|
751
824
|
</VStack>
|
|
@@ -50,10 +50,10 @@ export function useBlockComments( postId ) {
|
|
|
50
50
|
post: postId,
|
|
51
51
|
type: 'note',
|
|
52
52
|
status: 'all',
|
|
53
|
-
per_page:
|
|
53
|
+
per_page: -1,
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
const { records: threads
|
|
56
|
+
const { records: threads } = useEntityRecords(
|
|
57
57
|
'root',
|
|
58
58
|
'comment',
|
|
59
59
|
queryArgs,
|
|
@@ -160,7 +160,6 @@ export function useBlockComments( postId ) {
|
|
|
160
160
|
return {
|
|
161
161
|
resultComments,
|
|
162
162
|
unresolvedSortedThreads,
|
|
163
|
-
totalPages,
|
|
164
163
|
reflowComments,
|
|
165
164
|
commentLastUpdated,
|
|
166
165
|
};
|
|
@@ -399,7 +398,7 @@ export function useFloatingThread( {
|
|
|
399
398
|
if ( blockRef.current ) {
|
|
400
399
|
refs.setReference( blockRef.current );
|
|
401
400
|
}
|
|
402
|
-
}, [ blockRef, refs ] );
|
|
401
|
+
}, [ blockRef, refs, commentLastUpdated ] );
|
|
403
402
|
|
|
404
403
|
// Track thread heights.
|
|
405
404
|
useEffect( () => {
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
SIDEBARS,
|
|
21
21
|
} from './constants';
|
|
22
22
|
import { Comments } from './comments';
|
|
23
|
-
import { AddComment } from './add-comment';
|
|
24
23
|
import { store as editorStore } from '../../store';
|
|
25
24
|
import AddCommentMenuItem from './comment-menu-item';
|
|
26
25
|
import CommentAvatarIndicator from './comment-indicator-toolbar';
|
|
@@ -31,9 +30,9 @@ import {
|
|
|
31
30
|
useEnableFloatingSidebar,
|
|
32
31
|
} from './hooks';
|
|
33
32
|
import { focusCommentThread } from './utils';
|
|
34
|
-
import
|
|
33
|
+
import PostTypeSupportCheck from '../post-type-support-check';
|
|
35
34
|
|
|
36
|
-
function
|
|
35
|
+
function NotesSidebarContent( {
|
|
37
36
|
showCommentBoard,
|
|
38
37
|
setShowCommentBoard,
|
|
39
38
|
styles,
|
|
@@ -61,12 +60,6 @@ function CollabSidebarContent( {
|
|
|
61
60
|
}
|
|
62
61
|
} }
|
|
63
62
|
>
|
|
64
|
-
<AddComment
|
|
65
|
-
onSubmit={ onCreate }
|
|
66
|
-
showCommentBoard={ showCommentBoard }
|
|
67
|
-
setShowCommentBoard={ setShowCommentBoard }
|
|
68
|
-
commentSidebarRef={ commentSidebarRef }
|
|
69
|
-
/>
|
|
70
63
|
<Comments
|
|
71
64
|
threads={ comments }
|
|
72
65
|
onEditComment={ onEdit }
|
|
@@ -83,22 +76,14 @@ function CollabSidebarContent( {
|
|
|
83
76
|
);
|
|
84
77
|
}
|
|
85
78
|
|
|
86
|
-
|
|
87
|
-
* Renders the Collab sidebar.
|
|
88
|
-
*/
|
|
89
|
-
export default function CollabSidebar() {
|
|
79
|
+
function NotesSidebar( { postId, mode } ) {
|
|
90
80
|
const [ showCommentBoard, setShowCommentBoard ] = useState( false );
|
|
91
81
|
const { getActiveComplementaryArea } = useSelect( interfaceStore );
|
|
92
82
|
const { enableComplementaryArea } = useDispatch( interfaceStore );
|
|
93
83
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
94
84
|
const commentSidebarRef = useRef( null );
|
|
95
85
|
|
|
96
|
-
const
|
|
97
|
-
const { getCurrentPostId } = select( editorStore );
|
|
98
|
-
return {
|
|
99
|
-
postId: getCurrentPostId(),
|
|
100
|
-
};
|
|
101
|
-
}, [] );
|
|
86
|
+
const showFloatingSidebar = isLargeViewport && mode === 'post-only';
|
|
102
87
|
|
|
103
88
|
const blockCommentId = useSelect( ( select ) => {
|
|
104
89
|
const { getBlockAttributes, getSelectedBlockClientId } =
|
|
@@ -112,17 +97,14 @@ export default function CollabSidebar() {
|
|
|
112
97
|
const {
|
|
113
98
|
resultComments,
|
|
114
99
|
unresolvedSortedThreads,
|
|
115
|
-
totalPages,
|
|
116
100
|
reflowComments,
|
|
117
101
|
commentLastUpdated,
|
|
118
102
|
} = useBlockComments( postId );
|
|
119
103
|
useEnableFloatingSidebar(
|
|
120
|
-
|
|
104
|
+
showFloatingSidebar &&
|
|
121
105
|
( unresolvedSortedThreads.length > 0 || showCommentBoard )
|
|
122
106
|
);
|
|
123
107
|
|
|
124
|
-
const hasMoreComments = totalPages && totalPages > 1;
|
|
125
|
-
|
|
126
108
|
// Get the global styles to set the background color of the sidebar.
|
|
127
109
|
const { merged: GlobalStyles } = useGlobalStylesContext();
|
|
128
110
|
const backgroundColor = GlobalStyles?.styles?.color?.background;
|
|
@@ -132,20 +114,18 @@ export default function CollabSidebar() {
|
|
|
132
114
|
? resultComments.find( ( thread ) => thread.id === blockCommentId )
|
|
133
115
|
: null;
|
|
134
116
|
|
|
135
|
-
// If postId is not a valid number, do not render the comment sidebar.
|
|
136
|
-
if ( ! ( !! postId && typeof postId === 'number' ) ) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
117
|
async function openTheSidebar() {
|
|
141
118
|
const prevArea = await getActiveComplementaryArea( 'core' );
|
|
142
119
|
const activeNotesArea = SIDEBARS.find( ( name ) => name === prevArea );
|
|
143
120
|
|
|
144
|
-
|
|
145
|
-
|
|
121
|
+
if ( currentThread?.status === 'approved' ) {
|
|
122
|
+
enableComplementaryArea( 'core', collabHistorySidebarName );
|
|
123
|
+
} else if ( ! activeNotesArea ) {
|
|
146
124
|
enableComplementaryArea(
|
|
147
125
|
'core',
|
|
148
|
-
|
|
126
|
+
showFloatingSidebar
|
|
127
|
+
? collabSidebarName
|
|
128
|
+
: collabHistorySidebarName
|
|
149
129
|
);
|
|
150
130
|
}
|
|
151
131
|
|
|
@@ -169,18 +149,18 @@ export default function CollabSidebar() {
|
|
|
169
149
|
{ blockCommentId && (
|
|
170
150
|
<CommentAvatarIndicator
|
|
171
151
|
thread={ currentThread }
|
|
172
|
-
hasMoreComments={ hasMoreComments }
|
|
173
152
|
onClick={ openTheSidebar }
|
|
174
153
|
/>
|
|
175
154
|
) }
|
|
176
155
|
<AddCommentMenuItem onClick={ openTheSidebar } />
|
|
177
156
|
<PluginSidebar
|
|
178
157
|
identifier={ collabHistorySidebarName }
|
|
158
|
+
name={ collabHistorySidebarName }
|
|
179
159
|
title={ __( 'Notes' ) }
|
|
180
160
|
icon={ commentIcon }
|
|
181
161
|
closeLabel={ __( 'Close Notes' ) }
|
|
182
162
|
>
|
|
183
|
-
<
|
|
163
|
+
<NotesSidebarContent
|
|
184
164
|
comments={ resultComments }
|
|
185
165
|
showCommentBoard={ showCommentBoard }
|
|
186
166
|
setShowCommentBoard={ setShowCommentBoard }
|
|
@@ -198,7 +178,7 @@ export default function CollabSidebar() {
|
|
|
198
178
|
headerClassName="editor-collab-sidebar__header"
|
|
199
179
|
backgroundColor={ backgroundColor }
|
|
200
180
|
>
|
|
201
|
-
<
|
|
181
|
+
<NotesSidebarContent
|
|
202
182
|
comments={ unresolvedSortedThreads }
|
|
203
183
|
showCommentBoard={ showCommentBoard }
|
|
204
184
|
setShowCommentBoard={ setShowCommentBoard }
|
|
@@ -212,14 +192,26 @@ export default function CollabSidebar() {
|
|
|
212
192
|
/>
|
|
213
193
|
</PluginSidebar>
|
|
214
194
|
) }
|
|
215
|
-
<PluginMoreMenuItem
|
|
216
|
-
icon={ commentIcon }
|
|
217
|
-
onClick={ () =>
|
|
218
|
-
enableComplementaryArea( 'core', collabHistorySidebarName )
|
|
219
|
-
}
|
|
220
|
-
>
|
|
221
|
-
{ __( 'Notes' ) }
|
|
222
|
-
</PluginMoreMenuItem>
|
|
223
195
|
</>
|
|
224
196
|
);
|
|
225
197
|
}
|
|
198
|
+
|
|
199
|
+
export default function NotesSidebarContainer() {
|
|
200
|
+
const { postId, mode } = useSelect( ( select ) => {
|
|
201
|
+
const { getCurrentPostId, getRenderingMode } = select( editorStore );
|
|
202
|
+
return {
|
|
203
|
+
postId: getCurrentPostId(),
|
|
204
|
+
mode: getRenderingMode(),
|
|
205
|
+
};
|
|
206
|
+
}, [] );
|
|
207
|
+
|
|
208
|
+
if ( ! postId || typeof postId !== 'number' ) {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return (
|
|
213
|
+
<PostTypeSupportCheck supportKeys="editor.notes">
|
|
214
|
+
<NotesSidebar postId={ postId } mode={ mode } />
|
|
215
|
+
</PostTypeSupportCheck>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.editor-collab-sidebar-panel {
|
|
19
|
-
padding: $grid-unit-20;
|
|
19
|
+
padding: $grid-unit-20 $grid-unit-20 $grid-unit-30;
|
|
20
20
|
height: 100%;
|
|
21
21
|
overflow: hidden;
|
|
22
22
|
}
|
|
@@ -161,27 +161,6 @@
|
|
|
161
161
|
min-width: auto;
|
|
162
162
|
background: transparent;
|
|
163
163
|
border: none;
|
|
164
|
-
|
|
165
|
-
&:hover::before {
|
|
166
|
-
background: rgba(0, 0, 0, 0.04);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
&.has-unresolved {
|
|
170
|
-
.comment-avatar-stack {
|
|
171
|
-
&::after {
|
|
172
|
-
content: "";
|
|
173
|
-
position: absolute;
|
|
174
|
-
top: -2px;
|
|
175
|
-
right: -2px;
|
|
176
|
-
width: $grid-unit-10;
|
|
177
|
-
height: $grid-unit-10;
|
|
178
|
-
background: #d63638;
|
|
179
|
-
border-radius: $radius-round;
|
|
180
|
-
border: $border-width solid $white;
|
|
181
|
-
z-index: 10;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
164
|
}
|
|
186
165
|
|
|
187
166
|
.comment-avatar-stack {
|