@wix/patterns-fields 1.40.0 → 1.42.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/dist/cjs/components/address/input/address-input.st.css.js +3 -3
- package/dist/cjs/components/address/input/address-input.st.css.js.map +1 -1
- package/dist/cjs/components/audio/actions/actions-menu/actions-menu.st.css.js +3 -3
- package/dist/cjs/components/audio/actions/actions-menu/actions-menu.st.css.js.map +1 -1
- package/dist/cjs/components/audio/audio-field/form-audio-field.js +12 -10
- package/dist/cjs/components/audio/audio-field/form-audio-field.js.map +1 -1
- package/dist/cjs/components/audio/audio-field/form-audio-field.st.css.js +4 -4
- package/dist/cjs/components/audio/audio-field/form-audio-field.st.css.js.map +1 -1
- package/dist/cjs/components/audio/audio-player/audio-player.st.css.js +2 -2
- package/dist/cjs/components/audio/audio-player/audio-player.st.css.js.map +1 -1
- package/dist/cjs/components/color-view/cell-color-input.js +195 -0
- package/dist/cjs/components/color-view/cell-color-input.js.map +1 -0
- package/dist/cjs/components/color-view/cell-color-view.js +89 -0
- package/dist/cjs/components/color-view/cell-color-view.js.map +1 -0
- package/dist/cjs/components/color-view/cell-color-view.st.css +8 -0
- package/dist/cjs/components/color-view/cell-color-view.st.css.js +25 -0
- package/dist/cjs/components/color-view/cell-color-view.st.css.js.map +1 -0
- package/dist/cjs/components/color-view/color-input.js +33 -27
- package/dist/cjs/components/color-view/color-input.js.map +1 -1
- package/dist/cjs/components/color-view/color-view.st.css.js +4 -4
- package/dist/cjs/components/color-view/color-view.st.css.js.map +1 -1
- package/dist/cjs/components/color-view/hex.js +16 -0
- package/dist/cjs/components/color-view/hex.js.map +1 -0
- package/dist/cjs/components/color-view/index.js +18 -0
- package/dist/cjs/components/color-view/index.js.map +1 -1
- package/dist/cjs/components/delete-dialog/delete-dialog.st.css.js +3 -3
- package/dist/cjs/components/delete-dialog/delete-dialog.st.css.js.map +1 -1
- package/dist/cjs/components/document/form-document-field.st.css.js +7 -7
- package/dist/cjs/components/document/form-document-field.st.css.js.map +1 -1
- package/dist/cjs/components/exclamation/exclamation.st.css.js +5 -5
- package/dist/cjs/components/exclamation/exclamation.st.css.js.map +1 -1
- package/dist/cjs/components/highlighted-text/highlighted-text.st.css.js +5 -5
- package/dist/cjs/components/highlighted-text/highlighted-text.st.css.js.map +1 -1
- package/dist/cjs/components/image/thumbnail-replace-overlay.st.css.js +3 -3
- package/dist/cjs/components/image/thumbnail-replace-overlay.st.css.js.map +1 -1
- package/dist/cjs/components/media-control/cell-media-edit-shell.st.css.js +2 -2
- package/dist/cjs/components/media-control/cell-media-edit-shell.st.css.js.map +1 -1
- package/dist/cjs/components/media-control/paste-url-button.st.css.js +4 -4
- package/dist/cjs/components/media-control/paste-url-button.st.css.js.map +1 -1
- package/dist/cjs/components/media-gallery/form-media-gallery-field.st.css.js +10 -10
- package/dist/cjs/components/media-gallery/form-media-gallery-field.st.css.js.map +1 -1
- package/dist/cjs/components/media-image/media-image.st.css.js +4 -4
- package/dist/cjs/components/media-image/media-image.st.css.js.map +1 -1
- package/dist/cjs/components/media-image/overlays/overlay.st.css.js +3 -3
- package/dist/cjs/components/media-image/overlays/overlay.st.css.js.map +1 -1
- package/dist/cjs/components/media-loader/media-loader.st.css.js +3 -3
- package/dist/cjs/components/media-loader/media-loader.st.css.js.map +1 -1
- package/dist/cjs/components/media-tag/web-media-tag/media-tag.st.css.js +2 -2
- package/dist/cjs/components/media-tag/web-media-tag/media-tag.st.css.js.map +1 -1
- package/dist/cjs/components/multi-document/multi-document-input/form-multi-document.st.css.js +5 -5
- package/dist/cjs/components/multi-document/multi-document-input/form-multi-document.st.css.js.map +1 -1
- package/dist/cjs/components/reference/cell-reference-input.st.css.js +3 -3
- package/dist/cjs/components/reference/cell-reference-input.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/cell-rich-content-input.js +4 -3
- package/dist/cjs/components/rich-content/cell-rich-content-input.js.map +1 -1
- package/dist/cjs/components/rich-content/cell-rich-content-view.js +3 -2
- package/dist/cjs/components/rich-content/cell-rich-content-view.js.map +1 -1
- package/dist/cjs/components/rich-content/hooks/use-plain-text-rich-content.js +1 -1
- package/dist/cjs/components/rich-content/hooks/use-plain-text-rich-content.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/default-value-input/rich-content-default-value-input.st.css.js +4 -4
- package/dist/cjs/components/rich-content/rich-content-input/default-value-input/rich-content-default-value-input.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/form-input/rich-content-form-input.st.css.js +3 -3
- package/dist/cjs/components/rich-content/rich-content-input/form-input/rich-content-form-input.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/form-read-only-input/rich-content-form-read-only-input.st.css.js +2 -2
- package/dist/cjs/components/rich-content/rich-content-input/form-read-only-input/rich-content-form-read-only-input.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-common/fullscreen-modal/fullscreen-modal.st.css.js +3 -3
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-common/fullscreen-modal/fullscreen-modal.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-common/hooks.js +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-common/hooks.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-common/publish-loader/publish-loader.st.css.js +3 -3
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-common/publish-loader/publish-loader.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-common/toggle-fullscreen-button/toggle-fullscreen-button.st.css.js +2 -2
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-common/toggle-fullscreen-button/toggle-fullscreen-button.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-editor/plugins.js +0 -5
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-editor/plugins.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.js +169 -192
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.st.css.js +7 -7
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.js +52 -36
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.st.css +7 -0
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.st.css.js +5 -4
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-viewer/rich-content-viewer.js +10 -10
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-viewer/rich-content-viewer.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-viewer/rich-content-viewer.st.css.js +4 -4
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-viewer/rich-content-viewer.st.css.js.map +1 -1
- package/dist/cjs/components/rich-text/rich-text-input/rich-text-editor/rich-editor.st.css.js +18 -18
- package/dist/cjs/components/rich-text/rich-text-input/rich-text-editor/rich-editor.st.css.js.map +1 -1
- package/dist/cjs/components/rich-text/rich-text-input/rich-text-editor/rich-text-editor.st.css.js +4 -4
- package/dist/cjs/components/rich-text/rich-text-input/rich-text-editor/rich-text-editor.st.css.js.map +1 -1
- package/dist/cjs/components/rich-text/rich-text-input/rich-text-editor/toolbar/toolbar.st.css.js +18 -18
- package/dist/cjs/components/rich-text/rich-text-input/rich-text-editor/toolbar/toolbar.st.css.js.map +1 -1
- package/dist/cjs/components/text/text-view.st.css.js +3 -3
- package/dist/cjs/components/text/text-view.st.css.js.map +1 -1
- package/dist/cjs/components/time-input/form-time-input.js +21 -2
- package/dist/cjs/components/time-input/form-time-input.js.map +1 -1
- package/dist/cjs/styles.global.css +1 -1
- package/dist/cjs/validations/rich-content.js +2 -3
- package/dist/cjs/validations/rich-content.js.map +1 -1
- package/dist/esm/components/address/input/address-input.st.css.js +2 -2
- package/dist/esm/components/address/input/address-input.st.css.js.map +1 -1
- package/dist/esm/components/audio/actions/actions-menu/actions-menu.st.css.js +2 -2
- package/dist/esm/components/audio/actions/actions-menu/actions-menu.st.css.js.map +1 -1
- package/dist/esm/components/audio/audio-field/form-audio-field.js +2 -0
- package/dist/esm/components/audio/audio-field/form-audio-field.js.map +1 -1
- package/dist/esm/components/audio/audio-field/form-audio-field.st.css.js +2 -2
- package/dist/esm/components/audio/audio-field/form-audio-field.st.css.js.map +1 -1
- package/dist/esm/components/audio/audio-player/audio-player.st.css.js +2 -2
- package/dist/esm/components/color-view/cell-color-input.js +104 -0
- package/dist/esm/components/color-view/cell-color-input.js.map +1 -0
- package/dist/esm/components/color-view/cell-color-view.js +25 -0
- package/dist/esm/components/color-view/cell-color-view.js.map +1 -0
- package/dist/esm/components/color-view/cell-color-view.st.css +8 -0
- package/dist/esm/components/color-view/cell-color-view.st.css.js +15 -0
- package/dist/esm/components/color-view/cell-color-view.st.css.js.map +1 -0
- package/dist/esm/components/color-view/color-input.js +12 -12
- package/dist/esm/components/color-view/color-input.js.map +1 -1
- package/dist/esm/components/color-view/color-view.st.css.js +2 -2
- package/dist/esm/components/color-view/hex.js +9 -0
- package/dist/esm/components/color-view/hex.js.map +1 -0
- package/dist/esm/components/color-view/index.js +3 -0
- package/dist/esm/components/color-view/index.js.map +1 -1
- package/dist/esm/components/delete-dialog/delete-dialog.st.css.js +2 -2
- package/dist/esm/components/delete-dialog/delete-dialog.st.css.js.map +1 -1
- package/dist/esm/components/document/form-document-field.st.css.js +2 -2
- package/dist/esm/components/document/form-document-field.st.css.js.map +1 -1
- package/dist/esm/components/exclamation/exclamation.st.css.js +2 -2
- package/dist/esm/components/exclamation/exclamation.st.css.js.map +1 -1
- package/dist/esm/components/highlighted-text/highlighted-text.st.css.js +3 -3
- package/dist/esm/components/image/thumbnail-replace-overlay.st.css.js +2 -2
- package/dist/esm/components/media-control/cell-media-edit-shell.st.css.js +2 -2
- package/dist/esm/components/media-control/paste-url-button.st.css.js +2 -2
- package/dist/esm/components/media-control/paste-url-button.st.css.js.map +1 -1
- package/dist/esm/components/media-gallery/form-media-gallery-field.st.css.js +2 -2
- package/dist/esm/components/media-image/media-image.st.css.js +3 -3
- package/dist/esm/components/media-image/overlays/overlay.st.css.js +2 -2
- package/dist/esm/components/media-loader/media-loader.st.css.js +2 -2
- package/dist/esm/components/media-loader/media-loader.st.css.js.map +1 -1
- package/dist/esm/components/media-tag/web-media-tag/media-tag.st.css.js +2 -2
- package/dist/esm/components/multi-document/multi-document-input/form-multi-document.st.css.js +2 -2
- package/dist/esm/components/reference/cell-reference-input.st.css.js +2 -2
- package/dist/esm/components/rich-content/cell-rich-content-input.js +4 -3
- package/dist/esm/components/rich-content/cell-rich-content-input.js.map +1 -1
- package/dist/esm/components/rich-content/cell-rich-content-view.js +3 -4
- package/dist/esm/components/rich-content/cell-rich-content-view.js.map +1 -1
- package/dist/esm/components/rich-content/hooks/use-plain-text-rich-content.js +2 -2
- package/dist/esm/components/rich-content/hooks/use-plain-text-rich-content.js.map +1 -1
- package/dist/esm/components/rich-content/rich-content-input/default-value-input/rich-content-default-value-input.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/form-input/rich-content-form-input.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/form-read-only-input/rich-content-form-read-only-input.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/rich-content-common/fullscreen-modal/fullscreen-modal.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/rich-content-common/fullscreen-modal/fullscreen-modal.st.css.js.map +1 -1
- package/dist/esm/components/rich-content/rich-content-input/rich-content-common/hooks.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/rich-content-common/hooks.js.map +1 -1
- package/dist/esm/components/rich-content/rich-content-input/rich-content-common/publish-loader/publish-loader.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/rich-content-common/toggle-fullscreen-button/toggle-fullscreen-button.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/rich-content-editor/plugins.js +0 -5
- package/dist/esm/components/rich-content/rich-content-input/rich-content-editor/plugins.js.map +1 -1
- package/dist/esm/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.js +112 -135
- package/dist/esm/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.js.map +1 -1
- package/dist/esm/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.js +27 -35
- package/dist/esm/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.js.map +1 -1
- package/dist/esm/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.st.css +7 -0
- package/dist/esm/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.st.css.js.map +1 -1
- package/dist/esm/components/rich-content/rich-content-input/rich-content-viewer/rich-content-viewer.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/rich-content-viewer/rich-content-viewer.js.map +1 -1
- package/dist/esm/components/rich-content/rich-content-input/rich-content-viewer/rich-content-viewer.st.css.js +2 -2
- package/dist/esm/components/rich-text/rich-text-input/rich-text-editor/rich-editor.st.css.js +2 -2
- package/dist/esm/components/rich-text/rich-text-input/rich-text-editor/rich-editor.st.css.js.map +1 -1
- package/dist/esm/components/rich-text/rich-text-input/rich-text-editor/rich-text-editor.st.css.js +2 -2
- package/dist/esm/components/rich-text/rich-text-input/rich-text-editor/toolbar/toolbar.st.css.js +2 -2
- package/dist/esm/components/text/text-view.st.css.js +2 -2
- package/dist/esm/components/text/text-view.st.css.js.map +1 -1
- package/dist/esm/components/time-input/form-time-input.js +8 -3
- package/dist/esm/components/time-input/form-time-input.js.map +1 -1
- package/dist/esm/styles.global.css +1 -1
- package/dist/esm/validations/rich-content.js +3 -4
- package/dist/esm/validations/rich-content.js.map +1 -1
- package/dist/types/components/address/input/address-input.st.css.d.ts.map +1 -1
- package/dist/types/components/audio/actions/actions-menu/actions-menu.st.css.d.ts.map +1 -1
- package/dist/types/components/audio/audio-field/form-audio-field.d.ts.map +1 -1
- package/dist/types/components/audio/audio-field/form-audio-field.st.css.d.ts.map +1 -1
- package/dist/types/components/color-view/cell-color-input.d.ts +23 -0
- package/dist/types/components/color-view/cell-color-input.d.ts.map +1 -0
- package/dist/types/components/color-view/cell-color-view.d.ts +15 -0
- package/dist/types/components/color-view/cell-color-view.d.ts.map +1 -0
- package/dist/types/components/color-view/cell-color-view.st.css.d.ts +16 -0
- package/dist/types/components/color-view/cell-color-view.st.css.d.ts.map +1 -0
- package/dist/types/components/color-view/color-input.d.ts.map +1 -1
- package/dist/types/components/color-view/hex.d.ts +5 -0
- package/dist/types/components/color-view/hex.d.ts.map +1 -0
- package/dist/types/components/color-view/index.d.ts +3 -0
- package/dist/types/components/color-view/index.d.ts.map +1 -1
- package/dist/types/components/delete-dialog/delete-dialog.st.css.d.ts.map +1 -1
- package/dist/types/components/document/form-document-field.st.css.d.ts.map +1 -1
- package/dist/types/components/exclamation/exclamation.st.css.d.ts.map +1 -1
- package/dist/types/components/media-control/paste-url-button.st.css.d.ts.map +1 -1
- package/dist/types/components/media-loader/media-loader.st.css.d.ts.map +1 -1
- package/dist/types/components/rich-content/cell-rich-content-input.d.ts +2 -2
- package/dist/types/components/rich-content/cell-rich-content-input.d.ts.map +1 -1
- package/dist/types/components/rich-content/cell-rich-content-view.d.ts.map +1 -1
- package/dist/types/components/rich-content/hooks/use-plain-text-rich-content.d.ts +2 -2
- package/dist/types/components/rich-content/hooks/use-plain-text-rich-content.d.ts.map +1 -1
- package/dist/types/components/rich-content/rich-content-input/form-input/use-rich-content-form-input.d.ts +2 -2
- package/dist/types/components/rich-content/rich-content-input/hooks.d.ts +1 -1
- package/dist/types/components/rich-content/rich-content-input/rich-content-common/fullscreen-modal/fullscreen-modal.st.css.d.ts.map +1 -1
- package/dist/types/components/rich-content/rich-content-input/rich-content-common/hooks.d.ts +3 -3
- package/dist/types/components/rich-content/rich-content-input/rich-content-common/hooks.d.ts.map +1 -1
- package/dist/types/components/rich-content/rich-content-input/rich-content-editor/plugins.d.ts +2 -2
- package/dist/types/components/rich-content/rich-content-input/rich-content-editor/plugins.d.ts.map +1 -1
- package/dist/types/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.d.ts +12 -11
- package/dist/types/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.d.ts.map +1 -1
- package/dist/types/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.d.ts +2 -15
- package/dist/types/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.d.ts.map +1 -1
- package/dist/types/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.st.css.d.ts +1 -0
- package/dist/types/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.st.css.d.ts.map +1 -1
- package/dist/types/components/rich-content/rich-content-input/rich-content-viewer/plugins.d.ts +1 -1
- package/dist/types/components/rich-content/rich-content-input/rich-content-viewer/plugins.d.ts.map +1 -1
- package/dist/types/components/rich-content/rich-content-input/rich-content-viewer/rich-content-viewer.d.ts +5 -3
- package/dist/types/components/rich-content/rich-content-input/rich-content-viewer/rich-content-viewer.d.ts.map +1 -1
- package/dist/types/components/rich-text/rich-text-input/rich-text-editor/rich-editor.st.css.d.ts.map +1 -1
- package/dist/types/components/text/text-view.st.css.d.ts.map +1 -1
- package/dist/types/components/time-input/form-time-input.d.ts.map +1 -1
- package/dist/types/validations/rich-content.d.ts +3 -3
- package/dist/types/validations/rich-content.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/__tests__/components/rich-content-editor.spec.tsx +63 -72
- package/src/__tests__/validations/rich-content.spec.ts +4 -8
- package/src/components/address/input/address-input.st.css.ts +2 -2
- package/src/components/audio/actions/actions-menu/actions-menu.st.css.ts +2 -2
- package/src/components/audio/audio-field/form-audio-field.st.css.ts +2 -2
- package/src/components/audio/audio-field/form-audio-field.tsx +2 -0
- package/src/components/audio/audio-player/audio-player.st.css.ts +2 -2
- package/src/components/color-view/cell-color-input.tsx +200 -0
- package/src/components/color-view/cell-color-view.st.css +8 -0
- package/src/components/color-view/cell-color-view.st.css.ts +25 -0
- package/src/components/color-view/cell-color-view.tsx +52 -0
- package/src/components/color-view/color-input.tsx +23 -17
- package/src/components/color-view/color-view.st.css.ts +2 -2
- package/src/components/color-view/hex.ts +13 -0
- package/src/components/color-view/index.ts +3 -0
- package/src/components/delete-dialog/delete-dialog.st.css.ts +2 -2
- package/src/components/document/form-document-field.st.css.ts +2 -2
- package/src/components/exclamation/exclamation.st.css.ts +2 -2
- package/src/components/highlighted-text/highlighted-text.st.css.ts +3 -3
- package/src/components/image/thumbnail-replace-overlay.st.css.ts +2 -2
- package/src/components/media-control/cell-media-edit-shell.st.css.ts +2 -2
- package/src/components/media-control/paste-url-button.st.css.ts +2 -2
- package/src/components/media-gallery/form-media-gallery-field.st.css.ts +2 -2
- package/src/components/media-image/media-image.st.css.ts +3 -3
- package/src/components/media-image/overlays/overlay.st.css.ts +2 -2
- package/src/components/media-loader/media-loader.st.css.ts +2 -2
- package/src/components/media-tag/web-media-tag/media-tag.st.css.ts +2 -2
- package/src/components/multi-document/multi-document-input/form-multi-document.st.css.ts +2 -2
- package/src/components/reference/cell-reference-input.st.css.ts +2 -2
- package/src/components/rich-content/cell-rich-content-input.tsx +11 -14
- package/src/components/rich-content/cell-rich-content-view.tsx +3 -4
- package/src/components/rich-content/hooks/use-plain-text-rich-content.ts +4 -4
- package/src/components/rich-content/rich-content-input/default-value-input/rich-content-default-value-input.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/form-input/rich-content-form-input.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/form-read-only-input/rich-content-form-read-only-input.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/rich-content-common/fullscreen-modal/fullscreen-modal.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/rich-content-common/hooks.ts +5 -5
- package/src/components/rich-content/rich-content-input/rich-content-common/publish-loader/publish-loader.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/rich-content-common/toggle-fullscreen-button/toggle-fullscreen-button.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/rich-content-editor/plugins.ts +0 -6
- package/src/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.tsx +346 -355
- package/src/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.st.css +7 -0
- package/src/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.tsx +35 -62
- package/src/components/rich-content/rich-content-input/rich-content-viewer/rich-content-viewer.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/rich-content-viewer/rich-content-viewer.tsx +8 -9
- package/src/components/rich-text/rich-text-input/rich-text-editor/rich-editor.st.css.ts +2 -2
- package/src/components/rich-text/rich-text-input/rich-text-editor/rich-text-editor.st.css.ts +2 -2
- package/src/components/rich-text/rich-text-input/rich-text-editor/toolbar/toolbar.st.css.ts +2 -2
- package/src/components/text/text-view.st.css.ts +2 -2
- package/src/components/time-input/form-time-input.tsx +21 -4
- package/src/styles.global.css +1 -1
- package/src/validations/rich-content.ts +6 -7
package/src/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.tsx
CHANGED
|
@@ -15,21 +15,13 @@ import React, {
|
|
|
15
15
|
|
|
16
16
|
import { Box, Loader } from '@wix/design-system';
|
|
17
17
|
import type {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
ToolbarSettings,
|
|
24
|
-
EditorEventsProps,
|
|
25
|
-
ToolbarSettingsFunctions,
|
|
26
|
-
} from '@wix/ricos';
|
|
27
|
-
import {
|
|
28
|
-
WixRicosEditor,
|
|
29
|
-
ToolbarType as TOOLBARS,
|
|
30
|
-
FORMATTING_BUTTONS,
|
|
31
|
-
withEditorContext,
|
|
18
|
+
ExternalToolbarButton as RicosExternalToolbarButton,
|
|
19
|
+
RicosDocument,
|
|
20
|
+
RicosEditorAPI,
|
|
21
|
+
RicosEditorProps,
|
|
22
|
+
ToolbarsConfig,
|
|
32
23
|
} from '@wix/ricos';
|
|
24
|
+
import { RicosEditor, FORMATTING_BUTTONS } from '@wix/ricos';
|
|
33
25
|
|
|
34
26
|
import { useRequestFrameCallback } from '../../../../hooks';
|
|
35
27
|
import { getActiveElement, getAppRootElement } from '../../../../utils';
|
|
@@ -50,20 +42,20 @@ import { usePlugins } from './plugins';
|
|
|
50
42
|
import { ExternalToolbar } from './rich-content-toolbar';
|
|
51
43
|
import { st, classes } from './rich-content-editor.st.css.js';
|
|
52
44
|
|
|
53
|
-
type RicosProps = Pick<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
>;
|
|
45
|
+
type RicosProps = Pick<RicosEditorProps, 'biSettings' | 'theme'> & {
|
|
46
|
+
wixExperiments?: unknown;
|
|
47
|
+
};
|
|
57
48
|
|
|
58
49
|
interface RCEHandle {
|
|
59
50
|
isContentChanged: () => boolean;
|
|
51
|
+
prePublish: () => Promise<RicosDocument>;
|
|
52
|
+
setContent: (content: RicosDocument) => void;
|
|
60
53
|
}
|
|
61
54
|
|
|
62
55
|
interface RCEProps extends RicosProps {
|
|
63
|
-
content?:
|
|
64
|
-
injectedContent?:
|
|
65
|
-
onChange?: (content:
|
|
66
|
-
getToolbarSettings: GetToolbarSettings;
|
|
56
|
+
content?: RicosDocument;
|
|
57
|
+
injectedContent?: RicosDocument;
|
|
58
|
+
onChange?: (content: RicosDocument) => void;
|
|
67
59
|
autoFocus?: boolean;
|
|
68
60
|
onFocus?: () => void;
|
|
69
61
|
onBlur?: () => void;
|
|
@@ -73,11 +65,38 @@ interface RCEProps extends RicosProps {
|
|
|
73
65
|
dataHook?: string;
|
|
74
66
|
}
|
|
75
67
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
68
|
+
type ToolbarSyncProps = {
|
|
69
|
+
editor: RicosEditorAPI;
|
|
70
|
+
onButtonsChange: (buttons: readonly RicosExternalToolbarButton[]) => void;
|
|
71
|
+
onReadyChange: (ready: boolean) => void;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const InsertToolbarSync: FC<ToolbarSyncProps> = ({
|
|
75
|
+
editor,
|
|
76
|
+
onButtonsChange,
|
|
77
|
+
onReadyChange,
|
|
78
|
+
}) => {
|
|
79
|
+
const { buttons } = editor.useToolbarProps('insert');
|
|
80
|
+
|
|
81
|
+
// `useToolbarProps` rebuilds `buttons` (new array + closures) on every render,
|
|
82
|
+
// so guard against pushing an unchanged-by-content array into parent state.
|
|
83
|
+
const signature = buttons.map((b) => b.id).join('|');
|
|
84
|
+
const buttonsRef = useRef(buttons);
|
|
85
|
+
buttonsRef.current = buttons;
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
onButtonsChange(buttonsRef.current);
|
|
89
|
+
onReadyChange(buttonsRef.current.length > 0);
|
|
90
|
+
}, [signature, onButtonsChange, onReadyChange]);
|
|
91
|
+
|
|
92
|
+
return null;
|
|
79
93
|
};
|
|
80
94
|
|
|
95
|
+
InsertToolbarSync.displayName = 'InsertToolbarSync';
|
|
96
|
+
|
|
97
|
+
const filterStaticToolbarButtons = (button: string) =>
|
|
98
|
+
button !== FORMATTING_BUTTONS.CODE_BLOCK;
|
|
99
|
+
|
|
81
100
|
const RCE = forwardRef<RCEHandle, RCEProps & ToggleFullscreenButtonProps>(
|
|
82
101
|
(
|
|
83
102
|
{
|
|
@@ -88,13 +107,11 @@ const RCE = forwardRef<RCEHandle, RCEProps & ToggleFullscreenButtonProps>(
|
|
|
88
107
|
onFocus,
|
|
89
108
|
onBlur,
|
|
90
109
|
className,
|
|
91
|
-
getToolbarSettings,
|
|
92
110
|
dataHook,
|
|
93
111
|
colorScheme,
|
|
94
112
|
isFullScreen,
|
|
95
113
|
onToggleFullScreen,
|
|
96
114
|
hidden,
|
|
97
|
-
children,
|
|
98
115
|
...ricosProps
|
|
99
116
|
},
|
|
100
117
|
ref,
|
|
@@ -102,6 +119,9 @@ const RCE = forwardRef<RCEHandle, RCEProps & ToggleFullscreenButtonProps>(
|
|
|
102
119
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
103
120
|
const containerHeightRef = useRef<number | undefined>();
|
|
104
121
|
|
|
122
|
+
// Stable identity so RicosEditor doesn't see a new `container` prop each render.
|
|
123
|
+
const getContainer = useCallback(() => containerRef.current, []);
|
|
124
|
+
|
|
105
125
|
const onFullScreenChange = useCallback(() => {
|
|
106
126
|
onToggleFullScreen?.();
|
|
107
127
|
|
|
@@ -110,80 +130,90 @@ const RCE = forwardRef<RCEHandle, RCEProps & ToggleFullscreenButtonProps>(
|
|
|
110
130
|
}
|
|
111
131
|
}, [onToggleFullScreen]);
|
|
112
132
|
|
|
113
|
-
const editorRef = useRef<
|
|
133
|
+
const editorRef = useRef<RicosEditorAPI | null>(null);
|
|
134
|
+
const [editor, setEditor] = useState<RicosEditorAPI | null>(null);
|
|
114
135
|
const [isToolbarReady, setIsToolbarReady] = useState(false);
|
|
115
|
-
const [toolbarButtons, setToolbarButtons] = useState
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
136
|
+
const [toolbarButtons, setToolbarButtons] = useState<
|
|
137
|
+
readonly RicosExternalToolbarButton[]
|
|
138
|
+
>([]);
|
|
139
|
+
const [toolbarContainer, setToolbarContainer] =
|
|
140
|
+
useState<HTMLDivElement | null>(null);
|
|
141
|
+
|
|
142
|
+
const setEditorInstance = useCallback((nextEditor: RicosEditorAPI | null) => {
|
|
143
|
+
editorRef.current = nextEditor;
|
|
144
|
+
setEditor(nextEditor);
|
|
145
|
+
}, []);
|
|
122
146
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
147
|
+
const setContent = useCallback((nextContent: RicosDocument) => {
|
|
148
|
+
editorRef.current?.getEditorCommands().setContent(nextContent);
|
|
149
|
+
}, []);
|
|
126
150
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
151
|
+
useImperativeHandle(
|
|
152
|
+
ref,
|
|
153
|
+
() => ({
|
|
154
|
+
isContentChanged: () =>
|
|
155
|
+
Boolean(editorRef.current?.getContentTraits().isContentChanged),
|
|
156
|
+
prePublish: async () =>
|
|
157
|
+
(await editorRef.current?.prePublish()) ??
|
|
158
|
+
INITIAL_INJECTED_RICH_CONTENT,
|
|
159
|
+
setContent,
|
|
160
|
+
}),
|
|
161
|
+
[setContent],
|
|
133
162
|
);
|
|
134
|
-
useEffect(() => updateButtons(false, true));
|
|
135
|
-
|
|
136
|
-
// Poll via rAF until Ricos has populated its toolbar buttons before marking
|
|
137
|
-
// the toolbar as ready. A single call to updateButtons(true) at onLoad time
|
|
138
|
-
// fails silently when Ricos hasn't finished initialising — buttons is empty,
|
|
139
|
-
// setIsToolbarReady is never called, and the loader persists forever.
|
|
140
|
-
const onLoadEditor = useCallback(() => {
|
|
141
|
-
let frameId = 0;
|
|
142
|
-
(function loadToolbar() {
|
|
143
|
-
frameId = requestAnimationFrame(() => {
|
|
144
|
-
if (!editorRef.current) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const { buttons } = editorRef.current.getToolbarProps(
|
|
148
|
-
TOOLBARS.INSERT_PLUGIN,
|
|
149
|
-
);
|
|
150
|
-
if (Object.values(buttons).length > 0) {
|
|
151
|
-
setToolbarButtons(buttons);
|
|
152
|
-
setIsToolbarReady(true);
|
|
153
|
-
} else {
|
|
154
|
-
loadToolbar();
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
})();
|
|
158
|
-
return () => cancelAnimationFrame(frameId);
|
|
159
|
-
}, []);
|
|
160
163
|
|
|
164
|
+
const appliedInjectedContentRef = useRef<RicosDocument | undefined>();
|
|
161
165
|
useEffect(() => {
|
|
162
|
-
if (
|
|
166
|
+
if (
|
|
167
|
+
!injectedContent ||
|
|
168
|
+
isEqual(INITIAL_INJECTED_RICH_CONTENT, injectedContent) ||
|
|
169
|
+
isEqual(appliedInjectedContentRef.current, injectedContent)
|
|
170
|
+
) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
appliedInjectedContentRef.current = injectedContent;
|
|
175
|
+
const timerId = window.setTimeout(() => {
|
|
176
|
+
setContent(injectedContent);
|
|
177
|
+
}, 0);
|
|
178
|
+
|
|
179
|
+
return () => window.clearTimeout(timerId);
|
|
180
|
+
}, [injectedContent, setContent]);
|
|
181
|
+
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
if (!autoFocus || !editorRef.current) {
|
|
163
184
|
return;
|
|
164
185
|
}
|
|
165
186
|
|
|
166
187
|
const frameId = requestAnimationFrame(() => {
|
|
167
188
|
editorRef.current?.focus();
|
|
168
|
-
updateButtons();
|
|
169
189
|
});
|
|
170
190
|
|
|
171
191
|
return () => cancelAnimationFrame(frameId);
|
|
172
|
-
}, [autoFocus,
|
|
192
|
+
}, [autoFocus, editor]);
|
|
173
193
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
194
|
+
const toolbars = useMemo<ToolbarsConfig | undefined>(() => {
|
|
195
|
+
if (!toolbarContainer) {
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
178
198
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
199
|
+
return {
|
|
200
|
+
text: {
|
|
201
|
+
mode: 'static',
|
|
202
|
+
container: toolbarContainer,
|
|
203
|
+
alignment: 'left',
|
|
204
|
+
buttons: ({ defaultButtons }) =>
|
|
205
|
+
defaultButtons.filter(filterStaticToolbarButtons),
|
|
206
|
+
},
|
|
207
|
+
insert: {
|
|
208
|
+
footer: {
|
|
209
|
+
disabled: true,
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
}, [toolbarContainer]);
|
|
184
214
|
|
|
185
215
|
const isModalOpenRef = useRef(false);
|
|
186
|
-
const modalSettings = useMemo<
|
|
216
|
+
const modalSettings = useMemo<RicosEditorProps['modalSettings']>(
|
|
187
217
|
() => ({
|
|
188
218
|
onModalOpen() {
|
|
189
219
|
isModalOpenRef.current = true;
|
|
@@ -228,11 +258,10 @@ const RCE = forwardRef<RCEHandle, RCEProps & ToggleFullscreenButtonProps>(
|
|
|
228
258
|
const handleFocus = useCallback<FocusEventHandler>(() => {
|
|
229
259
|
if (containerRef.current === getActiveElement()) {
|
|
230
260
|
editorRef.current?.focus();
|
|
231
|
-
updateButtons();
|
|
232
261
|
}
|
|
233
262
|
|
|
234
263
|
triggerFocus();
|
|
235
|
-
}, [triggerFocus
|
|
264
|
+
}, [triggerFocus]);
|
|
236
265
|
const handleBlur = useCallback<FocusEventHandler>(
|
|
237
266
|
({ relatedTarget }) => {
|
|
238
267
|
if (!relatedTarget) {
|
|
@@ -244,22 +273,9 @@ const RCE = forwardRef<RCEHandle, RCEProps & ToggleFullscreenButtonProps>(
|
|
|
244
273
|
isModalOpenRef.current ||
|
|
245
274
|
containerRef.current?.contains(relatedTarget)
|
|
246
275
|
) {
|
|
247
|
-
/**
|
|
248
|
-
* @NOTE
|
|
249
|
-
* Ignore events which come from modal or
|
|
250
|
-
* from any target inside editor container
|
|
251
|
-
*/
|
|
252
276
|
return;
|
|
253
277
|
}
|
|
254
278
|
|
|
255
|
-
/**
|
|
256
|
-
* @NOTE
|
|
257
|
-
* If editor container is blurred due to focus of element
|
|
258
|
-
* that is out of app root (e.g. tooltip rendered in portal),
|
|
259
|
-
* then editor blur should be requested to ensure
|
|
260
|
-
* that editor should not be focused after user action,
|
|
261
|
-
* otherwise editor should be blurred immediately
|
|
262
|
-
*/
|
|
263
279
|
if (!getAppRootElement().contains(relatedTarget)) {
|
|
264
280
|
requestEditorBlur();
|
|
265
281
|
} else {
|
|
@@ -269,30 +285,10 @@ const RCE = forwardRef<RCEHandle, RCEProps & ToggleFullscreenButtonProps>(
|
|
|
269
285
|
[triggerBlur, requestEditorBlur],
|
|
270
286
|
);
|
|
271
287
|
|
|
272
|
-
/**
|
|
273
|
-
* NOTE:
|
|
274
|
-
* `handleOnChange` handles only change events when editor is not focused or focus was lost.
|
|
275
|
-
* In a normal flow `onChange` is not called on every input and all the changes submitted on blur.
|
|
276
|
-
*/
|
|
277
|
-
const handleOnChange = useCallback(() => {
|
|
278
|
-
const hasLostFocusElement = document.activeElement === document.body;
|
|
279
|
-
|
|
280
|
-
if (!isFocusedRef.current || hasLostFocusElement) {
|
|
281
|
-
const isInitialInjectedContent = isEqual(
|
|
282
|
-
INITIAL_INJECTED_RICH_CONTENT,
|
|
283
|
-
injectedContent,
|
|
284
|
-
);
|
|
285
|
-
|
|
286
|
-
if (!isInitialInjectedContent) {
|
|
287
|
-
onBlur?.();
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}, [onBlur, injectedContent]);
|
|
291
|
-
|
|
292
288
|
const wixRicosProps = useWixRicosProps();
|
|
293
289
|
const plugins = usePlugins(colorScheme);
|
|
294
290
|
|
|
295
|
-
|
|
291
|
+
return (
|
|
296
292
|
<div
|
|
297
293
|
ref={containerRef}
|
|
298
294
|
data-hook="rich-content.editor"
|
|
@@ -305,7 +301,7 @@ const RCE = forwardRef<RCEHandle, RCEProps & ToggleFullscreenButtonProps>(
|
|
|
305
301
|
}}
|
|
306
302
|
>
|
|
307
303
|
<div className={classes.toolbarAndFullScreenButtonWrapper}>
|
|
308
|
-
<div className={classes.toolbarContainer} ref={
|
|
304
|
+
<div className={classes.toolbarContainer} ref={setToolbarContainer} />
|
|
309
305
|
{!hidden && isToolbarReady && (
|
|
310
306
|
<ToggleFullscreenButton
|
|
311
307
|
isFullScreen={isFullScreen}
|
|
@@ -313,7 +309,32 @@ const RCE = forwardRef<RCEHandle, RCEProps & ToggleFullscreenButtonProps>(
|
|
|
313
309
|
/>
|
|
314
310
|
)}
|
|
315
311
|
</div>
|
|
316
|
-
|
|
312
|
+
|
|
313
|
+
{editor && (
|
|
314
|
+
<InsertToolbarSync
|
|
315
|
+
editor={editor}
|
|
316
|
+
onButtonsChange={setToolbarButtons}
|
|
317
|
+
onReadyChange={setIsToolbarReady}
|
|
318
|
+
/>
|
|
319
|
+
)}
|
|
320
|
+
|
|
321
|
+
{!hidden ? (
|
|
322
|
+
<div data-hook={dataHook} className={classes.editor}>
|
|
323
|
+
<RicosEditor
|
|
324
|
+
ref={setEditorInstance}
|
|
325
|
+
plugins={plugins}
|
|
326
|
+
initialContent={content}
|
|
327
|
+
toolbars={toolbars}
|
|
328
|
+
modalSettings={modalSettings}
|
|
329
|
+
textWrap={false}
|
|
330
|
+
onChange={onChange}
|
|
331
|
+
container={getContainer}
|
|
332
|
+
{...ricosProps}
|
|
333
|
+
{...wixRicosProps}
|
|
334
|
+
/>
|
|
335
|
+
</div>
|
|
336
|
+
) : null}
|
|
337
|
+
|
|
317
338
|
{!isToolbarReady && <RCELoader />}
|
|
318
339
|
{!hidden && isToolbarReady && (
|
|
319
340
|
<div
|
|
@@ -325,26 +346,6 @@ const RCE = forwardRef<RCEHandle, RCEProps & ToggleFullscreenButtonProps>(
|
|
|
325
346
|
)}
|
|
326
347
|
</div>
|
|
327
348
|
);
|
|
328
|
-
|
|
329
|
-
return renderInContainer(
|
|
330
|
-
<div data-hook={dataHook} className={classes.editor}>
|
|
331
|
-
<WixRicosEditor
|
|
332
|
-
ref={editorRef}
|
|
333
|
-
plugins={plugins}
|
|
334
|
-
content={content}
|
|
335
|
-
injectedContent={injectedContent}
|
|
336
|
-
toolbarSettings={toolbarSettings}
|
|
337
|
-
linkPanelSettings={linkPanelSettings}
|
|
338
|
-
modalSettings={modalSettings}
|
|
339
|
-
textWrap={false}
|
|
340
|
-
onLoad={onLoadEditor}
|
|
341
|
-
onChange={handleOnChange}
|
|
342
|
-
container={containerRef.current!}
|
|
343
|
-
{...ricosProps}
|
|
344
|
-
{...wixRicosProps}
|
|
345
|
-
/>
|
|
346
|
-
</div>,
|
|
347
|
-
);
|
|
348
349
|
},
|
|
349
350
|
);
|
|
350
351
|
RCE.displayName = 'RCE';
|
|
@@ -365,237 +366,227 @@ RCELoader.displayName = 'RCELoader';
|
|
|
365
366
|
|
|
366
367
|
const LOADER_DELAY = 100;
|
|
367
368
|
|
|
368
|
-
export type RichContentEditorProps = Omit<
|
|
369
|
-
RCEProps,
|
|
370
|
-
'getToolbarSettings' | 'modalSettings' | 'onChange'
|
|
371
|
-
> & {
|
|
369
|
+
export type RichContentEditorProps = Omit<RCEProps, 'onChange'> & {
|
|
372
370
|
onEnterFullScreen?: (
|
|
373
|
-
content?:
|
|
371
|
+
content?: RicosDocument,
|
|
374
372
|
isContentChanged?: boolean,
|
|
375
373
|
) => void;
|
|
376
374
|
onExitFullScreen?: (
|
|
377
|
-
content?:
|
|
375
|
+
content?: RicosDocument,
|
|
378
376
|
isContentChanged?: boolean,
|
|
379
377
|
) => void;
|
|
380
|
-
onChange?: (content:
|
|
381
|
-
onPublish?: (promise: Promise<
|
|
378
|
+
onChange?: (content: RicosDocument, isContentChanged?: boolean) => void;
|
|
379
|
+
onPublish?: (promise: Promise<RicosDocument>) => void;
|
|
382
380
|
fullScreenOnly?: boolean;
|
|
383
381
|
};
|
|
384
382
|
|
|
385
|
-
export const RichContentEditor: FC<RichContentEditorProps> =
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
(
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
(richContent
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
);
|
|
415
|
-
|
|
416
|
-
const [loader, setLoader] = useState(false);
|
|
417
|
-
const timer = useRef<number>(0);
|
|
418
|
-
const resetLoader = useCallback(() => {
|
|
419
|
-
window.clearTimeout(timer.current);
|
|
420
|
-
setLoader(false);
|
|
421
|
-
}, []);
|
|
422
|
-
const queueLoader = useCallback(() => {
|
|
423
|
-
timer.current = window.setTimeout(() => {
|
|
424
|
-
setLoader(true);
|
|
425
|
-
}, LOADER_DELAY);
|
|
426
|
-
}, []);
|
|
383
|
+
export const RichContentEditor: FC<RichContentEditorProps> = ({
|
|
384
|
+
onFocus,
|
|
385
|
+
onBlur,
|
|
386
|
+
onEnterFullScreen,
|
|
387
|
+
onExitFullScreen,
|
|
388
|
+
fullScreenOnly,
|
|
389
|
+
onPublish,
|
|
390
|
+
onChange,
|
|
391
|
+
theme,
|
|
392
|
+
content,
|
|
393
|
+
...props
|
|
394
|
+
}) => {
|
|
395
|
+
const editorRef = useRef<RCEHandle>(null);
|
|
396
|
+
const modalEditorRef = useRef<RCEHandle>(null);
|
|
397
|
+
|
|
398
|
+
const isRichContentChanged = useCallback(
|
|
399
|
+
() =>
|
|
400
|
+
Boolean(
|
|
401
|
+
editorRef.current?.isContentChanged() ||
|
|
402
|
+
modalEditorRef.current?.isContentChanged(),
|
|
403
|
+
),
|
|
404
|
+
[],
|
|
405
|
+
);
|
|
406
|
+
const handleChange = useCallback(
|
|
407
|
+
(richContent: RicosDocument) => {
|
|
408
|
+
onChange?.(richContent, isRichContentChanged());
|
|
409
|
+
},
|
|
410
|
+
[onChange, isRichContentChanged],
|
|
411
|
+
);
|
|
427
412
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
413
|
+
const [loader, setLoader] = useState(false);
|
|
414
|
+
const timer = useRef<number>(0);
|
|
415
|
+
const resetLoader = useCallback(() => {
|
|
416
|
+
window.clearTimeout(timer.current);
|
|
417
|
+
setLoader(false);
|
|
418
|
+
}, []);
|
|
419
|
+
const queueLoader = useCallback(() => {
|
|
420
|
+
timer.current = window.setTimeout(() => {
|
|
421
|
+
setLoader(true);
|
|
422
|
+
}, LOADER_DELAY);
|
|
423
|
+
}, []);
|
|
424
|
+
|
|
425
|
+
const [isFullScreen, setIsFullScreen] = useState(!!fullScreenOnly);
|
|
426
|
+
const [fullScreenContent, setFullScreenContent] = useState(content);
|
|
427
|
+
|
|
428
|
+
useEffect(() => {
|
|
429
|
+
if (!isFullScreen) {
|
|
430
|
+
setFullScreenContent(content);
|
|
431
|
+
}
|
|
432
|
+
}, [content, isFullScreen]);
|
|
433
|
+
|
|
434
|
+
const publishEditorContent = useCallback(
|
|
435
|
+
async (
|
|
436
|
+
editorHandle: RCEHandle | null,
|
|
437
|
+
fallbackContent?: RicosDocument,
|
|
438
|
+
): Promise<RicosDocument> => {
|
|
439
|
+
if (!editorHandle) {
|
|
440
|
+
return fallbackContent ?? INITIAL_INJECTED_RICH_CONTENT;
|
|
445
441
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
442
|
+
|
|
443
|
+
return (
|
|
444
|
+
(await editorHandle.prePublish()) ??
|
|
445
|
+
fallbackContent ??
|
|
446
|
+
INITIAL_INJECTED_RICH_CONTENT
|
|
447
|
+
);
|
|
448
|
+
},
|
|
449
|
+
[],
|
|
450
|
+
);
|
|
451
|
+
|
|
452
|
+
const onOpen = useCallback(async () => {
|
|
453
|
+
let finalContent = content;
|
|
454
|
+
const isChanged = isRichContentChanged();
|
|
455
|
+
|
|
456
|
+
try {
|
|
457
|
+
finalContent = await publishEditorContent(editorRef.current, content);
|
|
458
|
+
onEnterFullScreen?.(finalContent, isChanged);
|
|
459
|
+
} catch (error) {
|
|
460
|
+
finalContent = content;
|
|
461
|
+
onEnterFullScreen?.(content, isChanged);
|
|
462
|
+
} finally {
|
|
463
|
+
setFullScreenContent(finalContent);
|
|
464
|
+
setIsFullScreen(true);
|
|
465
|
+
|
|
466
|
+
if (isChanged && finalContent) {
|
|
467
|
+
handleChange(finalContent);
|
|
470
468
|
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
469
|
+
}
|
|
470
|
+
}, [
|
|
471
|
+
content,
|
|
472
|
+
handleChange,
|
|
473
|
+
isRichContentChanged,
|
|
474
|
+
onEnterFullScreen,
|
|
475
|
+
publishEditorContent,
|
|
476
|
+
]);
|
|
477
|
+
const onClose = useCallback(async () => {
|
|
478
|
+
queueLoader();
|
|
479
|
+
let finalContent = content;
|
|
480
|
+
const isChanged = isRichContentChanged();
|
|
481
|
+
|
|
482
|
+
try {
|
|
483
|
+
finalContent = await publishEditorContent(modalEditorRef.current, content);
|
|
484
|
+
onExitFullScreen?.(finalContent, isChanged);
|
|
485
|
+
} catch (error) {
|
|
486
|
+
finalContent = content;
|
|
487
|
+
onExitFullScreen?.(content, isChanged);
|
|
488
|
+
} finally {
|
|
489
|
+
resetLoader();
|
|
490
|
+
setIsFullScreen(false);
|
|
491
|
+
|
|
492
|
+
if (isChanged && finalContent) {
|
|
493
|
+
handleChange(finalContent);
|
|
484
494
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
495
|
+
}
|
|
496
|
+
}, [
|
|
497
|
+
content,
|
|
498
|
+
handleChange,
|
|
499
|
+
isRichContentChanged,
|
|
500
|
+
onExitFullScreen,
|
|
501
|
+
publishEditorContent,
|
|
502
|
+
queueLoader,
|
|
503
|
+
resetLoader,
|
|
504
|
+
]);
|
|
505
|
+
|
|
506
|
+
const handleBlur = useCallback(() => {
|
|
507
|
+
if (isRichContentChanged()) {
|
|
508
|
+
onPublish?.(
|
|
509
|
+
publishEditorContent(editorRef.current, content).catch(
|
|
510
|
+
() => content ?? INITIAL_INJECTED_RICH_CONTENT,
|
|
511
|
+
),
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
onBlur?.();
|
|
515
|
+
}, [
|
|
516
|
+
content,
|
|
517
|
+
isRichContentChanged,
|
|
518
|
+
onBlur,
|
|
519
|
+
onPublish,
|
|
520
|
+
publishEditorContent,
|
|
521
|
+
]);
|
|
522
|
+
|
|
523
|
+
useEffect(() => {
|
|
524
|
+
if (!isFullScreen) {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
const handleKeyDown = (e: KeyboardEvent) => {
|
|
529
|
+
if (e.key === 'Escape') {
|
|
530
|
+
e.stopPropagation();
|
|
531
|
+
void onClose();
|
|
493
532
|
}
|
|
494
|
-
const handleKeyDown = (e: KeyboardEvent) => {
|
|
495
|
-
if (e.key === 'Escape') {
|
|
496
|
-
e.stopPropagation();
|
|
497
|
-
onClose();
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
document.addEventListener('keydown', handleKeyDown, true);
|
|
501
|
-
return () => document.removeEventListener('keydown', handleKeyDown, true);
|
|
502
|
-
}, [isFullScreen, onClose]);
|
|
503
|
-
|
|
504
|
-
const getToolbarSettings = useGetToolbarSettings();
|
|
505
|
-
|
|
506
|
-
const rceProps = {
|
|
507
|
-
getToolbarSettings,
|
|
508
|
-
onChange: handleChange,
|
|
509
533
|
};
|
|
510
534
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
{
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
theme={theme}
|
|
531
|
-
onFocus={onFocus}
|
|
532
|
-
onBlur={handleBlur}
|
|
533
|
-
hidden={isFullScreen}
|
|
534
|
-
ref={editorRef}
|
|
535
|
-
isFullScreen={false}
|
|
536
|
-
onToggleFullScreen={onOpen}
|
|
537
|
-
/>
|
|
538
|
-
)}
|
|
539
|
-
<FullscreenModal isOpen={isFullScreen} isLoading={loader}>
|
|
540
|
-
<RCE
|
|
541
|
-
{...props}
|
|
542
|
-
{...rceProps}
|
|
543
|
-
theme={fullScreenTheme}
|
|
544
|
-
autoFocus
|
|
545
|
-
className={classes.modalEditor}
|
|
546
|
-
ref={modalEditorRef}
|
|
547
|
-
isFullScreen
|
|
548
|
-
onToggleFullScreen={onClose}
|
|
549
|
-
/>
|
|
550
|
-
</FullscreenModal>
|
|
551
|
-
</>
|
|
552
|
-
);
|
|
553
|
-
},
|
|
554
|
-
);
|
|
555
|
-
RichContentEditor.displayName = 'RichContentEditor';
|
|
556
|
-
|
|
557
|
-
const filterStaticToolbarButtons = (button: string | TextGroupButtons) =>
|
|
558
|
-
button !== FORMATTING_BUTTONS.CODE_BLOCK;
|
|
559
|
-
|
|
560
|
-
const useGetToolbarSettings = () =>
|
|
561
|
-
useCallback<GetToolbarSettings>(
|
|
562
|
-
({ textButtons }) =>
|
|
563
|
-
[
|
|
564
|
-
{
|
|
565
|
-
name: TOOLBARS.INSERT_PLUGIN,
|
|
566
|
-
shouldCreate: () => ({ desktop: true }),
|
|
567
|
-
},
|
|
568
|
-
{
|
|
569
|
-
name: TOOLBARS.FOOTER,
|
|
570
|
-
shouldCreate: () => ({ desktop: false }),
|
|
535
|
+
document.addEventListener('keydown', handleKeyDown, true);
|
|
536
|
+
return () => document.removeEventListener('keydown', handleKeyDown, true);
|
|
537
|
+
}, [isFullScreen, onClose]);
|
|
538
|
+
|
|
539
|
+
const rceProps = {
|
|
540
|
+
onChange: handleChange,
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
// Must be memoized: Ricos re-processes `theme` whenever its identity changes,
|
|
544
|
+
// so passing a freshly cloned object every render drives an infinite
|
|
545
|
+
// re-render loop (freezes the tab) once the fullscreen editor mounts.
|
|
546
|
+
const fullScreenTheme = useMemo(
|
|
547
|
+
() =>
|
|
548
|
+
defaultsDeep(cloneDeep(theme), {
|
|
549
|
+
customStyles: { editor: { maxHeight: '100%' } },
|
|
550
|
+
settingsStyles: {
|
|
551
|
+
modals: {
|
|
552
|
+
dialogZIndex: Z_INDEX_MODAL_POPOVER,
|
|
553
|
+
},
|
|
571
554
|
},
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
getButtons: () => ({
|
|
575
|
-
desktop: [
|
|
576
|
-
...(textButtons?.desktop?.filter?.(filterStaticToolbarButtons) ??
|
|
577
|
-
[]),
|
|
578
|
-
],
|
|
579
|
-
}),
|
|
580
|
-
},
|
|
581
|
-
{
|
|
582
|
-
name: TOOLBARS.QUICK_ACTIONS,
|
|
583
|
-
activateOnFloatingPlusButton: true,
|
|
584
|
-
shouldCreate: () => ({ desktop: true }),
|
|
585
|
-
},
|
|
586
|
-
].filter(Boolean) as ToolbarSettingsFunctions[],
|
|
587
|
-
[],
|
|
555
|
+
}),
|
|
556
|
+
[theme],
|
|
588
557
|
);
|
|
589
558
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
559
|
+
return (
|
|
560
|
+
<>
|
|
561
|
+
<UserSiteFonts />
|
|
562
|
+
{!fullScreenOnly && (
|
|
563
|
+
<RCE
|
|
564
|
+
{...props}
|
|
565
|
+
{...rceProps}
|
|
566
|
+
content={content}
|
|
567
|
+
theme={theme}
|
|
568
|
+
onFocus={onFocus}
|
|
569
|
+
onBlur={handleBlur}
|
|
570
|
+
hidden={isFullScreen}
|
|
571
|
+
ref={editorRef}
|
|
572
|
+
isFullScreen={false}
|
|
573
|
+
onToggleFullScreen={onOpen}
|
|
574
|
+
/>
|
|
575
|
+
)}
|
|
576
|
+
<FullscreenModal isOpen={isFullScreen} isLoading={loader}>
|
|
577
|
+
<RCE
|
|
578
|
+
{...props}
|
|
579
|
+
{...rceProps}
|
|
580
|
+
content={fullScreenContent}
|
|
581
|
+
theme={fullScreenTheme}
|
|
582
|
+
autoFocus
|
|
583
|
+
className={classes.modalEditor}
|
|
584
|
+
ref={modalEditorRef}
|
|
585
|
+
isFullScreen
|
|
586
|
+
onToggleFullScreen={onClose}
|
|
587
|
+
/>
|
|
588
|
+
</FullscreenModal>
|
|
589
|
+
</>
|
|
601
590
|
);
|
|
591
|
+
};
|
|
592
|
+
RichContentEditor.displayName = 'RichContentEditor';
|