@instructure/canvas-rce 5.12.1 → 5.12.2

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 (476) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/babel-register.js +0 -7
  3. package/babel.config.cjs.js +0 -7
  4. package/babel.config.js +0 -9
  5. package/es/enhance-user-content/doc_previews.js +4 -0
  6. package/es/enhance-user-content/enhance_user_content.js +4 -59
  7. package/es/enhance-user-content/external_links.js +75 -0
  8. package/es/enhance-user-content/mathml.js +9 -7
  9. package/es/index.js +1 -1
  10. package/es/rce/RCEWrapper.js +3 -2322
  11. package/es/rce/plugins/instructure_equation/EquationEditorModal/index.js +1 -1
  12. package/es/rce/plugins/instructure_equation/EquationEditorModal/styles.js +3 -11
  13. package/es/rce/plugins/instructure_equation/mathlive/index.js +5 -13
  14. package/es/rce/tinymce.oxide.content.min.css.js +732 -0
  15. package/es/rce/tinymce.oxide.skin.min.css.js +7 -0
  16. package/jest.config.js +0 -7
  17. package/package.json +1 -5
  18. package/scripts/build.js +1 -7
  19. package/lib/bridge/Bridge.js +0 -287
  20. package/lib/bridge/index.js +0 -21
  21. package/lib/canvasFileBrowser/FileBrowser.js +0 -457
  22. package/lib/canvasFileBrowser/en-US.js +0 -234
  23. package/lib/common/FlashAlert.js +0 -263
  24. package/lib/common/browser.js +0 -40
  25. package/lib/common/components/FileTree/File.js +0 -64
  26. package/lib/common/components/FileTree/Folder.js +0 -110
  27. package/lib/common/components/FileTree/index.js +0 -84
  28. package/lib/common/components/FileTree/styles.js +0 -72
  29. package/lib/common/components/Loading.js +0 -83
  30. package/lib/common/fileUrl.js +0 -152
  31. package/lib/common/getCookie.js +0 -32
  32. package/lib/common/incremental-loading/LoadMoreButton.js +0 -40
  33. package/lib/common/incremental-loading/LoadingIndicator.js +0 -36
  34. package/lib/common/incremental-loading/LoadingStatus.js +0 -47
  35. package/lib/common/incremental-loading/index.js +0 -21
  36. package/lib/common/incremental-loading/useIncrementalLoading.js +0 -58
  37. package/lib/common/indicate.js +0 -75
  38. package/lib/common/mimeClass.js +0 -120
  39. package/lib/common/natcompare.js +0 -47
  40. package/lib/defaultTinymceConfig.js +0 -160
  41. package/lib/elementDenylist.js +0 -19
  42. package/lib/enhance-user-content/doc_previews.js +0 -233
  43. package/lib/enhance-user-content/enhance_user_content.js +0 -396
  44. package/lib/enhance-user-content/index.js +0 -21
  45. package/lib/enhance-user-content/instructure_helper.js +0 -207
  46. package/lib/enhance-user-content/jqueryish_funcs.js +0 -88
  47. package/lib/enhance-user-content/mathml.js +0 -397
  48. package/lib/enhance-user-content/media_comment_thumbnail.js +0 -130
  49. package/lib/format-message.js +0 -30
  50. package/lib/getThemeVars.js +0 -46
  51. package/lib/getTranslations.js +0 -340
  52. package/lib/index.js +0 -51
  53. package/lib/rce/AlertMessageArea.js +0 -47
  54. package/lib/rce/DraggingBlocker.js +0 -43
  55. package/lib/rce/KeyboardShortcutModal.js +0 -88
  56. package/lib/rce/RCE.js +0 -150
  57. package/lib/rce/RCEGlobals.js +0 -62
  58. package/lib/rce/RCEWrapper.js +0 -4274
  59. package/lib/rce/RCEWrapperProps.js +0 -130
  60. package/lib/rce/RceHtmlEditor.js +0 -142
  61. package/lib/rce/ResizeHandle.js +0 -102
  62. package/lib/rce/RestoreAutoSaveModal.js +0 -82
  63. package/lib/rce/ShowOnFocusButton/index.js +0 -93
  64. package/lib/rce/StatusBar.js +0 -386
  65. package/lib/rce/__mocks__/_mockCryptoEs.js +0 -124
  66. package/lib/rce/__mocks__/styleMock.js +0 -18
  67. package/lib/rce/__mocks__/tinymceReact.js +0 -55
  68. package/lib/rce/alertHandler.js +0 -46
  69. package/lib/rce/contentInsertion.js +0 -325
  70. package/lib/rce/contentInsertionUtils.js +0 -85
  71. package/lib/rce/contentRendering.js +0 -145
  72. package/lib/rce/customEvents.js +0 -18
  73. package/lib/rce/editorLanguage.js +0 -101
  74. package/lib/rce/indicatorRegion.js +0 -49
  75. package/lib/rce/normalizeLocale.js +0 -50
  76. package/lib/rce/normalizeProps.js +0 -29
  77. package/lib/rce/plugins/instructure-ui-icons/plugin.js +0 -122
  78. package/lib/rce/plugins/instructure_condensed_buttons/core/ListUtils.js +0 -24
  79. package/lib/rce/plugins/instructure_condensed_buttons/plugin.js +0 -27
  80. package/lib/rce/plugins/instructure_condensed_buttons/ui/alignment-button.js +0 -63
  81. package/lib/rce/plugins/instructure_condensed_buttons/ui/directionality-button.js +0 -48
  82. package/lib/rce/plugins/instructure_condensed_buttons/ui/indent-outdent-button.js +0 -41
  83. package/lib/rce/plugins/instructure_condensed_buttons/ui/list-button.js +0 -145
  84. package/lib/rce/plugins/instructure_condensed_buttons/ui/subscript-superscript-button.js +0 -56
  85. package/lib/rce/plugins/instructure_documents/clickCallback.js +0 -23
  86. package/lib/rce/plugins/instructure_documents/components/DocumentsPanel.js +0 -120
  87. package/lib/rce/plugins/instructure_documents/components/Link.js +0 -219
  88. package/lib/rce/plugins/instructure_documents/plugin.js +0 -123
  89. package/lib/rce/plugins/instructure_equation/EquationEditorModal/advancedOnlySyntax.js +0 -25
  90. package/lib/rce/plugins/instructure_equation/EquationEditorModal/advancedPreference.js +0 -51
  91. package/lib/rce/plugins/instructure_equation/EquationEditorModal/index.js +0 -321
  92. package/lib/rce/plugins/instructure_equation/EquationEditorModal/latexTextareaUtil.js +0 -116
  93. package/lib/rce/plugins/instructure_equation/EquationEditorModal/parseLatex.js +0 -91
  94. package/lib/rce/plugins/instructure_equation/EquationEditorModal/styles.js +0 -46
  95. package/lib/rce/plugins/instructure_equation/EquationEditorToolbar/buttons.js +0 -728
  96. package/lib/rce/plugins/instructure_equation/EquationEditorToolbar/index.js +0 -84
  97. package/lib/rce/plugins/instructure_equation/MathIcon/index.js +0 -41
  98. package/lib/rce/plugins/instructure_equation/MathIcon/svgs.js +0 -236
  99. package/lib/rce/plugins/instructure_equation/clickCallback.js +0 -53
  100. package/lib/rce/plugins/instructure_equation/mathlive/index.js +0 -36
  101. package/lib/rce/plugins/instructure_equation/plugin.js +0 -69
  102. package/lib/rce/plugins/instructure_fullscreen/plugin.js +0 -50
  103. package/lib/rce/plugins/instructure_html_view/clickCallback.js +0 -21
  104. package/lib/rce/plugins/instructure_html_view/plugin.js +0 -37
  105. package/lib/rce/plugins/instructure_icon_maker/clickCallback.js +0 -57
  106. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ColorSection.js +0 -82
  107. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/CreateIconMakerForm.js +0 -56
  108. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Footer.js +0 -78
  109. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Group.js +0 -36
  110. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Header.js +0 -110
  111. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/Course.js +0 -169
  112. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/ImageOptions.js +0 -186
  113. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/ImageSection.js +0 -243
  114. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/ModeSelect.js +0 -64
  115. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/MultiColor/index.js +0 -73
  116. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/MultiColor/svg.js +0 -298
  117. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SVGList.js +0 -86
  118. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SVGThumbnail.js +0 -55
  119. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SingleColor/index.js +0 -70
  120. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SingleColor/svg.js +0 -317
  121. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/Upload.js +0 -149
  122. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/index.js +0 -18
  123. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/propTypes.js +0 -32
  124. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/utils.js +0 -25
  125. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Preview.js +0 -60
  126. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ShapeSection.js +0 -87
  127. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/TextSection.js +0 -139
  128. package/lib/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/index.js +0 -18
  129. package/lib/rce/plugins/instructure_icon_maker/components/IconMakerTray.js +0 -323
  130. package/lib/rce/plugins/instructure_icon_maker/components/SavedIconMakerList.js +0 -91
  131. package/lib/rce/plugins/instructure_icon_maker/plugin.js +0 -110
  132. package/lib/rce/plugins/instructure_icon_maker/reducers/imageSection.js +0 -194
  133. package/lib/rce/plugins/instructure_icon_maker/reducers/svgSettings.js +0 -98
  134. package/lib/rce/plugins/instructure_icon_maker/registerEditToolbar.js +0 -56
  135. package/lib/rce/plugins/instructure_icon_maker/svg/clipPath.js +0 -25
  136. package/lib/rce/plugins/instructure_icon_maker/svg/constants.js +0 -100
  137. package/lib/rce/plugins/instructure_icon_maker/svg/font.js +0 -25
  138. package/lib/rce/plugins/instructure_icon_maker/svg/image.js +0 -354
  139. package/lib/rce/plugins/instructure_icon_maker/svg/index.js +0 -122
  140. package/lib/rce/plugins/instructure_icon_maker/svg/metadata.js +0 -48
  141. package/lib/rce/plugins/instructure_icon_maker/svg/settings.js +0 -179
  142. package/lib/rce/plugins/instructure_icon_maker/svg/shape.js +0 -316
  143. package/lib/rce/plugins/instructure_icon_maker/svg/text.js +0 -468
  144. package/lib/rce/plugins/instructure_icon_maker/svg/utils.js +0 -70
  145. package/lib/rce/plugins/instructure_icon_maker/utils/IconMakerClose.js +0 -45
  146. package/lib/rce/plugins/instructure_icon_maker/utils/IconMakerFormHasChanges.js +0 -83
  147. package/lib/rce/plugins/instructure_icon_maker/utils/addIconMakerAttributes.js +0 -28
  148. package/lib/rce/plugins/instructure_icon_maker/utils/iconValidation.js +0 -35
  149. package/lib/rce/plugins/instructure_icon_maker/utils/iconsLabels.js +0 -375
  150. package/lib/rce/plugins/instructure_icon_maker/utils/useDebouncedValue.js +0 -59
  151. package/lib/rce/plugins/instructure_image/ImageEmbedOptions.js +0 -202
  152. package/lib/rce/plugins/instructure_image/ImageList/Image.js +0 -106
  153. package/lib/rce/plugins/instructure_image/ImageList/index.js +0 -69
  154. package/lib/rce/plugins/instructure_image/ImageOptionsTray/TrayController.js +0 -166
  155. package/lib/rce/plugins/instructure_image/ImageOptionsTray/index.js +0 -246
  156. package/lib/rce/plugins/instructure_image/Images/index.js +0 -122
  157. package/lib/rce/plugins/instructure_image/clickCallback.js +0 -24
  158. package/lib/rce/plugins/instructure_image/plugin.js +0 -157
  159. package/lib/rce/plugins/instructure_links/clickCallback.js +0 -22
  160. package/lib/rce/plugins/instructure_links/components/AccordionSection.js +0 -60
  161. package/lib/rce/plugins/instructure_links/components/CollectionPanel.js +0 -84
  162. package/lib/rce/plugins/instructure_links/components/Link.js +0 -213
  163. package/lib/rce/plugins/instructure_links/components/LinkOptionsDialog/LinkOptionsDialogController.js +0 -127
  164. package/lib/rce/plugins/instructure_links/components/LinkOptionsDialog/index.js +0 -141
  165. package/lib/rce/plugins/instructure_links/components/LinkOptionsTray/LinkOptionsTrayController.js +0 -125
  166. package/lib/rce/plugins/instructure_links/components/LinkOptionsTray/index.js +0 -245
  167. package/lib/rce/plugins/instructure_links/components/LinkSet.js +0 -195
  168. package/lib/rce/plugins/instructure_links/components/LinksPanel.js +0 -100
  169. package/lib/rce/plugins/instructure_links/components/NavigationPanel.js +0 -141
  170. package/lib/rce/plugins/instructure_links/components/NoResults.js +0 -87
  171. package/lib/rce/plugins/instructure_links/components/propTypes.js +0 -41
  172. package/lib/rce/plugins/instructure_links/plugin.js +0 -294
  173. package/lib/rce/plugins/instructure_links/validateURL.js +0 -70
  174. package/lib/rce/plugins/instructure_media_embed/clickCallback.js +0 -48
  175. package/lib/rce/plugins/instructure_media_embed/components/Embed.js +0 -68
  176. package/lib/rce/plugins/instructure_media_embed/plugin.js +0 -36
  177. package/lib/rce/plugins/instructure_paste/pasteMenuCommand.js +0 -117
  178. package/lib/rce/plugins/instructure_paste/plugin.js +0 -174
  179. package/lib/rce/plugins/instructure_rce_external_tools/ExternalToolsEnv.js +0 -169
  180. package/lib/rce/plugins/instructure_rce_external_tools/RceToolWrapper.js +0 -225
  181. package/lib/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialog.js +0 -297
  182. package/lib/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialogModal.js +0 -46
  183. package/lib/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialogTray.js +0 -79
  184. package/lib/rce/plugins/instructure_rce_external_tools/components/ExternalToolSelectionDialog/ExternalToolSelectionDialog.js +0 -153
  185. package/lib/rce/plugins/instructure_rce_external_tools/components/ExternalToolSelectionDialog/ExternalToolSelectionItem.js +0 -94
  186. package/lib/rce/plugins/instructure_rce_external_tools/components/util/ExpandoText.js +0 -90
  187. package/lib/rce/plugins/instructure_rce_external_tools/components/util/ToolLaunchIframe.js +0 -35
  188. package/lib/rce/plugins/instructure_rce_external_tools/dialog-helper.js +0 -29
  189. package/lib/rce/plugins/instructure_rce_external_tools/helpers/tags.js +0 -55
  190. package/lib/rce/plugins/instructure_rce_external_tools/jquery/jquery.dropdownList.js +0 -172
  191. package/lib/rce/plugins/instructure_rce_external_tools/lti11-content-items/RceLti11ContentItem.js +0 -203
  192. package/lib/rce/plugins/instructure_rce_external_tools/lti13-content-items/Lti13ContentItemJson.js +0 -23
  193. package/lib/rce/plugins/instructure_rce_external_tools/lti13-content-items/RceLti13ContentItem.js +0 -111
  194. package/lib/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/BaseLinkContentItem.js +0 -79
  195. package/lib/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/HtmlFragmentContentItem.js +0 -47
  196. package/lib/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/ImageContentItem.js +0 -57
  197. package/lib/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/LinkContentItem.js +0 -26
  198. package/lib/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/ResourceLinkContentItem.js +0 -47
  199. package/lib/rce/plugins/instructure_rce_external_tools/lti13-content-items/processEditorContentItems.js +0 -67
  200. package/lib/rce/plugins/instructure_rce_external_tools/lti13-content-items/rceLti13ContentItemFromJson.js +0 -48
  201. package/lib/rce/plugins/instructure_rce_external_tools/plugin.js +0 -112
  202. package/lib/rce/plugins/instructure_rce_external_tools/util/addParentFrameContextToUrl.js +0 -27
  203. package/lib/rce/plugins/instructure_record/AudioOptionsTray/TrayController.js +0 -152
  204. package/lib/rce/plugins/instructure_record/AudioOptionsTray/index.js +0 -154
  205. package/lib/rce/plugins/instructure_record/MediaPanel/index.js +0 -123
  206. package/lib/rce/plugins/instructure_record/VideoOptionsTray/TrayController.js +0 -240
  207. package/lib/rce/plugins/instructure_record/VideoOptionsTray/index.js +0 -350
  208. package/lib/rce/plugins/instructure_record/clickCallback.js +0 -105
  209. package/lib/rce/plugins/instructure_record/mediaTranslations.js +0 -94
  210. package/lib/rce/plugins/instructure_record/plugin.js +0 -173
  211. package/lib/rce/plugins/instructure_studio_media_options/plugin.js +0 -42
  212. package/lib/rce/plugins/instructure_wordcount/clickCallback.js +0 -49
  213. package/lib/rce/plugins/instructure_wordcount/components/WordCountModal.js +0 -88
  214. package/lib/rce/plugins/instructure_wordcount/plugin.js +0 -30
  215. package/lib/rce/plugins/instructure_wordcount/utils/countContent.js +0 -78
  216. package/lib/rce/plugins/instructure_wordcount/utils/tableContent.js +0 -40
  217. package/lib/rce/plugins/shared/CanvasContentTray.js +0 -580
  218. package/lib/rce/plugins/shared/CheckerboardStyling.js +0 -25
  219. package/lib/rce/plugins/shared/ColorInput.js +0 -233
  220. package/lib/rce/plugins/shared/ConditionalTooltip.js +0 -32
  221. package/lib/rce/plugins/shared/ContentSelection.js +0 -269
  222. package/lib/rce/plugins/shared/DimensionUtils.js +0 -66
  223. package/lib/rce/plugins/shared/DimensionsInput/DimensionInput.js +0 -62
  224. package/lib/rce/plugins/shared/DimensionsInput/index.js +0 -161
  225. package/lib/rce/plugins/shared/DimensionsInput/useDimensionsState.js +0 -220
  226. package/lib/rce/plugins/shared/ErrorBoundary.js +0 -54
  227. package/lib/rce/plugins/shared/EventUtils.js +0 -39
  228. package/lib/rce/plugins/shared/Filter.js +0 -353
  229. package/lib/rce/plugins/shared/FixedContentTray.js +0 -115
  230. package/lib/rce/plugins/shared/ImageCropper/DirectionRegion.js +0 -67
  231. package/lib/rce/plugins/shared/ImageCropper/Modal.js +0 -153
  232. package/lib/rce/plugins/shared/ImageCropper/Preview.js +0 -148
  233. package/lib/rce/plugins/shared/ImageCropper/constants.js +0 -39
  234. package/lib/rce/plugins/shared/ImageCropper/controls/CustomNumberInput.js +0 -83
  235. package/lib/rce/plugins/shared/ImageCropper/controls/ResetControls.js +0 -38
  236. package/lib/rce/plugins/shared/ImageCropper/controls/RotationControls.js +0 -89
  237. package/lib/rce/plugins/shared/ImageCropper/controls/ShapeControls.js +0 -82
  238. package/lib/rce/plugins/shared/ImageCropper/controls/ZoomControls.js +0 -111
  239. package/lib/rce/plugins/shared/ImageCropper/controls/index.js +0 -61
  240. package/lib/rce/plugins/shared/ImageCropper/controls/useDebouncedNumericValue.js +0 -94
  241. package/lib/rce/plugins/shared/ImageCropper/controls/utils.js +0 -41
  242. package/lib/rce/plugins/shared/ImageCropper/imageCropUtils.js +0 -149
  243. package/lib/rce/plugins/shared/ImageCropper/index.js +0 -18
  244. package/lib/rce/plugins/shared/ImageCropper/propTypes.js +0 -26
  245. package/lib/rce/plugins/shared/ImageCropper/reducers/imageCropper.js +0 -72
  246. package/lib/rce/plugins/shared/ImageCropper/shape.js +0 -27
  247. package/lib/rce/plugins/shared/ImageCropper/svg/index.js +0 -89
  248. package/lib/rce/plugins/shared/ImageCropper/svg/shape.js +0 -125
  249. package/lib/rce/plugins/shared/ImageCropper/svg/utils.js +0 -26
  250. package/lib/rce/plugins/shared/ImageCropper/useKeyMouseEvents.js +0 -233
  251. package/lib/rce/plugins/shared/ImageCropper/useMouseWheel.js +0 -66
  252. package/lib/rce/plugins/shared/ImageOptionsForm.js +0 -140
  253. package/lib/rce/plugins/shared/LinkDisplay.js +0 -96
  254. package/lib/rce/plugins/shared/PreviewIcon.js +0 -112
  255. package/lib/rce/plugins/shared/Previewable.js +0 -22
  256. package/lib/rce/plugins/shared/RceFileBrowser.js +0 -106
  257. package/lib/rce/plugins/shared/StoreContext.js +0 -57
  258. package/lib/rce/plugins/shared/StudioLtiSupportUtils.js +0 -71
  259. package/lib/rce/plugins/shared/UnknownFileTypePanel.js +0 -29
  260. package/lib/rce/plugins/shared/Upload/CategoryProcessor.js +0 -27
  261. package/lib/rce/plugins/shared/Upload/ComputerPanel.js +0 -334
  262. package/lib/rce/plugins/shared/Upload/SvgCategoryProcessor.js +0 -35
  263. package/lib/rce/plugins/shared/Upload/UploadFile.js +0 -171
  264. package/lib/rce/plugins/shared/Upload/UploadFileModal.js +0 -273
  265. package/lib/rce/plugins/shared/Upload/UrlPanel.js +0 -38
  266. package/lib/rce/plugins/shared/Upload/UsageRightsSelectBox.js +0 -172
  267. package/lib/rce/plugins/shared/Upload/doFileUpload.js +0 -77
  268. package/lib/rce/plugins/shared/__mocks__/screenfull.js +0 -24
  269. package/lib/rce/plugins/shared/buildDownloadUrl.js +0 -31
  270. package/lib/rce/plugins/shared/compressionUtils.js +0 -98
  271. package/lib/rce/plugins/shared/dateUtils.js +0 -28
  272. package/lib/rce/plugins/shared/fileShape.js +0 -129
  273. package/lib/rce/plugins/shared/fileTypeUtils.js +0 -139
  274. package/lib/rce/plugins/shared/fileUtils.js +0 -25
  275. package/lib/rce/plugins/shared/linkUtils.js +0 -89
  276. package/lib/rce/plugins/shared/round.js +0 -25
  277. package/lib/rce/plugins/shared/trayUtils.js +0 -34
  278. package/lib/rce/plugins/shared/useDataUrl.js +0 -76
  279. package/lib/rce/plugins/tinymce-a11y-checker/components/ColorField.js +0 -86
  280. package/lib/rce/plugins/tinymce-a11y-checker/components/checker.js +0 -558
  281. package/lib/rce/plugins/tinymce-a11y-checker/components/color-picker.js +0 -59
  282. package/lib/rce/plugins/tinymce-a11y-checker/components/placeholder-svg.js +0 -90
  283. package/lib/rce/plugins/tinymce-a11y-checker/components/pointer.js +0 -32
  284. package/lib/rce/plugins/tinymce-a11y-checker/node-checker.js +0 -54
  285. package/lib/rce/plugins/tinymce-a11y-checker/plugin.js +0 -90
  286. package/lib/rce/plugins/tinymce-a11y-checker/rules/__mocks__/index.js +0 -53
  287. package/lib/rce/plugins/tinymce-a11y-checker/rules/adjacent-links.js +0 -129
  288. package/lib/rce/plugins/tinymce-a11y-checker/rules/headings-sequence.js +0 -200
  289. package/lib/rce/plugins/tinymce-a11y-checker/rules/headings-start-at-h2.js +0 -67
  290. package/lib/rce/plugins/tinymce-a11y-checker/rules/img-alt-filename.js +0 -63
  291. package/lib/rce/plugins/tinymce-a11y-checker/rules/img-alt-length.js +0 -49
  292. package/lib/rce/plugins/tinymce-a11y-checker/rules/img-alt.js +0 -61
  293. package/lib/rce/plugins/tinymce-a11y-checker/rules/index.js +0 -31
  294. package/lib/rce/plugins/tinymce-a11y-checker/rules/large-text-contrast.js +0 -51
  295. package/lib/rce/plugins/tinymce-a11y-checker/rules/list-structure.js +0 -144
  296. package/lib/rce/plugins/tinymce-a11y-checker/rules/paragraphs-for-headings.js +0 -61
  297. package/lib/rce/plugins/tinymce-a11y-checker/rules/small-text-contrast.js +0 -75
  298. package/lib/rce/plugins/tinymce-a11y-checker/rules/table-caption.js +0 -54
  299. package/lib/rce/plugins/tinymce-a11y-checker/rules/table-header-scope.js +0 -52
  300. package/lib/rce/plugins/tinymce-a11y-checker/rules/table-header.js +0 -81
  301. package/lib/rce/plugins/tinymce-a11y-checker/utils/colors.js +0 -43
  302. package/lib/rce/plugins/tinymce-a11y-checker/utils/describe.js +0 -66
  303. package/lib/rce/plugins/tinymce-a11y-checker/utils/dom.js +0 -160
  304. package/lib/rce/plugins/tinymce-a11y-checker/utils/indicate.js +0 -83
  305. package/lib/rce/plugins/tinymce-a11y-checker/utils/rgb-hex.js +0 -57
  306. package/lib/rce/plugins/tinymce-a11y-checker/utils/strings.js +0 -40
  307. package/lib/rce/root.js +0 -58
  308. package/lib/rce/sanitizePlugins.js +0 -32
  309. package/lib/rce/style.js +0 -843
  310. package/lib/rce/tinyRCE.js +0 -66
  311. package/lib/rce/transformContent.js +0 -73
  312. package/lib/rce/userOS.js +0 -31
  313. package/lib/rce/wrapInitCb.js +0 -78
  314. package/lib/rcs/api.js +0 -672
  315. package/lib/rcs/buildError.js +0 -98
  316. package/lib/rcs/fake.js +0 -621
  317. package/lib/sidebar/actions/all_files.js +0 -29
  318. package/lib/sidebar/actions/data.js +0 -105
  319. package/lib/sidebar/actions/documents.js +0 -107
  320. package/lib/sidebar/actions/files.js +0 -167
  321. package/lib/sidebar/actions/filter.js +0 -63
  322. package/lib/sidebar/actions/flickr.js +0 -60
  323. package/lib/sidebar/actions/images.js +0 -153
  324. package/lib/sidebar/actions/links.js +0 -23
  325. package/lib/sidebar/actions/media.js +0 -142
  326. package/lib/sidebar/actions/session.js +0 -34
  327. package/lib/sidebar/actions/ui.js +0 -49
  328. package/lib/sidebar/actions/upload.js +0 -550
  329. package/lib/sidebar/containers/Sidebar.js +0 -67
  330. package/lib/sidebar/containers/sidebarHandlers.js +0 -73
  331. package/lib/sidebar/dragHtml.js +0 -49
  332. package/lib/sidebar/reducers/all_files.js +0 -35
  333. package/lib/sidebar/reducers/collection.js +0 -72
  334. package/lib/sidebar/reducers/collections.js +0 -52
  335. package/lib/sidebar/reducers/documents.js +0 -89
  336. package/lib/sidebar/reducers/files.js +0 -38
  337. package/lib/sidebar/reducers/filter.js +0 -61
  338. package/lib/sidebar/reducers/flickr.js +0 -51
  339. package/lib/sidebar/reducers/folder.js +0 -92
  340. package/lib/sidebar/reducers/folders.js +0 -39
  341. package/lib/sidebar/reducers/images.js +0 -115
  342. package/lib/sidebar/reducers/index.js +0 -57
  343. package/lib/sidebar/reducers/media.js +0 -84
  344. package/lib/sidebar/reducers/newPageLinkExpanded.js +0 -30
  345. package/lib/sidebar/reducers/noop.js +0 -21
  346. package/lib/sidebar/reducers/rootFolderId.js +0 -30
  347. package/lib/sidebar/reducers/session.js +0 -33
  348. package/lib/sidebar/reducers/ui.js +0 -87
  349. package/lib/sidebar/reducers/upload.js +0 -206
  350. package/lib/sidebar/store/configureStore.js +0 -26
  351. package/lib/sidebar/store/initialState.js +0 -173
  352. package/lib/translations/locales/ab.js +0 -26
  353. package/lib/translations/locales/ar.js +0 -2427
  354. package/lib/translations/locales/ca.js +0 -2427
  355. package/lib/translations/locales/cs.js +0 -27
  356. package/lib/translations/locales/cs_CZ.js +0 -27
  357. package/lib/translations/locales/cy.js +0 -2427
  358. package/lib/translations/locales/da-x-k12.js +0 -2427
  359. package/lib/translations/locales/da.js +0 -2427
  360. package/lib/translations/locales/da_DK.js +0 -27
  361. package/lib/translations/locales/de.js +0 -2427
  362. package/lib/translations/locales/el.js +0 -459
  363. package/lib/translations/locales/en-AU-x-unimelb.js +0 -2427
  364. package/lib/translations/locales/en-GB-x-ukhe.js +0 -2427
  365. package/lib/translations/locales/en.js +0 -2427
  366. package/lib/translations/locales/en_AU.js +0 -2427
  367. package/lib/translations/locales/en_CA.js +0 -2426
  368. package/lib/translations/locales/en_CY.js +0 -2426
  369. package/lib/translations/locales/en_GB.js +0 -2427
  370. package/lib/translations/locales/en_NZ.js +0 -26
  371. package/lib/translations/locales/en_SE.js +0 -26
  372. package/lib/translations/locales/en_US.js +0 -26
  373. package/lib/translations/locales/es.js +0 -2427
  374. package/lib/translations/locales/es_ES.js +0 -2427
  375. package/lib/translations/locales/es_GT.js +0 -27
  376. package/lib/translations/locales/fa_IR.js +0 -615
  377. package/lib/translations/locales/fi.js +0 -2427
  378. package/lib/translations/locales/fr.js +0 -2427
  379. package/lib/translations/locales/fr_CA.js +0 -2427
  380. package/lib/translations/locales/he.js +0 -486
  381. package/lib/translations/locales/ht.js +0 -2426
  382. package/lib/translations/locales/hu.js +0 -2007
  383. package/lib/translations/locales/hu_HU.js +0 -27
  384. package/lib/translations/locales/hy.js +0 -444
  385. package/lib/translations/locales/id.js +0 -2426
  386. package/lib/translations/locales/id_ID.js +0 -26
  387. package/lib/translations/locales/is.js +0 -2426
  388. package/lib/translations/locales/it.js +0 -2427
  389. package/lib/translations/locales/ja.js +0 -2427
  390. package/lib/translations/locales/ko.js +0 -342
  391. package/lib/translations/locales/ko_KR.js +0 -27
  392. package/lib/translations/locales/lt.js +0 -26
  393. package/lib/translations/locales/lt_LT.js +0 -26
  394. package/lib/translations/locales/mi.js +0 -2426
  395. package/lib/translations/locales/mn_MN.js +0 -26
  396. package/lib/translations/locales/ms.js +0 -2426
  397. package/lib/translations/locales/nb-x-k12.js +0 -2427
  398. package/lib/translations/locales/nb.js +0 -2427
  399. package/lib/translations/locales/nl.js +0 -2427
  400. package/lib/translations/locales/nl_NL.js +0 -27
  401. package/lib/translations/locales/nn.js +0 -2247
  402. package/lib/translations/locales/pl.js +0 -2427
  403. package/lib/translations/locales/pt.js +0 -2427
  404. package/lib/translations/locales/pt_BR.js +0 -2427
  405. package/lib/translations/locales/ro.js +0 -27
  406. package/lib/translations/locales/ru.js +0 -2427
  407. package/lib/translations/locales/se.js +0 -26
  408. package/lib/translations/locales/sl.js +0 -2427
  409. package/lib/translations/locales/sv-x-k12.js +0 -2427
  410. package/lib/translations/locales/sv.js +0 -2427
  411. package/lib/translations/locales/sv_SE.js +0 -27
  412. package/lib/translations/locales/tg.js +0 -26
  413. package/lib/translations/locales/th.js +0 -2427
  414. package/lib/translations/locales/th_TH.js +0 -27
  415. package/lib/translations/locales/tl_PH.js +0 -26
  416. package/lib/translations/locales/tr.js +0 -687
  417. package/lib/translations/locales/uk_UA.js +0 -519
  418. package/lib/translations/locales/vi.js +0 -2427
  419. package/lib/translations/locales/vi_VN.js +0 -27
  420. package/lib/translations/locales/zh-Hans.js +0 -2427
  421. package/lib/translations/locales/zh-Hant.js +0 -2427
  422. package/lib/translations/locales/zh.js +0 -2427
  423. package/lib/translations/locales/zh_HK.js +0 -2427
  424. package/lib/translations/locales/zh_TW.Big5.js +0 -27
  425. package/lib/translations/locales/zh_TW.js +0 -27
  426. package/lib/translations/tinymce/ar_SA.js +0 -211
  427. package/lib/translations/tinymce/bg_BG.js +0 -419
  428. package/lib/translations/tinymce/ca.js +0 -419
  429. package/lib/translations/tinymce/cs.js +0 -419
  430. package/lib/translations/tinymce/cy.js +0 -418
  431. package/lib/translations/tinymce/da.js +0 -419
  432. package/lib/translations/tinymce/de.js +0 -419
  433. package/lib/translations/tinymce/el.js +0 -261
  434. package/lib/translations/tinymce/en_GB.js +0 -230
  435. package/lib/translations/tinymce/es.js +0 -419
  436. package/lib/translations/tinymce/fa_IR.js +0 -390
  437. package/lib/translations/tinymce/fi.js +0 -19
  438. package/lib/translations/tinymce/fr_FR.js +0 -419
  439. package/lib/translations/tinymce/he_IL.js +0 -420
  440. package/lib/translations/tinymce/hu_HU.js +0 -419
  441. package/lib/translations/tinymce/hy.js +0 -419
  442. package/lib/translations/tinymce/it.js +0 -419
  443. package/lib/translations/tinymce/ja.js +0 -419
  444. package/lib/translations/tinymce/ko_KR.js +0 -419
  445. package/lib/translations/tinymce/nb_NO.js +0 -419
  446. package/lib/translations/tinymce/nl.js +0 -419
  447. package/lib/translations/tinymce/pl.js +0 -419
  448. package/lib/translations/tinymce/pt_BR.js +0 -419
  449. package/lib/translations/tinymce/pt_PT.js +0 -419
  450. package/lib/translations/tinymce/ro.js +0 -418
  451. package/lib/translations/tinymce/ru.js +0 -436
  452. package/lib/translations/tinymce/ru_RU.js +0 -71
  453. package/lib/translations/tinymce/sl.js +0 -462
  454. package/lib/translations/tinymce/sr.js +0 -278
  455. package/lib/translations/tinymce/sv_SE.js +0 -419
  456. package/lib/translations/tinymce/th.js +0 -479
  457. package/lib/translations/tinymce/tr_TR.js +0 -389
  458. package/lib/translations/tinymce/uk_UA.js +0 -278
  459. package/lib/translations/tinymce/vi_VN.js +0 -277
  460. package/lib/translations/tinymce/zh_CN.js +0 -419
  461. package/lib/translations/tinymce/zh_TW.js +0 -419
  462. package/lib/util/DeepPartialNullable.js +0 -1
  463. package/lib/util/ExtractRequired.js +0 -1
  464. package/lib/util/TypedDict.js +0 -131
  465. package/lib/util/assertNever.js +0 -44
  466. package/lib/util/elem-util.js +0 -26
  467. package/lib/util/encrypted-storage.js +0 -84
  468. package/lib/util/file-url-util.js +0 -44
  469. package/lib/util/fullscreenHelpers.js +0 -27
  470. package/lib/util/instui-icon-helper.js +0 -31
  471. package/lib/util/loadingPlaceholder.js +0 -436
  472. package/lib/util/simpleCache.js +0 -41
  473. package/lib/util/string-util.js +0 -48
  474. package/lib/util/textarea-editing-util.js +0 -87
  475. package/lib/util/tinymce-plugin-util.js +0 -52
  476. package/lib/util/url-util.js +0 -138
package/lib/rcs/api.js DELETED
@@ -1,672 +0,0 @@
1
- /*
2
- * Copyright (C) 2018 - present Instructure, Inc.
3
- *
4
- * This file is part of Canvas.
5
- *
6
- * Canvas is free software: you can redistribute it and/or modify it under
7
- * the terms of the GNU Affero General Public License as published by the Free
8
- * Software Foundation, version 3 of the License.
9
- *
10
- * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
11
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
- * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13
- * details.
14
- *
15
- * You should have received a copy of the GNU Affero General Public License along
16
- * with this program. If not, see <http://www.gnu.org/licenses/>.
17
- */
18
- import 'isomorphic-fetch';
19
- import { parse } from 'url';
20
- import { saveClosedCaptions, saveClosedCaptionsForAttachment, CONSTANTS } from '@instructure/canvas-media';
21
- import { downloadToWrap, fixupFileUrl } from '../common/fileUrl';
22
- import alertHandler from '../rce/alertHandler';
23
- import buildError from './buildError';
24
- import RCEGlobals from '../rce/RCEGlobals';
25
- export function headerFor(jwt) {
26
- return {
27
- Authorization: 'Bearer ' + jwt
28
- };
29
- }
30
- export function originFromHost(host, windowOverride) {
31
- let origin = host;
32
-
33
- if (typeof origin !== 'string') {
34
- origin = '';
35
- } else if (origin && origin.substr(0, 4) !== 'http') {
36
- var _windowHandle$locatio;
37
-
38
- origin = `//${origin}`;
39
- const windowHandle = windowOverride || (typeof window !== 'undefined' ? window : undefined);
40
-
41
- if (origin.length > 0 && windowHandle !== null && windowHandle !== void 0 && (_windowHandle$locatio = windowHandle.location) !== null && _windowHandle$locatio !== void 0 && _windowHandle$locatio.protocol) {
42
- origin = `${windowHandle.location.protocol}${origin}`;
43
- }
44
- }
45
-
46
- return origin;
47
- } // filter a response to raise an error on a 400+ status
48
-
49
- function checkStatus(response) {
50
- if (response.status < 400) {
51
- return response;
52
- } else {
53
- const error = new Error(response.statusText);
54
- error.response = response;
55
- throw error;
56
- }
57
- }
58
-
59
- function defaultRefreshTokenHandler() {
60
- throw new Error('Token expired, no refresh function provided');
61
- }
62
-
63
- function normalizeFileData(file) {
64
- return {
65
- // copy the name to the default display name if none provided
66
- display_name: file.name,
67
- ...file,
68
- // wrap the url
69
- href: downloadToWrap(file.href || file.url)
70
- };
71
- }
72
-
73
- function throwConnectionError(error) {
74
- if (error.name === 'TypeError') {
75
- // eslint-disable-next-line no-console
76
- console.error(`Failed to fetch from the canvas-rce-api.
77
- Did you forget to start it or configure it?
78
- Details can be found at https://github.com/instructure/canvas-rce-api
79
- `);
80
- }
81
-
82
- throw error;
83
- }
84
-
85
- class RceApiSource {
86
- constructor() {
87
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
88
- this.jwt = options.jwt;
89
- this.host = options.host;
90
- this.refreshToken = options.refreshToken || defaultRefreshTokenHandler;
91
- this.hasSession = false;
92
- this.alertFunc = options.alertFunc || alertHandler.handleAlert;
93
- this.canvasOrigin = options.canvasOrigin || window.origin;
94
- }
95
-
96
- getSession() {
97
- const headers = headerFor(this.jwt);
98
- const uri = this.baseUri('session');
99
- return this.apiReallyFetch(uri, headers).then(data => {
100
- this.hasSession = true;
101
- return data;
102
- }).catch(throwConnectionError);
103
- } // initial state of a collection is empty, not loading, with bookmark set to
104
- // uri for initial page fetch
105
-
106
-
107
- initializeCollection(endpoint, props) {
108
- return {
109
- links: [],
110
- bookmark: this.uriFor(endpoint, props),
111
- isLoading: false,
112
- hasMore: true,
113
- searchString: props.searchString
114
- };
115
- }
116
-
117
- initializeUpload() {
118
- return {
119
- uploading: false,
120
- folders: {},
121
- formExpanded: false
122
- };
123
- }
124
-
125
- initializeImages(props) {
126
- return this.initializeDocuments(props);
127
- }
128
-
129
- initializeDocuments(props) {
130
- return {
131
- [props.contextType]: {
132
- files: [],
133
- bookmark: null,
134
- isLoading: false,
135
- hasMore: true
136
- },
137
- searchString: ''
138
- };
139
- }
140
-
141
- initializeMedia(props) {
142
- return this.initializeDocuments(props);
143
- }
144
-
145
- initializeFlickr() {
146
- return {
147
- searchResults: [],
148
- searching: false,
149
- formExpanded: false
150
- };
151
- } // fetches the given URI and filters it to either an error or parsed response
152
-
153
-
154
- fetchPage(uri) {
155
- return this.apiFetch(uri, headerFor(this.jwt));
156
- }
157
-
158
- fetchBookmarkedData(fetchFunction, properties, onSuccess, onError, bookmark) {
159
- return fetchFunction(properties, bookmark).then(result => {
160
- onSuccess(result);
161
-
162
- if (result.bookmark) {
163
- this.fetchBookmarkedData(fetchFunction, properties, onSuccess, onError, result.bookmark);
164
- }
165
- }).catch(error => {
166
- onError(error);
167
- });
168
- }
169
-
170
- fetchDocs(props) {
171
- const documents = props.documents[props.contextType];
172
- const uri = documents.bookmark || this.uriFor('documents', props);
173
- return this.apiFetch(uri, headerFor(this.jwt)).then(_ref => {
174
- let {
175
- bookmark,
176
- files
177
- } = _ref;
178
- return {
179
- bookmark,
180
- files: files.map(f => fixupFileUrl(props.contextType, props.contextId, f, this.canvasOrigin))
181
- };
182
- });
183
- }
184
-
185
- fetchMedia(props) {
186
- var _RCEGlobals$getFeatur;
187
-
188
- const media = props.media[props.contextType];
189
- const uri = media.bookmark || this.uriFor('media', props);
190
-
191
- if ((_RCEGlobals$getFeatur = RCEGlobals.getFeatures()) !== null && _RCEGlobals$getFeatur !== void 0 && _RCEGlobals$getFeatur.media_links_use_attachment_id) {
192
- return this.apiFetch(uri, headerFor(this.jwt)).then(_ref2 => {
193
- let {
194
- bookmark,
195
- files
196
- } = _ref2;
197
- return {
198
- bookmark,
199
- files: files.map(f => fixupFileUrl(props.contextType, props.contextId, f, this.canvasOrigin))
200
- };
201
- });
202
- }
203
-
204
- return this.apiFetch(uri, headerFor(this.jwt));
205
- }
206
-
207
- fetchFiles(uri) {
208
- return this.fetchPage(uri).then(_ref3 => {
209
- let {
210
- bookmark,
211
- files
212
- } = _ref3;
213
- return {
214
- bookmark,
215
- files: files.map(normalizeFileData)
216
- };
217
- });
218
- }
219
-
220
- fetchLinks(key, props) {
221
- const {
222
- collections
223
- } = props;
224
- const bookmark = collections[key].bookmark || this.uriFor(key, props);
225
- return this.fetchPage(bookmark);
226
- }
227
-
228
- fetchRootFolder(props) {
229
- return this.fetchPage(this.uriFor('folders', props), this.jwt);
230
- }
231
-
232
- mediaServerSession() {
233
- return this.apiPost(this.baseUri('v1/services/kaltura_session'), headerFor(this.jwt), {});
234
- }
235
-
236
- uploadMediaToCanvas(mediaObject) {
237
- const body = {
238
- id: mediaObject.entryId,
239
- type: {
240
- 2: 'image',
241
- 5: 'audio'
242
- }[mediaObject.mediaType] || mediaObject.type.includes('audio') ? 'audio' : 'video',
243
- context_code: mediaObject.contextCode,
244
- title: mediaObject.title,
245
- user_entered_title: mediaObject.userTitle
246
- };
247
- return this.apiPost(this.baseUri('media_objects'), headerFor(this.jwt), body);
248
- }
249
-
250
- updateMediaObject(apiProps, _ref4) {
251
- var _RCEGlobals$getFeatur2;
252
-
253
- let {
254
- media_object_id,
255
- title,
256
- attachment_id
257
- } = _ref4;
258
- 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)}`;
259
- return this.apiPost(uri, headerFor(this.jwt), null, 'PUT');
260
- } // PUT to //RCS/api/media_objects/:mediaId/media_tracks [{locale, content}, ...]
261
- // receive back a 200 with the new subtitles, or a 4xx error
262
-
263
-
264
- updateClosedCaptions(apiProps, _ref5) {
265
- let {
266
- media_object_id,
267
- attachment_id,
268
- subtitles
269
- } = _ref5;
270
- let maxBytes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : CONSTANTS.CC_FILE_MAX_BYTES;
271
- const rcsConfig = {
272
- origin: originFromHost(apiProps.host),
273
- headers: headerFor(apiProps.jwt)
274
- };
275
- const saveCaptions = attachment_id ? saveClosedCaptionsForAttachment(attachment_id, subtitles, rcsConfig, maxBytes) : saveClosedCaptions(media_object_id, subtitles, rcsConfig, maxBytes);
276
- return saveCaptions.catch(e => {
277
- this.alertFunc(buildError({
278
- message: 'failed to save captions'
279
- }, e));
280
- });
281
- } // GET /media_objects/:mediaId/media_tracks
282
- // receive back the current list of media_tracks
283
-
284
-
285
- fetchClosedCaptions(_mediaId) {
286
- return Promise.resolve([{
287
- locale: 'af',
288
- content: '1\r\n00:00:00,000 --> 00:00:01,251\r\nThis is the content\r\n'
289
- }, {
290
- locale: 'es',
291
- content: '1\r\n00:00:00,000 --> 00:00:01,251\r\nThis is the content\r\n'
292
- }]);
293
- } // fetches folders for the given context to upload files to
294
-
295
-
296
- fetchFolders(props, bookmark) {
297
- const headers = headerFor(this.jwt);
298
- const uri = bookmark || this.uriFor('folders/all', props);
299
- return this.apiFetch(uri, headers);
300
- } // Fetches all files for a given folder
301
-
302
-
303
- fetchFilesForFolder(props, bookmark) {
304
- let uri;
305
-
306
- if (!bookmark) {
307
- const perPageQuery = props.perPage ? `per_page=${props.perPage}` : '';
308
- const searchParam = getSearchParam(props.searchString);
309
- uri = `${props.filesUrl}`;
310
- uri += perPageQuery ? `?${perPageQuery}` : '';
311
-
312
- if (searchParam) {
313
- uri += perPageQuery ? `${searchParam}` : `?${searchParam}`;
314
- }
315
-
316
- if (props.sortBy) {
317
- uri += `${getSortParams(props.sortBy.sort, props.sortBy.order)}`;
318
- }
319
- }
320
-
321
- return this.fetchPage(uri || bookmark, this.jwt);
322
- }
323
-
324
- fetchSubFolders(props, bookmark) {
325
- const uri = bookmark || `${this.baseUri('folders', props.host)}/${props.folderId}`;
326
- return this.apiFetch(uri, headerFor(this.jwt));
327
- }
328
-
329
- fetchIconMakerFolder(_ref6) {
330
- let {
331
- contextId,
332
- contextType
333
- } = _ref6;
334
- const uri = this.uriFor('folders/icon_maker', {
335
- contextId,
336
- contextType,
337
- host: this.host,
338
- jwt: this.jwt
339
- });
340
- return this.fetchPage(uri);
341
- }
342
-
343
- fetchMediaFolder(props) {
344
- let uri;
345
-
346
- if (props.contextType === 'user') {
347
- uri = this.uriFor('folders', props);
348
- } else {
349
- uri = this.uriFor('folders/media', props);
350
- }
351
-
352
- return this.fetchPage(uri);
353
- }
354
-
355
- fetchMediaObjectIframe(mediaObjectId) {
356
- return this.fetchPage(this.uriFor(`media_objects_iframe/${mediaObjectId}`));
357
- }
358
-
359
- fetchImages(props) {
360
- const images = props.images[props.contextType];
361
- const uri = images.bookmark || this.uriFor('images', props);
362
- const headers = headerFor(this.jwt);
363
- return this.apiFetch(uri, headers).then(_ref7 => {
364
- let {
365
- bookmark,
366
- files
367
- } = _ref7;
368
- return {
369
- bookmark,
370
- files: files.map(f => fixupFileUrl(props.contextType, props.contextId, f, this.canvasOrigin)),
371
- searchString: props.searchString
372
- };
373
- });
374
- }
375
-
376
- preflightUpload(fileProps, apiProps) {
377
- const headers = headerFor(this.jwt);
378
- const uri = this.baseUri('upload', apiProps.host);
379
- const body = {
380
- contextId: apiProps.contextId,
381
- contextType: apiProps.contextType,
382
- file: fileProps,
383
- no_redirect: true,
384
- onDuplicate: apiProps.onDuplicate,
385
- category: apiProps.category
386
- };
387
- return this.apiPost(uri, headers, body);
388
- }
389
-
390
- uploadFRD(fileDomObject, preflightProps) {
391
- const data = new window.FormData();
392
- Object.keys(preflightProps.upload_params).forEach(uploadProp => {
393
- data.append(uploadProp, preflightProps.upload_params[uploadProp]);
394
- });
395
- data.append('file', fileDomObject);
396
- const fetchOptions = {
397
- method: 'POST',
398
- body: data
399
- };
400
-
401
- if (!preflightProps.upload_params['x-amz-signature'] && !preflightProps.upload_url.includes('files_api')) {
402
- // _not_ an S3 upload, include the credentials in the upload POST
403
- // local uploads can include crendentials for same-origin requests
404
- fetchOptions.credentials = 'include';
405
- }
406
-
407
- return fetch(preflightProps.upload_url, fetchOptions).then(checkStatus).then(res => res.json()).then(uploadResults => {
408
- return this.finalizeUpload(preflightProps, uploadResults);
409
- }).catch(e => {
410
- this.alertFunc(buildError({}, e));
411
- });
412
- }
413
-
414
- finalizeUpload(preflightProps, uploadResults) {
415
- if (preflightProps.upload_params.success_url) {
416
- // s3 upload, follow-up at success_url to finalize. the success_url doesn't
417
- // require authentication
418
- return fetch(preflightProps.upload_params.success_url).then(checkStatus).then(res => res.json());
419
- } else if (uploadResults.location) {
420
- // inst-fs upload, follow-up by fetching file identified by location in
421
- // response. we can't just fetch the location as would be intended because
422
- // it requires Canvas authentication. we also don't have an RCE API
423
- // endpoint to forward it through.
424
- const {
425
- pathname
426
- } = parse(uploadResults.location);
427
- const matchData = pathname.match(/^\/api\/v1\/files\/((?:\d+~)?\d+)$/);
428
-
429
- if (!matchData) {
430
- const error = new Error('cannot determine file ID from location');
431
- error.location = uploadResults.location;
432
- throw error;
433
- }
434
-
435
- const fileId = matchData[1];
436
- return this.getFile(fileId).then(fileResults => {
437
- fileResults.uuid = uploadResults.uuid; // if present, we'll need the uuid for the file verifier downstream
438
-
439
- return fileResults;
440
- });
441
- } else {
442
- // local-storage upload, this _is_ the attachment information
443
- return Promise.resolve(uploadResults);
444
- }
445
- }
446
-
447
- setUsageRights(fileId, usageRights) {
448
- const headers = headerFor(this.jwt);
449
- const uri = this.baseUri('usage_rights');
450
- const body = {
451
- fileId,
452
- ...usageRights
453
- };
454
- return this.apiPost(uri, headers, body);
455
- }
456
-
457
- searchFlickr(term, apiProps) {
458
- const headers = headerFor(this.jwt);
459
- const base = this.baseUri('flickr_search', apiProps.host);
460
- const uri = `${base}?term=${encodeURIComponent(term)}`;
461
- return this.apiFetch(uri, headers);
462
- }
463
-
464
- getFile(id) {
465
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
466
- const headers = headerFor(this.jwt);
467
- const base = this.baseUri('file'); // Valid query parameters for getFile
468
-
469
- const {
470
- replacement_chain_context_type,
471
- replacement_chain_context_id,
472
- include
473
- } = options;
474
- const uri = this.addParamsIfPresent(`${base}/${id}`, {
475
- replacement_chain_context_type,
476
- replacement_chain_context_id,
477
- include
478
- });
479
- return this.apiFetch(uri, headers).then(normalizeFileData);
480
- } // @private
481
-
482
-
483
- addParamsIfPresent(uri, params) {
484
- let url;
485
-
486
- try {
487
- url = new URL(uri);
488
- } catch (e) {
489
- // Just return the URI if it was invalid
490
- return uri;
491
- } // Add all truthy parameters to the URL
492
-
493
-
494
- for (const [name, value] of Object.entries(params)) {
495
- if (!value) continue;
496
- url.searchParams.append(name, value);
497
- }
498
-
499
- return url.toString();
500
- } // @private
501
-
502
-
503
- async apiFetch(uri, headers, options) {
504
- if (!this.hasSession) {
505
- await this.getSession();
506
- }
507
-
508
- return this.apiReallyFetch(uri, headers, options);
509
- }
510
-
511
- apiReallyFetch(uri, headers) {
512
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
513
- uri = this.normalizeUriProtocol(uri);
514
- return fetch(uri, {
515
- headers
516
- }).then(response => {
517
- if (response.status === 401) {
518
- // retry once with fresh token
519
- return this.buildRetryHeaders(headers).then(newHeaders => {
520
- return fetch(uri, {
521
- headers: newHeaders
522
- });
523
- });
524
- } else {
525
- return response;
526
- }
527
- }).then(checkStatus).then(options.skipParse ? () => {} : res => res.json()).catch(throwConnectionError).catch(e => {
528
- this.alertFunc(buildError(e));
529
- throw e;
530
- });
531
- } // @private
532
-
533
-
534
- apiPost(uri, headers, body) {
535
- let method = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'POST';
536
- headers = { ...headers,
537
- 'Content-Type': 'application/json'
538
- };
539
- const fetchOptions = {
540
- method,
541
- headers
542
- };
543
-
544
- if (body) {
545
- fetchOptions.body = JSON.stringify(body);
546
- } else {
547
- fetchOptions.form = body;
548
- }
549
-
550
- uri = this.normalizeUriProtocol(uri);
551
- return fetch(uri, fetchOptions).then(response => {
552
- if (response.status === 401) {
553
- // retry once with fresh token
554
- return this.buildRetryHeaders(fetchOptions.headers).then(newHeaders => {
555
- const newOptions = { ...fetchOptions,
556
- headers: newHeaders
557
- };
558
- return fetch(uri, newOptions);
559
- });
560
- } else {
561
- return response;
562
- }
563
- }).then(checkStatus).then(res => res.json()).catch(throwConnectionError).catch(e => e.response.json().then(responseBody => {
564
- console.error(e); // eslint-disable-line no-console
565
-
566
- this.alertFunc(buildError(responseBody));
567
- throw e;
568
- }));
569
- } // @private
570
-
571
-
572
- normalizeUriProtocol(uri, windowOverride) {
573
- const windowHandle = windowOverride || (typeof window !== 'undefined' ? window : undefined);
574
-
575
- if (windowHandle && windowHandle.location && windowHandle.location.protocol === 'https:') {
576
- return uri.replace('http://', 'https://');
577
- }
578
-
579
- return uri;
580
- } // @private
581
-
582
-
583
- buildRetryHeaders(headers) {
584
- return new Promise(resolve => {
585
- this.refreshToken(freshToken => {
586
- this.jwt = freshToken;
587
- const freshHeader = headerFor(freshToken);
588
- const mergedHeaders = { ...headers,
589
- ...freshHeader
590
- };
591
- resolve(mergedHeaders);
592
- });
593
- });
594
- }
595
-
596
- baseUri(endpoint, host, windowOverride) {
597
- if (!host && this.host) {
598
- host = this.host;
599
- }
600
-
601
- host = originFromHost(host, windowOverride);
602
- const sharedEndpoints = ['images', 'media', 'documents', 'all']; // 'all' will eventually be something different
603
-
604
- const endpt = sharedEndpoints.includes(endpoint) ? 'documents' : endpoint;
605
- return `${host}/api/${endpt}`;
606
- } // returns the URI to use with the fetchPage method to fetch the first page of
607
- // the given endpoint. e.g. for wikiPages it might return:
608
- //
609
- // //rce.docker/api/wikiPages?context_type=course&context_id=42
610
- //
611
-
612
-
613
- uriFor(endpoint, props) {
614
- const {
615
- host,
616
- contextType,
617
- contextId,
618
- sortBy,
619
- searchString,
620
- perPage
621
- } = props;
622
- let extra = '';
623
- const pageSizeParam = perPage ? `&per_page=${perPage}` : '';
624
-
625
- switch (endpoint) {
626
- case 'images':
627
- extra = `&content_types=image${getSortParams(sortBy.sort, sortBy.dir)}${getSearchParam(searchString)}${optionalQuery(props, 'category')}`;
628
- break;
629
-
630
- case 'media':
631
- // when requesting media files via the documents endpoint
632
- extra = `&content_types=video,audio${getSortParams(sortBy.sort, sortBy.dir)}${getSearchParam(searchString)}`;
633
- break;
634
-
635
- case 'documents':
636
- extra = `&exclude_content_types=image,video,audio${getSortParams(sortBy.sort, sortBy.dir)}${getSearchParam(searchString)}`;
637
- break;
638
-
639
- case 'media_objects':
640
- // when requesting media objects (this is the currently used branch)
641
- extra = `${getSortParams(sortBy.sort === 'alphabetical' ? 'title' : 'date', sortBy.dir)}${getSearchParam(searchString)}`;
642
- break;
643
-
644
- default:
645
- extra = getSearchParam(searchString);
646
- }
647
-
648
- return `${this.baseUri(endpoint, host)}?contextType=${contextType}&contextId=${contextId}${pageSizeParam}${extra}`;
649
- }
650
-
651
- }
652
-
653
- function getSortParams(sort, dir) {
654
- let sortBy = sort;
655
-
656
- if (sortBy === 'date_added') {
657
- sortBy = 'created_at';
658
- } else if (sortBy === 'alphabetical') {
659
- sortBy = 'name';
660
- }
661
-
662
- return `&sort=${sortBy}&order=${dir}`;
663
- }
664
-
665
- function optionalQuery(props, name) {
666
- return props[name] ? `&${name}=${props[name]}` : '';
667
- }
668
-
669
- export function getSearchParam(searchString) {
670
- return (searchString === null || searchString === void 0 ? void 0 : searchString.length) >= 3 ? `&search_term=${encodeURIComponent(searchString)}` : '';
671
- }
672
- export default RceApiSource;