@wordpress/block-library 8.13.0 → 8.15.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 +4 -0
- package/build/archives/index.js +5 -1
- package/build/archives/index.js.map +1 -1
- package/build/audio/index.js +5 -1
- package/build/audio/index.js.map +1 -1
- package/build/avatar/edit.js +1 -0
- package/build/avatar/edit.js.map +1 -1
- package/build/avatar/index.js +1 -1
- package/build/block/edit.js +1 -1
- package/build/block/edit.js.map +1 -1
- package/build/block/edit.native.js +6 -9
- package/build/block/edit.native.js.map +1 -1
- package/build/block/index.js +2 -1
- package/build/block/index.js.map +1 -1
- package/build/buttons/edit.js +7 -3
- package/build/buttons/edit.js.map +1 -1
- package/build/categories/index.js +5 -1
- package/build/categories/index.js.map +1 -1
- package/build/code/index.js +5 -1
- package/build/code/index.js.map +1 -1
- package/build/column/edit.native.js +1 -4
- package/build/column/edit.native.js.map +1 -1
- package/build/column/index.js +1 -0
- package/build/column/index.js.map +1 -1
- package/build/columns/edit.js +1 -0
- package/build/columns/edit.js.map +1 -1
- package/build/comment-author-avatar/edit.js +1 -0
- package/build/comment-author-avatar/edit.js.map +1 -1
- package/build/comments/index.js +1 -0
- package/build/comments/index.js.map +1 -1
- package/build/cover/deprecated.js +4 -2
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +2 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/index.js +1 -0
- package/build/cover/index.js.map +1 -1
- package/build/details/index.js +5 -1
- package/build/details/index.js.map +1 -1
- package/build/embed/embed-placeholder.native.js +37 -13
- package/build/embed/embed-placeholder.native.js.map +1 -1
- package/build/embed/util.js +9 -8
- package/build/embed/util.js.map +1 -1
- package/build/file/inspector.js +1 -0
- package/build/file/inspector.js.map +1 -1
- package/build/file/{interactivity.js → view-interactivity.js} +6 -2
- package/build/file/view-interactivity.js.map +1 -0
- package/build/footnotes/edit.js +20 -1
- package/build/footnotes/edit.js.map +1 -1
- package/build/footnotes/format.js +19 -16
- package/build/footnotes/format.js.map +1 -1
- package/build/footnotes/index.js +0 -1
- package/build/footnotes/index.js.map +1 -1
- package/build/gallery/edit.js +1 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/index.js +3 -1
- package/build/gallery/index.js.map +1 -1
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/index.js +5 -1
- package/build/heading/index.js.map +1 -1
- package/build/heading/transforms.js +5 -1
- package/build/heading/transforms.js.map +1 -1
- package/build/image/deprecated.js +453 -175
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.js +0 -4
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +96 -43
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +6 -0
- package/build/image/index.js.map +1 -1
- package/build/image/save.js +8 -1
- package/build/image/save.js.map +1 -1
- package/build/image/utils.js +18 -0
- package/build/image/utils.js.map +1 -1
- package/build/image/{interactivity.js → view-interactivity.js} +86 -44
- package/build/image/view-interactivity.js.map +1 -0
- package/build/index.js +12 -3
- package/build/index.js.map +1 -1
- package/build/latest-comments/edit.js +1 -0
- package/build/latest-comments/edit.js.map +1 -1
- package/build/latest-posts/edit.js +2 -0
- package/build/latest-posts/edit.js.map +1 -1
- package/build/list/edit.js +4 -4
- package/build/list/edit.js.map +1 -1
- package/build/list/index.js +5 -1
- package/build/list/index.js.map +1 -1
- package/build/list-item/utils.js +6 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/media-text/index.js +1 -0
- package/build/media-text/index.js.map +1 -1
- package/build/media-text/media-container.native.js +2 -1
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/missing/edit.js +22 -8
- package/build/missing/edit.js.map +1 -1
- package/build/missing/edit.native.js +7 -5
- package/build/missing/edit.native.js.map +1 -1
- package/build/navigation/constants.js +10 -4
- package/build/navigation/constants.js.map +1 -1
- package/build/navigation/edit/index.js +17 -3
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +2 -2
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +0 -1
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +2 -2
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +10 -15
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +33 -45
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation/view-interactivity.js +185 -0
- package/build/navigation/view-interactivity.js.map +1 -0
- package/build/navigation-link/edit.js +12 -18
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/link-ui.js +12 -2
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/navigation-submenu/edit.js +2 -2
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +3 -3
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/edit.js +34 -39
- package/build/page-list/edit.js.map +1 -1
- package/build/page-list/use-convert-to-navigation-links.js +2 -15
- package/build/page-list/use-convert-to-navigation-links.js.map +1 -1
- package/build/paragraph/index.js +1 -0
- package/build/paragraph/index.js.map +1 -1
- package/build/paragraph/transforms.js +1 -0
- package/build/paragraph/transforms.js.map +1 -1
- package/build/post-comments-form/index.js +1 -0
- package/build/post-comments-form/index.js.map +1 -1
- package/build/post-navigation-link/index.js +1 -0
- package/build/post-navigation-link/index.js.map +1 -1
- package/build/post-time-to-read/index.js +5 -1
- package/build/post-time-to-read/index.js.map +1 -1
- package/build/query-pagination/edit.js +1 -1
- package/build/query-pagination/edit.js.map +1 -1
- package/build/query-pagination-numbers/index.js +1 -1
- package/build/query-title/edit.js +43 -1
- package/build/query-title/edit.js.map +1 -1
- package/build/quote/index.js +1 -0
- package/build/quote/index.js.map +1 -1
- package/build/quote/transforms.js +8 -0
- package/build/quote/transforms.js.map +1 -1
- package/build/rss/edit.js +3 -0
- package/build/rss/edit.js.map +1 -1
- package/build/search/edit.js +4 -3
- package/build/search/edit.js.map +1 -1
- package/build/search/index.js +1 -0
- package/build/search/index.js.map +1 -1
- package/build/site-logo/edit.js +1 -0
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-logo/index.js +5 -1
- package/build/site-logo/index.js.map +1 -1
- package/build/site-tagline/icon.js +1 -1
- package/build/site-tagline/icon.js.map +1 -1
- package/build/site-tagline/index.js +5 -1
- package/build/site-tagline/index.js.map +1 -1
- package/build/site-title/index.js +5 -1
- package/build/site-title/index.js.map +1 -1
- package/build/social-links/index.js +3 -1
- package/build/social-links/index.js.map +1 -1
- package/build/table/index.js +5 -1
- package/build/table/index.js.map +1 -1
- package/build/tag-cloud/edit.js +1 -0
- package/build/tag-cloud/edit.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/term-description/index.js +1 -0
- package/build/term-description/index.js.map +1 -1
- package/build/text-columns/edit.js +1 -0
- package/build/text-columns/edit.js.map +1 -1
- package/build/verse/index.js +5 -1
- package/build/verse/index.js.map +1 -1
- package/build/video/deprecated.js +5 -1
- package/build/video/deprecated.js.map +1 -1
- package/build/video/index.js +5 -1
- package/build/video/index.js.map +1 -1
- package/build-module/archives/index.js +5 -1
- package/build-module/archives/index.js.map +1 -1
- package/build-module/audio/index.js +5 -1
- package/build-module/audio/index.js.map +1 -1
- package/build-module/avatar/edit.js +1 -0
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/avatar/index.js +1 -1
- package/build-module/block/edit.js +1 -1
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/edit.native.js +7 -9
- package/build-module/block/edit.native.js.map +1 -1
- package/build-module/block/index.js +2 -1
- package/build-module/block/index.js.map +1 -1
- package/build-module/buttons/edit.js +7 -3
- package/build-module/buttons/edit.js.map +1 -1
- package/build-module/categories/index.js +5 -1
- package/build-module/categories/index.js.map +1 -1
- package/build-module/code/index.js +5 -1
- package/build-module/code/index.js.map +1 -1
- package/build-module/column/edit.native.js +1 -4
- package/build-module/column/edit.native.js.map +1 -1
- package/build-module/column/index.js +1 -0
- package/build-module/column/index.js.map +1 -1
- package/build-module/columns/edit.js +1 -0
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/comment-author-avatar/edit.js +1 -0
- package/build-module/comment-author-avatar/edit.js.map +1 -1
- package/build-module/comments/index.js +1 -0
- package/build-module/comments/index.js.map +1 -1
- package/build-module/cover/deprecated.js +4 -2
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +2 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/index.js +1 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/details/index.js +5 -1
- package/build-module/details/index.js.map +1 -1
- package/build-module/embed/embed-placeholder.native.js +37 -14
- package/build-module/embed/embed-placeholder.native.js.map +1 -1
- package/build-module/embed/util.js +6 -6
- package/build-module/embed/util.js.map +1 -1
- package/build-module/file/inspector.js +1 -0
- package/build-module/file/inspector.js.map +1 -1
- package/build-module/file/{interactivity.js → view-interactivity.js} +6 -2
- package/build-module/file/view-interactivity.js.map +1 -0
- package/build-module/footnotes/edit.js +18 -2
- package/build-module/footnotes/edit.js.map +1 -1
- package/build-module/footnotes/format.js +19 -16
- package/build-module/footnotes/format.js.map +1 -1
- package/build-module/footnotes/index.js +0 -1
- package/build-module/footnotes/index.js.map +1 -1
- package/build-module/gallery/edit.js +1 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/index.js +3 -1
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/index.js +5 -1
- package/build-module/heading/index.js.map +1 -1
- package/build-module/heading/transforms.js +5 -1
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/image/deprecated.js +454 -176
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.js +0 -4
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +96 -46
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +6 -0
- package/build-module/image/index.js.map +1 -1
- package/build-module/image/save.js +8 -1
- package/build-module/image/save.js.map +1 -1
- package/build-module/image/utils.js +16 -0
- package/build-module/image/utils.js.map +1 -1
- package/build-module/image/{interactivity.js → view-interactivity.js} +86 -44
- package/build-module/image/view-interactivity.js.map +1 -0
- package/build-module/index.js +12 -3
- package/build-module/index.js.map +1 -1
- package/build-module/latest-comments/edit.js +1 -0
- package/build-module/latest-comments/edit.js.map +1 -1
- package/build-module/latest-posts/edit.js +2 -0
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/list/edit.js +4 -4
- package/build-module/list/edit.js.map +1 -1
- package/build-module/list/index.js +5 -1
- package/build-module/list/index.js.map +1 -1
- package/build-module/list-item/utils.js +6 -1
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/media-text/index.js +1 -0
- package/build-module/media-text/index.js.map +1 -1
- package/build-module/media-text/media-container.native.js +2 -1
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/missing/edit.js +22 -8
- package/build-module/missing/edit.js.map +1 -1
- package/build-module/missing/edit.native.js +8 -6
- package/build-module/missing/edit.native.js.map +1 -1
- package/build-module/navigation/constants.js +8 -3
- package/build-module/navigation/constants.js.map +1 -1
- package/build-module/navigation/edit/index.js +18 -4
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +2 -2
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +0 -1
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +2 -2
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +10 -14
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +35 -47
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation/view-interactivity.js +182 -0
- package/build-module/navigation/view-interactivity.js.map +1 -0
- package/build-module/navigation-link/edit.js +13 -19
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +13 -3
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +2 -2
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +3 -3
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/edit.js +34 -39
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/page-list/use-convert-to-navigation-links.js +3 -16
- package/build-module/page-list/use-convert-to-navigation-links.js.map +1 -1
- package/build-module/paragraph/index.js +1 -0
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/paragraph/transforms.js +1 -0
- package/build-module/paragraph/transforms.js.map +1 -1
- package/build-module/post-comments-form/index.js +1 -0
- package/build-module/post-comments-form/index.js.map +1 -1
- package/build-module/post-navigation-link/index.js +1 -0
- package/build-module/post-navigation-link/index.js.map +1 -1
- package/build-module/post-time-to-read/index.js +5 -1
- package/build-module/post-time-to-read/index.js.map +1 -1
- package/build-module/query-pagination/edit.js +1 -1
- package/build-module/query-pagination/edit.js.map +1 -1
- package/build-module/query-pagination-numbers/index.js +1 -1
- package/build-module/query-title/edit.js +44 -3
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/quote/index.js +1 -0
- package/build-module/quote/index.js.map +1 -1
- package/build-module/quote/transforms.js +8 -0
- package/build-module/quote/transforms.js.map +1 -1
- package/build-module/rss/edit.js +3 -0
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/search/edit.js +4 -3
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/index.js +1 -0
- package/build-module/search/index.js.map +1 -1
- package/build-module/site-logo/edit.js +1 -0
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-logo/index.js +5 -1
- package/build-module/site-logo/index.js.map +1 -1
- package/build-module/site-tagline/icon.js +1 -1
- package/build-module/site-tagline/icon.js.map +1 -1
- package/build-module/site-tagline/index.js +5 -1
- package/build-module/site-tagline/index.js.map +1 -1
- package/build-module/site-title/index.js +5 -1
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-links/index.js +3 -1
- package/build-module/social-links/index.js.map +1 -1
- package/build-module/table/index.js +5 -1
- package/build-module/table/index.js.map +1 -1
- package/build-module/tag-cloud/edit.js +1 -0
- package/build-module/tag-cloud/edit.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/term-description/index.js +1 -0
- package/build-module/term-description/index.js.map +1 -1
- package/build-module/text-columns/edit.js +1 -0
- package/build-module/text-columns/edit.js.map +1 -1
- package/build-module/verse/index.js +5 -1
- package/build-module/verse/index.js.map +1 -1
- package/build-module/video/deprecated.js +5 -1
- package/build-module/video/deprecated.js.map +1 -1
- package/build-module/video/index.js +5 -1
- package/build-module/video/index.js.map +1 -1
- package/build-style/details/style-rtl.css +4 -2
- package/build-style/details/style.css +4 -2
- package/build-style/footnotes/style-rtl.css +4 -3
- package/build-style/footnotes/style.css +4 -3
- package/build-style/image/style-rtl.css +16 -2
- package/build-style/image/style.css +16 -2
- package/build-style/navigation/style-rtl.css +14 -2
- package/build-style/navigation/style.css +14 -2
- package/build-style/query-pagination/style-rtl.css +4 -2
- package/build-style/query-pagination/style.css +4 -2
- package/build-style/style-rtl.css +42 -11
- package/build-style/style.css +42 -11
- package/package.json +33 -37
- package/src/archives/block.json +5 -1
- package/src/audio/block.json +5 -1
- package/src/audio/test/__snapshots__/edit.native.js.snap +58 -33
- package/src/avatar/block.json +1 -1
- package/src/avatar/edit.js +1 -0
- package/src/block/block.json +2 -1
- package/src/block/edit.js +2 -2
- package/src/block/edit.native.js +8 -12
- package/src/block/editor.native.scss +2 -2
- package/src/block/test/edit.native.js +4 -4
- package/src/buttons/edit.js +4 -4
- package/src/categories/block.json +5 -1
- package/src/code/block.json +5 -1
- package/src/column/block.json +1 -0
- package/src/column/edit.native.js +4 -10
- package/src/column/editor.native.scss +0 -4
- package/src/columns/edit.js +1 -0
- package/src/comment-author-avatar/edit.js +1 -0
- package/src/comment-template/index.php +5 -2
- package/src/comments/block.json +1 -0
- package/src/cover/block.json +1 -0
- package/src/cover/deprecated.js +2 -0
- package/src/cover/edit/inspector-controls.js +1 -0
- package/src/details/block.json +5 -1
- package/src/embed/embed-placeholder.native.js +80 -47
- package/src/embed/styles.native.scss +54 -18
- package/src/embed/test/index.native.js +5 -5
- package/src/embed/util.js +4 -6
- package/src/file/index.php +4 -3
- package/src/file/inspector.js +1 -0
- package/src/file/test/__snapshots__/edit.native.js.snap +58 -33
- package/src/file/{interactivity.js → view-interactivity.js} +4 -1
- package/src/footnotes/block.json +0 -1
- package/src/footnotes/edit.js +21 -2
- package/src/footnotes/format.js +22 -20
- package/src/footnotes/index.php +11 -9
- package/src/footnotes/style.scss +6 -3
- package/src/gallery/block.json +3 -1
- package/src/gallery/edit.js +1 -1
- package/src/gallery/test/index.native.js +17 -16
- package/src/group/block.json +1 -0
- package/src/heading/block.json +5 -1
- package/src/heading/test/index.native.js +18 -0
- package/src/home-link/index.php +15 -2
- package/src/image/block.json +6 -0
- package/src/image/deprecated.js +597 -320
- package/src/image/edit.js +0 -4
- package/src/image/image.js +131 -62
- package/src/image/index.php +47 -8
- package/src/image/save.js +9 -1
- package/src/image/style.scss +15 -2
- package/src/image/test/edit.native.js +1 -1
- package/src/image/utils.js +16 -0
- package/src/image/{interactivity.js → view-interactivity.js} +99 -50
- package/src/index.js +18 -1
- package/src/latest-comments/edit.js +1 -0
- package/src/latest-posts/edit.js +2 -0
- package/src/latest-posts/index.php +1 -1
- package/src/list/block.json +5 -1
- package/src/list/edit.js +6 -4
- package/src/list/test/edit.native.js +129 -33
- package/src/media-text/block.json +1 -0
- package/src/media-text/media-container.native.js +1 -0
- package/src/missing/edit.js +31 -11
- package/src/missing/edit.native.js +12 -10
- package/src/missing/style.native.scss +19 -12
- package/src/missing/test/__snapshots__/edit.native.js.snap +21 -13
- package/src/navigation/constants.js +12 -6
- package/src/navigation/edit/index.js +30 -3
- package/src/navigation/edit/inner-blocks.js +2 -2
- package/src/navigation/edit/menu-inspector-controls.js +0 -1
- package/src/navigation/edit/unsaved-inner-blocks.js +2 -2
- package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +17 -21
- package/src/navigation/index.php +43 -16
- package/src/navigation/style.scss +27 -8
- package/src/navigation/use-navigation-menu.js +39 -63
- package/src/navigation/view-interactivity.js +196 -0
- package/src/navigation-link/edit.js +61 -61
- package/src/navigation-link/link-ui.js +14 -2
- package/src/navigation-submenu/edit.js +2 -2
- package/src/navigation-submenu/index.php +2 -12
- package/src/page-list/convert-to-links-modal.js +3 -3
- package/src/page-list/edit.js +65 -62
- package/src/page-list/use-convert-to-navigation-links.js +3 -20
- package/src/paragraph/block.json +1 -0
- package/src/paragraph/test/__snapshots__/edit.native.js.snap +1 -0
- package/src/paragraph/test/edit.native.js +26 -0
- package/src/post-comments-form/block.json +1 -0
- package/src/post-navigation-link/block.json +1 -0
- package/src/post-template/index.php +4 -2
- package/src/post-time-to-read/block.json +5 -1
- package/src/post-title/index.php +6 -3
- package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -0
- package/src/query-pagination/edit.js +17 -14
- package/src/query-pagination-numbers/block.json +1 -1
- package/src/query-title/edit.js +48 -6
- package/src/quote/block.json +1 -0
- package/src/quote/test/__snapshots__/transforms.native.js.snap +10 -0
- package/src/quote/test/transforms.native.js +5 -1
- package/src/quote/transforms.js +13 -0
- package/src/rss/edit.js +3 -0
- package/src/search/block.json +1 -0
- package/src/search/edit.js +4 -3
- package/src/search/index.php +22 -4
- package/src/search/test/__snapshots__/edit.native.js.snap +7 -0
- package/src/site-logo/block.json +5 -1
- package/src/site-logo/edit.js +1 -0
- package/src/site-tagline/block.json +5 -1
- package/src/site-tagline/icon.js +1 -1
- package/src/site-title/block.json +5 -1
- package/src/social-links/block.json +3 -1
- package/src/table/block.json +5 -1
- package/src/tag-cloud/edit.js +1 -0
- package/src/template-part/edit/index.js +1 -1
- package/src/template-part/index.php +9 -15
- package/src/term-description/block.json +1 -0
- package/src/text-columns/edit.js +1 -0
- package/src/verse/block.json +5 -1
- package/src/video/block.json +5 -1
- package/build/file/interactivity.js.map +0 -1
- package/build/gallery/shared-icon.native.js +0 -38
- package/build/gallery/shared-icon.native.js.map +0 -1
- package/build/heading/heading-level-icon.js +0 -61
- package/build/heading/heading-level-icon.js.map +0 -1
- package/build/image/interactivity.js.map +0 -1
- package/build/navigation/interactivity.js +0 -167
- package/build/navigation/interactivity.js.map +0 -1
- package/build/utils/interactivity/constants.js +0 -9
- package/build/utils/interactivity/constants.js.map +0 -1
- package/build/utils/interactivity/directives.js +0 -222
- package/build/utils/interactivity/directives.js.map +0 -1
- package/build/utils/interactivity/hooks.js +0 -159
- package/build/utils/interactivity/hooks.js.map +0 -1
- package/build/utils/interactivity/hydration.js +0 -34
- package/build/utils/interactivity/hydration.js.map +0 -1
- package/build/utils/interactivity/index.js +0 -32
- package/build/utils/interactivity/index.js.map +0 -1
- package/build/utils/interactivity/portals.js +0 -108
- package/build/utils/interactivity/portals.js.map +0 -1
- package/build/utils/interactivity/store.js +0 -66
- package/build/utils/interactivity/store.js.map +0 -1
- package/build/utils/interactivity/utils.js +0 -87
- package/build/utils/interactivity/utils.js.map +0 -1
- package/build/utils/interactivity/vdom.js +0 -119
- package/build/utils/interactivity/vdom.js.map +0 -1
- package/build-module/file/interactivity.js.map +0 -1
- package/build-module/gallery/shared-icon.native.js +0 -24
- package/build-module/gallery/shared-icon.native.js.map +0 -1
- package/build-module/heading/heading-level-icon.js +0 -53
- package/build-module/heading/heading-level-icon.js.map +0 -1
- package/build-module/image/interactivity.js.map +0 -1
- package/build-module/navigation/interactivity.js +0 -164
- package/build-module/navigation/interactivity.js.map +0 -1
- package/build-module/utils/interactivity/constants.js +0 -2
- package/build-module/utils/interactivity/constants.js.map +0 -1
- package/build-module/utils/interactivity/directives.js +0 -209
- package/build-module/utils/interactivity/directives.js.map +0 -1
- package/build-module/utils/interactivity/hooks.js +0 -145
- package/build-module/utils/interactivity/hooks.js.map +0 -1
- package/build-module/utils/interactivity/hydration.js +0 -21
- package/build-module/utils/interactivity/hydration.js.map +0 -1
- package/build-module/utils/interactivity/index.js +0 -15
- package/build-module/utils/interactivity/index.js.map +0 -1
- package/build-module/utils/interactivity/portals.js +0 -100
- package/build-module/utils/interactivity/portals.js.map +0 -1
- package/build-module/utils/interactivity/store.js +0 -55
- package/build-module/utils/interactivity/store.js.map +0 -1
- package/build-module/utils/interactivity/utils.js +0 -75
- package/build-module/utils/interactivity/utils.js.map +0 -1
- package/build-module/utils/interactivity/vdom.js +0 -107
- package/build-module/utils/interactivity/vdom.js.map +0 -1
- package/src/gallery/shared-icon.native.js +0 -23
- package/src/heading/heading-level-icon.js +0 -48
- package/src/navigation/interactivity.js +0 -169
- package/src/utils/interactivity/constants.js +0 -1
- package/src/utils/interactivity/directives.js +0 -200
- package/src/utils/interactivity/hooks.js +0 -145
- package/src/utils/interactivity/hydration.js +0 -22
- package/src/utils/interactivity/index.js +0 -15
- package/src/utils/interactivity/portals.js +0 -98
- package/src/utils/interactivity/store.js +0 -45
- package/src/utils/interactivity/utils.js +0 -66
- package/src/utils/interactivity/vdom.js +0 -111
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { h, options, createContext, cloneElement } from 'preact';
|
|
5
|
-
import { useRef, useMemo } from 'preact/hooks';
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { rawStore as store } from './store';
|
|
10
|
-
|
|
11
|
-
// Main context.
|
|
12
|
-
const context = createContext( {} );
|
|
13
|
-
|
|
14
|
-
// WordPress Directives.
|
|
15
|
-
const directiveMap = {};
|
|
16
|
-
const directivePriorities = {};
|
|
17
|
-
export const directive = ( name, cb, { priority = 10 } = {} ) => {
|
|
18
|
-
directiveMap[ name ] = cb;
|
|
19
|
-
directivePriorities[ name ] = priority;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// Resolve the path to some property of the store object.
|
|
23
|
-
const resolve = ( path, ctx ) => {
|
|
24
|
-
let current = { ...store, context: ctx };
|
|
25
|
-
path.split( '.' ).forEach( ( p ) => ( current = current[ p ] ) );
|
|
26
|
-
return current;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
// Generate the evaluate function.
|
|
30
|
-
const getEvaluate =
|
|
31
|
-
( { ref } = {} ) =>
|
|
32
|
-
( path, extraArgs = {} ) => {
|
|
33
|
-
// If path starts with !, remove it and save a flag.
|
|
34
|
-
const hasNegationOperator =
|
|
35
|
-
path[ 0 ] === '!' && !! ( path = path.slice( 1 ) );
|
|
36
|
-
const value = resolve( path, extraArgs.context );
|
|
37
|
-
const returnValue =
|
|
38
|
-
typeof value === 'function'
|
|
39
|
-
? value( {
|
|
40
|
-
ref: ref.current,
|
|
41
|
-
...store,
|
|
42
|
-
...extraArgs,
|
|
43
|
-
} )
|
|
44
|
-
: value;
|
|
45
|
-
return hasNegationOperator ? ! returnValue : returnValue;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// Separate directives by priority. The resulting array contains objects
|
|
49
|
-
// of directives grouped by same priority, and sorted in ascending order.
|
|
50
|
-
const usePriorityLevels = ( directives ) =>
|
|
51
|
-
useMemo( () => {
|
|
52
|
-
const byPriority = Object.entries( directives ).reduce(
|
|
53
|
-
( acc, [ name, values ] ) => {
|
|
54
|
-
const priority = directivePriorities[ name ];
|
|
55
|
-
if ( ! acc[ priority ] ) acc[ priority ] = {};
|
|
56
|
-
acc[ priority ][ name ] = values;
|
|
57
|
-
|
|
58
|
-
return acc;
|
|
59
|
-
},
|
|
60
|
-
{}
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
return Object.entries( byPriority )
|
|
64
|
-
.sort( ( [ p1 ], [ p2 ] ) => p1 - p2 )
|
|
65
|
-
.map( ( [ , obj ] ) => obj );
|
|
66
|
-
}, [ directives ] );
|
|
67
|
-
|
|
68
|
-
// Directive wrapper.
|
|
69
|
-
const Directive = ( { type, directives, props: originalProps } ) => {
|
|
70
|
-
const ref = useRef( null );
|
|
71
|
-
const element = h( type, { ...originalProps, ref } );
|
|
72
|
-
const evaluate = useMemo( () => getEvaluate( { ref } ), [] );
|
|
73
|
-
|
|
74
|
-
// Add wrappers recursively for each priority level.
|
|
75
|
-
const byPriorityLevel = usePriorityLevels( directives );
|
|
76
|
-
return (
|
|
77
|
-
<RecursivePriorityLevel
|
|
78
|
-
directives={ byPriorityLevel }
|
|
79
|
-
element={ element }
|
|
80
|
-
evaluate={ evaluate }
|
|
81
|
-
originalProps={ originalProps }
|
|
82
|
-
/>
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// Priority level wrapper.
|
|
87
|
-
const RecursivePriorityLevel = ( {
|
|
88
|
-
directives: [ directives, ...rest ],
|
|
89
|
-
element,
|
|
90
|
-
evaluate,
|
|
91
|
-
originalProps,
|
|
92
|
-
} ) => {
|
|
93
|
-
// This element needs to be a fresh copy so we are not modifying an already
|
|
94
|
-
// rendered element with Preact's internal properties initialized. This
|
|
95
|
-
// prevents an error with changes in `element.props.children` not being
|
|
96
|
-
// reflected in `element.__k`.
|
|
97
|
-
element = cloneElement( element );
|
|
98
|
-
|
|
99
|
-
// Recursively render the wrapper for the next priority level.
|
|
100
|
-
//
|
|
101
|
-
// Note that, even though we're instantiating a vnode with a
|
|
102
|
-
// `RecursivePriorityLevel` here, its render function will not be executed
|
|
103
|
-
// just yet. Actually, it will be delayed until the current render function
|
|
104
|
-
// has finished. That ensures directives in the current priorty level have
|
|
105
|
-
// run (and thus modified the passed `element`) before the next level.
|
|
106
|
-
const children =
|
|
107
|
-
rest.length > 0 ? (
|
|
108
|
-
<RecursivePriorityLevel
|
|
109
|
-
directives={ rest }
|
|
110
|
-
element={ element }
|
|
111
|
-
evaluate={ evaluate }
|
|
112
|
-
originalProps={ originalProps }
|
|
113
|
-
/>
|
|
114
|
-
) : (
|
|
115
|
-
element
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
const props = { ...originalProps, children };
|
|
119
|
-
const directiveArgs = { directives, props, element, context, evaluate };
|
|
120
|
-
|
|
121
|
-
for ( const d in directives ) {
|
|
122
|
-
const wrapper = directiveMap[ d ]?.( directiveArgs );
|
|
123
|
-
if ( wrapper !== undefined ) props.children = wrapper;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return props.children;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
// Preact Options Hook called each time a vnode is created.
|
|
130
|
-
const old = options.vnode;
|
|
131
|
-
options.vnode = ( vnode ) => {
|
|
132
|
-
if ( vnode.props.__directives ) {
|
|
133
|
-
const props = vnode.props;
|
|
134
|
-
const directives = props.__directives;
|
|
135
|
-
delete props.__directives;
|
|
136
|
-
vnode.props = {
|
|
137
|
-
type: vnode.type,
|
|
138
|
-
directives,
|
|
139
|
-
props,
|
|
140
|
-
};
|
|
141
|
-
vnode.type = Directive;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if ( old ) old( vnode );
|
|
145
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { hydrate } from 'preact';
|
|
5
|
-
/**
|
|
6
|
-
* Internal dependencies
|
|
7
|
-
*/
|
|
8
|
-
import { toVdom, hydratedIslands } from './vdom';
|
|
9
|
-
import { createRootFragment } from './utils';
|
|
10
|
-
import { directivePrefix } from './constants';
|
|
11
|
-
|
|
12
|
-
export const init = async () => {
|
|
13
|
-
document
|
|
14
|
-
.querySelectorAll( `[data-${ directivePrefix }-interactive]` )
|
|
15
|
-
.forEach( ( node ) => {
|
|
16
|
-
if ( ! hydratedIslands.has( node ) ) {
|
|
17
|
-
const fragment = createRootFragment( node.parentNode, node );
|
|
18
|
-
const vdom = toVdom( node );
|
|
19
|
-
hydrate( vdom, fragment );
|
|
20
|
-
}
|
|
21
|
-
} );
|
|
22
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import registerDirectives from './directives';
|
|
5
|
-
import { init } from './hydration';
|
|
6
|
-
export { store } from './store';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Initialize the Interactivity API.
|
|
10
|
-
*/
|
|
11
|
-
registerDirectives();
|
|
12
|
-
|
|
13
|
-
document.addEventListener( 'DOMContentLoaded', async () => {
|
|
14
|
-
await init();
|
|
15
|
-
} );
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { createElement, render } from 'preact';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @param {import('../../src/index').RenderableProps<{ context: any }>} props
|
|
8
|
-
*/
|
|
9
|
-
function ContextProvider( props ) {
|
|
10
|
-
this.getChildContext = () => props.context;
|
|
11
|
-
return props.children;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Portal component
|
|
16
|
-
*
|
|
17
|
-
* @this {import('./internal').Component}
|
|
18
|
-
* @param {object | null | undefined} props
|
|
19
|
-
*
|
|
20
|
-
* TODO: use createRoot() instead of fake root
|
|
21
|
-
*/
|
|
22
|
-
function Portal( props ) {
|
|
23
|
-
const _this = this;
|
|
24
|
-
const container = props._container;
|
|
25
|
-
|
|
26
|
-
_this.componentWillUnmount = function () {
|
|
27
|
-
render( null, _this._temp );
|
|
28
|
-
_this._temp = null;
|
|
29
|
-
_this._container = null;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// When we change container we should clear our old container and
|
|
33
|
-
// indicate a new mount.
|
|
34
|
-
if ( _this._container && _this._container !== container ) {
|
|
35
|
-
_this.componentWillUnmount();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// When props.vnode is undefined/false/null we are dealing with some kind of
|
|
39
|
-
// conditional vnode. This should not trigger a render.
|
|
40
|
-
if ( props._vnode ) {
|
|
41
|
-
if ( ! _this._temp ) {
|
|
42
|
-
_this._container = container;
|
|
43
|
-
|
|
44
|
-
// Create a fake DOM parent node that manages a subset of `container`'s children:
|
|
45
|
-
_this._temp = {
|
|
46
|
-
nodeType: 1,
|
|
47
|
-
parentNode: container,
|
|
48
|
-
childNodes: [],
|
|
49
|
-
appendChild( child ) {
|
|
50
|
-
this.childNodes.push( child );
|
|
51
|
-
_this._container.appendChild( child );
|
|
52
|
-
},
|
|
53
|
-
insertBefore( child ) {
|
|
54
|
-
this.childNodes.push( child );
|
|
55
|
-
_this._container.appendChild( child );
|
|
56
|
-
},
|
|
57
|
-
removeChild( child ) {
|
|
58
|
-
this.childNodes.splice(
|
|
59
|
-
// eslint-disable-next-line no-bitwise
|
|
60
|
-
this.childNodes.indexOf( child ) >>> 1,
|
|
61
|
-
1
|
|
62
|
-
);
|
|
63
|
-
_this._container.removeChild( child );
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Render our wrapping element into temp.
|
|
69
|
-
render(
|
|
70
|
-
createElement(
|
|
71
|
-
ContextProvider,
|
|
72
|
-
{ context: _this.context },
|
|
73
|
-
props._vnode
|
|
74
|
-
),
|
|
75
|
-
_this._temp
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
// When we come from a conditional render, on a mounted
|
|
79
|
-
// portal we should clear the DOM.
|
|
80
|
-
else if ( _this._temp ) {
|
|
81
|
-
_this.componentWillUnmount();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Create a `Portal` to continue rendering the vnode tree at a different DOM node
|
|
87
|
-
*
|
|
88
|
-
* @param {import('./internal').VNode} vnode The vnode to render
|
|
89
|
-
* @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
|
|
90
|
-
*/
|
|
91
|
-
export function createPortal( vnode, container ) {
|
|
92
|
-
const el = createElement( Portal, {
|
|
93
|
-
_vnode: vnode,
|
|
94
|
-
_container: container,
|
|
95
|
-
} );
|
|
96
|
-
el.containerInfo = container;
|
|
97
|
-
return el;
|
|
98
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { deepSignal } from 'deepsignal';
|
|
5
|
-
|
|
6
|
-
const isObject = ( item ) =>
|
|
7
|
-
item && typeof item === 'object' && ! Array.isArray( item );
|
|
8
|
-
|
|
9
|
-
const deepMerge = ( target, source ) => {
|
|
10
|
-
if ( isObject( target ) && isObject( source ) ) {
|
|
11
|
-
for ( const key in source ) {
|
|
12
|
-
if ( isObject( source[ key ] ) ) {
|
|
13
|
-
if ( ! target[ key ] ) Object.assign( target, { [ key ]: {} } );
|
|
14
|
-
deepMerge( target[ key ], source[ key ] );
|
|
15
|
-
} else {
|
|
16
|
-
Object.assign( target, { [ key ]: source[ key ] } );
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const getSerializedState = () => {
|
|
23
|
-
// TODO: change the store tag ID for a better one.
|
|
24
|
-
const storeTag = document.querySelector(
|
|
25
|
-
`script[type="application/json"]#store`
|
|
26
|
-
);
|
|
27
|
-
if ( ! storeTag ) return {};
|
|
28
|
-
try {
|
|
29
|
-
const { state } = JSON.parse( storeTag.textContent );
|
|
30
|
-
if ( isObject( state ) ) return state;
|
|
31
|
-
throw Error( 'Parsed state is not an object' );
|
|
32
|
-
} catch ( e ) {
|
|
33
|
-
// eslint-disable-next-line no-console
|
|
34
|
-
console.log( e );
|
|
35
|
-
}
|
|
36
|
-
return {};
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const rawState = getSerializedState();
|
|
40
|
-
export const rawStore = { state: deepSignal( rawState ) };
|
|
41
|
-
|
|
42
|
-
export const store = ( { state, ...block } ) => {
|
|
43
|
-
deepMerge( rawStore, block );
|
|
44
|
-
deepMerge( rawState, state );
|
|
45
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useRef, useEffect } from 'preact/hooks';
|
|
5
|
-
import { effect } from '@preact/signals';
|
|
6
|
-
|
|
7
|
-
function afterNextFrame( callback ) {
|
|
8
|
-
const done = () => {
|
|
9
|
-
window.cancelAnimationFrame( raf );
|
|
10
|
-
setTimeout( callback );
|
|
11
|
-
};
|
|
12
|
-
const raf = window.requestAnimationFrame( done );
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Using the mangled properties:
|
|
16
|
-
// this.c: this._callback
|
|
17
|
-
// this.x: this._compute
|
|
18
|
-
// https://github.com/preactjs/signals/blob/main/mangle.json
|
|
19
|
-
function createFlusher( compute, notify ) {
|
|
20
|
-
let flush;
|
|
21
|
-
const dispose = effect( function () {
|
|
22
|
-
flush = this.c.bind( this );
|
|
23
|
-
this.x = compute;
|
|
24
|
-
this.c = notify;
|
|
25
|
-
return compute();
|
|
26
|
-
} );
|
|
27
|
-
return { flush, dispose };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Version of `useSignalEffect` with a `useEffect`-like execution. This hook
|
|
31
|
-
// implementation comes from this PR:
|
|
32
|
-
// https://github.com/preactjs/signals/pull/290.
|
|
33
|
-
//
|
|
34
|
-
// We need to include it here in this repo until the mentioned PR is merged.
|
|
35
|
-
export function useSignalEffect( cb ) {
|
|
36
|
-
const callback = useRef( cb );
|
|
37
|
-
callback.current = cb;
|
|
38
|
-
|
|
39
|
-
useEffect( () => {
|
|
40
|
-
const execute = () => callback.current();
|
|
41
|
-
const notify = () => afterNextFrame( eff.flush );
|
|
42
|
-
const eff = createFlusher( execute, notify );
|
|
43
|
-
return eff.dispose;
|
|
44
|
-
}, [] );
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// For wrapperless hydration.
|
|
48
|
-
// See https://gist.github.com/developit/f4c67a2ede71dc2fab7f357f39cff28c
|
|
49
|
-
export const createRootFragment = ( parent, replaceNode ) => {
|
|
50
|
-
replaceNode = [].concat( replaceNode );
|
|
51
|
-
const s = replaceNode[ replaceNode.length - 1 ].nextSibling;
|
|
52
|
-
function insert( c, r ) {
|
|
53
|
-
parent.insertBefore( c, r || s );
|
|
54
|
-
}
|
|
55
|
-
return ( parent.__k = {
|
|
56
|
-
nodeType: 1,
|
|
57
|
-
parentNode: parent,
|
|
58
|
-
firstChild: replaceNode[ 0 ],
|
|
59
|
-
childNodes: replaceNode,
|
|
60
|
-
insertBefore: insert,
|
|
61
|
-
appendChild: insert,
|
|
62
|
-
removeChild( c ) {
|
|
63
|
-
parent.removeChild( c );
|
|
64
|
-
},
|
|
65
|
-
} );
|
|
66
|
-
};
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { h } from 'preact';
|
|
5
|
-
/**
|
|
6
|
-
* Internal dependencies
|
|
7
|
-
*/
|
|
8
|
-
import { directivePrefix as p } from './constants';
|
|
9
|
-
|
|
10
|
-
const ignoreAttr = `data-${ p }-ignore`;
|
|
11
|
-
const islandAttr = `data-${ p }-interactive`;
|
|
12
|
-
const fullPrefix = `data-${ p }-`;
|
|
13
|
-
|
|
14
|
-
// Regular expression for directive parsing.
|
|
15
|
-
const directiveParser = new RegExp(
|
|
16
|
-
`^data-${ p }-` + // ${p} must be a prefix string, like 'wp'.
|
|
17
|
-
// Match alphanumeric characters including hyphen-separated
|
|
18
|
-
// segments. It excludes underscore intentionally to prevent confusion.
|
|
19
|
-
// E.g., "custom-directive".
|
|
20
|
-
'([a-z0-9]+(?:-[a-z0-9]+)*)' +
|
|
21
|
-
// (Optional) Match '--' followed by any alphanumeric charachters. It
|
|
22
|
-
// excludes underscore intentionally to prevent confusion, but it can
|
|
23
|
-
// contain multiple hyphens. E.g., "--custom-prefix--with-more-info".
|
|
24
|
-
'(?:--([a-z0-9][a-z0-9-]+))?$',
|
|
25
|
-
'i' // Case insensitive.
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
export const hydratedIslands = new WeakSet();
|
|
29
|
-
|
|
30
|
-
// Recursive function that transforms a DOM tree into vDOM.
|
|
31
|
-
export function toVdom( root ) {
|
|
32
|
-
const treeWalker = document.createTreeWalker(
|
|
33
|
-
root,
|
|
34
|
-
205 // ELEMENT + TEXT + COMMENT + CDATA_SECTION + PROCESSING_INSTRUCTION
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
function walk( node ) {
|
|
38
|
-
const { attributes, nodeType } = node;
|
|
39
|
-
|
|
40
|
-
if ( nodeType === 3 ) return [ node.data ];
|
|
41
|
-
if ( nodeType === 4 ) {
|
|
42
|
-
const next = treeWalker.nextSibling();
|
|
43
|
-
node.replaceWith( new window.Text( node.nodeValue ) );
|
|
44
|
-
return [ node.nodeValue, next ];
|
|
45
|
-
}
|
|
46
|
-
if ( nodeType === 8 || nodeType === 7 ) {
|
|
47
|
-
const next = treeWalker.nextSibling();
|
|
48
|
-
node.remove();
|
|
49
|
-
return [ null, next ];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const props = {};
|
|
53
|
-
const children = [];
|
|
54
|
-
const directives = {};
|
|
55
|
-
let hasDirectives = false;
|
|
56
|
-
let ignore = false;
|
|
57
|
-
let island = false;
|
|
58
|
-
|
|
59
|
-
for ( let i = 0; i < attributes.length; i++ ) {
|
|
60
|
-
const n = attributes[ i ].name;
|
|
61
|
-
if (
|
|
62
|
-
n[ fullPrefix.length ] &&
|
|
63
|
-
n.slice( 0, fullPrefix.length ) === fullPrefix
|
|
64
|
-
) {
|
|
65
|
-
if ( n === ignoreAttr ) {
|
|
66
|
-
ignore = true;
|
|
67
|
-
} else if ( n === islandAttr ) {
|
|
68
|
-
island = true;
|
|
69
|
-
} else {
|
|
70
|
-
hasDirectives = true;
|
|
71
|
-
let val = attributes[ i ].value;
|
|
72
|
-
try {
|
|
73
|
-
val = JSON.parse( val );
|
|
74
|
-
} catch ( e ) {}
|
|
75
|
-
const [ , prefix, suffix ] = directiveParser.exec( n );
|
|
76
|
-
directives[ prefix ] = directives[ prefix ] || {};
|
|
77
|
-
directives[ prefix ][ suffix || 'default' ] = val;
|
|
78
|
-
}
|
|
79
|
-
} else if ( n === 'ref' ) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
props[ n ] = attributes[ i ].value;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if ( ignore && ! island )
|
|
86
|
-
return [
|
|
87
|
-
h( node.localName, {
|
|
88
|
-
...props,
|
|
89
|
-
innerHTML: node.innerHTML,
|
|
90
|
-
__directives: { ignore: true },
|
|
91
|
-
} ),
|
|
92
|
-
];
|
|
93
|
-
if ( island ) hydratedIslands.add( node );
|
|
94
|
-
|
|
95
|
-
if ( hasDirectives ) props.__directives = directives;
|
|
96
|
-
|
|
97
|
-
let child = treeWalker.firstChild();
|
|
98
|
-
if ( child ) {
|
|
99
|
-
while ( child ) {
|
|
100
|
-
const [ vnode, nextChild ] = walk( child );
|
|
101
|
-
if ( vnode ) children.push( vnode );
|
|
102
|
-
child = nextChild || treeWalker.nextSibling();
|
|
103
|
-
}
|
|
104
|
-
treeWalker.parentNode();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return [ h( node.localName, props, children ) ];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return walk( treeWalker.currentNode );
|
|
111
|
-
}
|