@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
package/es/rcs/api.js CHANGED
@@ -33,10 +33,9 @@ export function originFromHost(host, windowOverride) {
33
33
  if (typeof origin !== 'string') {
34
34
  origin = '';
35
35
  } else if (origin && origin.substr(0, 4) !== 'http') {
36
- var _windowHandle$locatio;
37
36
  origin = `//${origin}`;
38
37
  const windowHandle = windowOverride || (typeof window !== 'undefined' ? window : undefined);
39
- if (origin.length > 0 && windowHandle !== null && windowHandle !== void 0 && (_windowHandle$locatio = windowHandle.location) !== null && _windowHandle$locatio !== void 0 && _windowHandle$locatio.protocol) {
38
+ if (origin.length > 0 && windowHandle?.location?.protocol) {
40
39
  origin = `${windowHandle.location.protocol}${origin}`;
41
40
  }
42
41
  }
@@ -67,7 +66,6 @@ function normalizeFileData(file) {
67
66
  }
68
67
  function throwConnectionError(error) {
69
68
  if (error.name === 'TypeError') {
70
- // eslint-disable-next-line no-console
71
69
  console.error(`Failed to fetch from the canvas-rce-api.
72
70
  Did you forget to start it or configure it?
73
71
  Details can be found at https://github.com/instructure/canvas-rce-api
@@ -76,8 +74,7 @@ function throwConnectionError(error) {
76
74
  throw error;
77
75
  }
78
76
  class RceApiSource {
79
- constructor() {
80
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
77
+ constructor(options = {}) {
81
78
  this.jwt = options.jwt;
82
79
  this.host = options.host;
83
80
  this.refreshToken = options.refreshToken || defaultRefreshTokenHandler;
@@ -154,11 +151,10 @@ class RceApiSource {
154
151
  fetchDocs(props) {
155
152
  const documents = props.documents[props.contextType];
156
153
  const uri = documents.bookmark || this.uriFor('documents', props);
157
- return this.apiFetch(uri, headerFor(this.jwt)).then(_ref => {
158
- let {
159
- bookmark,
160
- files
161
- } = _ref;
154
+ return this.apiFetch(uri, headerFor(this.jwt)).then(({
155
+ bookmark,
156
+ files
157
+ }) => {
162
158
  return {
163
159
  bookmark,
164
160
  files: files.map(f => fixupFileUrl(props.contextType, props.contextId, f, this.canvasOrigin))
@@ -166,15 +162,13 @@ class RceApiSource {
166
162
  });
167
163
  }
168
164
  fetchMedia(props) {
169
- var _RCEGlobals$getFeatur;
170
165
  const media = props.media[props.contextType];
171
166
  const uri = media.bookmark || this.uriFor('media', props);
172
- if ((_RCEGlobals$getFeatur = RCEGlobals.getFeatures()) !== null && _RCEGlobals$getFeatur !== void 0 && _RCEGlobals$getFeatur.media_links_use_attachment_id) {
173
- return this.apiFetch(uri, headerFor(this.jwt)).then(_ref2 => {
174
- let {
175
- bookmark,
176
- files
177
- } = _ref2;
167
+ if (RCEGlobals.getFeatures()?.media_links_use_attachment_id) {
168
+ return this.apiFetch(uri, headerFor(this.jwt)).then(({
169
+ bookmark,
170
+ files
171
+ }) => {
178
172
  return {
179
173
  bookmark,
180
174
  files: files.map(f => fixupFileUrl(props.contextType, props.contextId, f, this.canvasOrigin))
@@ -184,11 +178,10 @@ class RceApiSource {
184
178
  return this.apiFetch(uri, headerFor(this.jwt));
185
179
  }
186
180
  fetchFiles(uri) {
187
- return this.fetchPage(uri).then(_ref3 => {
188
- let {
189
- bookmark,
190
- files
191
- } = _ref3;
181
+ return this.fetchPage(uri).then(({
182
+ bookmark,
183
+ files
184
+ }) => {
192
185
  return {
193
186
  bookmark,
194
187
  files: files.map(normalizeFileData)
@@ -221,26 +214,22 @@ class RceApiSource {
221
214
  };
222
215
  return this.apiPost(this.baseUri('media_objects'), headerFor(this.jwt), body);
223
216
  }
224
- updateMediaObject(apiProps, _ref4) {
225
- var _RCEGlobals$getFeatur2;
226
- let {
227
- media_object_id,
228
- title,
229
- attachment_id
230
- } = _ref4;
231
- const uri = (_RCEGlobals$getFeatur2 = RCEGlobals.getFeatures()) !== null && _RCEGlobals$getFeatur2 !== void 0 && _RCEGlobals$getFeatur2.media_links_use_attachment_id && attachment_id ? `${this.baseUri('media_attachments', apiProps.host)}/${attachment_id}?user_entered_title=${encodeURIComponent(title)}` : `${this.baseUri('media_objects', apiProps.host)}/${media_object_id}?user_entered_title=${encodeURIComponent(title)}`;
217
+ updateMediaObject(apiProps, {
218
+ media_object_id,
219
+ title,
220
+ attachment_id
221
+ }) {
222
+ const uri = RCEGlobals.getFeatures()?.media_links_use_attachment_id && attachment_id ? `${this.baseUri('media_attachments', apiProps.host)}/${attachment_id}?user_entered_title=${encodeURIComponent(title)}` : `${this.baseUri('media_objects', apiProps.host)}/${media_object_id}?user_entered_title=${encodeURIComponent(title)}`;
232
223
  return this.apiPost(uri, headerFor(this.jwt), null, 'PUT');
233
224
  }
234
225
 
235
226
  // PUT to //RCS/api/media_objects/:mediaId/media_tracks [{locale, content}, ...]
236
227
  // receive back a 200 with the new subtitles, or a 4xx error
237
- updateClosedCaptions(apiProps, _ref5) {
238
- let {
239
- media_object_id,
240
- attachment_id,
241
- subtitles
242
- } = _ref5;
243
- let maxBytes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : CONSTANTS.CC_FILE_MAX_BYTES;
228
+ updateClosedCaptions(apiProps, {
229
+ media_object_id,
230
+ attachment_id,
231
+ subtitles
232
+ }, maxBytes = CONSTANTS.CC_FILE_MAX_BYTES) {
244
233
  const rcsConfig = {
245
234
  origin: originFromHost(apiProps.host),
246
235
  headers: headerFor(apiProps.jwt)
@@ -293,11 +282,10 @@ class RceApiSource {
293
282
  const uri = bookmark || `${this.baseUri('folders', props.host)}/${props.folderId}`;
294
283
  return this.apiFetch(uri, headerFor(this.jwt));
295
284
  }
296
- fetchIconMakerFolder(_ref6) {
297
- let {
298
- contextId,
299
- contextType
300
- } = _ref6;
285
+ fetchIconMakerFolder({
286
+ contextId,
287
+ contextType
288
+ }) {
301
289
  const uri = this.uriFor('folders/icon_maker', {
302
290
  contextId,
303
291
  contextType,
@@ -322,11 +310,10 @@ class RceApiSource {
322
310
  const images = props.images[props.contextType];
323
311
  const uri = images.bookmark || this.uriFor('images', props);
324
312
  const headers = headerFor(this.jwt);
325
- return this.apiFetch(uri, headers).then(_ref7 => {
326
- let {
327
- bookmark,
328
- files
329
- } = _ref7;
313
+ return this.apiFetch(uri, headers).then(({
314
+ bookmark,
315
+ files
316
+ }) => {
330
317
  return {
331
318
  bookmark,
332
319
  files: files.map(f => fixupFileUrl(props.contextType, props.contextId, f, this.canvasOrigin)),
@@ -426,8 +413,7 @@ class RceApiSource {
426
413
  const uri = `${base}?term=${encodeURIComponent(term)}`;
427
414
  return this.apiFetch(uri, headers);
428
415
  }
429
- getFile(id) {
430
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
416
+ getFile(id, options = {}) {
431
417
  const headers = headerFor(this.jwt);
432
418
  const base = this.baseUri('file');
433
419
 
@@ -470,8 +456,7 @@ class RceApiSource {
470
456
  }
471
457
  return this.apiReallyFetch(uri, headers, options);
472
458
  }
473
- apiReallyFetch(uri, headers) {
474
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
459
+ apiReallyFetch(uri, headers, options = {}) {
475
460
  uri = this.normalizeUriProtocol(uri);
476
461
  return fetch(uri, {
477
462
  headers
@@ -493,8 +478,7 @@ class RceApiSource {
493
478
  }
494
479
 
495
480
  // @private
496
- apiPost(uri, headers, body) {
497
- let method = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'POST';
481
+ apiPost(uri, headers, body, method = 'POST') {
498
482
  headers = {
499
483
  ...headers,
500
484
  'Content-Type': 'application/json'
@@ -523,7 +507,7 @@ class RceApiSource {
523
507
  return response;
524
508
  }
525
509
  }).then(checkStatus).then(res => res.json()).catch(throwConnectionError).catch(e => e.response.json().then(responseBody => {
526
- console.error(e); // eslint-disable-line no-console
510
+ console.error(e);
527
511
  this.alertFunc(buildError(responseBody));
528
512
  throw e;
529
513
  }));
@@ -612,6 +596,6 @@ function optionalQuery(props, name) {
612
596
  return props[name] ? `&${name}=${props[name]}` : '';
613
597
  }
614
598
  export function getSearchParam(searchString) {
615
- return (searchString === null || searchString === void 0 ? void 0 : searchString.length) >= 3 ? `&search_term=${encodeURIComponent(searchString)}` : '';
599
+ return searchString?.length >= 3 ? `&search_term=${encodeURIComponent(searchString)}` : '';
616
600
  }
617
601
  export default RceApiSource;
@@ -39,7 +39,7 @@ function getErrorClass(errorContext, error) {
39
39
  }
40
40
  class QuotaError {
41
41
  static isMatch(errorContext) {
42
- return (errorContext === null || errorContext === void 0 ? void 0 : errorContext.message) === 'file size exceeds quota';
42
+ return errorContext?.message === 'file size exceeds quota';
43
43
  }
44
44
  static build(_error) {
45
45
  return {
@@ -50,7 +50,7 @@ class QuotaError {
50
50
  }
51
51
  class CaptionSizeError {
52
52
  static isMatch(_errorContext, error) {
53
- return (error === null || error === void 0 ? void 0 : error.name) === 'FileSizeError';
53
+ return error?.name === 'FileSizeError';
54
54
  }
55
55
  static build(error) {
56
56
  return {
@@ -63,7 +63,7 @@ class CaptionSizeError {
63
63
  }
64
64
  class CaptionCreationError {
65
65
  static isMatch(errorContext) {
66
- return (errorContext === null || errorContext === void 0 ? void 0 : errorContext.message) === 'failed to save captions';
66
+ return errorContext?.message === 'failed to save captions';
67
67
  }
68
68
  static build(_error) {
69
69
  return {
package/es/rcs/fake.js CHANGED
@@ -462,8 +462,7 @@ export function fetchFolders() {
462
462
  }, 1000);
463
463
  });
464
464
  }
465
- export function fetchFiles() {
466
- let uri = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'files';
465
+ export function fetchFiles(uri = 'files') {
467
466
  return Promise.resolve(PAGES[uri]);
468
467
  }
469
468
  export function fetchImages(props) {
@@ -577,11 +576,10 @@ export function fetchMedia(state) {
577
576
  }, FAKE_TIMEOUT);
578
577
  });
579
578
  }
580
- export function updateMediaObject(state, _ref) {
581
- let {
582
- media_object_id,
583
- title
584
- } = _ref;
579
+ export function updateMediaObject(state, {
580
+ media_object_id,
581
+ title
582
+ }) {
585
583
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
586
584
  return new Promise((resolve, reject) => {
587
585
  setTimeout(() => {
@@ -36,12 +36,11 @@ export function requestDocs(contextType) {
36
36
  }
37
37
  };
38
38
  }
39
- export function receiveDocs(_ref) {
40
- let {
41
- response,
42
- contextType,
43
- contextId
44
- } = _ref;
39
+ export function receiveDocs({
40
+ response,
41
+ contextType,
42
+ contextId
43
+ }) {
45
44
  const {
46
45
  files,
47
46
  bookmark
@@ -56,11 +55,10 @@ export function receiveDocs(_ref) {
56
55
  }
57
56
  };
58
57
  }
59
- export function failDocs(_ref2) {
60
- let {
61
- error,
62
- contextType
63
- } = _ref2;
58
+ export function failDocs({
59
+ error,
60
+ contextType
61
+ }) {
64
62
  return {
65
63
  type: FAIL_DOCS,
66
64
  payload: {
@@ -93,7 +91,7 @@ export function fetchNextDocs() {
93
91
  return (dispatch, getState) => {
94
92
  const state = getState();
95
93
  const documents = state.documents[state.contextType];
96
- if (!(documents !== null && documents !== void 0 && documents.isLoading) && documents !== null && documents !== void 0 && documents.hasMore) {
94
+ if (!documents?.isLoading && documents?.hasMore) {
97
95
  dispatch(requestDocs(state.contextType));
98
96
  return dispatch(fetchDocs());
99
97
  }
@@ -31,14 +31,13 @@ export function createToggle(id) {
31
31
  id
32
32
  };
33
33
  }
34
- export function createAddFile(_ref) {
35
- let {
36
- id,
37
- name,
38
- url,
39
- type,
40
- embed
41
- } = _ref;
34
+ export function createAddFile({
35
+ id,
36
+ name,
37
+ url,
38
+ type,
39
+ embed
40
+ }) {
42
41
  return {
43
42
  type: ADD_FILE,
44
43
  id,
@@ -75,11 +74,10 @@ export function requestFiles(id, bookmark) {
75
74
  folders
76
75
  } = getState();
77
76
  dispatch(createRequestFiles(id));
78
- return source.fetchFiles(bookmark || folders[id].filesUrl).then(_ref2 => {
79
- let {
80
- files,
81
- bookmark
82
- } = _ref2;
77
+ return source.fetchFiles(bookmark || folders[id].filesUrl).then(({
78
+ files,
79
+ bookmark
80
+ }) => {
83
81
  dispatch(files.map(createAddFile).concat(createReceiveFiles(id, files)));
84
82
  if (bookmark) {
85
83
  // Page through all in folder, pagination links of a tree may be
@@ -119,11 +117,10 @@ export function requestSubfolders(id, bookmark) {
119
117
  folders
120
118
  } = getState();
121
119
  dispatch(createRequestSubfolders(id));
122
- return source.fetchPage(bookmark || folders[id].foldersUrl).then(_ref3 => {
123
- let {
124
- folders,
125
- bookmark
126
- } = _ref3;
120
+ return source.fetchPage(bookmark || folders[id].foldersUrl).then(({
121
+ folders,
122
+ bookmark
123
+ }) => {
127
124
  dispatch(folders.map(createAddFolder).concat(createReceiveSubfolders(id, folders, bookmark)));
128
125
  if (bookmark) {
129
126
  // Page through all in folder, pagination links if a tree may be
@@ -151,10 +148,9 @@ export function createSetRoot(id) {
151
148
  }
152
149
  export function init(dispatch, getState) {
153
150
  const props = getState();
154
- return props.source.fetchRootFolder(props).then(_ref4 => {
155
- let {
156
- folders
157
- } = _ref4;
151
+ return props.source.fetchRootFolder(props).then(({
152
+ folders
153
+ }) => {
158
154
  const root = folders[0];
159
155
  if (root) {
160
156
  dispatch([createAddFolder(root), createSetRoot(root.id)]);
@@ -21,11 +21,10 @@ export const CHANGE_CONTEXT_TYPE = 'CHANGE_CONTEXT_TYPE';
21
21
  export const CHANGE_CONTEXT_ID = 'CHANGE_CONTEXT_ID';
22
22
  export const CHANGE_SEARCH_STRING = 'CHANGE_SEARCH_STRING';
23
23
  export const CHANGE_SORT_BY = 'CHANGE_SORT_BY';
24
- export function changeContext(_ref) {
25
- let {
26
- contextType,
27
- contextId
28
- } = _ref;
24
+ export function changeContext({
25
+ contextType,
26
+ contextId
27
+ }) {
29
28
  return dispatch => {
30
29
  dispatch(changeContextType(contextType));
31
30
  dispatch(changeContextId(contextId));
@@ -23,14 +23,13 @@ export const REQUEST_INITIAL_IMAGES = 'action.images.request_initial_images';
23
23
  export const REQUEST_IMAGES = 'action.images.request_images';
24
24
  export const RECEIVE_IMAGES = 'action.images.receive_images';
25
25
  export const FAIL_IMAGES_LOAD = 'action.images.fail_images_load';
26
- export function createAddImage(_ref, contextType) {
27
- let {
28
- id,
29
- filename,
30
- display_name,
31
- url,
32
- thumbnail_url
33
- } = _ref;
26
+ export function createAddImage({
27
+ id,
28
+ filename,
29
+ display_name,
30
+ url,
31
+ thumbnail_url
32
+ }, contextType) {
34
33
  return {
35
34
  type: ADD_IMAGE,
36
35
  payload: {
@@ -61,12 +60,11 @@ export function requestImages(contextType) {
61
60
  }
62
61
  };
63
62
  }
64
- export function receiveImages(_ref2) {
65
- let {
66
- response,
67
- contextType,
68
- opts = {}
69
- } = _ref2;
63
+ export function receiveImages({
64
+ response,
65
+ contextType,
66
+ opts = {}
67
+ }) {
70
68
  const {
71
69
  files,
72
70
  bookmark,
@@ -82,11 +80,10 @@ export function receiveImages(_ref2) {
82
80
  }
83
81
  };
84
82
  }
85
- export function failImagesLoad(_ref3) {
86
- let {
87
- error,
88
- contextType
89
- } = _ref3;
83
+ export function failImagesLoad({
84
+ error,
85
+ contextType
86
+ }) {
90
87
  return {
91
88
  type: FAIL_IMAGES_LOAD,
92
89
  payload: {
@@ -109,8 +106,7 @@ export const applyAttributes = (file, opts) => {
109
106
  // dispatches the start of the load, requests a page for the collection from
110
107
  // the source, then dispatches the loaded page to the store on success or
111
108
  // clears the load on failure
112
- export function fetchImages() {
113
- let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
109
+ export function fetchImages(opts = {}) {
114
110
  const {
115
111
  category
116
112
  } = opts;
@@ -131,12 +127,11 @@ export function fetchImages() {
131
127
  }
132
128
  // fetches a page only if a page is not already being loaded and the
133
129
  // collection is not yet completely loaded
134
- export function fetchNextImages() {
135
- let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
130
+ export function fetchNextImages(opts = {}) {
136
131
  return (dispatch, getState) => {
137
132
  const state = getState();
138
133
  const images = state.images[state.contextType];
139
- if (!(images !== null && images !== void 0 && images.isLoading) && images !== null && images !== void 0 && images.hasMore) {
134
+ if (!images?.isLoading && images?.hasMore) {
140
135
  dispatch(requestImages(state.contextType));
141
136
  return dispatch(fetchImages(opts));
142
137
  }
@@ -144,8 +139,7 @@ export function fetchNextImages() {
144
139
  }
145
140
  // fetches the next page (subject to conditions on fetchNextImages) only if the
146
141
  // collection is currently empty
147
- export function fetchInitialImages() {
148
- let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
142
+ export function fetchInitialImages(opts = {}) {
149
143
  return (dispatch, getState) => {
150
144
  const state = getState();
151
145
  dispatch(requestInitialImages(state.contextType));
@@ -38,11 +38,10 @@ export function requestMedia(contextType) {
38
38
  }
39
39
  };
40
40
  }
41
- export function receiveMedia(_ref) {
42
- let {
43
- response,
44
- contextType
45
- } = _ref;
41
+ export function receiveMedia({
42
+ response,
43
+ contextType
44
+ }) {
46
45
  const {
47
46
  files,
48
47
  bookmark
@@ -56,11 +55,10 @@ export function receiveMedia(_ref) {
56
55
  }
57
56
  };
58
57
  }
59
- export function failMedia(_ref2) {
60
- let {
61
- error,
62
- contextType
63
- } = _ref2;
58
+ export function failMedia({
59
+ error,
60
+ contextType
61
+ }) {
64
62
  return {
65
63
  type: FAIL_MEDIA,
66
64
  payload: {
@@ -93,7 +91,7 @@ export function fetchNextMedia() {
93
91
  return (dispatch, getState) => {
94
92
  const state = getState();
95
93
  const media = state.media[state.contextType];
96
- if (!(media !== null && media !== void 0 && media.isLoading) && media !== null && media !== void 0 && media.hasMore) {
94
+ if (!media?.isLoading && media?.hasMore) {
97
95
  dispatch(requestMedia(state.contextType));
98
96
  return dispatch(fetchMedia());
99
97
  }
@@ -111,13 +109,12 @@ export function fetchInitialMedia() {
111
109
  }
112
110
 
113
111
  // update the media object.
114
- export function updateMediaObject(_ref3) {
115
- let {
116
- media_object_id,
117
- attachment_id,
118
- title,
119
- subtitles
120
- } = _ref3;
112
+ export function updateMediaObject({
113
+ media_object_id,
114
+ attachment_id,
115
+ title,
116
+ subtitles
117
+ }) {
121
118
  return (dispatch, getState) => {
122
119
  const state = getState();
123
120
  const moUpdate = state.source.updateMediaObject(state, {
@@ -24,9 +24,8 @@ function receiveSession(data) {
24
24
  };
25
25
  }
26
26
  export function get(dispatch, getState) {
27
- var _source$getSession;
28
27
  const {
29
28
  source
30
29
  } = getState();
31
- return (_source$getSession = source.getSession) === null || _source$getSession === void 0 ? void 0 : _source$getSession.call(source).then(data => dispatch(receiveSession(data)));
30
+ return source.getSession?.().then(data => dispatch(receiveSession(data)));
32
31
  }