@instructure/canvas-rce 5.14.2 → 5.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/DEVELOPMENT.md +1 -1
  3. package/es/bridge/Bridge.js +10 -17
  4. package/es/canvasFileBrowser/FileBrowser.js +10 -19
  5. package/es/common/FlashAlert.js +8 -11
  6. package/es/common/fileUrl.js +6 -10
  7. package/es/common/incremental-loading/LoadMoreButton.js +3 -4
  8. package/es/common/incremental-loading/LoadingStatus.js +4 -11
  9. package/es/common/indicate.js +1 -2
  10. package/es/defaultTinymceConfig.js +1 -1
  11. package/es/enhance-user-content/doc_previews.js +10 -10
  12. package/es/enhance-user-content/enhance_user_content.js +4 -7
  13. package/es/enhance-user-content/external_links.js +1 -1
  14. package/es/enhance-user-content/instructure_helper.js +11 -17
  15. package/es/enhance-user-content/mathml.js +15 -27
  16. package/es/enhance-user-content/media_comment_thumbnail.js +3 -10
  17. package/es/format-message.js +2 -2
  18. package/es/index.d.ts +59 -0
  19. package/es/index.js +3 -5
  20. package/es/rce/AlertMessageArea.js +15 -16
  21. package/es/rce/KeyboardShortcutModal.js +2 -2
  22. package/es/rce/RCE.js +6 -8
  23. package/es/rce/RCEVariants.js +2 -4
  24. package/es/rce/RCEWrapper.js +397 -289
  25. package/es/rce/RCEWrapper.utils.js +131 -0
  26. package/es/rce/RCEWrapperProps.js +2 -3
  27. package/es/rce/RceHtmlEditor.js +12 -11
  28. package/es/rce/ResizeHandle.js +1 -2
  29. package/es/rce/ShowOnFocusButton/index.js +2 -2
  30. package/es/rce/StatusBar.js +5 -10
  31. package/es/rce/contentInsertion.js +1 -2
  32. package/es/rce/contentRendering.js +6 -5
  33. package/es/rce/editorLanguage.js +1 -1
  34. package/es/rce/indicatorRegion.js +1 -2
  35. package/es/rce/normalizeProps.js +4 -4
  36. package/es/rce/plugins/instructure_color/clickCallback.js +2 -4
  37. package/es/rce/plugins/instructure_color/components/ColorPicker.js +17 -22
  38. package/es/rce/plugins/instructure_color/components/ColorPopup.js +7 -8
  39. package/es/rce/plugins/instructure_condensed_buttons/ui/list-button.js +4 -10
  40. package/es/rce/plugins/instructure_condensed_buttons/ui/subscript-superscript-button.js +1 -1
  41. package/es/rce/plugins/instructure_documents/components/Link.js +1 -2
  42. package/es/rce/plugins/instructure_equation/EquationEditorModal/index.js +5 -8
  43. package/es/rce/plugins/instructure_equation/EquationEditorModal/latexTextareaUtil.js +3 -3
  44. package/es/rce/plugins/instructure_equation/EquationEditorModal/parseLatex.js +3 -3
  45. package/es/rce/plugins/instructure_equation/EquationEditorToolbar/buttons.js +2 -2
  46. package/es/rce/plugins/instructure_equation/EquationEditorToolbar/index.js +9 -11
  47. package/es/rce/plugins/instructure_equation/MathIcon/index.js +3 -4
  48. package/es/rce/plugins/instructure_equation/mathlive/index.js +167 -16
  49. package/es/rce/plugins/instructure_fullscreen/plugin.js +0 -2
  50. package/es/rce/plugins/instructure_icon_maker/clickCallback.js +3 -4
  51. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ColorSection.js +46 -49
  52. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/CreateIconMakerForm.js +9 -10
  53. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Footer.js +10 -11
  54. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Group.js +5 -6
  55. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Header.js +7 -8
  56. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/Course.js +7 -9
  57. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/ImageOptions.js +19 -26
  58. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/ImageSection.js +8 -12
  59. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/ModeSelect.js +6 -7
  60. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/MultiColor/index.js +5 -6
  61. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SVGList.js +6 -7
  62. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SVGThumbnail.js +8 -10
  63. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SingleColor/index.js +5 -6
  64. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SingleColor/svg.js +32 -80
  65. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/Upload.js +7 -8
  66. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/utils.js +4 -5
  67. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Preview.js +3 -4
  68. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ShapeSection.js +4 -5
  69. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/TextSection.js +4 -5
  70. package/es/rce/plugins/instructure_icon_maker/components/IconMakerTray.js +22 -29
  71. package/es/rce/plugins/instructure_icon_maker/registerEditToolbar.js +1 -1
  72. package/es/rce/plugins/instructure_icon_maker/svg/image.js +5 -7
  73. package/es/rce/plugins/instructure_icon_maker/svg/index.js +6 -9
  74. package/es/rce/plugins/instructure_icon_maker/svg/settings.js +17 -20
  75. package/es/rce/plugins/instructure_icon_maker/svg/shape.js +4 -5
  76. package/es/rce/plugins/instructure_icon_maker/svg/text.js +28 -32
  77. package/es/rce/plugins/instructure_icon_maker/svg/utils.js +2 -4
  78. package/es/rce/plugins/instructure_icon_maker/utils/IconMakerClose.js +2 -3
  79. package/es/rce/plugins/instructure_icon_maker/utils/iconValidation.js +1 -2
  80. package/es/rce/plugins/instructure_image/ImageEmbedOptions.js +3 -7
  81. package/es/rce/plugins/instructure_image/ImageList/Image.js +7 -8
  82. package/es/rce/plugins/instructure_image/ImageList/index.js +7 -8
  83. package/es/rce/plugins/instructure_image/ImageOptionsTray/TrayController.js +2 -4
  84. package/es/rce/plugins/instructure_image/ImageOptionsTray/index.js +3 -3
  85. package/es/rce/plugins/instructure_image/plugin.js +1 -2
  86. package/es/rce/plugins/instructure_links/components/AccordionSection.js +7 -8
  87. package/es/rce/plugins/instructure_links/components/Link.js +61 -65
  88. package/es/rce/plugins/instructure_links/components/LinkOptionsDialog/LinkOptionsDialogController.js +1 -2
  89. package/es/rce/plugins/instructure_links/components/LinkOptionsDialog/index.js +2 -2
  90. package/es/rce/plugins/instructure_links/components/LinkOptionsTray/index.js +2 -2
  91. package/es/rce/plugins/instructure_links/components/LinkSet.js +28 -37
  92. package/es/rce/plugins/instructure_links/components/LinksPanel.js +21 -8
  93. package/es/rce/plugins/instructure_links/components/NoResults.js +6 -7
  94. package/es/rce/plugins/instructure_links/plugin.js +6 -9
  95. package/es/rce/plugins/instructure_media_embed/clickCallback.js +3 -4
  96. package/es/rce/plugins/instructure_media_embed/components/Embed.js +6 -7
  97. package/es/rce/plugins/instructure_paste/plugin.js +5 -7
  98. package/es/rce/plugins/instructure_rce_external_tools/ExternalToolsEnv.js +24 -33
  99. package/es/rce/plugins/instructure_rce_external_tools/RceToolWrapper.js +7 -38
  100. package/es/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialog.js +30 -29
  101. package/es/rce/plugins/instructure_rce_external_tools/components/ExternalToolSelectionDialog/ExternalToolSelectionDialog.js +3 -4
  102. package/es/rce/plugins/instructure_rce_external_tools/dialog-helper.js +1 -2
  103. package/es/rce/plugins/instructure_rce_external_tools/jquery/jquery.dropdownList.js +3 -4
  104. package/es/rce/plugins/instructure_rce_external_tools/lti11-content-items/RceLti11ContentItem.js +17 -24
  105. package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/RceLti13ContentItem.js +2 -2
  106. package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/BaseLinkContentItem.js +4 -5
  107. package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/processEditorContentItems.js +8 -9
  108. package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/rceLti13ContentItemFromJson.js +0 -1
  109. package/es/rce/plugins/instructure_rce_external_tools/plugin.js +4 -4
  110. package/es/rce/plugins/instructure_rce_external_tools/util/externalToolsForToolbar.js +42 -0
  111. package/es/rce/plugins/instructure_record/AudioOptionsTray/TrayController.js +5 -10
  112. package/es/rce/plugins/instructure_record/AudioOptionsTray/index.js +12 -13
  113. package/es/rce/plugins/instructure_record/VideoOptionsTray/TrayController.js +8 -15
  114. package/es/rce/plugins/instructure_record/VideoOptionsTray/index.js +19 -20
  115. package/es/rce/plugins/instructure_record/clickCallback.js +26 -30
  116. package/es/rce/plugins/instructure_search_and_replace/clickCallback.js +2 -3
  117. package/es/rce/plugins/instructure_search_and_replace/components/FindReplaceTray.js +14 -16
  118. package/es/rce/plugins/instructure_search_and_replace/components/FindReplaceTrayController.js +9 -12
  119. package/es/rce/plugins/instructure_search_and_replace/plugin.js +1 -2
  120. package/es/rce/plugins/instructure_wordcount/clickCallback.js +3 -4
  121. package/es/rce/plugins/instructure_wordcount/components/WordCountModal.js +26 -33
  122. package/es/rce/plugins/instructure_wordcount/utils/countContent.js +3 -3
  123. package/es/rce/plugins/instructure_wordcount/utils/tableContent.js +5 -8
  124. package/es/rce/plugins/shared/CanvasContentTray.js +9 -16
  125. package/es/rce/plugins/shared/ColorInput.js +22 -25
  126. package/es/rce/plugins/shared/ConditionalTooltip.js +5 -6
  127. package/es/rce/plugins/shared/ContentSelection.js +12 -20
  128. package/es/rce/plugins/shared/DimensionUtils.js +2 -4
  129. package/es/rce/plugins/shared/EventUtils.js +1 -1
  130. package/es/rce/plugins/shared/FixedContentTray.js +13 -14
  131. package/es/rce/plugins/shared/ImageCropper/DirectionRegion.js +3 -4
  132. package/es/rce/plugins/shared/ImageCropper/Modal.js +12 -13
  133. package/es/rce/plugins/shared/ImageCropper/Preview.js +11 -13
  134. package/es/rce/plugins/shared/ImageCropper/controls/CustomNumberInput.js +8 -9
  135. package/es/rce/plugins/shared/ImageCropper/controls/ResetControls.js +3 -4
  136. package/es/rce/plugins/shared/ImageCropper/controls/RotationControls.js +4 -5
  137. package/es/rce/plugins/shared/ImageCropper/controls/ShapeControls.js +7 -11
  138. package/es/rce/plugins/shared/ImageCropper/controls/ZoomControls.js +4 -5
  139. package/es/rce/plugins/shared/ImageCropper/controls/index.js +4 -5
  140. package/es/rce/plugins/shared/ImageCropper/controls/useDebouncedNumericValue.js +13 -15
  141. package/es/rce/plugins/shared/ImageCropper/imageCropUtils.js +18 -21
  142. package/es/rce/plugins/shared/ImageCropper/svg/shape.js +4 -5
  143. package/es/rce/plugins/shared/ImageCropper/svg/utils.js +2 -4
  144. package/es/rce/plugins/shared/ImageCropper/useKeyMouseEvents.js +1 -4
  145. package/es/rce/plugins/shared/ImageOptionsForm.js +17 -18
  146. package/es/rce/plugins/shared/LinkDisplay.js +8 -9
  147. package/es/rce/plugins/shared/PreviewIcon.js +8 -9
  148. package/es/rce/plugins/shared/RceFileBrowser.js +2 -3
  149. package/es/rce/plugins/shared/StoreContext.js +8 -10
  150. package/es/rce/plugins/shared/StudioLtiSupportUtils.js +5 -6
  151. package/es/rce/plugins/shared/Upload/CanvasContentPanel.js +6 -7
  152. package/es/rce/plugins/shared/Upload/CategoryProcessor.js +1 -2
  153. package/es/rce/plugins/shared/Upload/ComputerPanel.js +11 -14
  154. package/es/rce/plugins/shared/Upload/PanelFilter.js +7 -8
  155. package/es/rce/plugins/shared/Upload/UploadFile.js +19 -22
  156. package/es/rce/plugins/shared/Upload/UploadFileModal.js +28 -34
  157. package/es/rce/plugins/shared/Upload/UrlPanel.js +4 -5
  158. package/es/rce/plugins/shared/Upload/UsageRightsSelectBox.js +18 -24
  159. package/es/rce/plugins/shared/Upload/doFileUpload.js +6 -7
  160. package/es/rce/plugins/shared/ai_tools/AIResponseModal.js +7 -8
  161. package/es/rce/plugins/shared/ai_tools/AIToolsTray.js +14 -17
  162. package/es/rce/plugins/shared/ai_tools/aiicons.js +2 -2
  163. package/es/rce/plugins/shared/canvasContentUtils.js +1 -2
  164. package/es/rce/plugins/shared/compressionUtils.js +17 -20
  165. package/es/rce/plugins/shared/do-fetch-api-effect/doFetchApi.js +12 -15
  166. package/es/rce/plugins/shared/do-fetch-api-effect/get-cookie.js +1 -1
  167. package/es/rce/plugins/shared/fileTypeUtils.js +3 -6
  168. package/es/rce/plugins/shared/round.js +1 -2
  169. package/es/rce/plugins/shared/trayUtils.js +3 -0
  170. package/es/rce/plugins/shared/useDataUrl.js +4 -5
  171. package/es/rce/plugins/tinymce-a11y-checker/components/ColorField.js +2 -2
  172. package/es/rce/plugins/tinymce-a11y-checker/components/checker.js +8 -10
  173. package/es/rce/plugins/tinymce-a11y-checker/node-checker.js +1 -3
  174. package/es/rce/plugins/tinymce-a11y-checker/plugin.js +14 -17
  175. package/es/rce/plugins/tinymce-a11y-checker/rules/headings-start-at-h2.js +1 -2
  176. package/es/rce/plugins/tinymce-a11y-checker/rules/large-text-contrast.js +1 -2
  177. package/es/rce/plugins/tinymce-a11y-checker/rules/small-text-contrast.js +1 -2
  178. package/es/rce/plugins/tinymce-a11y-checker/utils/dom.js +2 -4
  179. package/es/rce/plugins/tinymce-a11y-checker/utils/indicate.js +2 -3
  180. package/es/rce/plugins/tinymce-a11y-checker/utils/rgb-hex.js +1 -4
  181. package/es/rce/root.js +9 -9
  182. package/es/rce/tinyRCE.js +1 -0
  183. package/es/rce/transformContent.js +1 -1
  184. package/es/rcs/api.js +39 -55
  185. package/es/rcs/buildError.js +3 -3
  186. package/es/rcs/fake.js +5 -7
  187. package/es/sidebar/actions/documents.js +10 -12
  188. package/es/sidebar/actions/files.js +18 -22
  189. package/es/sidebar/actions/filter.js +4 -5
  190. package/es/sidebar/actions/images.js +20 -26
  191. package/es/sidebar/actions/media.js +15 -18
  192. package/es/sidebar/actions/session.js +1 -2
  193. package/es/sidebar/actions/upload.js +26 -37
  194. package/es/sidebar/containers/sidebarHandlers.js +6 -12
  195. package/es/sidebar/dragHtml.js +6 -2
  196. package/es/sidebar/reducers/all_files.js +1 -3
  197. package/es/sidebar/reducers/collection.js +1 -3
  198. package/es/sidebar/reducers/collections.js +1 -3
  199. package/es/sidebar/reducers/documents.js +1 -3
  200. package/es/sidebar/reducers/files.js +1 -3
  201. package/es/sidebar/reducers/filter.js +7 -15
  202. package/es/sidebar/reducers/flickr.js +1 -3
  203. package/es/sidebar/reducers/folder.js +1 -3
  204. package/es/sidebar/reducers/folders.js +1 -3
  205. package/es/sidebar/reducers/images.js +1 -3
  206. package/es/sidebar/reducers/media.js +1 -3
  207. package/es/sidebar/reducers/newPageLinkExpanded.js +1 -3
  208. package/es/sidebar/reducers/noop.js +1 -2
  209. package/es/sidebar/reducers/rootFolderId.js +1 -3
  210. package/es/sidebar/reducers/session.js +1 -3
  211. package/es/sidebar/reducers/ui.js +3 -9
  212. package/es/sidebar/reducers/upload.js +8 -24
  213. package/es/sidebar/store/initialState.js +1 -2
  214. package/es/translations/locales/ar.js +6 -0
  215. package/es/translations/locales/ca.js +6 -0
  216. package/es/translations/locales/cy.js +6 -0
  217. package/es/translations/locales/da-x-k12.js +6 -0
  218. package/es/translations/locales/da.js +6 -0
  219. package/es/translations/locales/de.js +6 -0
  220. package/es/translations/locales/en-AU-x-unimelb.js +6 -0
  221. package/es/translations/locales/en-GB-x-ukhe.js +6 -0
  222. package/es/translations/locales/en_AU.js +6 -0
  223. package/es/translations/locales/en_CA.js +6 -0
  224. package/es/translations/locales/en_CY.js +6 -0
  225. package/es/translations/locales/en_GB.js +6 -0
  226. package/es/translations/locales/es.js +6 -0
  227. package/es/translations/locales/es_ES.js +6 -0
  228. package/es/translations/locales/fi.js +6 -0
  229. package/es/translations/locales/fr.js +6 -0
  230. package/es/translations/locales/fr_CA.js +6 -0
  231. package/es/translations/locales/hi.js +6 -0
  232. package/es/translations/locales/ht.js +6 -0
  233. package/es/translations/locales/id.js +6 -0
  234. package/es/translations/locales/is.js +6 -0
  235. package/es/translations/locales/it.js +6 -0
  236. package/es/translations/locales/ja.js +6 -0
  237. package/es/translations/locales/mi.js +6 -0
  238. package/es/translations/locales/ms.js +6 -0
  239. package/es/translations/locales/nb-x-k12.js +6 -0
  240. package/es/translations/locales/nb.js +6 -0
  241. package/es/translations/locales/nl.js +6 -0
  242. package/es/translations/locales/pl.js +6 -0
  243. package/es/translations/locales/pt.js +6 -0
  244. package/es/translations/locales/pt_BR.js +6 -0
  245. package/es/translations/locales/ru.js +6 -0
  246. package/es/translations/locales/sl.js +6 -0
  247. package/es/translations/locales/sv-x-k12.js +6 -0
  248. package/es/translations/locales/sv.js +6 -0
  249. package/es/translations/locales/th.js +6 -0
  250. package/es/translations/locales/vi.js +6 -0
  251. package/es/translations/locales/zh-Hans.js +6 -0
  252. package/es/translations/locales/zh-Hant.js +6 -0
  253. package/es/translations/locales/zh.js +6 -0
  254. package/es/translations/locales/zh_HK.js +6 -0
  255. package/es/util/elem-util.js +1 -1
  256. package/es/util/file-url-util.js +1 -1
  257. package/es/util/fullscreenHelpers.js +6 -9
  258. package/es/util/loadingPlaceholder.js +2 -3
  259. package/es/util/simpleCache.js +1 -2
  260. package/es/util/url-util.js +5 -5
  261. package/eslint.config.js +15 -4
  262. package/locales/en.json +190 -10
  263. package/package.json +56 -55
  264. package/scripts/installTranslations.js +7 -8
  265. package/tsconfig.json +1 -1
  266. package/types/format-message-generate-id.d.ts +22 -0
  267. package/types/js-beautify.d.ts +21 -0
@@ -83,25 +83,21 @@ export default class TrayController {
83
83
  media_object_id: audioOptions.media_object_id,
84
84
  subtitles: audioOptions.subtitles,
85
85
  attachment_id: audioOptions.attachment_id
86
- }).then(() => container === null || container === void 0 ? void 0 : container.contentWindow.location.reload()).catch(ex => {
87
- // eslint-disable-next-line no-console
86
+ }).then(() => container?.contentWindow.location.reload()).catch(ex => {
88
87
  console.error('Failed updating audio captions', ex);
89
88
  });
90
89
  }
91
90
  requestSubtitlesFromIframe(cb) {
92
- var _this$_audioContainer, _this$_audioContainer2;
93
91
  if (!bridge.canvasOrigin) return;
94
92
  this._subtitleListener = new AbortController();
95
93
  window.addEventListener('message', event => {
96
- var _event$data;
97
- if ((event === null || event === void 0 ? void 0 : (_event$data = event.data) === null || _event$data === void 0 ? void 0 : _event$data.subject) === 'media_tracks_response') {
98
- var _event$data2;
99
- cb(event === null || event === void 0 ? void 0 : (_event$data2 = event.data) === null || _event$data2 === void 0 ? void 0 : _event$data2.payload);
94
+ if (event?.data?.subject === 'media_tracks_response') {
95
+ cb(event?.data?.payload);
100
96
  }
101
97
  }, {
102
98
  signal: this._subtitleListener.signal
103
99
  });
104
- (_this$_audioContainer = this._audioContainer) === null || _this$_audioContainer === void 0 ? void 0 : (_this$_audioContainer2 = _this$_audioContainer.contentWindow) === null || _this$_audioContainer2 === void 0 ? void 0 : _this$_audioContainer2.postMessage({
100
+ this._audioContainer?.contentWindow?.postMessage({
105
101
  subject: 'media_tracks_request'
106
102
  }, bridge.canvasOrigin);
107
103
  }
@@ -113,10 +109,9 @@ export default class TrayController {
113
109
  this._isOpen = true;
114
110
  },
115
111
  onExited: () => {
116
- var _this$_subtitleListen;
117
112
  bridge.focusActiveEditor(false);
118
113
  this._isOpen = false;
119
- (_this$_subtitleListen = this._subtitleListener) === null || _this$_subtitleListen === void 0 ? void 0 : _this$_subtitleListen.abort();
114
+ this._subtitleListener?.abort();
120
115
  },
121
116
  onSave: options => {
122
117
  this._applyAudioOptions(options);
@@ -27,20 +27,19 @@ import { StoreProvider } from '../../shared/StoreContext';
27
27
  import Bridge from '../../../../bridge';
28
28
  import formatMessage from '../../../../format-message';
29
29
  import { getTrayHeight } from '../../shared/trayUtils';
30
- import { instuiPopupMountNode } from '../../../../util/fullscreenHelpers';
30
+ import { instuiPopupMountNodeFn } from '../../../../util/fullscreenHelpers';
31
31
  import { Heading } from '@instructure/ui-heading';
32
32
  const getLiveRegion = () => document.getElementById('flash_screenreader_holder');
33
- export default function AudioOptionsTray(_ref) {
34
- let {
35
- open,
36
- onEntered,
37
- onExited,
38
- onDismiss,
39
- onSave,
40
- trayProps,
41
- audioOptions,
42
- requestSubtitlesFromIframe
43
- } = _ref;
33
+ export default function AudioOptionsTray({
34
+ open,
35
+ onEntered,
36
+ onExited,
37
+ onDismiss,
38
+ onSave,
39
+ trayProps,
40
+ audioOptions,
41
+ requestSubtitlesFromIframe
42
+ }) {
44
43
  const [subtitles, setSubtitles] = useState(audioOptions.tracks || []);
45
44
  useEffect(() => {
46
45
  if (subtitles.length === 0) requestSubtitlesFromIframe(setSubtitles);
@@ -57,7 +56,7 @@ export default function AudioOptionsTray(_ref) {
57
56
  key: "audio-options-tray",
58
57
  "data-mce-component": true,
59
58
  label: formatMessage('Audio Options Tray'),
60
- mountNode: instuiPopupMountNode,
59
+ mountNode: instuiPopupMountNodeFn,
61
60
  onDismiss: onDismiss,
62
61
  onEntered: onEntered,
63
62
  onExited: onExited,
@@ -68,15 +68,13 @@ export default class TrayController {
68
68
  }
69
69
  }
70
70
  _applyVideoOptions(videoOptions) {
71
- var _this$$videoContainer;
72
- if (((_this$$videoContainer = this.$videoContainer) === null || _this$$videoContainer === void 0 ? void 0 : _this$$videoContainer.tagName) === 'IFRAME') {
71
+ if (this.$videoContainer?.tagName === 'IFRAME') {
73
72
  const $tinymceIframeShim = this.$videoContainer.parentElement;
74
73
  if (videoOptions.displayAs === 'embed') {
75
- var _videoOptions$subtitl;
76
74
  const isVertical = videoOptions.appliedHeight > videoOptions.appliedWidth;
77
75
  // player v5 requires more space for the CC button
78
76
  // TODO: remove when using v7
79
- const minWidth = (_videoOptions$subtitl = videoOptions.subtitles) !== null && _videoOptions$subtitl !== void 0 && _videoOptions$subtitl.length ? 400 : 320;
77
+ const minWidth = videoOptions.subtitles?.length ? 400 : 320;
80
78
  const styl = {
81
79
  height: `${videoOptions.appliedHeight}px`,
82
80
  width: `${Math.max(minWidth, isVertical ? videoOptions.appliedHeight : videoOptions.appliedWidth)}px`
@@ -130,7 +128,7 @@ export default class TrayController {
130
128
  }, bridge.canvasOrigin);
131
129
  }
132
130
  }).catch(ex => {
133
- console.error('failed updating video captions', ex); // eslint-disable-line no-console
131
+ console.error('failed updating video captions', ex);
134
132
  });
135
133
  }
136
134
  }
@@ -138,27 +136,23 @@ export default class TrayController {
138
136
  }
139
137
  _dismissTray() {
140
138
  if (this.$videoContainer) {
141
- var _this$_editor, _this$_editor$selecti;
142
- (_this$_editor = this._editor) === null || _this$_editor === void 0 ? void 0 : (_this$_editor$selecti = _this$_editor.selection) === null || _this$_editor$selecti === void 0 ? void 0 : _this$_editor$selecti.select(this.$videoContainer);
139
+ this._editor?.selection?.select(this.$videoContainer);
143
140
  }
144
141
  this._shouldOpen = false;
145
142
  this._renderTray();
146
143
  this._editor = null;
147
144
  }
148
145
  requestSubtitlesFromIframe(cb) {
149
- var _this$$videoContainer2, _this$$videoContainer3;
150
146
  if (!bridge.canvasOrigin) return;
151
147
  this._subtitleListener = new AbortController();
152
148
  window.addEventListener('message', event => {
153
- var _event$data;
154
- if ((event === null || event === void 0 ? void 0 : (_event$data = event.data) === null || _event$data === void 0 ? void 0 : _event$data.subject) === 'media_tracks_response') {
155
- var _event$data2;
156
- cb(event === null || event === void 0 ? void 0 : (_event$data2 = event.data) === null || _event$data2 === void 0 ? void 0 : _event$data2.payload);
149
+ if (event?.data?.subject === 'media_tracks_response') {
150
+ cb(event?.data?.payload);
157
151
  }
158
152
  }, {
159
153
  signal: this._subtitleListener.signal
160
154
  });
161
- (_this$$videoContainer2 = this.$videoContainer) === null || _this$$videoContainer2 === void 0 ? void 0 : (_this$$videoContainer3 = _this$$videoContainer2.contentWindow) === null || _this$$videoContainer3 === void 0 ? void 0 : _this$$videoContainer3.postMessage({
155
+ this.$videoContainer?.contentWindow?.postMessage({
162
156
  subject: 'media_tracks_request'
163
157
  }, bridge.canvasOrigin);
164
158
  }
@@ -181,10 +175,9 @@ export default class TrayController {
181
175
  this._isOpen = true;
182
176
  },
183
177
  onExited: () => {
184
- var _this$_subtitleListen;
185
178
  bridge.focusActiveEditor(false);
186
179
  this._isOpen = false;
187
- (_this$_subtitleListen = this._subtitleListener) === null || _this$_subtitleListen === void 0 ? void 0 : _this$_subtitleListen.abort();
180
+ this._subtitleListener?.abort();
188
181
  },
189
182
  onSave: videoOptions => {
190
183
  this._applyVideoOptions(videoOptions);
@@ -38,23 +38,22 @@ import RceApiSource from '../../../../rcs/api';
38
38
  import formatMessage from '../../../../format-message';
39
39
  import DimensionsInput, { useDimensionsState } from '../../shared/DimensionsInput';
40
40
  import { getTrayHeight } from '../../shared/trayUtils';
41
- import { instuiPopupMountNode } from '../../../../util/fullscreenHelpers';
41
+ import { instuiPopupMountNodeFn } from '../../../../util/fullscreenHelpers';
42
42
  import { parsedStudioOptionsPropType } from '../../shared/StudioLtiSupportUtils';
43
43
  const getLiveRegion = () => document.getElementById('flash_screenreader_holder');
44
- export default function VideoOptionsTray(_ref) {
45
- let {
46
- videoOptions,
47
- onRequestClose,
48
- onSave,
49
- open,
50
- trayProps,
51
- requestSubtitlesFromIframe = () => {},
52
- onEntered = null,
53
- onExited = null,
54
- id = 'video-options-tray',
55
- studioOptions = null,
56
- forBlockEditorUse = false
57
- } = _ref;
44
+ export default function VideoOptionsTray({
45
+ videoOptions,
46
+ onRequestClose,
47
+ onSave,
48
+ open,
49
+ trayProps,
50
+ requestSubtitlesFromIframe = () => {},
51
+ onEntered = null,
52
+ onExited = null,
53
+ id = 'video-options-tray',
54
+ studioOptions = null,
55
+ forBlockEditorUse = false
56
+ }) {
58
57
  const {
59
58
  naturalHeight,
60
59
  naturalWidth
@@ -86,7 +85,7 @@ export default function VideoOptionsTray(_ref) {
86
85
  api.getFile(videoOptions.attachmentId, {
87
86
  include: ['blueprint_course_status']
88
87
  }).then(response => {
89
- setEditLocked((response === null || response === void 0 ? void 0 : response.restricted_by_master_course) && (response === null || response === void 0 ? void 0 : response.is_master_course_child_content));
88
+ setEditLocked(response?.restricted_by_master_course && response?.is_master_course_child_content);
90
89
  setLoading(false);
91
90
  }).catch(error => {
92
91
  setLoading(false);
@@ -175,7 +174,7 @@ export default function VideoOptionsTray(_ref) {
175
174
  key: "video-options-tray",
176
175
  "data-mce-component": true,
177
176
  label: isStudio ? formatMessage('Studio Media Options Tray') : formatMessage('Video Options Tray'),
178
- mountNode: instuiPopupMountNode,
177
+ mountNode: instuiPopupMountNodeFn,
179
178
  onDismiss: onRequestClose,
180
179
  onEntered: onEntered,
181
180
  onExited: onExited,
@@ -207,7 +206,7 @@ export default function VideoOptionsTray(_ref) {
207
206
  margin: "xx-large",
208
207
  padding: "xx-large"
209
208
  }, /*#__PURE__*/React.createElement(Spinner, {
210
- renderTitle: formatMessage("Loading")
209
+ renderTitle: formatMessage('Loading')
211
210
  })) : /*#__PURE__*/React.createElement(Flex.Item, {
212
211
  as: "form",
213
212
  shouldGrow: true,
@@ -261,7 +260,7 @@ export default function VideoOptionsTray(_ref) {
261
260
  padding: "small small xx-small small"
262
261
  }, /*#__PURE__*/React.createElement(SimpleSelect, {
263
262
  id: `${id}-size`,
264
- mountNode: instuiPopupMountNode,
263
+ mountNode: instuiPopupMountNodeFn,
265
264
  disabled: displayAs !== 'embed',
266
265
  renderLabel: formatMessage('Size'),
267
266
  messages: messagesForSize,
@@ -298,7 +297,7 @@ export default function VideoOptionsTray(_ref) {
298
297
  userLocale: Bridge.userLocale,
299
298
  updateSubtitles: handleUpdateSubtitles,
300
299
  liveRegion: getLiveRegion,
301
- mountNode: instuiPopupMountNode
300
+ mountNode: instuiPopupMountNodeFn
302
301
  }))))), /*#__PURE__*/React.createElement(Flex.Item, {
303
302
  background: "secondary",
304
303
  borderWidth: "small none none none",
@@ -22,11 +22,11 @@ import Bridge from '../../../bridge';
22
22
  import { StoreProvider } from '../shared/StoreContext';
23
23
  import formatMessage from '../../../format-message';
24
24
  import { headerFor, originFromHost } from '../../../rcs/api';
25
- import { instuiPopupMountNode } from '../../../util/fullscreenHelpers';
25
+ import { instuiPopupMountNodeFn } from '../../../util/fullscreenHelpers';
26
26
  import RCEGlobals from '../../RCEGlobals';
27
27
  export const handleUpload = (error, uploadData, onUploadComplete, uploadBookmark) => {
28
28
  let err_msg = error && Bridge.uploadMediaTranslations.UploadMediaStrings.UPLOADING_ERROR;
29
- if ((error === null || error === void 0 ? void 0 : error.name) === 'FileSizeError') {
29
+ if (error?.name === 'FileSizeError') {
30
30
  err_msg = formatMessage('Size of caption file is greater than the maximum {max} kb allowed file size.', {
31
31
  max: error.maxBytes / 1000
32
32
  });
@@ -64,39 +64,35 @@ export default function (ed, document) {
64
64
  // but it also does the upload. We need to separate them if we
65
65
  // want to stay within the redux approach
66
66
  const handleStartUpload = fileProps => {
67
- var _editorComponent$edit;
68
67
  Bridge.focusEditor(ed.rceWrapper);
69
68
  const editorComponent = Bridge.activeEditor();
70
- uploadBookmark = editorComponent === null || editorComponent === void 0 ? void 0 : (_editorComponent$edit = editorComponent.editor) === null || _editorComponent$edit === void 0 ? void 0 : _editorComponent$edit.selection.getBookmark(2, true);
69
+ uploadBookmark = editorComponent?.editor?.selection.getBookmark(2, true);
71
70
  Bridge.insertImagePlaceholder(fileProps);
72
71
  handleDismiss();
73
72
  };
74
73
  const trayProps = Bridge.trayProps.get(ed);
75
- ReactDOM.render(/*#__PURE__*/React.createElement(StoreProvider, trayProps, contentProps => {
76
- var _RCEGlobals$getFeatur;
77
- return /*#__PURE__*/React.createElement(UploadMedia, {
78
- "data-mce-component": true,
79
- rcsConfig: {
80
- contextType: ed.settings.canvas_rce_user_context.type,
81
- contextId: ed.settings.canvas_rce_user_context.id,
82
- origin: originFromHost(contentProps.host),
83
- headers: headerFor(contentProps.jwt)
84
- },
85
- userLocale: Bridge.userLocale,
86
- mountNode: instuiPopupMountNode,
87
- open: true,
88
- liveRegion: () => document.getElementById('flash_screenreader_holder'),
89
- onStartUpload: fileProps => handleStartUpload(fileProps),
90
- onUploadComplete: (err, data) => handleUpload(err, data, contentProps.mediaUploadComplete, uploadBookmark),
91
- onDismiss: handleDismiss,
92
- tabs: {
93
- record: true,
94
- upload: true
95
- },
96
- uploadMediaTranslations: Bridge.uploadMediaTranslations,
97
- media_links_use_attachment_id: RCEGlobals.getFeatures().media_links_use_attachment_id,
98
- useStudioPlayer: (_RCEGlobals$getFeatur = RCEGlobals.getFeatures()) === null || _RCEGlobals$getFeatur === void 0 ? void 0 : _RCEGlobals$getFeatur.consolidated_media_player
99
- });
100
- }), container);
74
+ ReactDOM.render(/*#__PURE__*/React.createElement(StoreProvider, trayProps, contentProps => /*#__PURE__*/React.createElement(UploadMedia, {
75
+ "data-mce-component": true,
76
+ rcsConfig: {
77
+ contextType: ed.settings.canvas_rce_user_context.type,
78
+ contextId: ed.settings.canvas_rce_user_context.id,
79
+ origin: originFromHost(contentProps.host),
80
+ headers: headerFor(contentProps.jwt)
81
+ },
82
+ userLocale: Bridge.userLocale,
83
+ mountNode: instuiPopupMountNodeFn,
84
+ open: true,
85
+ liveRegion: () => document.getElementById('flash_screenreader_holder'),
86
+ onStartUpload: fileProps => handleStartUpload(fileProps),
87
+ onUploadComplete: (err, data) => handleUpload(err, data, contentProps.mediaUploadComplete, uploadBookmark),
88
+ onDismiss: handleDismiss,
89
+ tabs: {
90
+ record: true,
91
+ upload: true
92
+ },
93
+ uploadMediaTranslations: Bridge.uploadMediaTranslations,
94
+ media_links_use_attachment_id: RCEGlobals.getFeatures().media_links_use_attachment_id,
95
+ useStudioPlayer: RCEGlobals.getFeatures()?.consolidated_media_player
96
+ })), container);
101
97
  });
102
98
  }
@@ -22,12 +22,11 @@ import FindReplaceController from './components/FindReplaceTrayController';
22
22
  import { getSelectionContext } from './getSelectionContext';
23
23
  const CONTAINER_ID = 'instructure-find-replace-tray-container';
24
24
  export default function (editor, document) {
25
- var _editor$selection, _editor$selection2;
26
25
  const plugin = editor.plugins.searchreplace;
27
- const initalSelection = (_editor$selection = editor.selection) === null || _editor$selection === void 0 ? void 0 : _editor$selection.getContent({
26
+ const initalSelection = editor.selection?.getContent({
28
27
  format: 'text'
29
28
  });
30
- if (initalSelection) (_editor$selection2 = editor.selection) === null || _editor$selection2 === void 0 ? void 0 : _editor$selection2.collapse(true);
29
+ if (initalSelection) editor.selection?.collapse(true);
31
30
  let container = document.getElementById(CONTAINER_ID);
32
31
  if (container == null) {
33
32
  container = document.createElement('div');
@@ -24,25 +24,24 @@ import { Heading } from '@instructure/ui-heading';
24
24
  import { IconWarningSolid } from '@instructure/ui-icons';
25
25
  import { getTrayHeight } from '../../shared/trayUtils';
26
26
  import { View } from '@instructure/ui-view';
27
- import { instuiPopupMountNode } from '../../../../util/fullscreenHelpers';
27
+ import { instuiPopupMountNodeFn } from '../../../../util/fullscreenHelpers';
28
28
  import formatMessage from '../../../../format-message';
29
29
  import { Tray } from '@instructure/ui-tray';
30
30
  import { TextInput } from '@instructure/ui-text-input';
31
31
  import { Text } from '@instructure/ui-text';
32
32
  import { ScreenReaderContent } from '@instructure/ui-a11y-content';
33
33
  import { Alert } from '@instructure/ui-alerts';
34
- export default function FindReplaceTray(_ref) {
35
- let {
36
- onNext,
37
- onPrevious,
38
- onFind,
39
- onRequestClose,
40
- onReplace,
41
- index,
42
- max,
43
- initialText = '',
44
- selectionContext = ['', '']
45
- } = _ref;
34
+ export default function FindReplaceTray({
35
+ onNext,
36
+ onPrevious,
37
+ onFind,
38
+ onRequestClose,
39
+ onReplace,
40
+ index,
41
+ max,
42
+ initialText = '',
43
+ selectionContext = ['', '']
44
+ }) {
46
45
  const [findText, setFindText] = useState(initialText);
47
46
  const [replaceText, setReplaceText] = useState('');
48
47
  const [hasOpened, setHasOpened] = useState(false);
@@ -54,13 +53,12 @@ export default function FindReplaceTray(_ref) {
54
53
  const srDupKey = useRef(0);
55
54
  // moves RCE when tray opens/closes, copied from CanvasContentTray
56
55
  useEffect(() => {
57
- var _trayRef$current;
58
56
  if (!hasOpened) return;
59
57
  let c = document.querySelector('[role="main"]');
60
58
  let target_w = 0;
61
59
  if (!c) return;
62
60
  const margin = window.getComputedStyle(c).direction === 'ltr' ? document.body.getBoundingClientRect().right - c.getBoundingClientRect().right : c.getBoundingClientRect().left;
63
- target_w = c.offsetWidth - ((_trayRef$current = trayRef.current) === null || _trayRef$current === void 0 ? void 0 : _trayRef$current.offsetWidth) + margin;
61
+ target_w = c.offsetWidth - trayRef.current?.offsetWidth + margin;
64
62
  if (target_w >= 320 && target_w < c.offsetWidth) {
65
63
  c.style.boxSizing = 'border-box';
66
64
  c.style.width = `${target_w}px`;
@@ -214,7 +212,7 @@ export default function FindReplaceTray(_ref) {
214
212
  return /*#__PURE__*/React.createElement(Tray, {
215
213
  "data-mce-component": true,
216
214
  label: formatMessage('Find and Replace'),
217
- mountNode: instuiPopupMountNode,
215
+ mountNode: instuiPopupMountNodeFn(),
218
216
  onDismiss: onRequestClose,
219
217
  open: true,
220
218
  placement: "end",
@@ -19,14 +19,13 @@ import _pt from "prop-types";
19
19
 
20
20
  import React, { useState } from 'react';
21
21
  import FindReplaceTray from './FindReplaceTray';
22
- export default function FindReplaceTrayController(_ref) {
23
- let {
24
- plugin,
25
- onDismiss,
26
- initialText = '',
27
- undoManager,
28
- getSelectionContext
29
- } = _ref;
22
+ export default function FindReplaceTrayController({
23
+ plugin,
24
+ onDismiss,
25
+ initialText = '',
26
+ undoManager,
27
+ getSelectionContext
28
+ }) {
30
29
  // this component really just exists to make the index easier to track
31
30
  const [findIndex, setFindIndex] = useState(0);
32
31
  const [findCount, setFindCount] = useState(0);
@@ -83,11 +82,9 @@ export default function FindReplaceTrayController(_ref) {
83
82
  updateSelectionContext();
84
83
  }
85
84
  };
86
- const handleReplace = function (text) {
87
- let forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
88
- let all = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
85
+ const handleReplace = (text, forward = true, all = false) => {
89
86
  if (!text) return;
90
- undoManager === null || undoManager === void 0 ? void 0 : undoManager.add();
87
+ undoManager?.add();
91
88
  plugin.replace(text, forward, all);
92
89
  if (findCount === 1 || all) {
93
90
  done();
@@ -20,9 +20,8 @@ import tinymce from 'tinymce';
20
20
  import formatMessage from '../../../format-message';
21
21
  import clickCallback from './clickCallback';
22
22
  tinymce.PluginManager.add('instructure_search_and_replace', function (editor) {
23
- var _editor$plugins;
24
23
  // We use the searchreplace plugins API
25
- if (!((_editor$plugins = editor.plugins) !== null && _editor$plugins !== void 0 && _editor$plugins.searchreplace)) return;
24
+ if (!editor.plugins?.searchreplace) return;
26
25
  const launchFindModal = ed => () => {
27
26
  clickCallback(ed, document);
28
27
  };
@@ -21,10 +21,9 @@ import ReactDOM from 'react-dom';
21
21
  import { generateRows, HEADERS } from './utils/tableContent';
22
22
  const MODAL_ID = 'canvas-rce-wordcount-container';
23
23
  export default function (ed, document, options) {
24
- return import('./components/WordCountModal').then(_ref => {
25
- let {
26
- WordCountModal
27
- } = _ref;
24
+ return import('./components/WordCountModal').then(({
25
+ WordCountModal
26
+ }) => {
28
27
  let container = document.querySelector(`#${MODAL_ID}`);
29
28
  if (!container) {
30
29
  container = document.createElement('div');
@@ -23,45 +23,38 @@ import { BaseButton, CloseButton } from '@instructure/ui-buttons';
23
23
  import { Heading } from '@instructure/ui-heading';
24
24
  import { Table } from '@instructure/ui-table';
25
25
  import formatMessage from '../../../../format-message';
26
- import { instuiPopupMountNode } from '../../../../util/fullscreenHelpers';
26
+ import { instuiPopupMountNodeFn } from '../../../../util/fullscreenHelpers';
27
27
  const renderBody = (headers, rows) => {
28
28
  return /*#__PURE__*/React.createElement(Table, {
29
29
  caption: formatMessage('Word Count')
30
- }, /*#__PURE__*/React.createElement(Table.Head, null, /*#__PURE__*/React.createElement(Table.Row, null, headers.map(_ref => {
31
- let {
32
- id,
33
- getLabel
34
- } = _ref;
35
- return /*#__PURE__*/React.createElement(Table.ColHeader, {
36
- key: id,
37
- id: id
38
- }, getLabel());
39
- }))), /*#__PURE__*/React.createElement(Table.Body, null, rows.map(_ref2 => {
40
- let {
41
- label,
42
- documentCount,
43
- selectionCount
44
- } = _ref2;
45
- return /*#__PURE__*/React.createElement(Table.Row, {
46
- key: label
47
- }, /*#__PURE__*/React.createElement(Table.Cell, {
48
- key: "label"
49
- }, label), /*#__PURE__*/React.createElement(Table.Cell, {
50
- key: "document"
51
- }, documentCount), /*#__PURE__*/React.createElement(Table.Cell, {
52
- key: "selection"
53
- }, selectionCount));
54
- })));
30
+ }, /*#__PURE__*/React.createElement(Table.Head, null, /*#__PURE__*/React.createElement(Table.Row, null, headers.map(({
31
+ id,
32
+ getLabel
33
+ }) => /*#__PURE__*/React.createElement(Table.ColHeader, {
34
+ key: id,
35
+ id: id
36
+ }, getLabel())))), /*#__PURE__*/React.createElement(Table.Body, null, rows.map(({
37
+ label,
38
+ documentCount,
39
+ selectionCount
40
+ }) => /*#__PURE__*/React.createElement(Table.Row, {
41
+ key: label
42
+ }, /*#__PURE__*/React.createElement(Table.Cell, {
43
+ key: "label"
44
+ }, label), /*#__PURE__*/React.createElement(Table.Cell, {
45
+ key: "document"
46
+ }, documentCount), /*#__PURE__*/React.createElement(Table.Cell, {
47
+ key: "selection"
48
+ }, selectionCount)))));
55
49
  };
56
- export const WordCountModal = _ref3 => {
57
- let {
58
- headers,
59
- rows,
60
- onDismiss
61
- } = _ref3;
50
+ export const WordCountModal = ({
51
+ headers,
52
+ rows,
53
+ onDismiss
54
+ }) => {
62
55
  return /*#__PURE__*/React.createElement(Modal, {
63
56
  label: formatMessage('Word Count'),
64
- mountNode: instuiPopupMountNode,
57
+ mountNode: instuiPopupMountNodeFn(),
65
58
  open: true,
66
59
  "data-mce-component": true
67
60
  }, /*#__PURE__*/React.createElement(Modal.Header, null, /*#__PURE__*/React.createElement(CloseButton, {
@@ -19,19 +19,19 @@
19
19
  export const IGNORE_WORDCOUNT_ATTRIBUTE = 'data-ignore-wordcount';
20
20
  export const countWords = node => {
21
21
  if (node.getAttribute(IGNORE_WORDCOUNT_ATTRIBUTE) === 'chars-only') return 0;
22
- const textContent = (node === null || node === void 0 ? void 0 : node.innerText) || '';
22
+ const textContent = node?.innerText || '';
23
23
  const trimmedTextContent = textContent.trim();
24
24
  if (trimmedTextContent.length === 0) return 0;
25
25
  return trimmedTextContent.split(/\s+/).length;
26
26
  };
27
27
  export const countCharsNoSpaces = node => {
28
- const textContent = (node === null || node === void 0 ? void 0 : node.innerText) || '';
28
+ const textContent = node?.innerText || '';
29
29
  const matches = textContent.match(/ /g); // a single space
30
30
  const spaces = matches ? matches.length : 0;
31
31
  return countChars(node) - spaces;
32
32
  };
33
33
  export const countChars = node => {
34
- const textContent = (node === null || node === void 0 ? void 0 : node.innerText) || '';
34
+ const textContent = node?.innerText || '';
35
35
  const iterator = textContent[Symbol.iterator]();
36
36
  let count = 0;
37
37
  while (!iterator.next().done) {
@@ -30,12 +30,9 @@ export const HEADERS = [{
30
30
  }];
31
31
  const ROW_LABELS = [['words', () => formatMessage('Words')], ['chars-no-spaces', () => formatMessage('Characters (no spaces)')], ['chars', () => formatMessage('Characters')]];
32
32
  export const generateRows = ed => {
33
- return ROW_LABELS.map(_ref => {
34
- let [category, getLabel] = _ref;
35
- return {
36
- label: getLabel(),
37
- documentCount: countContent(ed, 'body', category),
38
- selectionCount: countContent(ed, 'selection', category)
39
- };
40
- });
33
+ return ROW_LABELS.map(([category, getLabel]) => ({
34
+ label: getLabel(),
35
+ documentCount: countContent(ed, 'body', category),
36
+ selectionCount: countContent(ed, 'selection', category)
37
+ }));
41
38
  };
@@ -163,13 +163,12 @@ export default function CanvasContentTray(props) {
163
163
  }
164
164
  }, [hasOpened]);
165
165
  useEffect(() => {
166
- var _trayRef$current;
167
166
  if (!hasOpened) return;
168
167
  let c = document.querySelector('[role="main"]');
169
168
  let target_w = 0;
170
169
  if (!c) return;
171
170
  const margin = window.getComputedStyle(c).direction === 'ltr' ? document.body.getBoundingClientRect().right - c.getBoundingClientRect().right : c.getBoundingClientRect().left;
172
- target_w = c.offsetWidth - ((_trayRef$current = trayRef.current) === null || _trayRef$current === void 0 ? void 0 : _trayRef$current.offsetWidth) + margin;
171
+ target_w = c.offsetWidth - trayRef.current?.offsetWidth + margin;
173
172
  if (target_w >= 320 && target_w < c.offsetWidth) {
174
173
  c.style.boxSizing = 'border-box';
175
174
  c.style.width = `${target_w}px`;
@@ -271,11 +270,11 @@ export default function CanvasContentTray(props) {
271
270
  function renderLinkDisplay() {
272
271
  return isEditTray && /*#__PURE__*/React.createElement(LinkDisplay, {
273
272
  linkText: linkText,
274
- placeholderText: (link === null || link === void 0 ? void 0 : link.title) || placeholderText,
275
- linkFileName: (link === null || link === void 0 ? void 0 : link.title) || '',
276
- published: (link === null || link === void 0 ? void 0 : link.published) || false,
273
+ placeholderText: link?.title || placeholderText,
274
+ linkFileName: link?.title || '',
275
+ published: link?.published || false,
277
276
  handleTextChange: setLinkText,
278
- linkType: link === null || link === void 0 ? void 0 : link.type
277
+ linkType: link?.type
279
278
  });
280
279
  }
281
280
  return /*#__PURE__*/React.createElement(Tray, {
@@ -356,11 +355,6 @@ export default function CanvasContentTray(props) {
356
355
  }, storeProps)))), isEditTray && renderFooter())) : null));
357
356
  }
358
357
  CanvasContentTray.globalOpenCount = 0;
359
- function requiredWithoutSource(props, propName, componentName) {
360
- if (props.source == null && props[propName] == null) {
361
- throw new Error(`The prop \`${propName}\` is marked as required in \`${componentName}\`, but its value is \`${props[propName]}\`.`);
362
- }
363
- }
364
358
 
365
359
  // Changes made here may need to be reflected in the trayProps type in CanvasContentPanel
366
360
  const trayPropsMap = {
@@ -375,8 +369,8 @@ const trayPropsMap = {
375
369
  userId: string.isRequired
376
370
  }),
377
371
  filesTabDisabled: bool,
378
- host: requiredWithoutSource,
379
- jwt: requiredWithoutSource,
372
+ host: string,
373
+ jwt: string,
380
374
  refreshToken: func,
381
375
  source: shape({
382
376
  fetchImages: func.isRequired
@@ -397,12 +391,11 @@ CanvasContentTray.propTypes = {
397
391
  };
398
392
 
399
393
  // the way we define trayProps, eslint doesn't recognize the following as props
400
- /* eslint-disable react/default-props-match-prop-types */
394
+
401
395
  CanvasContentTray.defaultProps = {
402
396
  canUploadFiles: false,
403
397
  filesTabDisabled: false,
404
398
  refreshToken: null,
405
399
  source: null,
406
400
  themeUrl: null
407
- };
408
- /* eslint-enable react/default-props-match-prop-types */
401
+ };