@next-buildr/editor 2.0.1 → 3.0.0-rc.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/README.md +2 -0
- package/UPGRADING.md +322 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/app/builder-editor.test.js +223 -18
- package/dist/app/config.d.ts +27 -4
- package/dist/app/config.d.ts.map +1 -1
- package/dist/app/config.js +4 -3
- package/dist/app/contracts.d.ts +40 -0
- package/dist/app/contracts.d.ts.map +1 -0
- package/dist/app/contracts.js +4 -0
- package/dist/app/editor-app.d.ts.map +1 -1
- package/dist/app/editor-app.js +316 -24
- package/dist/app/editor-app.test.js +144 -6
- package/dist/app/layout.d.ts +11 -2
- package/dist/app/layout.d.ts.map +1 -1
- package/dist/app/layout.js +170 -9
- package/dist/app/manifest.d.ts +7 -2
- package/dist/app/manifest.d.ts.map +1 -1
- package/dist/app/manifest.js +16 -4
- package/dist/app/shell-panels.d.ts +15 -0
- package/dist/app/shell-panels.d.ts.map +1 -1
- package/dist/app/small-screen.test.js +2 -2
- package/dist/app/stage-slots.d.ts +9 -0
- package/dist/app/stage-slots.d.ts.map +1 -0
- package/dist/app/stage-slots.js +10 -0
- package/dist/app/status-info.d.ts +2 -3
- package/dist/app/status-info.d.ts.map +1 -1
- package/dist/app/status-info.js +49 -16
- package/dist/canvas-host/canvas-frame.d.ts +13 -1
- package/dist/canvas-host/canvas-frame.d.ts.map +1 -1
- package/dist/canvas-host/canvas-frame.js +96 -8
- package/dist/canvas-host/canvas-frame.test.js +156 -3
- package/dist/canvas-host/host.d.ts +6 -0
- package/dist/canvas-host/host.d.ts.map +1 -1
- package/dist/canvas-host/host.js +116 -4
- package/dist/canvas-host/host.test.js +195 -6
- package/dist/clipboard/clipboard.d.ts +1 -1
- package/dist/clipboard/clipboard.d.ts.map +1 -1
- package/dist/clipboard/clipboard.js +5 -0
- package/dist/clipboard/clipboard.test.js +21 -1
- package/dist/clipboard/format.d.ts +3 -1
- package/dist/clipboard/format.d.ts.map +1 -1
- package/dist/clipboard/react.d.ts +1 -1
- package/dist/clipboard/react.d.ts.map +1 -1
- package/dist/clipboard/react.js +49 -3
- package/dist/dialogs/external-source.d.ts +15 -0
- package/dist/dialogs/external-source.d.ts.map +1 -0
- package/dist/dialogs/external-source.js +18 -0
- package/dist/dialogs/index.d.ts +4 -0
- package/dist/dialogs/index.d.ts.map +1 -1
- package/dist/dialogs/index.js +2 -0
- package/dist/dialogs/media-picker/index.d.ts +2 -2
- package/dist/dialogs/media-picker/index.d.ts.map +1 -1
- package/dist/dialogs/media-picker/index.js +1 -1
- package/dist/dialogs/media-picker/media-picker.d.ts +5 -0
- package/dist/dialogs/media-picker/media-picker.d.ts.map +1 -1
- package/dist/dialogs/media-picker/media-picker.js +67 -5
- package/dist/dialogs/media-picker/media-picker.test.js +72 -1
- package/dist/dialogs/media-picker/media-ref.d.ts +15 -0
- package/dist/dialogs/media-picker/media-ref.d.ts.map +1 -1
- package/dist/dialogs/media-picker/media-ref.js +29 -0
- package/dist/dialogs/remove-confirm.d.ts +14 -0
- package/dist/dialogs/remove-confirm.d.ts.map +1 -0
- package/dist/dialogs/remove-confirm.js +42 -0
- package/dist/dialogs/remove-confirm.test.d.ts +2 -0
- package/dist/dialogs/remove-confirm.test.d.ts.map +1 -0
- package/dist/dialogs/remove-confirm.test.js +118 -0
- package/dist/dnd/dnd-react.test.js +11 -2
- package/dist/dnd/dnd.test.js +23 -0
- package/dist/dnd/engine.d.ts +4 -2
- package/dist/dnd/engine.d.ts.map +1 -1
- package/dist/dnd/engine.js +6 -0
- package/dist/dnd/move-to-dialog.d.ts +4 -3
- package/dist/dnd/move-to-dialog.d.ts.map +1 -1
- package/dist/dnd/move-to-dialog.js +67 -10
- package/dist/dnd/react.d.ts.map +1 -1
- package/dist/dnd/react.js +5 -0
- package/dist/i18n/diagnostics.d.ts +22 -0
- package/dist/i18n/diagnostics.d.ts.map +1 -0
- package/dist/i18n/diagnostics.js +153 -0
- package/dist/i18n/diagnostics.test.d.ts +2 -0
- package/dist/i18n/diagnostics.test.d.ts.map +1 -0
- package/dist/i18n/diagnostics.test.js +74 -0
- package/dist/i18n/label-catalog.d.ts +20 -0
- package/dist/i18n/label-catalog.d.ts.map +1 -0
- package/dist/i18n/label-catalog.js +1 -0
- package/dist/i18n/locale-name.d.ts +7 -0
- package/dist/i18n/locale-name.d.ts.map +1 -0
- package/dist/i18n/locale-name.js +31 -0
- package/dist/i18n/localize-manifest.d.ts +11 -0
- package/dist/i18n/localize-manifest.d.ts.map +1 -0
- package/dist/i18n/localize-manifest.js +78 -0
- package/dist/i18n/localize-manifest.test.d.ts +2 -0
- package/dist/i18n/localize-manifest.test.d.ts.map +1 -0
- package/dist/i18n/localize-manifest.test.js +71 -0
- package/dist/messages/catalogs.test.d.ts +2 -0
- package/dist/messages/catalogs.test.d.ts.map +1 -0
- package/dist/messages/catalogs.test.js +80 -0
- package/dist/messages/en/app.d.ts +8 -0
- package/dist/messages/en/app.d.ts.map +1 -0
- package/dist/messages/en/app.js +7 -0
- package/dist/messages/en/blocks.d.ts +54 -0
- package/dist/messages/en/blocks.d.ts.map +1 -0
- package/dist/messages/en/blocks.js +53 -0
- package/dist/messages/en/canvas.d.ts +31 -0
- package/dist/messages/en/canvas.d.ts.map +1 -0
- package/dist/messages/en/canvas.js +30 -0
- package/dist/messages/en/clipboard.d.ts +13 -0
- package/dist/messages/en/clipboard.d.ts.map +1 -0
- package/dist/messages/en/clipboard.js +12 -0
- package/dist/messages/en/colorPicker.d.ts +20 -0
- package/dist/messages/en/colorPicker.d.ts.map +1 -0
- package/dist/messages/en/colorPicker.js +19 -0
- package/dist/messages/en/diagnostics.d.ts +40 -0
- package/dist/messages/en/diagnostics.d.ts.map +1 -0
- package/dist/messages/en/diagnostics.js +39 -0
- package/dist/messages/en/dialogs/common.d.ts +6 -0
- package/dist/messages/en/dialogs/common.d.ts.map +1 -0
- package/dist/messages/en/dialogs/common.js +5 -0
- package/dist/messages/en/dialogs/conflict.d.ts +15 -0
- package/dist/messages/en/dialogs/conflict.d.ts.map +1 -0
- package/dist/messages/en/dialogs/conflict.js +14 -0
- package/dist/messages/en/dialogs/delete.d.ts +19 -0
- package/dist/messages/en/dialogs/delete.d.ts.map +1 -0
- package/dist/messages/en/dialogs/delete.js +18 -0
- package/dist/messages/en/dialogs/pageOptions.d.ts +9 -0
- package/dist/messages/en/dialogs/pageOptions.d.ts.map +1 -0
- package/dist/messages/en/dialogs/pageOptions.js +8 -0
- package/dist/messages/en/dialogs/publish.d.ts +15 -0
- package/dist/messages/en/dialogs/publish.d.ts.map +1 -0
- package/dist/messages/en/dialogs/publish.js +14 -0
- package/dist/messages/en/dnd.d.ts +19 -0
- package/dist/messages/en/dnd.d.ts.map +1 -0
- package/dist/messages/en/dnd.js +18 -0
- package/dist/messages/en/editor.d.ts +30 -0
- package/dist/messages/en/editor.d.ts.map +1 -0
- package/dist/messages/en/editor.js +29 -0
- package/dist/messages/en/external.d.ts +6 -0
- package/dist/messages/en/external.d.ts.map +1 -0
- package/dist/messages/en/external.js +5 -0
- package/dist/messages/en/insert.d.ts +25 -0
- package/dist/messages/en/insert.d.ts.map +1 -0
- package/dist/messages/en/insert.js +24 -0
- package/dist/messages/en/inspector.d.ts +176 -0
- package/dist/messages/en/inspector.d.ts.map +1 -0
- package/dist/messages/en/inspector.js +175 -0
- package/dist/messages/en/issues.d.ts +36 -0
- package/dist/messages/en/issues.d.ts.map +1 -0
- package/dist/messages/en/issues.js +35 -0
- package/dist/messages/en/layers.d.ts +29 -0
- package/dist/messages/en/layers.d.ts.map +1 -0
- package/dist/messages/en/layers.js +28 -0
- package/dist/messages/en/leftPanel.d.ts +15 -0
- package/dist/messages/en/leftPanel.d.ts.map +1 -0
- package/dist/messages/en/leftPanel.js +14 -0
- package/dist/messages/en/list.d.ts +9 -0
- package/dist/messages/en/list.d.ts.map +1 -0
- package/dist/messages/en/list.js +8 -0
- package/dist/messages/en/locale.d.ts +4 -0
- package/dist/messages/en/locale.d.ts.map +1 -0
- package/dist/messages/en/locale.js +3 -0
- package/dist/messages/en/media.d.ts +51 -0
- package/dist/messages/en/media.d.ts.map +1 -0
- package/dist/messages/en/media.js +50 -0
- package/dist/messages/en/menu.d.ts +12 -0
- package/dist/messages/en/menu.d.ts.map +1 -0
- package/dist/messages/en/menu.js +11 -0
- package/dist/messages/en/patterns.d.ts +24 -0
- package/dist/messages/en/patterns.d.ts.map +1 -0
- package/dist/messages/en/patterns.js +23 -0
- package/dist/messages/en/preview.d.ts +8 -0
- package/dist/messages/en/preview.d.ts.map +1 -0
- package/dist/messages/en/preview.js +7 -0
- package/dist/messages/en/publish.d.ts +19 -0
- package/dist/messages/en/publish.d.ts.map +1 -0
- package/dist/messages/en/publish.js +18 -0
- package/dist/messages/en/richText.d.ts +21 -0
- package/dist/messages/en/richText.d.ts.map +1 -0
- package/dist/messages/en/richText.js +20 -0
- package/dist/messages/en/sample.d.ts +5 -0
- package/dist/messages/en/sample.d.ts.map +1 -0
- package/dist/messages/en/sample.js +4 -0
- package/dist/messages/en/save.d.ts +15 -0
- package/dist/messages/en/save.d.ts.map +1 -0
- package/dist/messages/en/save.js +14 -0
- package/dist/messages/en/shortcut.d.ts +36 -0
- package/dist/messages/en/shortcut.d.ts.map +1 -0
- package/dist/messages/en/shortcut.js +35 -0
- package/dist/messages/en/statusBar.d.ts +14 -0
- package/dist/messages/en/statusBar.d.ts.map +1 -0
- package/dist/messages/en/statusBar.js +13 -0
- package/dist/messages/en/structure.d.ts +28 -0
- package/dist/messages/en/structure.d.ts.map +1 -0
- package/dist/messages/en/structure.js +27 -0
- package/dist/messages/en/style.d.ts +168 -0
- package/dist/messages/en/style.d.ts.map +1 -0
- package/dist/messages/en/style.js +167 -0
- package/dist/messages/en/styleField.d.ts +301 -0
- package/dist/messages/en/styleField.d.ts.map +1 -0
- package/dist/messages/en/styleField.js +300 -0
- package/dist/messages/en/styleOption.d.ts +128 -0
- package/dist/messages/en/styleOption.d.ts.map +1 -0
- package/dist/messages/en/styleOption.js +127 -0
- package/dist/messages/en/styleSection.d.ts +16 -0
- package/dist/messages/en/styleSection.d.ts.map +1 -0
- package/dist/messages/en/styleSection.js +15 -0
- package/dist/messages/en/toast.d.ts +22 -0
- package/dist/messages/en/toast.d.ts.map +1 -0
- package/dist/messages/en/toast.js +21 -0
- package/dist/messages/en/toolbar.d.ts +47 -0
- package/dist/messages/en/toolbar.d.ts.map +1 -0
- package/dist/messages/en/toolbar.js +46 -0
- package/dist/messages/en/translation.d.ts +7 -0
- package/dist/messages/en/translation.d.ts.map +1 -0
- package/dist/messages/en/translation.js +6 -0
- package/dist/messages/en/ui.d.ts +4 -0
- package/dist/messages/en/ui.d.ts.map +1 -0
- package/dist/messages/en/ui.js +3 -0
- package/dist/messages/en/values.d.ts +45 -0
- package/dist/messages/en/values.d.ts.map +1 -0
- package/dist/messages/en/values.js +44 -0
- package/dist/messages/en.d.ts +1298 -202
- package/dist/messages/en.d.ts.map +1 -1
- package/dist/messages/en.js +82 -330
- package/dist/messages/index.d.ts +12 -0
- package/dist/messages/index.d.ts.map +1 -1
- package/dist/messages/index.js +28 -1
- package/dist/messages/pl/app.d.ts +8 -0
- package/dist/messages/pl/app.d.ts.map +1 -0
- package/dist/messages/pl/app.js +7 -0
- package/dist/messages/pl/blocks.d.ts +54 -0
- package/dist/messages/pl/blocks.d.ts.map +1 -0
- package/dist/messages/pl/blocks.js +53 -0
- package/dist/messages/pl/canvas.d.ts +31 -0
- package/dist/messages/pl/canvas.d.ts.map +1 -0
- package/dist/messages/pl/canvas.js +30 -0
- package/dist/messages/pl/clipboard.d.ts +13 -0
- package/dist/messages/pl/clipboard.d.ts.map +1 -0
- package/dist/messages/pl/clipboard.js +12 -0
- package/dist/messages/pl/colorPicker.d.ts +20 -0
- package/dist/messages/pl/colorPicker.d.ts.map +1 -0
- package/dist/messages/pl/colorPicker.js +19 -0
- package/dist/messages/pl/componentLabels.d.ts +9 -0
- package/dist/messages/pl/componentLabels.d.ts.map +1 -0
- package/dist/messages/pl/componentLabels.js +308 -0
- package/dist/messages/pl/diagnostics.d.ts +39 -0
- package/dist/messages/pl/diagnostics.d.ts.map +1 -0
- package/dist/messages/pl/diagnostics.js +38 -0
- package/dist/messages/pl/dialogs/common.d.ts +6 -0
- package/dist/messages/pl/dialogs/common.d.ts.map +1 -0
- package/dist/messages/pl/dialogs/common.js +5 -0
- package/dist/messages/pl/dialogs/conflict.d.ts +15 -0
- package/dist/messages/pl/dialogs/conflict.d.ts.map +1 -0
- package/dist/messages/pl/dialogs/conflict.js +14 -0
- package/dist/messages/pl/dialogs/delete.d.ts +19 -0
- package/dist/messages/pl/dialogs/delete.d.ts.map +1 -0
- package/dist/messages/pl/dialogs/delete.js +18 -0
- package/dist/messages/pl/dialogs/pageOptions.d.ts +9 -0
- package/dist/messages/pl/dialogs/pageOptions.d.ts.map +1 -0
- package/dist/messages/pl/dialogs/pageOptions.js +8 -0
- package/dist/messages/pl/dialogs/publish.d.ts +15 -0
- package/dist/messages/pl/dialogs/publish.d.ts.map +1 -0
- package/dist/messages/pl/dialogs/publish.js +14 -0
- package/dist/messages/pl/dnd.d.ts +19 -0
- package/dist/messages/pl/dnd.d.ts.map +1 -0
- package/dist/messages/pl/dnd.js +18 -0
- package/dist/messages/pl/editor.d.ts +30 -0
- package/dist/messages/pl/editor.d.ts.map +1 -0
- package/dist/messages/pl/editor.js +29 -0
- package/dist/messages/pl/external.d.ts +6 -0
- package/dist/messages/pl/external.d.ts.map +1 -0
- package/dist/messages/pl/external.js +5 -0
- package/dist/messages/pl/insert.d.ts +25 -0
- package/dist/messages/pl/insert.d.ts.map +1 -0
- package/dist/messages/pl/insert.js +24 -0
- package/dist/messages/pl/inspector.d.ts +176 -0
- package/dist/messages/pl/inspector.d.ts.map +1 -0
- package/dist/messages/pl/inspector.js +175 -0
- package/dist/messages/pl/issues.d.ts +36 -0
- package/dist/messages/pl/issues.d.ts.map +1 -0
- package/dist/messages/pl/issues.js +35 -0
- package/dist/messages/pl/layers.d.ts +29 -0
- package/dist/messages/pl/layers.d.ts.map +1 -0
- package/dist/messages/pl/layers.js +28 -0
- package/dist/messages/pl/leftPanel.d.ts +15 -0
- package/dist/messages/pl/leftPanel.d.ts.map +1 -0
- package/dist/messages/pl/leftPanel.js +14 -0
- package/dist/messages/pl/list.d.ts +9 -0
- package/dist/messages/pl/list.d.ts.map +1 -0
- package/dist/messages/pl/list.js +8 -0
- package/dist/messages/pl/locale.d.ts +4 -0
- package/dist/messages/pl/locale.d.ts.map +1 -0
- package/dist/messages/pl/locale.js +3 -0
- package/dist/messages/pl/media.d.ts +51 -0
- package/dist/messages/pl/media.d.ts.map +1 -0
- package/dist/messages/pl/media.js +50 -0
- package/dist/messages/pl/menu.d.ts +12 -0
- package/dist/messages/pl/menu.d.ts.map +1 -0
- package/dist/messages/pl/menu.js +11 -0
- package/dist/messages/pl/patterns.d.ts +24 -0
- package/dist/messages/pl/patterns.d.ts.map +1 -0
- package/dist/messages/pl/patterns.js +23 -0
- package/dist/messages/pl/preview.d.ts +8 -0
- package/dist/messages/pl/preview.d.ts.map +1 -0
- package/dist/messages/pl/preview.js +7 -0
- package/dist/messages/pl/publish.d.ts +19 -0
- package/dist/messages/pl/publish.d.ts.map +1 -0
- package/dist/messages/pl/publish.js +18 -0
- package/dist/messages/pl/richText.d.ts +21 -0
- package/dist/messages/pl/richText.d.ts.map +1 -0
- package/dist/messages/pl/richText.js +20 -0
- package/dist/messages/pl/sample.d.ts +5 -0
- package/dist/messages/pl/sample.d.ts.map +1 -0
- package/dist/messages/pl/sample.js +4 -0
- package/dist/messages/pl/save.d.ts +15 -0
- package/dist/messages/pl/save.d.ts.map +1 -0
- package/dist/messages/pl/save.js +14 -0
- package/dist/messages/pl/shortcut.d.ts +36 -0
- package/dist/messages/pl/shortcut.d.ts.map +1 -0
- package/dist/messages/pl/shortcut.js +35 -0
- package/dist/messages/pl/statusBar.d.ts +14 -0
- package/dist/messages/pl/statusBar.d.ts.map +1 -0
- package/dist/messages/pl/statusBar.js +13 -0
- package/dist/messages/pl/structure.d.ts +28 -0
- package/dist/messages/pl/structure.d.ts.map +1 -0
- package/dist/messages/pl/structure.js +27 -0
- package/dist/messages/pl/style.d.ts +168 -0
- package/dist/messages/pl/style.d.ts.map +1 -0
- package/dist/messages/pl/style.js +167 -0
- package/dist/messages/pl/styleField.d.ts +301 -0
- package/dist/messages/pl/styleField.d.ts.map +1 -0
- package/dist/messages/pl/styleField.js +300 -0
- package/dist/messages/pl/styleOption.d.ts +128 -0
- package/dist/messages/pl/styleOption.d.ts.map +1 -0
- package/dist/messages/pl/styleOption.js +127 -0
- package/dist/messages/pl/styleSection.d.ts +16 -0
- package/dist/messages/pl/styleSection.d.ts.map +1 -0
- package/dist/messages/pl/styleSection.js +15 -0
- package/dist/messages/pl/toast.d.ts +22 -0
- package/dist/messages/pl/toast.d.ts.map +1 -0
- package/dist/messages/pl/toast.js +21 -0
- package/dist/messages/pl/toolbar.d.ts +47 -0
- package/dist/messages/pl/toolbar.d.ts.map +1 -0
- package/dist/messages/pl/toolbar.js +46 -0
- package/dist/messages/pl/translation.d.ts +7 -0
- package/dist/messages/pl/translation.d.ts.map +1 -0
- package/dist/messages/pl/translation.js +6 -0
- package/dist/messages/pl/ui.d.ts +4 -0
- package/dist/messages/pl/ui.d.ts.map +1 -0
- package/dist/messages/pl/ui.js +3 -0
- package/dist/messages/pl/values.d.ts +45 -0
- package/dist/messages/pl/values.d.ts.map +1 -0
- package/dist/messages/pl/values.js +44 -0
- package/dist/messages/pl.d.ts.map +1 -1
- package/dist/messages/pl.js +82 -325
- package/dist/messages/plural.test.d.ts +2 -0
- package/dist/messages/plural.test.d.ts.map +1 -0
- package/dist/messages/plural.test.js +50 -0
- package/dist/panels/breadcrumbs/breadcrumbs.d.ts +1 -1
- package/dist/panels/breadcrumbs/breadcrumbs.d.ts.map +1 -1
- package/dist/panels/breadcrumbs/breadcrumbs.js +10 -3
- package/dist/panels/breadcrumbs/breadcrumbs.test.js +9 -2
- package/dist/panels/index.d.ts +3 -0
- package/dist/panels/index.d.ts.map +1 -1
- package/dist/panels/index.js +1 -0
- package/dist/panels/insert/catalog.d.ts +21 -1
- package/dist/panels/insert/catalog.d.ts.map +1 -1
- package/dist/panels/insert/catalog.js +85 -3
- package/dist/panels/insert/catalog.order.test.js +106 -1
- package/dist/panels/insert/index.d.ts +1 -0
- package/dist/panels/insert/index.d.ts.map +1 -1
- package/dist/panels/insert/insert-panel.d.ts +14 -4
- package/dist/panels/insert/insert-panel.d.ts.map +1 -1
- package/dist/panels/insert/insert-panel.js +128 -69
- package/dist/panels/insert/insert-panel.test.js +278 -37
- package/dist/panels/insert/target.d.ts +5 -1
- package/dist/panels/insert/target.d.ts.map +1 -1
- package/dist/panels/insert/target.js +11 -1
- package/dist/panels/inspector/author-fields.d.ts +21 -0
- package/dist/panels/inspector/author-fields.d.ts.map +1 -0
- package/dist/panels/inspector/author-fields.js +191 -0
- package/dist/panels/inspector/author-fields.test.d.ts +2 -0
- package/dist/panels/inspector/author-fields.test.d.ts.map +1 -0
- package/dist/panels/inspector/author-fields.test.js +237 -0
- package/dist/panels/inspector/controls/external-link.d.ts +24 -0
- package/dist/panels/inspector/controls/external-link.d.ts.map +1 -0
- package/dist/panels/inspector/controls/external-link.js +43 -0
- package/dist/panels/inspector/controls/external-link.test.d.ts +2 -0
- package/dist/panels/inspector/controls/external-link.test.d.ts.map +1 -0
- package/dist/panels/inspector/controls/external-link.test.js +105 -0
- package/dist/panels/inspector/controls/index.d.ts +1 -0
- package/dist/panels/inspector/controls/index.d.ts.map +1 -1
- package/dist/panels/inspector/controls/index.js +1 -0
- package/dist/panels/inspector/controls/media.d.ts +3 -1
- package/dist/panels/inspector/controls/media.d.ts.map +1 -1
- package/dist/panels/inspector/controls/media.js +8 -3
- package/dist/panels/inspector/controls/rich-text.d.ts.map +1 -1
- package/dist/panels/inspector/controls/rich-text.js +36 -6
- package/dist/panels/inspector/controls/textarea.d.ts +7 -2
- package/dist/panels/inspector/controls/textarea.d.ts.map +1 -1
- package/dist/panels/inspector/controls/textarea.js +37 -2
- package/dist/panels/inspector/default-hint.d.ts +13 -0
- package/dist/panels/inspector/default-hint.d.ts.map +1 -0
- package/dist/panels/inspector/default-hint.js +30 -0
- package/dist/panels/inspector/default-hint.test.d.ts +2 -0
- package/dist/panels/inspector/default-hint.test.d.ts.map +1 -0
- package/dist/panels/inspector/default-hint.test.js +46 -0
- package/dist/panels/inspector/index.d.ts +3 -3
- package/dist/panels/inspector/index.d.ts.map +1 -1
- package/dist/panels/inspector/index.js +2 -2
- package/dist/panels/inspector/inspector.d.ts +20 -2
- package/dist/panels/inspector/inspector.d.ts.map +1 -1
- package/dist/panels/inspector/inspector.js +246 -26
- package/dist/panels/inspector/inspector.test.js +276 -11
- package/dist/panels/inspector/props-panel.d.ts +36 -0
- package/dist/panels/inspector/props-panel.d.ts.map +1 -1
- package/dist/panels/inspector/props-panel.js +99 -17
- package/dist/panels/inspector/props-panel.test.d.ts +2 -0
- package/dist/panels/inspector/props-panel.test.d.ts.map +1 -0
- package/dist/panels/inspector/props-panel.test.js +17 -0
- package/dist/panels/inspector/scrub-label.d.ts +14 -0
- package/dist/panels/inspector/scrub-label.d.ts.map +1 -0
- package/dist/panels/inspector/scrub-label.js +75 -0
- package/dist/panels/inspector/scrub-label.test.d.ts +2 -0
- package/dist/panels/inspector/scrub-label.test.d.ts.map +1 -0
- package/dist/panels/inspector/scrub-label.test.js +132 -0
- package/dist/panels/inspector/styles/background-media.d.ts +28 -0
- package/dist/panels/inspector/styles/background-media.d.ts.map +1 -0
- package/dist/panels/inspector/styles/background-media.js +78 -0
- package/dist/panels/inspector/styles/box-model.d.ts +13 -16
- package/dist/panels/inspector/styles/box-model.d.ts.map +1 -1
- package/dist/panels/inspector/styles/box-model.js +10 -25
- package/dist/panels/inspector/styles/color-input.d.ts +3 -0
- package/dist/panels/inspector/styles/color-input.d.ts.map +1 -0
- package/dist/panels/inspector/styles/color-input.js +72 -0
- package/dist/panels/inspector/styles/gradient-fields.d.ts +9 -0
- package/dist/panels/inspector/styles/gradient-fields.d.ts.map +1 -0
- package/dist/panels/inspector/styles/gradient-fields.js +50 -0
- package/dist/panels/inspector/styles/index.d.ts +2 -0
- package/dist/panels/inspector/styles/index.d.ts.map +1 -1
- package/dist/panels/inspector/styles/index.js +2 -0
- package/dist/panels/inspector/styles/model.d.ts +27 -5
- package/dist/panels/inspector/styles/model.d.ts.map +1 -1
- package/dist/panels/inspector/styles/model.js +101 -3
- package/dist/panels/inspector/styles/motion-rows.d.ts +17 -0
- package/dist/panels/inspector/styles/motion-rows.d.ts.map +1 -0
- package/dist/panels/inspector/styles/motion-rows.js +117 -0
- package/dist/panels/inspector/styles/number-input.d.ts +4 -0
- package/dist/panels/inspector/styles/number-input.d.ts.map +1 -0
- package/dist/panels/inspector/styles/number-input.js +12 -0
- package/dist/panels/inspector/styles/option-label.d.ts +7 -0
- package/dist/panels/inspector/styles/option-label.d.ts.map +1 -0
- package/dist/panels/inspector/styles/option-label.js +9 -0
- package/dist/panels/inspector/styles/property-label.d.ts +9 -0
- package/dist/panels/inspector/styles/property-label.d.ts.map +1 -0
- package/dist/panels/inspector/styles/property-label.js +11 -0
- package/dist/panels/inspector/styles/section-state.d.ts +22 -0
- package/dist/panels/inspector/styles/section-state.d.ts.map +1 -0
- package/dist/panels/inspector/styles/section-state.js +96 -0
- package/dist/panels/inspector/styles/section.d.ts +25 -0
- package/dist/panels/inspector/styles/section.d.ts.map +1 -0
- package/dist/panels/inspector/styles/section.js +43 -0
- package/dist/panels/inspector/styles/sections-context.d.ts +13 -0
- package/dist/panels/inspector/styles/sections-context.d.ts.map +1 -0
- package/dist/panels/inspector/styles/sections-context.js +19 -0
- package/dist/panels/inspector/styles/sections-context.test.d.ts +2 -0
- package/dist/panels/inspector/styles/sections-context.test.d.ts.map +1 -0
- package/dist/panels/inspector/styles/sections-context.test.js +18 -0
- package/dist/panels/inspector/styles/sections-toggle.d.ts +6 -0
- package/dist/panels/inspector/styles/sections-toggle.d.ts.map +1 -0
- package/dist/panels/inspector/styles/sections-toggle.js +18 -0
- package/dist/panels/inspector/styles/segments.d.ts +3 -0
- package/dist/panels/inspector/styles/segments.d.ts.map +1 -1
- package/dist/panels/inspector/styles/segments.js +11 -4
- package/dist/panels/inspector/styles/sides-editor.d.ts +1 -1
- package/dist/panels/inspector/styles/sides-editor.d.ts.map +1 -1
- package/dist/panels/inspector/styles/sides-editor.js +33 -4
- package/dist/panels/inspector/styles/style-inspector.d.ts +3 -1
- package/dist/panels/inspector/styles/style-inspector.d.ts.map +1 -1
- package/dist/panels/inspector/styles/style-inspector.js +610 -42
- package/dist/panels/inspector/styles/style-inspector.test.js +694 -14
- package/dist/panels/inspector/styles/token-picker.d.ts +1 -1
- package/dist/panels/inspector/styles/token-picker.d.ts.map +1 -1
- package/dist/panels/inspector/styles/token-picker.js +10 -3
- package/dist/panels/inspector/styles/widgets.d.ts +116 -0
- package/dist/panels/inspector/styles/widgets.d.ts.map +1 -0
- package/dist/panels/inspector/styles/widgets.js +304 -0
- package/dist/panels/inspector/styles/widgets.test.d.ts +2 -0
- package/dist/panels/inspector/styles/widgets.test.d.ts.map +1 -0
- package/dist/panels/inspector/styles/widgets.test.js +247 -0
- package/dist/panels/inspector/values/value-editor.d.ts +1 -1
- package/dist/panels/inspector/values/value-editor.d.ts.map +1 -1
- package/dist/panels/inspector/values/value-editor.js +9 -8
- package/dist/panels/inspector/values/values.test.js +9 -3
- package/dist/panels/issues/collect.d.ts +2 -0
- package/dist/panels/issues/collect.d.ts.map +1 -1
- package/dist/panels/issues/collect.js +1 -0
- package/dist/panels/issues/index.d.ts +1 -0
- package/dist/panels/issues/index.d.ts.map +1 -1
- package/dist/panels/issues/index.js +1 -0
- package/dist/panels/issues/issues-panel.d.ts +4 -3
- package/dist/panels/issues/issues-panel.d.ts.map +1 -1
- package/dist/panels/issues/issues-panel.js +22 -35
- package/dist/panels/issues/path.d.ts +7 -0
- package/dist/panels/issues/path.d.ts.map +1 -0
- package/dist/panels/issues/path.js +21 -0
- package/dist/panels/layers/flatten.d.ts +16 -2
- package/dist/panels/layers/flatten.d.ts.map +1 -1
- package/dist/panels/layers/flatten.js +48 -4
- package/dist/panels/layers/layers-panel.d.ts +5 -2
- package/dist/panels/layers/layers-panel.d.ts.map +1 -1
- package/dist/panels/layers/layers-panel.js +177 -35
- package/dist/panels/layers/layers-panel.test.js +173 -15
- package/dist/panels/left-panel.d.ts +17 -0
- package/dist/panels/left-panel.d.ts.map +1 -0
- package/dist/panels/left-panel.js +47 -0
- package/dist/panels/left-panel.test.d.ts +2 -0
- package/dist/panels/left-panel.test.d.ts.map +1 -0
- package/dist/panels/left-panel.test.js +77 -0
- package/dist/persistence/persistence.test.js +9 -3
- package/dist/persistence/react.d.ts.map +1 -1
- package/dist/persistence/react.js +2 -2
- package/dist/preview/preview.d.ts +8 -0
- package/dist/preview/preview.d.ts.map +1 -1
- package/dist/preview/preview.js +21 -1
- package/dist/preview/preview.test.js +18 -1
- package/dist/shortcuts/actions.d.ts +13 -2
- package/dist/shortcuts/actions.d.ts.map +1 -1
- package/dist/shortcuts/actions.js +70 -15
- package/dist/shortcuts/help.d.ts +11 -0
- package/dist/shortcuts/help.d.ts.map +1 -0
- package/dist/shortcuts/help.js +77 -0
- package/dist/shortcuts/index.d.ts +5 -2
- package/dist/shortcuts/index.d.ts.map +1 -1
- package/dist/shortcuts/index.js +3 -1
- package/dist/shortcuts/map.d.ts +1 -1
- package/dist/shortcuts/map.d.ts.map +1 -1
- package/dist/shortcuts/map.js +14 -8
- package/dist/shortcuts/navigation.d.ts +13 -0
- package/dist/shortcuts/navigation.d.ts.map +1 -0
- package/dist/shortcuts/navigation.js +48 -0
- package/dist/shortcuts/shortcuts.d.ts +12 -1
- package/dist/shortcuts/shortcuts.d.ts.map +1 -1
- package/dist/shortcuts/shortcuts.js +61 -14
- package/dist/shortcuts/shortcuts.test.js +206 -5
- package/dist/store/create-store.d.ts.map +1 -1
- package/dist/store/create-store.js +19 -1
- package/dist/store/index.d.ts +4 -1
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +3 -1
- package/dist/store/react.d.ts +4 -0
- package/dist/store/react.d.ts.map +1 -1
- package/dist/store/react.js +7 -0
- package/dist/store/store.test.js +24 -0
- package/dist/store/structure-lock.d.ts +16 -0
- package/dist/store/structure-lock.d.ts.map +1 -0
- package/dist/store/structure-lock.js +43 -0
- package/dist/store/structure-lock.test.d.ts +2 -0
- package/dist/store/structure-lock.test.d.ts.map +1 -0
- package/dist/store/structure-lock.test.js +49 -0
- package/dist/store/types.d.ts +9 -0
- package/dist/store/types.d.ts.map +1 -1
- package/dist/store/view.d.ts +20 -0
- package/dist/store/view.d.ts.map +1 -0
- package/dist/store/view.js +17 -0
- package/dist/store/view.test.d.ts +2 -0
- package/dist/store/view.test.d.ts.map +1 -0
- package/dist/store/view.test.js +103 -0
- package/dist/styles/tokens.test.js +88 -9
- package/dist/styles.css +4112 -586
- package/dist/toolbar/brand.d.ts +2 -2
- package/dist/toolbar/brand.d.ts.map +1 -1
- package/dist/toolbar/brand.js +4 -4
- package/dist/toolbar/breakpoint-control.d.ts +4 -0
- package/dist/toolbar/breakpoint-control.d.ts.map +1 -1
- package/dist/toolbar/breakpoint-control.js +11 -4
- package/dist/toolbar/editable-title.d.ts +4 -1
- package/dist/toolbar/editable-title.d.ts.map +1 -1
- package/dist/toolbar/editable-title.js +2 -2
- package/dist/toolbar/editable-title.test.js +10 -0
- package/dist/toolbar/locale-chip.d.ts +10 -0
- package/dist/toolbar/locale-chip.d.ts.map +1 -0
- package/dist/toolbar/locale-chip.js +27 -0
- package/dist/toolbar/locale-switcher.d.ts.map +1 -1
- package/dist/toolbar/locale-switcher.js +4 -1
- package/dist/toolbar/more-menu.d.ts +26 -4
- package/dist/toolbar/more-menu.d.ts.map +1 -1
- package/dist/toolbar/more-menu.js +60 -13
- package/dist/toolbar/page-chip.d.ts +10 -0
- package/dist/toolbar/page-chip.d.ts.map +1 -0
- package/dist/toolbar/page-chip.js +12 -0
- package/dist/toolbar/page-options-dialog.d.ts +16 -0
- package/dist/toolbar/page-options-dialog.d.ts.map +1 -0
- package/dist/toolbar/page-options-dialog.js +13 -0
- package/dist/toolbar/panel-toggles.d.ts +3 -2
- package/dist/toolbar/panel-toggles.d.ts.map +1 -1
- package/dist/toolbar/panel-toggles.js +9 -4
- package/dist/toolbar/publish-dialog.d.ts +3 -0
- package/dist/toolbar/publish-dialog.d.ts.map +1 -1
- package/dist/toolbar/publish-dialog.js +34 -7
- package/dist/toolbar/publish.test.js +63 -19
- package/dist/toolbar/safe-history.d.ts +3 -0
- package/dist/toolbar/safe-history.d.ts.map +1 -0
- package/dist/toolbar/safe-history.js +5 -0
- package/dist/toolbar/sample-picker.d.ts +24 -4
- package/dist/toolbar/sample-picker.d.ts.map +1 -1
- package/dist/toolbar/sample-picker.js +42 -18
- package/dist/toolbar/toolbar-centre.d.ts +3 -11
- package/dist/toolbar/toolbar-centre.d.ts.map +1 -1
- package/dist/toolbar/toolbar-centre.js +4 -5
- package/dist/toolbar/toolbar-left.d.ts +4 -7
- package/dist/toolbar/toolbar-left.d.ts.map +1 -1
- package/dist/toolbar/toolbar-left.js +13 -11
- package/dist/toolbar/toolbar-right.d.ts +21 -6
- package/dist/toolbar/toolbar-right.d.ts.map +1 -1
- package/dist/toolbar/toolbar-right.js +28 -14
- package/dist/toolbar/toolbar.d.ts +23 -17
- package/dist/toolbar/toolbar.d.ts.map +1 -1
- package/dist/toolbar/toolbar.js +28 -11
- package/dist/toolbar/toolbar.test.js +238 -23
- package/dist/toolbar/use-overflow-level.d.ts +2 -1
- package/dist/toolbar/use-overflow-level.d.ts.map +1 -1
- package/dist/toolbar/use-overflow-level.js +9 -3
- package/dist/toolbar/zoom-menu.d.ts +5 -1
- package/dist/toolbar/zoom-menu.d.ts.map +1 -1
- package/dist/toolbar/zoom-menu.js +3 -2
- package/dist/ui/icon.d.ts +53 -0
- package/dist/ui/icon.d.ts.map +1 -1
- package/dist/ui/icon.js +58 -1
- package/dist/ui/icon.test.js +101 -3
- package/dist/ui/index.d.ts +4 -3
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +3 -2
- package/dist/ui/primitives.d.ts +97 -14
- package/dist/ui/primitives.d.ts.map +1 -1
- package/dist/ui/primitives.js +108 -22
- package/dist/ui/primitives.test.js +204 -3
- package/dist/ui/structure-locked.d.ts +9 -0
- package/dist/ui/structure-locked.d.ts.map +1 -0
- package/dist/ui/structure-locked.js +28 -0
- package/dist/ui/toast.d.ts +3 -1
- package/dist/ui/toast.d.ts.map +1 -1
- package/dist/ui/toast.js +21 -5
- package/dist/ui/toast.test.js +34 -0
- package/package.json +5 -4
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { checkAttributes, checkClasses, compileCustomCss, MAX_ATTRIBUTES, MAX_CLASSES, MAX_CUSTOM_CSS_LENGTH, } from '@next-buildr/core';
|
|
3
|
+
import { useEffect, useId, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { interpolate, useT } from '../../messages/index.js';
|
|
5
|
+
import { useEditor } from '../../store/index.js';
|
|
6
|
+
import { Button, IconButton, Input } from '../../ui/index.js';
|
|
7
|
+
/** Adds " (line N)" to a CSS problem that quotes a piece of the source: the first line it appears on. */
|
|
8
|
+
export function describeCssProblem(source, message, line) {
|
|
9
|
+
const quoted = /"([^"]{1,40})"/.exec(message)?.[1];
|
|
10
|
+
const at = quoted === undefined ? -1 : source.indexOf(quoted);
|
|
11
|
+
if (at < 0)
|
|
12
|
+
return message;
|
|
13
|
+
return `${message} (${interpolate(line, { line: String(source.slice(0, at).split('\n').length) })})`;
|
|
14
|
+
}
|
|
15
|
+
/** Why a CSS source cannot be stored; empty when it can (or when it is empty). */
|
|
16
|
+
export function cssProblems(source) {
|
|
17
|
+
return source.trim() === '' ? [] : compileCustomCss('.b-check', source).errors;
|
|
18
|
+
}
|
|
19
|
+
/** Runs `node.setAttr`; the message of a refusal, or `''`. */
|
|
20
|
+
function useWriteAttr(nodeId) {
|
|
21
|
+
const store = useEditor();
|
|
22
|
+
return (key, value) => {
|
|
23
|
+
const result = store.dispatch({
|
|
24
|
+
type: 'node.setAttr',
|
|
25
|
+
payload: { id: nodeId, key, value },
|
|
26
|
+
});
|
|
27
|
+
return result.ok ? '' : (result.error?.message ?? '');
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function Problems(props) {
|
|
31
|
+
if (props.list.length === 0)
|
|
32
|
+
return null;
|
|
33
|
+
return (_jsxs("div", { id: props.id, role: "alert", className: "bd-author-problems", children: [_jsx("strong", { children: props.title }), _jsx("ul", { children: props.list.map((problem) => (_jsx("li", { children: problem }, problem))) })] }));
|
|
34
|
+
}
|
|
35
|
+
/** Custom CSS for the block: a code field that applies when it loses focus (or with Ctrl+Enter) and only when valid. */
|
|
36
|
+
export function CssField({ node, disabled }) {
|
|
37
|
+
const t = useT();
|
|
38
|
+
const id = useId();
|
|
39
|
+
const write = useWriteAttr(node.id);
|
|
40
|
+
const stored = node.customCss ?? '';
|
|
41
|
+
const [draft, setDraft] = useState(undefined);
|
|
42
|
+
const [refused, setRefused] = useState('');
|
|
43
|
+
const shown = draft ?? stored;
|
|
44
|
+
// An undo or a redo changes the stored CSS: show it, dropping a draft it replaces.
|
|
45
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: only a change of the stored value resets the draft
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
setDraft(undefined);
|
|
48
|
+
setRefused('');
|
|
49
|
+
}, [stored]);
|
|
50
|
+
const line = t('inspector.css.line');
|
|
51
|
+
const problems = useMemo(() => cssProblems(shown).map((message) => describeCssProblem(shown, message, line)), [shown, line]);
|
|
52
|
+
const list = refused !== '' && problems.length === 0 ? [refused] : problems;
|
|
53
|
+
const apply = () => {
|
|
54
|
+
if (draft === undefined || problems.length > 0)
|
|
55
|
+
return;
|
|
56
|
+
const value = draft.trim();
|
|
57
|
+
if (value === stored.trim()) {
|
|
58
|
+
setDraft(undefined);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const message = write('customCss', value === '' ? null : value);
|
|
62
|
+
setRefused(message);
|
|
63
|
+
if (message === '')
|
|
64
|
+
setDraft(undefined);
|
|
65
|
+
};
|
|
66
|
+
const remove = () => {
|
|
67
|
+
setRefused(write('customCss', null));
|
|
68
|
+
setDraft(undefined);
|
|
69
|
+
};
|
|
70
|
+
const errorId = `${id}-error`;
|
|
71
|
+
return (_jsxs("div", { className: "bd-field bd-author-field", "data-attr": "customCss", children: [_jsx("div", { className: "bd-field-head", children: _jsx("label", { className: "bd-field-label", htmlFor: id, children: t('inspector.css.label') }) }), _jsx("textarea", { id: id, className: "bd-input bd-textarea bd-code", rows: 8, value: shown, maxLength: MAX_CUSTOM_CSS_LENGTH, disabled: disabled, spellCheck: false, autoComplete: "off", autoCapitalize: "off", placeholder: "& { }", "aria-invalid": list.length > 0, "aria-describedby": list.length > 0 ? errorId : `${id}-hint`, onChange: (event) => {
|
|
72
|
+
setDraft(event.target.value);
|
|
73
|
+
setRefused('');
|
|
74
|
+
}, onBlur: apply, onKeyDown: (event) => {
|
|
75
|
+
if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
apply();
|
|
78
|
+
}
|
|
79
|
+
} }), _jsx(Problems, { id: errorId, title: t('inspector.css.error'), list: list }), _jsx("p", { className: "bd-field-hint", id: `${id}-hint`, children: t('inspector.css.hint') }), _jsxs("div", { className: "bd-author-actions", children: [_jsx(Button, { variant: "ghost", disabled: disabled || draft === undefined || problems.length > 0, onClick: apply, children: t('inspector.css.apply') }), stored !== '' ? (_jsx(Button, { variant: "ghost", disabled: disabled, onClick: remove, children: t('inspector.css.remove') })) : null, draft === undefined && stored !== '' ? (_jsx("span", { className: "bd-author-ok", role: "status", children: t('inspector.css.applied') })) : null] })] }));
|
|
80
|
+
}
|
|
81
|
+
const tokensOf = (text) => text.split(/\s+/).filter((part) => part !== '');
|
|
82
|
+
/** CSS classes of the block, as a space-separated list. */
|
|
83
|
+
export function ClassesField({ node, disabled }) {
|
|
84
|
+
const t = useT();
|
|
85
|
+
const id = useId();
|
|
86
|
+
const write = useWriteAttr(node.id);
|
|
87
|
+
const stored = (node.classes ?? []).join(' ');
|
|
88
|
+
const [draft, setDraft] = useState(undefined);
|
|
89
|
+
const [refused, setRefused] = useState('');
|
|
90
|
+
const shown = draft ?? stored;
|
|
91
|
+
// An undo or a redo changes the stored classes: show them, dropping a draft they replace.
|
|
92
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: only a change of the stored value resets the draft
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
setDraft(undefined);
|
|
95
|
+
setRefused('');
|
|
96
|
+
}, [stored]);
|
|
97
|
+
const checked = useMemo(() => {
|
|
98
|
+
const names = tokensOf(shown);
|
|
99
|
+
return names.length === 0 ? undefined : checkClasses(names);
|
|
100
|
+
}, [shown]);
|
|
101
|
+
const problem = checked !== undefined && !checked.ok ? checked.error : refused;
|
|
102
|
+
const apply = () => {
|
|
103
|
+
if (draft === undefined || (checked !== undefined && !checked.ok))
|
|
104
|
+
return;
|
|
105
|
+
const names = checked?.ok === true ? checked.value : [];
|
|
106
|
+
if (names.join(' ') === stored) {
|
|
107
|
+
setDraft(undefined);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const message = write('classes', names.length === 0 ? null : names);
|
|
111
|
+
setRefused(message);
|
|
112
|
+
if (message === '')
|
|
113
|
+
setDraft(undefined);
|
|
114
|
+
};
|
|
115
|
+
return (_jsxs("div", { className: "bd-field bd-author-field", "data-attr": "classes", children: [_jsx("div", { className: "bd-field-head", children: _jsx("label", { className: "bd-field-label", htmlFor: id, children: t('inspector.classes.label') }) }), _jsx(Input, { id: id, className: "bd-code", value: shown, disabled: disabled, spellCheck: false, autoComplete: "off", autoCapitalize: "off", "aria-invalid": problem !== '', "aria-describedby": problem !== '' ? `${id}-error` : `${id}-hint`, onChange: (event) => {
|
|
116
|
+
setDraft(event.target.value);
|
|
117
|
+
setRefused('');
|
|
118
|
+
}, onBlur: apply, onKeyDown: (event) => {
|
|
119
|
+
if (event.key === 'Enter')
|
|
120
|
+
apply();
|
|
121
|
+
} }), _jsx(Problems, { id: `${id}-error`, title: t('inspector.css.error'), list: problem === '' ? [] : [problem] }), _jsx("p", { className: "bd-field-hint", id: `${id}-hint`, children: interpolate(t('inspector.classes.hint'), { max: MAX_CLASSES }) })] }));
|
|
122
|
+
}
|
|
123
|
+
const canonical = (record) => JSON.stringify(Object.entries(record).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
|
|
124
|
+
/** The record the rows stand for (rows without a name are ignored), or the first problem. */
|
|
125
|
+
function recordOf(rows, duplicate) {
|
|
126
|
+
const out = {};
|
|
127
|
+
for (const row of rows) {
|
|
128
|
+
const name = row.name.trim();
|
|
129
|
+
if (name === '')
|
|
130
|
+
continue;
|
|
131
|
+
if (Object.hasOwn(out, name))
|
|
132
|
+
return { ok: false, error: `${duplicate}: ${name}` };
|
|
133
|
+
Object.defineProperty(out, name, {
|
|
134
|
+
value: row.value,
|
|
135
|
+
enumerable: true,
|
|
136
|
+
writable: true,
|
|
137
|
+
configurable: true,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
const checked = checkAttributes(out);
|
|
141
|
+
return checked.ok ? { ok: true, value: out } : { ok: false, error: checked.error };
|
|
142
|
+
}
|
|
143
|
+
/** HTML attributes of the block as name and value rows; a row applies once its name and value are valid. */
|
|
144
|
+
export function AttributesField({ node, disabled }) {
|
|
145
|
+
const t = useT();
|
|
146
|
+
const id = useId();
|
|
147
|
+
const write = useWriteAttr(node.id);
|
|
148
|
+
const counter = useRef(0);
|
|
149
|
+
const fromNode = () => Object.entries(node.attributes ?? {}).map(([name, value]) => ({
|
|
150
|
+
key: counter.current++,
|
|
151
|
+
name,
|
|
152
|
+
value,
|
|
153
|
+
}));
|
|
154
|
+
const [rows, setRows] = useState(fromNode);
|
|
155
|
+
const [refused, setRefused] = useState('');
|
|
156
|
+
const storedKey = canonical(node.attributes ?? {});
|
|
157
|
+
const parsed = recordOf(rows, t('inspector.attributes.duplicate'));
|
|
158
|
+
const problem = !parsed.ok ? parsed.error : refused;
|
|
159
|
+
// An undo or a redo changes the stored attributes under the rows: show what is stored.
|
|
160
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: only a change of the stored value resets the rows
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
const now = recordOf(rows, '');
|
|
163
|
+
if (!now.ok || canonical(now.value) !== storedKey) {
|
|
164
|
+
setRows(fromNode());
|
|
165
|
+
setRefused('');
|
|
166
|
+
}
|
|
167
|
+
}, [storedKey]);
|
|
168
|
+
const commit = (next) => {
|
|
169
|
+
const record = recordOf(next, t('inspector.attributes.duplicate'));
|
|
170
|
+
if (!record.ok)
|
|
171
|
+
return;
|
|
172
|
+
if (canonical(record.value) === storedKey)
|
|
173
|
+
return;
|
|
174
|
+
const message = write('attributes', Object.keys(record.value).length === 0 ? null : record.value);
|
|
175
|
+
setRefused(message);
|
|
176
|
+
};
|
|
177
|
+
const edit = (key, patch) => {
|
|
178
|
+
setRows(rows.map((row) => (row.key === key ? { ...row, ...patch } : row)));
|
|
179
|
+
setRefused('');
|
|
180
|
+
};
|
|
181
|
+
return (_jsxs("div", { className: "bd-field bd-author-field", "data-attr": "attributes", children: [_jsx("ul", { className: "bd-author-attrs", children: rows.map((row) => (_jsxs("li", { className: "bd-author-attr", children: [_jsx(Input, { className: "bd-code", "aria-label": t('inspector.attributes.name'), placeholder: "data-id", value: row.name, disabled: disabled, spellCheck: false, autoComplete: "off", onChange: (event) => edit(row.key, { name: event.target.value }), onBlur: () => commit(rows) }), _jsx(Input, { className: "bd-code", "aria-label": t('inspector.attributes.value'), value: row.value, disabled: disabled, spellCheck: false, autoComplete: "off", onChange: (event) => edit(row.key, { value: event.target.value }), onBlur: () => commit(rows) }), _jsx(IconButton, { variant: "ghost", icon: "trash-2", label: t('inspector.attributes.remove'), disabled: disabled, onClick: () => {
|
|
182
|
+
const next = rows.filter((other) => other.key !== row.key);
|
|
183
|
+
setRows(next);
|
|
184
|
+
commit(next);
|
|
185
|
+
} })] }, row.key))) }), _jsx(Problems, { id: `${id}-error`, title: t('inspector.attributes.error'), list: problem === '' ? [] : [problem] }), _jsx("div", { className: "bd-author-actions", children: _jsx(Button, { variant: "ghost", disabled: disabled || rows.length >= MAX_ATTRIBUTES, onClick: () => setRows([...rows, { key: counter.current++, name: '', value: '' }]), children: t('inspector.attributes.add') }) }), _jsx("p", { className: "bd-field-hint", children: t('inspector.attributes.hint') })] }));
|
|
186
|
+
}
|
|
187
|
+
/** What the Advanced tab says while the host has not enabled author code: a quiet note, no fields. */
|
|
188
|
+
export function AuthorOffNote({ held }) {
|
|
189
|
+
const t = useT();
|
|
190
|
+
return (_jsxs("div", { className: "bd-author-off", "data-state": "author-off", children: [_jsx("p", { className: "bd-field-hint", children: t('inspector.author.off') }), held ? _jsx("p", { className: "bd-field-hint", children: t('inspector.author.offHeld') }) : null] }));
|
|
191
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"author-fields.test.d.ts","sourceRoot":"","sources":["../../../src/panels/inspector/author-fields.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// @vitest-environment jsdom
|
|
3
|
+
import { createRegistryMeta, createSeededIdGenerator, p, toManifest, } from '@next-buildr/core';
|
|
4
|
+
import { act } from 'react';
|
|
5
|
+
import { createRoot } from 'react-dom/client';
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
7
|
+
import { ManifestProvider } from '../../app/manifest.js';
|
|
8
|
+
import { MessagesProvider } from '../../messages/index.js';
|
|
9
|
+
import { createEditorStore, EditorStoreProvider } from '../../store/index.js';
|
|
10
|
+
import { cssProblems, describeCssProblem } from './author-fields.js';
|
|
11
|
+
import { Inspector } from './inspector.js';
|
|
12
|
+
import { hasTextModes } from './props-panel.js';
|
|
13
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
14
|
+
const text = {
|
|
15
|
+
type: 'buildr/text',
|
|
16
|
+
version: 1,
|
|
17
|
+
label: 'Text',
|
|
18
|
+
category: 'content',
|
|
19
|
+
props: {
|
|
20
|
+
mode: p.select({ options: ['plain', 'rich', 'html'], default: 'plain', group: 'content' }),
|
|
21
|
+
text: p.textarea({ default: 'Hello', group: 'content' }),
|
|
22
|
+
rich: p.richText({ label: 'Rich text', group: 'content' }),
|
|
23
|
+
html: p.textarea({ format: 'html', default: '', group: 'content' }),
|
|
24
|
+
},
|
|
25
|
+
contentCategories: ['flow'],
|
|
26
|
+
styles: { groups: [] },
|
|
27
|
+
runtime: 'shared',
|
|
28
|
+
slots: { default: {} },
|
|
29
|
+
};
|
|
30
|
+
const page = {
|
|
31
|
+
...text,
|
|
32
|
+
type: 'buildr/page',
|
|
33
|
+
label: 'Page',
|
|
34
|
+
props: {},
|
|
35
|
+
capabilities: { root: true },
|
|
36
|
+
};
|
|
37
|
+
const registry = createRegistryMeta({ components: [page, text] });
|
|
38
|
+
const manifest = toManifest(registry);
|
|
39
|
+
const fixture = () => ({
|
|
40
|
+
schemaVersion: 1,
|
|
41
|
+
root: 'root',
|
|
42
|
+
nodes: {
|
|
43
|
+
root: { id: 'root', type: 'buildr/page', slots: { default: ['text00001'] } },
|
|
44
|
+
text00001: { id: 'text00001', type: 'buildr/text' },
|
|
45
|
+
},
|
|
46
|
+
components: {},
|
|
47
|
+
});
|
|
48
|
+
let container;
|
|
49
|
+
let root;
|
|
50
|
+
beforeEach(() => {
|
|
51
|
+
container = document.createElement('div');
|
|
52
|
+
document.body.append(container);
|
|
53
|
+
root = createRoot(container);
|
|
54
|
+
Element.prototype.scrollIntoView ??= () => { };
|
|
55
|
+
Element.prototype.hasPointerCapture ??= () => false;
|
|
56
|
+
Element.prototype.setPointerCapture ??= () => { };
|
|
57
|
+
Element.prototype.releasePointerCapture ??= () => { };
|
|
58
|
+
});
|
|
59
|
+
afterEach(() => {
|
|
60
|
+
act(() => root.unmount());
|
|
61
|
+
document.body.innerHTML = '';
|
|
62
|
+
});
|
|
63
|
+
async function mount(authorCode, tab = 'Advanced') {
|
|
64
|
+
const store = createEditorStore({
|
|
65
|
+
doc: fixture(),
|
|
66
|
+
registry,
|
|
67
|
+
generateId: createSeededIdGenerator(3),
|
|
68
|
+
validationDelayMs: null,
|
|
69
|
+
...(authorCode === undefined ? {} : { capabilities: { authorCode } }),
|
|
70
|
+
});
|
|
71
|
+
store.select('text00001');
|
|
72
|
+
await act(async () => root.render(_jsx(MessagesProvider, { locale: "en", children: _jsx(ManifestProvider, { manifest: manifest, children: _jsx(EditorStoreProvider, { store: store, children: _jsx(Inspector, {}) }) }) })));
|
|
73
|
+
await act(async () => {
|
|
74
|
+
const el = [...container.querySelectorAll('[role=tab]')].find((t) => t.textContent === tab);
|
|
75
|
+
el?.dispatchEvent(new MouseEvent('mousedown', { bubbles: true, button: 0 }));
|
|
76
|
+
});
|
|
77
|
+
return store;
|
|
78
|
+
}
|
|
79
|
+
const typeInto = (element, value) => act(async () => {
|
|
80
|
+
const proto = element instanceof HTMLTextAreaElement
|
|
81
|
+
? HTMLTextAreaElement.prototype
|
|
82
|
+
: HTMLInputElement.prototype;
|
|
83
|
+
Object.getOwnPropertyDescriptor(proto, 'value')?.set?.call(element, value);
|
|
84
|
+
element.dispatchEvent(new Event('input', { bubbles: true }));
|
|
85
|
+
});
|
|
86
|
+
const blur = (element) => act(async () => {
|
|
87
|
+
element.dispatchEvent(new FocusEvent('focusout', { bubbles: true }));
|
|
88
|
+
});
|
|
89
|
+
const attr = (name) => container.querySelector(`[data-attr=${name}]`);
|
|
90
|
+
const node = (store) => store.getState().doc.nodes['text00001'];
|
|
91
|
+
describe('capability plumbing', () => {
|
|
92
|
+
it('is off unless the host passes exactly true', async () => {
|
|
93
|
+
expect((await mount(undefined)).authorCode).toBe(false);
|
|
94
|
+
expect((await mount(false)).authorCode).toBe(false);
|
|
95
|
+
expect((await mount(true)).authorCode).toBe(true);
|
|
96
|
+
});
|
|
97
|
+
it('refuses author attributes through the command while off', async () => {
|
|
98
|
+
const store = await mount(false);
|
|
99
|
+
const result = store.dispatch({
|
|
100
|
+
type: 'node.setAttr',
|
|
101
|
+
payload: { id: 'text00001', key: 'classes', value: ['hero'] },
|
|
102
|
+
});
|
|
103
|
+
expect(result.ok).toBe(false);
|
|
104
|
+
expect(node(store)?.classes).toBeUndefined();
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
describe('Advanced author fields', () => {
|
|
108
|
+
it('shows a quiet note and no fields while author code is off', async () => {
|
|
109
|
+
await mount(false);
|
|
110
|
+
expect(container.querySelector('[data-state=author-off]')).not.toBeNull();
|
|
111
|
+
expect(attr('customCss')).toBeNull();
|
|
112
|
+
expect(attr('classes')).toBeNull();
|
|
113
|
+
expect(attr('attributes')).toBeNull();
|
|
114
|
+
});
|
|
115
|
+
it('shows the three fields while it is on', async () => {
|
|
116
|
+
await mount(true);
|
|
117
|
+
expect(container.querySelector('[data-state=author-off]')).toBeNull();
|
|
118
|
+
expect(attr('customCss')).not.toBeNull();
|
|
119
|
+
expect(attr('classes')).not.toBeNull();
|
|
120
|
+
expect(attr('attributes')).not.toBeNull();
|
|
121
|
+
});
|
|
122
|
+
it('applies valid CSS on blur and keeps a refused one out of the document', async () => {
|
|
123
|
+
const store = await mount(true);
|
|
124
|
+
const area = attr('customCss').querySelector('textarea');
|
|
125
|
+
await typeInto(area, '& { color: red; }');
|
|
126
|
+
await blur(area);
|
|
127
|
+
expect(node(store)?.customCss).toBe('& { color: red; }');
|
|
128
|
+
await typeInto(area, '@import url("https://x.test/a.css");');
|
|
129
|
+
await blur(area);
|
|
130
|
+
expect(attr('customCss').querySelector('[role=alert]')).not.toBeNull();
|
|
131
|
+
expect(node(store)?.customCss).toBe('& { color: red; }');
|
|
132
|
+
});
|
|
133
|
+
it('writes classes and rejects an unsafe one', async () => {
|
|
134
|
+
const store = await mount(true);
|
|
135
|
+
const field = attr('classes').querySelector('input');
|
|
136
|
+
await typeInto(field, 'hero wide');
|
|
137
|
+
await blur(field);
|
|
138
|
+
expect(node(store)?.classes).toEqual(['hero', 'wide']);
|
|
139
|
+
await typeInto(field, 'bad"class');
|
|
140
|
+
await blur(field);
|
|
141
|
+
expect(attr('classes').querySelector('[role=alert]')).not.toBeNull();
|
|
142
|
+
expect(node(store)?.classes).toEqual(['hero', 'wide']);
|
|
143
|
+
});
|
|
144
|
+
it('shows the stored CSS again after an undo, dropping an unapplied draft', async () => {
|
|
145
|
+
const store = await mount(true);
|
|
146
|
+
const area = attr('customCss').querySelector('textarea');
|
|
147
|
+
await typeInto(area, '& { color: red; }');
|
|
148
|
+
await blur(area);
|
|
149
|
+
await typeInto(area, '& { color: blue; }');
|
|
150
|
+
expect(area.value).toBe('& { color: blue; }');
|
|
151
|
+
await act(async () => void store.undo());
|
|
152
|
+
expect(node(store)?.customCss).toBeUndefined();
|
|
153
|
+
expect(area.value).toBe('');
|
|
154
|
+
});
|
|
155
|
+
it('shows the stored classes again after an undo, dropping an unapplied draft', async () => {
|
|
156
|
+
const store = await mount(true);
|
|
157
|
+
const field = attr('classes').querySelector('input');
|
|
158
|
+
await typeInto(field, 'hero');
|
|
159
|
+
await blur(field);
|
|
160
|
+
await typeInto(field, 'hero extra');
|
|
161
|
+
await act(async () => void store.undo());
|
|
162
|
+
expect(field.value).toBe('');
|
|
163
|
+
});
|
|
164
|
+
it('states the class limit through the localized hint', async () => {
|
|
165
|
+
await mount(true);
|
|
166
|
+
expect(attr('classes').textContent).toMatch(/\(\d+ max\)/);
|
|
167
|
+
expect(attr('classes').textContent).not.toContain('{max}');
|
|
168
|
+
});
|
|
169
|
+
it('writes an attribute row once its name is set', async () => {
|
|
170
|
+
const store = await mount(true);
|
|
171
|
+
const add = [...attr('attributes').querySelectorAll('button')].find((b) => b.textContent?.includes('Add'));
|
|
172
|
+
await act(async () => add?.click());
|
|
173
|
+
const [name, value] = [...attr('attributes').querySelectorAll('input')];
|
|
174
|
+
await typeInto(name, 'data-id');
|
|
175
|
+
await typeInto(value, '7');
|
|
176
|
+
await blur(value);
|
|
177
|
+
expect(node(store)?.attributes).toEqual({ 'data-id': '7' });
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
describe('css problems', () => {
|
|
181
|
+
it('is empty for valid or empty CSS', () => {
|
|
182
|
+
expect(cssProblems('')).toEqual([]);
|
|
183
|
+
expect(cssProblems('& { color: red; }')).toEqual([]);
|
|
184
|
+
});
|
|
185
|
+
it('adds a line number when the message quotes the source', () => {
|
|
186
|
+
expect(describeCssProblem('a\nfoo', 'bad "foo" here', 'line {line}')).toBe('bad "foo" here (line 2)');
|
|
187
|
+
expect(describeCssProblem('a', 'no quote', 'line {line}')).toBe('no quote');
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
describe('Text modes', () => {
|
|
191
|
+
it('is recognised by the prop shape', () => {
|
|
192
|
+
expect(hasTextModes(text.props)).toBe(true);
|
|
193
|
+
expect(hasTextModes({ ...text.props, rich: p.text({}) })).toBe(false);
|
|
194
|
+
});
|
|
195
|
+
it('shows only the field of the chosen mode', async () => {
|
|
196
|
+
const store = await mount(true, 'Content');
|
|
197
|
+
const has = (name) => container.querySelector(`[data-prop=${name}]`) !== null;
|
|
198
|
+
expect(has('text')).toBe(true);
|
|
199
|
+
expect(has('rich')).toBe(false);
|
|
200
|
+
expect(has('html')).toBe(false);
|
|
201
|
+
await act(async () => {
|
|
202
|
+
store.dispatch({
|
|
203
|
+
type: 'node.setProp',
|
|
204
|
+
payload: {
|
|
205
|
+
id: 'text00001',
|
|
206
|
+
prop: 'mode',
|
|
207
|
+
value: { kind: 'static', value: 'html' },
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
expect(has('text')).toBe(false);
|
|
212
|
+
expect(has('html')).toBe(true);
|
|
213
|
+
});
|
|
214
|
+
it('disables the HTML mode and its field while author code is off', async () => {
|
|
215
|
+
await mount(false, 'Content');
|
|
216
|
+
const html = [...container.querySelectorAll('.bd-segment')].find((b) => b.textContent === 'HTML code');
|
|
217
|
+
expect(html.disabled).toBe(true);
|
|
218
|
+
});
|
|
219
|
+
it('reports what the sanitiser removes', async () => {
|
|
220
|
+
const store = await mount(true, 'Content');
|
|
221
|
+
await act(async () => {
|
|
222
|
+
store.dispatch({
|
|
223
|
+
type: 'node.setProp',
|
|
224
|
+
payload: {
|
|
225
|
+
id: 'text00001',
|
|
226
|
+
prop: 'mode',
|
|
227
|
+
value: { kind: 'static', value: 'html' },
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
const area = container.querySelector('[data-prop=html] textarea');
|
|
232
|
+
await typeInto(area, '<p>ok</p><script>alert(1)</script>');
|
|
233
|
+
expect(container.querySelector('.bd-author-problems[data-kind=removed]')).not.toBeNull();
|
|
234
|
+
expect(container.querySelector('.bd-code-preview')?.textContent).toContain('<p>ok</p>');
|
|
235
|
+
expect(container.querySelector('.bd-code-preview')?.textContent).not.toContain('script');
|
|
236
|
+
});
|
|
237
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface ExternalLinkEntryProps {
|
|
2
|
+
/** The accessible name of the prop the link is for. */
|
|
3
|
+
readonly label: string;
|
|
4
|
+
readonly disabled: boolean;
|
|
5
|
+
/** Called with the checked address, after the author confirmed the warning. */
|
|
6
|
+
readonly onAdd: (url: string) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A field for an address outside the site (ADR-028). The address is checked for feedback (HTTPS,
|
|
10
|
+
* no credentials), then the "Zewnętrzne źródło" warning opens; the value is stored only when the
|
|
11
|
+
* author confirms, and Cancel stores nothing.
|
|
12
|
+
*/
|
|
13
|
+
export declare function ExternalLinkEntry({ label, disabled, onAdd }: ExternalLinkEntryProps): import("react").JSX.Element;
|
|
14
|
+
export interface ExternalUrlControlProps {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly label: string;
|
|
17
|
+
readonly describedBy: string | undefined;
|
|
18
|
+
readonly value: unknown;
|
|
19
|
+
readonly disabled: boolean;
|
|
20
|
+
readonly onChange: (value: unknown) => void;
|
|
21
|
+
}
|
|
22
|
+
/** A text prop that is always an external address (the iframe's `url`): shows it, removes it, adds one after the warning. */
|
|
23
|
+
export declare function ExternalUrlControl({ id, label, describedBy, value, disabled, onChange, }: ExternalUrlControlProps): import("react").JSX.Element;
|
|
24
|
+
//# sourceMappingURL=external-link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-link.d.ts","sourceRoot":"","sources":["../../../../src/panels/inspector/controls/external-link.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,sBAAsB;IACrC,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,sBAAsB,+BA2DnF;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC7C;AAED,6HAA6H;AAC7H,wBAAgB,kBAAkB,CAAC,EACjC,EAAE,EACF,KAAK,EACL,WAAW,EACX,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE,uBAAuB,+BA8BzB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from 'react';
|
|
3
|
+
import { ExternalSourceDialog } from '../../../dialogs/external-source.js';
|
|
4
|
+
import { normalizeExternalUrl } from '../../../dialogs/media-picker/media-ref.js';
|
|
5
|
+
import { useT } from '../../../messages/index.js';
|
|
6
|
+
import { Button, Input } from '../../../ui/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* A field for an address outside the site (ADR-028). The address is checked for feedback (HTTPS,
|
|
9
|
+
* no credentials), then the "Zewnętrzne źródło" warning opens; the value is stored only when the
|
|
10
|
+
* author confirms, and Cancel stores nothing.
|
|
11
|
+
*/
|
|
12
|
+
export function ExternalLinkEntry({ label, disabled, onAdd }) {
|
|
13
|
+
const t = useT();
|
|
14
|
+
const id = useId();
|
|
15
|
+
const [text, setText] = useState('');
|
|
16
|
+
const [invalid, setInvalid] = useState(false);
|
|
17
|
+
const [pending, setPending] = useState(null);
|
|
18
|
+
const submit = () => {
|
|
19
|
+
const url = normalizeExternalUrl(text);
|
|
20
|
+
setInvalid(url === undefined);
|
|
21
|
+
if (url !== undefined)
|
|
22
|
+
setPending(url);
|
|
23
|
+
};
|
|
24
|
+
return (_jsxs("div", { className: "bd-external-entry", children: [_jsxs("div", { className: "bd-external-row", children: [_jsx(Input, { type: "url", value: text, disabled: disabled, placeholder: t('media.external.placeholder'), "aria-label": `${label}: ${t('media.external.label')}`, "aria-invalid": invalid, "aria-describedby": invalid ? `${id}-error` : undefined, onChange: (event) => {
|
|
25
|
+
setText(event.target.value);
|
|
26
|
+
setInvalid(false);
|
|
27
|
+
}, onKeyDown: (event) => {
|
|
28
|
+
if (event.key === 'Enter') {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
submit();
|
|
31
|
+
}
|
|
32
|
+
} }), _jsx(Button, { disabled: disabled || text.trim() === '', "aria-label": `${label}: ${t('media.external.add')}`, onClick: submit, children: t('media.external.add') })] }), invalid ? (_jsx("p", { role: "alert", id: `${id}-error`, className: "bd-media-error", children: t('media.external.invalid') })) : null, _jsx(ExternalSourceDialog, { url: pending, onCancel: () => setPending(null), onConfirm: (url) => {
|
|
33
|
+
setPending(null);
|
|
34
|
+
setText('');
|
|
35
|
+
onAdd(url);
|
|
36
|
+
} })] }));
|
|
37
|
+
}
|
|
38
|
+
/** A text prop that is always an external address (the iframe's `url`): shows it, removes it, adds one after the warning. */
|
|
39
|
+
export function ExternalUrlControl({ id, label, describedBy, value, disabled, onChange, }) {
|
|
40
|
+
const t = useT();
|
|
41
|
+
const current = typeof value === 'string' && value !== '' ? value : undefined;
|
|
42
|
+
return (_jsxs("div", { className: "bd-media-control", id: id, "aria-describedby": describedBy, children: [current !== undefined ? (_jsxs("div", { className: "bd-media-preview", children: [_jsx("span", { className: "bd-media-badge", children: t('media.external.badge') }), _jsx("span", { className: "bd-media-name", title: current, children: current })] })) : (_jsx("p", { className: "bd-field-hint", children: t('media.none') })), current !== undefined ? (_jsx("div", { className: "bd-media-actions", children: _jsx(Button, { variant: "ghost", disabled: disabled, "aria-label": `${label}: ${t('media.remove')}`, onClick: () => onChange(''), children: t('media.remove') }) })) : null, _jsx(ExternalLinkEntry, { label: label, disabled: disabled, onAdd: (url) => onChange(url) })] }));
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-link.test.d.ts","sourceRoot":"","sources":["../../../../src/panels/inspector/controls/external-link.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// @vitest-environment jsdom
|
|
3
|
+
import { p } from '@next-buildr/core';
|
|
4
|
+
import { act } from 'react';
|
|
5
|
+
import { createRoot } from 'react-dom/client';
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
7
|
+
import { normalizeExternalUrl, parseExternalMedia, } from '../../../dialogs/media-picker/media-ref.js';
|
|
8
|
+
import { MessagesProvider } from '../../../messages/index.js';
|
|
9
|
+
import { ExternalUrlControl } from './external-link.js';
|
|
10
|
+
import { MediaControl } from './media.js';
|
|
11
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
12
|
+
describe('external media values', () => {
|
|
13
|
+
it('accepts only https addresses without credentials', () => {
|
|
14
|
+
expect(normalizeExternalUrl(' https://cdn.example.com/a.mp4 ')).toBe('https://cdn.example.com/a.mp4');
|
|
15
|
+
expect(normalizeExternalUrl('http://cdn.example.com/a.mp4')).toBeUndefined();
|
|
16
|
+
expect(normalizeExternalUrl('https://user:pw@cdn.example.com/a')).toBeUndefined();
|
|
17
|
+
expect(normalizeExternalUrl('javascript:alert(1)')).toBeUndefined();
|
|
18
|
+
expect(normalizeExternalUrl('not a url')).toBeUndefined();
|
|
19
|
+
expect(normalizeExternalUrl(`https://a.example/${'x'.repeat(2100)}`)).toBeUndefined();
|
|
20
|
+
});
|
|
21
|
+
it('reads the stored shape back and ignores the rest', () => {
|
|
22
|
+
const value = { external: true, url: 'https://a.example/x.png' };
|
|
23
|
+
expect(parseExternalMedia(value)).toEqual(value);
|
|
24
|
+
expect(parseExternalMedia({ external: false, url: 'https://a.example' })).toBeUndefined();
|
|
25
|
+
expect(parseExternalMedia(null)).toBeUndefined();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
describe('the external source warning', () => {
|
|
29
|
+
let container;
|
|
30
|
+
let root;
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
container = document.createElement('div');
|
|
33
|
+
document.body.append(container);
|
|
34
|
+
root = createRoot(container);
|
|
35
|
+
Element.prototype.scrollIntoView ??= () => { };
|
|
36
|
+
Element.prototype.hasPointerCapture ??= () => false;
|
|
37
|
+
Element.prototype.setPointerCapture ??= () => { };
|
|
38
|
+
Element.prototype.releasePointerCapture ??= () => { };
|
|
39
|
+
});
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
act(() => root.unmount());
|
|
42
|
+
document.body.innerHTML = '';
|
|
43
|
+
});
|
|
44
|
+
const render = (locale, node) => act(async () => root.render(_jsx(MessagesProvider, { locale: locale, children: node })));
|
|
45
|
+
const byText = (text) => [...document.querySelectorAll('button')].find((b) => b.textContent?.includes(text));
|
|
46
|
+
const type = (element, value) => act(async () => {
|
|
47
|
+
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(element, value);
|
|
48
|
+
element.dispatchEvent(new Event('input', { bubbles: true }));
|
|
49
|
+
});
|
|
50
|
+
const input = () => container.querySelector('input[type="url"]');
|
|
51
|
+
const mediaDef = p.media({ label: 'Image', accept: ['image'] });
|
|
52
|
+
it('stores an external media value only after "Potwierdzam i dodaję link"', async () => {
|
|
53
|
+
const onChange = vi.fn();
|
|
54
|
+
await render('pl', _jsx(MediaControl, { id: "i", def: mediaDef, label: "Obraz", describedBy: undefined, value: null, disabled: false, onChange: onChange }));
|
|
55
|
+
await type(input(), 'https://cdn.example.com/a.png');
|
|
56
|
+
await act(async () => byText('Dodaj link')?.click());
|
|
57
|
+
const dialog = document.querySelector('[role="alertdialog"]');
|
|
58
|
+
expect(dialog?.textContent).toContain('Zewnętrzne źródło');
|
|
59
|
+
expect(dialog?.textContent).toContain('biblioteki mediów');
|
|
60
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
61
|
+
await act(async () => byText('Potwierdzam i dodaję link')?.click());
|
|
62
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
63
|
+
external: true,
|
|
64
|
+
url: 'https://cdn.example.com/a.png',
|
|
65
|
+
});
|
|
66
|
+
expect(document.querySelector('[role="alertdialog"]')).toBeNull();
|
|
67
|
+
});
|
|
68
|
+
it('stores nothing when the warning is cancelled', async () => {
|
|
69
|
+
const onChange = vi.fn();
|
|
70
|
+
await render('pl', _jsx(MediaControl, { id: "i", def: mediaDef, label: "Obraz", describedBy: undefined, value: null, disabled: false, onChange: onChange }));
|
|
71
|
+
await type(input(), 'https://cdn.example.com/a.png');
|
|
72
|
+
await act(async () => byText('Dodaj link')?.click());
|
|
73
|
+
await act(async () => byText('Anuluj')?.click());
|
|
74
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
75
|
+
expect(document.querySelector('[role="alertdialog"]')).toBeNull();
|
|
76
|
+
});
|
|
77
|
+
it('refuses an address that is not https without opening the warning', async () => {
|
|
78
|
+
const onChange = vi.fn();
|
|
79
|
+
await render('en', _jsx(MediaControl, { id: "i", def: mediaDef, label: "Image", describedBy: undefined, value: null, disabled: false, onChange: onChange }));
|
|
80
|
+
await type(input(), 'http://cdn.example.com/a.png');
|
|
81
|
+
await act(async () => byText('Add link')?.click());
|
|
82
|
+
expect(document.querySelector('[role="alertdialog"]')).toBeNull();
|
|
83
|
+
expect(container.textContent).toContain('starts with https://');
|
|
84
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
85
|
+
});
|
|
86
|
+
it('shows a stored external value with its badge and removes it', async () => {
|
|
87
|
+
const onChange = vi.fn();
|
|
88
|
+
await render('en', _jsx(MediaControl, { id: "i", def: mediaDef, label: "Image", describedBy: undefined, value: { external: true, url: 'https://cdn.example.com/a.png' }, disabled: false, onChange: onChange }));
|
|
89
|
+
expect(container.textContent).toContain('External');
|
|
90
|
+
expect(container.textContent).toContain('https://cdn.example.com/a.png');
|
|
91
|
+
await act(async () => byText('Remove')?.click());
|
|
92
|
+
expect(onChange).toHaveBeenCalledWith(null);
|
|
93
|
+
});
|
|
94
|
+
it('asks for the same confirmation for a text address (the iframe url)', async () => {
|
|
95
|
+
const onChange = vi.fn();
|
|
96
|
+
await render('pl', _jsx(ExternalUrlControl, { id: "u", label: "Adres", describedBy: undefined, value: "", disabled: false, onChange: onChange }));
|
|
97
|
+
await type(input(), 'https://maps.example.com/embed');
|
|
98
|
+
await act(async () => byText('Dodaj link')?.click());
|
|
99
|
+
await act(async () => byText('Anuluj')?.click());
|
|
100
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
101
|
+
await act(async () => byText('Dodaj link')?.click());
|
|
102
|
+
await act(async () => byText('Potwierdzam i dodaję link')?.click());
|
|
103
|
+
expect(onChange).toHaveBeenCalledWith('https://maps.example.com/embed');
|
|
104
|
+
});
|
|
105
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { BooleanControl } from './boolean.tsx';
|
|
2
2
|
export { ListControl, moveItem, ObjectControl, renderControl } from './compound.tsx';
|
|
3
|
+
export { ExternalLinkEntry, ExternalUrlControl } from './external-link.tsx';
|
|
3
4
|
export { IconControl } from './icon.tsx';
|
|
4
5
|
export { propLabel } from './label.ts';
|
|
5
6
|
export { LinkControl } from './link.tsx';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/panels/inspector/controls/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/panels/inspector/controls/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { BooleanControl } from './boolean.js';
|
|
2
2
|
export { ListControl, moveItem, ObjectControl, renderControl } from './compound.js';
|
|
3
|
+
export { ExternalLinkEntry, ExternalUrlControl } from './external-link.js';
|
|
3
4
|
export { IconControl } from './icon.js';
|
|
4
5
|
export { propLabel } from './label.js';
|
|
5
6
|
export { LinkControl } from './link.js';
|