@wordpress/block-library 9.6.1 → 9.7.1-next.5368f64a9.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/archives/edit.js +1 -1
- package/build/archives/edit.js.map +1 -1
- package/build/audio/edit.js +2 -1
- package/build/audio/edit.js.map +1 -1
- package/build/block/edit.js +5 -8
- package/build/block/edit.js.map +1 -1
- package/build/button/edit.js +1 -1
- package/build/button/edit.js.map +1 -1
- package/build/buttons/index.js +1 -1
- package/build/categories/index.js +1 -0
- package/build/categories/index.js.map +1 -1
- package/build/comment-edit-link/index.js +13 -2
- package/build/comment-edit-link/index.js.map +1 -1
- package/build/comment-reply-link/index.js +13 -2
- package/build/comment-reply-link/index.js.map +1 -1
- package/build/comments/edit/comments-legacy.js +1 -0
- package/build/comments/edit/comments-legacy.js.map +1 -1
- package/build/cover/deprecated.js +1 -1
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit/block-controls.js +4 -2
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/cover/edit/index.js +6 -3
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +4 -12
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/details/index.js +3 -1
- package/build/details/index.js.map +1 -1
- package/build/details/transforms.js +24 -0
- package/build/details/transforms.js.map +1 -0
- package/build/embed/edit.js +5 -11
- package/build/embed/edit.js.map +1 -1
- package/build/embed/embed-placeholder.js +2 -0
- package/build/embed/embed-placeholder.js.map +1 -1
- package/build/embed/embed-preview.js +16 -4
- package/build/embed/embed-preview.js.map +1 -1
- package/build/file/edit.js +12 -1
- package/build/file/edit.js.map +1 -1
- package/build/file/transforms.js +18 -4
- package/build/file/transforms.js.map +1 -1
- package/build/freeform/edit.js +4 -4
- package/build/freeform/edit.js.map +1 -1
- package/build/freeform/modal.js +3 -0
- package/build/freeform/modal.js.map +1 -1
- package/build/home-link/edit.js +3 -9
- package/build/home-link/edit.js.map +1 -1
- package/build/image/edit.js +95 -45
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +39 -24
- package/build/image/image.js.map +1 -1
- package/build/image/transforms.js +0 -13
- package/build/image/transforms.js.map +1 -1
- package/build/image/use-max-width-observer.js +35 -0
- package/build/image/use-max-width-observer.js.map +1 -0
- package/build/image/utils.js +11 -0
- package/build/image/utils.js.map +1 -1
- package/build/latest-posts/edit.js +1 -1
- package/build/latest-posts/edit.js.map +1 -1
- package/build/media-text/deprecated.js +144 -3
- package/build/media-text/deprecated.js.map +1 -1
- package/build/media-text/edit.js +5 -5
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/image-fill.js +12 -0
- package/build/media-text/image-fill.js.map +1 -0
- package/build/media-text/media-container.js +21 -18
- package/build/media-text/media-container.js.map +1 -1
- package/build/media-text/media-container.native.js +0 -7
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/media-text/save.js +5 -6
- package/build/media-text/save.js.map +1 -1
- package/build/missing/edit.js +3 -2
- package/build/missing/edit.js.map +1 -1
- package/build/navigation/edit/deleted-navigation-warning.js +14 -7
- package/build/navigation/edit/deleted-navigation-warning.js.map +1 -1
- package/build/navigation/edit/index.js +1 -0
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +2 -1
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation/edit/navigation-menu-delete-control.js +1 -0
- package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +1 -0
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +2 -0
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +4 -4
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation-link/link-ui.js +2 -1
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +2 -0
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/edit.js +4 -1
- package/build/page-list/edit.js.map +1 -1
- package/build/post-comments-form/form.js +1 -0
- package/build/post-comments-form/form.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +6 -8
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-featured-image/edit.js +2 -4
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-title/index.js +4 -1
- package/build/post-title/index.js.map +1 -1
- package/build/query/edit/enhanced-pagination-modal.js +3 -2
- package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js +3 -3
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +2 -10
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +9 -3
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/edit/query-placeholder.js +2 -0
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/site-logo/edit.js +9 -13
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-title/index.js +4 -1
- package/build/site-title/index.js.map +1 -1
- package/build/social-link/edit.js +4 -1
- package/build/social-link/edit.js.map +1 -1
- package/build/social-links/edit.js +10 -9
- package/build/social-links/edit.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/index.js +1 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/inner-blocks.js +10 -1
- package/build/template-part/edit/inner-blocks.js.map +1 -1
- package/build/template-part/edit/placeholder.js +2 -0
- package/build/template-part/edit/placeholder.js.map +1 -1
- package/build/utils/hooks.js +10 -10
- package/build/utils/hooks.js.map +1 -1
- package/build/video/edit.js +16 -12
- package/build/video/edit.js.map +1 -1
- package/build/video/tracks-editor.js +3 -0
- package/build/video/tracks-editor.js.map +1 -1
- package/build-module/archives/edit.js +1 -1
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/audio/edit.js +2 -1
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/block/edit.js +6 -9
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/edit.js +1 -1
- package/build-module/button/edit.js.map +1 -1
- package/build-module/buttons/index.js +1 -1
- package/build-module/categories/index.js +1 -0
- package/build-module/categories/index.js.map +1 -1
- package/build-module/comment-edit-link/index.js +13 -2
- package/build-module/comment-edit-link/index.js.map +1 -1
- package/build-module/comment-reply-link/index.js +13 -2
- package/build-module/comment-reply-link/index.js.map +1 -1
- package/build-module/comments/edit/comments-legacy.js +1 -0
- package/build-module/comments/edit/comments-legacy.js.map +1 -1
- package/build-module/cover/deprecated.js +1 -1
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +4 -2
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/cover/edit/index.js +6 -3
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +5 -13
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/details/index.js +3 -1
- package/build-module/details/index.js.map +1 -1
- package/build-module/details/transforms.js +18 -0
- package/build-module/details/transforms.js.map +1 -0
- package/build-module/embed/edit.js +6 -12
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/embed/embed-placeholder.js +2 -0
- package/build-module/embed/embed-placeholder.js.map +1 -1
- package/build-module/embed/embed-preview.js +16 -4
- package/build-module/embed/embed-preview.js.map +1 -1
- package/build-module/file/edit.js +12 -1
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/transforms.js +18 -4
- package/build-module/file/transforms.js.map +1 -1
- package/build-module/freeform/edit.js +4 -4
- package/build-module/freeform/edit.js.map +1 -1
- package/build-module/freeform/modal.js +3 -0
- package/build-module/freeform/modal.js.map +1 -1
- package/build-module/home-link/edit.js +3 -9
- package/build-module/home-link/edit.js.map +1 -1
- package/build-module/image/edit.js +99 -48
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +40 -25
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/transforms.js +0 -13
- package/build-module/image/transforms.js.map +1 -1
- package/build-module/image/use-max-width-observer.js +29 -0
- package/build-module/image/use-max-width-observer.js.map +1 -0
- package/build-module/image/utils.js +11 -1
- package/build-module/image/utils.js.map +1 -1
- package/build-module/latest-posts/edit.js +1 -1
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/media-text/deprecated.js +144 -3
- package/build-module/media-text/deprecated.js.map +1 -1
- package/build-module/media-text/edit.js +5 -5
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/image-fill.js +6 -0
- package/build-module/media-text/image-fill.js.map +1 -0
- package/build-module/media-text/media-container.js +21 -17
- package/build-module/media-text/media-container.js.map +1 -1
- package/build-module/media-text/media-container.native.js +0 -1
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/media-text/save.js +5 -6
- package/build-module/media-text/save.js.map +1 -1
- package/build-module/missing/edit.js +3 -2
- package/build-module/missing/edit.js.map +1 -1
- package/build-module/navigation/edit/deleted-navigation-warning.js +15 -8
- package/build-module/navigation/edit/deleted-navigation-warning.js.map +1 -1
- package/build-module/navigation/edit/index.js +1 -0
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +2 -1
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-delete-control.js +1 -0
- package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +1 -0
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +2 -0
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +4 -4
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +4 -3
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +2 -0
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/edit.js +4 -1
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +1 -0
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +6 -8
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-featured-image/edit.js +3 -5
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-title/index.js +4 -1
- package/build-module/post-title/index.js.map +1 -1
- package/build-module/query/edit/enhanced-pagination-modal.js +3 -2
- package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +3 -3
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +2 -10
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +10 -4
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +2 -0
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/site-logo/edit.js +10 -14
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-title/index.js +4 -1
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-link/edit.js +4 -1
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-links/edit.js +11 -10
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +1 -1
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/inner-blocks.js +10 -1
- package/build-module/template-part/edit/inner-blocks.js.map +1 -1
- package/build-module/template-part/edit/placeholder.js +2 -0
- package/build-module/template-part/edit/placeholder.js.map +1 -1
- package/build-module/utils/hooks.js +10 -10
- package/build-module/utils/hooks.js.map +1 -1
- package/build-module/video/edit.js +16 -13
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/tracks-editor.js +3 -0
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/button/editor-rtl.css +0 -4
- package/build-style/button/editor.css +0 -4
- package/build-style/buttons/editor-rtl.css +2 -5
- package/build-style/buttons/editor.css +2 -5
- package/build-style/buttons/style-rtl.css +2 -2
- package/build-style/buttons/style.css +2 -2
- package/build-style/comment-edit-link/style-rtl.css +94 -0
- package/build-style/comment-edit-link/style.css +94 -0
- package/build-style/comment-reply-link/style-rtl.css +94 -0
- package/build-style/comment-reply-link/style.css +94 -0
- package/build-style/comments-pagination/editor-rtl.css +2 -2
- package/build-style/comments-pagination/editor.css +2 -2
- package/build-style/common-rtl.css +2 -2
- package/build-style/common.css +2 -2
- package/build-style/cover/editor-rtl.css +0 -6
- package/build-style/cover/editor.css +0 -6
- package/build-style/editor-rtl.css +35 -99
- package/build-style/editor.css +35 -101
- package/build-style/group/editor-rtl.css +0 -1
- package/build-style/group/editor.css +0 -1
- package/build-style/image/editor-rtl.css +6 -27
- package/build-style/image/editor.css +6 -27
- package/build-style/media-text/editor-rtl.css +3 -1
- package/build-style/media-text/editor.css +3 -1
- package/build-style/media-text/style-rtl.css +20 -0
- package/build-style/media-text/style.css +20 -0
- package/build-style/navigation/editor-rtl.css +1 -2
- package/build-style/navigation/editor.css +1 -2
- package/build-style/post-featured-image/style-rtl.css +1 -1
- package/build-style/post-featured-image/style.css +1 -1
- package/build-style/post-title/style-rtl.css +21 -0
- package/build-style/post-title/style.css +21 -0
- package/build-style/query-pagination/editor-rtl.css +2 -16
- package/build-style/query-pagination/editor.css +2 -18
- package/build-style/query-pagination/style-rtl.css +0 -11
- package/build-style/query-pagination/style.css +0 -13
- package/build-style/site-title/editor-rtl.css +0 -4
- package/build-style/site-title/editor.css +0 -4
- package/build-style/site-title/style-rtl.css +21 -0
- package/build-style/site-title/style.css +21 -0
- package/build-style/social-links/editor-rtl.css +17 -0
- package/build-style/social-links/editor.css +17 -0
- package/build-style/style-rtl.css +75 -16
- package/build-style/style.css +75 -18
- package/build-style/video/editor-rtl.css +0 -29
- package/build-style/video/editor.css +0 -29
- package/package.json +42 -35
- package/src/archives/edit.js +1 -1
- package/src/audio/edit.js +1 -0
- package/src/block/edit.js +9 -11
- package/src/button/edit.js +1 -1
- package/src/button/editor.scss +0 -5
- package/src/buttons/block.json +1 -1
- package/src/buttons/editor.scss +2 -8
- package/src/buttons/style.scss +2 -2
- package/src/categories/block.json +1 -0
- package/src/categories/index.php +13 -2
- package/src/comment-edit-link/block.json +13 -2
- package/src/comment-edit-link/style.scss +4 -0
- package/src/comment-reply-link/block.json +13 -2
- package/src/comment-reply-link/style.scss +4 -0
- package/src/comments/edit/comments-legacy.js +1 -0
- package/src/comments-pagination/editor.scss +1 -1
- package/src/cover/deprecated.js +3 -2
- package/src/cover/edit/block-controls.js +2 -0
- package/src/cover/edit/index.js +6 -1
- package/src/cover/edit/inspector-controls.js +3 -15
- package/src/cover/editor.scss +0 -5
- package/src/cover/test/edit.js +30 -26
- package/src/details/index.js +2 -0
- package/src/details/transforms.js +26 -0
- package/src/embed/edit.js +0 -7
- package/src/embed/embed-placeholder.js +10 -2
- package/src/embed/embed-preview.js +22 -2
- package/src/file/edit.js +11 -0
- package/src/file/index.php +1 -1
- package/src/file/transforms.js +26 -6
- package/src/freeform/edit.js +4 -4
- package/src/freeform/editor.scss +1 -1
- package/src/freeform/modal.js +7 -1
- package/src/gallery/editor.scss +1 -1
- package/src/group/editor.scss +0 -1
- package/src/home-link/edit.js +4 -7
- package/src/image/edit.js +130 -47
- package/src/image/editor.scss +7 -41
- package/src/image/image.js +100 -67
- package/src/image/index.php +1 -1
- package/src/image/transforms.js +0 -23
- package/src/image/use-max-width-observer.js +32 -0
- package/src/image/utils.js +13 -1
- package/src/latest-posts/edit.js +1 -1
- package/src/media-text/deprecated.js +159 -3
- package/src/media-text/edit.js +5 -5
- package/src/media-text/editor.scss +3 -1
- package/src/media-text/image-fill.js +11 -0
- package/src/media-text/index.php +53 -43
- package/src/media-text/media-container.js +25 -25
- package/src/media-text/media-container.native.js +0 -2
- package/src/media-text/save.js +9 -13
- package/src/media-text/style.scss +21 -0
- package/src/media-text/test/image-fill.js +19 -0
- package/src/missing/edit.js +8 -3
- package/src/navigation/edit/deleted-navigation-warning.js +23 -13
- package/src/navigation/edit/index.js +1 -0
- package/src/navigation/edit/menu-inspector-controls.js +3 -1
- package/src/navigation/edit/navigation-menu-delete-control.js +1 -0
- package/src/navigation/edit/placeholder/index.js +1 -0
- package/src/navigation/edit/responsive-wrapper.js +2 -0
- package/src/navigation/edit/unsaved-inner-blocks.js +4 -4
- package/src/navigation/editor.scss +11 -4
- package/src/navigation/index.php +1 -1
- package/src/navigation-link/link-ui.js +4 -3
- package/src/page-list/convert-to-links-modal.js +6 -1
- package/src/page-list/edit.js +6 -1
- package/src/page-list/index.php +3 -1
- package/src/post-comments-form/form.js +1 -0
- package/src/post-featured-image/dimension-controls.js +4 -4
- package/src/post-featured-image/edit.js +3 -6
- package/src/post-featured-image/style.scss +1 -1
- package/src/post-title/block.json +4 -1
- package/src/post-title/style.scss +24 -0
- package/src/query/edit/enhanced-pagination-modal.js +7 -3
- package/src/query/edit/inspector-controls/enhanced-pagination-control.js +3 -3
- package/src/query/edit/inspector-controls/index.js +2 -9
- package/src/query/edit/query-content.js +7 -0
- package/src/query/edit/query-placeholder.js +2 -0
- package/src/query/index.php +1 -1
- package/src/query-pagination/editor.scss +1 -21
- package/src/query-pagination/style.scss +0 -15
- package/src/search/index.php +1 -1
- package/src/site-logo/edit.js +11 -20
- package/src/site-title/block.json +4 -1
- package/src/site-title/editor.scss +0 -4
- package/src/site-title/style.scss +24 -0
- package/src/social-link/edit.js +2 -0
- package/src/social-links/edit.js +17 -10
- package/src/social-links/editor.scss +24 -5
- package/src/style.scss +2 -0
- package/src/tag-cloud/index.php +7 -2
- package/src/template-part/edit/advanced-controls.js +0 -1
- package/src/template-part/edit/index.js +12 -10
- package/src/template-part/edit/inner-blocks.js +20 -1
- package/src/template-part/edit/placeholder.js +6 -1
- package/src/utils/hooks.js +11 -11
- package/src/video/edit.js +24 -21
- package/src/video/editor.scss +0 -45
- package/src/video/tracks-editor.js +3 -0
- package/src/media-text/test/media-container.js +0 -24
|
@@ -21,6 +21,7 @@ import { getAuthority } from '@wordpress/url';
|
|
|
21
21
|
* Internal dependencies
|
|
22
22
|
*/
|
|
23
23
|
import WpEmbedPreview from './wp-embed-preview';
|
|
24
|
+
import { Caption } from '../utils/caption';
|
|
24
25
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
26
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
27
|
class EmbedPreview extends Component {
|
|
@@ -60,7 +61,11 @@ class EmbedPreview extends Component {
|
|
|
60
61
|
type,
|
|
61
62
|
className,
|
|
62
63
|
icon,
|
|
63
|
-
label
|
|
64
|
+
label,
|
|
65
|
+
insertBlocksAfter,
|
|
66
|
+
attributes,
|
|
67
|
+
setAttributes,
|
|
68
|
+
isSelected
|
|
64
69
|
} = this.props;
|
|
65
70
|
const {
|
|
66
71
|
scripts
|
|
@@ -96,11 +101,11 @@ class EmbedPreview extends Component {
|
|
|
96
101
|
});
|
|
97
102
|
/* eslint-enable jsx-a11y/no-static-element-interactions */
|
|
98
103
|
|
|
99
|
-
return /*#__PURE__*/
|
|
104
|
+
return /*#__PURE__*/_jsxs("figure", {
|
|
100
105
|
className: clsx(className, 'wp-block-embed', {
|
|
101
106
|
'is-type-video': 'video' === type
|
|
102
107
|
}),
|
|
103
|
-
children: previewable ? embedWrapper : /*#__PURE__*/_jsxs(Placeholder, {
|
|
108
|
+
children: [previewable ? embedWrapper : /*#__PURE__*/_jsxs(Placeholder, {
|
|
104
109
|
icon: /*#__PURE__*/_jsx(BlockIcon, {
|
|
105
110
|
icon: icon,
|
|
106
111
|
showColors: true
|
|
@@ -117,7 +122,14 @@ class EmbedPreview extends Component {
|
|
|
117
122
|
children: sprintf( /* translators: %s: host providing embed content e.g: www.youtube.com */
|
|
118
123
|
__("Embedded content from %s can't be previewed in the editor."), embedSourceUrl)
|
|
119
124
|
})]
|
|
120
|
-
})
|
|
125
|
+
}), /*#__PURE__*/_jsx(Caption, {
|
|
126
|
+
attributes: attributes,
|
|
127
|
+
setAttributes: setAttributes,
|
|
128
|
+
isSelected: isSelected,
|
|
129
|
+
insertBlocksAfter: insertBlocksAfter,
|
|
130
|
+
label: __('Embed caption text'),
|
|
131
|
+
showToolbarButton: isSelected
|
|
132
|
+
})]
|
|
121
133
|
});
|
|
122
134
|
}
|
|
123
135
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getPhotoHtml","clsx","__","sprintf","Placeholder","SandBox","BlockIcon","Component","getAuthority","WpEmbedPreview","jsx","_jsx","jsxs","_jsxs","EmbedPreview","constructor","arguments","hideOverlay","bind","state","interactive","getDerivedStateFromProps","nextProps","isSelected","setState","render","preview","previewable","url","type","className","icon","label","props","scripts","html","embedSourceUrl","iframeTitle","sandboxClassnames","embedWrapper","children","title","onFocus","onMouseUp","showColors","href"],"sources":["@wordpress/block-library/src/embed/embed-preview.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { getPhotoHtml } from './util';\n\n/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Placeholder, SandBox } from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { Component } from '@wordpress/element';\nimport { getAuthority } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport WpEmbedPreview from './wp-embed-preview';\n\nclass EmbedPreview extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.hideOverlay = this.hideOverlay.bind( this );\n\t\tthis.state = {\n\t\t\tinteractive: false,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromProps( nextProps, state ) {\n\t\tif ( ! nextProps.isSelected && state.interactive ) {\n\t\t\t// We only want to change this when the block is not selected, because changing it when\n\t\t\t// the block becomes selected makes the overlap disappear too early. Hiding the overlay\n\t\t\t// happens on mouseup when the overlay is clicked.\n\t\t\treturn { interactive: false };\n\t\t}\n\n\t\treturn null;\n\t}\n\n\thideOverlay() {\n\t\t// This is called onMouseUp on the overlay. We can't respond to the `isSelected` prop\n\t\t// changing, because that happens on mouse down, and the overlay immediately disappears,\n\t\t// and the mouse event can end up in the preview content. We can't use onClick on\n\t\t// the overlay to hide it either, because then the editor misses the mouseup event, and\n\t\t// thinks we're multi-selecting blocks.\n\t\tthis.setState( { interactive: true } );\n\t}\n\n\trender() {\n\t\tconst {
|
|
1
|
+
{"version":3,"names":["getPhotoHtml","clsx","__","sprintf","Placeholder","SandBox","BlockIcon","Component","getAuthority","WpEmbedPreview","Caption","jsx","_jsx","jsxs","_jsxs","EmbedPreview","constructor","arguments","hideOverlay","bind","state","interactive","getDerivedStateFromProps","nextProps","isSelected","setState","render","preview","previewable","url","type","className","icon","label","insertBlocksAfter","attributes","setAttributes","props","scripts","html","embedSourceUrl","iframeTitle","sandboxClassnames","embedWrapper","children","title","onFocus","onMouseUp","showColors","href","showToolbarButton"],"sources":["@wordpress/block-library/src/embed/embed-preview.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { getPhotoHtml } from './util';\n\n/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Placeholder, SandBox } from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { Component } from '@wordpress/element';\nimport { getAuthority } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport WpEmbedPreview from './wp-embed-preview';\nimport { Caption } from '../utils/caption';\n\nclass EmbedPreview extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.hideOverlay = this.hideOverlay.bind( this );\n\t\tthis.state = {\n\t\t\tinteractive: false,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromProps( nextProps, state ) {\n\t\tif ( ! nextProps.isSelected && state.interactive ) {\n\t\t\t// We only want to change this when the block is not selected, because changing it when\n\t\t\t// the block becomes selected makes the overlap disappear too early. Hiding the overlay\n\t\t\t// happens on mouseup when the overlay is clicked.\n\t\t\treturn { interactive: false };\n\t\t}\n\n\t\treturn null;\n\t}\n\n\thideOverlay() {\n\t\t// This is called onMouseUp on the overlay. We can't respond to the `isSelected` prop\n\t\t// changing, because that happens on mouse down, and the overlay immediately disappears,\n\t\t// and the mouse event can end up in the preview content. We can't use onClick on\n\t\t// the overlay to hide it either, because then the editor misses the mouseup event, and\n\t\t// thinks we're multi-selecting blocks.\n\t\tthis.setState( { interactive: true } );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tpreview,\n\t\t\tpreviewable,\n\t\t\turl,\n\t\t\ttype,\n\t\t\tclassName,\n\t\t\ticon,\n\t\t\tlabel,\n\t\t\tinsertBlocksAfter,\n\t\t\tattributes,\n\t\t\tsetAttributes,\n\t\t\tisSelected,\n\t\t} = this.props;\n\t\tconst { scripts } = preview;\n\t\tconst { interactive } = this.state;\n\n\t\tconst html = 'photo' === type ? getPhotoHtml( preview ) : preview.html;\n\t\tconst embedSourceUrl = getAuthority( url );\n\t\tconst iframeTitle = sprintf(\n\t\t\t// translators: %s: host providing embed content e.g: www.youtube.com\n\t\t\t__( 'Embedded content from %s' ),\n\t\t\tembedSourceUrl\n\t\t);\n\t\tconst sandboxClassnames = clsx(\n\t\t\ttype,\n\t\t\tclassName,\n\t\t\t'wp-block-embed__wrapper'\n\t\t);\n\n\t\t// Disabled because the overlay div doesn't actually have a role or functionality\n\t\t// as far as the user is concerned. We're just catching the first click so that\n\t\t// the block can be selected without interacting with the embed preview that the overlay covers.\n\t\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\t\tconst embedWrapper =\n\t\t\t'wp-embed' === type ? (\n\t\t\t\t<WpEmbedPreview html={ html } />\n\t\t\t) : (\n\t\t\t\t<div className=\"wp-block-embed__wrapper\">\n\t\t\t\t\t<SandBox\n\t\t\t\t\t\thtml={ html }\n\t\t\t\t\t\tscripts={ scripts }\n\t\t\t\t\t\ttitle={ iframeTitle }\n\t\t\t\t\t\ttype={ sandboxClassnames }\n\t\t\t\t\t\tonFocus={ this.hideOverlay }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! interactive && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"block-library-embed__interactive-overlay\"\n\t\t\t\t\t\t\tonMouseUp={ this.hideOverlay }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t);\n\t\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n\n\t\treturn (\n\t\t\t<figure\n\t\t\t\tclassName={ clsx( className, 'wp-block-embed', {\n\t\t\t\t\t'is-type-video': 'video' === type,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t{ previewable ? (\n\t\t\t\t\tembedWrapper\n\t\t\t\t) : (\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\ticon={ <BlockIcon icon={ icon } showColors /> }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t>\n\t\t\t\t\t\t<p className=\"components-placeholder__error\">\n\t\t\t\t\t\t\t<a href={ url }>{ url }</a>\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p className=\"components-placeholder__error\">\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: host providing embed content e.g: www.youtube.com */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\"Embedded content from %s can't be previewed in the editor.\"\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tembedSourceUrl\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</Placeholder>\n\t\t\t\t) }\n\t\t\t\t<Caption\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tlabel={ __( 'Embed caption text' ) }\n\t\t\t\t\tshowToolbarButton={ isSelected }\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t);\n\t}\n}\n\nexport default EmbedPreview;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,QAAQ;;AAErC;AACA;AACA;AACA,OAAOC,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,WAAW,EAAEC,OAAO,QAAQ,uBAAuB;AAC5D,SAASC,SAAS,QAAQ,yBAAyB;AACnD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,YAAY,QAAQ,gBAAgB;;AAE7C;AACA;AACA;AACA,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,SAASC,OAAO,QAAQ,kBAAkB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAE3C,MAAMC,YAAY,SAASR,SAAS,CAAC;EACpCS,WAAWA,CAAA,EAAG;IACb,KAAK,CAAE,GAAGC,SAAU,CAAC;IACrB,IAAI,CAACC,WAAW,GAAG,IAAI,CAACA,WAAW,CAACC,IAAI,CAAE,IAAK,CAAC;IAChD,IAAI,CAACC,KAAK,GAAG;MACZC,WAAW,EAAE;IACd,CAAC;EACF;EAEA,OAAOC,wBAAwBA,CAAEC,SAAS,EAAEH,KAAK,EAAG;IACnD,IAAK,CAAEG,SAAS,CAACC,UAAU,IAAIJ,KAAK,CAACC,WAAW,EAAG;MAClD;MACA;MACA;MACA,OAAO;QAAEA,WAAW,EAAE;MAAM,CAAC;IAC9B;IAEA,OAAO,IAAI;EACZ;EAEAH,WAAWA,CAAA,EAAG;IACb;IACA;IACA;IACA;IACA;IACA,IAAI,CAACO,QAAQ,CAAE;MAAEJ,WAAW,EAAE;IAAK,CAAE,CAAC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B,EAAE;QAC9C,eAAe,EAAE,OAAO,KAAKD;MAC9B,CAAE,CAAG;MAAAc,QAAA,GAEHhB,WAAW,GACZe,YAAY,gBAEZ7B,KAAA,CAACV,WAAW;QACX4B,IAAI,eAAGpB,IAAA,CAACN,SAAS;UAAC0B,IAAI,EAAGA,IAAM;UAACgB,UAAU;QAAA,CAAE,CAAG;QAC/Cf,KAAK,EAAGA,KAAO;QAAAW,QAAA,gBAEfhC,IAAA;UAAGmB,SAAS,EAAC,+BAA+B;UAAAa,QAAA,eAC3ChC,IAAA;YAAGqC,IAAI,EAAGpB,GAAK;YAAAe,QAAA,EAAGf;UAAG,CAAK;QAAC,CACzB,CAAC,eACJjB,IAAA;UAAGmB,SAAS,EAAC,+BAA+B;UAAAa,QAAA,EACzCzC,OAAO,EACR;UACAD,EAAE,CACD,4DACD,CAAC,EACDsC,cACD;QAAC,CACC,CAAC;MAAA,CACQ,CACb,eACD5B,IAAA,CAACF,OAAO;QACPyB,UAAU,EAAGA,UAAY;QACzBC,aAAa,EAAGA,aAAe;QAC/BZ,UAAU,EAAGA,UAAY;QACzBU,iBAAiB,EAAGA,iBAAmB;QACvCD,KAAK,EAAG/B,EAAE,CAAE,oBAAqB,CAAG;QACpCgD,iBAAiB,EAAG1B;MAAY,CAChC,CAAC;IAAA,CACK,CAAC;EAEX;AACD;AAEA,eAAeT,YAAY","ignoreList":[]}
|
|
@@ -99,6 +99,16 @@ function FileEdit({
|
|
|
99
99
|
}, []);
|
|
100
100
|
function onSelectFile(newMedia) {
|
|
101
101
|
if (!newMedia || !newMedia.url) {
|
|
102
|
+
// Reset attributes.
|
|
103
|
+
setAttributes({
|
|
104
|
+
href: undefined,
|
|
105
|
+
fileName: undefined,
|
|
106
|
+
textLinkHref: undefined,
|
|
107
|
+
id: undefined,
|
|
108
|
+
fileId: undefined,
|
|
109
|
+
displayPreview: undefined,
|
|
110
|
+
previewHeight: undefined
|
|
111
|
+
});
|
|
102
112
|
setTemporaryURL();
|
|
103
113
|
return;
|
|
104
114
|
}
|
|
@@ -210,7 +220,8 @@ function FileEdit({
|
|
|
210
220
|
mediaURL: href,
|
|
211
221
|
accept: "*",
|
|
212
222
|
onSelect: onSelectFile,
|
|
213
|
-
onError: onUploadError
|
|
223
|
+
onError: onUploadError,
|
|
224
|
+
onReset: () => onSelectFile(undefined)
|
|
214
225
|
}), /*#__PURE__*/_jsx(ClipboardToolbarButton, {
|
|
215
226
|
text: href,
|
|
216
227
|
disabled: isBlobURL(href)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","isBlobURL","__unstableGetAnimateClassName","getAnimateClassName","ResizableBox","ToolbarButton","useSelect","useDispatch","BlockControls","BlockIcon","MediaPlaceholder","MediaReplaceFlow","RichText","useBlockProps","store","blockEditorStore","__experimentalGetElementClassName","useEffect","useState","useCopyToClipboard","__","_x","file","icon","coreStore","noticesStore","FileBlockInspector","browserSupportsPdfs","removeAnchorTag","useUploadMediaFromBlobURL","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","MIN_PREVIEW_HEIGHT","MAX_PREVIEW_HEIGHT","ClipboardToolbarButton","text","disabled","createNotice","ref","isDismissible","type","className","children","FileEdit","attributes","isSelected","setAttributes","clientId","id","fileName","href","textLinkHref","textLinkTarget","showDownloadButton","downloadButtonText","displayPreview","previewHeight","temporaryURL","setTemporaryURL","blob","media","select","undefined","getMedia","createErrorNotice","toggleSelection","__unstableMarkNextChangeAsNotPersistent","url","onChange","onSelectFile","onError","onUploadError","isEmpty","newMedia","isPdf","endsWith","title","fileId","message","changeLinkDestinationOption","newHref","changeOpenInNewWindow","newValue","changeShowDownloadButton","changeDisplayPreview","handleOnResizeStop","event","direction","elt","delta","newHeight","parseInt","height","changePreviewHeight","Math","max","attachmentPage","link","blockProps","displayPreviewInEditor","labels","instructions","onSelect","accept","hrefs","openInNewWindow","group","mediaId","mediaURL","size","minHeight","maxHeight","minWidth","grid","enable","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft","onResizeStart","onResizeStop","showHandle","data","identifier","tagName","value","placeholder","withoutInteractiveFormatting"],"sources":["@wordpress/block-library/src/file/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\t__unstableGetAnimateClassName as getAnimateClassName,\n\tResizableBox,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { useEffect, useState } from '@wordpress/element';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { __, _x } from '@wordpress/i18n';\nimport { file as icon } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport FileBlockInspector from './inspector';\nimport { browserSupportsPdfs } from './utils';\nimport removeAnchorTag from '../utils/remove-anchor-tag';\nimport { useUploadMediaFromBlobURL } from '../utils/hooks';\n\nexport const MIN_PREVIEW_HEIGHT = 200;\nexport const MAX_PREVIEW_HEIGHT = 2000;\n\nfunction ClipboardToolbarButton( { text, disabled } ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst ref = useCopyToClipboard( text, () => {\n\t\tcreateNotice( 'info', __( 'Copied URL to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\n\treturn (\n\t\t<ToolbarButton\n\t\t\tclassName=\"components-clipboard-toolbar-button\"\n\t\t\tref={ ref }\n\t\t\tdisabled={ disabled }\n\t\t>\n\t\t\t{ __( 'Copy URL' ) }\n\t\t</ToolbarButton>\n\t);\n}\n\nfunction FileEdit( { attributes, isSelected, setAttributes, clientId } ) {\n\tconst {\n\t\tid,\n\t\tfileName,\n\t\thref,\n\t\ttextLinkHref,\n\t\ttextLinkTarget,\n\t\tshowDownloadButton,\n\t\tdownloadButtonText,\n\t\tdisplayPreview,\n\t\tpreviewHeight,\n\t} = attributes;\n\tconst [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );\n\tconst { media } = useSelect(\n\t\t( select ) => ( {\n\t\t\tmedia:\n\t\t\t\tid === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: select( coreStore ).getMedia( id ),\n\t\t} ),\n\t\t[ id ]\n\t);\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { toggleSelection, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseUploadMediaFromBlobURL( {\n\t\turl: temporaryURL,\n\t\tonChange: onSelectFile,\n\t\tonError: onUploadError,\n\t} );\n\n\t// Note: Handle setting a default value for `downloadButtonText` via HTML API\n\t// when it supports replacing text content for HTML tags.\n\tuseEffect( () => {\n\t\tif ( RichText.isEmpty( downloadButtonText ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tdownloadButtonText: _x( 'Download', 'button label' ),\n\t\t\t} );\n\t\t}\n\t\t// Reason: This effect should only run on mount.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\tfunction onSelectFile( newMedia ) {\n\t\tif ( ! newMedia || ! newMedia.url ) {\n\t\t\tsetTemporaryURL();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( newMedia.url ) ) {\n\t\t\tsetTemporaryURL( newMedia.url );\n\t\t\treturn;\n\t\t}\n\n\t\tconst isPdf = newMedia.url.endsWith( '.pdf' );\n\t\tsetAttributes( {\n\t\t\thref: newMedia.url,\n\t\t\tfileName: newMedia.title,\n\t\t\ttextLinkHref: newMedia.url,\n\t\t\tid: newMedia.id,\n\t\t\tdisplayPreview: isPdf ? true : undefined,\n\t\t\tpreviewHeight: isPdf ? 600 : undefined,\n\t\t\tfileId: `wp-block-file--media-${ clientId }`,\n\t\t\tblob: undefined,\n\t\t} );\n\t\tsetTemporaryURL();\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tsetAttributes( { href: undefined } );\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\tfunction changeLinkDestinationOption( newHref ) {\n\t\t// Choose Media File or Attachment Page (when file is in Media Library).\n\t\tsetAttributes( { textLinkHref: newHref } );\n\t}\n\n\tfunction changeOpenInNewWindow( newValue ) {\n\t\tsetAttributes( {\n\t\t\ttextLinkTarget: newValue ? '_blank' : false,\n\t\t} );\n\t}\n\n\tfunction changeShowDownloadButton( newValue ) {\n\t\tsetAttributes( { showDownloadButton: newValue } );\n\t}\n\n\tfunction changeDisplayPreview( newValue ) {\n\t\tsetAttributes( { displayPreview: newValue } );\n\t}\n\n\tfunction handleOnResizeStop( event, direction, elt, delta ) {\n\t\ttoggleSelection( true );\n\n\t\tconst newHeight = parseInt( previewHeight + delta.height, 10 );\n\t\tsetAttributes( { previewHeight: newHeight } );\n\t}\n\n\tfunction changePreviewHeight( newValue ) {\n\t\tconst newHeight = Math.max(\n\t\t\tparseInt( newValue, 10 ),\n\t\t\tMIN_PREVIEW_HEIGHT\n\t\t);\n\t\tsetAttributes( { previewHeight: newHeight } );\n\t}\n\n\tconst attachmentPage = media && media.link;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx(\n\t\t\t!! temporaryURL && getAnimateClassName( { type: 'loading' } ),\n\t\t\t{\n\t\t\t\t'is-transient': !! temporaryURL,\n\t\t\t}\n\t\t),\n\t} );\n\n\tconst displayPreviewInEditor = browserSupportsPdfs() && displayPreview;\n\n\tif ( ! href && ! temporaryURL ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tlabels={ {\n\t\t\t\t\t\ttitle: __( 'File' ),\n\t\t\t\t\t\tinstructions: __(\n\t\t\t\t\t\t\t'Upload a file or pick one from your media library.'\n\t\t\t\t\t\t),\n\t\t\t\t\t} }\n\t\t\t\t\tonSelect={ onSelectFile }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\taccept=\"*\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<FileBlockInspector\n\t\t\t\threfs={ {\n\t\t\t\t\thref: href || temporaryURL,\n\t\t\t\t\ttextLinkHref,\n\t\t\t\t\tattachmentPage,\n\t\t\t\t} }\n\t\t\t\t{ ...{\n\t\t\t\t\topenInNewWindow: !! textLinkTarget,\n\t\t\t\t\tshowDownloadButton,\n\t\t\t\t\tchangeLinkDestinationOption,\n\t\t\t\t\tchangeOpenInNewWindow,\n\t\t\t\t\tchangeShowDownloadButton,\n\t\t\t\t\tdisplayPreview,\n\t\t\t\t\tchangeDisplayPreview,\n\t\t\t\t\tpreviewHeight,\n\t\t\t\t\tchangePreviewHeight,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ href }\n\t\t\t\t\taccept=\"*\"\n\t\t\t\t\tonSelect={ onSelectFile }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t\t<ClipboardToolbarButton\n\t\t\t\t\ttext={ href }\n\t\t\t\t\tdisabled={ isBlobURL( href ) }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ displayPreviewInEditor && (\n\t\t\t\t\t<ResizableBox\n\t\t\t\t\t\tsize={ { height: previewHeight } }\n\t\t\t\t\t\tminHeight={ MIN_PREVIEW_HEIGHT }\n\t\t\t\t\t\tmaxHeight={ MAX_PREVIEW_HEIGHT }\n\t\t\t\t\t\tminWidth=\"100%\"\n\t\t\t\t\t\tgrid={ [ 10, 10 ] }\n\t\t\t\t\t\tenable={ {\n\t\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\t\tright: false,\n\t\t\t\t\t\t\tbottom: true,\n\t\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonResizeStart={ () => toggleSelection( false ) }\n\t\t\t\t\t\tonResizeStop={ handleOnResizeStop }\n\t\t\t\t\t\tshowHandle={ isSelected }\n\t\t\t\t\t>\n\t\t\t\t\t\t<object\n\t\t\t\t\t\t\tclassName=\"wp-block-file__preview\"\n\t\t\t\t\t\t\tdata={ href }\n\t\t\t\t\t\t\ttype=\"application/pdf\"\n\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t'Embed of the selected PDF file.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ ! isSelected && (\n\t\t\t\t\t\t\t<div className=\"wp-block-file__preview-overlay\" />\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ResizableBox>\n\t\t\t\t) }\n\t\t\t\t<div className=\"wp-block-file__content-wrapper\">\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tidentifier=\"fileName\"\n\t\t\t\t\t\ttagName=\"a\"\n\t\t\t\t\t\tvalue={ fileName }\n\t\t\t\t\t\tplaceholder={ __( 'Write file name…' ) }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tonChange={ ( text ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tfileName: removeAnchorTag( text ),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thref={ textLinkHref }\n\t\t\t\t\t/>\n\t\t\t\t\t{ showDownloadButton && (\n\t\t\t\t\t\t<div className=\"wp-block-file__button-richtext-wrapper\">\n\t\t\t\t\t\t\t{ /* Using RichText here instead of PlainText so that it can be styled like a button. */ }\n\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\tidentifier=\"downloadButtonText\"\n\t\t\t\t\t\t\t\ttagName=\"div\" // Must be block-level or else cursor disappears.\n\t\t\t\t\t\t\t\taria-label={ __( 'Download button text' ) }\n\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t'wp-block-file__button',\n\t\t\t\t\t\t\t\t\t__experimentalGetElementClassName(\n\t\t\t\t\t\t\t\t\t\t'button'\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\tvalue={ downloadButtonText }\n\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\tplaceholder={ __( 'Add text…' ) }\n\t\t\t\t\t\t\t\tonChange={ ( text ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tdownloadButtonText:\n\t\t\t\t\t\t\t\t\t\t\tremoveAnchorTag( text ),\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/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default FileEdit;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,6BAA6B,IAAIC,mBAAmB,EACpDC,YAAY,EACZC,aAAa,QACP,uBAAuB;AAC9B,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,aAAa,EACbC,SAAS,EACTC,gBAAgB,EAChBC,gBAAgB,EAChBC,QAAQ,EACRC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,iCAAiC,QAC3B,yBAAyB;AACh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,CAAC;IAAA,CACF,CAAC;EAAA,CACL,CAAC;AAEL;AAEA,eAAeQ,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","isBlobURL","__unstableGetAnimateClassName","getAnimateClassName","ResizableBox","ToolbarButton","useSelect","useDispatch","BlockControls","BlockIcon","MediaPlaceholder","MediaReplaceFlow","RichText","useBlockProps","store","blockEditorStore","__experimentalGetElementClassName","useEffect","useState","useCopyToClipboard","__","_x","file","icon","coreStore","noticesStore","FileBlockInspector","browserSupportsPdfs","removeAnchorTag","useUploadMediaFromBlobURL","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","MIN_PREVIEW_HEIGHT","MAX_PREVIEW_HEIGHT","ClipboardToolbarButton","text","disabled","createNotice","ref","isDismissible","type","className","children","FileEdit","attributes","isSelected","setAttributes","clientId","id","fileName","href","textLinkHref","textLinkTarget","showDownloadButton","downloadButtonText","displayPreview","previewHeight","temporaryURL","setTemporaryURL","blob","media","select","undefined","getMedia","createErrorNotice","toggleSelection","__unstableMarkNextChangeAsNotPersistent","url","onChange","onSelectFile","onError","onUploadError","isEmpty","newMedia","fileId","isPdf","endsWith","title","message","changeLinkDestinationOption","newHref","changeOpenInNewWindow","newValue","changeShowDownloadButton","changeDisplayPreview","handleOnResizeStop","event","direction","elt","delta","newHeight","parseInt","height","changePreviewHeight","Math","max","attachmentPage","link","blockProps","displayPreviewInEditor","labels","instructions","onSelect","accept","hrefs","openInNewWindow","group","mediaId","mediaURL","onReset","size","minHeight","maxHeight","minWidth","grid","enable","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft","onResizeStart","onResizeStop","showHandle","data","identifier","tagName","value","placeholder","withoutInteractiveFormatting"],"sources":["@wordpress/block-library/src/file/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\t__unstableGetAnimateClassName as getAnimateClassName,\n\tResizableBox,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { useEffect, useState } from '@wordpress/element';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { __, _x } from '@wordpress/i18n';\nimport { file as icon } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport FileBlockInspector from './inspector';\nimport { browserSupportsPdfs } from './utils';\nimport removeAnchorTag from '../utils/remove-anchor-tag';\nimport { useUploadMediaFromBlobURL } from '../utils/hooks';\n\nexport const MIN_PREVIEW_HEIGHT = 200;\nexport const MAX_PREVIEW_HEIGHT = 2000;\n\nfunction ClipboardToolbarButton( { text, disabled } ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst ref = useCopyToClipboard( text, () => {\n\t\tcreateNotice( 'info', __( 'Copied URL to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\n\treturn (\n\t\t<ToolbarButton\n\t\t\tclassName=\"components-clipboard-toolbar-button\"\n\t\t\tref={ ref }\n\t\t\tdisabled={ disabled }\n\t\t>\n\t\t\t{ __( 'Copy URL' ) }\n\t\t</ToolbarButton>\n\t);\n}\n\nfunction FileEdit( { attributes, isSelected, setAttributes, clientId } ) {\n\tconst {\n\t\tid,\n\t\tfileName,\n\t\thref,\n\t\ttextLinkHref,\n\t\ttextLinkTarget,\n\t\tshowDownloadButton,\n\t\tdownloadButtonText,\n\t\tdisplayPreview,\n\t\tpreviewHeight,\n\t} = attributes;\n\tconst [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );\n\tconst { media } = useSelect(\n\t\t( select ) => ( {\n\t\t\tmedia:\n\t\t\t\tid === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: select( coreStore ).getMedia( id ),\n\t\t} ),\n\t\t[ id ]\n\t);\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { toggleSelection, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseUploadMediaFromBlobURL( {\n\t\turl: temporaryURL,\n\t\tonChange: onSelectFile,\n\t\tonError: onUploadError,\n\t} );\n\n\t// Note: Handle setting a default value for `downloadButtonText` via HTML API\n\t// when it supports replacing text content for HTML tags.\n\tuseEffect( () => {\n\t\tif ( RichText.isEmpty( downloadButtonText ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tdownloadButtonText: _x( 'Download', 'button label' ),\n\t\t\t} );\n\t\t}\n\t\t// Reason: This effect should only run on mount.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\tfunction onSelectFile( newMedia ) {\n\t\tif ( ! newMedia || ! newMedia.url ) {\n\t\t\t// Reset attributes.\n\t\t\tsetAttributes( {\n\t\t\t\thref: undefined,\n\t\t\t\tfileName: undefined,\n\t\t\t\ttextLinkHref: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tfileId: undefined,\n\t\t\t\tdisplayPreview: undefined,\n\t\t\t\tpreviewHeight: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( newMedia.url ) ) {\n\t\t\tsetTemporaryURL( newMedia.url );\n\t\t\treturn;\n\t\t}\n\n\t\tconst isPdf = newMedia.url.endsWith( '.pdf' );\n\t\tsetAttributes( {\n\t\t\thref: newMedia.url,\n\t\t\tfileName: newMedia.title,\n\t\t\ttextLinkHref: newMedia.url,\n\t\t\tid: newMedia.id,\n\t\t\tdisplayPreview: isPdf ? true : undefined,\n\t\t\tpreviewHeight: isPdf ? 600 : undefined,\n\t\t\tfileId: `wp-block-file--media-${ clientId }`,\n\t\t\tblob: undefined,\n\t\t} );\n\t\tsetTemporaryURL();\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tsetAttributes( { href: undefined } );\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\tfunction changeLinkDestinationOption( newHref ) {\n\t\t// Choose Media File or Attachment Page (when file is in Media Library).\n\t\tsetAttributes( { textLinkHref: newHref } );\n\t}\n\n\tfunction changeOpenInNewWindow( newValue ) {\n\t\tsetAttributes( {\n\t\t\ttextLinkTarget: newValue ? '_blank' : false,\n\t\t} );\n\t}\n\n\tfunction changeShowDownloadButton( newValue ) {\n\t\tsetAttributes( { showDownloadButton: newValue } );\n\t}\n\n\tfunction changeDisplayPreview( newValue ) {\n\t\tsetAttributes( { displayPreview: newValue } );\n\t}\n\n\tfunction handleOnResizeStop( event, direction, elt, delta ) {\n\t\ttoggleSelection( true );\n\n\t\tconst newHeight = parseInt( previewHeight + delta.height, 10 );\n\t\tsetAttributes( { previewHeight: newHeight } );\n\t}\n\n\tfunction changePreviewHeight( newValue ) {\n\t\tconst newHeight = Math.max(\n\t\t\tparseInt( newValue, 10 ),\n\t\t\tMIN_PREVIEW_HEIGHT\n\t\t);\n\t\tsetAttributes( { previewHeight: newHeight } );\n\t}\n\n\tconst attachmentPage = media && media.link;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx(\n\t\t\t!! temporaryURL && getAnimateClassName( { type: 'loading' } ),\n\t\t\t{\n\t\t\t\t'is-transient': !! temporaryURL,\n\t\t\t}\n\t\t),\n\t} );\n\n\tconst displayPreviewInEditor = browserSupportsPdfs() && displayPreview;\n\n\tif ( ! href && ! temporaryURL ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tlabels={ {\n\t\t\t\t\t\ttitle: __( 'File' ),\n\t\t\t\t\t\tinstructions: __(\n\t\t\t\t\t\t\t'Upload a file or pick one from your media library.'\n\t\t\t\t\t\t),\n\t\t\t\t\t} }\n\t\t\t\t\tonSelect={ onSelectFile }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\taccept=\"*\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<FileBlockInspector\n\t\t\t\threfs={ {\n\t\t\t\t\thref: href || temporaryURL,\n\t\t\t\t\ttextLinkHref,\n\t\t\t\t\tattachmentPage,\n\t\t\t\t} }\n\t\t\t\t{ ...{\n\t\t\t\t\topenInNewWindow: !! textLinkTarget,\n\t\t\t\t\tshowDownloadButton,\n\t\t\t\t\tchangeLinkDestinationOption,\n\t\t\t\t\tchangeOpenInNewWindow,\n\t\t\t\t\tchangeShowDownloadButton,\n\t\t\t\t\tdisplayPreview,\n\t\t\t\t\tchangeDisplayPreview,\n\t\t\t\t\tpreviewHeight,\n\t\t\t\t\tchangePreviewHeight,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ href }\n\t\t\t\t\taccept=\"*\"\n\t\t\t\t\tonSelect={ onSelectFile }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\tonReset={ () => onSelectFile( undefined ) }\n\t\t\t\t/>\n\t\t\t\t<ClipboardToolbarButton\n\t\t\t\t\ttext={ href }\n\t\t\t\t\tdisabled={ isBlobURL( href ) }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ displayPreviewInEditor && (\n\t\t\t\t\t<ResizableBox\n\t\t\t\t\t\tsize={ { height: previewHeight } }\n\t\t\t\t\t\tminHeight={ MIN_PREVIEW_HEIGHT }\n\t\t\t\t\t\tmaxHeight={ MAX_PREVIEW_HEIGHT }\n\t\t\t\t\t\tminWidth=\"100%\"\n\t\t\t\t\t\tgrid={ [ 10, 10 ] }\n\t\t\t\t\t\tenable={ {\n\t\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\t\tright: false,\n\t\t\t\t\t\t\tbottom: true,\n\t\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonResizeStart={ () => toggleSelection( false ) }\n\t\t\t\t\t\tonResizeStop={ handleOnResizeStop }\n\t\t\t\t\t\tshowHandle={ isSelected }\n\t\t\t\t\t>\n\t\t\t\t\t\t<object\n\t\t\t\t\t\t\tclassName=\"wp-block-file__preview\"\n\t\t\t\t\t\t\tdata={ href }\n\t\t\t\t\t\t\ttype=\"application/pdf\"\n\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t'Embed of the selected PDF file.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ ! isSelected && (\n\t\t\t\t\t\t\t<div className=\"wp-block-file__preview-overlay\" />\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ResizableBox>\n\t\t\t\t) }\n\t\t\t\t<div className=\"wp-block-file__content-wrapper\">\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tidentifier=\"fileName\"\n\t\t\t\t\t\ttagName=\"a\"\n\t\t\t\t\t\tvalue={ fileName }\n\t\t\t\t\t\tplaceholder={ __( 'Write file name…' ) }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tonChange={ ( text ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tfileName: removeAnchorTag( text ),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thref={ textLinkHref }\n\t\t\t\t\t/>\n\t\t\t\t\t{ showDownloadButton && (\n\t\t\t\t\t\t<div className=\"wp-block-file__button-richtext-wrapper\">\n\t\t\t\t\t\t\t{ /* Using RichText here instead of PlainText so that it can be styled like a button. */ }\n\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\tidentifier=\"downloadButtonText\"\n\t\t\t\t\t\t\t\ttagName=\"div\" // Must be block-level or else cursor disappears.\n\t\t\t\t\t\t\t\taria-label={ __( 'Download button text' ) }\n\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t'wp-block-file__button',\n\t\t\t\t\t\t\t\t\t__experimentalGetElementClassName(\n\t\t\t\t\t\t\t\t\t\t'button'\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\tvalue={ downloadButtonText }\n\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\tplaceholder={ __( 'Add text…' ) }\n\t\t\t\t\t\t\t\tonChange={ ( text ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tdownloadButtonText:\n\t\t\t\t\t\t\t\t\t\t\tremoveAnchorTag( text ),\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/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default FileEdit;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,6BAA6B,IAAIC,mBAAmB,EACpDC,YAAY,EACZC,aAAa,QACP,uBAAuB;AAC9B,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,aAAa,EACbC,SAAS,EACTC,gBAAgB,EAChBC,gBAAgB,EAChBC,QAAQ,EACRC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,iCAAiC,QAC3B,yB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I,CACf,uBAAuB,EACvBgB,iCAAiC,CAChC,QACD,CACD,CAAG;YACHsH,KAAK,EAAG5E,kBAAoB;YAC5B8E,4BAA4B;YAC5BD,WAAW,EAAGnH,EAAE,CAAE,WAAY,CAAG;YACjCoD,QAAQ,EAAKjC,IAAI,IAChBW,aAAa,CAAE;cACdQ,kBAAkB,EACjB9B,eAAe,CAAEW,IAAK;YACxB,CAAE;UACF,CACD;QAAC,CACE,CACL;MAAA,CACG,CAAC;IAAA,CACF,CAAC;EAAA,CACL,CAAC;AAEL;AAEA,eAAeQ,QAAQ","ignoreList":[]}
|
|
@@ -21,10 +21,24 @@ const transforms = {
|
|
|
21
21
|
const blobURL = createBlobURL(file);
|
|
22
22
|
|
|
23
23
|
// File will be uploaded in componentDidMount()
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
if (file.type.startsWith('video/')) {
|
|
25
|
+
blocks.push(createBlock('core/video', {
|
|
26
|
+
blob: createBlobURL(file)
|
|
27
|
+
}));
|
|
28
|
+
} else if (file.type.startsWith('image/')) {
|
|
29
|
+
blocks.push(createBlock('core/image', {
|
|
30
|
+
blob: createBlobURL(file)
|
|
31
|
+
}));
|
|
32
|
+
} else if (file.type.startsWith('audio/')) {
|
|
33
|
+
blocks.push(createBlock('core/audio', {
|
|
34
|
+
blob: createBlobURL(file)
|
|
35
|
+
}));
|
|
36
|
+
} else {
|
|
37
|
+
blocks.push(createBlock('core/file', {
|
|
38
|
+
blob: blobURL,
|
|
39
|
+
fileName: file.name
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
28
42
|
});
|
|
29
43
|
return blocks;
|
|
30
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createBlobURL","createBlock","select","store","coreStore","getFilename","transforms","from","type","isMatch","files","length","priority","transform","blocks","forEach","file","blobURL","push","blob","fileName","name","attributes","href","src","caption","textLinkHref","id","anchor","url","to","getMedia","media","mime_type","includes"],"sources":["@wordpress/block-library/src/file/transforms.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlobURL } from '@wordpress/blob';\nimport { createBlock } from '@wordpress/blocks';\nimport { select } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { getFilename } from '@wordpress/url';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'files',\n\t\t\tisMatch( files ) {\n\t\t\t\treturn files.length > 0;\n\t\t\t},\n\t\t\t// We define a lower priorty (higher number) than the default of 10. This\n\t\t\t// ensures that the File block is only created as a fallback.\n\t\t\tpriority: 15,\n\t\t\ttransform: ( files ) => {\n\t\t\t\tconst blocks = [];\n\n\t\t\t\tfiles.forEach( ( file ) => {\n\t\t\t\t\tconst blobURL = createBlobURL( file );\n\n\t\t\t\t\t// File will be uploaded in componentDidMount()\n\t\t\t\t\tblocks.push(\n\t\t\t\t\t\tcreateBlock( 'core/file', {\n\t\t\t\t\t\t\tblob: blobURL,\n\t\t\t\t\t\t\tfileName: file.name,\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t} );\n\n\t\t\t\treturn blocks;\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/audio' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/file', {\n\t\t\t\t\thref: attributes.src,\n\t\t\t\t\tfileName: attributes.caption,\n\t\t\t\t\ttextLinkHref: attributes.src,\n\t\t\t\t\tid: attributes.id,\n\t\t\t\t\tanchor: attributes.anchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/video' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/file', {\n\t\t\t\t\thref: attributes.src,\n\t\t\t\t\tfileName: attributes.caption,\n\t\t\t\t\ttextLinkHref: attributes.src,\n\t\t\t\t\tid: attributes.id,\n\t\t\t\t\tanchor: attributes.anchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/image' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/file', {\n\t\t\t\t\thref: attributes.url,\n\t\t\t\t\tfileName:\n\t\t\t\t\t\tattributes.caption || getFilename( attributes.url ),\n\t\t\t\t\ttextLinkHref: attributes.url,\n\t\t\t\t\tid: attributes.id,\n\t\t\t\t\tanchor: attributes.anchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/audio' ],\n\t\t\tisMatch: ( { id } ) => {\n\t\t\t\tif ( ! id ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tconst { getMedia } = select( coreStore );\n\t\t\t\tconst media = getMedia( id );\n\t\t\t\treturn !! media && media.mime_type.includes( 'audio' );\n\t\t\t},\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/audio', {\n\t\t\t\t\tsrc: attributes.href,\n\t\t\t\t\tcaption: attributes.fileName,\n\t\t\t\t\tid: attributes.id,\n\t\t\t\t\tanchor: attributes.anchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/video' ],\n\t\t\tisMatch: ( { id } ) => {\n\t\t\t\tif ( ! id ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tconst { getMedia } = select( coreStore );\n\t\t\t\tconst media = getMedia( id );\n\t\t\t\treturn !! media && media.mime_type.includes( 'video' );\n\t\t\t},\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/video', {\n\t\t\t\t\tsrc: attributes.href,\n\t\t\t\t\tcaption: attributes.fileName,\n\t\t\t\t\tid: attributes.id,\n\t\t\t\t\tanchor: attributes.anchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/image' ],\n\t\t\tisMatch: ( { id } ) => {\n\t\t\t\tif ( ! id ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tconst { getMedia } = select( coreStore );\n\t\t\t\tconst media = getMedia( id );\n\t\t\t\treturn !! media && media.mime_type.includes( 'image' );\n\t\t\t},\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/image', {\n\t\t\t\t\turl: attributes.href,\n\t\t\t\t\tcaption: attributes.fileName,\n\t\t\t\t\tid: attributes.id,\n\t\t\t\t\tanchor: attributes.anchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,WAAW,QAAQ,gBAAgB;AAE5C,MAAMC,UAAU,GAAG;EAClBC,IAAI,EAAE,CACL;IACCC,IAAI,EAAE,OAAO;IACbC,OAAOA,CAAEC,KAAK,EAAG;MAChB,OAAOA,KAAK,CAACC,MAAM,GAAG,CAAC;IACxB,CAAC;IACD;IACA;IACAC,QAAQ,EAAE,EAAE;IACZC,SAAS,EAAIH,KAAK,IAAM;MACvB,MAAMI,MAAM,GAAG,EAAE;MAEjBJ,KAAK,CAACK,OAAO,CAAIC,IAAI,IAAM;QAC1B,MAAMC,OAAO,GAAGjB,aAAa,CAAEgB,IAAK,CAAC;;QAErC;
|
|
1
|
+
{"version":3,"names":["createBlobURL","createBlock","select","store","coreStore","getFilename","transforms","from","type","isMatch","files","length","priority","transform","blocks","forEach","file","blobURL","startsWith","push","blob","fileName","name","attributes","href","src","caption","textLinkHref","id","anchor","url","to","getMedia","media","mime_type","includes"],"sources":["@wordpress/block-library/src/file/transforms.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlobURL } from '@wordpress/blob';\nimport { createBlock } from '@wordpress/blocks';\nimport { select } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { getFilename } from '@wordpress/url';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'files',\n\t\t\tisMatch( files ) {\n\t\t\t\treturn files.length > 0;\n\t\t\t},\n\t\t\t// We define a lower priorty (higher number) than the default of 10. This\n\t\t\t// ensures that the File block is only created as a fallback.\n\t\t\tpriority: 15,\n\t\t\ttransform: ( files ) => {\n\t\t\t\tconst blocks = [];\n\n\t\t\t\tfiles.forEach( ( file ) => {\n\t\t\t\t\tconst blobURL = createBlobURL( file );\n\n\t\t\t\t\t// File will be uploaded in componentDidMount()\n\t\t\t\t\tif ( file.type.startsWith( 'video/' ) ) {\n\t\t\t\t\t\tblocks.push(\n\t\t\t\t\t\t\tcreateBlock( 'core/video', {\n\t\t\t\t\t\t\t\tblob: createBlobURL( file ),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if ( file.type.startsWith( 'image/' ) ) {\n\t\t\t\t\t\tblocks.push(\n\t\t\t\t\t\t\tcreateBlock( 'core/image', {\n\t\t\t\t\t\t\t\tblob: createBlobURL( file ),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if ( file.type.startsWith( 'audio/' ) ) {\n\t\t\t\t\t\tblocks.push(\n\t\t\t\t\t\t\tcreateBlock( 'core/audio', {\n\t\t\t\t\t\t\t\tblob: createBlobURL( file ),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tblocks.push(\n\t\t\t\t\t\t\tcreateBlock( 'core/file', {\n\t\t\t\t\t\t\t\tblob: blobURL,\n\t\t\t\t\t\t\t\tfileName: file.name,\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\n\t\t\t\treturn blocks;\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/audio' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/file', {\n\t\t\t\t\thref: attributes.src,\n\t\t\t\t\tfileName: attributes.caption,\n\t\t\t\t\ttextLinkHref: attributes.src,\n\t\t\t\t\tid: attributes.id,\n\t\t\t\t\tanchor: attributes.anchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/video' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/file', {\n\t\t\t\t\thref: attributes.src,\n\t\t\t\t\tfileName: attributes.caption,\n\t\t\t\t\ttextLinkHref: attributes.src,\n\t\t\t\t\tid: attributes.id,\n\t\t\t\t\tanchor: attributes.anchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/image' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/file', {\n\t\t\t\t\thref: attributes.url,\n\t\t\t\t\tfileName:\n\t\t\t\t\t\tattributes.caption || getFilename( attributes.url ),\n\t\t\t\t\ttextLinkHref: attributes.url,\n\t\t\t\t\tid: attributes.id,\n\t\t\t\t\tanchor: attributes.anchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/audio' ],\n\t\t\tisMatch: ( { id } ) => {\n\t\t\t\tif ( ! id ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tconst { getMedia } = select( coreStore );\n\t\t\t\tconst media = getMedia( id );\n\t\t\t\treturn !! media && media.mime_type.includes( 'audio' );\n\t\t\t},\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/audio', {\n\t\t\t\t\tsrc: attributes.href,\n\t\t\t\t\tcaption: attributes.fileName,\n\t\t\t\t\tid: attributes.id,\n\t\t\t\t\tanchor: attributes.anchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/video' ],\n\t\t\tisMatch: ( { id } ) => {\n\t\t\t\tif ( ! id ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tconst { getMedia } = select( coreStore );\n\t\t\t\tconst media = getMedia( id );\n\t\t\t\treturn !! media && media.mime_type.includes( 'video' );\n\t\t\t},\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/video', {\n\t\t\t\t\tsrc: attributes.href,\n\t\t\t\t\tcaption: attributes.fileName,\n\t\t\t\t\tid: attributes.id,\n\t\t\t\t\tanchor: attributes.anchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/image' ],\n\t\t\tisMatch: ( { id } ) => {\n\t\t\t\tif ( ! id ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tconst { getMedia } = select( coreStore );\n\t\t\t\tconst media = getMedia( id );\n\t\t\t\treturn !! media && media.mime_type.includes( 'image' );\n\t\t\t},\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/image', {\n\t\t\t\t\turl: attributes.href,\n\t\t\t\t\tcaption: attributes.fileName,\n\t\t\t\t\tid: attributes.id,\n\t\t\t\t\tanchor: attributes.anchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC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E,OAAO;IACbM,MAAM,EAAE,CAAE,YAAY,CAAE;IACxBL,OAAO,EAAEA,CAAE;MAAEmB;IAAG,CAAC,KAAM;MACtB,IAAK,CAAEA,EAAE,EAAG;QACX,OAAO,KAAK;MACb;MACA,MAAM;QAAEI;MAAS,CAAC,GAAG9B,MAAM,CAAEE,SAAU,CAAC;MACxC,MAAM6B,KAAK,GAAGD,QAAQ,CAAEJ,EAAG,CAAC;MAC5B,OAAO,CAAC,CAAEK,KAAK,IAAIA,KAAK,CAACC,SAAS,CAACC,QAAQ,CAAE,OAAQ,CAAC;IACvD,CAAC;IACDtB,SAAS,EAAIU,UAAU,IAAM;MAC5B,OAAOtB,WAAW,CAAE,YAAY,EAAE;QACjC6B,GAAG,EAAEP,UAAU,CAACC,IAAI;QACpBE,OAAO,EAAEH,UAAU,CAACF,QAAQ;QAC5BO,EAAE,EAAEL,UAAU,CAACK,EAAE;QACjBC,MAAM,EAAEN,UAAU,CAACM;MACpB,CAAE,CAAC;IACJ;EACD,CAAC;AAEH,CAAC;AAED,eAAevB,UAAU","ignoreList":[]}
|
|
@@ -74,9 +74,9 @@ function ClassicEdit({
|
|
|
74
74
|
const {
|
|
75
75
|
getMultiSelectedBlockClientIds
|
|
76
76
|
} = useSelect(blockEditorStore);
|
|
77
|
-
const
|
|
77
|
+
const didMountRef = useRef(false);
|
|
78
78
|
useEffect(() => {
|
|
79
|
-
if (!
|
|
79
|
+
if (!didMountRef.current) {
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
const editor = window.tinymce.get(`editor-${clientId}`);
|
|
@@ -93,7 +93,7 @@ function ClassicEdit({
|
|
|
93
93
|
baseURL,
|
|
94
94
|
suffix
|
|
95
95
|
} = window.wpEditorL10n.tinymce;
|
|
96
|
-
|
|
96
|
+
didMountRef.current = true;
|
|
97
97
|
window.tinymce.EditorManager.overrideDefaults({
|
|
98
98
|
base_url: baseURL,
|
|
99
99
|
suffix
|
|
@@ -205,7 +205,7 @@ function ClassicEdit({
|
|
|
205
205
|
return () => {
|
|
206
206
|
document.removeEventListener('readystatechange', onReadyStateChange);
|
|
207
207
|
wp.oldEditor.remove(`editor-${clientId}`);
|
|
208
|
-
|
|
208
|
+
didMountRef.current = false;
|
|
209
209
|
};
|
|
210
210
|
}, []);
|
|
211
211
|
function focus() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BlockControls","useBlockProps","store","blockEditorStore","debounce","useRefEffect","useSelect","ToolbarGroup","useEffect","useRef","useState","__","BACKSPACE","DELETE","F10","isKeyboardEvent","ConvertToBlocksButton","ModalEdit","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","wp","window","isTmceEmpty","editor","body","getBody","childNodes","length","test","innerText","textContent","FreeformEdit","props","clientId","canRemove","select","canRemoveBlock","isIframed","setIsIframed","ref","element","ownerDocument","document","children","ClassicEdit","attributes","content","setAttributes","onReplace","getMultiSelectedBlockClientIds","didMount","current","tinymce","get","currentContent","getContent","setContent","baseURL","suffix","wpEditorL10n","EditorManager","overrideDefaults","base_url","onSetup","bookmark","on","selection","getBookmark","scrollContainer","querySelector","scrollPosition","scrollTop","once","moveToBookmark","debouncedOnChange","value","_lastChange","cancel","event","primary","stopPropagation","keyCode","preventDefault","stopImmediatePropagation","altKey","rootNode","activeElement","blur","focus","initialize","settings","oldEditor","inline","content_css","fixed_toolbar_container","setup","onReadyStateChange","readyState","addEventListener","removeEventListener","remove","onToolbarKeyDown","nativeEvent","id","className","onClick","onKeyDown"],"sources":["@wordpress/block-library/src/freeform/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { debounce, useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { ToolbarGroup } from '@wordpress/components';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { BACKSPACE, DELETE, F10, isKeyboardEvent } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport ConvertToBlocksButton from './convert-to-blocks-button';\nimport ModalEdit from './modal';\n\nconst { wp } = window;\n\nfunction isTmceEmpty( editor ) {\n\t// When tinyMce is empty the content seems to be:\n\t// <p><br data-mce-bogus=\"1\"></p>\n\t// avoid expensive checks for large documents\n\tconst body = editor.getBody();\n\tif ( body.childNodes.length > 1 ) {\n\t\treturn false;\n\t} else if ( body.childNodes.length === 0 ) {\n\t\treturn true;\n\t}\n\tif ( body.childNodes[ 0 ].childNodes.length > 1 ) {\n\t\treturn false;\n\t}\n\treturn /^\\n?$/.test( body.innerText || body.textContent );\n}\n\nexport default function FreeformEdit( props ) {\n\tconst { clientId } = props;\n\tconst canRemove = useSelect(\n\t\t( select ) => select( blockEditorStore ).canRemoveBlock( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst [ isIframed, setIsIframed ] = useState( false );\n\tconst ref = useRefEffect( ( element ) => {\n\t\tsetIsIframed( element.ownerDocument !== document );\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t{ canRemove && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ConvertToBlocksButton clientId={ clientId } />\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<div { ...useBlockProps( { ref } ) }>\n\t\t\t\t{ isIframed ? (\n\t\t\t\t\t<ModalEdit { ...props } />\n\t\t\t\t) : (\n\t\t\t\t\t<ClassicEdit { ...props } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nfunction ClassicEdit( {\n\tclientId,\n\tattributes: { content },\n\tsetAttributes,\n\tonReplace,\n} ) {\n\tconst { getMultiSelectedBlockClientIds } = useSelect( blockEditorStore );\n\tconst didMount = useRef( false );\n\n\tuseEffect( () => {\n\t\tif ( ! didMount.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst editor = window.tinymce.get( `editor-${ clientId }` );\n\t\tif ( ! editor ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst currentContent = editor.getContent();\n\t\tif ( currentContent !== content ) {\n\t\t\teditor.setContent( content || '' );\n\t\t}\n\t}, [ clientId, content ] );\n\n\tuseEffect( () => {\n\t\tconst { baseURL, suffix } = window.wpEditorL10n.tinymce;\n\n\t\tdidMount.current = true;\n\n\t\twindow.tinymce.EditorManager.overrideDefaults( {\n\t\t\tbase_url: baseURL,\n\t\t\tsuffix,\n\t\t} );\n\n\t\tfunction onSetup( editor ) {\n\t\t\tlet bookmark;\n\n\t\t\tif ( content ) {\n\t\t\t\teditor.on( 'loadContent', () => editor.setContent( content ) );\n\t\t\t}\n\n\t\t\teditor.on( 'blur', () => {\n\t\t\t\tbookmark = editor.selection.getBookmark( 2, true );\n\t\t\t\t// There is an issue with Chrome and the editor.focus call in core at https://core.trac.wordpress.org/browser/trunk/src/js/_enqueues/lib/link.js#L451.\n\t\t\t\t// This causes a scroll to the top of editor content on return from some content updating dialogs so tracking\n\t\t\t\t// scroll position until this is fixed in core.\n\t\t\t\tconst scrollContainer = document.querySelector(\n\t\t\t\t\t'.interface-interface-skeleton__content'\n\t\t\t\t);\n\t\t\t\tconst scrollPosition = scrollContainer.scrollTop;\n\n\t\t\t\t// Only update attributes if we aren't multi-selecting blocks.\n\t\t\t\t// Updating during multi-selection can overwrite attributes of other blocks.\n\t\t\t\tif ( ! getMultiSelectedBlockClientIds()?.length ) {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tcontent: editor.getContent(),\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\teditor.once( 'focus', () => {\n\t\t\t\t\tif ( bookmark ) {\n\t\t\t\t\t\teditor.selection.moveToBookmark( bookmark );\n\t\t\t\t\t\tif ( scrollContainer.scrollTop !== scrollPosition ) {\n\t\t\t\t\t\t\tscrollContainer.scrollTop = scrollPosition;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\treturn false;\n\t\t\t} );\n\n\t\t\teditor.on( 'mousedown touchstart', () => {\n\t\t\t\tbookmark = null;\n\t\t\t} );\n\n\t\t\tconst debouncedOnChange = debounce( () => {\n\t\t\t\tconst value = editor.getContent();\n\n\t\t\t\tif ( value !== editor._lastChange ) {\n\t\t\t\t\teditor._lastChange = value;\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tcontent: value,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}, 250 );\n\t\t\teditor.on( 'Paste Change input Undo Redo', debouncedOnChange );\n\n\t\t\t// We need to cancel the debounce call because when we remove\n\t\t\t// the editor (onUnmount) this callback is executed in\n\t\t\t// another tick. This results in setting the content to empty.\n\t\t\teditor.on( 'remove', debouncedOnChange.cancel );\n\n\t\t\teditor.on( 'keydown', ( event ) => {\n\t\t\t\tif ( isKeyboardEvent.primary( event, 'z' ) ) {\n\t\t\t\t\t// Prevent the gutenberg undo kicking in so TinyMCE undo stack works as expected.\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t( event.keyCode === BACKSPACE ||\n\t\t\t\t\t\tevent.keyCode === DELETE ) &&\n\t\t\t\t\tisTmceEmpty( editor )\n\t\t\t\t) {\n\t\t\t\t\t// Delete the block.\n\t\t\t\t\tonReplace( [] );\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tevent.stopImmediatePropagation();\n\t\t\t\t}\n\n\t\t\t\tconst { altKey } = event;\n\t\t\t\t/*\n\t\t\t\t * Prevent Mousetrap from kicking in: TinyMCE already uses its own\n\t\t\t\t * `alt+f10` shortcut to focus its toolbar.\n\t\t\t\t */\n\t\t\t\tif ( altKey && event.keyCode === F10 ) {\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\teditor.on( 'init', () => {\n\t\t\t\tconst rootNode = editor.getBody();\n\n\t\t\t\t// Create the toolbar by refocussing the editor.\n\t\t\t\tif ( rootNode.ownerDocument.activeElement === rootNode ) {\n\t\t\t\t\trootNode.blur();\n\t\t\t\t\teditor.focus();\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\tfunction initialize() {\n\t\t\tconst { settings } = window.wpEditorL10n.tinymce;\n\t\t\twp.oldEditor.initialize( `editor-${ clientId }`, {\n\t\t\t\ttinymce: {\n\t\t\t\t\t...settings,\n\t\t\t\t\tinline: true,\n\t\t\t\t\tcontent_css: false,\n\t\t\t\t\tfixed_toolbar_container: `#toolbar-${ clientId }`,\n\t\t\t\t\tsetup: onSetup,\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\tfunction onReadyStateChange() {\n\t\t\tif ( document.readyState === 'complete' ) {\n\t\t\t\tinitialize();\n\t\t\t}\n\t\t}\n\n\t\tif ( document.readyState === 'complete' ) {\n\t\t\tinitialize();\n\t\t} else {\n\t\t\tdocument.addEventListener( 'readystatechange', onReadyStateChange );\n\t\t}\n\n\t\treturn () => {\n\t\t\tdocument.removeEventListener(\n\t\t\t\t'readystatechange',\n\t\t\t\tonReadyStateChange\n\t\t\t);\n\t\t\twp.oldEditor.remove( `editor-${ clientId }` );\n\t\t\tdidMount.current = false;\n\t\t};\n\t}, [] );\n\n\tfunction focus() {\n\t\tconst editor = window.tinymce.get( `editor-${ clientId }` );\n\t\tif ( editor ) {\n\t\t\teditor.focus();\n\t\t}\n\t}\n\n\tfunction onToolbarKeyDown( event ) {\n\t\t// Prevent WritingFlow from kicking in and allow arrows navigation on the toolbar.\n\t\tevent.stopPropagation();\n\t\t// Prevent Mousetrap from moving focus to the top toolbar when pressing `alt+f10` on this block toolbar.\n\t\tevent.nativeEvent.stopImmediatePropagation();\n\t}\n\n\t// Disable reasons:\n\t//\n\t// jsx-a11y/no-static-element-interactions\n\t// - the toolbar itself is non-interactive, but must capture events\n\t// from the KeyboardShortcuts component to stop their propagation.\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tkey=\"toolbar\"\n\t\t\t\tid={ `toolbar-${ clientId }` }\n\t\t\t\tclassName=\"block-library-classic__toolbar\"\n\t\t\t\tonClick={ focus }\n\t\t\t\tdata-placeholder={ __( 'Classic' ) }\n\t\t\t\tonKeyDown={ onToolbarKeyDown }\n\t\t\t/>\n\t\t\t<div\n\t\t\t\tkey=\"editor\"\n\t\t\t\tid={ `editor-${ clientId }` }\n\t\t\t\tclassName=\"wp-block-freeform block-library-rich-text__tinymce\"\n\t\t\t/>\n\t\t</>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,QAAQ,EAAEC,YAAY,QAAQ,oBAAoB;AAC3D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAChE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,MAAM,EAAEC,GAAG,EAAEC,eAAe,QAAQ,qBAAqB;;AAE7E;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,SAAS,MAAM,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEhC,MAAM;EAAEC;AAAG,CAAC,GAAGC,MAAM;AAErB,SAASC,WAAWA,CAAEC,MAAM,EAAG;EAC9B;EACA;EACA;EACA,MAAMC,IAAI,GAAGD,MAAM,CAACE,OAAO,CAAC,CAAC;EAC7B,IAAKD,IAAI,CAACE,UAAU,CAACC,MAAM,GAAG,CAAC,EAAG;IACjC,OAAO,KAAK;EACb,CAAC,MAAM,IAAKH,IAAI,CAACE,UAAU,CA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CACD,CAAC;EAEJ;AACD","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["BlockControls","useBlockProps","store","blockEditorStore","debounce","useRefEffect","useSelect","ToolbarGroup","useEffect","useRef","useState","__","BACKSPACE","DELETE","F10","isKeyboardEvent","ConvertToBlocksButton","ModalEdit","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","wp","window","isTmceEmpty","editor","body","getBody","childNodes","length","test","innerText","textContent","FreeformEdit","props","clientId","canRemove","select","canRemoveBlock","isIframed","setIsIframed","ref","element","ownerDocument","document","children","ClassicEdit","attributes","content","setAttributes","onReplace","getMultiSelectedBlockClientIds","didMountRef","current","tinymce","get","currentContent","getContent","setContent","baseURL","suffix","wpEditorL10n","EditorManager","overrideDefaults","base_url","onSetup","bookmark","on","selection","getBookmark","scrollContainer","querySelector","scrollPosition","scrollTop","once","moveToBookmark","debouncedOnChange","value","_lastChange","cancel","event","primary","stopPropagation","keyCode","preventDefault","stopImmediatePropagation","altKey","rootNode","activeElement","blur","focus","initialize","settings","oldEditor","inline","content_css","fixed_toolbar_container","setup","onReadyStateChange","readyState","addEventListener","removeEventListener","remove","onToolbarKeyDown","nativeEvent","id","className","onClick","onKeyDown"],"sources":["@wordpress/block-library/src/freeform/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { debounce, useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { ToolbarGroup } from '@wordpress/components';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { BACKSPACE, DELETE, F10, isKeyboardEvent } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport ConvertToBlocksButton from './convert-to-blocks-button';\nimport ModalEdit from './modal';\n\nconst { wp } = window;\n\nfunction isTmceEmpty( editor ) {\n\t// When tinyMce is empty the content seems to be:\n\t// <p><br data-mce-bogus=\"1\"></p>\n\t// avoid expensive checks for large documents\n\tconst body = editor.getBody();\n\tif ( body.childNodes.length > 1 ) {\n\t\treturn false;\n\t} else if ( body.childNodes.length === 0 ) {\n\t\treturn true;\n\t}\n\tif ( body.childNodes[ 0 ].childNodes.length > 1 ) {\n\t\treturn false;\n\t}\n\treturn /^\\n?$/.test( body.innerText || body.textContent );\n}\n\nexport default function FreeformEdit( props ) {\n\tconst { clientId } = props;\n\tconst canRemove = useSelect(\n\t\t( select ) => select( blockEditorStore ).canRemoveBlock( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst [ isIframed, setIsIframed ] = useState( false );\n\tconst ref = useRefEffect( ( element ) => {\n\t\tsetIsIframed( element.ownerDocument !== document );\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t{ canRemove && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ConvertToBlocksButton clientId={ clientId } />\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<div { ...useBlockProps( { ref } ) }>\n\t\t\t\t{ isIframed ? (\n\t\t\t\t\t<ModalEdit { ...props } />\n\t\t\t\t) : (\n\t\t\t\t\t<ClassicEdit { ...props } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nfunction ClassicEdit( {\n\tclientId,\n\tattributes: { content },\n\tsetAttributes,\n\tonReplace,\n} ) {\n\tconst { getMultiSelectedBlockClientIds } = useSelect( blockEditorStore );\n\tconst didMountRef = useRef( false );\n\n\tuseEffect( () => {\n\t\tif ( ! didMountRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst editor = window.tinymce.get( `editor-${ clientId }` );\n\t\tif ( ! editor ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst currentContent = editor.getContent();\n\t\tif ( currentContent !== content ) {\n\t\t\teditor.setContent( content || '' );\n\t\t}\n\t}, [ clientId, content ] );\n\n\tuseEffect( () => {\n\t\tconst { baseURL, suffix } = window.wpEditorL10n.tinymce;\n\n\t\tdidMountRef.current = true;\n\n\t\twindow.tinymce.EditorManager.overrideDefaults( {\n\t\t\tbase_url: baseURL,\n\t\t\tsuffix,\n\t\t} );\n\n\t\tfunction onSetup( editor ) {\n\t\t\tlet bookmark;\n\n\t\t\tif ( content ) {\n\t\t\t\teditor.on( 'loadContent', () => editor.setContent( content ) );\n\t\t\t}\n\n\t\t\teditor.on( 'blur', () => {\n\t\t\t\tbookmark = editor.selection.getBookmark( 2, true );\n\t\t\t\t// There is an issue with Chrome and the editor.focus call in core at https://core.trac.wordpress.org/browser/trunk/src/js/_enqueues/lib/link.js#L451.\n\t\t\t\t// This causes a scroll to the top of editor content on return from some content updating dialogs so tracking\n\t\t\t\t// scroll position until this is fixed in core.\n\t\t\t\tconst scrollContainer = document.querySelector(\n\t\t\t\t\t'.interface-interface-skeleton__content'\n\t\t\t\t);\n\t\t\t\tconst scrollPosition = scrollContainer.scrollTop;\n\n\t\t\t\t// Only update attributes if we aren't multi-selecting blocks.\n\t\t\t\t// Updating during multi-selection can overwrite attributes of other blocks.\n\t\t\t\tif ( ! getMultiSelectedBlockClientIds()?.length ) {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tcontent: editor.getContent(),\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\teditor.once( 'focus', () => {\n\t\t\t\t\tif ( bookmark ) {\n\t\t\t\t\t\teditor.selection.moveToBookmark( bookmark );\n\t\t\t\t\t\tif ( scrollContainer.scrollTop !== scrollPosition ) {\n\t\t\t\t\t\t\tscrollContainer.scrollTop = scrollPosition;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\treturn false;\n\t\t\t} );\n\n\t\t\teditor.on( 'mousedown touchstart', () => {\n\t\t\t\tbookmark = null;\n\t\t\t} );\n\n\t\t\tconst debouncedOnChange = debounce( () => {\n\t\t\t\tconst value = editor.getContent();\n\n\t\t\t\tif ( value !== editor._lastChange ) {\n\t\t\t\t\teditor._lastChange = value;\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tcontent: value,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}, 250 );\n\t\t\teditor.on( 'Paste Change input Undo Redo', debouncedOnChange );\n\n\t\t\t// We need to cancel the debounce call because when we remove\n\t\t\t// the editor (onUnmount) this callback is executed in\n\t\t\t// another tick. This results in setting the content to empty.\n\t\t\teditor.on( 'remove', debouncedOnChange.cancel );\n\n\t\t\teditor.on( 'keydown', ( event ) => {\n\t\t\t\tif ( isKeyboardEvent.primary( event, 'z' ) ) {\n\t\t\t\t\t// Prevent the gutenberg undo kicking in so TinyMCE undo stack works as expected.\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t( event.keyCode === BACKSPACE ||\n\t\t\t\t\t\tevent.keyCode === DELETE ) &&\n\t\t\t\t\tisTmceEmpty( editor )\n\t\t\t\t) {\n\t\t\t\t\t// Delete the block.\n\t\t\t\t\tonReplace( [] );\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tevent.stopImmediatePropagation();\n\t\t\t\t}\n\n\t\t\t\tconst { altKey } = event;\n\t\t\t\t/*\n\t\t\t\t * Prevent Mousetrap from kicking in: TinyMCE already uses its own\n\t\t\t\t * `alt+f10` shortcut to focus its toolbar.\n\t\t\t\t */\n\t\t\t\tif ( altKey && event.keyCode === F10 ) {\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\teditor.on( 'init', () => {\n\t\t\t\tconst rootNode = editor.getBody();\n\n\t\t\t\t// Create the toolbar by refocussing the editor.\n\t\t\t\tif ( rootNode.ownerDocument.activeElement === rootNode ) {\n\t\t\t\t\trootNode.blur();\n\t\t\t\t\teditor.focus();\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\tfunction initialize() {\n\t\t\tconst { settings } = window.wpEditorL10n.tinymce;\n\t\t\twp.oldEditor.initialize( `editor-${ clientId }`, {\n\t\t\t\ttinymce: {\n\t\t\t\t\t...settings,\n\t\t\t\t\tinline: true,\n\t\t\t\t\tcontent_css: false,\n\t\t\t\t\tfixed_toolbar_container: `#toolbar-${ clientId }`,\n\t\t\t\t\tsetup: onSetup,\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\tfunction onReadyStateChange() {\n\t\t\tif ( document.readyState === 'complete' ) {\n\t\t\t\tinitialize();\n\t\t\t}\n\t\t}\n\n\t\tif ( document.readyState === 'complete' ) {\n\t\t\tinitialize();\n\t\t} else {\n\t\t\tdocument.addEventListener( 'readystatechange', onReadyStateChange );\n\t\t}\n\n\t\treturn () => {\n\t\t\tdocument.removeEventListener(\n\t\t\t\t'readystatechange',\n\t\t\t\tonReadyStateChange\n\t\t\t);\n\t\t\twp.oldEditor.remove( `editor-${ clientId }` );\n\t\t\tdidMountRef.current = false;\n\t\t};\n\t}, [] );\n\n\tfunction focus() {\n\t\tconst editor = window.tinymce.get( `editor-${ clientId }` );\n\t\tif ( editor ) {\n\t\t\teditor.focus();\n\t\t}\n\t}\n\n\tfunction onToolbarKeyDown( event ) {\n\t\t// Prevent WritingFlow from kicking in and allow arrows navigation on the toolbar.\n\t\tevent.stopPropagation();\n\t\t// Prevent Mousetrap from moving focus to the top toolbar when pressing `alt+f10` on this block toolbar.\n\t\tevent.nativeEvent.stopImmediatePropagation();\n\t}\n\n\t// Disable reasons:\n\t//\n\t// jsx-a11y/no-static-element-interactions\n\t// - the toolbar itself is non-interactive, but must capture events\n\t// from the KeyboardShortcuts component to stop their propagation.\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tkey=\"toolbar\"\n\t\t\t\tid={ `toolbar-${ clientId }` }\n\t\t\t\tclassName=\"block-library-classic__toolbar\"\n\t\t\t\tonClick={ focus }\n\t\t\t\tdata-placeholder={ __( 'Classic' ) }\n\t\t\t\tonKeyDown={ onToolbarKeyDown }\n\t\t\t/>\n\t\t\t<div\n\t\t\t\tkey=\"editor\"\n\t\t\t\tid={ `editor-${ clientId }` }\n\t\t\t\tclassName=\"wp-block-freeform block-library-rich-text__tinymce\"\n\t\t\t/>\n\t\t</>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,QAAQ,EAAEC,YAAY,QAAQ,oBAAoB;AAC3D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAChE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,MAAM,EAAEC,GAAG,EAAEC,eAAe,QAAQ,qBAAqB;;AAE7E;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,SAAS,MAAM,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEhC,MAAM;EAAEC;AAAG,CAAC,GAAGC,MAAM;AAErB,SAASC,WAAWA,CAAEC,MAAM,EAAG;EAC9B;EACA;EACA;EACA,MAAMC,IAAI,GAAGD,MAAM,CAACE,OAAO,CAAC,CAAC;EAC7B,IAAKD,IAAI,CAACE,UAAU,CAACC,MAAM,GAAG,CAAC,EAAG;IACjC,OAAO,KAAK;EACb,CAAC,MAAM,IAAKH,IAAI,CAACE,UAAU,CAACC,MAAM,KAAK,CAAC,EAAG;IAC1C,OAAO,IAAI;EACZ;EACA,IAAKH,IAAI,CAACE,UAAU,CAAE,CAAC,CAAE,CAACA,UAAU,CAACC,MAAM,GAAG,CAAC,EAAG;IACjD,OAAO,KAAK;EACb;EACA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CAAC,MAAM;MACN/C,QAAQ,CAACwD,gBAAgB,CAAE,kBAAkB,EAAEF,kBAAmB,CAAC;IACpE;IAEA,OAAO,MAAM;MACZtD,QAAQ,CAACyD,mBAAmB,CAC3B,kBAAkB,EAClBH,kBACD,CAAC;MACD5E,EAAE,CAACuE,SAAS,CAACS,MAAM,CAAG,UAAUnE,QAAU,EAAE,CAAC;MAC7CiB,WAAW,CAACC,OAAO,GAAG,KAAK;IAC5B,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,SAASqC,KAAKA,CAAA,EAAG;IAChB,MAAMjE,MAAM,GAAGF,MAAM,CAAC+B,OAAO,CAACC,GAAG,CAAG,UAAUpB,QAAU,EAAE,CAAC;IAC3D,IAAKV,MAAM,EAAG;MACbA,MAAM,CAACiE,KAAK,CAAC,CAAC;IACf;EACD;EAEA,SAASa,gBAAgBA,CAAEvB,KAAK,EAAG;IAClC;IACAA,KAAK,CAACE,eAAe,CAAC,CAAC;IACvB;IACAF,KAAK,CAACwB,WAAW,CAACnB,wBAAwB,CAAC,CAAC;EAC7C;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA,oBACChE,KAAA,CAAAF,SAAA;IAAA0B,QAAA,gBACC5B,IAAA;MAECwF,EAAE,EAAI,WAAWtE,QAAU,EAAG;MAC9BuE,SAAS,EAAC,gCAAgC;MAC1CC,OAAO,EAAGjB,KAAO;MACjB,oBAAmBjF,EAAE,CAAE,SAAU,CAAG;MACpCmG,SAAS,EAAGL;IAAkB,GAL1B,SAMJ,CAAC,eACFtF,IAAA;MAECwF,EAAE,EAAI,UAAUtE,QAAU,EAAG;MAC7BuE,SAAS,EAAC;IAAoD,GAF1D,QAGJ,CAAC;EAAA,CACD,CAAC;EAEJ;AACD","ignoreList":[]}
|
|
@@ -21,6 +21,7 @@ function ModalAuxiliaryActions({
|
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
return /*#__PURE__*/_jsx(Button, {
|
|
24
|
+
size: "small",
|
|
24
25
|
onClick: onClick,
|
|
25
26
|
icon: fullscreen,
|
|
26
27
|
isPressed: isModalFullScreen,
|
|
@@ -107,12 +108,14 @@ export default function ModalEdit(props) {
|
|
|
107
108
|
expanded: false,
|
|
108
109
|
children: [/*#__PURE__*/_jsx(FlexItem, {
|
|
109
110
|
children: /*#__PURE__*/_jsx(Button, {
|
|
111
|
+
__next40pxDefaultSize: true,
|
|
110
112
|
variant: "tertiary",
|
|
111
113
|
onClick: onClose,
|
|
112
114
|
children: __('Cancel')
|
|
113
115
|
})
|
|
114
116
|
}), /*#__PURE__*/_jsx(FlexItem, {
|
|
115
117
|
children: /*#__PURE__*/_jsx(Button, {
|
|
118
|
+
__next40pxDefaultSize: true,
|
|
116
119
|
variant: "primary",
|
|
117
120
|
onClick: () => {
|
|
118
121
|
setAttributes({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BlockControls","store","ToolbarGroup","ToolbarButton","Modal","Button","Flex","FlexItem","useEffect","useState","RawHTML","__","useSelect","fullscreen","useViewportMatch","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","ModalAuxiliaryActions","onClick","isModalFullScreen","isMobileViewport","icon","isPressed","label","ClassicEdit","props","styles","select","getSettings","baseURL","suffix","settings","window","wpEditorL10n","tinymce","EditorManager","overrideDefaults","base_url","wp","oldEditor","initialize","id","setup","editor","on","doc","getDoc","forEach","css","styleEl","createElement","innerHTML","head","appendChild","remove","ModalEdit","clientId","attributes","content","setAttributes","onReplace","isOpen","setOpen","setIsModalFullScreen","onClose","children","title","onRequestClose","shouldCloseOnClickOutside","overlayClassName","isFullScreen","className","headerActions","defaultValue","justify","expanded","variant","getContent"],"sources":["@wordpress/block-library/src/freeform/modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BlockControls, store } from '@wordpress/block-editor';\nimport {\n\tToolbarGroup,\n\tToolbarButton,\n\tModal,\n\tButton,\n\tFlex,\n\tFlexItem,\n} from '@wordpress/components';\nimport { useEffect, useState, RawHTML } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { fullscreen } from '@wordpress/icons';\nimport { useViewportMatch } from '@wordpress/compose';\n\nfunction ModalAuxiliaryActions( { onClick, isModalFullScreen } ) {\n\t// 'small' to match the rules in editor.scss.\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tif ( isMobileViewport ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\tonClick={ onClick }\n\t\t\ticon={ fullscreen }\n\t\t\tisPressed={ isModalFullScreen }\n\t\t\tlabel={\n\t\t\t\tisModalFullScreen\n\t\t\t\t\t? __( 'Exit fullscreen' )\n\t\t\t\t\t: __( 'Enter fullscreen' )\n\t\t\t}\n\t\t/>\n\t);\n}\n\nfunction ClassicEdit( props ) {\n\tconst styles = useSelect(\n\t\t( select ) => select( store ).getSettings().styles\n\t);\n\tuseEffect( () => {\n\t\tconst { baseURL, suffix, settings } = window.wpEditorL10n.tinymce;\n\n\t\twindow.tinymce.EditorManager.overrideDefaults( {\n\t\t\tbase_url: baseURL,\n\t\t\tsuffix,\n\t\t} );\n\n\t\twindow.wp.oldEditor.initialize( props.id, {\n\t\t\ttinymce: {\n\t\t\t\t...settings,\n\t\t\t\tsetup( editor ) {\n\t\t\t\t\teditor.on( 'init', () => {\n\t\t\t\t\t\tconst doc = editor.getDoc();\n\t\t\t\t\t\tstyles.forEach( ( { css } ) => {\n\t\t\t\t\t\t\tconst styleEl = doc.createElement( 'style' );\n\t\t\t\t\t\t\tstyleEl.innerHTML = css;\n\t\t\t\t\t\t\tdoc.head.appendChild( styleEl );\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} );\n\n\t\treturn () => {\n\t\t\twindow.wp.oldEditor.remove( props.id );\n\t\t};\n\t}, [] );\n\n\treturn <textarea { ...props } />;\n}\n\nexport default function ModalEdit( props ) {\n\tconst {\n\t\tclientId,\n\t\tattributes: { content },\n\t\tsetAttributes,\n\t\tonReplace,\n\t} = props;\n\tconst [ isOpen, setOpen ] = useState( false );\n\tconst [ isModalFullScreen, setIsModalFullScreen ] = useState( false );\n\tconst id = `editor-${ clientId }`;\n\n\tconst onClose = () => ( content ? setOpen( false ) : onReplace( [] ) );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton onClick={ () => setOpen( true ) }>\n\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t</ToolbarButton>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ content && <RawHTML>{ content }</RawHTML> }\n\t\t\t{ ( isOpen || ! content ) && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Classic Editor' ) }\n\t\t\t\t\tonRequestClose={ onClose }\n\t\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t\t\toverlayClassName=\"block-editor-freeform-modal\"\n\t\t\t\t\tisFullScreen={ isModalFullScreen }\n\t\t\t\t\tclassName=\"block-editor-freeform-modal__content\"\n\t\t\t\t\theaderActions={\n\t\t\t\t\t\t<ModalAuxiliaryActions\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\tsetIsModalFullScreen( ! isModalFullScreen )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisModalFullScreen={ isModalFullScreen }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<ClassicEdit id={ id } defaultValue={ content } />\n\t\t\t\t\t<Flex\n\t\t\t\t\t\tclassName=\"block-editor-freeform-modal__actions\"\n\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t>\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<Button
|
|
1
|
+
{"version":3,"names":["BlockControls","store","ToolbarGroup","ToolbarButton","Modal","Button","Flex","FlexItem","useEffect","useState","RawHTML","__","useSelect","fullscreen","useViewportMatch","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","ModalAuxiliaryActions","onClick","isModalFullScreen","isMobileViewport","size","icon","isPressed","label","ClassicEdit","props","styles","select","getSettings","baseURL","suffix","settings","window","wpEditorL10n","tinymce","EditorManager","overrideDefaults","base_url","wp","oldEditor","initialize","id","setup","editor","on","doc","getDoc","forEach","css","styleEl","createElement","innerHTML","head","appendChild","remove","ModalEdit","clientId","attributes","content","setAttributes","onReplace","isOpen","setOpen","setIsModalFullScreen","onClose","children","title","onRequestClose","shouldCloseOnClickOutside","overlayClassName","isFullScreen","className","headerActions","defaultValue","justify","expanded","__next40pxDefaultSize","variant","getContent"],"sources":["@wordpress/block-library/src/freeform/modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BlockControls, store } from '@wordpress/block-editor';\nimport {\n\tToolbarGroup,\n\tToolbarButton,\n\tModal,\n\tButton,\n\tFlex,\n\tFlexItem,\n} from '@wordpress/components';\nimport { useEffect, useState, RawHTML } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { fullscreen } from '@wordpress/icons';\nimport { useViewportMatch } from '@wordpress/compose';\n\nfunction ModalAuxiliaryActions( { onClick, isModalFullScreen } ) {\n\t// 'small' to match the rules in editor.scss.\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tif ( isMobileViewport ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\tsize=\"small\"\n\t\t\tonClick={ onClick }\n\t\t\ticon={ fullscreen }\n\t\t\tisPressed={ isModalFullScreen }\n\t\t\tlabel={\n\t\t\t\tisModalFullScreen\n\t\t\t\t\t? __( 'Exit fullscreen' )\n\t\t\t\t\t: __( 'Enter fullscreen' )\n\t\t\t}\n\t\t/>\n\t);\n}\n\nfunction ClassicEdit( props ) {\n\tconst styles = useSelect(\n\t\t( select ) => select( store ).getSettings().styles\n\t);\n\tuseEffect( () => {\n\t\tconst { baseURL, suffix, settings } = window.wpEditorL10n.tinymce;\n\n\t\twindow.tinymce.EditorManager.overrideDefaults( {\n\t\t\tbase_url: baseURL,\n\t\t\tsuffix,\n\t\t} );\n\n\t\twindow.wp.oldEditor.initialize( props.id, {\n\t\t\ttinymce: {\n\t\t\t\t...settings,\n\t\t\t\tsetup( editor ) {\n\t\t\t\t\teditor.on( 'init', () => {\n\t\t\t\t\t\tconst doc = editor.getDoc();\n\t\t\t\t\t\tstyles.forEach( ( { css } ) => {\n\t\t\t\t\t\t\tconst styleEl = doc.createElement( 'style' );\n\t\t\t\t\t\t\tstyleEl.innerHTML = css;\n\t\t\t\t\t\t\tdoc.head.appendChild( styleEl );\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} );\n\n\t\treturn () => {\n\t\t\twindow.wp.oldEditor.remove( props.id );\n\t\t};\n\t}, [] );\n\n\treturn <textarea { ...props } />;\n}\n\nexport default function ModalEdit( props ) {\n\tconst {\n\t\tclientId,\n\t\tattributes: { content },\n\t\tsetAttributes,\n\t\tonReplace,\n\t} = props;\n\tconst [ isOpen, setOpen ] = useState( false );\n\tconst [ isModalFullScreen, setIsModalFullScreen ] = useState( false );\n\tconst id = `editor-${ clientId }`;\n\n\tconst onClose = () => ( content ? setOpen( false ) : onReplace( [] ) );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton onClick={ () => setOpen( true ) }>\n\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t</ToolbarButton>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ content && <RawHTML>{ content }</RawHTML> }\n\t\t\t{ ( isOpen || ! content ) && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Classic Editor' ) }\n\t\t\t\t\tonRequestClose={ onClose }\n\t\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t\t\toverlayClassName=\"block-editor-freeform-modal\"\n\t\t\t\t\tisFullScreen={ isModalFullScreen }\n\t\t\t\t\tclassName=\"block-editor-freeform-modal__content\"\n\t\t\t\t\theaderActions={\n\t\t\t\t\t\t<ModalAuxiliaryActions\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\tsetIsModalFullScreen( ! isModalFullScreen )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisModalFullScreen={ isModalFullScreen }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<ClassicEdit id={ id } defaultValue={ content } />\n\t\t\t\t\t<Flex\n\t\t\t\t\t\tclassName=\"block-editor-freeform-modal__actions\"\n\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t>\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcontent:\n\t\t\t\t\t\t\t\t\t\t\twindow.wp.oldEditor.getContent(\n\t\t\t\t\t\t\t\t\t\t\t\tid\n\t\t\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\tsetOpen( false );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t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AG,KAAO;QAAAV,QAAA,gBAElBtD,IAAA,CAACT,QAAQ;UAAA+D,QAAA,eACRtD,IAAA,CAACX,MAAM;YACN4E,qBAAqB;YACrBC,OAAO,EAAC,UAAU;YAClB5D,OAAO,EAAG+C,OAAS;YAAAC,QAAA,EAEjB3D,EAAE,CAAE,QAAS;UAAC,CACT;QAAC,CACA,CAAC,eACXK,IAAA,CAACT,QAAQ;UAAA+D,QAAA,eACRtD,IAAA,CAACX,MAAM;YACN4E,qBAAqB;YACrBC,OAAO,EAAC,SAAS;YACjB5D,OAAO,EAAGA,CAAA,KAAM;cACf0C,aAAa,CAAE;gBACdD,OAAO,EACN1B,MAAM,CAACM,EAAE,CAACC,SAAS,CAACuC,UAAU,CAC7BrC,EACD;cACF,CAAE,CAAC;cACHqB,OAAO,CAAE,KAAM,CAAC;YACjB,CAAG;YAAAG,QAAA,EAED3D,EAAE,CAAE,MAAO;UAAC,CACP;QAAC,CACA,CAAC;MAAA,CACN,CAAC;IAAA,CACD,CACP;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
|
|
@@ -19,15 +19,9 @@ export default function HomeEdit({
|
|
|
19
19
|
setAttributes,
|
|
20
20
|
context
|
|
21
21
|
}) {
|
|
22
|
-
const {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const {
|
|
26
|
-
getUnstableBase // Site index.
|
|
27
|
-
} = select(coreStore);
|
|
28
|
-
return {
|
|
29
|
-
homeUrl: getUnstableBase()?.home
|
|
30
|
-
};
|
|
22
|
+
const homeUrl = useSelect(select => {
|
|
23
|
+
// Site index.
|
|
24
|
+
return select(coreStore).getEntityRecord('root', '__unstableBase')?.home;
|
|
31
25
|
}, []);
|
|
32
26
|
const {
|
|
33
27
|
__unstableMarkNextChangeAsNotPersistent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","RichText","useBlockProps","store","blockEditorStore","__","useSelect","useDispatch","coreStore","useEffect","jsx","_jsx","Fragment","_Fragment","preventDefault","event","HomeEdit","attributes","setAttributes","context","homeUrl","select","
|
|
1
|
+
{"version":3,"names":["clsx","RichText","useBlockProps","store","blockEditorStore","__","useSelect","useDispatch","coreStore","useEffect","jsx","_jsx","Fragment","_Fragment","preventDefault","event","HomeEdit","attributes","setAttributes","context","homeUrl","select","getEntityRecord","home","__unstableMarkNextChangeAsNotPersistent","textColor","backgroundColor","style","blockProps","className","color","text","background","label","undefined","children","href","onClick","identifier","value","onChange","labelValue","placeholder","withoutInteractiveFormatting","allowedFormats"],"sources":["@wordpress/block-library/src/home-link/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useEffect } from '@wordpress/element';\n\nconst preventDefault = ( event ) => event.preventDefault();\n\nexport default function HomeEdit( { attributes, setAttributes, context } ) {\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\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { textColor, backgroundColor, style } = context;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'has-text-color': !! textColor || !! style?.color?.text,\n\t\t\t[ `has-${ textColor }-color` ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || !! style?.color?.background,\n\t\t\t[ `has-${ backgroundColor }-background-color` ]: !! backgroundColor,\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: style?.color?.text,\n\t\t\tbackgroundColor: style?.color?.background,\n\t\t},\n\t} );\n\n\tconst { label } = attributes;\n\n\tuseEffect( () => {\n\t\tif ( label === undefined ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { label: __( 'Home' ) } );\n\t\t}\n\t}, [ label ] );\n\n\treturn (\n\t\t<>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<a\n\t\t\t\t\tclassName=\"wp-block-home-link__content wp-block-navigation-item__content\"\n\t\t\t\t\thref={ homeUrl }\n\t\t\t\t\tonClick={ preventDefault }\n\t\t\t\t>\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\tclassName=\"wp-block-home-link__label\"\n\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\taria-label={ __( 'Home link text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add home link' ) }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tallowedFormats={ [\n\t\t\t\t\t\t\t'core/bold',\n\t\t\t\t\t\t\t'core/italic',\n\t\t\t\t\t\t\t'core/image',\n\t\t\t\t\t\t\t'core/strikethrough',\n\t\t\t\t\t\t] }\n\t\t\t\t\t/>\n\t\t\t\t</a>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,QAAQ,EACRC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASJ,KAAK,IAAIK,SAAS,QAAQ,sBAAsB;AACzD,SAASC,SAAS,QAAQ,oBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAE/C,MAAMC,cAAc,GAAKC,KAAK,IAAMA,KAAK,CAACD,cAAc,C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