@brightspot/ui 3.0.1-cms-ui-migration.1 → 3.0.1-cms-ui-migration.3
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 +54 -35
- package/dist/custom-elements.json +2536 -2536
- package/dist/storybook/assets/{ActionBar.stories-BhdqLyzJ.js → ActionBar.stories-CSxtZl7v.js} +1 -1
- package/dist/storybook/assets/{ActionItem.stories-17zjMCkO.js → ActionItem.stories-BWcMRMP3.js} +1 -1
- package/dist/storybook/assets/{Avatar.stories-C5m3-zOH.js → Avatar.stories-CYTUGXzH.js} +1 -1
- package/dist/storybook/assets/{AvatarGroup.stories-DE88PJ6w.js → AvatarGroup.stories-CSYBYo_5.js} +1 -1
- package/dist/storybook/assets/{Badge.stories-D905HmvO.js → Badge.stories-LuF4BuVr.js} +1 -1
- package/dist/storybook/assets/{Button-ANyLESGb.js → Button-CrXCMxHb.js} +1 -1
- package/dist/storybook/assets/{Button.stories-DbH6q5L3.js → Button.stories-JVwxdrdM.js} +1 -1
- package/dist/storybook/assets/{ButtonGroup.stories-loqgAB7p.js → ButtonGroup.stories-qtq64a1H.js} +1 -1
- package/dist/storybook/assets/{Celebrate.stories-CRO3rSgp.js → Celebrate.stories-DjTtaSd6.js} +1 -1
- package/dist/storybook/assets/{Checkbox.stories-SZtgfbFe.js → Checkbox.stories-v1Pr5mL6.js} +1 -1
- package/dist/storybook/assets/{CircularProgress.stories-VayPxO4M.js → CircularProgress.stories-DkV7PJ4D.js} +1 -1
- package/dist/storybook/assets/{ClipboardMixin.stories-0EB2O2zT.js → ClipboardMixin.stories-Dh5c7uSM.js} +1 -1
- package/dist/storybook/assets/{Color-6BZIO3FS-CFpcD80i.js → Color-6BZIO3FS-B1gcREt6.js} +1 -1
- package/dist/storybook/assets/{Colors.stories-BJGM6xnp.js → Colors.stories-DnubtRqn.js} +1 -1
- package/dist/storybook/assets/{CombinedEffects.stories-DUwocYcn.js → CombinedEffects.stories-By6akSve.js} +1 -1
- package/dist/storybook/assets/{ComponentStatesMixin-MUqdPCf7.js → ComponentStatesMixin-CPLGv3h-.js} +1 -1
- package/dist/storybook/assets/{ComponentStatesMixin.stories-DjrxNwE7.js → ComponentStatesMixin.stories-CiQ_lyhm.js} +1 -1
- package/dist/storybook/assets/{CopyToClipboard.stories-DptOcPq6.js → CopyToClipboard.stories-cJ7rl3mj.js} +1 -1
- package/dist/storybook/assets/{Debounce.stories-BbcIWmhD.js → Debounce.stories-Bw-goobU.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-LL677BLK-Yy8fjeNG.js → DocsRenderer-LL677BLK-CNW57dGQ.js} +3 -3
- package/dist/storybook/assets/{Dropdown.stories-Du3LrBR6.js → Dropdown.stories-CwC3HXXd.js} +1 -1
- package/dist/storybook/assets/{EmptyState.stories-Dy9P8aOY.js → EmptyState.stories-BUEJwuhP.js} +1 -1
- package/dist/storybook/assets/{Events.stories-DvdVQxDf.js → Events.stories-D1mf9buv.js} +1 -1
- package/dist/storybook/assets/{Heading.stories-BQ1jFOKn.js → Heading.stories-DO906G4P.js} +1 -1
- package/dist/storybook/assets/{HueRipple.stories-CrZFjnRl.js → HueRipple.stories-BOySRSZB.js} +1 -1
- package/dist/storybook/assets/{Icon.stories-C2Tj8Lx1.js → Icon.stories-BsqgTbdG.js} +1 -1
- package/dist/storybook/assets/{IconButton.stories-DFqouOJb.js → IconButton.stories-aza1AAKk.js} +1 -1
- package/dist/storybook/assets/{LinearProgress.stories-DtNw3QX3.js → LinearProgress.stories-CDYmiiex.js} +1 -1
- package/dist/storybook/assets/{Pagination.stories-CFiZ9APs.js → Pagination.stories-LXB-x7YB.js} +1 -1
- package/dist/storybook/assets/{Popover.stories-DkkTuYag.js → Popover.stories-DY1HesPJ.js} +1 -1
- package/dist/storybook/assets/{ReadyMixin-BA01Vm_B.js → ReadyMixin-DmOC67IJ.js} +1 -1
- package/dist/storybook/assets/{RovingTabindexMixin.stories-BesAqt48.js → RovingTabindexMixin.stories-BWy0Rq8d.js} +1 -1
- package/dist/storybook/assets/{Rtc.stories-iTw43rjp.js → Rtc.stories-DrmdqqbI.js} +1 -1
- package/dist/storybook/assets/{ScrollShadow.stories-QYqQCcAo.js → ScrollShadow.stories-DiKFPazh.js} +1 -1
- package/dist/storybook/assets/{Switch.stories-BKArq9Mk.js → Switch.stories-BgFnw8_z.js} +1 -1
- package/dist/storybook/assets/{Tab.stories-8UdDPvE5.js → Tab.stories-c2wLMooF.js} +1 -1
- package/dist/storybook/assets/{Tabs.stories-BPGMZ552.js → Tabs.stories-CjH8seNP.js} +1 -1
- package/dist/storybook/assets/{Throttle.stories-CYl5d0r6.js → Throttle.stories-CXysc_QE.js} +1 -1
- package/dist/storybook/assets/{Tooltip.stories-cZ0zSlwX.js → Tooltip.stories-6qzyByPm.js} +1 -1
- package/dist/storybook/assets/{Upload.stories-CPC7N0Ed.js → Upload.stories-BLxykydQ.js} +1 -1
- package/dist/storybook/assets/{UploadItem.stories-D0LClT0a.js → UploadItem.stories-CcfcqdJW.js} +1 -1
- package/dist/storybook/assets/{Welcome.stories-C8JUaRas.js → Welcome.stories-CzYS_3fH.js} +1 -1
- package/dist/storybook/assets/{Widget.stories-C1FxF24-.js → Widget.stories-Du7T4LAI.js} +1 -1
- package/dist/storybook/assets/{WithTooltip-65CFNBJE-BMBo-fie.js → WithTooltip-65CFNBJE-D4LfXdYt.js} +1 -1
- package/dist/storybook/assets/{blocks-BTsuXRXZ.js → blocks-DR3fGePu.js} +5 -5
- package/dist/storybook/assets/{formatter-EIJCOSYU-BJ1Cwrpx.js → formatter-EIJCOSYU-Cf01216O.js} +1 -1
- package/dist/storybook/assets/if-defined-DaMmbcIU.js +1 -0
- package/dist/storybook/assets/{iframe-B3YWTqkR.js → iframe-CQArUhO8.js} +4 -4
- package/dist/storybook/assets/{iframe-BgFj0b5u.css → iframe-D0roG0J-.css} +1 -1
- package/dist/storybook/assets/{index-BBUTVEdP.js → index-B1uI_67G.js} +1 -1
- package/dist/storybook/assets/{onFind-NC0lGo-r.js → onFind-BpFkN2Rh.js} +1 -1
- package/dist/storybook/assets/{onFind.stories-CqbwQgQF.js → onFind.stories-Cxdeg69X.js} +1 -1
- package/dist/storybook/assets/{onRemove.stories-Y8Ycs77o.js → onRemove.stories-BHEWpNrE.js} +1 -1
- package/dist/storybook/assets/{onVisible.stories-CcLUE35q.js → onVisible.stories-DFJ3S_ZS.js} +1 -1
- package/dist/storybook/assets/{style-map-MSB_ngx3.js → style-map-DJ83UC3V.js} +1 -1
- package/dist/storybook/assets/{syntaxhighlighter-ED5Y7EFY-BjkjEDMG.js → syntaxhighlighter-ED5Y7EFY-zYN83mxK.js} +1 -1
- package/dist/storybook/iframe.html +2 -2
- package/dist/storybook/project.json +1 -1
- package/dist/tailwind.config.d.ts +4 -1
- package/dist/tailwind.config.d.ts.map +1 -1
- package/dist/tailwind.config.js +0 -2
- package/dist/tailwind.config.js.map +1 -1
- package/dist/tailwind.config.ts +0 -2
- package/package.json +16 -2
- package/dist/storybook/assets/if-defined-BPCd2NXs.js +0 -1
- package/src/legacy/tool-ui/src/main/resources/settings.properties +0 -1
- package/src/legacy/tool-ui/src/main/webapp/WEB-INF/web.xml +0 -81
- package/src/legacy/tool-ui/src/main/webapp/script/bsp-uploader.js +0 -170
- package/src/legacy/tool-ui/src/main/webapp/script/bsp-utils.js +0 -393
- package/src/legacy/tool-ui/src/main/webapp/script/content/layout-element.js +0 -141
- package/src/legacy/tool-ui/src/main/webapp/script/input/query.js +0 -78
- package/src/legacy/tool-ui/src/main/webapp/script/input/workflow.js +0 -718
- package/src/legacy/tool-ui/src/main/webapp/script/jquery.extra.js +0 -633
- package/src/legacy/tool-ui/src/main/webapp/script/v3/Dropbox.js +0 -18
- package/src/legacy/tool-ui/src/main/webapp/script/v3/EditFieldUpdate.js +0 -406
- package/src/legacy/tool-ui/src/main/webapp/script/v3/EditFieldUpdateCache.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/script/v3/Notification.js +0 -151
- package/src/legacy/tool-ui/src/main/webapp/script/v3/content/edit.js +0 -194
- package/src/legacy/tool-ui/src/main/webapp/script/v3/content/state.js +0 -785
- package/src/legacy/tool-ui/src/main/webapp/script/v3/csrf.js +0 -35
- package/src/legacy/tool-ui/src/main/webapp/script/v3/dashboard.js +0 -65
- package/src/legacy/tool-ui/src/main/webapp/script/v3/input/dataTransfer.js +0 -129
- package/src/legacy/tool-ui/src/main/webapp/script/v3/input/file.js +0 -433
- package/src/legacy/tool-ui/src/main/webapp/script/v3/input/object.js +0 -743
- package/src/legacy/tool-ui/src/main/webapp/script/v3/input/read-only.js +0 -17
- package/src/legacy/tool-ui/src/main/webapp/script/v3/jquery.frame.js +0 -478
- package/src/legacy/tool-ui/src/main/webapp/script/v3/jquery.repeatable.js +0 -2406
- package/src/legacy/tool-ui/src/main/webapp/script/v3/plugin/popup.d.ts +0 -2
- package/src/legacy/tool-ui/src/main/webapp/script/v3/plugin/popup.js +0 -446
- package/src/legacy/tool-ui/src/main/webapp/script/v3/search-filters.js +0 -62
- package/src/legacy/tool-ui/src/main/webapp/script/v3/search.js +0 -53
- package/src/legacy/tool-ui/src/main/webapp/script/v3.js +0 -1049
- package/src/legacy/tool-ui/src/main/webapp/v4/Admin.js +0 -16
- package/src/legacy/tool-ui/src/main/webapp/v4/AutoExpand.js +0 -84
- package/src/legacy/tool-ui/src/main/webapp/v4/AutoSubmit.js +0 -68
- package/src/legacy/tool-ui/src/main/webapp/v4/Bridge.js +0 -536
- package/src/legacy/tool-ui/src/main/webapp/v4/CheckboxInput.js +0 -22
- package/src/legacy/tool-ui/src/main/webapp/v4/ColorInput.js +0 -5
- package/src/legacy/tool-ui/src/main/webapp/v4/ColorInputSpectrum.js +0 -107
- package/src/legacy/tool-ui/src/main/webapp/v4/ComboInput.js +0 -1491
- package/src/legacy/tool-ui/src/main/webapp/v4/CommunityWidget.js +0 -29
- package/src/legacy/tool-ui/src/main/webapp/v4/ContentEdit.js +0 -2427
- package/src/legacy/tool-ui/src/main/webapp/v4/ContentLock.js +0 -470
- package/src/legacy/tool-ui/src/main/webapp/v4/ContentReporting.js +0 -32
- package/src/legacy/tool-ui/src/main/webapp/v4/DataTable.js +0 -31
- package/src/legacy/tool-ui/src/main/webapp/v4/DateStringField.js +0 -485
- package/src/legacy/tool-ui/src/main/webapp/v4/Entry.js +0 -264
- package/src/legacy/tool-ui/src/main/webapp/v4/ExternalItemAuth.js +0 -16
- package/src/legacy/tool-ui/src/main/webapp/v4/Form.js +0 -31
- package/src/legacy/tool-ui/src/main/webapp/v4/Hierarchy.js +0 -100
- package/src/legacy/tool-ui/src/main/webapp/v4/Icon.ts +0 -49
- package/src/legacy/tool-ui/src/main/webapp/v4/ImageEditor.js +0 -2403
- package/src/legacy/tool-ui/src/main/webapp/v4/ImageEditorBundle.js +0 -5
- package/src/legacy/tool-ui/src/main/webapp/v4/LinkCarousel.js +0 -40
- package/src/legacy/tool-ui/src/main/webapp/v4/LinkList.js +0 -14
- package/src/legacy/tool-ui/src/main/webapp/v4/LinkTable.js +0 -123
- package/src/legacy/tool-ui/src/main/webapp/v4/Location.js +0 -19
- package/src/legacy/tool-ui/src/main/webapp/v4/LocationMap.js +0 -148
- package/src/legacy/tool-ui/src/main/webapp/v4/LookingGlass.js +0 -24
- package/src/legacy/tool-ui/src/main/webapp/v4/Message.js +0 -14
- package/src/legacy/tool-ui/src/main/webapp/v4/NumberBar.js +0 -32
- package/src/legacy/tool-ui/src/main/webapp/v4/Page.js +0 -890
- package/src/legacy/tool-ui/src/main/webapp/v4/Preview.js +0 -758
- package/src/legacy/tool-ui/src/main/webapp/v4/PreviewEditor.js +0 -86
- package/src/legacy/tool-ui/src/main/webapp/v4/PreviewOverlay.js +0 -1005
- package/src/legacy/tool-ui/src/main/webapp/v4/PubSub.js +0 -47
- package/src/legacy/tool-ui/src/main/webapp/v4/QueryField.js +0 -211
- package/src/legacy/tool-ui/src/main/webapp/v4/RegionMap.js +0 -215
- package/src/legacy/tool-ui/src/main/webapp/v4/RepeatableContentInputGroup.js +0 -160
- package/src/legacy/tool-ui/src/main/webapp/v4/RichTextEditor.js +0 -154
- package/src/legacy/tool-ui/src/main/webapp/v4/SearchFields.js +0 -281
- package/src/legacy/tool-ui/src/main/webapp/v4/SearchResult.js +0 -255
- package/src/legacy/tool-ui/src/main/webapp/v4/SharePreview.js +0 -56
- package/src/legacy/tool-ui/src/main/webapp/v4/Sortable.js +0 -874
- package/src/legacy/tool-ui/src/main/webapp/v4/StyleEmbeddedContent.js +0 -100
- package/src/legacy/tool-ui/src/main/webapp/v4/StyleguidePresets.js +0 -357
- package/src/legacy/tool-ui/src/main/webapp/v4/TabContainer.js +0 -360
- package/src/legacy/tool-ui/src/main/webapp/v4/Taxonomy.js +0 -27
- package/src/legacy/tool-ui/src/main/webapp/v4/ThemeBundleEditor.js +0 -224
- package/src/legacy/tool-ui/src/main/webapp/v4/TimedContent.js +0 -147
- package/src/legacy/tool-ui/src/main/webapp/v4/TimedContentBundle.js +0 -8
- package/src/legacy/tool-ui/src/main/webapp/v4/VideoEditor.js +0 -2417
- package/src/legacy/tool-ui/src/main/webapp/v4/VideoEditorBundle.js +0 -8
- package/src/legacy/tool-ui/src/main/webapp/v4/ViewMirror.js +0 -52
- package/src/legacy/tool-ui/src/main/webapp/v4/ViewPreview.d.ts +0 -13
- package/src/legacy/tool-ui/src/main/webapp/v4/ViewPreview.js +0 -177
- package/src/legacy/tool-ui/src/main/webapp/v4/Widget.js +0 -90
- package/src/legacy/tool-ui/src/main/webapp/v4/__mocks__/fileMock.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/__mocks__/styleMock.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/__mocks__/textArea.mock.js +0 -20
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/globals.js +0 -770
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/ProseMirror.test.js +0 -16
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/index.html +0 -54
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/comment_manager/CommentManager.test.js +0 -29
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/comment_manager/index.html +0 -35
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/custom_keyboard/CustomKeyboard.js +0 -42
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/custom_keyboard/index.html +0 -37
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/enhancement_manager/EnhancementManager.test.js +0 -288
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/enhancement_manager/block.html +0 -38
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/enhancement_manager/inline.html +0 -38
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/enhancement_manager/no-popups.html +0 -38
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/list_manager/ListManager.js +0 -257
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/list_manager/index.html +0 -38
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/menubar/hierarchal.html +0 -33
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/menubar/index.html +0 -33
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/menubar/menubar.test.js +0 -195
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/menubar/small.html +0 -34
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/menubar/tags.html +0 -34
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/placeholder_manager/PlaceholderManager.test.js +0 -134
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/placeholder_manager/has-editable-placeholder.html +0 -32
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/placeholder_manager/has-text.html +0 -34
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/placeholder_manager/index.html +0 -31
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/table_manager/TableManager.test.js +0 -63
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/table_manager/existing.html +0 -48
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/track_manager/TrackManager.test.js +0 -291
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/track_manager/existing.html +0 -39
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/integration/rte/plugins/track_manager/insert.html +0 -37
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/unit/Sortable.test.js +0 -105
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/unit/rte/ProseMirror.test.js +0 -41
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/unit/rte/codemirror-shim.test.js +0 -72
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/unit/rte/plugins/collab_manager/CollabManager.test.js +0 -46
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/unit/rte/plugins/enhancement_manager/EnhancementManager.test.js +0 -84
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/unit/rte/plugins/list_manager/ListManager.test.js +0 -54
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/unit/rte/plugins/menubar/menubar.test.js +0 -183
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/unit/rte/plugins/spellcheck/SpellCheck.test.js +0 -45
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/unit/rte/settings/BSSerializer.test.js +0 -346
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/unit/rte/settings/menuItemsBuilder.test.js +0 -226
- package/src/legacy/tool-ui/src/main/webapp/v4/__tests__/unit/rte/utilities.test.js +0 -118
- package/src/legacy/tool-ui/src/main/webapp/v4/appetizeio/Appetizeio.js +0 -5
- package/src/legacy/tool-ui/src/main/webapp/v4/appetizeio/AppetizeioEmbedded.js +0 -113
- package/src/legacy/tool-ui/src/main/webapp/v4/compat/Fetch.js +0 -16
- package/src/legacy/tool-ui/src/main/webapp/v4/compat/jquery.js +0 -32
- package/src/legacy/tool-ui/src/main/webapp/v4/compat/requirejs.js +0 -13
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/Tether.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/TetherLayout.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/closest.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/create.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/find.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/findAll.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/ifClick.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/ifMatches.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/ifUnmodified.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/index.js +0 -5
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/insertBefore.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/insertFirst.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/insertLast.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/onFind.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/onFindOnce.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/onRTEReady.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/onRemove.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/onVisible.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/previousUntil.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/dom/resolveIconCompat.js +0 -40
- package/src/legacy/tool-ui/src/main/webapp/v4/rtc/Socket.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/rtc/index.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/ProseMirror.js +0 -909
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/README.md +0 -68
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/codemirror-shim.d.ts +0 -8
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/codemirror-shim.js +0 -274
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/collab-workflow.jpeg +0 -0
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/interchangeable.ts +0 -250
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/mention.js +0 -90
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/PluginProvider.js +0 -124
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/README.md +0 -46
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/ai_inline_manager/AIInlineManager.ts +0 -124
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/ai_inline_manager/views/AIInlineView.ts +0 -1019
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/ai_manager/AiManager.ts +0 -199
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/collab_manager/CollabManager.js +0 -339
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/collab_manager/views/AvatarView.js +0 -96
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/comment_manager/CommentManager.js +0 -348
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/custom_keyboard/CustomKeyboard.js +0 -110
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/custom_keyboard/README.md +0 -29
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/enhancement_manager/EnhancementManager.js +0 -428
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/enhancement_manager/README.md +0 -63
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/enhancement_manager/commands.js +0 -690
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/enhancement_manager/constants.js +0 -12
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/enhancement_manager/enhancement-creation.jpeg +0 -0
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/enhancement_manager/index.js +0 -15
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/enhancement_manager/rte-flow.jpeg +0 -0
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/enhancement_manager/views/ActionButtonView.js +0 -86
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/enhancement_manager/views/BlockSubmenuView.js +0 -60
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/enhancement_manager/views/EnhancementView.js +0 -208
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/enhancement_manager/views/PreviewView.js +0 -102
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/enhancement_manager/views/SubmenuView.js +0 -365
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/find_replace_manager/FindReplaceManager.js +0 -239
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/find_replace_manager/views/FindView.js +0 -604
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/fullscreen_manager/FullscreenManager.js +0 -57
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/fullscreen_manager/README.md +0 -26
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/fullscreen_manager/commands.js +0 -16
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/fullscreen_manager/index.js +0 -4
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/fullscreen_manager/views/FullscreenView.js +0 -474
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/html_editor_manager/htmlEditorManager.js +0 -66
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/html_editor_manager/views/HtmlEditorView.js +0 -97
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/list_manager/ListManager.js +0 -342
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/list_manager/README.md +0 -50
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/list_manager/commands.js +0 -207
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/list_manager/constants.js +0 -26
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/list_manager/index.js +0 -4
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/menubar/Menubar.js +0 -485
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/menubar/README.md +0 -40
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/menubar/views/MenuView.js +0 -842
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/paste_manager/PasteManager.js +0 -368
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/placeholder_manager/PlaceHolderManager.js +0 -128
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/raw_text_manager/README.md +0 -13
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/raw_text_manager/RawTextManager.js +0 -96
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/spellcheck/index.js +0 -3
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/spellcheck/spellcheck-plugin.js +0 -280
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/spellcheck/spellcheck-service.js +0 -94
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/table_manager/TableManager.js +0 -57
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/table_manager/commands.js +0 -97
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/table_manager/views/TableSizerView.js +0 -88
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/table_manager/views/TableView.js +0 -613
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/track_manager/README.md +0 -13
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/plugins/track_manager/TrackManager.js +0 -905
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/settings/BSSerializer.js +0 -819
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/settings/README.md +0 -80
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/settings/commands.js +0 -98
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/settings/constants.d.ts +0 -84
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/settings/constants.js +0 -87
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/settings/index.js +0 -13
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/settings/keymapBuilder.js +0 -223
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/settings/menuItemsBuilder.js +0 -559
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/settings/schemaBuilder.js +0 -1281
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/utilities.d.ts +0 -4
- package/src/legacy/tool-ui/src/main/webapp/v4/rte/utilities.js +0 -359
- package/src/legacy/tool-ui/src/main/webapp/v4/theme/ColorRotator.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/util/debounce.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/util/getComponentKey.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/util/noise.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/util/repaint.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/util/storage.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/util/throttle.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/v4/widget/AssignmentContent.js +0 -33
- package/src/legacy/tool-ui/src/main/webapp/v4/widget/AssignmentDeskDashboard.js +0 -217
- package/src/legacy/tool-ui/src/main/webapp/v4/widget/AssociatedContentWidget.js +0 -7
- package/src/legacy/tool-ui/src/main/webapp/v4/widget/BulkUpload.js +0 -19
- package/src/legacy/tool-ui/src/main/webapp/v4/widget/Calendar.js +0 -7
- package/src/legacy/tool-ui/src/main/webapp/v4/widget/ClosableWindow.js +0 -13
- package/src/legacy/tool-ui/src/main/webapp/v4/widget/PitchAssignments.js +0 -25
- package/src/legacy/tool-ui/src/main/webapp/v4/widget/PitchContent.js +0 -33
- package/src/legacy/tool-ui/src/main/webapp/v4/widget/Revisions.js +0 -61
|
@@ -1,2427 +0,0 @@
|
|
|
1
|
-
import { announce } from '../../../dom/aria.ts'
|
|
2
|
-
import scrollIntoView from 'scroll-into-view'
|
|
3
|
-
import { v1 as uuidv1 } from 'uuid'
|
|
4
|
-
import create from './dom/create'
|
|
5
|
-
import find from './dom/find'
|
|
6
|
-
import findAll from './dom/findAll'
|
|
7
|
-
import insertBefore from './dom/insertBefore'
|
|
8
|
-
import insertFirst from './dom/insertFirst'
|
|
9
|
-
import insertLast from './dom/insertLast'
|
|
10
|
-
import onFind from './dom/onFind'
|
|
11
|
-
import onRemove from './dom/onRemove'
|
|
12
|
-
import Tether from './dom/Tether'
|
|
13
|
-
import debounce from './util/debounce'
|
|
14
|
-
import repaint from './util/repaint'
|
|
15
|
-
import Preview from './ViewPreview'
|
|
16
|
-
import PreviewOverlay from './PreviewOverlay'
|
|
17
|
-
import { toggleMenu, setupMenuForAria } from '../../../dom/popupMenu'
|
|
18
|
-
import onRTEReady from './dom/onRTEReady'
|
|
19
|
-
|
|
20
|
-
const tooltips = window.BRIGHTSPOT?.ui.tooltips
|
|
21
|
-
|
|
22
|
-
// Focus on the first input.
|
|
23
|
-
function focusByLabel(cig, selector) {
|
|
24
|
-
const id = cig.querySelector(selector)?.htmlFor
|
|
25
|
-
|
|
26
|
-
if (id) {
|
|
27
|
-
document.getElementById(id)?.focus()
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const previewOverlays = new Map()
|
|
32
|
-
let selectedViewport = 0
|
|
33
|
-
|
|
34
|
-
// Minimum container width (px) to show both preview and widget panels simultaneously
|
|
35
|
-
const DUAL_PANEL_MIN_WIDTH = 900
|
|
36
|
-
|
|
37
|
-
onFind(['.ContentEdit.is-new', '.StandardForm.is-new'], (form) => {
|
|
38
|
-
if (document.querySelector('.Admin-nav')) return
|
|
39
|
-
|
|
40
|
-
const cig = form.querySelector('.CIG:not(:empty)')
|
|
41
|
-
if (!cig) return
|
|
42
|
-
|
|
43
|
-
let prevTab
|
|
44
|
-
|
|
45
|
-
for (const row of cig.querySelectorAll(':scope > [data-tab]')) {
|
|
46
|
-
const tab = row.dataset.tab
|
|
47
|
-
|
|
48
|
-
if (!prevTab) {
|
|
49
|
-
prevTab = tab
|
|
50
|
-
} else if (prevTab !== tab) {
|
|
51
|
-
// If there are multiple tabs, focus on the first input of the first tab.
|
|
52
|
-
onFind(cig, ':scope > .TabBar', (tb) => {
|
|
53
|
-
focusByLabel(
|
|
54
|
-
cig,
|
|
55
|
-
`:scope > .CIG-row:not(.inputContainer-readOnly)[data-tab="${
|
|
56
|
-
Array.prototype.filter.call(
|
|
57
|
-
tb.querySelectorAll('button[data-tab]'),
|
|
58
|
-
(i) => !i.hidden,
|
|
59
|
-
)[0]?.dataset.tab
|
|
60
|
-
}"] > .CIG-label > label`,
|
|
61
|
-
)
|
|
62
|
-
})
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
focusByLabel(
|
|
68
|
-
cig,
|
|
69
|
-
':scope > .CIG-row:not(.inputContainer-readOnly) > .CIG-label > label',
|
|
70
|
-
)
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
// When editing existing content in popup, send focus to ContentEdit popup
|
|
74
|
-
onFind(
|
|
75
|
-
'.Popup[data-popup-source-class*="ContentSelector-edit"] button.Popup-heading',
|
|
76
|
-
(backButton) => {
|
|
77
|
-
backButton.focus()
|
|
78
|
-
},
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
// Move messages in top to main.
|
|
82
|
-
onFind('.ContentEdit-top .Message', (message) => {
|
|
83
|
-
const title = message
|
|
84
|
-
.closest('.ContentEdit')
|
|
85
|
-
.querySelector('.ContentEdit-main > .ContentEdit-title')
|
|
86
|
-
title.parentNode.insertBefore(message, title.nextSibling)
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
// Controls.
|
|
90
|
-
function appendControls(newList, oldList, tag) {
|
|
91
|
-
if (oldList) {
|
|
92
|
-
for (const item of findAll(oldList, tag)) {
|
|
93
|
-
newList.appendChild(tag === 'li' ? item : create('li', {}, item))
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
oldList.remove()
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
onFind('.ContentEdit', (edit) => {
|
|
101
|
-
const popup = edit.closest('.Popup-content')
|
|
102
|
-
if (popup) {
|
|
103
|
-
popup.classList.add('is-editing')
|
|
104
|
-
} else {
|
|
105
|
-
document.body.classList.add('is-editing')
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const top = find(edit, '.widget-publishing')
|
|
109
|
-
if (!top) return
|
|
110
|
-
|
|
111
|
-
const list = create('ul', {
|
|
112
|
-
className: 'ContentEdit-controlsList',
|
|
113
|
-
role: 'menu',
|
|
114
|
-
'aria-label': tooltips.actions?.contentEdit,
|
|
115
|
-
})
|
|
116
|
-
const onClassChange = (mutations) => {
|
|
117
|
-
mutations.forEach((mutation) => {
|
|
118
|
-
const target = mutation.target
|
|
119
|
-
const isLocked = target.classList.contains('is-locked')
|
|
120
|
-
target.querySelectorAll('[accesskey]').forEach((el) => {
|
|
121
|
-
isLocked
|
|
122
|
-
? el.setAttribute('disabled', '')
|
|
123
|
-
: el.removeAttribute('disabled')
|
|
124
|
-
})
|
|
125
|
-
})
|
|
126
|
-
}
|
|
127
|
-
const observer = new MutationObserver(onClassChange)
|
|
128
|
-
observer.observe(edit, { attributeFilter: ['class'] })
|
|
129
|
-
|
|
130
|
-
const contentEditBar = find(edit, '.ContentEdit-bar')
|
|
131
|
-
const publishingExtraLeft = find(edit, '.widget-publishingExtra-left')
|
|
132
|
-
const saveElement = find(publishingExtraLeft, [
|
|
133
|
-
'[name="action-draft"]',
|
|
134
|
-
'[name="action-newDraft"]',
|
|
135
|
-
])
|
|
136
|
-
|
|
137
|
-
const referenceNode =
|
|
138
|
-
find(contentEditBar, '.ContentEdit-workflow') ||
|
|
139
|
-
find(contentEditBar, '.ContentEdit-publish')
|
|
140
|
-
|
|
141
|
-
if (saveElement !== null) {
|
|
142
|
-
const saveClone = saveElement.cloneNode(true)
|
|
143
|
-
|
|
144
|
-
// If user sets a schedule but clicks Save then clear schedule date.
|
|
145
|
-
if (saveClone.name === 'action-draft') {
|
|
146
|
-
saveClone.addEventListener('click', () => {
|
|
147
|
-
const publishDateInput = edit.querySelector('input[name="publishDate"]')
|
|
148
|
-
if (publishDateInput) {
|
|
149
|
-
publishDateInput.value = ''
|
|
150
|
-
}
|
|
151
|
-
})
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (referenceNode) {
|
|
155
|
-
contentEditBar.insertBefore(saveClone, referenceNode)
|
|
156
|
-
} else {
|
|
157
|
-
contentEditBar.appendChild(saveClone)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
saveElement.closest('.ContentEdit').classList.contains('is-new') ||
|
|
162
|
-
saveElement.getAttribute('name') === 'action-draft'
|
|
163
|
-
) {
|
|
164
|
-
saveElement.parentNode.remove()
|
|
165
|
-
} else {
|
|
166
|
-
saveClone.style.display = 'none'
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
appendControls(list, find(edit, '.widget-contentCreate'), 'li')
|
|
170
|
-
appendControls(list, publishingExtraLeft, 'li')
|
|
171
|
-
appendControls(list, find(edit, '.widgetControls'), 'a')
|
|
172
|
-
appendControls(list, find(edit, '.widget-publishingExtra-right'), 'li')
|
|
173
|
-
appendControls(list, find(edit, '.widget-publishing > .widget-controls'), 'a')
|
|
174
|
-
|
|
175
|
-
const full = find(list, '.widgetControlsEditInFull')
|
|
176
|
-
if (full && !edit.closest('.Popup')) full.closest('li').remove()
|
|
177
|
-
|
|
178
|
-
const controls = create('div', {
|
|
179
|
-
className: 'ContentEdit-controls',
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
const toggle = create('button', {
|
|
183
|
-
className: 'ContentEdit-controlsToggle',
|
|
184
|
-
type: 'button',
|
|
185
|
-
title: tooltips.actions?.actions,
|
|
186
|
-
'aria-haspopup': 'menu',
|
|
187
|
-
'aria-expanded': 'false',
|
|
188
|
-
'aria-label': tooltips.actions?.contentEdit,
|
|
189
|
-
onclick: () => {
|
|
190
|
-
toggleMenu(list, toggle, controls)
|
|
191
|
-
},
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
setupMenuForAria(list, toggle)
|
|
195
|
-
|
|
196
|
-
controls.appendChild(toggle)
|
|
197
|
-
controls.appendChild(list)
|
|
198
|
-
controls.setAttribute('data-tether-anchor', '')
|
|
199
|
-
top.appendChild(controls)
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
onFind('.ContentEdit-controlsList .DraftAndReturnAction', (hiddenMenuItem) =>
|
|
203
|
-
hiddenMenuItem.setAttribute('aria-hidden', 'true'),
|
|
204
|
-
)
|
|
205
|
-
|
|
206
|
-
onFind('.ContentEdit-controlsList .NewDraftAndReturnAction', (hiddenMenuItem) =>
|
|
207
|
-
hiddenMenuItem.setAttribute('aria-hidden', 'true'),
|
|
208
|
-
)
|
|
209
|
-
|
|
210
|
-
// Restore.
|
|
211
|
-
onFind('.ContentEdit-restore', (restore) => {
|
|
212
|
-
const controls = restore.closest('.ContentEdit-controls')
|
|
213
|
-
controls.parentNode.insertBefore(restore, controls)
|
|
214
|
-
|
|
215
|
-
const toggle = create(
|
|
216
|
-
'div',
|
|
217
|
-
{
|
|
218
|
-
className: 'ContentEdit-restoreToggle',
|
|
219
|
-
onclick: () => {
|
|
220
|
-
Tether.toggle(toggle, restore, () =>
|
|
221
|
-
restore.classList.toggle(
|
|
222
|
-
'is-open',
|
|
223
|
-
toggle.classList.toggle('is-open'),
|
|
224
|
-
),
|
|
225
|
-
)
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
restore.getAttribute('data-restore-label') || 'restore',
|
|
229
|
-
)
|
|
230
|
-
restore.parentNode.insertBefore(toggle, restore)
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
// Workflow.
|
|
234
|
-
onFind('.ContentEdit-workflow', (workflow) => {
|
|
235
|
-
const dialogContainer = workflow.closest('btu-dialog')
|
|
236
|
-
|
|
237
|
-
workflow.setAttribute('hidden', '')
|
|
238
|
-
|
|
239
|
-
const triggerCloseMenu = (event) => {
|
|
240
|
-
if (event.key === 'Escape') {
|
|
241
|
-
// When hosted by <dialog>, explicity call close().
|
|
242
|
-
// We can't rely on the jQuery popup close logic since workflow doesn't use it.
|
|
243
|
-
dialogContainer?.close(event)
|
|
244
|
-
|
|
245
|
-
toggle.click()
|
|
246
|
-
toggle.focus()
|
|
247
|
-
} else if (
|
|
248
|
-
event.key === 'Tab' &&
|
|
249
|
-
!document.activeElement.closest('.ContentEdit-workflow.is-open') &&
|
|
250
|
-
!document.activeElement.closest('.Popup.is-calendar') &&
|
|
251
|
-
!document.activeElement.matches('.Page') &&
|
|
252
|
-
document.activeElement !== toggle
|
|
253
|
-
) {
|
|
254
|
-
toggle.click()
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
const popupClose = (event) => {
|
|
259
|
-
// in v5, the workflow popup logic is handled in dialog.ts
|
|
260
|
-
if (window.BRIGHTSPOT?.ui.cms.enableV5UI) return
|
|
261
|
-
|
|
262
|
-
const popup = event.target.closest('.Popup')
|
|
263
|
-
const proseMirror = find(
|
|
264
|
-
document,
|
|
265
|
-
'.ProseMirror-fullscreen-container:not(.hide)',
|
|
266
|
-
)
|
|
267
|
-
|
|
268
|
-
if (
|
|
269
|
-
(popup && !event.target.matches('.Popup-close')) ||
|
|
270
|
-
(proseMirror && event.target.closest('.ProseMirrorToolbar-action')) ||
|
|
271
|
-
event.target.closest('.ProseMirror-fullscreen-container') ||
|
|
272
|
-
event.target.matches('.rte2-toolbar-fullscreen')
|
|
273
|
-
) {
|
|
274
|
-
toggle.click()
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const first = find(
|
|
279
|
-
workflow,
|
|
280
|
-
'.ContentEdit-workflowWrapper > .ContentEdit-workflowBody',
|
|
281
|
-
)
|
|
282
|
-
let height = 0
|
|
283
|
-
const publish = find(workflow.parentNode, '.ContentEdit-publish')
|
|
284
|
-
const toggle = create(
|
|
285
|
-
'button',
|
|
286
|
-
{
|
|
287
|
-
'aria-expanded': false,
|
|
288
|
-
'aria-haspopup': true,
|
|
289
|
-
className: 'ContentEdit-workflowToggle',
|
|
290
|
-
onclick: () => {
|
|
291
|
-
Tether.toggle(toggle, workflow, () => {
|
|
292
|
-
const isOpen = toggle.classList.toggle('is-open')
|
|
293
|
-
const popup = find(document, '.Popup')
|
|
294
|
-
const proseMirror = find(
|
|
295
|
-
document,
|
|
296
|
-
'.ProseMirror-fullscreen-container:not(.hide)',
|
|
297
|
-
)
|
|
298
|
-
|
|
299
|
-
if (isOpen) {
|
|
300
|
-
workflow.removeAttribute('hidden')
|
|
301
|
-
window.addEventListener('keyup', triggerCloseMenu)
|
|
302
|
-
window.addEventListener('click', popupClose)
|
|
303
|
-
} else {
|
|
304
|
-
window.removeEventListener('keyup', triggerCloseMenu)
|
|
305
|
-
if (!popup && !proseMirror) {
|
|
306
|
-
window.removeEventListener('click', popupClose)
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
toggle.setAttribute('aria-expanded', isOpen ? 'true' : 'false')
|
|
311
|
-
return workflow.classList.toggle('is-open', isOpen)
|
|
312
|
-
})
|
|
313
|
-
|
|
314
|
-
if (publish) {
|
|
315
|
-
for (const child of findAll(
|
|
316
|
-
workflow,
|
|
317
|
-
'.ContentEdit-workflowWrapper',
|
|
318
|
-
)) {
|
|
319
|
-
child.classList.toggle(
|
|
320
|
-
'is-active',
|
|
321
|
-
child.getAttribute('data-name') === 'workflow',
|
|
322
|
-
)
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
},
|
|
326
|
-
type: 'button',
|
|
327
|
-
},
|
|
328
|
-
workflow.getAttribute('data-workflow-label') || 'Workflow',
|
|
329
|
-
)
|
|
330
|
-
workflow.parentNode.insertBefore(toggle, workflow)
|
|
331
|
-
workflow.closest('.ContentEdit').classList.add('is-workflow')
|
|
332
|
-
|
|
333
|
-
const buttons = workflow.querySelectorAll(
|
|
334
|
-
'.ContentEdit-workflowActions button[name="action-workflow"]',
|
|
335
|
-
)
|
|
336
|
-
const commentRequiredAttr = workflow.querySelector(
|
|
337
|
-
'.ContentEdit-workflowActions button[data-workflow-comment-required]',
|
|
338
|
-
)
|
|
339
|
-
|
|
340
|
-
if (commentRequiredAttr) {
|
|
341
|
-
onFind(
|
|
342
|
-
'.CIG-row[data-field-name="comment"] > .AutoExpand > textarea',
|
|
343
|
-
(textarea) => {
|
|
344
|
-
textarea.addEventListener('input', () => {
|
|
345
|
-
buttons.forEach((button) => {
|
|
346
|
-
if (button.disabled) {
|
|
347
|
-
if (textarea.value.trim() !== '') {
|
|
348
|
-
button.removeAttribute('disabled')
|
|
349
|
-
} else {
|
|
350
|
-
button.setAttribute('disabled', 'true')
|
|
351
|
-
}
|
|
352
|
-
} else if (textarea.value.trim() === '') {
|
|
353
|
-
button.setAttribute('disabled', 'true')
|
|
354
|
-
}
|
|
355
|
-
})
|
|
356
|
-
})
|
|
357
|
-
},
|
|
358
|
-
)
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
if (publish) {
|
|
362
|
-
find(
|
|
363
|
-
workflow,
|
|
364
|
-
'.ContentEdit-workflowWrapper[data-name="publishOverride"] > .ContentEdit-workflowBody',
|
|
365
|
-
).appendChild(publish)
|
|
366
|
-
workflow.classList.add('is-publishOverride')
|
|
367
|
-
|
|
368
|
-
for (const link of findAll(
|
|
369
|
-
workflow,
|
|
370
|
-
'.ContentEdit-workflowWrapper > .ContentEdit-workflowLink',
|
|
371
|
-
)) {
|
|
372
|
-
link.addEventListener('click', (event) => {
|
|
373
|
-
event.preventDefault()
|
|
374
|
-
event.stopPropagation()
|
|
375
|
-
if (link.parentNode.getAttribute('data-name') === 'workflow') {
|
|
376
|
-
height = first.offsetHeight + '%'
|
|
377
|
-
}
|
|
378
|
-
for (const child of findAll(workflow, '.ContentEdit-workflowWrapper')) {
|
|
379
|
-
child.classList.toggle(
|
|
380
|
-
'is-active',
|
|
381
|
-
child.getAttribute('data-name') ===
|
|
382
|
-
link.getAttribute('data-action'),
|
|
383
|
-
)
|
|
384
|
-
if (child.classList.contains('is-active')) {
|
|
385
|
-
child.querySelector('.DateTimeInput, .AutoExpand textarea')?.focus()
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
find(
|
|
389
|
-
workflow,
|
|
390
|
-
'.ContentEdit-workflowWrapper:not([data-name="workflow"]) > .ContentEdit-workflowBody',
|
|
391
|
-
).style.height = height
|
|
392
|
-
})
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
})
|
|
396
|
-
|
|
397
|
-
// Change publish button state when scheduling.
|
|
398
|
-
onFind('.ContentEdit-publish .ContentEdit-publishButton', (button) => {
|
|
399
|
-
const publish = button.closest('.ContentEdit-publish')
|
|
400
|
-
const pdd = publish.querySelector('input[name="publishDate.date"]')
|
|
401
|
-
const pdt = publish.querySelector('input[name="publishDate.time"]')
|
|
402
|
-
|
|
403
|
-
if (!pdd || !pdt) {
|
|
404
|
-
return
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
const pdAnchor = publish.querySelector('.DateTimeInput')
|
|
408
|
-
const overrideMessage = find(
|
|
409
|
-
button.parentNode.parentNode,
|
|
410
|
-
'.ContentEdit-overrideMessage',
|
|
411
|
-
)
|
|
412
|
-
|
|
413
|
-
const oldButtonText = button.textContent
|
|
414
|
-
|
|
415
|
-
function onChange() {
|
|
416
|
-
if (pdd.value && pdt.value) {
|
|
417
|
-
publish.classList.add('is-scheduling')
|
|
418
|
-
button.innerText = button.getAttribute('data-schedule-label')
|
|
419
|
-
pdAnchor.classList.remove('is-empty')
|
|
420
|
-
} else {
|
|
421
|
-
publish.classList.remove('is-scheduling')
|
|
422
|
-
button.innerText = oldButtonText
|
|
423
|
-
pdAnchor.classList.add('is-empty')
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
if (overrideMessage) {
|
|
427
|
-
overrideMessage.innerHTML = publish.classList.contains('is-scheduling')
|
|
428
|
-
? overrideMessage.getAttribute('data-schedule-message')
|
|
429
|
-
: overrideMessage.getAttribute('data-publish-message')
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
onChange()
|
|
434
|
-
pdd.addEventListener('change', onChange)
|
|
435
|
-
pdt.addEventListener('change', onChange)
|
|
436
|
-
|
|
437
|
-
const ns = publish.querySelector('select[name="newSchedule"]')
|
|
438
|
-
|
|
439
|
-
if (ns) {
|
|
440
|
-
ns.addEventListener('change', onChange)
|
|
441
|
-
}
|
|
442
|
-
})
|
|
443
|
-
|
|
444
|
-
// Change workflow transition button state when scheduling.
|
|
445
|
-
onFind('.ContentEdit-workflowActions .ContentEdit-publishButton', (button) => {
|
|
446
|
-
const workflowActions = button.closest('.ContentEdit-workflowActions')
|
|
447
|
-
const pdd = workflowActions.querySelector(
|
|
448
|
-
'input.ContentEdit-workflowScheduleDate',
|
|
449
|
-
)
|
|
450
|
-
const pdt = workflowActions.querySelector(
|
|
451
|
-
'input.ContentEdit-workflowScheduleTime',
|
|
452
|
-
)
|
|
453
|
-
|
|
454
|
-
if (!pdd || !pdt) {
|
|
455
|
-
return
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
const pdAnchor = workflowActions.querySelector(
|
|
459
|
-
'.ContentEdit-workflowScheduleLink',
|
|
460
|
-
)
|
|
461
|
-
const oldButtonText = button.textContent
|
|
462
|
-
|
|
463
|
-
function onChange() {
|
|
464
|
-
if (pdd.value && pdt.value) {
|
|
465
|
-
workflowActions.classList.add('is-scheduling')
|
|
466
|
-
button.innerText = button.getAttribute('data-schedule-label')
|
|
467
|
-
if (pdAnchor) {
|
|
468
|
-
pdAnchor.classList.remove('is-empty')
|
|
469
|
-
}
|
|
470
|
-
} else {
|
|
471
|
-
workflowActions.classList.remove('is-scheduling')
|
|
472
|
-
button.innerText = oldButtonText
|
|
473
|
-
if (pdAnchor) {
|
|
474
|
-
pdAnchor.classList.add('is-empty')
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
onChange()
|
|
480
|
-
pdd.addEventListener('change', onChange)
|
|
481
|
-
pdt.addEventListener('change', onChange)
|
|
482
|
-
})
|
|
483
|
-
|
|
484
|
-
const ls = window.localStorage
|
|
485
|
-
|
|
486
|
-
// Preview.
|
|
487
|
-
let previewFrameIndex = 0
|
|
488
|
-
|
|
489
|
-
//New Preview System
|
|
490
|
-
onFind('.ContentEdit', (edit) => {
|
|
491
|
-
const top = edit.querySelector('.ContentEdit-top')
|
|
492
|
-
if (!top) return
|
|
493
|
-
const contentId = edit.getAttribute('data-object-id')
|
|
494
|
-
const container = edit.closest('.Page-content, .Popup')
|
|
495
|
-
if (!container) return
|
|
496
|
-
const contentEditPreview = container.querySelector('.ContentEdit-preview')
|
|
497
|
-
if (!contentEditPreview) return
|
|
498
|
-
contentEditPreview.setAttribute('inert', '')
|
|
499
|
-
const previewFrame = contentEditPreview.querySelector('.PreviewFrame')
|
|
500
|
-
if (!previewFrame) return
|
|
501
|
-
const previewTypeFrame = contentEditPreview.querySelector(
|
|
502
|
-
'.PreviewFrame-typeFrame',
|
|
503
|
-
)
|
|
504
|
-
if (!previewTypeFrame) return
|
|
505
|
-
|
|
506
|
-
window.addEventListener('viewport-device-changed', (evt) => {
|
|
507
|
-
window.requestAnimationFrame(() => {
|
|
508
|
-
getPreviewFrame(contentId)?.contentWindow?.postMessage(
|
|
509
|
-
{
|
|
510
|
-
type: 'BSP.ContentEdit.ViewportDeviceChanged',
|
|
511
|
-
},
|
|
512
|
-
'*',
|
|
513
|
-
)
|
|
514
|
-
})
|
|
515
|
-
})
|
|
516
|
-
|
|
517
|
-
const page = edit.closest('.Page.is-previewToEdit')
|
|
518
|
-
if (page) {
|
|
519
|
-
container.setAttribute('data-preview-menu', false)
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
// ViewPreview.
|
|
523
|
-
const resizePreview = repaint(() => {
|
|
524
|
-
const previewTypeDisplay = previewTypeFrame.querySelector(
|
|
525
|
-
'.PreviewFrame-typeDisplay',
|
|
526
|
-
)
|
|
527
|
-
if (previewTypeDisplay) {
|
|
528
|
-
const frames = previewTypeDisplay.querySelectorAll('iframe')
|
|
529
|
-
|
|
530
|
-
if (frames.length < 1) {
|
|
531
|
-
return
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
const frame = frames[0]
|
|
535
|
-
const widthSelect = previewFrame.querySelector('.deviceWidthSelect')
|
|
536
|
-
let frameWidth = frame.getBoundingClientRect().width
|
|
537
|
-
|
|
538
|
-
frame.style.transform = ''
|
|
539
|
-
frame.style.width = ''
|
|
540
|
-
|
|
541
|
-
if (widthSelect) {
|
|
542
|
-
if (container) {
|
|
543
|
-
container.style.removeProperty('--ContentEdit-previewWidth')
|
|
544
|
-
|
|
545
|
-
const option = widthSelect.options[widthSelect.selectedIndex]
|
|
546
|
-
|
|
547
|
-
if (option) {
|
|
548
|
-
frameWidth = parseInt(option.getAttribute('data-device-width'), 10)
|
|
549
|
-
frame.style.width = `${frameWidth}px`
|
|
550
|
-
|
|
551
|
-
if (frameWidth < previewFrame.getBoundingClientRect().width) {
|
|
552
|
-
container.style.setProperty(
|
|
553
|
-
'--ContentEdit-previewWidth',
|
|
554
|
-
`${frameWidth}px`,
|
|
555
|
-
)
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
} else {
|
|
560
|
-
if (container) {
|
|
561
|
-
//No width control, so reset back to the default
|
|
562
|
-
container.style.removeProperty('--ContentEdit-previewWidth')
|
|
563
|
-
frame.style.width = ``
|
|
564
|
-
frameWidth = 1920
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
selectedViewport = frameWidth
|
|
568
|
-
// Do calculations after styles have been set to get accurate measurement.
|
|
569
|
-
const scale = previewTypeDisplay.clientWidth / frameWidth
|
|
570
|
-
frame.style.transform = `scale(${scale})`
|
|
571
|
-
frame.setAttribute('previewScale', scale)
|
|
572
|
-
frame.style.setProperty('--PreviewFrame-scale', scale)
|
|
573
|
-
|
|
574
|
-
PreviewOverlay.getOverlayWindow(
|
|
575
|
-
previewTypeFrame
|
|
576
|
-
.querySelector(':scope iframe:first-of-type')
|
|
577
|
-
.getAttribute('data-container-id'),
|
|
578
|
-
)?.dispatchEvent(new Event('resize'))
|
|
579
|
-
}
|
|
580
|
-
})
|
|
581
|
-
let preview = new Preview(previewFrame, resizePreview)
|
|
582
|
-
|
|
583
|
-
const deletePreview = function () {
|
|
584
|
-
setTimeout(function () {
|
|
585
|
-
preview.deletePreview()
|
|
586
|
-
}, 500)
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
const addDefaultEvents = function () {
|
|
590
|
-
window.addEventListener('resize', resizePreview)
|
|
591
|
-
edit.addEventListener('brightspot-content-state-change', () =>
|
|
592
|
-
preview.updatePreview(),
|
|
593
|
-
)
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
const removeDefaultEvents = function () {
|
|
597
|
-
window.removeEventListener('resize', resizePreview)
|
|
598
|
-
edit.removeEventListener('brightspot-content-state-change', () =>
|
|
599
|
-
preview.updatePreview(),
|
|
600
|
-
)
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
window.ContentEditFields = new Map()
|
|
604
|
-
|
|
605
|
-
const rootContentEdit = container.querySelector(
|
|
606
|
-
'.content-edit > .ContentEdit .ContentEdit-left',
|
|
607
|
-
)
|
|
608
|
-
// Find all the form inputs that may be used in Preview.
|
|
609
|
-
if (rootContentEdit) {
|
|
610
|
-
onFind(
|
|
611
|
-
rootContentEdit,
|
|
612
|
-
`.inputContainer[data-tab="Main"]:not([type="hidden"])`,
|
|
613
|
-
(inputElement) => {
|
|
614
|
-
const id = inputElement.dataset.name
|
|
615
|
-
const removeInvisible =
|
|
616
|
-
inputElement.closest('.TC-unselected') &&
|
|
617
|
-
window.ContentEditFields.has(id)
|
|
618
|
-
if (removeInvisible) {
|
|
619
|
-
window.ContentEditFields.delete(id)
|
|
620
|
-
} else {
|
|
621
|
-
window.ContentEditFields.set(id, inputElement)
|
|
622
|
-
}
|
|
623
|
-
},
|
|
624
|
-
)
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
onFind(edit, ':scope .ContentEdit-previewButton', (previewButton) => {
|
|
628
|
-
previewButton.type = 'button'
|
|
629
|
-
previewButton.ariaLabel = container.classList.contains('is-previewing')
|
|
630
|
-
? tooltips.preview.close
|
|
631
|
-
: tooltips.preview.open
|
|
632
|
-
previewButton.title = previewButton.ariaLabel
|
|
633
|
-
const toolbar = previewButton.closest('.ContentEdit-toolbar')
|
|
634
|
-
previewButton.onclick = function () {
|
|
635
|
-
if (container.classList.toggle('is-previewing')) {
|
|
636
|
-
if (container.classList.contains('Popup')) {
|
|
637
|
-
container
|
|
638
|
-
.querySelector(':scope > .Popup-content')
|
|
639
|
-
?.classList.add('is-previewing')
|
|
640
|
-
}
|
|
641
|
-
preview.isVisible = true
|
|
642
|
-
contentEditPreview.removeAttribute('inert')
|
|
643
|
-
previewButton.title = tooltips.preview.close
|
|
644
|
-
previewButton.ariaLabel = tooltips.preview.close
|
|
645
|
-
announce(tooltips.preview.opened)
|
|
646
|
-
ls.removeItem('BSP.ContentEdit.previewClosed')
|
|
647
|
-
preview.reloadPreview()
|
|
648
|
-
addDefaultEvents()
|
|
649
|
-
const activeTab = toolbar.querySelector(
|
|
650
|
-
'button.is-active[data-right-tab]',
|
|
651
|
-
)
|
|
652
|
-
const shouldClosePanel = window.BRIGHTSPOT?.ui?.cms?.enableV5UI
|
|
653
|
-
? container.offsetWidth < DUAL_PANEL_MIN_WIDTH
|
|
654
|
-
: true
|
|
655
|
-
if (shouldClosePanel && activeTab) {
|
|
656
|
-
const panel = edit.querySelector(
|
|
657
|
-
`.ContentEdit-right[data-right-tab="${activeTab.dataset.iconButtonName}"]`,
|
|
658
|
-
)
|
|
659
|
-
togglePanel(activeTab, panel, {
|
|
660
|
-
container: container,
|
|
661
|
-
updateStorage: true,
|
|
662
|
-
})
|
|
663
|
-
}
|
|
664
|
-
} else {
|
|
665
|
-
if (container.classList.contains('Popup')) {
|
|
666
|
-
container
|
|
667
|
-
.querySelector(':scope > .Popup-content')
|
|
668
|
-
?.classList.remove('is-previewing')
|
|
669
|
-
}
|
|
670
|
-
preview.isVisible = false
|
|
671
|
-
contentEditPreview.setAttribute('inert', '')
|
|
672
|
-
previewButton.title = tooltips.preview.open
|
|
673
|
-
previewButton.ariaLabel = tooltips.preview.open
|
|
674
|
-
announce(tooltips.preview.closed)
|
|
675
|
-
ls.setItem('BSP.ContentEdit.previewClosed', 1)
|
|
676
|
-
deletePreview()
|
|
677
|
-
removeDefaultEvents()
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
if (
|
|
682
|
-
window.innerWidth >= 768 &&
|
|
683
|
-
!contentEditPreview.classList.contains('is-previewClosedByDefault') &&
|
|
684
|
-
!ls.getItem('BSP.ContentEdit.previewClosed') &&
|
|
685
|
-
!container.classList.contains('is-previewing')
|
|
686
|
-
) {
|
|
687
|
-
previewButton.title = tooltips.preview.close
|
|
688
|
-
previewButton.onclick()
|
|
689
|
-
} else if (container.classList.contains('is-previewing')) {
|
|
690
|
-
/* Occasionally the local storage setting for previewClosed is out of sync with actual state.
|
|
691
|
-
In this case don't click the preview button but still update the preview and add the default events.
|
|
692
|
-
*/
|
|
693
|
-
if (!preview.isVisible) preview.isVisible = true // ensure visibility flag is set for preview
|
|
694
|
-
preview.updatePreview()
|
|
695
|
-
addDefaultEvents()
|
|
696
|
-
contentEditPreview.removeAttribute('inert')
|
|
697
|
-
}
|
|
698
|
-
})
|
|
699
|
-
})
|
|
700
|
-
|
|
701
|
-
//Old Preview System
|
|
702
|
-
onFind('.ContentEdit', (edit) => {
|
|
703
|
-
const top = edit.querySelector('.ContentEdit-top')
|
|
704
|
-
if (!top) return
|
|
705
|
-
const container = edit.closest('.Page-content, .Popup')
|
|
706
|
-
if (!container) return
|
|
707
|
-
const preview = container.querySelector('.ContentEdit-preview')
|
|
708
|
-
if (!preview) return
|
|
709
|
-
let previewControls = preview.querySelector('.ContentEdit-previewControls')
|
|
710
|
-
if (!previewControls) return
|
|
711
|
-
let previewForm = previewControls.querySelector('form[id]')
|
|
712
|
-
if (!previewForm) return
|
|
713
|
-
let previewInput = previewForm.querySelector('input[name="_previewObject"]')
|
|
714
|
-
const display = preview.querySelector('.ContentEdit-previewDisplay')
|
|
715
|
-
if (!display) return
|
|
716
|
-
const previewTypes = preview.querySelector('.ContentEdit-previewTypes')
|
|
717
|
-
let shouldRefresh = true
|
|
718
|
-
const mainObjectId = edit.getAttribute('data-object-id')
|
|
719
|
-
|
|
720
|
-
const page = edit.closest('.Page.is-previewToEdit')
|
|
721
|
-
if (page) {
|
|
722
|
-
container.setAttribute('data-preview-menu', false)
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
// Move the ComboInputs that make up the secondary form UI into a new row container.
|
|
726
|
-
onFind('.ContentEdit-preview', (frame) => {
|
|
727
|
-
// Query for two different selectors since the preview controls could be loaded initially, or async when previewTypes are present.
|
|
728
|
-
onFind(
|
|
729
|
-
frame,
|
|
730
|
-
[
|
|
731
|
-
'.widget-preview > .ContentEdit-previewControls',
|
|
732
|
-
'.frame.loaded[name^="previewControls"] .ContentEdit-previewControls',
|
|
733
|
-
],
|
|
734
|
-
(container) => {
|
|
735
|
-
const target = container.querySelector('form:last-of-type')
|
|
736
|
-
if (target) {
|
|
737
|
-
const secondary = create('div', {
|
|
738
|
-
class: 'ContentEdit-secondaryPreviewControls',
|
|
739
|
-
})
|
|
740
|
-
onFind(
|
|
741
|
-
target,
|
|
742
|
-
':scope select:not(.deviceWidthSelect) + .ComboInput',
|
|
743
|
-
(combo) => {
|
|
744
|
-
secondary.appendChild(combo)
|
|
745
|
-
},
|
|
746
|
-
)
|
|
747
|
-
target.appendChild(secondary)
|
|
748
|
-
}
|
|
749
|
-
},
|
|
750
|
-
)
|
|
751
|
-
})
|
|
752
|
-
|
|
753
|
-
// Make sure that the preview form data is always up to date.
|
|
754
|
-
edit.addEventListener('brightspot-content-state-change', (event) => {
|
|
755
|
-
for (const input of findAll(
|
|
756
|
-
previewControls,
|
|
757
|
-
'input[name="_previewObject"]',
|
|
758
|
-
)) {
|
|
759
|
-
input.value = event.detail
|
|
760
|
-
}
|
|
761
|
-
})
|
|
762
|
-
|
|
763
|
-
// Add the preview link.
|
|
764
|
-
const previewButton = document.createElement('A')
|
|
765
|
-
previewButton.className = 'ContentEdit-previewButton'
|
|
766
|
-
previewButton.href = '#'
|
|
767
|
-
|
|
768
|
-
const previewButtonWrapper = create(
|
|
769
|
-
'div',
|
|
770
|
-
{ className: 'ContentEdit-previewButtonWrapper' },
|
|
771
|
-
[
|
|
772
|
-
create('div', { className: 'ContentEdit-previewButtonCircle' }),
|
|
773
|
-
previewButton,
|
|
774
|
-
],
|
|
775
|
-
)
|
|
776
|
-
|
|
777
|
-
const resizePreview = repaint(() => {
|
|
778
|
-
const frames = display.querySelectorAll('iframe')
|
|
779
|
-
|
|
780
|
-
if (frames.length < 1) {
|
|
781
|
-
return
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
const frame = frames[0]
|
|
785
|
-
const widthSelect = document.querySelector('.deviceWidthSelect')
|
|
786
|
-
let frameWidth = frame.getBoundingClientRect().width
|
|
787
|
-
|
|
788
|
-
frame.style.transform = ''
|
|
789
|
-
frame.style.width = ''
|
|
790
|
-
container.style.removeProperty('--ContentEdit-previewWidth')
|
|
791
|
-
|
|
792
|
-
if (widthSelect) {
|
|
793
|
-
const option = widthSelect.options[widthSelect.selectedIndex]
|
|
794
|
-
|
|
795
|
-
if (option) {
|
|
796
|
-
frameWidth = parseInt(option.getAttribute('data-device-width'), 10)
|
|
797
|
-
frame.style.width = `${frameWidth}px`
|
|
798
|
-
|
|
799
|
-
if (frameWidth < preview.getBoundingClientRect().width) {
|
|
800
|
-
container.style.setProperty(
|
|
801
|
-
'--ContentEdit-previewWidth',
|
|
802
|
-
`${frameWidth}px`,
|
|
803
|
-
)
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
selectedViewport = frameWidth
|
|
808
|
-
|
|
809
|
-
// Do calculations after styles have been set to get accurate measurement.
|
|
810
|
-
frame.style.transform = `scale(${display.clientWidth / frameWidth})`
|
|
811
|
-
})
|
|
812
|
-
|
|
813
|
-
window.ContentEditFields = new Map()
|
|
814
|
-
|
|
815
|
-
const rootContentEdit = container.querySelector(
|
|
816
|
-
'.content-edit > .ContentEdit .ContentEdit-left',
|
|
817
|
-
)
|
|
818
|
-
// Find all the form inputs that may be used in Preview.
|
|
819
|
-
if (rootContentEdit) {
|
|
820
|
-
onFind(
|
|
821
|
-
rootContentEdit,
|
|
822
|
-
`.inputContainer[data-tab="Main"]:not([type="hidden"])`,
|
|
823
|
-
(inputElement) => {
|
|
824
|
-
const id = inputElement.dataset.name
|
|
825
|
-
const removeInvisible =
|
|
826
|
-
inputElement.closest('.TC-unselected') &&
|
|
827
|
-
window.ContentEditFields.has(id)
|
|
828
|
-
if (removeInvisible) {
|
|
829
|
-
window.ContentEditFields.delete(id)
|
|
830
|
-
} else {
|
|
831
|
-
window.ContentEditFields.set(id, inputElement)
|
|
832
|
-
}
|
|
833
|
-
},
|
|
834
|
-
)
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
const updatePreview = debounce(1000, () => {
|
|
838
|
-
if (previewInput && previewInput.value === '') {
|
|
839
|
-
return
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
const frame = document.createElement('IFRAME')
|
|
843
|
-
|
|
844
|
-
frame.name = 'ContentEdit-previewFrame' + previewFrameIndex++
|
|
845
|
-
display.insertBefore(frame, display.firstChild)
|
|
846
|
-
frame.setAttribute('data-container-id', mainObjectId)
|
|
847
|
-
|
|
848
|
-
const popup = frame.closest('.Popup')
|
|
849
|
-
const toggleAnimation = (force = null) => {
|
|
850
|
-
const root = popup ?? document
|
|
851
|
-
root
|
|
852
|
-
.querySelector('.ContentEdit-previewButtonWrapper')
|
|
853
|
-
?.classList.toggle('is-animating', force)
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
toggleAnimation(true)
|
|
857
|
-
|
|
858
|
-
resizePreview()
|
|
859
|
-
|
|
860
|
-
frame.onload = function () {
|
|
861
|
-
const nextFrames = []
|
|
862
|
-
|
|
863
|
-
for (let f = frame; (f = f.nextElementSibling); ) {
|
|
864
|
-
if (
|
|
865
|
-
f.tagName === 'IFRAME' &&
|
|
866
|
-
!f.classList.contains('Preview-overlayFrame')
|
|
867
|
-
) {
|
|
868
|
-
nextFrames.push(f)
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
const p = frame.parentNode
|
|
873
|
-
nextFrames.forEach((f) => p.removeChild(f))
|
|
874
|
-
|
|
875
|
-
toggleAnimation(false)
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
onRemove(frame, () => toggleAnimation(false))
|
|
879
|
-
|
|
880
|
-
previewForm.target = frame.name
|
|
881
|
-
previewForm.submit()
|
|
882
|
-
})
|
|
883
|
-
|
|
884
|
-
const deletePreview = function () {
|
|
885
|
-
setTimeout(function () {
|
|
886
|
-
let previewIframes = display.querySelectorAll(':scope > iframe')
|
|
887
|
-
previewIframes.forEach((iframe) => iframe.remove())
|
|
888
|
-
}, 500)
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
const addDefaultEvents = function () {
|
|
892
|
-
window.addEventListener('resize', resizePreview)
|
|
893
|
-
edit.addEventListener('brightspot-content-state-change', updatePreview)
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
const removeDefaultEvents = function () {
|
|
897
|
-
window.removeEventListener('resize', resizePreview)
|
|
898
|
-
edit.removeEventListener('brightspot-content-state-change', updatePreview)
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
if (previewTypes) {
|
|
902
|
-
onFind('.ContentEdit-previewTypesForm', (previewTypesForm) => {
|
|
903
|
-
const selection = previewTypesForm.querySelector(
|
|
904
|
-
'select[name="previewType"]',
|
|
905
|
-
)
|
|
906
|
-
shouldRefresh =
|
|
907
|
-
selection.selectedOptions[0].getAttribute('data-refresh') === 'true'
|
|
908
|
-
|
|
909
|
-
selection.onchange = function () {
|
|
910
|
-
display.innerHTML = ''
|
|
911
|
-
shouldRefresh =
|
|
912
|
-
selection.selectedOptions[0].getAttribute('data-refresh') === 'true'
|
|
913
|
-
updatePreview()
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
const previewTypeFrame = previewTypes.querySelector(
|
|
917
|
-
'div[name^="previewControls"]',
|
|
918
|
-
)
|
|
919
|
-
previewTypeFrame.onload = function () {
|
|
920
|
-
const previousInputValue = previewInput?.value
|
|
921
|
-
|
|
922
|
-
// Override local variable values
|
|
923
|
-
previewControls = previewTypeFrame.querySelector(
|
|
924
|
-
'.ContentEdit-previewControls',
|
|
925
|
-
)
|
|
926
|
-
previewForm = previewControls.querySelector('form[id]')
|
|
927
|
-
previewInput = previewForm.querySelector('input[name="_previewObject"]')
|
|
928
|
-
|
|
929
|
-
if (previewInput && previewInput.value === '') {
|
|
930
|
-
previewInput.value = previousInputValue
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
if (
|
|
934
|
-
container.classList.contains('is-previewing') &&
|
|
935
|
-
(shouldRefresh ||
|
|
936
|
-
selection.options[selection.selectedIndex].getAttribute(
|
|
937
|
-
'data-refresh',
|
|
938
|
-
) === 'true')
|
|
939
|
-
) {
|
|
940
|
-
updatePreview()
|
|
941
|
-
addDefaultEvents()
|
|
942
|
-
} else {
|
|
943
|
-
removeDefaultEvents()
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
})
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
previewButton.onclick = function () {
|
|
950
|
-
if (container.classList.toggle('is-previewing')) {
|
|
951
|
-
ls.removeItem('BSP.ContentEdit.previewClosed')
|
|
952
|
-
ls.removeItem('BSP.ContentEdit.rightPanel')
|
|
953
|
-
if (!window.BRIGHTSPOT?.ui?.cms?.enableV5UI) {
|
|
954
|
-
container.style.setProperty('--ContentEdit-rightWidth', '0px')
|
|
955
|
-
}
|
|
956
|
-
preview.removeAttribute('inert')
|
|
957
|
-
if (shouldRefresh) {
|
|
958
|
-
updatePreview()
|
|
959
|
-
addDefaultEvents()
|
|
960
|
-
}
|
|
961
|
-
} else {
|
|
962
|
-
ls.setItem('BSP.ContentEdit.previewClosed', 1)
|
|
963
|
-
preview.setAttribute('inert', '')
|
|
964
|
-
if (shouldRefresh) {
|
|
965
|
-
removeDefaultEvents()
|
|
966
|
-
deletePreview()
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
return false
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
top.insertBefore(previewButtonWrapper, top.firstChild)
|
|
974
|
-
|
|
975
|
-
if (
|
|
976
|
-
window.innerWidth >= 768 &&
|
|
977
|
-
!preview.classList.contains('is-previewClosedByDefault') &&
|
|
978
|
-
!ls.getItem('BSP.ContentEdit.previewClosed')
|
|
979
|
-
) {
|
|
980
|
-
previewButton.onclick()
|
|
981
|
-
}
|
|
982
|
-
})
|
|
983
|
-
|
|
984
|
-
// Display the current overlay in the title and allow it to be changed.
|
|
985
|
-
onFind('.ContentEdit-title', (title) => {
|
|
986
|
-
const form = title.closest('form')
|
|
987
|
-
|
|
988
|
-
if (!form) return
|
|
989
|
-
|
|
990
|
-
// The title is reparented because it needs to stay put when the "leftSide" animates when opening/closing live preview.
|
|
991
|
-
form.insertAdjacentElement('afterbegin', title)
|
|
992
|
-
|
|
993
|
-
const list = find(title.closest('.content-edit'), '.ContentEdit-overlayList')
|
|
994
|
-
if (!list) return
|
|
995
|
-
|
|
996
|
-
title.insertBefore(
|
|
997
|
-
create(
|
|
998
|
-
'button',
|
|
999
|
-
{
|
|
1000
|
-
className: 'ContentEdit-overlay',
|
|
1001
|
-
type: 'button',
|
|
1002
|
-
'aria-haspopup': 'true',
|
|
1003
|
-
'aria-expanded': 'false',
|
|
1004
|
-
'aria-label': find(list, 'li.selected').textContent,
|
|
1005
|
-
onclick: (e) => {
|
|
1006
|
-
toggleMenu(list, e.target)
|
|
1007
|
-
},
|
|
1008
|
-
},
|
|
1009
|
-
find(list, 'li.selected').textContent,
|
|
1010
|
-
),
|
|
1011
|
-
title.firstChild,
|
|
1012
|
-
)
|
|
1013
|
-
|
|
1014
|
-
const button = title.querySelector('.ContentEdit-overlay')
|
|
1015
|
-
setupMenuForAria(list, button)
|
|
1016
|
-
})
|
|
1017
|
-
|
|
1018
|
-
const getPreviewFrame = (mainObjectId) => {
|
|
1019
|
-
let frame
|
|
1020
|
-
if (!mainObjectId) {
|
|
1021
|
-
frame = document.querySelector(
|
|
1022
|
-
'.ContentEdit-previewDisplay iframe:first-of-type',
|
|
1023
|
-
)
|
|
1024
|
-
if (!frame) {
|
|
1025
|
-
frame = document.querySelector(
|
|
1026
|
-
'.PreviewFrame-typeDisplay iframe:first-of-type',
|
|
1027
|
-
)
|
|
1028
|
-
}
|
|
1029
|
-
} else {
|
|
1030
|
-
frame = document.querySelector(
|
|
1031
|
-
`iframe[data-container-id="${mainObjectId}"]`,
|
|
1032
|
-
)
|
|
1033
|
-
}
|
|
1034
|
-
return frame
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
// TODO: delete, `is-overlaid` no longer used
|
|
1038
|
-
// Add overlaid field count to the tabs.
|
|
1039
|
-
onFind('.CIG > .TabBar', (bar) => {
|
|
1040
|
-
const cig = bar.closest('.CIG')
|
|
1041
|
-
|
|
1042
|
-
onFind(cig, '.CIG-row.is-overlaid', (row) => {
|
|
1043
|
-
const tab = row.dataset.tab
|
|
1044
|
-
const item = find(bar, `:scope > .TabBar-item[data-tab="${tab}"]`)
|
|
1045
|
-
if (!item) return
|
|
1046
|
-
|
|
1047
|
-
let count = 0
|
|
1048
|
-
|
|
1049
|
-
for (const row of findAll(cig, `:scope > [data-tab="${tab}"]`)) {
|
|
1050
|
-
count += row.classList.contains('is-overlaid')
|
|
1051
|
-
? 1
|
|
1052
|
-
: findAll(row, '.is-overlaid').length
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
const badge = find(item, ':scope > .Badge')
|
|
1056
|
-
|
|
1057
|
-
if (count > 0) {
|
|
1058
|
-
if (badge) {
|
|
1059
|
-
badge.textContent = count
|
|
1060
|
-
} else {
|
|
1061
|
-
insertLast(create('div', { className: 'Badge' }, count), item)
|
|
1062
|
-
}
|
|
1063
|
-
} else {
|
|
1064
|
-
badge.remove()
|
|
1065
|
-
}
|
|
1066
|
-
})
|
|
1067
|
-
})
|
|
1068
|
-
|
|
1069
|
-
// Move workstream to the top.
|
|
1070
|
-
onFind(
|
|
1071
|
-
['.Page-content .publishing-workflow', '.Popup .publishing-workflow'],
|
|
1072
|
-
(message) => {
|
|
1073
|
-
const progressText = find(message, ':scope > .progress')
|
|
1074
|
-
const actions = find(message, ':scope > ul')
|
|
1075
|
-
const skip = find(actions, '.icon-step-forward')
|
|
1076
|
-
const stop = find(actions, '.icon-stop')
|
|
1077
|
-
|
|
1078
|
-
message.closest('.Page-content, .Popup').classList.add('is-workstream')
|
|
1079
|
-
message.classList.add('ContentEdit-workstreamMessage')
|
|
1080
|
-
message.removeAttribute('style')
|
|
1081
|
-
progressText.classList.add('ContentEdit-workstreamProgressText')
|
|
1082
|
-
progressText.removeAttribute('style')
|
|
1083
|
-
actions.classList.add('ContentEdit-workstreamActions')
|
|
1084
|
-
skip.classList.add('ContentEdit-workstreamSkip')
|
|
1085
|
-
stop.classList.add('ContentEdit-workstreamStop')
|
|
1086
|
-
|
|
1087
|
-
insertFirst(
|
|
1088
|
-
message,
|
|
1089
|
-
insertBefore(
|
|
1090
|
-
create(
|
|
1091
|
-
'div',
|
|
1092
|
-
{ className: 'ContentEdit-workstream' },
|
|
1093
|
-
create(
|
|
1094
|
-
'div',
|
|
1095
|
-
{ className: 'ContentEdit-workstreamProgress' },
|
|
1096
|
-
find(progressText, ':scope > .progressBar'),
|
|
1097
|
-
progressText,
|
|
1098
|
-
),
|
|
1099
|
-
actions,
|
|
1100
|
-
),
|
|
1101
|
-
message,
|
|
1102
|
-
),
|
|
1103
|
-
)
|
|
1104
|
-
},
|
|
1105
|
-
)
|
|
1106
|
-
|
|
1107
|
-
// Finds the TabBar trigger element given a descendant element.
|
|
1108
|
-
const findTabs = (el) => {
|
|
1109
|
-
if (!el) return
|
|
1110
|
-
|
|
1111
|
-
let elem = el
|
|
1112
|
-
let tab = null
|
|
1113
|
-
|
|
1114
|
-
let selectedTabs = []
|
|
1115
|
-
|
|
1116
|
-
const queryForTab = function (el) {
|
|
1117
|
-
return !el ? null : el.closest('[data-tab]')
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
for (;;) {
|
|
1121
|
-
tab = queryForTab(elem)
|
|
1122
|
-
if (tab) {
|
|
1123
|
-
const tbName = tab.getAttribute('data-tab')
|
|
1124
|
-
const tbBar = tab.parentNode.querySelector(':scope > .TabBar')
|
|
1125
|
-
if (tbBar) {
|
|
1126
|
-
selectedTabs.push(tbBar.querySelector(`[data-tab="${tbName}"]`))
|
|
1127
|
-
}
|
|
1128
|
-
elem = tab.parentNode
|
|
1129
|
-
} else {
|
|
1130
|
-
break
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
return selectedTabs
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
// Triggers Tab selection given a descendant element.
|
|
1138
|
-
const selectTab = (descendantEl) => {
|
|
1139
|
-
const tabs = findTabs(descendantEl)
|
|
1140
|
-
|
|
1141
|
-
tabs.forEach((tab) => {
|
|
1142
|
-
if (tab && !tab.classList.contains('is-selected')) {
|
|
1143
|
-
tab.click()
|
|
1144
|
-
}
|
|
1145
|
-
})
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
const findEditUIByOverlay = (id, name) => {
|
|
1149
|
-
const cig = find(document, `.CIG-row[data-name='${id}/${name}']`)
|
|
1150
|
-
const eig = find(document, `.EIG-title[data-object-id='${id}']`)
|
|
1151
|
-
const option = find(
|
|
1152
|
-
document,
|
|
1153
|
-
`option[value='${id}'], input.objectId[value='${id}']`,
|
|
1154
|
-
)
|
|
1155
|
-
const rteEnhancement = find(
|
|
1156
|
-
document,
|
|
1157
|
-
`[data-rte-container] .Enhancement[data-state*="${id}"]`,
|
|
1158
|
-
)
|
|
1159
|
-
const repeatableCig = find(document, `.RCIG-title[data-object-id="${id}"]`)
|
|
1160
|
-
if (cig) {
|
|
1161
|
-
// Try to find a more specific RCS...
|
|
1162
|
-
const rcs = cig.querySelector(
|
|
1163
|
-
`:scope .RCS ol[data-sortable-input-name='${id}/${name}']`,
|
|
1164
|
-
)
|
|
1165
|
-
if (rcs) {
|
|
1166
|
-
return { type: 'RCS', element: rcs }
|
|
1167
|
-
} else {
|
|
1168
|
-
return { type: 'CIG', element: cig }
|
|
1169
|
-
}
|
|
1170
|
-
} else if (option) {
|
|
1171
|
-
return { type: 'OPTION', element: option }
|
|
1172
|
-
} else if (rteEnhancement) {
|
|
1173
|
-
return { type: 'ENHANCEMENT', element: rteEnhancement }
|
|
1174
|
-
} else if (eig) {
|
|
1175
|
-
return { type: 'EIG', element: eig }
|
|
1176
|
-
} else if (repeatableCig) {
|
|
1177
|
-
return { type: 'RCIG', element: repeatableCig }
|
|
1178
|
-
} else {
|
|
1179
|
-
console.debug('Form element does not exist for the preview overlay')
|
|
1180
|
-
return null
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
const openFormFieldPopup = (element, modal, edit, label) => {
|
|
1185
|
-
if (element.classList.contains('is-new-item')) {
|
|
1186
|
-
element.classList.remove('is-new-item')
|
|
1187
|
-
}
|
|
1188
|
-
const container = element.closest('.is-preview-menu')
|
|
1189
|
-
if (!container) {
|
|
1190
|
-
return
|
|
1191
|
-
}
|
|
1192
|
-
const parent = element.parentNode
|
|
1193
|
-
let popupContainer
|
|
1194
|
-
const nextSibling = element.nextElementSibling
|
|
1195
|
-
const closeField = () => {
|
|
1196
|
-
modal.classList.remove('is-visible')
|
|
1197
|
-
popupContainer.removeChild(actions)
|
|
1198
|
-
if (popupHeading) {
|
|
1199
|
-
popupContainer.removeChild(popupHeading)
|
|
1200
|
-
}
|
|
1201
|
-
const clear =
|
|
1202
|
-
element.classList.contains('RCS-item') &&
|
|
1203
|
-
element.querySelector(':scope > .ContentSelector-clear')
|
|
1204
|
-
if (clear) {
|
|
1205
|
-
clear.classList.remove('is-visible')
|
|
1206
|
-
}
|
|
1207
|
-
parent.insertBefore(element, nextSibling)
|
|
1208
|
-
popupContainer.remove()
|
|
1209
|
-
}
|
|
1210
|
-
const cancelButton = create('div', {
|
|
1211
|
-
className: 'Preview-popupCancel',
|
|
1212
|
-
onclick: (event) => {
|
|
1213
|
-
closeField()
|
|
1214
|
-
},
|
|
1215
|
-
})
|
|
1216
|
-
const saveButton = document.createElement('button')
|
|
1217
|
-
saveButton.classList.add('is-save')
|
|
1218
|
-
saveButton.classList.add('is-dominant')
|
|
1219
|
-
saveButton.textContent = 'Save & Close'
|
|
1220
|
-
const actions = create('div', { className: 'ActionBar' })
|
|
1221
|
-
actions.appendChild(saveButton)
|
|
1222
|
-
let popupHeading
|
|
1223
|
-
if (label) {
|
|
1224
|
-
popupHeading = create('div', { className: 'Preview-popupHeading' }, label)
|
|
1225
|
-
}
|
|
1226
|
-
popupContainer = create(
|
|
1227
|
-
'div',
|
|
1228
|
-
{
|
|
1229
|
-
className: 'Preview-popup is-previewEditing',
|
|
1230
|
-
},
|
|
1231
|
-
popupHeading,
|
|
1232
|
-
element,
|
|
1233
|
-
cancelButton,
|
|
1234
|
-
actions,
|
|
1235
|
-
)
|
|
1236
|
-
edit.appendChild(popupContainer)
|
|
1237
|
-
saveButton.addEventListener('click', (event) => {
|
|
1238
|
-
closeField()
|
|
1239
|
-
})
|
|
1240
|
-
modal.classList.add('is-visible')
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
window.addEventListener('message', async ({ data }) => {
|
|
1244
|
-
if (typeof data !== 'object') return
|
|
1245
|
-
|
|
1246
|
-
const id = data.id
|
|
1247
|
-
const type = data.type
|
|
1248
|
-
const name = data.name
|
|
1249
|
-
|
|
1250
|
-
if (type === 'BSP.Preview.onChangedHeight') {
|
|
1251
|
-
const edit = document.querySelector(
|
|
1252
|
-
`.ContentEdit[data-object-id="${data.previewContainerId}"]`,
|
|
1253
|
-
)
|
|
1254
|
-
if (edit) {
|
|
1255
|
-
const container = edit.closest('.Page-content, .Popup')
|
|
1256
|
-
const contentEditPreview = container?.querySelector(
|
|
1257
|
-
'.ContentEdit-preview',
|
|
1258
|
-
)
|
|
1259
|
-
contentEditPreview?.style.setProperty(
|
|
1260
|
-
'--PreviewFrame-height',
|
|
1261
|
-
`${data.height}px`,
|
|
1262
|
-
)
|
|
1263
|
-
}
|
|
1264
|
-
} else if (type === 'BSP.Preview.OverlayClick') {
|
|
1265
|
-
const parentFields = data.parentFields
|
|
1266
|
-
const hasFormField = data.hasFormField
|
|
1267
|
-
|
|
1268
|
-
const scrollToEditUI = () => {
|
|
1269
|
-
const ui = findEditUIByOverlay(id, name)
|
|
1270
|
-
if (!ui) return
|
|
1271
|
-
findAll(document.body, '.RCIG-item').forEach((item) => {
|
|
1272
|
-
const title = find(item, ':scope > .RCIG-title')
|
|
1273
|
-
if (!title) return
|
|
1274
|
-
if (item.contains(ui.element) || item.isEqualNode(ui.element)) {
|
|
1275
|
-
// expand collapsed RCIG-items that contain the clicked element or are the element
|
|
1276
|
-
if (item.classList.contains('is-collapsed')) {
|
|
1277
|
-
title.click()
|
|
1278
|
-
}
|
|
1279
|
-
} else if (!item.classList.contains('is-collapsed')) {
|
|
1280
|
-
// collapse all the other expandable items that do not contain the clicked element
|
|
1281
|
-
// or are not the element itself
|
|
1282
|
-
title.click()
|
|
1283
|
-
}
|
|
1284
|
-
})
|
|
1285
|
-
const cigRow = ui.element.closest('.CIG-row')
|
|
1286
|
-
if (cigRow && cigRow.classList.contains('is-inHiddenCluster')) {
|
|
1287
|
-
for (let n = cigRow; (n = n.previousElementSibling); ) {
|
|
1288
|
-
if (n.classList.contains('CIG-title')) {
|
|
1289
|
-
n.click()
|
|
1290
|
-
break
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
selectTab(ui.element)
|
|
1295
|
-
const evt = new MouseEvent('click', {
|
|
1296
|
-
bubbles: true,
|
|
1297
|
-
cancelable: true,
|
|
1298
|
-
view: window,
|
|
1299
|
-
})
|
|
1300
|
-
if (ui.type === 'CIG' || ui.type === 'EIG') {
|
|
1301
|
-
// Refine the match if we can identify the item that this CIG is within.
|
|
1302
|
-
scrollIntoView(ui.element, { align: { top: 0, topOffset: 10 } })
|
|
1303
|
-
const elmFocus = ui.element.querySelector('.CIG-small')
|
|
1304
|
-
if (elmFocus) {
|
|
1305
|
-
onFind(
|
|
1306
|
-
elmFocus,
|
|
1307
|
-
[
|
|
1308
|
-
':scope > btu-input input',
|
|
1309
|
-
':scope > textarea',
|
|
1310
|
-
':scope > btu-textarea-input > textarea',
|
|
1311
|
-
':scope > .ComboInput',
|
|
1312
|
-
':scope > input',
|
|
1313
|
-
],
|
|
1314
|
-
(inputField) => {
|
|
1315
|
-
const proseMirror = elmFocus.querySelector(
|
|
1316
|
-
'.ProseMirrorContainer > .ProseMirror',
|
|
1317
|
-
)
|
|
1318
|
-
if (proseMirror) {
|
|
1319
|
-
proseMirror.focus()
|
|
1320
|
-
} else {
|
|
1321
|
-
inputField.focus()
|
|
1322
|
-
}
|
|
1323
|
-
},
|
|
1324
|
-
)
|
|
1325
|
-
}
|
|
1326
|
-
} else if (ui.type === 'RCS') {
|
|
1327
|
-
const targetEl = ui.element.closest('.CIG-small')
|
|
1328
|
-
if (targetEl.classList.contains('RCS')) {
|
|
1329
|
-
let rcsTarget = ui.element.closest('.RCS-item') ?? targetEl
|
|
1330
|
-
scrollIntoView(rcsTarget, {
|
|
1331
|
-
align: { top: 0, topOffset: 10 },
|
|
1332
|
-
})
|
|
1333
|
-
rcsTarget.dispatchEvent(evt)
|
|
1334
|
-
} else {
|
|
1335
|
-
if (targetEl) {
|
|
1336
|
-
onFind(targetEl, ':scope > .ComboInput', (inputField) => {
|
|
1337
|
-
inputField.focus()
|
|
1338
|
-
})
|
|
1339
|
-
}
|
|
1340
|
-
scrollIntoView(ui.element.closest('.CIG-row'), {
|
|
1341
|
-
align: { top: 0, topOffset: 10 },
|
|
1342
|
-
})
|
|
1343
|
-
}
|
|
1344
|
-
ui.element.dispatchEvent(evt)
|
|
1345
|
-
} else if (ui.type === 'OPTION') {
|
|
1346
|
-
const targetEl = ui.element.closest('.CIG-small')
|
|
1347
|
-
if (targetEl.classList.contains('RCS')) {
|
|
1348
|
-
let rcsTarget = ui.element.closest('.RCS-item') ?? targetEl
|
|
1349
|
-
scrollIntoView(rcsTarget, {
|
|
1350
|
-
align: { top: 0, topOffset: 0 },
|
|
1351
|
-
})
|
|
1352
|
-
rcsTarget.dispatchEvent(evt)
|
|
1353
|
-
} else {
|
|
1354
|
-
if (targetEl) {
|
|
1355
|
-
onFind(targetEl, ':scope > .ComboInput', (inputField) => {
|
|
1356
|
-
inputField.focus()
|
|
1357
|
-
})
|
|
1358
|
-
}
|
|
1359
|
-
scrollIntoView(ui.element.closest('.CIG-row'), {
|
|
1360
|
-
align: { top: 0, topOffset: 10 },
|
|
1361
|
-
})
|
|
1362
|
-
}
|
|
1363
|
-
ui.element.dispatchEvent(evt)
|
|
1364
|
-
} else if (ui.type === 'RCIG') {
|
|
1365
|
-
scrollIntoView(ui.element, {
|
|
1366
|
-
align: { top: 0, topOffset: 10 },
|
|
1367
|
-
})
|
|
1368
|
-
} else if (ui.type === 'ENHANCEMENT') {
|
|
1369
|
-
let topOffset,
|
|
1370
|
-
toolbarHeight = 0
|
|
1371
|
-
const rteContainer = ui.element.closest('.ProseMirrorContainer')
|
|
1372
|
-
if (rteContainer) {
|
|
1373
|
-
toolbarHeight = rteContainer.querySelector(
|
|
1374
|
-
'.ProseMirrorToolbar',
|
|
1375
|
-
)?.offsetHeight
|
|
1376
|
-
}
|
|
1377
|
-
let marginTop = parseInt(window.getComputedStyle(ui.element).marginTop)
|
|
1378
|
-
if (!isNaN(marginTop)) {
|
|
1379
|
-
topOffset = Math.abs(toolbarHeight - marginTop)
|
|
1380
|
-
}
|
|
1381
|
-
scrollIntoView(ui.element, {
|
|
1382
|
-
align: { top: 0, topOffset: topOffset },
|
|
1383
|
-
})
|
|
1384
|
-
}
|
|
1385
|
-
|
|
1386
|
-
if (data.behavior) {
|
|
1387
|
-
let parentEl = ui.element
|
|
1388
|
-
if (ui.type === 'OPTION' && parentEl.closest('.RCS-item')) {
|
|
1389
|
-
parentEl = parentEl.closest('.RCS-item')
|
|
1390
|
-
}
|
|
1391
|
-
const sharedElement = parentEl.querySelector('.ContentSelector-edit')
|
|
1392
|
-
sharedElement?.click()
|
|
1393
|
-
}
|
|
1394
|
-
if (!hasFormField) {
|
|
1395
|
-
parentFields.push({
|
|
1396
|
-
id: data.id,
|
|
1397
|
-
name: data.name,
|
|
1398
|
-
})
|
|
1399
|
-
const overlayWindow = PreviewOverlay.getOverlayWindow(
|
|
1400
|
-
data.previewContainerId,
|
|
1401
|
-
)
|
|
1402
|
-
overlayWindow.postMessage(
|
|
1403
|
-
{
|
|
1404
|
-
type: 'BSP.Preview.UpdateOverlays',
|
|
1405
|
-
overlays: parentFields,
|
|
1406
|
-
},
|
|
1407
|
-
'*',
|
|
1408
|
-
)
|
|
1409
|
-
}
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
const loadEditUI = (parentData) => {
|
|
1413
|
-
const parentKey = parentData.key
|
|
1414
|
-
const { id, name, overlayType, isEnhancement } = data
|
|
1415
|
-
let selector
|
|
1416
|
-
if (isEnhancement) {
|
|
1417
|
-
selector = `.CIG-row[data-name='${parentKey}'] .ProseMirrorContainer`
|
|
1418
|
-
} else if (overlayType === 'bspField') {
|
|
1419
|
-
selector = `.CIG-row[data-name='${id}/${name}']`
|
|
1420
|
-
} else if (overlayType === 'bspModule') {
|
|
1421
|
-
if (parentData.ui.type === 'RCS') {
|
|
1422
|
-
selector = `input.objectId[value="${id}"]`
|
|
1423
|
-
} else {
|
|
1424
|
-
selector = `.repeatableLabel[data-object-id="${id}"]`
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
onFind(selector, () => {
|
|
1429
|
-
scrollToEditUI()
|
|
1430
|
-
})
|
|
1431
|
-
}
|
|
1432
|
-
|
|
1433
|
-
if (!hasFormField) {
|
|
1434
|
-
// if there is no field yet expand all the collapsed parent fields
|
|
1435
|
-
let promises = []
|
|
1436
|
-
parentFields.forEach((field, index) => {
|
|
1437
|
-
const { id, name, type } = field
|
|
1438
|
-
let selector = ''
|
|
1439
|
-
if (type === 'bspField') {
|
|
1440
|
-
selector = `.CIG-row[data-name='${id}/${name}']`
|
|
1441
|
-
} else if (type === 'bspModule') {
|
|
1442
|
-
selector = `.repeatableLabel[data-object-id="${id}"]`
|
|
1443
|
-
}
|
|
1444
|
-
const expandItem = (resolve, reject) => {
|
|
1445
|
-
onFind(selector, () => {
|
|
1446
|
-
let ui = findEditUIByOverlay(id, name)
|
|
1447
|
-
if (!ui) {
|
|
1448
|
-
reject(
|
|
1449
|
-
'Could not load edit ui: fields for one or more parent overlay(s) are missing in the form',
|
|
1450
|
-
)
|
|
1451
|
-
return
|
|
1452
|
-
}
|
|
1453
|
-
const editElement = ui.element
|
|
1454
|
-
scrollIntoView(editElement, { align: { top: 0, topOffset: 10 } })
|
|
1455
|
-
|
|
1456
|
-
if (data.isEnhancement) {
|
|
1457
|
-
/* Find RTE enhancement and scroll it into view */
|
|
1458
|
-
onRTEReady((rte) => {
|
|
1459
|
-
const enhancementElement = rte.view.dom.querySelector(
|
|
1460
|
-
`[data-state*='_id":"${data.id}']`,
|
|
1461
|
-
)
|
|
1462
|
-
|
|
1463
|
-
if (enhancementElement) {
|
|
1464
|
-
scrollIntoView(enhancementElement)
|
|
1465
|
-
enhancementElement.click()
|
|
1466
|
-
}
|
|
1467
|
-
}, editElement.querySelector('textarea.richtext'))
|
|
1468
|
-
}
|
|
1469
|
-
|
|
1470
|
-
if (ui.type === 'RCIG' && editElement?.closest('.is-collapsed')) {
|
|
1471
|
-
editElement.click()
|
|
1472
|
-
}
|
|
1473
|
-
const cigRow = editElement.closest('.CIG-row')
|
|
1474
|
-
if (cigRow && cigRow.classList.contains('is-inHiddenCluster')) {
|
|
1475
|
-
for (let n = cigRow; (n = n.previousElementSibling); ) {
|
|
1476
|
-
if (n.classList.contains('CIG-title')) {
|
|
1477
|
-
n.click()
|
|
1478
|
-
break
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
}
|
|
1482
|
-
|
|
1483
|
-
if (resolve) {
|
|
1484
|
-
resolve({ ui: ui, key: id + '/' + name })
|
|
1485
|
-
}
|
|
1486
|
-
})
|
|
1487
|
-
}
|
|
1488
|
-
promises.push(
|
|
1489
|
-
new Promise((resolve, reject) => {
|
|
1490
|
-
expandItem(resolve, reject)
|
|
1491
|
-
}),
|
|
1492
|
-
)
|
|
1493
|
-
})
|
|
1494
|
-
|
|
1495
|
-
Promise.all(promises)
|
|
1496
|
-
.then((parents) => {
|
|
1497
|
-
const immediateParent = parents[parents.length - 1]
|
|
1498
|
-
loadEditUI(immediateParent)
|
|
1499
|
-
})
|
|
1500
|
-
.catch((error) => {
|
|
1501
|
-
console.debug(error)
|
|
1502
|
-
})
|
|
1503
|
-
} else {
|
|
1504
|
-
// scroll to the edit element
|
|
1505
|
-
scrollToEditUI()
|
|
1506
|
-
}
|
|
1507
|
-
} else if (type === 'BSP.Preview.ContentLoad') {
|
|
1508
|
-
const edit = document.querySelector(
|
|
1509
|
-
`.ContentEdit[data-object-id="${data.previewContainerId}"]`,
|
|
1510
|
-
)
|
|
1511
|
-
const isPreviewOpen =
|
|
1512
|
-
edit?.closest('.Page-content.is-previewing') ||
|
|
1513
|
-
edit?.closest('.Popup.is-previewing')
|
|
1514
|
-
const activeElement = document.activeElement
|
|
1515
|
-
let isPreviewFocused =
|
|
1516
|
-
activeElement.closest('.Preview-overlayFrame') ||
|
|
1517
|
-
activeElement.closest(
|
|
1518
|
-
`iframe[data-container-id="${data.previewContainerId}"]`,
|
|
1519
|
-
)
|
|
1520
|
-
// check to see if the preview pane is open and user is hovering over it
|
|
1521
|
-
let deferPreviewInit = !isPreviewOpen || !isPreviewFocused ? true : false
|
|
1522
|
-
const previewFrame = getPreviewFrame(data.previewContainerId)
|
|
1523
|
-
// update data-defer-init attribute for preview & preview overlay frame everytime preview refreshes
|
|
1524
|
-
// to check if the dom parsing and overlay rendering should run
|
|
1525
|
-
previewFrame?.contentWindow.postMessage(
|
|
1526
|
-
{
|
|
1527
|
-
type: 'BSP.Preview.UpdateInitToggle',
|
|
1528
|
-
deferPreviewInit,
|
|
1529
|
-
},
|
|
1530
|
-
'*',
|
|
1531
|
-
)
|
|
1532
|
-
let overlayWindow = PreviewOverlay.getOverlayWindow(data.previewContainerId)
|
|
1533
|
-
overlayWindow?.postMessage(
|
|
1534
|
-
{
|
|
1535
|
-
type: 'BSP.Preview.UpdateInitToggle',
|
|
1536
|
-
deferPreviewInit,
|
|
1537
|
-
},
|
|
1538
|
-
'*',
|
|
1539
|
-
)
|
|
1540
|
-
} else if (type === 'BSP.Preview.DOMParsed') {
|
|
1541
|
-
// Check if the preview is open before rendering the overlays
|
|
1542
|
-
const edit = document.querySelector(
|
|
1543
|
-
`.ContentEdit[data-object-id="${data.previewContainerId}"]`,
|
|
1544
|
-
)
|
|
1545
|
-
const isPreviewToEditParticipating =
|
|
1546
|
-
edit?.closest('.Page-content.is-previewing') ||
|
|
1547
|
-
edit?.closest('.Popup.is-previewing')
|
|
1548
|
-
|
|
1549
|
-
if (!isPreviewToEditParticipating) return
|
|
1550
|
-
|
|
1551
|
-
// Determine which markers should result in Overlays being rendered.
|
|
1552
|
-
let filteredOverlays = new Map()
|
|
1553
|
-
|
|
1554
|
-
const updateOverlays = (key, overlay, parent) => {
|
|
1555
|
-
filteredOverlays.set(key, overlay)
|
|
1556
|
-
if (!parent) return
|
|
1557
|
-
if (parent.type === 'bspModule' && !parent.dimensions) {
|
|
1558
|
-
if (parent.childKeys) {
|
|
1559
|
-
parent.childKeys.push(key)
|
|
1560
|
-
} else {
|
|
1561
|
-
parent.childKeys = [key]
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
// Recursive method to find all the form fields and connect them to p2e overlays
|
|
1567
|
-
const getEditElements = (
|
|
1568
|
-
fieldId,
|
|
1569
|
-
parentContainer,
|
|
1570
|
-
parentObj,
|
|
1571
|
-
parentKey,
|
|
1572
|
-
overlayKey,
|
|
1573
|
-
) => {
|
|
1574
|
-
const isRoot = fieldId === data.previewContainerId
|
|
1575
|
-
const overlay = filteredOverlays.get(overlayKey)
|
|
1576
|
-
|
|
1577
|
-
const rcig = parentContainer.querySelector(
|
|
1578
|
-
`.RCIG-title[data-object-id="${fieldId}"]`,
|
|
1579
|
-
)
|
|
1580
|
-
const eig = parentContainer.querySelector(
|
|
1581
|
-
`.EIG-title[data-object-id="${fieldId}"]`,
|
|
1582
|
-
)
|
|
1583
|
-
|
|
1584
|
-
let contentEditElements
|
|
1585
|
-
let elm
|
|
1586
|
-
|
|
1587
|
-
const objectInput = parentContainer.querySelector(
|
|
1588
|
-
`.objectInputs[data-object-id="${fieldId}"]`,
|
|
1589
|
-
)
|
|
1590
|
-
// For form fields inside a collapsible cluster/widget that are not yet loaded
|
|
1591
|
-
// Will be using data state object to setup overlays map and their hierarchy
|
|
1592
|
-
if ((rcig || eig) && !objectInput) {
|
|
1593
|
-
let childDataKeys = []
|
|
1594
|
-
const immediateParent = parentContainer.querySelector(
|
|
1595
|
-
`input[name="${parentKey}.id"][value="${fieldId}"]`,
|
|
1596
|
-
)?.parentNode
|
|
1597
|
-
const val = immediateParent?.querySelector(
|
|
1598
|
-
`input[name="${parentKey}.data"]`,
|
|
1599
|
-
).value
|
|
1600
|
-
if (val) {
|
|
1601
|
-
const childData = JSON.parse(val)
|
|
1602
|
-
const recursiveSearch = (obj, keys, parentObj, isEnhancement) => {
|
|
1603
|
-
let moduleKey = parentObj.children?.find((chKey) => {
|
|
1604
|
-
return chKey.split('/')[0] === obj._id
|
|
1605
|
-
})
|
|
1606
|
-
let realParent = parentObj
|
|
1607
|
-
if (moduleKey) {
|
|
1608
|
-
const pOb = data.overlays.get(moduleKey)
|
|
1609
|
-
let overlayData = {
|
|
1610
|
-
id: moduleKey.split('/')[0],
|
|
1611
|
-
hasFormField: false,
|
|
1612
|
-
parentKey: parentObj.id + '/' + parentObj.name,
|
|
1613
|
-
parentRoot: parentObj.parentRoot,
|
|
1614
|
-
depth: parentObj.depth + 1,
|
|
1615
|
-
type: 'bspModule',
|
|
1616
|
-
name: moduleKey.split('/')[1],
|
|
1617
|
-
}
|
|
1618
|
-
if (pOb) {
|
|
1619
|
-
overlayData = Object.assign(overlayData, pOb)
|
|
1620
|
-
}
|
|
1621
|
-
updateOverlays(moduleKey, overlayData, parentObj)
|
|
1622
|
-
realParent = overlayData
|
|
1623
|
-
}
|
|
1624
|
-
keys.forEach((k) => {
|
|
1625
|
-
if (!/^_|^theme./.test(k)) {
|
|
1626
|
-
let o
|
|
1627
|
-
let isCigSelect
|
|
1628
|
-
let isDropdown
|
|
1629
|
-
const val = obj[k]
|
|
1630
|
-
if (obj._id) {
|
|
1631
|
-
const cKey = obj._id + '/' + k
|
|
1632
|
-
childDataKeys.push(cKey)
|
|
1633
|
-
const extn = data.overlays.get(cKey)
|
|
1634
|
-
if (extn) {
|
|
1635
|
-
if (val && typeof val === 'object') {
|
|
1636
|
-
isCigSelect = Object.keys(val).includes(extn.name)
|
|
1637
|
-
const relevantKey = Object.keys(val).find((rk) => {
|
|
1638
|
-
return !/^_|^theme./.test(rk)
|
|
1639
|
-
})
|
|
1640
|
-
if (!relevantKey) {
|
|
1641
|
-
isDropdown = true
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
if (!isCigSelect || isEnhancement) {
|
|
1645
|
-
o = Object.assign(
|
|
1646
|
-
{
|
|
1647
|
-
parentKey: realParent.id + '/' + realParent.name,
|
|
1648
|
-
parentRoot: realParent.parentRoot,
|
|
1649
|
-
depth: realParent.depth + 1,
|
|
1650
|
-
isInitialized: true,
|
|
1651
|
-
hasFormField: false,
|
|
1652
|
-
isShared: obj[k]._ref ? cKey + '_acEdit' : null,
|
|
1653
|
-
isEnhancement: !!isEnhancement,
|
|
1654
|
-
isDropdown,
|
|
1655
|
-
},
|
|
1656
|
-
extn,
|
|
1657
|
-
)
|
|
1658
|
-
updateOverlays(cKey, o, realParent)
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
if (!isEnhancement) {
|
|
1663
|
-
if (isCigSelect) {
|
|
1664
|
-
o = realParent
|
|
1665
|
-
} else if (!o) {
|
|
1666
|
-
o = parentObj
|
|
1667
|
-
}
|
|
1668
|
-
if (val) {
|
|
1669
|
-
if (typeof val === 'object') {
|
|
1670
|
-
if (Array.isArray(val)) {
|
|
1671
|
-
val.forEach((child) => {
|
|
1672
|
-
if (child._ref) {
|
|
1673
|
-
const rcsKey = o.children?.find((chKey) => {
|
|
1674
|
-
return child._ref === chKey.split('/')[0]
|
|
1675
|
-
})
|
|
1676
|
-
const rcsExtn = data.overlays.get(rcsKey)
|
|
1677
|
-
if (rcsExtn) {
|
|
1678
|
-
const rcsOvr = Object.assign({
|
|
1679
|
-
parentKey: o.id + '/' + o.name,
|
|
1680
|
-
parentRoot: o.parentRoot,
|
|
1681
|
-
depth: realParent.depth + 1,
|
|
1682
|
-
isInitialized: true,
|
|
1683
|
-
hasFormField: false,
|
|
1684
|
-
isShared:
|
|
1685
|
-
o.id +
|
|
1686
|
-
'/' +
|
|
1687
|
-
o.name +
|
|
1688
|
-
'_' +
|
|
1689
|
-
rcsExtn.id +
|
|
1690
|
-
'_acEdit',
|
|
1691
|
-
})
|
|
1692
|
-
updateOverlays(rcsKey, rcsOvr, o)
|
|
1693
|
-
}
|
|
1694
|
-
} else {
|
|
1695
|
-
recursiveSearch(child, Object.keys(child), o)
|
|
1696
|
-
}
|
|
1697
|
-
})
|
|
1698
|
-
} else {
|
|
1699
|
-
recursiveSearch(val, Object.keys(val), o)
|
|
1700
|
-
}
|
|
1701
|
-
} else if (typeof val === 'string') {
|
|
1702
|
-
const parser = new DOMParser(),
|
|
1703
|
-
doc = parser.parseFromString(val, 'text/html'),
|
|
1704
|
-
elementsWithState = doc.querySelectorAll('[data-state]')
|
|
1705
|
-
|
|
1706
|
-
elementsWithState.forEach((element) => {
|
|
1707
|
-
const dataState = element.getAttribute('data-state'),
|
|
1708
|
-
enhancementState = JSON.parse(dataState)
|
|
1709
|
-
|
|
1710
|
-
if (enhancementState) {
|
|
1711
|
-
recursiveSearch(
|
|
1712
|
-
enhancementState,
|
|
1713
|
-
Object.keys(enhancementState),
|
|
1714
|
-
o,
|
|
1715
|
-
true,
|
|
1716
|
-
)
|
|
1717
|
-
}
|
|
1718
|
-
})
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
})
|
|
1724
|
-
}
|
|
1725
|
-
recursiveSearch(childData, Object.keys(childData), overlay)
|
|
1726
|
-
}
|
|
1727
|
-
} else {
|
|
1728
|
-
// All form fields that are already loaded in the DOM
|
|
1729
|
-
let realParent = parentObj
|
|
1730
|
-
let realParentKey = parentKey
|
|
1731
|
-
elm = objectInput || parentContainer
|
|
1732
|
-
contentEditElements = [
|
|
1733
|
-
...elm.querySelectorAll(
|
|
1734
|
-
`div.inputContainer[data-name^="${fieldId}"]:not([hidden])`,
|
|
1735
|
-
),
|
|
1736
|
-
].filter((inputElement) => {
|
|
1737
|
-
return !inputElement.closest('.TC-unselected')
|
|
1738
|
-
})
|
|
1739
|
-
if (rcig || eig) {
|
|
1740
|
-
// these are the collapsible containers
|
|
1741
|
-
const pOb = data.overlays.get(overlayKey)
|
|
1742
|
-
realParentKey = overlayKey
|
|
1743
|
-
let overlayData = {
|
|
1744
|
-
id: overlayKey.split('/')[0],
|
|
1745
|
-
hasFormField: true,
|
|
1746
|
-
parentKey: parentKey,
|
|
1747
|
-
parentRoot: parentObj.parentRoot,
|
|
1748
|
-
depth: parentObj.depth + 1,
|
|
1749
|
-
type: 'bspModule',
|
|
1750
|
-
name: overlayKey.split('/')[1],
|
|
1751
|
-
}
|
|
1752
|
-
if (pOb) {
|
|
1753
|
-
overlayData = Object.assign(overlayData, pOb)
|
|
1754
|
-
}
|
|
1755
|
-
updateOverlays(overlayKey, overlayData, realParent)
|
|
1756
|
-
realParent = overlayData
|
|
1757
|
-
}
|
|
1758
|
-
contentEditElements.forEach((contentEditElement) => {
|
|
1759
|
-
const key = contentEditElement.dataset.name
|
|
1760
|
-
let ovr
|
|
1761
|
-
const extn = data.overlays.get(key)
|
|
1762
|
-
let isCigSelect
|
|
1763
|
-
let isDropdown
|
|
1764
|
-
if (!extn || extn.isEmpty) return
|
|
1765
|
-
if (extn.type === 'bspField') {
|
|
1766
|
-
isCigSelect =
|
|
1767
|
-
!isRoot &&
|
|
1768
|
-
contentEditElement.querySelector(`select[name="${key}.id"]`)
|
|
1769
|
-
isDropdown = contentEditElement.querySelector(
|
|
1770
|
-
`select[name="${key}.id"]`,
|
|
1771
|
-
)
|
|
1772
|
-
const sharedElement = isShared(
|
|
1773
|
-
key,
|
|
1774
|
-
contentEditElement,
|
|
1775
|
-
extn.fieldValue?.split('/')[0],
|
|
1776
|
-
)
|
|
1777
|
-
const previewElement = extn.hasElement
|
|
1778
|
-
if (sharedElement && !previewElement) {
|
|
1779
|
-
return
|
|
1780
|
-
}
|
|
1781
|
-
let editAction = `${key}_acEdit`
|
|
1782
|
-
if (sharedElement) {
|
|
1783
|
-
sharedElement.dataset.previewAction = editAction
|
|
1784
|
-
}
|
|
1785
|
-
ovr = Object.assign(
|
|
1786
|
-
{
|
|
1787
|
-
isShared: sharedElement ? editAction : false,
|
|
1788
|
-
isLocked: isLocked(contentEditElement),
|
|
1789
|
-
isInitialized: true,
|
|
1790
|
-
depth: isRoot ? 1 : realParent.depth + 1,
|
|
1791
|
-
parentRoot: isRoot ? key : realParent.parentRoot,
|
|
1792
|
-
parentKey: isRoot ? null : realParentKey,
|
|
1793
|
-
hasFormField: true,
|
|
1794
|
-
isDropdown,
|
|
1795
|
-
},
|
|
1796
|
-
extn,
|
|
1797
|
-
)
|
|
1798
|
-
if (!isCigSelect) {
|
|
1799
|
-
updateOverlays(key, ovr, realParent)
|
|
1800
|
-
}
|
|
1801
|
-
} else if (extn.type === 'bspModule') {
|
|
1802
|
-
if (extn.referencesRichText) {
|
|
1803
|
-
const enhancements =
|
|
1804
|
-
parentContainer.querySelectorAll('.Enhancement')
|
|
1805
|
-
enhancements.forEach((enhancement) => {
|
|
1806
|
-
if (enhancement.dataset.state) {
|
|
1807
|
-
const state = JSON.parse(enhancement.dataset.state)
|
|
1808
|
-
const id = state._id
|
|
1809
|
-
if (id === extn.id) {
|
|
1810
|
-
ovr = Object.assign(
|
|
1811
|
-
{
|
|
1812
|
-
isShared: false,
|
|
1813
|
-
isInitialized: true,
|
|
1814
|
-
depth: isRoot ? 1 : realParent.depth + 1,
|
|
1815
|
-
parentRoot: realParent.parentRoot,
|
|
1816
|
-
parentKey: realParentKey,
|
|
1817
|
-
hasFormField: true,
|
|
1818
|
-
},
|
|
1819
|
-
extn,
|
|
1820
|
-
)
|
|
1821
|
-
updateOverlays(key, ovr, realParent)
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
})
|
|
1825
|
-
} else {
|
|
1826
|
-
// currently a no-op for bspModules which are not associated with rich text.
|
|
1827
|
-
}
|
|
1828
|
-
}
|
|
1829
|
-
let children = []
|
|
1830
|
-
if (ovr.children) {
|
|
1831
|
-
children = [...ovr.children]
|
|
1832
|
-
} else if (!ovr.isShared && ovr.fieldValue) {
|
|
1833
|
-
children.push(ovr.fieldValue)
|
|
1834
|
-
}
|
|
1835
|
-
const rcs = contentEditElement.querySelector(
|
|
1836
|
-
`.RCS ol[data-sortable-input-name='${key}']`,
|
|
1837
|
-
)
|
|
1838
|
-
// Check if this is a rich text field with enhancements
|
|
1839
|
-
if (ovr.internalType === 'text') {
|
|
1840
|
-
const updateEnhancements = function (source) {
|
|
1841
|
-
const parser = new DOMParser(),
|
|
1842
|
-
doc = parser.parseFromString(source, 'text/html'),
|
|
1843
|
-
elementsWithState = doc.querySelectorAll('[data-state]')
|
|
1844
|
-
|
|
1845
|
-
elementsWithState.forEach((element) => {
|
|
1846
|
-
const dataState = element.getAttribute('data-state'),
|
|
1847
|
-
enhancementState = JSON.parse(dataState)
|
|
1848
|
-
|
|
1849
|
-
if (enhancementState) {
|
|
1850
|
-
Object.keys(enhancementState).forEach((k) => {
|
|
1851
|
-
if (!/^_|^theme./.test(k)) {
|
|
1852
|
-
const enhancementKey = enhancementState._id + '/' + k
|
|
1853
|
-
const extn = data.overlays.get(enhancementKey)
|
|
1854
|
-
if (extn && !extn.isInitialized) {
|
|
1855
|
-
updateOverlays(
|
|
1856
|
-
enhancementKey,
|
|
1857
|
-
Object.assign(
|
|
1858
|
-
{
|
|
1859
|
-
behaviors: false,
|
|
1860
|
-
isLocked: false,
|
|
1861
|
-
isInitialized: true,
|
|
1862
|
-
isRoot: false,
|
|
1863
|
-
parentKey: key,
|
|
1864
|
-
depth: ovr.depth + 1,
|
|
1865
|
-
hasFormField: false,
|
|
1866
|
-
isEnhancement: true,
|
|
1867
|
-
parentRoot: ovr.parentRoot,
|
|
1868
|
-
},
|
|
1869
|
-
extn,
|
|
1870
|
-
),
|
|
1871
|
-
ovr,
|
|
1872
|
-
)
|
|
1873
|
-
}
|
|
1874
|
-
}
|
|
1875
|
-
})
|
|
1876
|
-
}
|
|
1877
|
-
})
|
|
1878
|
-
}
|
|
1879
|
-
|
|
1880
|
-
const rteContainer = contentEditElement.querySelector(
|
|
1881
|
-
'[data-rte-container="true"]',
|
|
1882
|
-
),
|
|
1883
|
-
textarea = contentEditElement.querySelector('textarea')
|
|
1884
|
-
|
|
1885
|
-
if (rteContainer && textarea) {
|
|
1886
|
-
if (rteContainer.dataset.value) {
|
|
1887
|
-
updateEnhancements(rteContainer.dataset.value)
|
|
1888
|
-
} else if (textarea.value) {
|
|
1889
|
-
// Fallback on textarea value if the rteContainer is not scrolled into
|
|
1890
|
-
updateEnhancements(textarea.value)
|
|
1891
|
-
}
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
const rcsItems = rcs?.querySelectorAll(`input[name="${key}"]`)
|
|
1895
|
-
children?.forEach((childKey, idx) => {
|
|
1896
|
-
const existing = data.overlays.get(childKey)
|
|
1897
|
-
let childId = childKey.split('/')[0]
|
|
1898
|
-
let rcsItem
|
|
1899
|
-
let isSharedItem
|
|
1900
|
-
let editAction = `${key}_${childId}_acEdit`
|
|
1901
|
-
if (rcs) {
|
|
1902
|
-
rcsItem = [...rcsItems].find((rItem) => {
|
|
1903
|
-
return rItem.value === childId
|
|
1904
|
-
})
|
|
1905
|
-
isSharedItem = isShared(childId, rcsItem, undefined, key)
|
|
1906
|
-
if (isSharedItem) {
|
|
1907
|
-
isSharedItem.dataset.previewAction = editAction
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
const overlayData = {
|
|
1911
|
-
id: childId,
|
|
1912
|
-
isInitialized: true,
|
|
1913
|
-
parentKey: key,
|
|
1914
|
-
parentRoot: ovr.parentRoot,
|
|
1915
|
-
depth: ovr.depth + 1,
|
|
1916
|
-
type: 'bspModule',
|
|
1917
|
-
name: childKey.split('/')[1],
|
|
1918
|
-
isShared: rcsItem && isSharedItem ? editAction : false,
|
|
1919
|
-
hasFormField: true,
|
|
1920
|
-
}
|
|
1921
|
-
if (rcsItem && rcsItem.dataset.label) {
|
|
1922
|
-
overlayData.label = rcsItem.dataset.label
|
|
1923
|
-
}
|
|
1924
|
-
if (!isCigSelect) {
|
|
1925
|
-
if (existing) {
|
|
1926
|
-
updateOverlays(
|
|
1927
|
-
childKey,
|
|
1928
|
-
Object.assign(overlayData, existing),
|
|
1929
|
-
ovr,
|
|
1930
|
-
)
|
|
1931
|
-
} else {
|
|
1932
|
-
updateOverlays(childKey, overlayData, ovr)
|
|
1933
|
-
data.overlays.set(childKey, Object.assign({}, overlayData))
|
|
1934
|
-
}
|
|
1935
|
-
getEditElements(
|
|
1936
|
-
childKey.split('/')[0],
|
|
1937
|
-
contentEditElement,
|
|
1938
|
-
ovr,
|
|
1939
|
-
key,
|
|
1940
|
-
childKey,
|
|
1941
|
-
)
|
|
1942
|
-
} else {
|
|
1943
|
-
getEditElements(
|
|
1944
|
-
childKey.split('/')[0],
|
|
1945
|
-
contentEditElement,
|
|
1946
|
-
realParent,
|
|
1947
|
-
realParentKey,
|
|
1948
|
-
childKey,
|
|
1949
|
-
)
|
|
1950
|
-
}
|
|
1951
|
-
})
|
|
1952
|
-
})
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1955
|
-
getEditElements(data.previewContainerId, document)
|
|
1956
|
-
// filters out dropdown fields that do not have children preview elements
|
|
1957
|
-
const dropdownOverlays = [...filteredOverlays.values()].filter((t) => {
|
|
1958
|
-
return t.isDropdown && !t.linked && !t.isShared
|
|
1959
|
-
})
|
|
1960
|
-
|
|
1961
|
-
dropdownOverlays.forEach((s) => {
|
|
1962
|
-
const k = s.id + '/' + s.name
|
|
1963
|
-
const hasAChild = [...filteredOverlays.values()].find((t) => {
|
|
1964
|
-
return t.parentKey === k && t.dimensions
|
|
1965
|
-
})
|
|
1966
|
-
if (!hasAChild) {
|
|
1967
|
-
filteredOverlays.delete(k)
|
|
1968
|
-
} else {
|
|
1969
|
-
delete s.isDropdown
|
|
1970
|
-
}
|
|
1971
|
-
})
|
|
1972
|
-
|
|
1973
|
-
if (previewOverlays.get(data.previewContainerId)) {
|
|
1974
|
-
// reload preview overlay frame for every preview refresh
|
|
1975
|
-
let prevFrame = getPreviewFrame(data.previewContainerId)
|
|
1976
|
-
previewOverlays
|
|
1977
|
-
.get(data.previewContainerId)
|
|
1978
|
-
?._overlayFrame.contentDocument.getElementsByTagName('html')[0]
|
|
1979
|
-
.style.setProperty(
|
|
1980
|
-
'--PreviewScale',
|
|
1981
|
-
prevFrame.getAttribute('previewScale'),
|
|
1982
|
-
)
|
|
1983
|
-
|
|
1984
|
-
previewOverlays
|
|
1985
|
-
.get(data.previewContainerId)
|
|
1986
|
-
.reload(filteredOverlays, data, selectedViewport)
|
|
1987
|
-
} else {
|
|
1988
|
-
// initialize preview overlay frame when preview is loaded the first time
|
|
1989
|
-
const overlay = await PreviewOverlay.create(data)
|
|
1990
|
-
previewOverlays.set(data.previewContainerId, overlay)
|
|
1991
|
-
previewOverlays
|
|
1992
|
-
.get(data.previewContainerId)
|
|
1993
|
-
.reload(filteredOverlays, data, selectedViewport)
|
|
1994
|
-
onRemove(
|
|
1995
|
-
previewOverlays.get(data.previewContainerId)._overlayFrame,
|
|
1996
|
-
() => {
|
|
1997
|
-
previewOverlays.get(data.previewContainerId).destroy()
|
|
1998
|
-
delete previewOverlays.get(data.previewContainerId)
|
|
1999
|
-
previewOverlays.delete(data.previewContainerId)
|
|
2000
|
-
},
|
|
2001
|
-
)
|
|
2002
|
-
}
|
|
2003
|
-
} else if (type === 'BSP.Preview.OverlayActionClick') {
|
|
2004
|
-
const key = data.key
|
|
2005
|
-
const cig = document.querySelector(`.CIG-row[data-name="${key}"]`)
|
|
2006
|
-
const modal = document.querySelector('.ContentEdit-previewModal')
|
|
2007
|
-
const edit = document.querySelector(
|
|
2008
|
-
`.ContentEdit[data-object-id="${data.previewContainerId}"]`,
|
|
2009
|
-
)
|
|
2010
|
-
|
|
2011
|
-
if (data.handler) {
|
|
2012
|
-
const element = data.elementId
|
|
2013
|
-
? document.querySelector(
|
|
2014
|
-
`.repeatableLabel[data-object-id="${data.elementId}"]`,
|
|
2015
|
-
)
|
|
2016
|
-
: null
|
|
2017
|
-
const li = element.parentElement
|
|
2018
|
-
|
|
2019
|
-
if (data.handler === 'moveUp') {
|
|
2020
|
-
li.parentElement.insertBefore(li, li.previousElementSibling)
|
|
2021
|
-
} else if (data.handler === 'moveDown') {
|
|
2022
|
-
li.parentElement.insertBefore(
|
|
2023
|
-
li,
|
|
2024
|
-
li.nextElementSibling?.nextElementSibling,
|
|
2025
|
-
)
|
|
2026
|
-
}
|
|
2027
|
-
|
|
2028
|
-
edit.dispatchEvent(new Event('change', { bubbles: true }))
|
|
2029
|
-
return
|
|
2030
|
-
}
|
|
2031
|
-
|
|
2032
|
-
if (data.internalType === 'text') {
|
|
2033
|
-
openFormFieldPopup(cig, modal, edit)
|
|
2034
|
-
} else {
|
|
2035
|
-
const element = data.elementId
|
|
2036
|
-
? document.querySelector(
|
|
2037
|
-
`.repeatableLabel[data-object-id="${data.elementId}"]`,
|
|
2038
|
-
)
|
|
2039
|
-
: null
|
|
2040
|
-
const parent = element ? element.parentNode : document
|
|
2041
|
-
const behaviorEl = parent.querySelector(
|
|
2042
|
-
`[data-preview-action="${data.actionId}"]`,
|
|
2043
|
-
)
|
|
2044
|
-
if (behaviorEl.classList.contains('RCIG-addSelect')) {
|
|
2045
|
-
onFind(behaviorEl, ':scope > .ComboInput', (combo) => {
|
|
2046
|
-
combo.click()
|
|
2047
|
-
})
|
|
2048
|
-
} else {
|
|
2049
|
-
behaviorEl.click()
|
|
2050
|
-
}
|
|
2051
|
-
if (element && behaviorEl.classList.contains('removeButton')) {
|
|
2052
|
-
element.click()
|
|
2053
|
-
scrollIntoView(element)
|
|
2054
|
-
}
|
|
2055
|
-
if (behaviorEl.classList.contains('RCIG-add')) {
|
|
2056
|
-
const rcig = behaviorEl.closest('.RCIG')
|
|
2057
|
-
onFind(
|
|
2058
|
-
rcig,
|
|
2059
|
-
':scope > .RCIG-list > li.RCIG-item.is-new-item',
|
|
2060
|
-
(item) => {
|
|
2061
|
-
openFormFieldPopup(item, modal, edit)
|
|
2062
|
-
},
|
|
2063
|
-
)
|
|
2064
|
-
} else if (behaviorEl.classList.contains('RCS-add')) {
|
|
2065
|
-
const rcs = behaviorEl.closest('.RCS')
|
|
2066
|
-
const label = data.label
|
|
2067
|
-
onFind(rcs, ':scope > .RCS-list > li.RCS-item.is-new-item', (item) => {
|
|
2068
|
-
openFormFieldPopup(item, modal, edit, label)
|
|
2069
|
-
})
|
|
2070
|
-
} else if (behaviorEl.classList.contains('EIG-add')) {
|
|
2071
|
-
const eig = behaviorEl.closest('.EIG')
|
|
2072
|
-
onFind(eig, ':scope > .EIG-item', (item) => {
|
|
2073
|
-
openFormFieldPopup(item, modal, edit)
|
|
2074
|
-
})
|
|
2075
|
-
} else {
|
|
2076
|
-
const item = behaviorEl.closest('.RCIG-item, .EIG-item')
|
|
2077
|
-
openFormFieldPopup(item, modal, edit)
|
|
2078
|
-
}
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
})
|
|
2082
|
-
|
|
2083
|
-
// ContentEdit Utils:
|
|
2084
|
-
// Check if this element is a shared / non-embedded element.
|
|
2085
|
-
const isShared = (id, element, fieldValue, parentId) => {
|
|
2086
|
-
if (element === null) return
|
|
2087
|
-
let sharedElement
|
|
2088
|
-
let input = element.querySelector(`input[name="${id}"]`)
|
|
2089
|
-
|
|
2090
|
-
if (input && !parentId) {
|
|
2091
|
-
// Try to find an associated input via the fieldValue.
|
|
2092
|
-
// Otherwise, fallback on the found input.
|
|
2093
|
-
if (fieldValue) {
|
|
2094
|
-
input =
|
|
2095
|
-
element.querySelector(
|
|
2096
|
-
`input[name="${fieldValue}/` + `${id.split('/')[1]}"]`,
|
|
2097
|
-
) ?? input
|
|
2098
|
-
}
|
|
2099
|
-
|
|
2100
|
-
// Keep looking for the edit element.
|
|
2101
|
-
if (input) {
|
|
2102
|
-
sharedElement =
|
|
2103
|
-
!(
|
|
2104
|
-
input.parentNode.classList.contains('RCIG-item') ||
|
|
2105
|
-
input.parentNode.classList.contains('RCS-item')
|
|
2106
|
-
) && input.parentNode.querySelector(':scope > .ContentSelector-edit')
|
|
2107
|
-
}
|
|
2108
|
-
} else {
|
|
2109
|
-
// We may have started with an input element
|
|
2110
|
-
// in the case of a child overlay.
|
|
2111
|
-
// This happens with RCS items.
|
|
2112
|
-
if (element.getAttribute('name') === parentId) {
|
|
2113
|
-
// try to find the edit element from the parent
|
|
2114
|
-
sharedElement = element.parentNode.querySelector(
|
|
2115
|
-
':scope > .ContentSelector-edit',
|
|
2116
|
-
)
|
|
2117
|
-
}
|
|
2118
|
-
}
|
|
2119
|
-
|
|
2120
|
-
return sharedElement
|
|
2121
|
-
}
|
|
2122
|
-
|
|
2123
|
-
//Check if there is field-level/content level locking
|
|
2124
|
-
const isLocked = (element) => {
|
|
2125
|
-
return element.closest('.is-readOnly')
|
|
2126
|
-
? true
|
|
2127
|
-
: null ||
|
|
2128
|
-
element.classList.contains('is-readOnly') ||
|
|
2129
|
-
element.classList.contains('is-pending') ||
|
|
2130
|
-
element.closest('.is-pending')
|
|
2131
|
-
? true
|
|
2132
|
-
: null || element.closest('.is-locked')
|
|
2133
|
-
? true
|
|
2134
|
-
: null
|
|
2135
|
-
}
|
|
2136
|
-
|
|
2137
|
-
// Updates the guide based on the input.
|
|
2138
|
-
function updateGuide(input, value) {
|
|
2139
|
-
if (!input.closest('.Page.is-guideOpen')) {
|
|
2140
|
-
return
|
|
2141
|
-
}
|
|
2142
|
-
|
|
2143
|
-
// Figure out the path to the input.
|
|
2144
|
-
const focuses = []
|
|
2145
|
-
|
|
2146
|
-
for (let group = input, row; (row = group.closest('.CIG-row')); ) {
|
|
2147
|
-
group = row.closest('.CIG')
|
|
2148
|
-
|
|
2149
|
-
focuses.unshift({
|
|
2150
|
-
typeId: group.dataset.typeId,
|
|
2151
|
-
field: row.dataset.fieldName,
|
|
2152
|
-
})
|
|
2153
|
-
}
|
|
2154
|
-
|
|
2155
|
-
if (focuses.length < 1) {
|
|
2156
|
-
return
|
|
2157
|
-
}
|
|
2158
|
-
|
|
2159
|
-
let selector = ''
|
|
2160
|
-
|
|
2161
|
-
for (let i = 0, l = focuses.length; i < l; ++i) {
|
|
2162
|
-
const { typeId, field } = focuses[i]
|
|
2163
|
-
selector += `.Guide-content[data-type-id="${typeId}"] > .Guide-field[data-field="${field}"] `
|
|
2164
|
-
|
|
2165
|
-
if (i + 1 === l) {
|
|
2166
|
-
const select = document.querySelector(`${selector} > form > select`)
|
|
2167
|
-
|
|
2168
|
-
if (select) {
|
|
2169
|
-
select.value = value(focuses[i])
|
|
2170
|
-
select.dispatchEvent(new Event('change', { bubbles: true }))
|
|
2171
|
-
}
|
|
2172
|
-
}
|
|
2173
|
-
}
|
|
2174
|
-
|
|
2175
|
-
// Focus and scroll to the corresponding section in the guide.
|
|
2176
|
-
const observer = new MutationObserver(async () => {
|
|
2177
|
-
const field = document.querySelector(selector)
|
|
2178
|
-
|
|
2179
|
-
if (field) {
|
|
2180
|
-
observer.disconnect()
|
|
2181
|
-
field.scrollIntoView()
|
|
2182
|
-
field.classList.add('is-focus')
|
|
2183
|
-
}
|
|
2184
|
-
})
|
|
2185
|
-
|
|
2186
|
-
observer.observe(document, {
|
|
2187
|
-
attributes: true,
|
|
2188
|
-
childList: true,
|
|
2189
|
-
subtree: true,
|
|
2190
|
-
})
|
|
2191
|
-
}
|
|
2192
|
-
|
|
2193
|
-
// Update the guide when the user focuses into an input.
|
|
2194
|
-
onFind(['.ContentEdit', '.enhancementForm', '.standardForm'], (edit) => {
|
|
2195
|
-
edit.addEventListener('focusin', ({ target }) => {
|
|
2196
|
-
updateGuide(target, (focus) => focus.typeId)
|
|
2197
|
-
})
|
|
2198
|
-
|
|
2199
|
-
edit.addEventListener('focusout', () => {
|
|
2200
|
-
for (const field of document.querySelectorAll('.Guide-field')) {
|
|
2201
|
-
field.classList.remove('is-focus')
|
|
2202
|
-
}
|
|
2203
|
-
})
|
|
2204
|
-
})
|
|
2205
|
-
|
|
2206
|
-
// Update the guide when the user selects a different embedded form.
|
|
2207
|
-
onFind(
|
|
2208
|
-
'.CIG-row[data-type="record"] > .CIG-small > select, .CIG-row[data-type="record"] > .CIG-small > btu-toggleable > select',
|
|
2209
|
-
(select) => {
|
|
2210
|
-
select.addEventListener('change', () => {
|
|
2211
|
-
updateGuide(select, () => {
|
|
2212
|
-
const i = select.selectedIndex
|
|
2213
|
-
return i >= 0 ? select.options[i].dataset.type : null
|
|
2214
|
-
})
|
|
2215
|
-
})
|
|
2216
|
-
},
|
|
2217
|
-
)
|
|
2218
|
-
|
|
2219
|
-
// Update the guide based on the initial form state.
|
|
2220
|
-
onFind('.Guide-field.is-embedded', (field) => {
|
|
2221
|
-
const select = field.querySelector('select')
|
|
2222
|
-
if (!select) return
|
|
2223
|
-
|
|
2224
|
-
const typeId = field.closest('.Guide-content[data-type-id]')?.dataset?.typeId
|
|
2225
|
-
if (!typeId) return
|
|
2226
|
-
|
|
2227
|
-
const value = document.querySelector(
|
|
2228
|
-
`.CIG[data-type-id='${typeId}'] > .CIG-row[data-field-name='${field.dataset.field}'] .CIG`,
|
|
2229
|
-
)?.dataset?.typeId
|
|
2230
|
-
|
|
2231
|
-
if (value) {
|
|
2232
|
-
select.value = value
|
|
2233
|
-
select.dispatchEvent(new Event('change', { bubbles: true }))
|
|
2234
|
-
select.form.requestSubmit()
|
|
2235
|
-
}
|
|
2236
|
-
})
|
|
2237
|
-
|
|
2238
|
-
// track which right panel is open
|
|
2239
|
-
const panelKey = 'BSP.ContentEdit.rightPanel'
|
|
2240
|
-
|
|
2241
|
-
const togglePanel = (tab, panel, options) => {
|
|
2242
|
-
const show = tab.classList.toggle('is-active')
|
|
2243
|
-
tab.ariaExpanded = show
|
|
2244
|
-
panel.classList.toggle('is-visible', show)
|
|
2245
|
-
const label = panel.querySelector('.ContentEdit-right-title')?.textContent
|
|
2246
|
-
tab.ariaLabel = `${show ? tooltips.close : tooltips.open} ${label}`
|
|
2247
|
-
tab.title = tab.ariaLabel
|
|
2248
|
-
|
|
2249
|
-
// Manage has-widget-panel-open class for performance (replaces expensive :has() selectors)
|
|
2250
|
-
// Only manage for widget panels, not for manage_search (shelf)
|
|
2251
|
-
if (tab.dataset.iconButtonName !== 'manage_search') {
|
|
2252
|
-
const toolbar = tab.closest('.ContentEdit-toolbar')
|
|
2253
|
-
const containerEl =
|
|
2254
|
-
options?.container ||
|
|
2255
|
-
toolbar?.closest('.Page-content, .Popup-content, .Popup')
|
|
2256
|
-
|
|
2257
|
-
if (containerEl) {
|
|
2258
|
-
if (show) {
|
|
2259
|
-
// Opening a widget panel - add the class
|
|
2260
|
-
containerEl.classList.add('has-widget-panel-open')
|
|
2261
|
-
} else {
|
|
2262
|
-
// Closing a widget panel - only remove class if no other widget panels are active
|
|
2263
|
-
const hasOtherActivePanel = toolbar?.querySelector(
|
|
2264
|
-
'button.is-active:not([data-icon-button-name="manage_search"])',
|
|
2265
|
-
)
|
|
2266
|
-
if (!hasOtherActivePanel) {
|
|
2267
|
-
containerEl.classList.remove('has-widget-panel-open')
|
|
2268
|
-
}
|
|
2269
|
-
}
|
|
2270
|
-
}
|
|
2271
|
-
}
|
|
2272
|
-
|
|
2273
|
-
if (!options) return
|
|
2274
|
-
const { container, updateStorage } = options
|
|
2275
|
-
let contentRightWidth
|
|
2276
|
-
if (container) {
|
|
2277
|
-
if (show) {
|
|
2278
|
-
contentRightWidth = panel.dataset.width
|
|
2279
|
-
} else {
|
|
2280
|
-
contentRightWidth = '0px'
|
|
2281
|
-
}
|
|
2282
|
-
container.style.setProperty('--ContentEdit-rightWidth', contentRightWidth)
|
|
2283
|
-
}
|
|
2284
|
-
if (!container.classList.contains('Popup') && updateStorage) {
|
|
2285
|
-
if (show) {
|
|
2286
|
-
ls.setItem(panelKey, tab.dataset.iconButtonName)
|
|
2287
|
-
} else {
|
|
2288
|
-
ls.removeItem(panelKey)
|
|
2289
|
-
}
|
|
2290
|
-
}
|
|
2291
|
-
}
|
|
2292
|
-
|
|
2293
|
-
// Content edit side toolbar functionality
|
|
2294
|
-
onFind('.ContentEdit-toolbar', (toolbar) => {
|
|
2295
|
-
// by default only toolbar is visible
|
|
2296
|
-
const container = toolbar.closest('.Page-content, .Popup-content, .Popup')
|
|
2297
|
-
// This variable will be updated with panel width
|
|
2298
|
-
container.style.setProperty('--ContentEdit-rightWidth', '0px')
|
|
2299
|
-
const editForm = toolbar.closest('.ContentEdit')
|
|
2300
|
-
if (!editForm) return
|
|
2301
|
-
const formId = editForm.dataset.objectId
|
|
2302
|
-
const selectedPanel = ls.getItem(panelKey)
|
|
2303
|
-
const tabButtons = [...toolbar.querySelectorAll('button[data-right-tab]')]
|
|
2304
|
-
|
|
2305
|
-
tabButtons.forEach((tab) => {
|
|
2306
|
-
// Shelf is handled by ContentEditDrawer.ts
|
|
2307
|
-
if (tab.dataset.iconButtonName === 'manage_search') {
|
|
2308
|
-
return
|
|
2309
|
-
}
|
|
2310
|
-
|
|
2311
|
-
const iconName = tab.dataset.iconButtonName
|
|
2312
|
-
const panel = editForm.querySelector(
|
|
2313
|
-
`.ContentEdit-right[data-right-tab="${iconName}"]`,
|
|
2314
|
-
)
|
|
2315
|
-
if (!panel) return
|
|
2316
|
-
const panelId = formId + '/' + iconName
|
|
2317
|
-
panel.id = panelId
|
|
2318
|
-
|
|
2319
|
-
if (!panel.dataset.width) {
|
|
2320
|
-
const computedWidth = getComputedStyle(panel).getPropertyValue(
|
|
2321
|
-
'--contentRight-width',
|
|
2322
|
-
)
|
|
2323
|
-
|
|
2324
|
-
panel.dataset.width = parseFloat(computedWidth) ? computedWidth : '320px'
|
|
2325
|
-
}
|
|
2326
|
-
|
|
2327
|
-
tab.setAttribute('aria-controls', panel.id)
|
|
2328
|
-
const labelOpen = `${tooltips.open} ${tab.ariaLabel}`
|
|
2329
|
-
tab.ariaLabel = labelOpen
|
|
2330
|
-
tab.title = labelOpen
|
|
2331
|
-
tab.ariaExpanded = false
|
|
2332
|
-
|
|
2333
|
-
onFind('.ContentEdit-right .Widget.is-error', (widget) => {
|
|
2334
|
-
const panel = widget.closest('.ContentEdit-right')
|
|
2335
|
-
if (!panel) return
|
|
2336
|
-
const tab = document.querySelector(`button[aria-controls="${panel.id}"]`)
|
|
2337
|
-
if (!tab) return
|
|
2338
|
-
tab.classList.add('is-error')
|
|
2339
|
-
})
|
|
2340
|
-
|
|
2341
|
-
const panelClose = panel.querySelector('.ContentEdit-right-close')
|
|
2342
|
-
panelClose.ariaLabel = tooltips.close
|
|
2343
|
-
panelClose.title = tooltips.close
|
|
2344
|
-
panelClose.onclick = () => {
|
|
2345
|
-
togglePanel(tab, panel, { container: container, updateStorage: true })
|
|
2346
|
-
// Return focus to the toolbar button when panel is closed
|
|
2347
|
-
tab.focus()
|
|
2348
|
-
}
|
|
2349
|
-
|
|
2350
|
-
tab.onclick = (event) => {
|
|
2351
|
-
const prevSelected = toolbar.querySelector(
|
|
2352
|
-
'button.is-active:not([data-icon-button-name="manage_search"])',
|
|
2353
|
-
)
|
|
2354
|
-
const wasOpen = tab.classList.contains('is-active')
|
|
2355
|
-
|
|
2356
|
-
// V5 UI: close preview if space is limited and we're opening a widget panel
|
|
2357
|
-
if (
|
|
2358
|
-
window.BRIGHTSPOT?.ui?.cms?.enableV5UI &&
|
|
2359
|
-
!wasOpen &&
|
|
2360
|
-
container.classList.contains('is-previewing')
|
|
2361
|
-
) {
|
|
2362
|
-
if (container.offsetWidth < DUAL_PANEL_MIN_WIDTH) {
|
|
2363
|
-
const previewButton = toolbar.querySelector(
|
|
2364
|
-
'.ContentEdit-previewButton',
|
|
2365
|
-
)
|
|
2366
|
-
previewButton?.click()
|
|
2367
|
-
}
|
|
2368
|
-
}
|
|
2369
|
-
|
|
2370
|
-
togglePanel(tab, panel, { container: container, updateStorage: true })
|
|
2371
|
-
|
|
2372
|
-
if (!prevSelected) {
|
|
2373
|
-
if (!window.BRIGHTSPOT?.ui.cms.enableV5UI) {
|
|
2374
|
-
if (container.classList.contains('is-previewing')) {
|
|
2375
|
-
const previewButton = toolbar.querySelector(
|
|
2376
|
-
'.ContentEdit-previewButton',
|
|
2377
|
-
)
|
|
2378
|
-
previewButton.click()
|
|
2379
|
-
}
|
|
2380
|
-
}
|
|
2381
|
-
} else if (prevSelected.dataset.iconButtonName !== iconName) {
|
|
2382
|
-
const prevPanel = editForm.querySelector(
|
|
2383
|
-
`.ContentEdit-right.is-visible[data-right-tab=${prevSelected.dataset.iconButtonName}]`,
|
|
2384
|
-
)
|
|
2385
|
-
togglePanel(prevSelected, prevPanel)
|
|
2386
|
-
}
|
|
2387
|
-
// Move focus to the close button when panel is opened by user interaction.
|
|
2388
|
-
// We wait for `transitionend` instead of using setTimeout because the
|
|
2389
|
-
// duration may be near-zero under prefers-reduced-motion (see Page.css).
|
|
2390
|
-
if (!wasOpen && tab.classList.contains('is-active') && event.isTrusted) {
|
|
2391
|
-
container.addEventListener(
|
|
2392
|
-
'transitionend',
|
|
2393
|
-
function handleTransitionEnd(e) {
|
|
2394
|
-
// The grid opens via grid-template-columns; ignore other property firings
|
|
2395
|
-
// to avoid calling focus() multiple times in a single transition sequence.
|
|
2396
|
-
if (e.propertyName !== 'grid-template-columns') return
|
|
2397
|
-
// Always remove unconditionally — prevents leak if panel closes mid-transition.
|
|
2398
|
-
container.removeEventListener('transitionend', handleTransitionEnd)
|
|
2399
|
-
if (tab.classList.contains('is-active')) {
|
|
2400
|
-
panelClose.focus()
|
|
2401
|
-
}
|
|
2402
|
-
},
|
|
2403
|
-
)
|
|
2404
|
-
}
|
|
2405
|
-
}
|
|
2406
|
-
|
|
2407
|
-
if (selectedPanel === iconName) {
|
|
2408
|
-
tab.click()
|
|
2409
|
-
}
|
|
2410
|
-
})
|
|
2411
|
-
|
|
2412
|
-
// V5 UI: Close preview when container becomes too narrow for both panels
|
|
2413
|
-
if (window.BRIGHTSPOT?.ui?.cms?.enableV5UI) {
|
|
2414
|
-
new ResizeObserver(() => {
|
|
2415
|
-
if (
|
|
2416
|
-
container.offsetWidth < DUAL_PANEL_MIN_WIDTH &&
|
|
2417
|
-
container.classList.contains('is-previewing') &&
|
|
2418
|
-
container.querySelector('.ContentEdit-right.is-visible')
|
|
2419
|
-
) {
|
|
2420
|
-
const previewButton = toolbar.querySelector(
|
|
2421
|
-
'.ContentEdit-previewButton',
|
|
2422
|
-
)
|
|
2423
|
-
previewButton?.click()
|
|
2424
|
-
}
|
|
2425
|
-
}).observe(container)
|
|
2426
|
-
}
|
|
2427
|
-
})
|