@instructure/canvas-rce 5.14.1 → 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 (489) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/DEVELOPMENT.md +2 -2
  3. package/README.md +0 -8
  4. package/__tests__/common/indicate.test.js +84 -0
  5. package/__tests__/common/mimeClass.test.js +85 -0
  6. package/__tests__/module/contentInsertionUtils.test.js +52 -0
  7. package/__tests__/module/indicatorRegion.test.js +75 -0
  8. package/__tests__/module/normalizeLocale.test.js +46 -0
  9. package/__tests__/module/normalizeProps.test.js +51 -0
  10. package/__tests__/module/sanitizePlugins.test.js +48 -0
  11. package/__tests__/module/wrapInitCb.test.js +56 -0
  12. package/__tests__/rcs/api.test.js +819 -0
  13. package/{mocha-reporter-config.js → __tests__/sidebar/actions/all_files.test.js} +10 -9
  14. package/__tests__/sidebar/actions/data.test.js +196 -0
  15. package/__tests__/sidebar/actions/utils.js +44 -0
  16. package/{es/rce/__mocks__/_mockStudioPlayer.js → __tests__/sidebar/reducers/all_files.test.js} +12 -4
  17. package/babel.config.js +3 -1
  18. package/es/bridge/Bridge.js +18 -73
  19. package/es/bridge/index.js +1 -0
  20. package/es/canvasFileBrowser/FileBrowser.js +21 -77
  21. package/es/canvasFileBrowser/en-US.js +3 -6
  22. package/es/common/FlashAlert.js +15 -39
  23. package/es/common/browser.js +4 -2
  24. package/es/common/fileUrl.js +105 -64
  25. package/es/common/incremental-loading/LoadMoreButton.js +4 -4
  26. package/es/common/incremental-loading/LoadingIndicator.js +1 -2
  27. package/es/common/incremental-loading/LoadingStatus.js +5 -13
  28. package/es/common/incremental-loading/index.js +1 -0
  29. package/es/common/incremental-loading/useIncrementalLoading.js +1 -3
  30. package/es/common/indicate.js +16 -10
  31. package/es/common/mimeClass.js +3 -4
  32. package/es/common/natcompare.js +1 -4
  33. package/es/defaultTinymceConfig.js +5 -3
  34. package/es/elementDenylist.js +1 -0
  35. package/es/enhance-user-content/doc_previews.js +24 -35
  36. package/es/enhance-user-content/enhance_user_content.js +32 -67
  37. package/es/enhance-user-content/external_links.js +6 -9
  38. package/es/enhance-user-content/index.js +1 -0
  39. package/es/enhance-user-content/instructure_helper.js +22 -50
  40. package/es/enhance-user-content/jqueryish_funcs.js +8 -11
  41. package/es/enhance-user-content/mathml.js +48 -107
  42. package/es/enhance-user-content/media_comment_thumbnail.js +6 -25
  43. package/es/format-message.js +4 -5
  44. package/es/getThemeVars.js +8 -6
  45. package/es/getTranslations.js +1 -78
  46. package/es/index.d.ts +59 -0
  47. package/es/index.js +6 -6
  48. package/es/rce/AlertMessageArea.js +15 -16
  49. package/es/rce/DraggingBlocker.js +4 -2
  50. package/es/rce/KeyboardShortcutModal.js +3 -2
  51. package/es/rce/RCE.js +16 -17
  52. package/es/rce/RCEGlobals.js +12 -10
  53. package/es/rce/RCEVariants.js +29 -14
  54. package/es/rce/RCEWrapper.js +530 -641
  55. package/es/rce/RCEWrapper.utils.js +131 -0
  56. package/es/rce/RCEWrapperProps.js +9 -5
  57. package/es/rce/RceHtmlEditor.js +17 -19
  58. package/es/rce/ResizeHandle.js +4 -10
  59. package/es/rce/RestoreAutoSaveModal.js +1 -2
  60. package/es/rce/ShowOnFocusButton/index.js +2 -8
  61. package/es/rce/StatusBar.js +10 -44
  62. package/es/rce/alertHandler.js +1 -4
  63. package/es/rce/contentInsertion.js +36 -59
  64. package/es/rce/contentInsertionUtils.js +6 -8
  65. package/es/rce/contentRendering.js +13 -17
  66. package/es/rce/customEvents.js +1 -0
  67. package/es/rce/editorLanguage.js +23 -11
  68. package/es/rce/indicatorRegion.js +7 -7
  69. package/es/rce/normalizeLocale.js +5 -3
  70. package/es/rce/normalizeProps.js +7 -5
  71. package/es/rce/plugins/instructure-ui-icons/plugin.js +21 -3
  72. package/es/rce/plugins/instructure_color/clickCallback.js +82 -0
  73. package/es/rce/plugins/instructure_color/components/ColorPicker.js +294 -0
  74. package/es/rce/plugins/instructure_color/components/ColorPopup.js +67 -0
  75. package/es/rce/plugins/instructure_color/components/colorUtils.js +60 -0
  76. package/es/rce/plugins/instructure_color/plugin.js +40 -0
  77. package/es/rce/plugins/instructure_condensed_buttons/core/ListUtils.js +10 -3
  78. package/es/rce/plugins/instructure_condensed_buttons/plugin.js +1 -0
  79. package/es/rce/plugins/instructure_condensed_buttons/ui/alignment-button.js +1 -2
  80. package/es/rce/plugins/instructure_condensed_buttons/ui/directionality-button.js +3 -2
  81. package/es/rce/plugins/instructure_condensed_buttons/ui/indent-outdent-button.js +1 -0
  82. package/es/rce/plugins/instructure_condensed_buttons/ui/list-button.js +26 -25
  83. package/es/rce/plugins/instructure_condensed_buttons/ui/subscript-superscript-button.js +2 -3
  84. package/es/rce/plugins/instructure_documents/clickCallback.js +1 -0
  85. package/es/rce/plugins/instructure_documents/components/DocumentsPanel.js +1 -9
  86. package/es/rce/plugins/instructure_documents/components/Link.js +4 -20
  87. package/es/rce/plugins/instructure_documents/plugin.js +7 -14
  88. package/es/rce/plugins/instructure_equation/EquationEditorModal/advancedOnlySyntax.js +4 -2
  89. package/es/rce/plugins/instructure_equation/EquationEditorModal/advancedPreference.js +1 -2
  90. package/es/rce/plugins/instructure_equation/EquationEditorModal/index.js +17 -37
  91. package/es/rce/plugins/instructure_equation/EquationEditorModal/latexTextareaUtil.js +14 -15
  92. package/es/rce/plugins/instructure_equation/EquationEditorModal/parseLatex.js +6 -5
  93. package/es/rce/plugins/instructure_equation/EquationEditorModal/styles.js +4 -2
  94. package/es/rce/plugins/instructure_equation/EquationEditorToolbar/buttons.js +14 -8
  95. package/es/rce/plugins/instructure_equation/EquationEditorToolbar/index.js +13 -18
  96. package/es/rce/plugins/instructure_equation/MathIcon/index.js +4 -5
  97. package/es/rce/plugins/instructure_equation/MathIcon/svgs.js +1 -1
  98. package/es/rce/plugins/instructure_equation/clickCallback.js +2 -5
  99. package/es/rce/plugins/instructure_equation/mathlive/index.js +167 -16
  100. package/es/rce/plugins/instructure_equation/plugin.js +7 -10
  101. package/es/rce/plugins/instructure_fullscreen/plugin.js +1 -6
  102. package/es/rce/plugins/instructure_html_view/clickCallback.js +1 -0
  103. package/es/rce/plugins/instructure_html_view/plugin.js +5 -4
  104. package/es/rce/plugins/instructure_icon_maker/clickCallback.js +5 -8
  105. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ColorSection.js +47 -51
  106. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/CreateIconMakerForm.js +10 -10
  107. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Footer.js +11 -11
  108. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Group.js +6 -6
  109. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Header.js +8 -10
  110. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/Course.js +32 -31
  111. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/ImageOptions.js +24 -35
  112. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/ImageSection.js +32 -32
  113. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/ModeSelect.js +11 -11
  114. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/MultiColor/index.js +16 -15
  115. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/MultiColor/svg.js +1 -0
  116. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SVGList.js +11 -11
  117. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SVGThumbnail.js +9 -13
  118. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SingleColor/index.js +12 -13
  119. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SingleColor/svg.js +33 -80
  120. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/Upload.js +34 -28
  121. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/index.js +1 -0
  122. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/propTypes.js +1 -0
  123. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/utils.js +5 -5
  124. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Preview.js +7 -8
  125. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ShapeSection.js +5 -7
  126. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/TextSection.js +5 -10
  127. package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/index.js +1 -0
  128. package/es/rce/plugins/instructure_icon_maker/components/IconMakerTray.js +38 -60
  129. package/es/rce/plugins/instructure_icon_maker/components/SavedIconMakerList.js +4 -4
  130. package/es/rce/plugins/instructure_icon_maker/plugin.js +10 -14
  131. package/es/rce/plugins/instructure_icon_maker/reducers/imageSection.js +37 -38
  132. package/es/rce/plugins/instructure_icon_maker/reducers/svgSettings.js +24 -24
  133. package/es/rce/plugins/instructure_icon_maker/registerEditToolbar.js +2 -4
  134. package/es/rce/plugins/instructure_icon_maker/svg/constants.js +4 -3
  135. package/es/rce/plugins/instructure_icon_maker/svg/font.js +3 -1
  136. package/es/rce/plugins/instructure_icon_maker/svg/image.js +74 -90
  137. package/es/rce/plugins/instructure_icon_maker/svg/index.js +17 -24
  138. package/es/rce/plugins/instructure_icon_maker/svg/metadata.js +1 -0
  139. package/es/rce/plugins/instructure_icon_maker/svg/settings.js +48 -58
  140. package/es/rce/plugins/instructure_icon_maker/svg/shape.js +5 -54
  141. package/es/rce/plugins/instructure_icon_maker/svg/text.js +35 -124
  142. package/es/rce/plugins/instructure_icon_maker/svg/utils.js +3 -11
  143. package/es/rce/plugins/instructure_icon_maker/utils/IconMakerClose.js +4 -9
  144. package/es/rce/plugins/instructure_icon_maker/utils/IconMakerFormHasChanges.js +1 -15
  145. package/es/rce/plugins/instructure_icon_maker/utils/addIconMakerAttributes.js +3 -4
  146. package/es/rce/plugins/instructure_icon_maker/utils/iconValidation.js +2 -3
  147. package/es/rce/plugins/instructure_icon_maker/utils/iconsLabels.js +1 -0
  148. package/es/rce/plugins/instructure_icon_maker/utils/useDebouncedValue.js +12 -13
  149. package/es/rce/plugins/instructure_image/ImageEmbedOptions.js +9 -31
  150. package/es/rce/plugins/instructure_image/ImageList/Image.js +8 -14
  151. package/es/rce/plugins/instructure_image/ImageList/index.js +8 -10
  152. package/es/rce/plugins/instructure_image/ImageOptionsTray/TrayController.js +9 -31
  153. package/es/rce/plugins/instructure_image/ImageOptionsTray/index.js +6 -19
  154. package/es/rce/plugins/instructure_image/Images/index.js +1 -3
  155. package/es/rce/plugins/instructure_image/clickCallback.js +1 -0
  156. package/es/rce/plugins/instructure_image/plugin.js +14 -20
  157. package/es/rce/plugins/instructure_links/clickCallback.js +1 -0
  158. package/es/rce/plugins/instructure_links/components/AccordionSection.js +8 -8
  159. package/es/rce/plugins/instructure_links/components/CollectionPanel.js +1 -3
  160. package/es/rce/plugins/instructure_links/components/Link.js +68 -84
  161. package/es/rce/plugins/instructure_links/components/LinkOptionsDialog/LinkOptionsDialogController.js +2 -23
  162. package/es/rce/plugins/instructure_links/components/LinkOptionsDialog/index.js +3 -6
  163. package/es/rce/plugins/instructure_links/components/LinkOptionsTray/LinkOptionsTrayController.js +3 -20
  164. package/es/rce/plugins/instructure_links/components/LinkOptionsTray/index.js +3 -14
  165. package/es/rce/plugins/instructure_links/components/LinkSet.js +32 -57
  166. package/es/rce/plugins/instructure_links/components/LinksPanel.js +22 -10
  167. package/es/rce/plugins/instructure_links/components/NavigationPanel.js +7 -9
  168. package/es/rce/plugins/instructure_links/components/NoResults.js +7 -14
  169. package/es/rce/plugins/instructure_links/plugin.js +23 -49
  170. package/es/rce/plugins/instructure_links/validateURL.js +81 -36
  171. package/es/rce/plugins/instructure_media_embed/clickCallback.js +5 -9
  172. package/es/rce/plugins/instructure_media_embed/components/Embed.js +7 -7
  173. package/es/rce/plugins/instructure_media_embed/plugin.js +7 -3
  174. package/es/rce/plugins/instructure_paste/pasteMenuCommand.js +1 -5
  175. package/es/rce/plugins/instructure_paste/plugin.js +29 -33
  176. package/es/rce/plugins/instructure_rce_external_tools/ExternalToolsEnv.js +31 -79
  177. package/es/rce/plugins/instructure_rce_external_tools/RceToolWrapper.js +24 -83
  178. package/es/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialog.js +39 -69
  179. package/es/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialogModal.js +1 -2
  180. package/es/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialogTray.js +1 -1
  181. package/es/rce/plugins/instructure_rce_external_tools/components/ExternalToolSelectionDialog/ExternalToolSelectionDialog.js +5 -14
  182. package/es/rce/plugins/instructure_rce_external_tools/components/ExternalToolSelectionDialog/ExternalToolSelectionItem.js +1 -2
  183. package/es/rce/plugins/instructure_rce_external_tools/components/util/ExpandoText.js +1 -0
  184. package/es/rce/plugins/instructure_rce_external_tools/components/util/ToolLaunchIframe.js +2 -1
  185. package/es/rce/plugins/instructure_rce_external_tools/constants.js +28 -0
  186. package/es/rce/plugins/instructure_rce_external_tools/dialog-helper.js +20 -6
  187. package/es/rce/plugins/instructure_rce_external_tools/helpers/tags.js +0 -2
  188. package/es/rce/plugins/instructure_rce_external_tools/jquery/jquery.dropdownList.js +129 -136
  189. package/es/rce/plugins/instructure_rce_external_tools/lti11-content-items/RceLti11ContentItem.js +110 -112
  190. package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/Lti13ContentItemJson.js +1 -0
  191. package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/RceLti13ContentItem.js +4 -21
  192. package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/BaseLinkContentItem.js +5 -19
  193. package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/HtmlFragmentContentItem.js +1 -6
  194. package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/ImageContentItem.js +1 -9
  195. package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/LinkContentItem.js +1 -1
  196. package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/ResourceLinkContentItem.js +3 -5
  197. package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/processEditorContentItems.js +23 -16
  198. package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/rceLti13ContentItemFromJson.js +3 -4
  199. package/es/rce/plugins/instructure_rce_external_tools/plugin.js +11 -20
  200. package/es/rce/plugins/instructure_rce_external_tools/util/addParentFrameContextToUrl.js +1 -1
  201. package/es/rce/plugins/instructure_rce_external_tools/util/externalToolsForToolbar.js +42 -0
  202. package/es/rce/plugins/instructure_record/AudioOptionsTray/TrayController.js +6 -35
  203. package/es/rce/plugins/instructure_record/AudioOptionsTray/index.js +13 -17
  204. package/es/rce/plugins/instructure_record/MediaPanel/index.js +1 -9
  205. package/es/rce/plugins/instructure_record/VideoOptionsTray/TrayController.js +16 -66
  206. package/es/rce/plugins/instructure_record/VideoOptionsTray/index.js +21 -35
  207. package/es/rce/plugins/instructure_record/clickCallback.js +32 -44
  208. package/es/rce/plugins/instructure_record/mediaTranslations.js +1 -0
  209. package/es/rce/plugins/instructure_record/plugin.js +11 -18
  210. package/es/rce/plugins/instructure_search_and_replace/clickCallback.js +4 -8
  211. package/es/rce/plugins/instructure_search_and_replace/components/FindReplaceTray.js +34 -51
  212. package/es/rce/plugins/instructure_search_and_replace/components/FindReplaceTrayController.js +12 -30
  213. package/es/rce/plugins/instructure_search_and_replace/getSelectionContext.js +2 -9
  214. package/es/rce/plugins/instructure_search_and_replace/plugin.js +2 -5
  215. package/es/rce/plugins/instructure_studio_media_options/plugin.js +1 -1
  216. package/es/rce/plugins/instructure_wordcount/clickCallback.js +5 -9
  217. package/es/rce/plugins/instructure_wordcount/components/WordCountModal.js +27 -37
  218. package/es/rce/plugins/instructure_wordcount/plugin.js +1 -0
  219. package/es/rce/plugins/instructure_wordcount/utils/countContent.js +4 -11
  220. package/es/rce/plugins/instructure_wordcount/utils/tableContent.js +6 -8
  221. package/es/rce/plugins/shared/CanvasContentTray.js +29 -63
  222. package/es/rce/plugins/shared/CheckerboardStyling.js +1 -1
  223. package/es/rce/plugins/shared/ColorInput.js +27 -39
  224. package/es/rce/plugins/shared/ConditionalTooltip.js +6 -6
  225. package/es/rce/plugins/shared/ContentSelection.js +29 -78
  226. package/es/rce/plugins/shared/DimensionUtils.js +3 -12
  227. package/es/rce/plugins/shared/DimensionsInput/DimensionInput.js +6 -6
  228. package/es/rce/plugins/shared/DimensionsInput/index.js +37 -15
  229. package/es/rce/plugins/shared/DimensionsInput/useDimensionsState.js +5 -29
  230. package/es/rce/plugins/shared/ErrorBoundary.js +2 -5
  231. package/es/rce/plugins/shared/EventUtils.js +2 -4
  232. package/es/rce/plugins/shared/Filter.js +8 -38
  233. package/es/rce/plugins/shared/FixedContentTray.js +16 -17
  234. package/es/rce/plugins/shared/ImageCropper/DirectionRegion.js +4 -12
  235. package/es/rce/plugins/shared/ImageCropper/Modal.js +16 -20
  236. package/es/rce/plugins/shared/ImageCropper/Preview.js +18 -24
  237. package/es/rce/plugins/shared/ImageCropper/constants.js +1 -0
  238. package/es/rce/plugins/shared/ImageCropper/controls/CustomNumberInput.js +10 -14
  239. package/es/rce/plugins/shared/ImageCropper/controls/ResetControls.js +4 -4
  240. package/es/rce/plugins/shared/ImageCropper/controls/RotationControls.js +5 -15
  241. package/es/rce/plugins/shared/ImageCropper/controls/ShapeControls.js +8 -11
  242. package/es/rce/plugins/shared/ImageCropper/controls/ZoomControls.js +5 -16
  243. package/es/rce/plugins/shared/ImageCropper/controls/index.js +5 -5
  244. package/es/rce/plugins/shared/ImageCropper/controls/useDebouncedNumericValue.js +16 -31
  245. package/es/rce/plugins/shared/ImageCropper/controls/utils.js +1 -2
  246. package/es/rce/plugins/shared/ImageCropper/imageCropUtils.js +19 -31
  247. package/es/rce/plugins/shared/ImageCropper/index.js +1 -0
  248. package/es/rce/plugins/shared/ImageCropper/propTypes.js +1 -0
  249. package/es/rce/plugins/shared/ImageCropper/reducers/imageCropper.js +15 -14
  250. package/es/rce/plugins/shared/ImageCropper/shape.js +1 -0
  251. package/es/rce/plugins/shared/ImageCropper/svg/index.js +1 -2
  252. package/es/rce/plugins/shared/ImageCropper/svg/shape.js +5 -22
  253. package/es/rce/plugins/shared/ImageCropper/svg/utils.js +3 -4
  254. package/es/rce/plugins/shared/ImageCropper/useKeyMouseEvents.js +20 -50
  255. package/es/rce/plugins/shared/ImageCropper/useMouseWheel.js +8 -10
  256. package/es/rce/plugins/shared/ImageOptionsForm.js +18 -20
  257. package/es/rce/plugins/shared/LinkDisplay.js +9 -11
  258. package/es/rce/plugins/shared/PreviewIcon.js +9 -15
  259. package/es/rce/plugins/shared/Previewable.js +1 -0
  260. package/es/rce/plugins/shared/RceFileBrowser.js +7 -10
  261. package/es/rce/plugins/shared/StoreContext.js +9 -12
  262. package/es/rce/plugins/shared/StudioLtiSupportUtils.js +15 -12
  263. package/es/rce/plugins/shared/UnknownFileTypePanel.js +1 -0
  264. package/es/rce/plugins/shared/Upload/CanvasContentPanel.js +19 -25
  265. package/es/rce/plugins/shared/Upload/CategoryProcessor.js +2 -3
  266. package/es/rce/plugins/shared/Upload/ComputerPanel.js +19 -40
  267. package/es/rce/plugins/shared/Upload/PanelFilter.js +10 -20
  268. package/es/rce/plugins/shared/Upload/SvgCategoryProcessor.js +4 -3
  269. package/es/rce/plugins/shared/Upload/UploadFile.js +32 -38
  270. package/es/rce/plugins/shared/Upload/UploadFileModal.js +37 -59
  271. package/es/rce/plugins/shared/Upload/UrlPanel.js +5 -5
  272. package/es/rce/plugins/shared/Upload/UsageRightsSelectBox.js +25 -36
  273. package/es/rce/plugins/shared/Upload/doFileUpload.js +10 -13
  274. package/es/rce/plugins/shared/Upload/index.js +1 -0
  275. package/es/rce/plugins/shared/ai_tools/AIResponseModal.js +8 -11
  276. package/es/rce/plugins/shared/ai_tools/AIToolsTray.js +19 -40
  277. package/es/rce/plugins/shared/ai_tools/aiicons.js +3 -2
  278. package/es/rce/plugins/shared/ai_tools/index.js +1 -0
  279. package/es/rce/plugins/shared/buildDownloadUrl.js +0 -2
  280. package/es/rce/plugins/shared/canvasContentUtils.js +7 -11
  281. package/es/rce/plugins/shared/compressionUtils.js +18 -28
  282. package/es/rce/plugins/shared/dateUtils.js +1 -1
  283. package/es/rce/plugins/shared/do-fetch-api-effect/defaultFetchOptions.js +4 -2
  284. package/es/rce/plugins/shared/do-fetch-api-effect/doFetchApi.js +18 -24
  285. package/es/rce/plugins/shared/do-fetch-api-effect/get-cookie.js +1 -1
  286. package/es/rce/plugins/shared/do-fetch-api-effect/index.js +1 -0
  287. package/es/rce/plugins/shared/do-fetch-api-effect/parse-link-header.js +6 -20
  288. package/es/rce/plugins/shared/do-fetch-api-effect/query-string-encoding.js +5 -3
  289. package/es/rce/plugins/shared/fileShape.js +4 -9
  290. package/es/rce/plugins/shared/fileTypeUtils.js +34 -47
  291. package/es/rce/plugins/shared/fileUtils.js +1 -2
  292. package/es/rce/plugins/shared/linkUtils.js +1 -16
  293. package/es/rce/plugins/shared/round.js +2 -2
  294. package/es/rce/plugins/shared/trayUtils.js +7 -3
  295. package/es/rce/plugins/shared/useDataUrl.js +13 -14
  296. package/es/rce/plugins/shared/useFilterSettings.js +3 -3
  297. package/es/rce/plugins/tinymce-a11y-checker/components/ColorField.js +4 -8
  298. package/es/rce/plugins/tinymce-a11y-checker/components/checker.js +12 -72
  299. package/es/rce/plugins/tinymce-a11y-checker/components/color-picker.js +1 -2
  300. package/es/rce/plugins/tinymce-a11y-checker/components/placeholder-svg.js +1 -0
  301. package/es/rce/plugins/tinymce-a11y-checker/components/pointer.js +1 -0
  302. package/es/rce/plugins/tinymce-a11y-checker/node-checker.js +2 -9
  303. package/es/rce/plugins/tinymce-a11y-checker/plugin.js +18 -24
  304. package/es/rce/plugins/tinymce-a11y-checker/rules/adjacent-links.js +3 -26
  305. package/es/rce/plugins/tinymce-a11y-checker/rules/headings-sequence.js +9 -38
  306. package/es/rce/plugins/tinymce-a11y-checker/rules/headings-start-at-h2.js +2 -7
  307. package/es/rce/plugins/tinymce-a11y-checker/rules/img-alt-filename.js +1 -2
  308. package/es/rce/plugins/tinymce-a11y-checker/rules/img-alt-length.js +1 -1
  309. package/es/rce/plugins/tinymce-a11y-checker/rules/img-alt.js +1 -2
  310. package/es/rce/plugins/tinymce-a11y-checker/rules/index.js +1 -0
  311. package/es/rce/plugins/tinymce-a11y-checker/rules/large-text-contrast.js +2 -6
  312. package/es/rce/plugins/tinymce-a11y-checker/rules/list-structure.js +5 -24
  313. package/es/rce/plugins/tinymce-a11y-checker/rules/paragraphs-for-headings.js +1 -3
  314. package/es/rce/plugins/tinymce-a11y-checker/rules/small-text-contrast.js +2 -8
  315. package/es/rce/plugins/tinymce-a11y-checker/rules/table-caption.js +1 -3
  316. package/es/rce/plugins/tinymce-a11y-checker/rules/table-header-scope.js +1 -2
  317. package/es/rce/plugins/tinymce-a11y-checker/rules/table-header.js +1 -9
  318. package/es/rce/plugins/tinymce-a11y-checker/utils/colors.js +1 -0
  319. package/es/rce/plugins/tinymce-a11y-checker/utils/describe.js +1 -7
  320. package/es/rce/plugins/tinymce-a11y-checker/utils/dom.js +3 -30
  321. package/es/rce/plugins/tinymce-a11y-checker/utils/indicate.js +18 -18
  322. package/es/rce/plugins/tinymce-a11y-checker/utils/rgb-hex.js +6 -12
  323. package/es/rce/plugins/tinymce-a11y-checker/utils/strings.js +1 -4
  324. package/es/rce/root.js +17 -16
  325. package/es/rce/sanitizePlugins.js +1 -3
  326. package/es/rce/style.js +1 -4
  327. package/es/rce/tinyRCE.js +14 -9
  328. package/es/rce/tinymce.oxide.content.min.css.js +1 -0
  329. package/es/rce/tinymce.oxide.skin.min.css.js +1 -0
  330. package/es/rce/transformContent.js +9 -11
  331. package/es/rce/types.js +1 -0
  332. package/es/rce/userOS.js +1 -1
  333. package/es/rce/wrapInitCb.js +50 -43
  334. package/es/rcs/api.js +100 -171
  335. package/es/rcs/buildError.js +8 -20
  336. package/es/rcs/fake.js +9 -20
  337. package/es/sidebar/actions/all_files.js +2 -0
  338. package/es/sidebar/actions/data.js +4 -7
  339. package/es/sidebar/actions/documents.js +19 -18
  340. package/es/sidebar/actions/files.js +21 -28
  341. package/es/sidebar/actions/filter.js +5 -5
  342. package/es/sidebar/actions/flickr.js +1 -1
  343. package/es/sidebar/actions/images.js +32 -37
  344. package/es/sidebar/actions/links.js +1 -0
  345. package/es/sidebar/actions/media.js +27 -28
  346. package/es/sidebar/actions/session.js +2 -5
  347. package/es/sidebar/actions/ui.js +1 -0
  348. package/es/sidebar/actions/upload.js +38 -74
  349. package/es/sidebar/containers/Sidebar.js +1 -2
  350. package/es/sidebar/containers/sidebarHandlers.js +9 -13
  351. package/es/sidebar/dragHtml.js +11 -5
  352. package/es/sidebar/reducers/all_files.js +5 -6
  353. package/es/sidebar/reducers/collection.js +12 -15
  354. package/es/sidebar/reducers/collections.js +6 -8
  355. package/es/sidebar/reducers/documents.js +7 -16
  356. package/es/sidebar/reducers/files.js +4 -6
  357. package/es/sidebar/reducers/filter.js +8 -23
  358. package/es/sidebar/reducers/flickr.js +10 -12
  359. package/es/sidebar/reducers/folder.js +16 -18
  360. package/es/sidebar/reducers/folders.js +4 -6
  361. package/es/sidebar/reducers/images.js +4 -16
  362. package/es/sidebar/reducers/index.js +3 -1
  363. package/es/sidebar/reducers/media.js +7 -16
  364. package/es/sidebar/reducers/newPageLinkExpanded.js +2 -5
  365. package/es/sidebar/reducers/noop.js +2 -2
  366. package/es/sidebar/reducers/rootFolderId.js +2 -5
  367. package/es/sidebar/reducers/session.js +4 -6
  368. package/es/sidebar/reducers/ui.js +6 -25
  369. package/es/sidebar/reducers/upload.js +16 -64
  370. package/es/sidebar/store/configureStore.js +1 -0
  371. package/es/sidebar/store/initialState.js +14 -26
  372. package/es/translations/locales/ab.js +1 -0
  373. package/es/translations/locales/ar.js +72 -8
  374. package/es/translations/locales/ca.js +72 -8
  375. package/es/translations/locales/cs.js +1 -0
  376. package/es/translations/locales/cs_CZ.js +1 -0
  377. package/es/translations/locales/cy.js +72 -8
  378. package/es/translations/locales/da-x-k12.js +72 -8
  379. package/es/translations/locales/da.js +72 -8
  380. package/es/translations/locales/da_DK.js +1 -0
  381. package/es/translations/locales/de.js +72 -8
  382. package/es/translations/locales/el.js +4 -0
  383. package/es/translations/locales/en-AU-x-unimelb.js +72 -8
  384. package/es/translations/locales/en-GB-x-ukhe.js +72 -8
  385. package/es/translations/locales/en.js +72 -8
  386. package/es/translations/locales/en_AU.js +72 -8
  387. package/es/translations/locales/en_CA.js +72 -8
  388. package/es/translations/locales/en_CY.js +72 -8
  389. package/es/translations/locales/en_GB.js +72 -8
  390. package/es/translations/locales/en_NZ.js +1 -0
  391. package/es/translations/locales/en_SE.js +1 -0
  392. package/es/translations/locales/en_US.js +1 -0
  393. package/es/translations/locales/es.js +72 -8
  394. package/es/translations/locales/es_ES.js +72 -8
  395. package/es/translations/locales/es_GT.js +1 -0
  396. package/es/translations/locales/fa_IR.js +7 -0
  397. package/es/translations/locales/fi.js +72 -8
  398. package/es/translations/locales/fr.js +72 -8
  399. package/es/translations/locales/fr_CA.js +73 -9
  400. package/es/translations/locales/ga.js +5 -13
  401. package/es/translations/locales/he.js +7 -0
  402. package/es/translations/locales/hi.js +72 -8
  403. package/es/translations/locales/ht.js +72 -8
  404. package/es/translations/locales/hu.js +7 -6
  405. package/es/translations/locales/hu_HU.js +1 -0
  406. package/es/translations/locales/hy.js +1 -0
  407. package/es/translations/locales/id.js +72 -8
  408. package/es/translations/locales/id_ID.js +1 -0
  409. package/es/translations/locales/is.js +72 -8
  410. package/es/translations/locales/it.js +72 -8
  411. package/es/translations/locales/ja.js +72 -8
  412. package/es/translations/locales/ko.js +1 -0
  413. package/es/translations/locales/ko_KR.js +1 -0
  414. package/es/translations/locales/lt.js +1 -0
  415. package/es/translations/locales/lt_LT.js +1 -0
  416. package/es/translations/locales/mi.js +72 -8
  417. package/es/translations/locales/mn_MN.js +1 -0
  418. package/es/translations/locales/ms.js +72 -8
  419. package/es/translations/locales/nb-x-k12.js +72 -8
  420. package/es/translations/locales/nb.js +72 -8
  421. package/es/translations/locales/nl.js +72 -8
  422. package/es/translations/locales/nl_NL.js +1 -0
  423. package/es/translations/locales/nn.js +7 -6
  424. package/es/translations/locales/pl.js +72 -8
  425. package/es/translations/locales/pt.js +72 -8
  426. package/es/translations/locales/pt_BR.js +72 -8
  427. package/es/translations/locales/ro.js +1 -0
  428. package/es/translations/locales/ru.js +72 -8
  429. package/es/translations/locales/se.js +1 -0
  430. package/es/translations/locales/sl.js +72 -8
  431. package/es/translations/locales/sv-x-k12.js +72 -8
  432. package/es/translations/locales/sv.js +72 -8
  433. package/es/translations/locales/sv_SE.js +1 -0
  434. package/es/translations/locales/tg.js +1 -0
  435. package/es/translations/locales/th.js +72 -8
  436. package/es/translations/locales/th_TH.js +1 -0
  437. package/es/translations/locales/tl_PH.js +1 -0
  438. package/es/translations/locales/tr.js +7 -0
  439. package/es/translations/locales/uk_UA.js +7 -0
  440. package/es/translations/locales/vi.js +72 -8
  441. package/es/translations/locales/vi_VN.js +1 -0
  442. package/es/translations/locales/zh-Hans.js +72 -8
  443. package/es/translations/locales/zh-Hant.js +72 -8
  444. package/es/translations/locales/zh.js +72 -8
  445. package/es/translations/locales/zh_HK.js +72 -8
  446. package/es/translations/locales/zh_TW.Big5.js +1 -0
  447. package/es/translations/locales/zh_TW.js +1 -0
  448. package/es/translations/tinymce/ar_SA.js +1 -0
  449. package/es/translations/tinymce/fi.js +1 -0
  450. package/es/translations/tinymce/ga.js +1 -0
  451. package/es/translations/tinymce/id.js +1 -0
  452. package/es/translations/tinymce/ru.js +1 -0
  453. package/es/translations/tinymce/ru_RU.js +1 -0
  454. package/es/translations/tinymce/sl.js +1 -0
  455. package/es/translations/tinymce/sr.js +1 -0
  456. package/es/translations/tinymce/th.js +1 -0
  457. package/es/translations/tinymce/uk_UA.js +1 -0
  458. package/es/translations/tinymce/vi_VN.js +1 -0
  459. package/es/util/TypedDict.js +4 -2
  460. package/es/util/elem-util.js +1 -1
  461. package/es/util/encrypted-storage.js +3 -13
  462. package/es/util/file-url-util.js +2 -7
  463. package/es/util/fullscreenHelpers.js +9 -9
  464. package/es/util/instui-icon-helper.js +4 -3
  465. package/es/util/loadingPlaceholder.js +39 -41
  466. package/es/util/simpleCache.js +1 -5
  467. package/es/util/string-util.js +1 -1
  468. package/es/util/textarea-editing-util.js +3 -7
  469. package/es/util/tinymce-plugin-util.js +0 -5
  470. package/es/util/url-util.js +20 -29
  471. package/eslint.config.js +250 -0
  472. package/jest.config.js +1 -1
  473. package/locales/en.json +190 -10
  474. package/package.json +78 -82
  475. package/scripts/build-canvas +2 -1
  476. package/scripts/build.js +4 -4
  477. package/scripts/installTranslations.js +7 -8
  478. package/testcafe/RCEWrapper.test.js +0 -1
  479. package/testcafe/StatusBar.test.js +0 -1
  480. package/testcafe/axe.test.js +3 -4
  481. package/testcafe/enhanceUserContent.test.js +0 -1
  482. package/tsconfig.json +21 -16
  483. package/{es/rce/__mocks__/styleMock.js → types/format-message-generate-id.d.ts} +6 -2
  484. package/{es/rce/plugins/shared/__mocks__/screenfull.js → types/js-beautify.d.ts} +4 -7
  485. package/.eslintrc +0 -45
  486. package/.prettierignore +0 -6
  487. package/es/rce/__mocks__/_mockCryptoEs.js +0 -124
  488. package/es/rce/__mocks__/tinymceReact.js +0 -55
  489. package/es/rce/plugins/tinymce-a11y-checker/rules/__mocks__/index.js +0 -53
@@ -1,5 +1,4 @@
1
1
  import _pt from "prop-types";
2
-
3
2
  /*
4
3
  * Copyright (C) 2024 - present Instructure, Inc.
5
4
  *
@@ -17,6 +16,7 @@ import _pt from "prop-types";
17
16
  * You should have received a copy of the GNU Affero General Public License along
18
17
  * with this program. If not, see <http://www.gnu.org/licenses/>.
19
18
  */
19
+
20
20
  import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
21
21
  import formatMessage from '../../../../format-message';
22
22
  import { Button, CloseButton, CondensedButton, IconButton } from '@instructure/ui-buttons';
@@ -35,24 +35,21 @@ import { showFlashAlert } from '../../../../common/FlashAlert';
35
35
  import doFetchApi from '../do-fetch-api-effect';
36
36
  import { AIWandSVG, AIAvatarSVG, InsertSVG, CopySVG, RefreshSVG, DislikeSVG } from './aiicons';
37
37
  import { AIResponseModal } from './AIResponseModal';
38
-
39
38
  const msgid = () => uid('msg', 3);
40
-
41
39
  const modifyAllTaskMessage = formatMessage('Hello. Please describe the modifications you would like to make to your composition.');
42
40
  const modifySelectionTaskMessage = formatMessage('Hello. Please describe the modifications you would like to make to your selection.');
43
41
  const generateTaskMessage = formatMessage('Please decribe what you would like to compose.');
44
- export const AIToolsTray = _ref => {
45
- let {
46
- open,
47
- container,
48
- mountNode,
49
- contextId,
50
- contextType,
51
- currentContent,
52
- onClose,
53
- onInsertContent,
54
- onReplaceContent
55
- } = _ref;
42
+ export const AIToolsTray = ({
43
+ open,
44
+ container,
45
+ mountNode,
46
+ contextId,
47
+ contextType,
48
+ currentContent,
49
+ onClose,
50
+ onInsertContent,
51
+ onReplaceContent
52
+ }) => {
56
53
  const [trayRef, setTrayRef] = useState(null);
57
54
  const [containerStyle] = useState(() => {
58
55
  if (container) {
@@ -62,7 +59,6 @@ export const AIToolsTray = _ref => {
62
59
  transition: container.style.transition
63
60
  };
64
61
  }
65
-
66
62
  return {};
67
63
  });
68
64
  const [isOpen, setIsOpen] = useState(open);
@@ -94,10 +90,8 @@ export const AIToolsTray = _ref => {
94
90
  setUserPrompt('');
95
91
  }, [initChatMessages]);
96
92
  useLayoutEffect(() => {
97
- var _chatContainerRef$cur;
98
-
99
- const lastbox = (_chatContainerRef$cur = chatContainerRef.current) === null || _chatContainerRef$cur === void 0 ? void 0 : _chatContainerRef$cur.querySelector('.ai-chat-box:last-child');
100
- lastbox === null || lastbox === void 0 ? void 0 : lastbox.scrollIntoView({
93
+ const lastbox = chatContainerRef.current?.querySelector('.ai-chat-box:last-child');
94
+ lastbox?.scrollIntoView({
101
95
  behavior: 'smooth',
102
96
  block: 'nearest'
103
97
  });
@@ -121,7 +115,6 @@ export const AIToolsTray = _ref => {
121
115
  const ed_rect = ed.getBoundingClientRect();
122
116
  const padding = parseInt(edstyle.paddingRight, 10);
123
117
  const tray_left = window.innerWidth - trayRef.offsetWidth;
124
-
125
118
  if (ed_rect.right > tray_left) {
126
119
  ed.style.boxSizing = 'border-box';
127
120
  ed.style.width = `${ed_rect.width - (ed_rect.right - tray_left - padding)}px`;
@@ -135,8 +128,9 @@ export const AIToolsTray = _ref => {
135
128
  }
136
129
  }, [containerStyle, open, trayRef]);
137
130
  const getResponse = useCallback(prompt => {
138
- setWaitingForResponse(true); // the .finally triggered the error even though there is a .catch
139
- // eslint-disable-next-line promise/catch-or-return
131
+ setWaitingForResponse(true);
132
+
133
+ // the .finally triggered the error even though there is a .catch
140
134
 
141
135
  doFetchApi({
142
136
  path: '/api/v1/rich_content/generate',
@@ -156,7 +150,6 @@ export const AIToolsTray = _ref => {
156
150
  const {
157
151
  json
158
152
  } = result;
159
-
160
153
  if (json.error) {
161
154
  chatMessagesRef.current.push({
162
155
  id: msgid(),
@@ -217,7 +210,6 @@ export const AIToolsTray = _ref => {
217
210
  }, [onInsertContent]);
218
211
  const handleCopyResponse = useCallback(async responseText => {
219
212
  try {
220
- // @ts-expect-error ClipboardItem.supports really does exist
221
213
  if (ClipboardItem.supports('text/html')) {
222
214
  const htmlBlob = new Blob([responseText], {
223
215
  type: 'text/html'
@@ -230,7 +222,6 @@ export const AIToolsTray = _ref => {
230
222
  div.innerHTML = responseText;
231
223
  await navigator.clipboard.writeText(div.textContent || '');
232
224
  }
233
-
234
225
  showFlashAlert({
235
226
  message: formatMessage('Response copied to clipboard'),
236
227
  type: 'success',
@@ -248,13 +239,11 @@ export const AIToolsTray = _ref => {
248
239
  getResponse(userPrompt);
249
240
  }, [getResponse, userPrompt]);
250
241
  const handleDislikeResponse = useCallback(() => {
251
- // eslint-disable-next-line no-console
252
242
  console.log('dislike response'); // TODO: what?
253
243
  }, []);
254
244
  const handleShowWholeResponse = useCallback(event => {
255
245
  const msgId = event.target.dataset.messageId;
256
246
  const message = chatMessagesRef.current.find(msg => msg.id === msgId);
257
-
258
247
  if (message) {
259
248
  setResponseHtml(message.message);
260
249
  }
@@ -270,7 +259,6 @@ export const AIToolsTray = _ref => {
270
259
  onReplaceContent(responseHtml);
271
260
  handleCloseResponseModal();
272
261
  }, [handleCloseResponseModal, onReplaceContent, responseHtml]);
273
-
274
262
  const sharkfin = () => {
275
263
  return /*#__PURE__*/React.createElement("svg", {
276
264
  width: "14",
@@ -288,14 +276,11 @@ export const AIToolsTray = _ref => {
288
276
  strokeWidth: "2"
289
277
  }));
290
278
  };
291
-
292
279
  const renderResponse = msgId => {
293
280
  const message = chatMessagesRef.current.find(msg => msg.id === msgId);
294
-
295
281
  if (!message) {
296
282
  return /*#__PURE__*/React.createElement("span", null, formatMessage("I'm sorry, but I cannot find the AI's answer"));
297
283
  }
298
-
299
284
  const div = document.createElement('div');
300
285
  div.innerHTML = message.message;
301
286
  return /*#__PURE__*/React.createElement("div", {
@@ -313,9 +298,9 @@ export const AIToolsTray = _ref => {
313
298
  onClick: handleShowWholeResponse,
314
299
  "data-message-id": msgId
315
300
  }, formatMessage('Show all'))));
316
- }; // TODO: should the response box get truncated?
317
-
301
+ };
318
302
 
303
+ // TODO: should the response box get truncated?
319
304
  const renderChatBox = (message, key) => {
320
305
  return /*#__PURE__*/React.createElement("div", {
321
306
  id: message.id,
@@ -346,11 +331,9 @@ export const AIToolsTray = _ref => {
346
331
  top: '-18px',
347
332
  // Adjust this value to position the sharkfin
348
333
  left: '40px' // Adjust this value to align the sharkfin horizontally
349
-
350
334
  }
351
335
  }, sharkfin())), message.type === 'response' ?
352
336
  /*#__PURE__*/
353
-
354
337
  /* TODO: why is it to wide w/o maxWidth? */
355
338
  React.createElement("div", {
356
339
  style: {
@@ -394,12 +377,10 @@ export const AIToolsTray = _ref => {
394
377
  size: "x-small"
395
378
  }))) : null);
396
379
  };
397
-
398
380
  const renderChatMessages = () => {
399
381
  const messages = chatMessagesRef.current.map(message => {
400
382
  return renderChatBox(message, message.id);
401
383
  });
402
-
403
384
  if (waitingForResponse) {
404
385
  messages.push(renderChatBox({
405
386
  id: msgid(),
@@ -407,10 +388,8 @@ export const AIToolsTray = _ref => {
407
388
  message: formatMessage('Waiting for response')
408
389
  }, 'ai-waiting-message'));
409
390
  }
410
-
411
391
  return messages;
412
392
  };
413
-
414
393
  return /*#__PURE__*/React.createElement(Tray, {
415
394
  contentRef: el => setTrayRef(el),
416
395
  label: "AIToolsTray",
@@ -15,6 +15,7 @@
15
15
  * You should have received a copy of the GNU Affero General Public License along
16
16
  * with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
+
18
19
  // @ts-expect-error
19
20
  import { IconCopyLine, IconRefreshLine } from '@instructure/ui-icons/es/svg';
20
21
  const AIWandSVG = `<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -37,8 +38,8 @@ const InsertSVG = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18
37
38
  <path d="M3.59082 14.4093H14.4099V3.59058H3.59082V14.4093ZM4.64532 4.64508H13.3551V13.3548H4.64532V4.64508Z" fill="#2D3B45"/>
38
39
  <path d="M9.52752 6.92065H8.47302V8.47278H6.9209V9.52728H8.47302V11.0794H9.52752V9.52728H11.0796V8.47278H9.52752V6.92065Z" fill="#2D3B45"/>
39
40
  </svg>`;
40
- const CopySVG = IconCopyLine === null || IconCopyLine === void 0 ? void 0 : IconCopyLine.src;
41
- const RefreshSVG = IconRefreshLine === null || IconRefreshLine === void 0 ? void 0 : IconRefreshLine.src;
41
+ const CopySVG = IconCopyLine?.src;
42
+ const RefreshSVG = IconRefreshLine?.src;
42
43
  const DislikeSVG = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
43
44
  <path fill-rule="evenodd" clip-rule="evenodd" d="M2.17647 7.41176L3.2353 7.41176L3.2353 6.35294C2.65189 6.35294 2.17647 5.87859 2.17647 5.29411C2.17647 4.70964 2.65189 4.23529 3.2353 4.23529L4.29412 4.23529L4.29412 3.17647C3.71071 3.17647 3.2353 2.70211 3.2353 2.11764C3.2353 1.53317 3.71071 1.05882 4.29412 1.05882L13.2941 1.05882C14.7532 1.05882 15.9412 2.24576 15.9412 3.70588L15.9412 9.52941L14.9417 9.52941C13.6277 9.52941 12.3698 10.0694 11.4888 11.0086C10.2267 12.3554 8.738 14.4445 8.54953 16.9412L8.20859 16.9412C7.7353 16.9412 7.28953 16.7315 6.98671 16.3652C6.68071 15.9946 6.55683 15.5107 6.64788 15.0385C6.86071 13.9267 7.21224 12.8255 7.69083 11.7656C7.91424 11.2733 7.87188 10.71 7.58071 10.2568C7.28635 9.80153 6.78659 9.52941 6.24341 9.52941L2.17647 9.52941C1.59306 9.52941 1.11765 9.05506 1.11765 8.47059C1.11765 7.88611 1.59306 7.41176 2.17647 7.41176ZM0.0588235 8.47059C0.0588234 9.63847 1.00859 10.5882 2.17647 10.5882L6.24341 10.5882C6.42765 10.5882 6.59071 10.6761 6.69024 10.8307C6.78765 10.9821 6.80141 11.1642 6.72624 11.3294C6.21377 12.4645 5.83682 13.6461 5.60706 14.8405C5.45776 15.624 5.66212 16.4255 6.17035 17.0396C6.67541 17.6495 7.41871 18 8.20859 18L9.58824 18L9.58824 17.4706C9.58824 15.0851 11.042 13.0341 12.2607 11.7328C12.9426 11.0065 13.9199 10.5882 14.9416 10.5882L17 10.5882L17 3.70588C17 1.66235 15.3376 -1.45327e-07 13.2941 -3.23979e-07L4.29412 -1.11078e-06C3.12624 -1.21288e-06 2.17647 0.949763 2.17647 2.11765C2.17647 2.55282 2.30882 2.95835 2.53435 3.29506C1.71059 3.58518 1.11765 4.37188 1.11765 5.29412C1.11765 5.72929 1.25 6.13482 1.47553 6.47153C0.651767 6.76164 0.0588235 7.54835 0.0588235 8.47059Z" fill="#2D3B45"/>
44
45
  </svg>`;
@@ -15,6 +15,7 @@
15
15
  * You should have received a copy of the GNU Affero General Public License along
16
16
  * with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
+
18
19
  export * from './aiicons';
19
20
  export * from './AIToolsTray';
20
21
  export * from './AIResponseModal';
@@ -18,14 +18,12 @@
18
18
  import { ICON_MAKER_PARAM } from '../instructure_icon_maker/svg/constants';
19
19
  export default function buildDownloadUrl(url) {
20
20
  let downloadUrl;
21
-
22
21
  try {
23
22
  downloadUrl = new URL(url);
24
23
  } catch (e) {
25
24
  // eslint-disable-next-line no-throw-literal
26
25
  throw `Error parsing ${url}. 'buildDownloadUrl' only supports absolute URLs.`;
27
26
  }
28
-
29
27
  downloadUrl.searchParams.append(ICON_MAKER_PARAM, 1);
30
28
  return downloadUrl.toString();
31
29
  }
@@ -15,6 +15,7 @@
15
15
  * You should have received a copy of the GNU Affero General Public License along
16
16
  * with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
+
18
19
  import React, { Suspense } from 'react';
19
20
  import { Spinner } from '@instructure/ui-spinner';
20
21
  import formatMessage from '../../../format-message';
@@ -27,19 +28,18 @@ const thePanels = {
27
28
  media: /*#__PURE__*/React.lazy(() => import('../instructure_record/MediaPanel')),
28
29
  all: /*#__PURE__*/React.lazy(() => import('./RceFileBrowser')),
29
30
  unknown: /*#__PURE__*/React.lazy(() => import('./UnknownFileTypePanel'))
30
- }; // Returns a Suspense wrapped lazy loaded component
31
- // pulled from useLazy's cache
31
+ };
32
32
 
33
+ // Returns a Suspense wrapped lazy loaded component
34
+ // pulled from useLazy's cache
33
35
  export function DynamicPanel(props) {
34
36
  let key = '';
35
-
36
37
  if (props.contentType === 'links') {
37
38
  key = 'links';
38
39
  } else {
39
40
  key = props.contentSubtype in thePanels ? props.contentSubtype : 'unknown';
40
- } // @ts-expect-error
41
-
42
-
41
+ }
42
+ // @ts-expect-error
43
43
  const Component = thePanels[key];
44
44
  return /*#__PURE__*/React.createElement(Suspense, {
45
45
  fallback: /*#__PURE__*/React.createElement(Spinner, {
@@ -163,15 +163,11 @@ export const FILTER_SETTINGS_BY_PLUGIN = {
163
163
  }
164
164
  };
165
165
  export function isLoading(sprops) {
166
- var _sprops$collections$a, _sprops$collections$a2, _sprops$collections$d, _sprops$collections$m, _sprops$collections$q, _sprops$collections$w, _sprops$documents$cou, _sprops$documents$use, _sprops$documents$gro, _sprops$media$course, _sprops$media$user, _sprops$media$group, _sprops$all_files;
167
-
168
- return ((_sprops$collections$a = sprops.collections.announcements) === null || _sprops$collections$a === void 0 ? void 0 : _sprops$collections$a.isLoading) || ((_sprops$collections$a2 = sprops.collections.assignments) === null || _sprops$collections$a2 === void 0 ? void 0 : _sprops$collections$a2.isLoading) || ((_sprops$collections$d = sprops.collections.discussions) === null || _sprops$collections$d === void 0 ? void 0 : _sprops$collections$d.isLoading) || ((_sprops$collections$m = sprops.collections.modules) === null || _sprops$collections$m === void 0 ? void 0 : _sprops$collections$m.isLoading) || ((_sprops$collections$q = sprops.collections.quizzes) === null || _sprops$collections$q === void 0 ? void 0 : _sprops$collections$q.isLoading) || ((_sprops$collections$w = sprops.collections.wikiPages) === null || _sprops$collections$w === void 0 ? void 0 : _sprops$collections$w.isLoading) || ((_sprops$documents$cou = sprops.documents.course) === null || _sprops$documents$cou === void 0 ? void 0 : _sprops$documents$cou.isLoading) || ((_sprops$documents$use = sprops.documents.user) === null || _sprops$documents$use === void 0 ? void 0 : _sprops$documents$use.isLoading) || ((_sprops$documents$gro = sprops.documents.group) === null || _sprops$documents$gro === void 0 ? void 0 : _sprops$documents$gro.isLoading) || ((_sprops$media$course = sprops.media.course) === null || _sprops$media$course === void 0 ? void 0 : _sprops$media$course.isLoading) || ((_sprops$media$user = sprops.media.user) === null || _sprops$media$user === void 0 ? void 0 : _sprops$media$user.isLoading) || ((_sprops$media$group = sprops.media.group) === null || _sprops$media$group === void 0 ? void 0 : _sprops$media$group.isLoading) || ((_sprops$all_files = sprops.all_files) === null || _sprops$all_files === void 0 ? void 0 : _sprops$all_files.isLoading);
166
+ return sprops.collections.announcements?.isLoading || sprops.collections.assignments?.isLoading || sprops.collections.discussions?.isLoading || sprops.collections.modules?.isLoading || sprops.collections.quizzes?.isLoading || sprops.collections.wikiPages?.isLoading || sprops.documents.course?.isLoading || sprops.documents.user?.isLoading || sprops.documents.group?.isLoading || sprops.media.course?.isLoading || sprops.media.user?.isLoading || sprops.media.group?.isLoading || sprops.all_files?.isLoading;
169
167
  }
170
-
171
168
  function renderLoading() {
172
169
  return formatMessage('Loading');
173
170
  }
174
-
175
171
  export const UploadCanvasPanelIds = ['user_documents', 'course_documents', 'group_documents', 'user_images', 'course_images', 'group_images', 'user_media', 'course_media', 'group_media', 'course_links', 'group_links', 'list_icon_maker_icons', 'all'];
176
172
  export const CanvasPanelTitles = {
177
173
  user_documents: formatMessage('User Documents'),
@@ -15,34 +15,29 @@
15
15
  * You should have received a copy of the GNU Affero General Public License along
16
16
  * with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
+
18
19
  const DEFAULT_TARGET_QUALITY = 0.75;
19
20
  export const MAX_IMAGE_SIZE_BYTES = 500 * 1024;
20
-
21
21
  function blobToBase64(blob) {
22
22
  return new Promise(resolve => {
23
23
  const reader = new FileReader();
24
-
25
24
  reader.onloadend = () => resolve(reader.result);
26
-
27
25
  reader.readAsDataURL(blob);
28
26
  });
29
27
  }
30
-
31
- function drawImageOnCanvasElement(_ref) {
32
- let {
33
- image,
34
- quality,
35
- previewWidth,
36
- previewHeight,
37
- resolve,
38
- reject
39
- } = _ref;
28
+ function drawImageOnCanvasElement({
29
+ image,
30
+ quality,
31
+ previewWidth,
32
+ previewHeight,
33
+ resolve,
34
+ reject
35
+ }) {
40
36
  const {
41
37
  width,
42
38
  height
43
39
  } = image;
44
40
  let compressedImageWidth, compressedImageHeight;
45
-
46
41
  if (width > previewWidth || height > previewHeight) {
47
42
  if (width > height) {
48
43
  compressedImageWidth = previewWidth;
@@ -54,7 +49,6 @@ function drawImageOnCanvasElement(_ref) {
54
49
  compressedImageWidth = compressedImageHeight = previewHeight;
55
50
  }
56
51
  }
57
-
58
52
  const canvas = document.createElement('canvas');
59
53
  canvas.width = compressedImageWidth;
60
54
  canvas.height = compressedImageHeight;
@@ -62,28 +56,24 @@ function drawImageOnCanvasElement(_ref) {
62
56
  ctx.drawImage(image, 0, 0, compressedImageWidth, compressedImageHeight);
63
57
  canvas.toBlob(blob => blob ? resolve(blob) : reject(blob), 'image/jpeg', quality);
64
58
  }
65
-
66
59
  export function canCompressImage() {
67
60
  // Some old browsers don't support toBlob
68
61
  return Boolean(document.createElement('canvas').toBlob);
69
62
  }
70
- export function shouldCompressImage(_ref2) {
71
- let {
72
- type,
73
- size
74
- } = _ref2;
63
+ export function shouldCompressImage({
64
+ type,
65
+ size
66
+ }) {
75
67
  return ['image/jpeg', 'image/webp', 'image/bmp', 'image/tiff'].includes(type) && size > MAX_IMAGE_SIZE_BYTES;
76
68
  }
77
- export function compressImage(_ref3) {
78
- let {
79
- encodedImage,
80
- previewWidth,
81
- previewHeight
82
- } = _ref3;
69
+ export function compressImage({
70
+ encodedImage,
71
+ previewWidth,
72
+ previewHeight
73
+ }) {
83
74
  return new Promise((resolve, reject) => {
84
75
  const image = new Image();
85
76
  image.src = encodedImage;
86
-
87
77
  image.onload = function () {
88
78
  drawImageOnCanvasElement({
89
79
  image,
@@ -15,12 +15,12 @@
15
15
  * You should have received a copy of the GNU Affero General Public License along
16
16
  * with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
+
18
19
  import moment from 'moment-timezone';
19
20
  export const applyTimezoneOffsetToDate = (date, targetTimezone) => {
20
21
  if (!targetTimezone) {
21
22
  return moment(date).toDate();
22
23
  }
23
-
24
24
  const currentTimezoneOffset = moment(date).utcOffset();
25
25
  const expectedTimezoneOffset = moment.tz(date, targetTimezone).utcOffset();
26
26
  const totalOffset = expectedTimezoneOffset - currentTimezoneOffset;
@@ -15,12 +15,14 @@
15
15
  * You should have received a copy of the GNU Affero General Public License along
16
16
  * with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
+
18
19
  import getCookie from './get-cookie';
19
- const csrfToken = getCookie('_csrf_token'); // these are duplicated in application_helper.rb#prefetch_xhr
20
+ const csrfToken = getCookie('_csrf_token');
21
+
22
+ // these are duplicated in application_helper.rb#prefetch_xhr
20
23
  // because we don't have a good pattern for sharing them yet.
21
24
  // If you change these defaults, you should probably cascade that change
22
25
  // to that ruby location
23
-
24
26
  export const defaultFetchOptions = () => ({
25
27
  credentials: 'same-origin',
26
28
  headers: {
@@ -1,5 +1,3 @@
1
- // @ts-nocheck
2
-
3
1
  /*
4
2
  * Copyright (C) 2019 - present Instructure, Inc.
5
3
  *
@@ -17,40 +15,39 @@
17
15
  * You should have received a copy of the GNU Affero General Public License along
18
16
  * with this program. If not, see <http://www.gnu.org/licenses/>.
19
17
  */
18
+
19
+ // @ts-expect-error
20
20
  import parseLinkHeader from './parse-link-header';
21
21
  import { defaultFetchOptions } from './defaultFetchOptions';
22
22
  import { toQueryString } from './query-string-encoding';
23
-
24
- function constructRelativeUrl(_ref) {
25
- let {
26
- path,
27
- params
28
- } = _ref;
23
+ function constructRelativeUrl({
24
+ path,
25
+ params
26
+ }) {
29
27
  const queryString = toQueryString(params);
30
28
  if (queryString.length === 0) return path;
31
29
  return path + '?' + queryString;
32
- } // https://fetch.spec.whatwg.org/#requestinit
30
+ }
33
31
 
32
+ // https://fetch.spec.whatwg.org/#requestinit
34
33
 
35
34
  // NOTE: we do NOT deep-merge customFetchOptions.headers, they should be passed
36
35
  // in the headers arg instead.
37
- export default async function doFetchApi(_ref2) {
38
- let {
39
- path,
40
- method = 'GET',
41
- headers = {},
42
- params = {},
43
- body,
44
- fetchOpts = {}
45
- } = _ref2;
46
- const finalFetchOptions = { ...defaultFetchOptions()
36
+ export default async function doFetchApi({
37
+ path,
38
+ method = 'GET',
39
+ headers = {},
40
+ params = {},
41
+ body,
42
+ fetchOpts = {}
43
+ }) {
44
+ const finalFetchOptions = {
45
+ ...defaultFetchOptions()
47
46
  };
48
-
49
47
  if (body && typeof body !== 'string') {
50
48
  body = JSON.stringify(body);
51
49
  finalFetchOptions.headers['Content-Type'] = 'application/json';
52
50
  }
53
-
54
51
  Object.assign(finalFetchOptions.headers, headers);
55
52
  Object.assign(finalFetchOptions, fetchOpts);
56
53
  const url = constructRelativeUrl({
@@ -63,16 +60,13 @@ export default async function doFetchApi(_ref2) {
63
60
  ...finalFetchOptions,
64
61
  credentials: finalFetchOptions.credentials
65
62
  });
66
-
67
63
  if (!response.ok) {
68
64
  const err = new Error(`doFetchApi received a bad response: ${response.status} ${response.statusText}`);
69
65
  Object.assign(err, {
70
66
  response
71
67
  }); // in case anyone wants to check it for something
72
-
73
68
  throw err;
74
69
  }
75
-
76
70
  const linkHeader = response.headers.get('Link');
77
71
  const link = linkHeader && parseLinkHeader(linkHeader) || undefined;
78
72
  const text = await response.text();
@@ -24,6 +24,6 @@
24
24
  */
25
25
  export default function getCookie(cookieName) {
26
26
  const match = document.cookie.match('(^|[^;]+)\\s*' + cookieName + '\\s*=\\s*([^;]+)');
27
- const first = match === null || match === void 0 ? void 0 : match.pop();
27
+ const first = match?.pop();
28
28
  return first ? decodeURIComponent(first) : undefined;
29
29
  }
@@ -15,6 +15,7 @@
15
15
  * You should have received a copy of the GNU Affero General Public License along
16
16
  * with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
+
18
19
  import doFetchApi from './doFetchApi';
19
20
  export * from './get-cookie';
20
21
  export * from './parse-link-header';
@@ -15,29 +15,26 @@
15
15
  * You should have received a copy of the GNU Affero General Public License along
16
16
  * with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
+
18
19
  // based on https://github.com/thlorenz/parse-link-header/blob/master/index.js (MIT)
20
+
19
21
  function parseQueryParams(linkUrl) {
20
22
  const queryParams = {};
21
23
  const urlParts = linkUrl.split('?');
22
-
23
24
  if (urlParts.length > 1) {
24
25
  urlParts[1].split('&').forEach(param => {
25
26
  const [key, value] = param.split('=');
26
27
  queryParams[key] = decodeURIComponent(value);
27
28
  });
28
29
  }
29
-
30
30
  return queryParams;
31
31
  }
32
-
33
32
  function parseLink(link) {
34
33
  try {
35
34
  const linkMatch = link.match(/<([^>]*)>\s*(.*)/);
36
-
37
35
  if (!linkMatch) {
38
36
  return null;
39
37
  }
40
-
41
38
  const [, linkUrl, partsString] = linkMatch;
42
39
  const parts = partsString.split(';').map(part => part.trim());
43
40
  const info = {
@@ -45,46 +42,40 @@ function parseLink(link) {
45
42
  };
46
43
  parts.forEach(part => {
47
44
  const partMatch = part.match(/(.+)\s*=\s*"?([^"]+)"?/);
48
-
49
45
  if (partMatch) {
50
46
  const [, key, value] = partMatch;
51
47
  info[key.trim()] = value.trim();
52
48
  }
53
49
  });
54
- return { ...parseQueryParams(linkUrl),
50
+ return {
51
+ ...parseQueryParams(linkUrl),
55
52
  ...info
56
53
  };
57
54
  } catch (e) {
58
55
  return null;
59
56
  }
60
57
  }
61
-
62
58
  function hasRel(x) {
63
59
  return x !== null && 'rel' in x;
64
60
  }
65
-
66
61
  function intoRels(acc, x) {
67
62
  x.rel.split(/\s+/).forEach(rel => {
68
- const { ...rest
63
+ const {
64
+ ...rest
69
65
  } = x;
70
-
71
66
  switch (rel) {
72
67
  case 'first':
73
68
  acc.first = rest;
74
69
  break;
75
-
76
70
  case 'prev':
77
71
  acc.prev = rest;
78
72
  break;
79
-
80
73
  case 'current':
81
74
  acc.current = rest;
82
75
  break;
83
-
84
76
  case 'next':
85
77
  acc.next = rest;
86
78
  break;
87
-
88
79
  case 'last':
89
80
  acc.last = rest;
90
81
  break;
@@ -92,13 +83,10 @@ function intoRels(acc, x) {
92
83
  });
93
84
  return acc;
94
85
  }
95
-
96
86
  const PARSE_LINK_HEADER_MAXLEN = 2000;
97
87
  const PARSE_LINK_HEADER_THROW_ON_MAXLEN_EXCEEDED = process.env.PARSE_LINK_HEADER_THROW_ON_MAXLEN_EXCEEDED != null;
98
-
99
88
  function checkHeader(linkHeader) {
100
89
  if (!linkHeader) return false;
101
-
102
90
  if (linkHeader.length > PARSE_LINK_HEADER_MAXLEN) {
103
91
  if (PARSE_LINK_HEADER_THROW_ON_MAXLEN_EXCEEDED) {
104
92
  throw new Error(`Input string too long, it should be under ${PARSE_LINK_HEADER_MAXLEN} characters.`);
@@ -106,10 +94,8 @@ function checkHeader(linkHeader) {
106
94
  return false;
107
95
  }
108
96
  }
109
-
110
97
  return true;
111
98
  }
112
-
113
99
  export default function parseLinkHeader(linkHeader) {
114
100
  if (!checkHeader(linkHeader)) return null;
115
101
  return linkHeader.split(/,\s*(?=<)/).map(parseLink).filter(hasRel).reduce(intoRels, {});
@@ -15,19 +15,22 @@
15
15
  * You should have received a copy of the GNU Affero General Public License along
16
16
  * with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
+
18
19
  // toQueryString does what jQuery's .param() does, only without having to bring in
19
20
  // all of jQuery.
21
+
20
22
  // URLSearchParams turns arrays into queries like a=1,2,3
21
23
  // But our jQuery makes the older "PHP" style like a[]=1&a[]=2&a[]=3
22
24
  // JQuery also magically deals with parameters that are functions, and recursive
23
25
  // objects within objects, {a: 1, b: {c: 2, d: 3}, e: 4} => a=1&b[c]=2&b[d]=3&e=4
24
26
  // ... so we have to do a lot of massaging with the params object before using it
25
27
  // So fun!
28
+
26
29
  export function toQueryString(params) {
27
- const paramsWithIndexes = []; // fix up the array/object indexes to match the PHP standard
30
+ const paramsWithIndexes = [];
28
31
 
32
+ // fix up the array/object indexes to match the PHP standard
29
33
  const fixIndexes = elt => [elt[0].replace(/\[\d+\]$/, '[]').replace(/{/g, '[').replace(/}/g, ']'), elt[1]];
30
-
31
34
  function serialize(k, elt, suffix) {
32
35
  if (elt instanceof Function) {
33
36
  paramsWithIndexes.push([k + suffix, elt()]);
@@ -45,7 +48,6 @@ export function toQueryString(params) {
45
48
  paramsWithIndexes.push([k + suffix, elt]);
46
49
  }
47
50
  }
48
-
49
51
  Object.keys(params).forEach(k => serialize(k, params[k], ''));
50
52
  return new URLSearchParams(paramsWithIndexes.map(fixIndexes)).toString();
51
53
  }