@instructure/canvas-rce 5.14.2 → 5.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/DEVELOPMENT.md +1 -1
- package/es/bridge/Bridge.js +10 -17
- package/es/canvasFileBrowser/FileBrowser.js +10 -19
- package/es/common/FlashAlert.js +8 -11
- package/es/common/fileUrl.js +6 -10
- package/es/common/incremental-loading/LoadMoreButton.js +3 -4
- package/es/common/incremental-loading/LoadingStatus.js +4 -11
- package/es/common/indicate.js +1 -2
- package/es/defaultTinymceConfig.js +1 -1
- package/es/enhance-user-content/doc_previews.js +10 -10
- package/es/enhance-user-content/enhance_user_content.js +4 -7
- package/es/enhance-user-content/external_links.js +1 -1
- package/es/enhance-user-content/instructure_helper.js +11 -17
- package/es/enhance-user-content/mathml.js +15 -27
- package/es/enhance-user-content/media_comment_thumbnail.js +3 -10
- package/es/format-message.js +2 -2
- package/es/index.js +3 -5
- package/es/rce/AlertMessageArea.js +15 -16
- package/es/rce/KeyboardShortcutModal.js +2 -2
- package/es/rce/RCE.js +6 -8
- package/es/rce/RCEVariants.js +2 -4
- package/es/rce/RCEWrapper.js +397 -289
- package/es/rce/RCEWrapper.utils.js +131 -0
- package/es/rce/RCEWrapperProps.js +2 -3
- package/es/rce/RceHtmlEditor.js +12 -11
- package/es/rce/ResizeHandle.js +1 -2
- package/es/rce/ShowOnFocusButton/index.js +2 -2
- package/es/rce/StatusBar.js +5 -10
- package/es/rce/contentInsertion.js +1 -2
- package/es/rce/contentRendering.js +6 -5
- package/es/rce/editorLanguage.js +1 -1
- package/es/rce/indicatorRegion.js +1 -2
- package/es/rce/normalizeProps.js +4 -4
- package/es/rce/plugins/instructure_color/clickCallback.js +2 -4
- package/es/rce/plugins/instructure_color/components/ColorPicker.js +17 -22
- package/es/rce/plugins/instructure_color/components/ColorPopup.js +7 -8
- package/es/rce/plugins/instructure_condensed_buttons/ui/list-button.js +4 -10
- package/es/rce/plugins/instructure_condensed_buttons/ui/subscript-superscript-button.js +1 -1
- package/es/rce/plugins/instructure_documents/components/Link.js +1 -2
- package/es/rce/plugins/instructure_equation/EquationEditorModal/index.js +5 -8
- package/es/rce/plugins/instructure_equation/EquationEditorModal/latexTextareaUtil.js +3 -3
- package/es/rce/plugins/instructure_equation/EquationEditorModal/parseLatex.js +3 -3
- package/es/rce/plugins/instructure_equation/EquationEditorToolbar/buttons.js +2 -2
- package/es/rce/plugins/instructure_equation/EquationEditorToolbar/index.js +9 -11
- package/es/rce/plugins/instructure_equation/MathIcon/index.js +3 -4
- package/es/rce/plugins/instructure_equation/mathlive/index.js +167 -16
- package/es/rce/plugins/instructure_fullscreen/plugin.js +0 -2
- package/es/rce/plugins/instructure_icon_maker/clickCallback.js +3 -4
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ColorSection.js +46 -49
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/CreateIconMakerForm.js +9 -10
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Footer.js +10 -11
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Group.js +5 -6
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Header.js +7 -8
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/Course.js +7 -9
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/ImageOptions.js +19 -26
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/ImageSection.js +8 -12
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/ModeSelect.js +6 -7
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/MultiColor/index.js +5 -6
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SVGList.js +6 -7
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SVGThumbnail.js +8 -10
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SingleColor/index.js +5 -6
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/SingleColor/svg.js +32 -80
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/Upload.js +7 -8
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ImageSection/utils.js +4 -5
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/Preview.js +3 -4
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/ShapeSection.js +4 -5
- package/es/rce/plugins/instructure_icon_maker/components/CreateIconMakerForm/TextSection.js +4 -5
- package/es/rce/plugins/instructure_icon_maker/components/IconMakerTray.js +22 -29
- package/es/rce/plugins/instructure_icon_maker/registerEditToolbar.js +1 -1
- package/es/rce/plugins/instructure_icon_maker/svg/image.js +5 -7
- package/es/rce/plugins/instructure_icon_maker/svg/index.js +6 -9
- package/es/rce/plugins/instructure_icon_maker/svg/settings.js +17 -20
- package/es/rce/plugins/instructure_icon_maker/svg/shape.js +4 -5
- package/es/rce/plugins/instructure_icon_maker/svg/text.js +28 -32
- package/es/rce/plugins/instructure_icon_maker/svg/utils.js +2 -4
- package/es/rce/plugins/instructure_icon_maker/utils/IconMakerClose.js +2 -3
- package/es/rce/plugins/instructure_icon_maker/utils/iconValidation.js +1 -2
- package/es/rce/plugins/instructure_image/ImageEmbedOptions.js +3 -7
- package/es/rce/plugins/instructure_image/ImageList/Image.js +7 -8
- package/es/rce/plugins/instructure_image/ImageList/index.js +7 -8
- package/es/rce/plugins/instructure_image/ImageOptionsTray/TrayController.js +2 -4
- package/es/rce/plugins/instructure_image/ImageOptionsTray/index.js +3 -3
- package/es/rce/plugins/instructure_image/plugin.js +1 -2
- package/es/rce/plugins/instructure_links/components/AccordionSection.js +7 -8
- package/es/rce/plugins/instructure_links/components/Link.js +61 -65
- package/es/rce/plugins/instructure_links/components/LinkOptionsDialog/LinkOptionsDialogController.js +1 -2
- package/es/rce/plugins/instructure_links/components/LinkOptionsDialog/index.js +2 -2
- package/es/rce/plugins/instructure_links/components/LinkOptionsTray/index.js +2 -2
- package/es/rce/plugins/instructure_links/components/LinkSet.js +28 -37
- package/es/rce/plugins/instructure_links/components/LinksPanel.js +21 -8
- package/es/rce/plugins/instructure_links/components/NoResults.js +6 -7
- package/es/rce/plugins/instructure_links/plugin.js +6 -9
- package/es/rce/plugins/instructure_media_embed/clickCallback.js +3 -4
- package/es/rce/plugins/instructure_media_embed/components/Embed.js +6 -7
- package/es/rce/plugins/instructure_paste/plugin.js +5 -7
- package/es/rce/plugins/instructure_rce_external_tools/ExternalToolsEnv.js +24 -33
- package/es/rce/plugins/instructure_rce_external_tools/RceToolWrapper.js +7 -38
- package/es/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialog.js +30 -29
- package/es/rce/plugins/instructure_rce_external_tools/components/ExternalToolSelectionDialog/ExternalToolSelectionDialog.js +3 -4
- package/es/rce/plugins/instructure_rce_external_tools/dialog-helper.js +1 -2
- package/es/rce/plugins/instructure_rce_external_tools/jquery/jquery.dropdownList.js +3 -4
- package/es/rce/plugins/instructure_rce_external_tools/lti11-content-items/RceLti11ContentItem.js +17 -24
- package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/RceLti13ContentItem.js +2 -2
- package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/BaseLinkContentItem.js +4 -5
- package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/processEditorContentItems.js +8 -9
- package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/rceLti13ContentItemFromJson.js +0 -1
- package/es/rce/plugins/instructure_rce_external_tools/plugin.js +4 -4
- package/es/rce/plugins/instructure_rce_external_tools/util/externalToolsForToolbar.js +42 -0
- package/es/rce/plugins/instructure_record/AudioOptionsTray/TrayController.js +5 -10
- package/es/rce/plugins/instructure_record/AudioOptionsTray/index.js +12 -13
- package/es/rce/plugins/instructure_record/VideoOptionsTray/TrayController.js +8 -15
- package/es/rce/plugins/instructure_record/VideoOptionsTray/index.js +19 -20
- package/es/rce/plugins/instructure_record/clickCallback.js +26 -30
- package/es/rce/plugins/instructure_search_and_replace/clickCallback.js +2 -3
- package/es/rce/plugins/instructure_search_and_replace/components/FindReplaceTray.js +14 -16
- package/es/rce/plugins/instructure_search_and_replace/components/FindReplaceTrayController.js +9 -12
- package/es/rce/plugins/instructure_search_and_replace/plugin.js +1 -2
- package/es/rce/plugins/instructure_wordcount/clickCallback.js +3 -4
- package/es/rce/plugins/instructure_wordcount/components/WordCountModal.js +26 -33
- package/es/rce/plugins/instructure_wordcount/utils/countContent.js +3 -3
- package/es/rce/plugins/instructure_wordcount/utils/tableContent.js +5 -8
- package/es/rce/plugins/shared/CanvasContentTray.js +9 -16
- package/es/rce/plugins/shared/ColorInput.js +22 -25
- package/es/rce/plugins/shared/ConditionalTooltip.js +5 -6
- package/es/rce/plugins/shared/ContentSelection.js +12 -20
- package/es/rce/plugins/shared/DimensionUtils.js +2 -4
- package/es/rce/plugins/shared/EventUtils.js +1 -1
- package/es/rce/plugins/shared/FixedContentTray.js +13 -14
- package/es/rce/plugins/shared/ImageCropper/DirectionRegion.js +3 -4
- package/es/rce/plugins/shared/ImageCropper/Modal.js +12 -13
- package/es/rce/plugins/shared/ImageCropper/Preview.js +11 -13
- package/es/rce/plugins/shared/ImageCropper/controls/CustomNumberInput.js +8 -9
- package/es/rce/plugins/shared/ImageCropper/controls/ResetControls.js +3 -4
- package/es/rce/plugins/shared/ImageCropper/controls/RotationControls.js +4 -5
- package/es/rce/plugins/shared/ImageCropper/controls/ShapeControls.js +7 -11
- package/es/rce/plugins/shared/ImageCropper/controls/ZoomControls.js +4 -5
- package/es/rce/plugins/shared/ImageCropper/controls/index.js +4 -5
- package/es/rce/plugins/shared/ImageCropper/controls/useDebouncedNumericValue.js +13 -15
- package/es/rce/plugins/shared/ImageCropper/imageCropUtils.js +18 -21
- package/es/rce/plugins/shared/ImageCropper/svg/shape.js +4 -5
- package/es/rce/plugins/shared/ImageCropper/svg/utils.js +2 -4
- package/es/rce/plugins/shared/ImageCropper/useKeyMouseEvents.js +1 -4
- package/es/rce/plugins/shared/ImageOptionsForm.js +17 -18
- package/es/rce/plugins/shared/LinkDisplay.js +8 -9
- package/es/rce/plugins/shared/PreviewIcon.js +8 -9
- package/es/rce/plugins/shared/RceFileBrowser.js +2 -3
- package/es/rce/plugins/shared/StoreContext.js +8 -10
- package/es/rce/plugins/shared/StudioLtiSupportUtils.js +5 -6
- package/es/rce/plugins/shared/Upload/CanvasContentPanel.js +6 -7
- package/es/rce/plugins/shared/Upload/CategoryProcessor.js +1 -2
- package/es/rce/plugins/shared/Upload/ComputerPanel.js +11 -14
- package/es/rce/plugins/shared/Upload/PanelFilter.js +7 -8
- package/es/rce/plugins/shared/Upload/UploadFile.js +19 -22
- package/es/rce/plugins/shared/Upload/UploadFileModal.js +28 -34
- package/es/rce/plugins/shared/Upload/UrlPanel.js +4 -5
- package/es/rce/plugins/shared/Upload/UsageRightsSelectBox.js +18 -24
- package/es/rce/plugins/shared/Upload/doFileUpload.js +6 -7
- package/es/rce/plugins/shared/ai_tools/AIResponseModal.js +7 -8
- package/es/rce/plugins/shared/ai_tools/AIToolsTray.js +14 -17
- package/es/rce/plugins/shared/ai_tools/aiicons.js +2 -2
- package/es/rce/plugins/shared/canvasContentUtils.js +1 -2
- package/es/rce/plugins/shared/compressionUtils.js +17 -20
- package/es/rce/plugins/shared/do-fetch-api-effect/doFetchApi.js +12 -15
- package/es/rce/plugins/shared/do-fetch-api-effect/get-cookie.js +1 -1
- package/es/rce/plugins/shared/fileTypeUtils.js +3 -6
- package/es/rce/plugins/shared/round.js +1 -2
- package/es/rce/plugins/shared/trayUtils.js +3 -0
- package/es/rce/plugins/shared/useDataUrl.js +4 -5
- package/es/rce/plugins/tinymce-a11y-checker/components/ColorField.js +2 -2
- package/es/rce/plugins/tinymce-a11y-checker/components/checker.js +8 -10
- package/es/rce/plugins/tinymce-a11y-checker/node-checker.js +1 -3
- package/es/rce/plugins/tinymce-a11y-checker/plugin.js +14 -17
- package/es/rce/plugins/tinymce-a11y-checker/rules/headings-start-at-h2.js +1 -2
- package/es/rce/plugins/tinymce-a11y-checker/rules/large-text-contrast.js +1 -2
- package/es/rce/plugins/tinymce-a11y-checker/rules/small-text-contrast.js +1 -2
- package/es/rce/plugins/tinymce-a11y-checker/utils/dom.js +2 -4
- package/es/rce/plugins/tinymce-a11y-checker/utils/indicate.js +2 -3
- package/es/rce/plugins/tinymce-a11y-checker/utils/rgb-hex.js +1 -4
- package/es/rce/root.js +9 -9
- package/es/rce/tinyRCE.js +1 -0
- package/es/rce/transformContent.js +1 -1
- package/es/rcs/api.js +39 -55
- package/es/rcs/buildError.js +3 -3
- package/es/rcs/fake.js +5 -7
- package/es/sidebar/actions/documents.js +10 -12
- package/es/sidebar/actions/files.js +18 -22
- package/es/sidebar/actions/filter.js +4 -5
- package/es/sidebar/actions/images.js +20 -26
- package/es/sidebar/actions/media.js +15 -18
- package/es/sidebar/actions/session.js +1 -2
- package/es/sidebar/actions/upload.js +26 -37
- package/es/sidebar/containers/sidebarHandlers.js +6 -12
- package/es/sidebar/dragHtml.js +6 -2
- package/es/sidebar/reducers/all_files.js +1 -3
- package/es/sidebar/reducers/collection.js +1 -3
- package/es/sidebar/reducers/collections.js +1 -3
- package/es/sidebar/reducers/documents.js +1 -3
- package/es/sidebar/reducers/files.js +1 -3
- package/es/sidebar/reducers/filter.js +7 -15
- package/es/sidebar/reducers/flickr.js +1 -3
- package/es/sidebar/reducers/folder.js +1 -3
- package/es/sidebar/reducers/folders.js +1 -3
- package/es/sidebar/reducers/images.js +1 -3
- package/es/sidebar/reducers/media.js +1 -3
- package/es/sidebar/reducers/newPageLinkExpanded.js +1 -3
- package/es/sidebar/reducers/noop.js +1 -2
- package/es/sidebar/reducers/rootFolderId.js +1 -3
- package/es/sidebar/reducers/session.js +1 -3
- package/es/sidebar/reducers/ui.js +3 -9
- package/es/sidebar/reducers/upload.js +8 -24
- package/es/sidebar/store/initialState.js +1 -2
- package/es/translations/locales/ar.js +6 -0
- package/es/translations/locales/ca.js +6 -0
- package/es/translations/locales/cy.js +6 -0
- package/es/translations/locales/da-x-k12.js +6 -0
- package/es/translations/locales/da.js +6 -0
- package/es/translations/locales/de.js +6 -0
- package/es/translations/locales/en-AU-x-unimelb.js +6 -0
- package/es/translations/locales/en-GB-x-ukhe.js +6 -0
- package/es/translations/locales/en_AU.js +6 -0
- package/es/translations/locales/en_CA.js +6 -0
- package/es/translations/locales/en_CY.js +6 -0
- package/es/translations/locales/en_GB.js +6 -0
- package/es/translations/locales/es.js +6 -0
- package/es/translations/locales/es_ES.js +6 -0
- package/es/translations/locales/fi.js +6 -0
- package/es/translations/locales/fr.js +6 -0
- package/es/translations/locales/fr_CA.js +6 -0
- package/es/translations/locales/hi.js +6 -0
- package/es/translations/locales/ht.js +6 -0
- package/es/translations/locales/id.js +6 -0
- package/es/translations/locales/is.js +6 -0
- package/es/translations/locales/it.js +6 -0
- package/es/translations/locales/ja.js +6 -0
- package/es/translations/locales/mi.js +6 -0
- package/es/translations/locales/ms.js +6 -0
- package/es/translations/locales/nb-x-k12.js +6 -0
- package/es/translations/locales/nb.js +6 -0
- package/es/translations/locales/nl.js +6 -0
- package/es/translations/locales/pl.js +6 -0
- package/es/translations/locales/pt.js +6 -0
- package/es/translations/locales/pt_BR.js +6 -0
- package/es/translations/locales/ru.js +6 -0
- package/es/translations/locales/sl.js +6 -0
- package/es/translations/locales/sv-x-k12.js +6 -0
- package/es/translations/locales/sv.js +6 -0
- package/es/translations/locales/th.js +6 -0
- package/es/translations/locales/vi.js +6 -0
- package/es/translations/locales/zh-Hans.js +6 -0
- package/es/translations/locales/zh-Hant.js +6 -0
- package/es/translations/locales/zh.js +6 -0
- package/es/translations/locales/zh_HK.js +6 -0
- package/es/util/elem-util.js +1 -1
- package/es/util/file-url-util.js +1 -1
- package/es/util/fullscreenHelpers.js +6 -9
- package/es/util/loadingPlaceholder.js +2 -3
- package/es/util/simpleCache.js +1 -2
- package/es/util/url-util.js +5 -5
- package/eslint.config.js +15 -4
- package/locales/en.json +190 -10
- package/package.json +56 -55
- package/scripts/installTranslations.js +7 -8
- package/tsconfig.json +1 -1
- package/types/format-message-generate-id.d.ts +22 -0
- package/types/js-beautify.d.ts +21 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2025 - 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
|
+
|
|
19
|
+
import formatMessage from '../format-message';
|
|
20
|
+
|
|
21
|
+
// standard: string of tinymce menu commands
|
|
22
|
+
// e.g. 'instructure_links | inserttable instructure_media_embed | hr'
|
|
23
|
+
// custom: a string of tinymce menu commands
|
|
24
|
+
// returns: standard + custom with any duplicate commands removed from custom
|
|
25
|
+
export function mergeMenuItems(standard, custom) {
|
|
26
|
+
let c = custom?.trim?.();
|
|
27
|
+
if (!c) return standard;
|
|
28
|
+
const s = new Set(standard.split(/[\s|]+/));
|
|
29
|
+
// remove any duplicates
|
|
30
|
+
const c_array = c.split(/\s+/).filter(m => !s.has(m));
|
|
31
|
+
c = c_array.join(' ').replace(/^\s*\|\s*/, '').replace(/\s*\|\s*$/, '');
|
|
32
|
+
return `${standard} | ${c}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// standard: the incoming tinymce menu object
|
|
36
|
+
// custom: tinymce menu object to merge into standard
|
|
37
|
+
// returns: the merged result by mutating incoming standard arg.
|
|
38
|
+
// It will add commands to existing menus, or add a new menu
|
|
39
|
+
// if the custom one does not exist
|
|
40
|
+
export function mergeMenu(standard, custom) {
|
|
41
|
+
if (!custom) return standard;
|
|
42
|
+
Object.keys(custom).forEach(k => {
|
|
43
|
+
const curr_m = standard[k];
|
|
44
|
+
if (curr_m) {
|
|
45
|
+
curr_m.items = mergeMenuItems(curr_m.items, custom[k].items);
|
|
46
|
+
} else {
|
|
47
|
+
standard[k] = {
|
|
48
|
+
...custom[k]
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return standard;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// standard: incoming tinymce toolbar array
|
|
56
|
+
// custom: tinymce toolbar array to merge into standard
|
|
57
|
+
// returns: the merged result by mutating the incoming standard arg.
|
|
58
|
+
// It will add commands to existing toolbars, or add a new toolbar
|
|
59
|
+
// if the custom one does not exist
|
|
60
|
+
export function mergeToolbar(standard, custom) {
|
|
61
|
+
if (!custom) return standard;
|
|
62
|
+
// merge given toolbar data into the default toolbar
|
|
63
|
+
custom.forEach(tb => {
|
|
64
|
+
const curr_tb = standard.find(t => tb.name && formatMessage(tb.name) === t.name);
|
|
65
|
+
if (curr_tb) {
|
|
66
|
+
curr_tb.items.splice(curr_tb.items.length, 0, ...tb.items);
|
|
67
|
+
} else {
|
|
68
|
+
standard.push(tb);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return standard;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// standard: incoming array of plugin names
|
|
75
|
+
// custom: array of plugin names to merge
|
|
76
|
+
// exclusions: array of plugins to remove
|
|
77
|
+
// returns: the merged result, duplicates and exclusions removed
|
|
78
|
+
export function mergePlugins(standard, custom = [], exclusions = []) {
|
|
79
|
+
const union = new Set(standard);
|
|
80
|
+
for (const c of custom) {
|
|
81
|
+
union.add(c);
|
|
82
|
+
}
|
|
83
|
+
for (const e of exclusions) {
|
|
84
|
+
union.delete(e);
|
|
85
|
+
}
|
|
86
|
+
return [...union];
|
|
87
|
+
}
|
|
88
|
+
export function focusToolbar(el) {
|
|
89
|
+
const $firstToolbarButton = el.querySelector('.tox-tbtn');
|
|
90
|
+
if ($firstToolbarButton) {
|
|
91
|
+
$firstToolbarButton.focus();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export function focusFirstMenuButton(el) {
|
|
95
|
+
const $firstMenu = el.querySelector('.tox-mbtn');
|
|
96
|
+
if ($firstMenu) {
|
|
97
|
+
$firstMenu.focus();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export function isElementWithinTable(node) {
|
|
101
|
+
let elem = node;
|
|
102
|
+
while (elem) {
|
|
103
|
+
if (elem.tagName === 'TABLE' || elem.tagName === 'TD' || elem.tagName === 'TH') {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
elem = elem.parentElement;
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// plugins is an array of strings
|
|
112
|
+
// the convention is that plugins starting with '-',
|
|
113
|
+
// i.e. a hyphen, are to be disabled in the RCE instance
|
|
114
|
+
export function parsePluginsToExclude(plugins) {
|
|
115
|
+
return plugins.filter(plugin => plugin.length > 0 && plugin[0] === '-').map(pluginToIgnore => pluginToIgnore.slice(1));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// if a placeholder image shows up in autosaved content, we have to remove it
|
|
119
|
+
// because the data url gets converted to a blob, which is not valid when restored.
|
|
120
|
+
// besides, the placeholder is intended to be temporary while the file
|
|
121
|
+
// is being uploaded
|
|
122
|
+
export function patchAutosavedContent(content, asText = false) {
|
|
123
|
+
const temp = document.createElement('div');
|
|
124
|
+
temp.innerHTML = content;
|
|
125
|
+
temp.querySelectorAll('[data-placeholder-for]').forEach(placeholder => {
|
|
126
|
+
// @ts-expect-error
|
|
127
|
+
placeholder.parentElement.removeChild(placeholder);
|
|
128
|
+
});
|
|
129
|
+
if (asText) return temp.textContent;
|
|
130
|
+
return temp.innerHTML;
|
|
131
|
+
}
|
|
@@ -20,7 +20,6 @@ import PropTypes from 'prop-types';
|
|
|
20
20
|
import { trayPropTypes } from './plugins/shared/CanvasContentTray';
|
|
21
21
|
import { RCEVariantValues } from './RCEVariants';
|
|
22
22
|
import { PRETTY_HTML_EDITOR_VIEW, RAW_HTML_EDITOR_VIEW, WYSIWYG_VIEW } from './StatusBar';
|
|
23
|
-
|
|
24
23
|
// This file contains the prop types for the RCEWrapper component, so that types can be shared without having
|
|
25
24
|
// to refactor RCEWrapper.js into typescript.
|
|
26
25
|
|
|
@@ -67,7 +66,7 @@ export const ltiToolsPropType = PropTypes.arrayOf(PropTypes.shape({
|
|
|
67
66
|
icon_url: PropTypes.string
|
|
68
67
|
}), PropTypes.any])
|
|
69
68
|
}));
|
|
70
|
-
export const
|
|
69
|
+
export const EditorOptionsPropType = PropTypes.shape({
|
|
71
70
|
// height of the RCE.
|
|
72
71
|
// if a number interpreted as pixels.
|
|
73
72
|
// if a string as a CSS value.
|
|
@@ -105,7 +104,7 @@ export const rceWrapperPropTypes = {
|
|
|
105
104
|
}),
|
|
106
105
|
canvasOrigin: PropTypes.string,
|
|
107
106
|
defaultContent: PropTypes.string,
|
|
108
|
-
editorOptions:
|
|
107
|
+
editorOptions: EditorOptionsPropType,
|
|
109
108
|
handleUnmount: PropTypes.func,
|
|
110
109
|
editorView: PropTypes.oneOf([WYSIWYG_VIEW, PRETTY_HTML_EDITOR_VIEW, RAW_HTML_EDITOR_VIEW]),
|
|
111
110
|
renderKBShortcutModal: PropTypes.bool,
|
package/es/rce/RceHtmlEditor.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _pt from "prop-types";
|
|
1
2
|
/*
|
|
2
3
|
* Copyright (C) 2020 - present Instructure, Inc.
|
|
3
4
|
*
|
|
@@ -15,13 +16,12 @@
|
|
|
15
16
|
* You should have received a copy of the GNU Affero General Public License along
|
|
16
17
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
18
|
*/
|
|
18
|
-
import React, {
|
|
19
|
-
import { func, string } from 'prop-types';
|
|
19
|
+
import React, { useEffect, useState } from 'react';
|
|
20
20
|
import formatMessage from '../format-message';
|
|
21
21
|
import { SourceCodeEditor } from '@instructure/ui-source-code-editor';
|
|
22
22
|
import beautify from 'js-beautify';
|
|
23
23
|
const RceHtmlEditor = /*#__PURE__*/React.forwardRef((props, editorRef) => {
|
|
24
|
-
const [
|
|
24
|
+
const [_code, setCode] = useState(props.code);
|
|
25
25
|
const label = formatMessage('html code editor');
|
|
26
26
|
const [dir, setDir] = useState(getComputedStyle(document.body, null).direction);
|
|
27
27
|
useEffect(() => {
|
|
@@ -46,7 +46,9 @@ const RceHtmlEditor = /*#__PURE__*/React.forwardRef((props, editorRef) => {
|
|
|
46
46
|
document.head.appendChild(stylesheet);
|
|
47
47
|
}
|
|
48
48
|
// odds are, this won't change the dir.
|
|
49
|
-
|
|
49
|
+
if (editorRef && 'current' in editorRef) {
|
|
50
|
+
setDir(getComputedStyle(editorRef.current || document.body, null).direction);
|
|
51
|
+
}
|
|
50
52
|
}, [dir, editorRef]);
|
|
51
53
|
const direction = ['ltr', 'rtl'].includes(dir) ? dir : 'ltr';
|
|
52
54
|
|
|
@@ -55,7 +57,7 @@ const RceHtmlEditor = /*#__PURE__*/React.forwardRef((props, editorRef) => {
|
|
|
55
57
|
ref: editorRef,
|
|
56
58
|
className: "RceHtmlEditor",
|
|
57
59
|
style: {
|
|
58
|
-
height: props.height,
|
|
60
|
+
height: props.height || 'auto',
|
|
59
61
|
overflow: 'hidden',
|
|
60
62
|
textAlign: 'start'
|
|
61
63
|
}
|
|
@@ -68,21 +70,20 @@ const RceHtmlEditor = /*#__PURE__*/React.forwardRef((props, editorRef) => {
|
|
|
68
70
|
spellcheck: true,
|
|
69
71
|
direction: direction,
|
|
70
72
|
rtlMoveVisually: true,
|
|
71
|
-
height: props.height,
|
|
73
|
+
height: props.height || 'auto',
|
|
72
74
|
defaultValue: beautify.html(props.code),
|
|
73
75
|
onChange: value => {
|
|
74
76
|
setCode(value);
|
|
75
|
-
props.onChange(value);
|
|
77
|
+
props.onChange?.(value);
|
|
76
78
|
}
|
|
77
79
|
}));
|
|
78
80
|
});
|
|
79
81
|
RceHtmlEditor.propTypes = {
|
|
80
|
-
code: string.isRequired,
|
|
81
|
-
height: string,
|
|
82
|
-
onChange: func
|
|
82
|
+
code: _pt.string.isRequired,
|
|
83
|
+
height: _pt.string,
|
|
84
|
+
onChange: _pt.func
|
|
83
85
|
};
|
|
84
86
|
RceHtmlEditor.defaultProps = {
|
|
85
|
-
height: 'auto',
|
|
86
87
|
onChange: _value => {}
|
|
87
88
|
};
|
|
88
89
|
export default RceHtmlEditor;
|
package/es/rce/ResizeHandle.js
CHANGED
|
@@ -42,9 +42,8 @@ export default function ResizeHandle(props) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
function handleFocus(event) {
|
|
45
|
-
var _props$onFocus;
|
|
46
45
|
setIsFocused(true);
|
|
47
|
-
|
|
46
|
+
props.onFocus?.(event);
|
|
48
47
|
}
|
|
49
48
|
function handleBlur() {
|
|
50
49
|
setIsFocused(false);
|
package/es/rce/StatusBar.js
CHANGED
|
@@ -38,7 +38,7 @@ export const PRETTY_HTML_EDITOR_VIEW = 'PRETTY';
|
|
|
38
38
|
export const RAW_HTML_EDITOR_VIEW = 'RAW';
|
|
39
39
|
|
|
40
40
|
// I don't know why eslint is reporting this, the props are all used
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
StatusBar.propTypes = {
|
|
43
43
|
id: string.isRequired,
|
|
44
44
|
rceIsFullscreen: bool,
|
|
@@ -67,22 +67,17 @@ StatusBar.defaultProps = {
|
|
|
67
67
|
disabledPlugins: []
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
/* eslint-enable react/no-unused-prop-types */
|
|
71
|
-
|
|
72
70
|
// we use the array index because pathname may not be unique
|
|
73
|
-
|
|
74
|
-
function renderPathString(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
} = _ref;
|
|
71
|
+
|
|
72
|
+
function renderPathString({
|
|
73
|
+
path
|
|
74
|
+
}) {
|
|
78
75
|
return path.reduce((result, pathName, index) => {
|
|
79
76
|
return result.concat(/*#__PURE__*/React.createElement("span", {
|
|
80
77
|
key: `${pathName}-${index}`
|
|
81
78
|
}, /*#__PURE__*/React.createElement(Text, null, index > 0 ? /*#__PURE__*/React.createElement(IconMiniArrowEndLine, null) : null, pathName)));
|
|
82
79
|
}, []);
|
|
83
80
|
}
|
|
84
|
-
/* eslint-enable react/no-array-index-key */
|
|
85
|
-
|
|
86
81
|
function emptyTagIcon() {
|
|
87
82
|
return /*#__PURE__*/React.createElement(SVGIcon, {
|
|
88
83
|
viewBox: "0 0 24 24",
|
|
@@ -278,7 +278,6 @@ export function insertAudio(editor, audio, canvasOrigin) {
|
|
|
278
278
|
function insertMedia(editor, media, renderMedia, canvasOrigin) {
|
|
279
279
|
const src = mediaPlayerURLFromFile(media, canvasOrigin);
|
|
280
280
|
if (editor.selection.isCollapsed()) {
|
|
281
|
-
var _result;
|
|
282
281
|
let result = insertContent(editor, renderMedia(media, canvasOrigin));
|
|
283
282
|
// for some reason, editor.selection.getEnd() returned from
|
|
284
283
|
// insertContent is parent paragraph when inserting the
|
|
@@ -290,7 +289,7 @@ function insertMedia(editor, media, renderMedia, canvasOrigin) {
|
|
|
290
289
|
// When the iframe is inserted, it doesn't allow the media to play
|
|
291
290
|
// because the wrapping span captures the click events. Setting
|
|
292
291
|
// contentEditable to false disables this behavior.
|
|
293
|
-
if (
|
|
292
|
+
if (result?.parentElement) {
|
|
294
293
|
editor.dom.setAttrib(result.parentElement, 'contenteditable', false);
|
|
295
294
|
}
|
|
296
295
|
return result;
|
|
@@ -55,8 +55,7 @@ export function renderLinkedImage(linkElem, image, canvasOrigin) {
|
|
|
55
55
|
doNotLink: true
|
|
56
56
|
})));
|
|
57
57
|
}
|
|
58
|
-
export function constructJSXImageElement(image, canvasOrigin) {
|
|
59
|
-
let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
58
|
+
export function constructJSXImageElement(image, canvasOrigin, opts = {}) {
|
|
60
59
|
const {
|
|
61
60
|
href,
|
|
62
61
|
url,
|
|
@@ -80,7 +79,8 @@ export function constructJSXImageElement(image, canvasOrigin) {
|
|
|
80
79
|
alt: altText,
|
|
81
80
|
src: imageSrc,
|
|
82
81
|
width: image.width,
|
|
83
|
-
height: image.height
|
|
82
|
+
height: image.height,
|
|
83
|
+
loading: "lazy"
|
|
84
84
|
}, otherAttributes));
|
|
85
85
|
if (link && !opts.doNotLink) {
|
|
86
86
|
return /*#__PURE__*/React.createElement("a", {
|
|
@@ -103,6 +103,7 @@ export function renderVideo(video, canvasOrigin) {
|
|
|
103
103
|
allowfullscreen
|
|
104
104
|
data-media-id="${getMediaId(video)}"
|
|
105
105
|
data-media-type="video"
|
|
106
|
+
loading="lazy"
|
|
106
107
|
src="${src}"
|
|
107
108
|
style="width:${VIDEO_SIZE_DEFAULT.width};height:${VIDEO_SIZE_DEFAULT.height};display:inline-block;"
|
|
108
109
|
title="${formatMessage('Video player for {title}', {
|
|
@@ -116,6 +117,7 @@ export function renderAudio(audio, canvasOrigin) {
|
|
|
116
117
|
<iframe
|
|
117
118
|
data-media-id="${getMediaId(audio)}"
|
|
118
119
|
data-media-type="audio"
|
|
120
|
+
loading="lazy"
|
|
119
121
|
src="${src}"
|
|
120
122
|
style="width:${AUDIO_PLAYER_SIZE.width};height:${AUDIO_PLAYER_SIZE.height};display:inline-block;"
|
|
121
123
|
title="${formatMessage('Audio player for {title}', {
|
|
@@ -128,11 +130,10 @@ export function getMediaId(media) {
|
|
|
128
130
|
return media.media_id || media.media_entry_id || media.id || media.file_id;
|
|
129
131
|
}
|
|
130
132
|
export function updateImage(editor, img, attrs) {
|
|
131
|
-
var _editor$rceWrapper;
|
|
132
133
|
// Workaround: When passing empty string to editor.dom.setAttribs it removes the attribute
|
|
133
134
|
img.setAttribute('alt', attrs.altText);
|
|
134
135
|
editor.dom.setAttribs(img, {
|
|
135
|
-
src: absoluteToRelativeUrl(attrs.url,
|
|
136
|
+
src: absoluteToRelativeUrl(attrs.url, editor.rceWrapper?.getCanvasUrl()),
|
|
136
137
|
role: attrs.isDecorativeImage ? 'presentation' : null,
|
|
137
138
|
width: attrs.appliedWidth,
|
|
138
139
|
height: attrs.appliedHeight
|
package/es/rce/editorLanguage.js
CHANGED
|
@@ -36,8 +36,7 @@ function box(el) {
|
|
|
36
36
|
// the shape of the target's sillhouette on the editor's container. have to
|
|
37
37
|
// subtract out the iframe's scroll since the target's position is relative to
|
|
38
38
|
// the iframe's _document_, not its visible window.
|
|
39
|
-
export default function indicatorRegion(editor, target) {
|
|
40
|
-
let offsetFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : offset;
|
|
39
|
+
export default function indicatorRegion(editor, target, offsetFn = offset) {
|
|
41
40
|
const iframe = editorIframe(editor);
|
|
42
41
|
const outerShape = offsetFn(iframe);
|
|
43
42
|
const innerShape = box(target);
|
package/es/rce/normalizeProps.js
CHANGED
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import wrapInitCb from './wrapInitCb';
|
|
20
|
-
export default function (props,
|
|
21
|
-
const initialEditorOptions = props.editorOptions(
|
|
22
|
-
const editorOptions = wrapInitCb(props.mirroredAttrs, initialEditorOptions);
|
|
20
|
+
export default function normalizeProps(props, tinyMCE) {
|
|
21
|
+
const initialEditorOptions = props.editorOptions ? props.editorOptions(tinyMCE) : {};
|
|
22
|
+
const editorOptions = wrapInitCb(props.mirroredAttrs || {}, initialEditorOptions);
|
|
23
23
|
return {
|
|
24
24
|
// other props, including overrides
|
|
25
25
|
...props,
|
|
26
26
|
// enforced values, in addition to props and cannot be overridden by
|
|
27
27
|
// props
|
|
28
28
|
editorOptions,
|
|
29
|
-
tinymce
|
|
29
|
+
tinymce: tinyMCE
|
|
30
30
|
};
|
|
31
31
|
}
|
|
@@ -22,7 +22,6 @@ import tinycolor from 'tinycolor2';
|
|
|
22
22
|
import { ColorPopup } from './components/ColorPopup';
|
|
23
23
|
const CONTAINER_ID = 'instructure-color-popup-container';
|
|
24
24
|
export default function (editor) {
|
|
25
|
-
var _container;
|
|
26
25
|
let container = document.getElementById(CONTAINER_ID);
|
|
27
26
|
if (container == null) {
|
|
28
27
|
container = document.createElement('div');
|
|
@@ -31,8 +30,7 @@ export default function (editor) {
|
|
|
31
30
|
}
|
|
32
31
|
const handleDismiss = () => {
|
|
33
32
|
if (container) {
|
|
34
|
-
|
|
35
|
-
(_container$_reactRoot = container._reactRoot) === null || _container$_reactRoot === void 0 ? void 0 : _container$_reactRoot.unmount();
|
|
33
|
+
container._reactRoot?.unmount();
|
|
36
34
|
container._reactRoot = null;
|
|
37
35
|
}
|
|
38
36
|
};
|
|
@@ -50,7 +48,7 @@ export default function (editor) {
|
|
|
50
48
|
handleDismiss();
|
|
51
49
|
});
|
|
52
50
|
};
|
|
53
|
-
if (
|
|
51
|
+
if (container?._reactRoot) {
|
|
54
52
|
handleDismiss();
|
|
55
53
|
document.removeEventListener('rce-text-block-popup-close', handleDismiss);
|
|
56
54
|
return;
|
|
@@ -33,26 +33,24 @@ import { isTransparent, getContrastStatus, getDefaultColors } from './colorUtils
|
|
|
33
33
|
|
|
34
34
|
// A custom type constraint that enforces at least one key is present
|
|
35
35
|
|
|
36
|
-
const ColorPicker =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const [
|
|
45
|
-
const [currBgColor, setCurrBgColor] = useState(isTransparent((_tabs$background = tabs.background) === null || _tabs$background === void 0 ? void 0 : _tabs$background.color) ? tabs.effectiveBgColor || '#ffffff' : (_tabs$background2 = tabs.background) === null || _tabs$background2 === void 0 ? void 0 : _tabs$background2.color);
|
|
46
|
-
const [currBorderColor, setCurrBorderColor] = useState((_tabs$border = tabs.border) === null || _tabs$border === void 0 ? void 0 : _tabs$border.color);
|
|
36
|
+
const ColorPicker = ({
|
|
37
|
+
tabs,
|
|
38
|
+
colorsInUse,
|
|
39
|
+
onCancel,
|
|
40
|
+
onSave
|
|
41
|
+
}) => {
|
|
42
|
+
const [currFgColor, setCurrFgColor] = useState(tabs.foreground?.color);
|
|
43
|
+
const [currBgColor, setCurrBgColor] = useState(isTransparent(tabs.background?.color) ? tabs.effectiveBgColor || '#ffffff' : tabs.background?.color);
|
|
44
|
+
const [currBorderColor, setCurrBorderColor] = useState(tabs.border?.color);
|
|
47
45
|
const [activeTab, setActiveTab] = useState(() => {
|
|
48
46
|
if (tabs.foreground) return 'foreground';
|
|
49
47
|
if (tabs.background) return 'background';
|
|
50
48
|
return 'border';
|
|
51
49
|
});
|
|
52
50
|
const [defaultColors] = useState(getDefaultColors());
|
|
53
|
-
const [customForeground, setCustomForeground] = useState(!!
|
|
54
|
-
const [customBackground, setCustomBackground] = useState(!isTransparent(
|
|
55
|
-
const [customBorder, setCustomBorder] = useState(!isTransparent(
|
|
51
|
+
const [customForeground, setCustomForeground] = useState(!!tabs.foreground?.color && tabs.foreground.color !== tabs.foreground.default);
|
|
52
|
+
const [customBackground, setCustomBackground] = useState(!isTransparent(tabs.background?.color) && tabs.background?.color !== tabs.background?.default);
|
|
53
|
+
const [customBorder, setCustomBorder] = useState(!isTransparent(tabs.border?.color) && tabs.border?.color !== tabs.border?.default);
|
|
56
54
|
const handleFgColorChange = useCallback(newColor => {
|
|
57
55
|
setCurrFgColor(newColor);
|
|
58
56
|
}, []);
|
|
@@ -109,16 +107,15 @@ const ColorPicker = _ref => {
|
|
|
109
107
|
onSave(newcolors);
|
|
110
108
|
}, [currBgColor, currBorderColor, currFgColor, customBackground, customBorder, customForeground, onSave]);
|
|
111
109
|
const getColorPresets = variant => {
|
|
112
|
-
var _tabs$background6, _tabs$foreground3;
|
|
113
110
|
const defaults = defaultColors;
|
|
114
|
-
if (
|
|
111
|
+
if (tabs.background?.default) {
|
|
115
112
|
defaults[0] = tabs.background.default;
|
|
116
113
|
}
|
|
117
|
-
if (
|
|
114
|
+
if (tabs.foreground?.default) {
|
|
118
115
|
defaults[1] = tabs.foreground.default;
|
|
119
116
|
}
|
|
120
117
|
// return only unique colors
|
|
121
|
-
return [...defaults, ...(
|
|
118
|
+
return [...defaults, ...(colorsInUse?.[variant] || [])].filter((c, i, a) => a.indexOf(c) === i && !isTransparent(c));
|
|
122
119
|
};
|
|
123
120
|
const renderColorMixer = (variant, enabled) => {
|
|
124
121
|
let value = currBgColor;
|
|
@@ -169,12 +166,10 @@ const ColorPicker = _ref => {
|
|
|
169
166
|
const getFirstColor = () => {
|
|
170
167
|
let firstColor, firstColorLabel;
|
|
171
168
|
if (activeTab === 'foreground' || activeTab === 'background' && !!tabs.foreground) {
|
|
172
|
-
|
|
173
|
-
firstColor = currFgColor || ((_tabs$foreground4 = tabs.foreground) === null || _tabs$foreground4 === void 0 ? void 0 : _tabs$foreground4.default) || defaultColors[0];
|
|
169
|
+
firstColor = currFgColor || tabs.foreground?.default || defaultColors[0];
|
|
174
170
|
firstColorLabel = formatMessage('Color');
|
|
175
171
|
} else if (activeTab === 'border' || activeTab === 'background' && !!tabs.border) {
|
|
176
|
-
|
|
177
|
-
firstColor = currBorderColor || ((_tabs$border5 = tabs.border) === null || _tabs$border5 === void 0 ? void 0 : _tabs$border5.default) || defaultColors[0];
|
|
172
|
+
firstColor = currBorderColor || tabs.border?.default || defaultColors[0];
|
|
178
173
|
firstColorLabel = formatMessage('Border');
|
|
179
174
|
}
|
|
180
175
|
// @ts-expect-error
|
|
@@ -21,14 +21,13 @@ import React, { useCallback, useState } from 'react';
|
|
|
21
21
|
import { Popover } from '@instructure/ui-popover';
|
|
22
22
|
import { ColorPicker } from './ColorPicker';
|
|
23
23
|
import formatMessage from '../../../../format-message';
|
|
24
|
-
const ColorPopup =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} = _ref;
|
|
24
|
+
const ColorPopup = ({
|
|
25
|
+
tabs,
|
|
26
|
+
open,
|
|
27
|
+
positionTarget,
|
|
28
|
+
onCancel,
|
|
29
|
+
onChange
|
|
30
|
+
}) => {
|
|
32
31
|
const [recreateKey, setRecreateKey] = useState(0);
|
|
33
32
|
const handleHideContent = useCallback(() => {
|
|
34
33
|
onCancel();
|
|
@@ -109,10 +109,7 @@ export default function register(editor) {
|
|
|
109
109
|
icon: listType.icon,
|
|
110
110
|
text: listType.getTooltipText()
|
|
111
111
|
}))),
|
|
112
|
-
onAction: () =>
|
|
113
|
-
var _listStyleInfoForSele;
|
|
114
|
-
return editor.execCommand(((_listStyleInfoForSele = listStyleInfoForSelectionOfEditor(editor)) === null || _listStyleInfoForSele === void 0 ? void 0 : _listStyleInfoForSele.listType) === 'OL' ? 'InsertOrderedList' : 'InsertUnorderedList');
|
|
115
|
-
},
|
|
112
|
+
onAction: () => editor.execCommand(listStyleInfoForSelectionOfEditor(editor)?.listType === 'OL' ? 'InsertOrderedList' : 'InsertUnorderedList'),
|
|
116
113
|
onItemAction: (splitButtonApi, value) => {
|
|
117
114
|
// @ts-expect-error
|
|
118
115
|
const desiredListStyleInfo = listStyleInfos.byKey[value] || defaultStyleInfoForListType.UL;
|
|
@@ -121,7 +118,7 @@ export default function register(editor) {
|
|
|
121
118
|
// When the user clicks the list button that matches the current list style in the selection,
|
|
122
119
|
// we want to interpret that as un-list-ifying the selection
|
|
123
120
|
|
|
124
|
-
if (
|
|
121
|
+
if (currentListStyleInfo?.listStyleType !== desiredListStyleInfo.listStyleType) {
|
|
125
122
|
editor.execCommand(desiredListStyleInfo.listType === 'UL' ? 'InsertUnorderedList' : 'InsertOrderedList', false, {
|
|
126
123
|
'list-style-type': desiredListStyleInfo.listStyleType
|
|
127
124
|
});
|
|
@@ -129,10 +126,7 @@ export default function register(editor) {
|
|
|
129
126
|
editor.execCommand('RemoveList');
|
|
130
127
|
}
|
|
131
128
|
},
|
|
132
|
-
select: value =>
|
|
133
|
-
var _listStyleInfoForSele2;
|
|
134
|
-
return ((_listStyleInfoForSele2 = listStyleInfoForSelectionOfEditor(editor)) === null || _listStyleInfoForSele2 === void 0 ? void 0 : _listStyleInfoForSele2.listStyleType) === value;
|
|
135
|
-
},
|
|
129
|
+
select: value => listStyleInfoForSelectionOfEditor(editor)?.listStyleType === value,
|
|
136
130
|
onSetup: api => {
|
|
137
131
|
// Handle updating the icon on the toolbar based on
|
|
138
132
|
// the type of list the user's selection is currently within
|
|
@@ -142,7 +136,7 @@ export default function register(editor) {
|
|
|
142
136
|
const nodeChangeHandler = () => {
|
|
143
137
|
const activeListType = listStyleInfoForSelectionOfEditor(editor);
|
|
144
138
|
api.setActive(!!activeListType);
|
|
145
|
-
$iconSvgContainer.html(allIcons[
|
|
139
|
+
$iconSvgContainer.html(allIcons[activeListType?.icon || 'list-bull-default']);
|
|
146
140
|
};
|
|
147
141
|
nodeChangeHandler();
|
|
148
142
|
editor.on('NodeChange', nodeChangeHandler);
|
|
@@ -45,7 +45,7 @@ export default function register(editor) {
|
|
|
45
45
|
function nodeChangeHandler() {
|
|
46
46
|
const activeStyleInfo = styleInfos.find(b => editor.formatter.match(b.icon));
|
|
47
47
|
api.setActive(!!activeStyleInfo);
|
|
48
|
-
iconHelper.updateIcon(
|
|
48
|
+
iconHelper.updateIcon(activeStyleInfo?.icon || defaultIcon);
|
|
49
49
|
}
|
|
50
50
|
nodeChangeHandler();
|
|
51
51
|
editor.on('NodeChange', nodeChangeHandler);
|
|
@@ -33,7 +33,6 @@ import { isPreviewable } from '../../shared/Previewable';
|
|
|
33
33
|
import { applyTimezoneOffsetToDate } from '../../shared/dateUtils';
|
|
34
34
|
import RCEGlobals from '../../../RCEGlobals';
|
|
35
35
|
export default function Link(props) {
|
|
36
|
-
var _RCEGlobals$getConfig;
|
|
37
36
|
const [isHovering, setIsHovering] = useState(false);
|
|
38
37
|
const {
|
|
39
38
|
filename,
|
|
@@ -48,7 +47,7 @@ export default function Link(props) {
|
|
|
48
47
|
const Icon = getIconFromType(content_type);
|
|
49
48
|
const color = published ? 'success' : 'primary';
|
|
50
49
|
// Uses user locale and timezone
|
|
51
|
-
const configuredTimezone =
|
|
50
|
+
const configuredTimezone = RCEGlobals.getConfig()?.timezone;
|
|
52
51
|
const dateString = formatMessage.date(applyTimezoneOffsetToDate(date, configuredTimezone), 'long');
|
|
53
52
|
const publishedMsg = published ? formatMessage('published') : formatMessage('unpublished');
|
|
54
53
|
function linkAttrsFromDoc() {
|
|
@@ -30,7 +30,7 @@ import formatMessage from '../../../../format-message';
|
|
|
30
30
|
import MemoizedEquationEditorToolbar from '../EquationEditorToolbar';
|
|
31
31
|
import { containsAdvancedSyntax } from './advancedOnlySyntax';
|
|
32
32
|
import * as advancedPreference from './advancedPreference';
|
|
33
|
-
import {
|
|
33
|
+
import { instuiPopupMountNodeFn } from '../../../../util/fullscreenHelpers';
|
|
34
34
|
import { css } from 'aphrodite';
|
|
35
35
|
import { MathJaxDirective, Mathml } from '../../../../enhance-user-content/mathml';
|
|
36
36
|
import styles from './styles';
|
|
@@ -51,9 +51,8 @@ export default class EquationEditorModal extends Component {
|
|
|
51
51
|
this.advancedEditor = /*#__PURE__*/React.createRef();
|
|
52
52
|
this.executeCommand = (cmd, advancedCmd) => {
|
|
53
53
|
if (this.state.advanced) {
|
|
54
|
-
var _this$advancedEditor$;
|
|
55
54
|
const insertionText = advancedCmd || cmd;
|
|
56
|
-
const textarea =
|
|
55
|
+
const textarea = this.advancedEditor.current?._textarea;
|
|
57
56
|
if (textarea) {
|
|
58
57
|
insertTextIntoLatexTextarea(textarea, insertionText);
|
|
59
58
|
this.setState({
|
|
@@ -151,14 +150,13 @@ export default class EquationEditorModal extends Component {
|
|
|
151
150
|
}));
|
|
152
151
|
};
|
|
153
152
|
this.render = () => {
|
|
154
|
-
var _RCEGlobals$getFeatur;
|
|
155
153
|
const {
|
|
156
154
|
onModalClose
|
|
157
155
|
} = this.props;
|
|
158
156
|
return /*#__PURE__*/React.createElement(Modal, {
|
|
159
157
|
"data-mce-component": true,
|
|
160
158
|
label: formatMessage('Equation Editor'),
|
|
161
|
-
mountNode:
|
|
159
|
+
mountNode: instuiPopupMountNodeFn,
|
|
162
160
|
onClose: onModalClose,
|
|
163
161
|
onDismiss: this.handleModalCancel,
|
|
164
162
|
open: true,
|
|
@@ -220,7 +218,7 @@ export default class EquationEditorModal extends Component {
|
|
|
220
218
|
}, /*#__PURE__*/React.createElement("span", {
|
|
221
219
|
"data-testid": "mathml-preview-element",
|
|
222
220
|
ref: this.previewElement,
|
|
223
|
-
className:
|
|
221
|
+
className: RCEGlobals.getFeatures()?.explicit_latex_typesetting ? MathJaxDirective.Process : null
|
|
224
222
|
})))), /*#__PURE__*/React.createElement(Modal.Footer, null, this.renderFooter()));
|
|
225
223
|
};
|
|
226
224
|
this.mathml = new Mathml(RCEGlobals.getFeatures(), RCEGlobals.getConfig());
|
|
@@ -279,12 +277,11 @@ export default class EquationEditorModal extends Component {
|
|
|
279
277
|
}
|
|
280
278
|
}
|
|
281
279
|
stubMacros() {
|
|
282
|
-
var _this$mathField;
|
|
283
280
|
// Mathlive's macros exist for a different use case;
|
|
284
281
|
// we don't intend for our users to utilize them.
|
|
285
282
|
// This effectively disables all of them to prevent
|
|
286
283
|
// weird behaviors that users don't expect.
|
|
287
|
-
|
|
284
|
+
this.mathField?.setOptions({
|
|
288
285
|
macros: {}
|
|
289
286
|
});
|
|
290
287
|
}
|