@bigbinary/neeto-editor-frontend 0.0.0-stage → 2.0.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.
- package/LICENSE.md +21 -0
- package/README.md +145 -2
- package/app/javascript/src/translations/ar.json +209 -0
- package/app/javascript/src/translations/bg.json +209 -0
- package/app/javascript/src/translations/ca.json +209 -0
- package/app/javascript/src/translations/cs.json +209 -0
- package/app/javascript/src/translations/da.json +209 -0
- package/app/javascript/src/translations/de.json +209 -0
- package/app/javascript/src/translations/en.json +208 -0
- package/app/javascript/src/translations/es-MX.json +209 -0
- package/app/javascript/src/translations/es.json +209 -0
- package/app/javascript/src/translations/et.json +209 -0
- package/app/javascript/src/translations/fi.json +209 -0
- package/app/javascript/src/translations/fil.json +209 -0
- package/app/javascript/src/translations/fr.json +209 -0
- package/app/javascript/src/translations/he.json +209 -0
- package/app/javascript/src/translations/hi.json +209 -0
- package/app/javascript/src/translations/hr.json +209 -0
- package/app/javascript/src/translations/hu.json +209 -0
- package/app/javascript/src/translations/id.json +209 -0
- package/app/javascript/src/translations/index.js +1 -0
- package/app/javascript/src/translations/it.json +209 -0
- package/app/javascript/src/translations/ja.json +209 -0
- package/app/javascript/src/translations/ko.json +209 -0
- package/app/javascript/src/translations/lv.json +208 -0
- package/app/javascript/src/translations/nl.json +209 -0
- package/app/javascript/src/translations/pl.json +209 -0
- package/app/javascript/src/translations/pt-BR.json +209 -0
- package/app/javascript/src/translations/pt.json +209 -0
- package/app/javascript/src/translations/ro.json +209 -0
- package/app/javascript/src/translations/ru.json +209 -0
- package/app/javascript/src/translations/sk.json +209 -0
- package/app/javascript/src/translations/sl.json +209 -0
- package/app/javascript/src/translations/sv.json +209 -0
- package/app/javascript/src/translations/th.json +209 -0
- package/app/javascript/src/translations/tr.json +209 -0
- package/app/javascript/src/translations/uk.json +209 -0
- package/app/javascript/src/translations/vi.json +209 -0
- package/app/javascript/src/translations/zh-CN.json +209 -0
- package/app/javascript/src/translations/zh-TW.json +209 -0
- package/dist/.ready +1 -0
- package/dist/Attachments.js +53 -0
- package/dist/Attachments.js.map +1 -0
- package/dist/Editor.js +5532 -0
- package/dist/Editor.js.map +1 -0
- package/dist/EditorContent.js +252 -0
- package/dist/EditorContent.js.map +1 -0
- package/dist/FormikEditor.js +202 -0
- package/dist/FormikEditor.js.map +1 -0
- package/dist/Menu.js +107 -0
- package/dist/Menu.js.map +1 -0
- package/dist/chunk-1NlIGj6C.js +378 -0
- package/dist/chunk-1NlIGj6C.js.map +1 -0
- package/dist/chunk-BFKmIsWV.js +8660 -0
- package/dist/chunk-BFKmIsWV.js.map +1 -0
- package/dist/chunk-BFTU3MAI.js +8 -0
- package/dist/chunk-BFTU3MAI.js.map +1 -0
- package/dist/chunk-Ba4Q3HC8.js +15258 -0
- package/dist/chunk-Ba4Q3HC8.js.map +1 -0
- package/dist/chunk-Bra5VPWO.js +555 -0
- package/dist/chunk-Bra5VPWO.js.map +1 -0
- package/dist/chunk-C2dztUxs.js +4 -0
- package/dist/chunk-C2dztUxs.js.map +1 -0
- package/dist/chunk-CK_Ss-J5.js +425 -0
- package/dist/chunk-CK_Ss-J5.js.map +1 -0
- package/dist/chunk-CO-Yfs5R.js +206 -0
- package/dist/chunk-CO-Yfs5R.js.map +1 -0
- package/dist/chunk-CX-0IHKE.js +381 -0
- package/dist/chunk-CX-0IHKE.js.map +1 -0
- package/dist/chunk-CeoqieEt.js +25570 -0
- package/dist/chunk-CeoqieEt.js.map +1 -0
- package/dist/chunk-D52F37yF.js +19 -0
- package/dist/chunk-D52F37yF.js.map +1 -0
- package/dist/chunk-DcFvJOrc.js +3368 -0
- package/dist/chunk-DcFvJOrc.js.map +1 -0
- package/dist/chunk-DgZGzqPs.js +6804 -0
- package/dist/chunk-DgZGzqPs.js.map +1 -0
- package/dist/chunk-Di3ipdfT.js +20227 -0
- package/dist/chunk-Di3ipdfT.js.map +1 -0
- package/dist/chunk-DrHVV_g1.js +89 -0
- package/dist/chunk-DrHVV_g1.js.map +1 -0
- package/dist/chunk-DsAUS6bL.js +3464 -0
- package/dist/chunk-DsAUS6bL.js.map +1 -0
- package/dist/chunk-PSGRE5nX.js +97 -0
- package/dist/chunk-PSGRE5nX.js.map +1 -0
- package/dist/chunk-Qg4uQqj3.js +16238 -0
- package/dist/chunk-Qg4uQqj3.js.map +1 -0
- package/dist/chunk-aCTMceVU.js +135 -0
- package/dist/chunk-aCTMceVU.js.map +1 -0
- package/dist/chunk-fDmcpgqx.js +12510 -0
- package/dist/chunk-fDmcpgqx.js.map +1 -0
- package/dist/chunk-mFZL53CS.js +204 -0
- package/dist/chunk-mFZL53CS.js.map +1 -0
- package/dist/chunk-y5pmJStT.js +573 -0
- package/dist/chunk-y5pmJStT.js.map +1 -0
- package/dist/cjs/Attachments.cjs.js +59 -0
- package/dist/cjs/Attachments.cjs.js.map +1 -0
- package/dist/cjs/Editor.cjs.js +5611 -0
- package/dist/cjs/Editor.cjs.js.map +1 -0
- package/dist/cjs/EditorContent.cjs.js +266 -0
- package/dist/cjs/EditorContent.cjs.js.map +1 -0
- package/dist/cjs/FormikEditor.cjs.js +209 -0
- package/dist/cjs/FormikEditor.cjs.js.map +1 -0
- package/dist/cjs/Menu.cjs.js +113 -0
- package/dist/cjs/Menu.cjs.js.map +1 -0
- package/dist/cjs/chunk-B2NfgecV.cjs.js +599 -0
- package/dist/cjs/chunk-B2NfgecV.cjs.js.map +1 -0
- package/dist/cjs/chunk-B6qYtOJe.cjs.js +6 -0
- package/dist/cjs/chunk-B6qYtOJe.cjs.js.map +1 -0
- package/dist/cjs/chunk-BJu3ubxk.cjs.js +11 -0
- package/dist/cjs/chunk-BJu3ubxk.cjs.js.map +1 -0
- package/dist/cjs/chunk-BKvkHB8E.cjs.js +16259 -0
- package/dist/cjs/chunk-BKvkHB8E.cjs.js.map +1 -0
- package/dist/cjs/chunk-BlWQNLLE.cjs.js +3450 -0
- package/dist/cjs/chunk-BlWQNLLE.cjs.js.map +1 -0
- package/dist/cjs/chunk-Bmjmsp-E.cjs.js +97 -0
- package/dist/cjs/chunk-Bmjmsp-E.cjs.js.map +1 -0
- package/dist/cjs/chunk-C-VxABfm.cjs.js +25578 -0
- package/dist/cjs/chunk-C-VxABfm.cjs.js.map +1 -0
- package/dist/cjs/chunk-C8X4oFtP.cjs.js +216 -0
- package/dist/cjs/chunk-C8X4oFtP.cjs.js.map +1 -0
- package/dist/cjs/chunk-CCCSexAh.cjs.js +206 -0
- package/dist/cjs/chunk-CCCSexAh.cjs.js.map +1 -0
- package/dist/cjs/chunk-CNIzgxEP.cjs.js +49 -0
- package/dist/cjs/chunk-CNIzgxEP.cjs.js.map +1 -0
- package/dist/cjs/chunk-CesnwG-V.cjs.js +140 -0
- package/dist/cjs/chunk-CesnwG-V.cjs.js.map +1 -0
- package/dist/cjs/chunk-CohcWDmm.cjs.js +20318 -0
- package/dist/cjs/chunk-CohcWDmm.cjs.js.map +1 -0
- package/dist/cjs/chunk-Crp27WMe.cjs.js +6833 -0
- package/dist/cjs/chunk-Crp27WMe.cjs.js.map +1 -0
- package/dist/cjs/chunk-D3Unocnm.cjs.js +8681 -0
- package/dist/cjs/chunk-D3Unocnm.cjs.js.map +1 -0
- package/dist/cjs/chunk-D6ygkQBu.cjs.js +421 -0
- package/dist/cjs/chunk-D6ygkQBu.cjs.js.map +1 -0
- package/dist/cjs/chunk-D7p10rIr.cjs.js +112 -0
- package/dist/cjs/chunk-D7p10rIr.cjs.js.map +1 -0
- package/dist/cjs/chunk-DM1lUvXy.cjs.js +3525 -0
- package/dist/cjs/chunk-DM1lUvXy.cjs.js.map +1 -0
- package/dist/cjs/chunk-DWyvxp1a.cjs.js +394 -0
- package/dist/cjs/chunk-DWyvxp1a.cjs.js.map +1 -0
- package/dist/cjs/chunk-DXsX8co9.cjs.js +12512 -0
- package/dist/cjs/chunk-DXsX8co9.cjs.js.map +1 -0
- package/dist/cjs/chunk-DxXc6tiG.cjs.js +15326 -0
- package/dist/cjs/chunk-DxXc6tiG.cjs.js.map +1 -0
- package/dist/cjs/chunk-MxWVMW6e.cjs.js +569 -0
- package/dist/cjs/chunk-MxWVMW6e.cjs.js.map +1 -0
- package/dist/cjs/chunk-cwORbcv3.cjs.js +479 -0
- package/dist/cjs/chunk-cwORbcv3.cjs.js.map +1 -0
- package/dist/cjs/constants.cjs.js +13 -0
- package/dist/cjs/constants.cjs.js.map +1 -0
- package/dist/cjs/index.cjs.js +163 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/utils.cjs.js +29 -0
- package/dist/cjs/utils.cjs.js.map +1 -0
- package/dist/cjs/v2/Attachments.cjs.js +49 -0
- package/dist/cjs/v2/Attachments.cjs.js.map +1 -0
- package/dist/cjs/v2/Editor.cjs.js +5741 -0
- package/dist/cjs/v2/Editor.cjs.js.map +1 -0
- package/dist/cjs/v2/EditorContent.cjs.js +33 -0
- package/dist/cjs/v2/EditorContent.cjs.js.map +1 -0
- package/dist/cjs/v2/FormikEditor.cjs.js +164 -0
- package/dist/cjs/v2/FormikEditor.cjs.js.map +1 -0
- package/dist/cjs/v2/Menu.cjs.js +62 -0
- package/dist/cjs/v2/Menu.cjs.js.map +1 -0
- package/dist/cjs/v2/constants.cjs.js +13 -0
- package/dist/cjs/v2/constants.cjs.js.map +1 -0
- package/dist/cjs/v2/index.cjs.js +120 -0
- package/dist/cjs/v2/index.cjs.js.map +1 -0
- package/dist/cjs/v2/utils.cjs.js +29 -0
- package/dist/cjs/v2/utils.cjs.js.map +1 -0
- package/dist/codeblockHighlight.js +15155 -0
- package/dist/codeblockHighlight.js.map +1 -0
- package/dist/constants.js +6 -0
- package/dist/constants.js.map +1 -0
- package/dist/editor-content.min.css +1 -0
- package/dist/editor-output-pdf-email.css +1 -0
- package/dist/editor-output-pdf-email.js +4 -0
- package/dist/editor-output-pdf-email.js.map +1 -0
- package/dist/editor-output.js +4 -0
- package/dist/editor-output.js.map +1 -0
- package/dist/editor-stats.html +4842 -0
- package/dist/editorUtils.js +170 -0
- package/dist/headerLinks.js +59 -0
- package/dist/headerLinks.js.map +1 -0
- package/dist/index.js +146 -0
- package/dist/index.js.map +1 -0
- package/dist/utils.js +17 -0
- package/dist/utils.js.map +1 -0
- package/dist/v2/Attachments.js +43 -0
- package/dist/v2/Attachments.js.map +1 -0
- package/dist/v2/Editor.js +5692 -0
- package/dist/v2/Editor.js.map +1 -0
- package/dist/v2/EditorContent.js +27 -0
- package/dist/v2/EditorContent.js.map +1 -0
- package/dist/v2/FormikEditor.js +157 -0
- package/dist/v2/FormikEditor.js.map +1 -0
- package/dist/v2/Menu.js +56 -0
- package/dist/v2/Menu.js.map +1 -0
- package/dist/v2/constants.js +6 -0
- package/dist/v2/constants.js.map +1 -0
- package/dist/v2/editor-content-styles.js +4 -0
- package/dist/v2/editor-content-styles.js.map +1 -0
- package/dist/v2/editor-content.min.css +1 -0
- package/dist/v2/index.js +101 -0
- package/dist/v2/index.js.map +1 -0
- package/dist/v2/styles.css +1 -0
- package/dist/v2/styles.js +4 -0
- package/dist/v2/styles.js.map +1 -0
- package/dist/v2/utils.js +17 -0
- package/dist/v2/utils.js.map +1 -0
- package/formik.d.ts +9 -0
- package/package.json +322 -4
- package/types.d.ts +199 -0
|
@@ -0,0 +1,3368 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
3
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
+
import React__default, { memo, createElement, useRef, useState, useEffect, useCallback, useMemo } from 'react';
|
|
5
|
+
import { prop, fromPairs, assoc, not, isEmpty, last } from 'ramda';
|
|
6
|
+
import { n } from './chunk-C2dztUxs.js';
|
|
7
|
+
import i18n, { t as t$1 } from 'i18next';
|
|
8
|
+
import TextH1 from '@bigbinary/neeto-icons/TextH1';
|
|
9
|
+
import TextH2 from '@bigbinary/neeto-icons/TextH2';
|
|
10
|
+
import TextH3 from '@bigbinary/neeto-icons/TextH3';
|
|
11
|
+
import TextH4 from '@bigbinary/neeto-icons/TextH4';
|
|
12
|
+
import TextH5 from '@bigbinary/neeto-icons/TextH5';
|
|
13
|
+
import TextP from '@bigbinary/neeto-icons/TextP';
|
|
14
|
+
import { e as emojiPickerApi, u as useEditorStore, g as generateFocusProps, B as BubbleMenu } from './chunk-Di3ipdfT.js';
|
|
15
|
+
import classnames from 'classnames';
|
|
16
|
+
import { findBy, hyphenate, isNotPresent, noop, isNotEmpty, filterBy } from '@bigbinary/neeto-cist';
|
|
17
|
+
import { b as URL_VALIDATORS, A as ALL_PROTOCOL_URL_REGEXP, E as EDITOR_OPTIONS } from './chunk-DrHVV_g1.js';
|
|
18
|
+
import Link from '@bigbinary/neeto-icons/Link';
|
|
19
|
+
import Column from '@bigbinary/neeto-icons/Column';
|
|
20
|
+
import Down from '@bigbinary/neeto-icons/Down';
|
|
21
|
+
import Dropdown$1 from '@bigbinary/neetoui/Dropdown';
|
|
22
|
+
import { useTranslation } from 'react-i18next';
|
|
23
|
+
import Close from '@bigbinary/neeto-icons/Close';
|
|
24
|
+
import Button$1 from '@bigbinary/neetoui/Button';
|
|
25
|
+
import { v as validateAndFormatUrl } from './chunk-PSGRE5nX.js';
|
|
26
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
27
|
+
import { withEventTargetValue, hyphenize } from '@bigbinary/neeto-commons-frontend/utils';
|
|
28
|
+
import Check from '@bigbinary/neeto-icons/Check';
|
|
29
|
+
import Label from '@bigbinary/neetoui/Label';
|
|
30
|
+
import Quote from '@bigbinary/neeto-icons/Quote';
|
|
31
|
+
import Attachment from '@bigbinary/neeto-icons/Attachment';
|
|
32
|
+
import CodeBlock from '@bigbinary/neeto-icons/CodeBlock';
|
|
33
|
+
import Code from '@bigbinary/neeto-icons/Code';
|
|
34
|
+
import Highlight from '@bigbinary/neeto-icons/Highlight';
|
|
35
|
+
import TextBold from '@bigbinary/neeto-icons/TextBold';
|
|
36
|
+
import TextCross from '@bigbinary/neeto-icons/TextCross';
|
|
37
|
+
import TextItalic from '@bigbinary/neeto-icons/TextItalic';
|
|
38
|
+
import Underline from '@bigbinary/neeto-icons/Underline';
|
|
39
|
+
import ListDot from '@bigbinary/neeto-icons/ListDot';
|
|
40
|
+
import ListNumber from '@bigbinary/neeto-icons/ListNumber';
|
|
41
|
+
import ImageUpload from '@bigbinary/neeto-icons/ImageUpload';
|
|
42
|
+
import Video from '@bigbinary/neeto-icons/Video';
|
|
43
|
+
import Undo from '@bigbinary/neeto-icons/Undo';
|
|
44
|
+
import Redo from '@bigbinary/neeto-icons/Redo';
|
|
45
|
+
import Email from '@bigbinary/neeto-icons/Email';
|
|
46
|
+
import Avatar from '@bigbinary/neetoui/Avatar';
|
|
47
|
+
import Typography from '@bigbinary/neetoui/Typography';
|
|
48
|
+
import Smiley from '@bigbinary/neeto-icons/Smiley';
|
|
49
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
50
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
51
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
52
|
+
import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
|
|
53
|
+
import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
|
|
54
|
+
import _inherits from '@babel/runtime/helpers/inherits';
|
|
55
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
56
|
+
import { Picker } from 'emoji-mart';
|
|
57
|
+
import { useOnClickOutside, withT } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
58
|
+
import Customize from '@bigbinary/neeto-icons/Customize';
|
|
59
|
+
import Refresh from '@bigbinary/neeto-icons/Refresh';
|
|
60
|
+
import Input from '@bigbinary/neetoui/Input';
|
|
61
|
+
import { HexColorPicker } from 'react-colorful';
|
|
62
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
63
|
+
import ImageUploader from '@bigbinary/neeto-image-uploader-frontend/ImageUploader';
|
|
64
|
+
import Modal from '@bigbinary/neetoui/Modal';
|
|
65
|
+
import Tab from '@bigbinary/neetoui/Tab';
|
|
66
|
+
import Toastr from '@bigbinary/neetoui/Toastr';
|
|
67
|
+
import { u as useDropFiles, d as directUploadsApi } from './chunk-BFKmIsWV.js';
|
|
68
|
+
import { F as File, u as useFileUploader, A as ALLOWED_IMAGE_TYPES, a as ALLOWED_VIDEO_TYPES, c as convertToFileSize, D as DEFAULT_IMAGE_UPLOAD_CONFIG, b as DEFAULT_VIDEO_UPLOAD_CONFIG, V as VIDEO_EMBED_FORM_VALIDATION_SCHEMA, g as getTabs } from './chunk-CK_Ss-J5.js';
|
|
69
|
+
import Tooltip from '@bigbinary/neetoui/Tooltip';
|
|
70
|
+
import Form from '@bigbinary/neetoui/formik/Form';
|
|
71
|
+
import Input$1 from '@bigbinary/neetoui/formik/Input';
|
|
72
|
+
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
|
|
73
|
+
import Checkbox from '@bigbinary/neetoui/Checkbox';
|
|
74
|
+
import { createPortal } from 'react-dom';
|
|
75
|
+
import Checkbox$1 from '@bigbinary/neeto-icons/Checkbox';
|
|
76
|
+
import File$1 from '@bigbinary/neeto-icons/File';
|
|
77
|
+
import { shallow } from 'zustand/shallow';
|
|
78
|
+
import Flag from '@bigbinary/neeto-icons/Flag';
|
|
79
|
+
import Info from '@bigbinary/neeto-icons/misc/Info';
|
|
80
|
+
import Warning from '@bigbinary/neeto-icons/misc/Warning';
|
|
81
|
+
import Danger from '@bigbinary/neeto-icons/misc/Danger';
|
|
82
|
+
import Megaphone from '@bigbinary/neeto-icons/misc/Megaphone';
|
|
83
|
+
import Success from '@bigbinary/neeto-icons/misc/Success';
|
|
84
|
+
import MenuHorizontal from '@bigbinary/neeto-icons/MenuHorizontal';
|
|
85
|
+
import DynamicVariables from '@bigbinary/neeto-molecules/DynamicVariables';
|
|
86
|
+
import Tippy from '@tippyjs/react';
|
|
87
|
+
import { D as DEFAULT_EDITOR_OPTIONS } from './chunk-D52F37yF.js';
|
|
88
|
+
|
|
89
|
+
var CALLOUT_TYPES = [{
|
|
90
|
+
type: "default",
|
|
91
|
+
label: t$1("neetoEditor.menu.calloutDefault"),
|
|
92
|
+
icon: Megaphone,
|
|
93
|
+
bgColor: "--neeto-editor-gray-100"
|
|
94
|
+
}, {
|
|
95
|
+
type: "info",
|
|
96
|
+
label: t$1("neetoEditor.menu.calloutInfo"),
|
|
97
|
+
icon: Info,
|
|
98
|
+
bgColor: "--neeto-editor-info-100"
|
|
99
|
+
}, {
|
|
100
|
+
type: "warning",
|
|
101
|
+
label: t$1("neetoEditor.menu.calloutWarning"),
|
|
102
|
+
icon: Warning,
|
|
103
|
+
bgColor: "--neeto-editor-warning-100"
|
|
104
|
+
}, {
|
|
105
|
+
type: "error",
|
|
106
|
+
label: t$1("neetoEditor.menu.calloutError"),
|
|
107
|
+
icon: Danger,
|
|
108
|
+
bgColor: "--neeto-editor-error-100"
|
|
109
|
+
}, {
|
|
110
|
+
type: "success",
|
|
111
|
+
label: t$1("neetoEditor.menu.calloutSuccess"),
|
|
112
|
+
icon: Success,
|
|
113
|
+
bgColor: "--neeto-editor-success-100"
|
|
114
|
+
}];
|
|
115
|
+
|
|
116
|
+
function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
117
|
+
function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
118
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
119
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
120
|
+
var EmojiPickerMenu = /*#__PURE__*/function (_React$Component) {
|
|
121
|
+
function EmojiPickerMenu() {
|
|
122
|
+
var _this;
|
|
123
|
+
_classCallCheck(this, EmojiPickerMenu);
|
|
124
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
125
|
+
args[_key] = arguments[_key];
|
|
126
|
+
}
|
|
127
|
+
_this = _callSuper(this, EmojiPickerMenu, [].concat(args));
|
|
128
|
+
_defineProperty(_this, "ref", /*#__PURE__*/React__default.createRef());
|
|
129
|
+
_defineProperty(_this, "fetchEmojiData", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
130
|
+
var _yield$emojiPickerApi, data;
|
|
131
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
132
|
+
while (1) switch (_context.prev = _context.next) {
|
|
133
|
+
case 0:
|
|
134
|
+
_context.prev = 0;
|
|
135
|
+
_context.next = 3;
|
|
136
|
+
return emojiPickerApi.fetch();
|
|
137
|
+
case 3:
|
|
138
|
+
_yield$emojiPickerApi = _context.sent;
|
|
139
|
+
data = _yield$emojiPickerApi.data;
|
|
140
|
+
return _context.abrupt("return", data);
|
|
141
|
+
case 8:
|
|
142
|
+
_context.prev = 8;
|
|
143
|
+
_context.t0 = _context["catch"](0);
|
|
144
|
+
return _context.abrupt("return", {});
|
|
145
|
+
case 11:
|
|
146
|
+
case "end":
|
|
147
|
+
return _context.stop();
|
|
148
|
+
}
|
|
149
|
+
}, _callee, null, [[0, 8]]);
|
|
150
|
+
})));
|
|
151
|
+
_defineProperty(_this, "onKeyDown", function (_ref2) {
|
|
152
|
+
var event = _ref2.event;
|
|
153
|
+
if (event.key === "Escape") {
|
|
154
|
+
_this.props.editor.chain().focus().deleteRange(_this.props.range).run();
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
});
|
|
159
|
+
_defineProperty(_this, "handleSelect", function (emoji) {
|
|
160
|
+
var _this$props$setActive, _this$props;
|
|
161
|
+
_this.props.editor.chain().focus().deleteRange(_this.props.range).setEmoji(emoji).run();
|
|
162
|
+
(_this$props$setActive = (_this$props = _this.props).setActive) === null || _this$props$setActive === void 0 || _this$props$setActive.call(_this$props, false);
|
|
163
|
+
});
|
|
164
|
+
return _this;
|
|
165
|
+
}
|
|
166
|
+
_inherits(EmojiPickerMenu, _React$Component);
|
|
167
|
+
return _createClass(EmojiPickerMenu, [{
|
|
168
|
+
key: "componentDidMount",
|
|
169
|
+
value: function componentDidMount() {
|
|
170
|
+
new Picker(_objectSpread$b(_objectSpread$b({}, this.props), {}, {
|
|
171
|
+
onEmojiSelect: this.handleSelect,
|
|
172
|
+
style: {
|
|
173
|
+
maxWidth: "100%"
|
|
174
|
+
},
|
|
175
|
+
theme: "light",
|
|
176
|
+
"native": true,
|
|
177
|
+
previewPosition: "none",
|
|
178
|
+
showSkinTones: false,
|
|
179
|
+
data: this.fetchEmojiData,
|
|
180
|
+
ref: this.ref
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
}, {
|
|
184
|
+
key: "render",
|
|
185
|
+
value: function render() {
|
|
186
|
+
return /*#__PURE__*/jsx("div", {
|
|
187
|
+
"data-testid": "neeto-editor-emoji-picker",
|
|
188
|
+
ref: this.ref,
|
|
189
|
+
style: {
|
|
190
|
+
minWidth: "350px"
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}]);
|
|
195
|
+
}(React__default.Component);
|
|
196
|
+
EmojiPickerMenu.defaultProps = {
|
|
197
|
+
editor: {},
|
|
198
|
+
range: {}
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
var validateUrl = function validateUrl(url) {
|
|
202
|
+
if (!url) return false;
|
|
203
|
+
for (var _i = 0, _Object$values = Object.values(URL_VALIDATORS); _i < _Object$values.length; _i++) {
|
|
204
|
+
var validator = _Object$values[_i];
|
|
205
|
+
var result = validator(url);
|
|
206
|
+
if (result) return result;
|
|
207
|
+
}
|
|
208
|
+
return false;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
212
|
+
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
213
|
+
var MenuButton = function MenuButton(_ref) {
|
|
214
|
+
var icon = _ref.icon,
|
|
215
|
+
command = _ref.command,
|
|
216
|
+
optionName = _ref.optionName,
|
|
217
|
+
highlight = _ref.highlight,
|
|
218
|
+
_ref$disabled = _ref.disabled,
|
|
219
|
+
isButtonDisabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
220
|
+
label = _ref.label;
|
|
221
|
+
var _useEditorStore = useEditorStore(function (store) {
|
|
222
|
+
var _store$marksState, _store$marksState2;
|
|
223
|
+
return {
|
|
224
|
+
isActive: (_store$marksState = store["marksState"]) === null || _store$marksState === void 0 || (_store$marksState = _store$marksState[optionName]) === null || _store$marksState === void 0 ? void 0 : _store$marksState["isActive"],
|
|
225
|
+
disabled: (_store$marksState2 = store["marksState"]) === null || _store$marksState2 === void 0 || (_store$marksState2 = _store$marksState2[optionName]) === null || _store$marksState2 === void 0 ? void 0 : _store$marksState2["disabled"]
|
|
226
|
+
};
|
|
227
|
+
}, shallow),
|
|
228
|
+
isActive = _useEditorStore.isActive,
|
|
229
|
+
_useEditorStore$disab = _useEditorStore.disabled,
|
|
230
|
+
disabled = _useEditorStore$disab === void 0 ? isButtonDisabled : _useEditorStore$disab;
|
|
231
|
+
return /*#__PURE__*/jsx(Button$1, _objectSpread$a({
|
|
232
|
+
disabled: disabled,
|
|
233
|
+
icon: icon,
|
|
234
|
+
className: "neeto-editor-fixed-menu__item",
|
|
235
|
+
"data-testid": "neeto-editor-fixed-menu-".concat(optionName, "-option"),
|
|
236
|
+
style: isActive ? "secondary" : "text",
|
|
237
|
+
tabIndex: "-1",
|
|
238
|
+
tooltipProps: {
|
|
239
|
+
content: renderTooltipContent(label, optionName),
|
|
240
|
+
position: "bottom"
|
|
241
|
+
},
|
|
242
|
+
onClick: command
|
|
243
|
+
}, generateFocusProps(highlight)));
|
|
244
|
+
};
|
|
245
|
+
var MenuButton$1 = /*#__PURE__*/memo(MenuButton);
|
|
246
|
+
|
|
247
|
+
var CalloutIcon = function CalloutIcon(_ref) {
|
|
248
|
+
var currentType = _ref.currentType;
|
|
249
|
+
if (currentType !== null && currentType !== void 0 && currentType.icon) {
|
|
250
|
+
var Icon = currentType.icon;
|
|
251
|
+
return /*#__PURE__*/jsx("span", {
|
|
252
|
+
className: "neeto-editor-callout-dropdown__current-emoji",
|
|
253
|
+
children: /*#__PURE__*/jsx(Icon, {
|
|
254
|
+
size: 22
|
|
255
|
+
})
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
return /*#__PURE__*/jsx(Flag, {
|
|
259
|
+
size: 16
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
var CalloutTypeOption = function CalloutTypeOption(_ref) {
|
|
264
|
+
var calloutType = _ref.calloutType,
|
|
265
|
+
isSelected = _ref.isSelected,
|
|
266
|
+
onClick = _ref.onClick;
|
|
267
|
+
var optionClass = classnames("neeto-editor-callout-dropdown__type-option", {
|
|
268
|
+
"neeto-editor-callout-dropdown__type-option--selected": isSelected
|
|
269
|
+
});
|
|
270
|
+
var Icon = calloutType.icon;
|
|
271
|
+
return /*#__PURE__*/jsxs("div", {
|
|
272
|
+
onClick: onClick,
|
|
273
|
+
className: optionClass,
|
|
274
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
275
|
+
className: "neeto-editor-callout-dropdown__type-emoji",
|
|
276
|
+
"data-testid": "callout-type-emoji",
|
|
277
|
+
children: /*#__PURE__*/jsx(Icon, {})
|
|
278
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
279
|
+
className: "neeto-editor-callout-dropdown__type-label",
|
|
280
|
+
style: "body2",
|
|
281
|
+
weight: "medium",
|
|
282
|
+
children: calloutType.label
|
|
283
|
+
})]
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
var RenderCalloutOptions = function RenderCalloutOptions(_ref) {
|
|
288
|
+
var isInCallout = _ref.isInCallout,
|
|
289
|
+
currentCalloutAttrs = _ref.currentCalloutAttrs,
|
|
290
|
+
handleCalloutTypeClick = _ref.handleCalloutTypeClick;
|
|
291
|
+
return CALLOUT_TYPES.map(function (calloutType, idx) {
|
|
292
|
+
return /*#__PURE__*/createElement(CalloutTypeOption, {
|
|
293
|
+
calloutType: calloutType,
|
|
294
|
+
isSelected: isInCallout && (currentCalloutAttrs === null || currentCalloutAttrs === void 0 ? void 0 : currentCalloutAttrs.type) === calloutType.type,
|
|
295
|
+
key: idx,
|
|
296
|
+
onClick: function onClick() {
|
|
297
|
+
return handleCalloutTypeClick(calloutType);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
var CalloutDropdown = function CalloutDropdown(_ref) {
|
|
304
|
+
var editor = _ref.editor,
|
|
305
|
+
label = _ref.label,
|
|
306
|
+
tooltipContent = _ref.tooltipContent;
|
|
307
|
+
var _useTranslation = useTranslation(),
|
|
308
|
+
t = _useTranslation.t;
|
|
309
|
+
var dropdownRef = useRef(null);
|
|
310
|
+
var isInCallout = editor.isActive("callout");
|
|
311
|
+
var currentCalloutAttrs = isInCallout ? editor.getAttributes("callout") : null;
|
|
312
|
+
var currentType = findBy({
|
|
313
|
+
type: currentCalloutAttrs === null || currentCalloutAttrs === void 0 ? void 0 : currentCalloutAttrs.type
|
|
314
|
+
}, CALLOUT_TYPES) || CALLOUT_TYPES[0];
|
|
315
|
+
var handleCalloutTypeClick = function handleCalloutTypeClick(calloutType) {
|
|
316
|
+
var editorChain = editor.chain().focus();
|
|
317
|
+
var isSameType = isInCallout && (currentCalloutAttrs === null || currentCalloutAttrs === void 0 ? void 0 : currentCalloutAttrs.type) === calloutType.type;
|
|
318
|
+
if (isSameType) {
|
|
319
|
+
editorChain.lift("callout").run();
|
|
320
|
+
} else if (isInCallout) {
|
|
321
|
+
editorChain.updateAttributes("callout", {
|
|
322
|
+
type: calloutType.type,
|
|
323
|
+
emoji: calloutType.emoji
|
|
324
|
+
}).run();
|
|
325
|
+
} else {
|
|
326
|
+
editorChain.setCallout({
|
|
327
|
+
type: calloutType.type,
|
|
328
|
+
emoji: calloutType.emoji
|
|
329
|
+
}).run();
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
return /*#__PURE__*/jsx(Dropdown$1, {
|
|
333
|
+
autoWidth: true,
|
|
334
|
+
placement: "bottom-start",
|
|
335
|
+
strategy: "fixed",
|
|
336
|
+
buttonProps: {
|
|
337
|
+
icon: function icon() {
|
|
338
|
+
return /*#__PURE__*/jsx(CalloutIcon, {
|
|
339
|
+
currentType: isInCallout ? currentType : null
|
|
340
|
+
});
|
|
341
|
+
},
|
|
342
|
+
iconPosition: "left",
|
|
343
|
+
iconSize: 20,
|
|
344
|
+
label: /*#__PURE__*/jsx(Down, {
|
|
345
|
+
size: 12
|
|
346
|
+
}),
|
|
347
|
+
ref: dropdownRef,
|
|
348
|
+
"data-testid": "neeto-editor-fixed-menu-callout-option",
|
|
349
|
+
onKeyDown: function onKeyDown(event) {
|
|
350
|
+
var _dropdownRef$current;
|
|
351
|
+
return event.key === "ArrowDown" && ((_dropdownRef$current = dropdownRef.current) === null || _dropdownRef$current === void 0 ? void 0 : _dropdownRef$current.click());
|
|
352
|
+
},
|
|
353
|
+
tooltipProps: {
|
|
354
|
+
content: tooltipContent !== null && tooltipContent !== void 0 ? tooltipContent : label,
|
|
355
|
+
position: "bottom"
|
|
356
|
+
},
|
|
357
|
+
style: isInCallout ? "secondary" : "text",
|
|
358
|
+
size: "small",
|
|
359
|
+
className: "neeto-editor-fixed-menu__item"
|
|
360
|
+
},
|
|
361
|
+
children: /*#__PURE__*/jsx(Dropdown$1.Menu, {
|
|
362
|
+
className: "neeto-editor-callout-dropdown",
|
|
363
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
364
|
+
className: "neeto-editor-callout-dropdown__section",
|
|
365
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
366
|
+
className: "neeto-editor-callout-dropdown__section-title",
|
|
367
|
+
style: "body2",
|
|
368
|
+
weight: "normal",
|
|
369
|
+
children: t("neetoEditor.menu.selectCalloutType")
|
|
370
|
+
}), /*#__PURE__*/jsx("div", {
|
|
371
|
+
className: "neeto-editor-callout-dropdown__options-grid",
|
|
372
|
+
children: /*#__PURE__*/jsx(RenderCalloutOptions, {
|
|
373
|
+
currentCalloutAttrs: currentCalloutAttrs,
|
|
374
|
+
handleCalloutTypeClick: handleCalloutTypeClick,
|
|
375
|
+
isInCallout: isInCallout
|
|
376
|
+
})
|
|
377
|
+
})]
|
|
378
|
+
})
|
|
379
|
+
})
|
|
380
|
+
});
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
var MenuItem$3 = Dropdown$1.MenuItem;
|
|
384
|
+
var SecondaryMenuTarget = function SecondaryMenuTarget(_ref) {
|
|
385
|
+
var Icon = _ref.icon,
|
|
386
|
+
label = _ref.label;
|
|
387
|
+
return /*#__PURE__*/jsxs(MenuItem$3.Button, {
|
|
388
|
+
"data-testid": "neeto-editor-fixed-menu-".concat(hyphenate(label), "-option"),
|
|
389
|
+
children: [/*#__PURE__*/jsx(Icon, {}), " ", label]
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
var EmojiOption = function EmojiOption(_ref) {
|
|
394
|
+
var editor = _ref.editor,
|
|
395
|
+
isActive = _ref.isActive,
|
|
396
|
+
setActive = _ref.setActive,
|
|
397
|
+
tooltipContent = _ref.tooltipContent,
|
|
398
|
+
_ref$isSecondaryMenu = _ref.isSecondaryMenu,
|
|
399
|
+
isSecondaryMenu = _ref$isSecondaryMenu === void 0 ? false : _ref$isSecondaryMenu,
|
|
400
|
+
label = _ref.label;
|
|
401
|
+
return /*#__PURE__*/jsx(Dropdown$1, {
|
|
402
|
+
buttonStyle: "text",
|
|
403
|
+
closeOnSelect: false,
|
|
404
|
+
icon: Smiley,
|
|
405
|
+
isOpen: isActive,
|
|
406
|
+
position: isSecondaryMenu ? "left-start" : "bottom-start",
|
|
407
|
+
strategy: "fixed",
|
|
408
|
+
buttonProps: {
|
|
409
|
+
tabIndex: -1,
|
|
410
|
+
tooltipProps: {
|
|
411
|
+
content: tooltipContent !== null && tooltipContent !== void 0 ? tooltipContent : label,
|
|
412
|
+
position: "bottom"
|
|
413
|
+
},
|
|
414
|
+
className: "neeto-editor-fixed-menu__item",
|
|
415
|
+
"data-testid": "neeto-editor-fixed-menu-emoji-option"
|
|
416
|
+
},
|
|
417
|
+
customTarget: isSecondaryMenu && /*#__PURE__*/jsx(SecondaryMenuTarget, {
|
|
418
|
+
label: label,
|
|
419
|
+
icon: Smiley
|
|
420
|
+
}),
|
|
421
|
+
dropdownProps: {
|
|
422
|
+
classNames: "neeto-editor-fixed-menu__emoji-dropdown",
|
|
423
|
+
onClick: function onClick(e) {
|
|
424
|
+
return isSecondaryMenu && e.stopPropagation();
|
|
425
|
+
}
|
|
426
|
+
},
|
|
427
|
+
onClose: function onClose() {
|
|
428
|
+
return setActive(false);
|
|
429
|
+
},
|
|
430
|
+
onClick: function onClick(e) {
|
|
431
|
+
setActive(function (active) {
|
|
432
|
+
return !active;
|
|
433
|
+
});
|
|
434
|
+
isSecondaryMenu && e.stopPropagation();
|
|
435
|
+
},
|
|
436
|
+
children: /*#__PURE__*/jsx(EmojiPickerMenu, {
|
|
437
|
+
editor: editor,
|
|
438
|
+
setActive: setActive
|
|
439
|
+
})
|
|
440
|
+
});
|
|
441
|
+
};
|
|
442
|
+
var EmojiOption$1 = /*#__PURE__*/memo(EmojiOption);
|
|
443
|
+
|
|
444
|
+
var LinkOption = function LinkOption(_ref) {
|
|
445
|
+
var editor = _ref.editor,
|
|
446
|
+
handleClose = _ref.handleClose,
|
|
447
|
+
handleAnimateInvalidLink = _ref.handleAnimateInvalidLink;
|
|
448
|
+
var _useTranslation = useTranslation(),
|
|
449
|
+
t = _useTranslation.t;
|
|
450
|
+
var _useState = useState(""),
|
|
451
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
452
|
+
link = _useState2[0],
|
|
453
|
+
setLink = _useState2[1];
|
|
454
|
+
useEffect(function () {
|
|
455
|
+
setLink(editor.getAttributes("link").href || "");
|
|
456
|
+
}, [editor]);
|
|
457
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
458
|
+
if (event.key === "Escape") {
|
|
459
|
+
handleClose();
|
|
460
|
+
} else if (event.key === "Enter") {
|
|
461
|
+
handleSubmit();
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
var handleSubmit = function handleSubmit() {
|
|
465
|
+
if (ALL_PROTOCOL_URL_REGEXP.test(link)) {
|
|
466
|
+
editor.chain().focus().setLink({
|
|
467
|
+
href: link
|
|
468
|
+
}).run();
|
|
469
|
+
handleClose();
|
|
470
|
+
} else if (isNotPresent(link)) {
|
|
471
|
+
editor.chain().focus().unsetLink().run();
|
|
472
|
+
handleClose();
|
|
473
|
+
} else {
|
|
474
|
+
setLink("");
|
|
475
|
+
handleAnimateInvalidLink();
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
var handleReset = function handleReset() {
|
|
479
|
+
if (link) {
|
|
480
|
+
setLink("");
|
|
481
|
+
editor.chain().focus().unsetLink().run();
|
|
482
|
+
} else {
|
|
483
|
+
handleClose();
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
return /*#__PURE__*/jsxs("div", {
|
|
487
|
+
className: "neeto-editor-bubble-menu__link",
|
|
488
|
+
onKeyDown: handleKeyDown,
|
|
489
|
+
children: [/*#__PURE__*/jsx("input", {
|
|
490
|
+
autoFocus: true,
|
|
491
|
+
className: "neeto-editor-bubble-menu-link__input",
|
|
492
|
+
"data-testid": "neeto-editor-link-input",
|
|
493
|
+
name: "url",
|
|
494
|
+
placeholder: t("neetoEditor.placeholders.linkInput"),
|
|
495
|
+
value: link,
|
|
496
|
+
onChange: function onChange(_ref2) {
|
|
497
|
+
var value = _ref2.target.value;
|
|
498
|
+
return setLink(validateAndFormatUrl(value));
|
|
499
|
+
}
|
|
500
|
+
}), /*#__PURE__*/jsx(Button$1, {
|
|
501
|
+
"data-testid": "neeto-editor-link-cancel-button",
|
|
502
|
+
icon: Close,
|
|
503
|
+
size: "small",
|
|
504
|
+
style: "secondary",
|
|
505
|
+
onClick: handleReset
|
|
506
|
+
})]
|
|
507
|
+
});
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
var TableOption$2 = function TableOption(_ref) {
|
|
511
|
+
var editor = _ref.editor,
|
|
512
|
+
handleClose = _ref.handleClose;
|
|
513
|
+
var _useTranslation = useTranslation(),
|
|
514
|
+
t = _useTranslation.t;
|
|
515
|
+
var _useState = useState(3),
|
|
516
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
517
|
+
rows = _useState2[0],
|
|
518
|
+
setRows = _useState2[1];
|
|
519
|
+
var _useState3 = useState(3),
|
|
520
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
521
|
+
columns = _useState4[0],
|
|
522
|
+
setColumns = _useState4[1];
|
|
523
|
+
var handleSubmit = function handleSubmit() {
|
|
524
|
+
editor.chain().focus().insertTable({
|
|
525
|
+
rows: rows,
|
|
526
|
+
cols: columns,
|
|
527
|
+
withHeaderRow: true
|
|
528
|
+
}).run(), setRows(3);
|
|
529
|
+
setColumns(3);
|
|
530
|
+
handleClose();
|
|
531
|
+
};
|
|
532
|
+
return /*#__PURE__*/jsxs("div", {
|
|
533
|
+
className: "neeto-editor-bubble-menu__table",
|
|
534
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
535
|
+
className: "neeto-editor-bubble-menu__table__menu-item",
|
|
536
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
537
|
+
className: "neeto-editor-bubble-menu__table__input-label",
|
|
538
|
+
children: t("neetoEditor.menu.rows")
|
|
539
|
+
}), /*#__PURE__*/jsx("input", {
|
|
540
|
+
autoFocus: true,
|
|
541
|
+
"data-testid": "neeto-editor-bubble-menu-table-rows-input",
|
|
542
|
+
min: "1",
|
|
543
|
+
type: "number",
|
|
544
|
+
value: rows,
|
|
545
|
+
onChange: withEventTargetValue(setRows)
|
|
546
|
+
})]
|
|
547
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
548
|
+
className: "neeto-editor-bubble-menu__table__menu-item",
|
|
549
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
550
|
+
className: "neeto-editor-bubble-menu__table__input-label",
|
|
551
|
+
children: t("neetoEditor.menu.columns")
|
|
552
|
+
}), /*#__PURE__*/jsx("input", {
|
|
553
|
+
"data-testid": "neeto-editor-bubble-menu-table-option-input",
|
|
554
|
+
min: "1",
|
|
555
|
+
type: "number",
|
|
556
|
+
value: columns,
|
|
557
|
+
onChange: withEventTargetValue(setColumns)
|
|
558
|
+
})]
|
|
559
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
560
|
+
className: "neeto-editor-bubble-menu__table__buttons",
|
|
561
|
+
children: [/*#__PURE__*/jsx(Button$1, {
|
|
562
|
+
"data-testid": "neeto-editor-bubble-menu-table-option-create-button",
|
|
563
|
+
icon: Check,
|
|
564
|
+
size: "small",
|
|
565
|
+
style: "secondary",
|
|
566
|
+
onClick: handleSubmit
|
|
567
|
+
}), /*#__PURE__*/jsx(Button$1, {
|
|
568
|
+
"data-testid": "neeto-editor-bubble-menu-table-option-close-button",
|
|
569
|
+
icon: Close,
|
|
570
|
+
size: "small",
|
|
571
|
+
style: "secondary",
|
|
572
|
+
onClick: handleClose
|
|
573
|
+
})]
|
|
574
|
+
})]
|
|
575
|
+
});
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
function ownKeys$9(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
579
|
+
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
580
|
+
var createMenuOptions$2 = function createMenuOptions(_ref) {
|
|
581
|
+
var tooltips = _ref.tooltips,
|
|
582
|
+
editor = _ref.editor,
|
|
583
|
+
setMediaUploader = _ref.setMediaUploader,
|
|
584
|
+
attachmentProps = _ref.attachmentProps,
|
|
585
|
+
setIsAddLinkActive = _ref.setIsAddLinkActive;
|
|
586
|
+
return {
|
|
587
|
+
font: [{
|
|
588
|
+
Icon: TextBold,
|
|
589
|
+
command: function command() {
|
|
590
|
+
return editor.chain().focus().toggleBold().run();
|
|
591
|
+
},
|
|
592
|
+
active: editor.isActive("bold"),
|
|
593
|
+
optionName: "bold",
|
|
594
|
+
tooltip: tooltips.bold || t$1("neetoEditor.menu.bold")
|
|
595
|
+
}, {
|
|
596
|
+
Icon: TextItalic,
|
|
597
|
+
command: function command() {
|
|
598
|
+
return editor.chain().focus().toggleItalic().run();
|
|
599
|
+
},
|
|
600
|
+
active: editor.isActive("italic"),
|
|
601
|
+
optionName: "italic",
|
|
602
|
+
tooltip: tooltips.italic || t$1("neetoEditor.menu.italic")
|
|
603
|
+
}, {
|
|
604
|
+
Icon: Underline,
|
|
605
|
+
command: function command() {
|
|
606
|
+
return editor.chain().focus().toggleUnderline().run();
|
|
607
|
+
},
|
|
608
|
+
active: editor.isActive("underline"),
|
|
609
|
+
optionName: "underline",
|
|
610
|
+
tooltip: tooltips.underline || t$1("neetoEditor.menu.underline")
|
|
611
|
+
}, {
|
|
612
|
+
Icon: Link,
|
|
613
|
+
command: function command() {
|
|
614
|
+
return setIsAddLinkActive(not);
|
|
615
|
+
},
|
|
616
|
+
optionName: "link",
|
|
617
|
+
tooltip: "Link"
|
|
618
|
+
}, {
|
|
619
|
+
Icon: TextCross,
|
|
620
|
+
command: function command() {
|
|
621
|
+
return editor.chain().focus().toggleStrike().run();
|
|
622
|
+
},
|
|
623
|
+
active: editor.isActive("strike"),
|
|
624
|
+
optionName: "strike",
|
|
625
|
+
tooltip: tooltips.strike || t$1("neetoEditor.menu.strike")
|
|
626
|
+
}, {
|
|
627
|
+
Icon: Highlight,
|
|
628
|
+
command: function command() {
|
|
629
|
+
return editor.chain().focus().toggleHighlight().run();
|
|
630
|
+
},
|
|
631
|
+
active: editor.isActive("highlight"),
|
|
632
|
+
optionName: "highlight",
|
|
633
|
+
tooltip: tooltips.highlight || t$1("neetoEditor.menu.highlight")
|
|
634
|
+
}],
|
|
635
|
+
block: [{
|
|
636
|
+
Icon: Quote,
|
|
637
|
+
command: function command() {
|
|
638
|
+
return editor.chain().focus().toggleBlockquote().run();
|
|
639
|
+
},
|
|
640
|
+
active: editor.isActive("blockquote"),
|
|
641
|
+
optionName: "block-quote",
|
|
642
|
+
highlight: true,
|
|
643
|
+
tooltip: tooltips.blockQuote || t$1("neetoEditor.menu.blockQuote")
|
|
644
|
+
}, {
|
|
645
|
+
Icon: Code,
|
|
646
|
+
command: function command() {
|
|
647
|
+
return editor.chain().focus().toggleCode().run();
|
|
648
|
+
},
|
|
649
|
+
active: editor.isActive("code"),
|
|
650
|
+
optionName: "code",
|
|
651
|
+
tooltip: tooltips.code || t$1("neetoEditor.menu.code")
|
|
652
|
+
}, {
|
|
653
|
+
Icon: CodeBlock,
|
|
654
|
+
command: function command() {
|
|
655
|
+
return editor.chain().focus().toggleCodeBlock().run();
|
|
656
|
+
},
|
|
657
|
+
active: editor.isActive("codeBlock"),
|
|
658
|
+
optionName: "code-block",
|
|
659
|
+
tooltip: tooltips.codeBlock || t$1("neetoEditor.menu.codeBlock")
|
|
660
|
+
}],
|
|
661
|
+
list: [{
|
|
662
|
+
Icon: ListDot,
|
|
663
|
+
command: function command() {
|
|
664
|
+
return editor.chain().focus().toggleBulletList().run();
|
|
665
|
+
},
|
|
666
|
+
active: editor.isActive("bulletList"),
|
|
667
|
+
optionName: "bullet-list",
|
|
668
|
+
highlight: true,
|
|
669
|
+
tooltip: tooltips.bulletList || t$1("neetoEditor.menu.bulletedList")
|
|
670
|
+
}, {
|
|
671
|
+
Icon: ListNumber,
|
|
672
|
+
command: function command() {
|
|
673
|
+
return editor.chain().focus().toggleOrderedList().run();
|
|
674
|
+
},
|
|
675
|
+
active: editor.isActive("orderedList"),
|
|
676
|
+
optionName: "ordered-list",
|
|
677
|
+
highlight: true,
|
|
678
|
+
tooltip: tooltips.orderedList || t$1("neetoEditor.menu.orderedList")
|
|
679
|
+
}],
|
|
680
|
+
misc: [{
|
|
681
|
+
Icon: Attachment,
|
|
682
|
+
command: attachmentProps === null || attachmentProps === void 0 ? void 0 : attachmentProps.handleUploadAttachments,
|
|
683
|
+
disabled: attachmentProps === null || attachmentProps === void 0 ? void 0 : attachmentProps.isDisabled,
|
|
684
|
+
active: false,
|
|
685
|
+
optionName: "attachments",
|
|
686
|
+
tooltip: tooltips.attachments || t$1("neetoEditor.menu.attachments")
|
|
687
|
+
}, {
|
|
688
|
+
Icon: ImageUpload,
|
|
689
|
+
command: function command() {
|
|
690
|
+
return setMediaUploader(assoc("image", true));
|
|
691
|
+
},
|
|
692
|
+
optionName: "image-upload",
|
|
693
|
+
tooltip: tooltips.imageUpload || t$1("neetoEditor.menu.imageUpload")
|
|
694
|
+
}, {
|
|
695
|
+
Icon: Video,
|
|
696
|
+
command: function command() {
|
|
697
|
+
return setMediaUploader(assoc("video", true));
|
|
698
|
+
},
|
|
699
|
+
optionName: "video-upload",
|
|
700
|
+
tooltip: tooltips.videoUpload || t$1("neetoEditor.menu.videoUpload")
|
|
701
|
+
}],
|
|
702
|
+
right: [{
|
|
703
|
+
Icon: Undo,
|
|
704
|
+
command: function command() {
|
|
705
|
+
return editor.chain().focus().undo().run();
|
|
706
|
+
},
|
|
707
|
+
active: false,
|
|
708
|
+
disabled: !editor.can().undo(),
|
|
709
|
+
optionName: "undo",
|
|
710
|
+
tooltip: tooltips.undo || t$1("neetoEditor.menu.undo")
|
|
711
|
+
}, {
|
|
712
|
+
Icon: Redo,
|
|
713
|
+
command: function command() {
|
|
714
|
+
return editor.chain().focus().redo().run();
|
|
715
|
+
},
|
|
716
|
+
active: false,
|
|
717
|
+
disabled: !editor.can().redo(),
|
|
718
|
+
optionName: "redo",
|
|
719
|
+
tooltip: tooltips.redo || t$1("neetoEditor.menu.redo")
|
|
720
|
+
}]
|
|
721
|
+
};
|
|
722
|
+
};
|
|
723
|
+
var buildBubbleMenuOptions = function buildBubbleMenuOptions(_ref2) {
|
|
724
|
+
var tooltips = _ref2.tooltips,
|
|
725
|
+
editor = _ref2.editor,
|
|
726
|
+
options = _ref2.options,
|
|
727
|
+
setMediaUploader = _ref2.setMediaUploader,
|
|
728
|
+
attachmentProps = _ref2.attachmentProps,
|
|
729
|
+
setIsAddLinkActive = _ref2.setIsAddLinkActive;
|
|
730
|
+
var menuOptions = createMenuOptions$2({
|
|
731
|
+
tooltips: tooltips,
|
|
732
|
+
editor: editor,
|
|
733
|
+
setMediaUploader: setMediaUploader,
|
|
734
|
+
attachmentProps: attachmentProps,
|
|
735
|
+
setIsAddLinkActive: setIsAddLinkActive
|
|
736
|
+
});
|
|
737
|
+
return fromPairs(["font", "block", "list", "misc", "right"].map(function (option) {
|
|
738
|
+
return [option, menuOptions[option].filter(function (item) {
|
|
739
|
+
return options.includes(item.optionName);
|
|
740
|
+
})];
|
|
741
|
+
}));
|
|
742
|
+
};
|
|
743
|
+
var getTextMenuDropdownOptions = function getTextMenuDropdownOptions(_ref3) {
|
|
744
|
+
var editor = _ref3.editor,
|
|
745
|
+
options = _ref3.options;
|
|
746
|
+
var textOptions = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, EDITOR_OPTIONS.H1, {
|
|
747
|
+
optionName: "Heading 1",
|
|
748
|
+
icon: TextH1,
|
|
749
|
+
active: editor.isActive("heading", {
|
|
750
|
+
level: 1
|
|
751
|
+
}),
|
|
752
|
+
command: function command() {
|
|
753
|
+
return editor.chain().focus().setNode("heading", {
|
|
754
|
+
level: 1
|
|
755
|
+
}).run();
|
|
756
|
+
}
|
|
757
|
+
}), EDITOR_OPTIONS.H2, {
|
|
758
|
+
optionName: "Heading 2",
|
|
759
|
+
icon: TextH2,
|
|
760
|
+
active: editor.isActive("heading", {
|
|
761
|
+
level: 2
|
|
762
|
+
}),
|
|
763
|
+
command: function command() {
|
|
764
|
+
return editor.chain().focus().setNode("heading", {
|
|
765
|
+
level: 2
|
|
766
|
+
}).run();
|
|
767
|
+
}
|
|
768
|
+
}), EDITOR_OPTIONS.H3, {
|
|
769
|
+
optionName: "Heading 3",
|
|
770
|
+
icon: TextH3,
|
|
771
|
+
active: editor.isActive("heading", {
|
|
772
|
+
level: 3
|
|
773
|
+
}),
|
|
774
|
+
command: function command() {
|
|
775
|
+
return editor.chain().focus().setNode("heading", {
|
|
776
|
+
level: 3
|
|
777
|
+
}).run();
|
|
778
|
+
}
|
|
779
|
+
}), EDITOR_OPTIONS.PARAGRAPH, {
|
|
780
|
+
optionName: "Text",
|
|
781
|
+
icon: TextP,
|
|
782
|
+
active: editor.isActive("paragraph"),
|
|
783
|
+
command: function command() {
|
|
784
|
+
return editor.chain().focus().setNode("paragraph").run();
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
var result = [];
|
|
788
|
+
options.forEach(function (option) {
|
|
789
|
+
if (!textOptions[option]) return;
|
|
790
|
+
result.push(textOptions[option]);
|
|
791
|
+
});
|
|
792
|
+
return result;
|
|
793
|
+
};
|
|
794
|
+
var getNodeIcon = function getNodeIcon(options) {
|
|
795
|
+
var _options$find;
|
|
796
|
+
return ((_options$find = options.find(prop("active"))) === null || _options$find === void 0 ? void 0 : _options$find.icon) || TextP;
|
|
797
|
+
};
|
|
798
|
+
var renderOptionButton = function renderOptionButton(_ref4) {
|
|
799
|
+
var tooltip = _ref4.tooltip,
|
|
800
|
+
Icon = _ref4.Icon,
|
|
801
|
+
command = _ref4.command,
|
|
802
|
+
active = _ref4.active,
|
|
803
|
+
optionName = _ref4.optionName,
|
|
804
|
+
highlight = _ref4.highlight;
|
|
805
|
+
return /*#__PURE__*/jsx(Button$1, _objectSpread$9({
|
|
806
|
+
className: "neeto-editor-bubble-menu__item",
|
|
807
|
+
"data-testid": "neeto-editor-bubble-menu-".concat(optionName, "-option"),
|
|
808
|
+
icon: Icon,
|
|
809
|
+
size: "medium",
|
|
810
|
+
style: active ? "secondary" : "text",
|
|
811
|
+
tooltipProps: {
|
|
812
|
+
content: tooltip,
|
|
813
|
+
position: "bottom",
|
|
814
|
+
theme: "dark"
|
|
815
|
+
},
|
|
816
|
+
onClick: command
|
|
817
|
+
}, generateFocusProps(highlight)), optionName);
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
var Menu$4 = Dropdown$1.Menu,
|
|
821
|
+
MenuItem$2 = Dropdown$1.MenuItem;
|
|
822
|
+
var Mentions = function Mentions(_ref) {
|
|
823
|
+
var editor = _ref.editor,
|
|
824
|
+
mentions = _ref.mentions,
|
|
825
|
+
tooltipContent = _ref.tooltipContent,
|
|
826
|
+
_ref$isSecondaryMenu = _ref.isSecondaryMenu,
|
|
827
|
+
isSecondaryMenu = _ref$isSecondaryMenu === void 0 ? false : _ref$isSecondaryMenu,
|
|
828
|
+
label = _ref.label;
|
|
829
|
+
if (isEmpty(mentions)) return null;
|
|
830
|
+
return /*#__PURE__*/jsx(Dropdown$1, {
|
|
831
|
+
buttonStyle: "text",
|
|
832
|
+
"data-testid": "neeto-editor-mention-option",
|
|
833
|
+
icon: Email,
|
|
834
|
+
position: isSecondaryMenu ? "left-start" : "bottom-start",
|
|
835
|
+
strategy: "fixed",
|
|
836
|
+
buttonProps: {
|
|
837
|
+
tooltipProps: {
|
|
838
|
+
content: tooltipContent !== null && tooltipContent !== void 0 ? tooltipContent : label,
|
|
839
|
+
position: "bottom"
|
|
840
|
+
},
|
|
841
|
+
className: "neeto-editor-fixed-menu__item"
|
|
842
|
+
},
|
|
843
|
+
customTarget: isSecondaryMenu && /*#__PURE__*/jsx(SecondaryMenuTarget, {
|
|
844
|
+
label: label,
|
|
845
|
+
icon: Email
|
|
846
|
+
}),
|
|
847
|
+
onClick: function onClick(e) {
|
|
848
|
+
return isSecondaryMenu && e.stopPropagation();
|
|
849
|
+
},
|
|
850
|
+
children: /*#__PURE__*/jsx(Menu$4, {
|
|
851
|
+
children: mentions.map(function (_ref2) {
|
|
852
|
+
var key = _ref2.key,
|
|
853
|
+
name = _ref2.name,
|
|
854
|
+
imageUrl = _ref2.imageUrl;
|
|
855
|
+
return /*#__PURE__*/jsxs(MenuItem$2.Button, {
|
|
856
|
+
"data-testid": "neeto-editor-mention-option-".concat(key),
|
|
857
|
+
onClick: function onClick() {
|
|
858
|
+
return editor.commands.setMention({
|
|
859
|
+
id: key,
|
|
860
|
+
label: name
|
|
861
|
+
});
|
|
862
|
+
},
|
|
863
|
+
children: [/*#__PURE__*/jsx(Avatar, {
|
|
864
|
+
size: "small",
|
|
865
|
+
user: {
|
|
866
|
+
name: name,
|
|
867
|
+
imageUrl: imageUrl
|
|
868
|
+
}
|
|
869
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
870
|
+
style: "body2",
|
|
871
|
+
children: name
|
|
872
|
+
})]
|
|
873
|
+
}, key);
|
|
874
|
+
})
|
|
875
|
+
})
|
|
876
|
+
});
|
|
877
|
+
};
|
|
878
|
+
var Mentions$1 = /*#__PURE__*/memo(Mentions);
|
|
879
|
+
|
|
880
|
+
var TextColorOption = function TextColorOption(_ref) {
|
|
881
|
+
var editor = _ref.editor,
|
|
882
|
+
tooltipContent = _ref.tooltipContent,
|
|
883
|
+
_ref$isSecondaryMenu = _ref.isSecondaryMenu,
|
|
884
|
+
isSecondaryMenu = _ref$isSecondaryMenu === void 0 ? false : _ref$isSecondaryMenu,
|
|
885
|
+
label = _ref.label;
|
|
886
|
+
var _useState = useState(false),
|
|
887
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
888
|
+
isOpen = _useState2[0],
|
|
889
|
+
setIsOpen = _useState2[1];
|
|
890
|
+
var _useState3 = useState(null),
|
|
891
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
892
|
+
color = _useState4[0],
|
|
893
|
+
setColor = _useState4[1];
|
|
894
|
+
var dropdownWrapperRef = useRef(null);
|
|
895
|
+
var _useTranslation = useTranslation(),
|
|
896
|
+
t = _useTranslation.t;
|
|
897
|
+
var handleSave = function handleSave() {
|
|
898
|
+
editor.chain().focus().setColor(color).run();
|
|
899
|
+
setIsOpen(false);
|
|
900
|
+
};
|
|
901
|
+
var handleUnset = function handleUnset() {
|
|
902
|
+
editor.chain().focus().unsetColor().run();
|
|
903
|
+
setColor(null);
|
|
904
|
+
setIsOpen(false);
|
|
905
|
+
};
|
|
906
|
+
useOnClickOutside(dropdownWrapperRef, function (event) {
|
|
907
|
+
if (!isOpen) return;
|
|
908
|
+
event.preventDefault();
|
|
909
|
+
editor.commands.focus();
|
|
910
|
+
setIsOpen(false);
|
|
911
|
+
});
|
|
912
|
+
useEffect(function () {
|
|
913
|
+
setColor(editor.getAttributes("textStyle").color);
|
|
914
|
+
}, [isOpen, editor.getAttributes("textStyle").color]);
|
|
915
|
+
var openColorPicker = function openColorPicker(e) {
|
|
916
|
+
isSecondaryMenu && e.stopPropagation();
|
|
917
|
+
setColor(editor.getAttributes("textStyle").color);
|
|
918
|
+
setIsOpen(not);
|
|
919
|
+
};
|
|
920
|
+
return /*#__PURE__*/jsx(Dropdown$1, {
|
|
921
|
+
isOpen: isOpen,
|
|
922
|
+
buttonStyle: isOpen || color ? "secondary" : "text",
|
|
923
|
+
icon: Customize,
|
|
924
|
+
position: isSecondaryMenu ? "left-start" : "bottom-start",
|
|
925
|
+
buttonProps: {
|
|
926
|
+
tabIndex: -1,
|
|
927
|
+
tooltipProps: {
|
|
928
|
+
content: tooltipContent !== null && tooltipContent !== void 0 ? tooltipContent : label,
|
|
929
|
+
position: "bottom"
|
|
930
|
+
},
|
|
931
|
+
className: "neeto-editor-fixed-menu__item neeto-editor-text-color-option",
|
|
932
|
+
"data-testid": "neeto-editor-fixed-menu-text-color-option"
|
|
933
|
+
},
|
|
934
|
+
customTarget: isSecondaryMenu && /*#__PURE__*/jsx(SecondaryMenuTarget, {
|
|
935
|
+
label: label,
|
|
936
|
+
icon: Customize
|
|
937
|
+
}),
|
|
938
|
+
onClick: openColorPicker,
|
|
939
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
940
|
+
ref: dropdownWrapperRef,
|
|
941
|
+
style: {
|
|
942
|
+
"min-width": "236px"
|
|
943
|
+
},
|
|
944
|
+
onClick: function onClick(e) {
|
|
945
|
+
e.stopPropagation();
|
|
946
|
+
},
|
|
947
|
+
children: [/*#__PURE__*/jsx(HexColorPicker, {
|
|
948
|
+
color: color || "#000000",
|
|
949
|
+
onChange: setColor
|
|
950
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
951
|
+
className: "neeto-editor-text-color-option__options-group",
|
|
952
|
+
children: [/*#__PURE__*/jsx(Input, {
|
|
953
|
+
autoFocus: true,
|
|
954
|
+
className: "neeto-editor-text-color-option__options-group__input",
|
|
955
|
+
placeholder: t("neetoEditor.placeholders.pickColor"),
|
|
956
|
+
size: "small",
|
|
957
|
+
value: color,
|
|
958
|
+
onChange: withEventTargetValue(setColor),
|
|
959
|
+
onClick: function onClick(event) {
|
|
960
|
+
return event.stopPropagation();
|
|
961
|
+
}
|
|
962
|
+
}), /*#__PURE__*/jsx(Button$1, {
|
|
963
|
+
icon: Check,
|
|
964
|
+
size: "small",
|
|
965
|
+
onClick: handleSave
|
|
966
|
+
}), /*#__PURE__*/jsx(Button$1, {
|
|
967
|
+
icon: Close,
|
|
968
|
+
size: "small",
|
|
969
|
+
style: "text",
|
|
970
|
+
onClick: function onClick() {
|
|
971
|
+
editor.commands.focus();
|
|
972
|
+
setIsOpen(false);
|
|
973
|
+
}
|
|
974
|
+
}), /*#__PURE__*/jsx(Button$1, {
|
|
975
|
+
icon: Refresh,
|
|
976
|
+
size: "small",
|
|
977
|
+
style: "text",
|
|
978
|
+
tooltipProps: {
|
|
979
|
+
content: t("neetoEditor.common.resetToDefault"),
|
|
980
|
+
position: "top"
|
|
981
|
+
},
|
|
982
|
+
onClick: handleUnset
|
|
983
|
+
})]
|
|
984
|
+
})]
|
|
985
|
+
})
|
|
986
|
+
});
|
|
987
|
+
};
|
|
988
|
+
|
|
989
|
+
var Options = function Options(_ref) {
|
|
990
|
+
var editor = _ref.editor,
|
|
991
|
+
options = _ref.options,
|
|
992
|
+
mentions = _ref.mentions,
|
|
993
|
+
tooltips = _ref.tooltips,
|
|
994
|
+
setIsInvalidLink = _ref.setIsInvalidLink,
|
|
995
|
+
isLinkOptionActive = _ref.isLinkOptionActive,
|
|
996
|
+
isTableOptionActive = _ref.isTableOptionActive,
|
|
997
|
+
setIsLinkOptionActive = _ref.setIsLinkOptionActive,
|
|
998
|
+
setIsTableOptionActive = _ref.setIsTableOptionActive,
|
|
999
|
+
setMediaUploader = _ref.setMediaUploader,
|
|
1000
|
+
attachmentProps = _ref.attachmentProps,
|
|
1001
|
+
isEmojiPickerActive = _ref.isEmojiPickerActive,
|
|
1002
|
+
setIsEmojiPickerActive = _ref.setIsEmojiPickerActive;
|
|
1003
|
+
var _useTranslation = useTranslation(),
|
|
1004
|
+
t = _useTranslation.t;
|
|
1005
|
+
var Menu = Dropdown$1.Menu,
|
|
1006
|
+
MenuItem = Dropdown$1.MenuItem;
|
|
1007
|
+
var dropdownOptions = getTextMenuDropdownOptions({
|
|
1008
|
+
editor: editor,
|
|
1009
|
+
options: options
|
|
1010
|
+
});
|
|
1011
|
+
var Icon = getNodeIcon(dropdownOptions);
|
|
1012
|
+
var isEmojiActive = options.includes(EDITOR_OPTIONS.EMOJI);
|
|
1013
|
+
var isTextColorOptionActive = options.includes(EDITOR_OPTIONS.TEXT_COLOR);
|
|
1014
|
+
var isLinkActive = options.includes(EDITOR_OPTIONS.LINK);
|
|
1015
|
+
var isTableActive = options.includes(EDITOR_OPTIONS.TABLE);
|
|
1016
|
+
var _buildBubbleMenuOptio = buildBubbleMenuOptions({
|
|
1017
|
+
editor: editor,
|
|
1018
|
+
options: options,
|
|
1019
|
+
setMediaUploader: setMediaUploader,
|
|
1020
|
+
tooltips: tooltips,
|
|
1021
|
+
attachmentProps: attachmentProps,
|
|
1022
|
+
setIsAddLinkActive: setIsLinkOptionActive
|
|
1023
|
+
}),
|
|
1024
|
+
fontStyleOptions = _buildBubbleMenuOptio.font,
|
|
1025
|
+
blockStyleOptions = _buildBubbleMenuOptio.block,
|
|
1026
|
+
listStyleOptions = _buildBubbleMenuOptio.list;
|
|
1027
|
+
var handleAnimateInvalidLink = function handleAnimateInvalidLink() {
|
|
1028
|
+
setIsInvalidLink(true);
|
|
1029
|
+
setTimeout(function () {
|
|
1030
|
+
setIsInvalidLink(false);
|
|
1031
|
+
}, 1000);
|
|
1032
|
+
};
|
|
1033
|
+
if (isLinkOptionActive) {
|
|
1034
|
+
return /*#__PURE__*/jsx(LinkOption, {
|
|
1035
|
+
editor: editor,
|
|
1036
|
+
handleAnimateInvalidLink: handleAnimateInvalidLink,
|
|
1037
|
+
handleClose: function handleClose() {
|
|
1038
|
+
return setIsLinkOptionActive(false);
|
|
1039
|
+
}
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
if (isTableOptionActive) {
|
|
1043
|
+
return /*#__PURE__*/jsx(TableOption$2, {
|
|
1044
|
+
editor: editor,
|
|
1045
|
+
handleClose: function handleClose() {
|
|
1046
|
+
return setIsTableOptionActive(false);
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
1051
|
+
children: [/*#__PURE__*/jsx(Dropdown$1, {
|
|
1052
|
+
buttonSize: "small",
|
|
1053
|
+
buttonStyle: "text",
|
|
1054
|
+
label: Icon,
|
|
1055
|
+
strategy: "fixed",
|
|
1056
|
+
buttonProps: {
|
|
1057
|
+
icon: Icon,
|
|
1058
|
+
iconPosition: "left",
|
|
1059
|
+
iconSize: 22,
|
|
1060
|
+
label: /*#__PURE__*/jsx(Down, {
|
|
1061
|
+
size: 12
|
|
1062
|
+
}),
|
|
1063
|
+
"data-testid": "neeto-editor-fixed-menu-font-size-option",
|
|
1064
|
+
style: "text",
|
|
1065
|
+
size: "small",
|
|
1066
|
+
className: "neeto-editor-bubble-menu__item neeto-editor-font-size__wrapper"
|
|
1067
|
+
},
|
|
1068
|
+
children: /*#__PURE__*/jsx(Menu, {
|
|
1069
|
+
className: "neeto-ui-flex neeto-ui-gap-1 neeto-editor-menu-font-size-options",
|
|
1070
|
+
children: dropdownOptions.map(function (_ref2) {
|
|
1071
|
+
var optionName = _ref2.optionName,
|
|
1072
|
+
command = _ref2.command,
|
|
1073
|
+
Icon = _ref2.icon;
|
|
1074
|
+
return /*#__PURE__*/jsx(MenuItem.Button, {
|
|
1075
|
+
className: "neeto-editor-menu-font-size-options__item-btn",
|
|
1076
|
+
tooltipProps: {
|
|
1077
|
+
content: optionName,
|
|
1078
|
+
position: "bottom"
|
|
1079
|
+
},
|
|
1080
|
+
onClick: command,
|
|
1081
|
+
children: /*#__PURE__*/jsx(Icon, {
|
|
1082
|
+
size: 22
|
|
1083
|
+
})
|
|
1084
|
+
}, optionName);
|
|
1085
|
+
})
|
|
1086
|
+
})
|
|
1087
|
+
}), fontStyleOptions.map(renderOptionButton), blockStyleOptions.map(renderOptionButton), isTextColorOptionActive && /*#__PURE__*/jsx(TextColorOption, {
|
|
1088
|
+
editor: editor,
|
|
1089
|
+
tooltipContent: tooltips.textColor || t("neetoEditor.menu.textColor")
|
|
1090
|
+
}), isEmojiActive && /*#__PURE__*/jsx(EmojiOption$1, {
|
|
1091
|
+
editor: editor,
|
|
1092
|
+
isActive: isEmojiPickerActive,
|
|
1093
|
+
setActive: setIsEmojiPickerActive,
|
|
1094
|
+
tooltipContent: tooltips.emoji || t("neetoEditor.menu.emoji")
|
|
1095
|
+
}), listStyleOptions.map(renderOptionButton), isLinkActive && renderOptionButton({
|
|
1096
|
+
Icon: Link,
|
|
1097
|
+
command: function command() {
|
|
1098
|
+
return setIsLinkOptionActive(true);
|
|
1099
|
+
},
|
|
1100
|
+
active: editor.isActive("link"),
|
|
1101
|
+
optionName: "link",
|
|
1102
|
+
highlight: false,
|
|
1103
|
+
tooltip: tooltips.link || t("neetoEditor.menu.link")
|
|
1104
|
+
}), isTableActive && renderOptionButton({
|
|
1105
|
+
Icon: Column,
|
|
1106
|
+
command: function command() {
|
|
1107
|
+
return setIsTableOptionActive(true);
|
|
1108
|
+
},
|
|
1109
|
+
active: editor.isActive("table"),
|
|
1110
|
+
optionName: "table",
|
|
1111
|
+
highlight: false,
|
|
1112
|
+
tooltip: tooltips.table || t("neetoEditor.menu.table")
|
|
1113
|
+
}), /*#__PURE__*/jsx(Mentions$1, {
|
|
1114
|
+
editor: editor,
|
|
1115
|
+
mentions: mentions,
|
|
1116
|
+
tooltipContent: tooltips.mention || t("neetoEditor.menu.mention")
|
|
1117
|
+
})]
|
|
1118
|
+
});
|
|
1119
|
+
};
|
|
1120
|
+
|
|
1121
|
+
var Bubble = function Bubble(_ref) {
|
|
1122
|
+
var editor = _ref.editor,
|
|
1123
|
+
textOptions = _ref.options,
|
|
1124
|
+
_ref$mentions = _ref.mentions,
|
|
1125
|
+
mentions = _ref$mentions === void 0 ? [] : _ref$mentions,
|
|
1126
|
+
setMediaUploader = _ref.setMediaUploader,
|
|
1127
|
+
_ref$tooltips = _ref.tooltips,
|
|
1128
|
+
tooltips = _ref$tooltips === void 0 ? {} : _ref$tooltips,
|
|
1129
|
+
attachmentProps = _ref.attachmentProps,
|
|
1130
|
+
isEmojiPickerActive = _ref.isEmojiPickerActive,
|
|
1131
|
+
setIsEmojiPickerActive = _ref.setIsEmojiPickerActive;
|
|
1132
|
+
var _useState = useState(false),
|
|
1133
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1134
|
+
isInvalidLink = _useState2[0],
|
|
1135
|
+
setIsInvalidLink = _useState2[1];
|
|
1136
|
+
var _useState3 = useState(false),
|
|
1137
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1138
|
+
isLinkOptionActive = _useState4[0],
|
|
1139
|
+
setIsLinkOptionActive = _useState4[1];
|
|
1140
|
+
var _useState5 = useState(false),
|
|
1141
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1142
|
+
isTableOptionActive = _useState6[0],
|
|
1143
|
+
setIsTableOptionActive = _useState6[1];
|
|
1144
|
+
var selectedNode = editor && editor.view.state.selection.node;
|
|
1145
|
+
var isImageNodeSelected = selectedNode && selectedNode.type.name === "image";
|
|
1146
|
+
var bubbleMenuOptions = [EDITOR_OPTIONS.BOLD, EDITOR_OPTIONS.ITALIC, EDITOR_OPTIONS.UNDERLINE, EDITOR_OPTIONS.STRIKETHROUGH, EDITOR_OPTIONS.LINK];
|
|
1147
|
+
var noTextOptions = isNotPresent(textOptions.filter(function (option) {
|
|
1148
|
+
return bubbleMenuOptions.includes(option);
|
|
1149
|
+
}));
|
|
1150
|
+
if (!editor || !isImageNodeSelected && noTextOptions) {
|
|
1151
|
+
return null;
|
|
1152
|
+
}
|
|
1153
|
+
return /*#__PURE__*/jsx("div", {
|
|
1154
|
+
children: /*#__PURE__*/jsx(BubbleMenu, {
|
|
1155
|
+
editor: editor,
|
|
1156
|
+
style: {
|
|
1157
|
+
zIndex: 99999,
|
|
1158
|
+
maxWidth: 500
|
|
1159
|
+
},
|
|
1160
|
+
className: classnames("neeto-editor-bubble-menu", {
|
|
1161
|
+
"neeto-editor-bubble-menu-animate-shake": isInvalidLink
|
|
1162
|
+
}),
|
|
1163
|
+
options: {
|
|
1164
|
+
offset: 10,
|
|
1165
|
+
onHide: function onHide() {
|
|
1166
|
+
setIsLinkOptionActive(false);
|
|
1167
|
+
setIsTableOptionActive(false);
|
|
1168
|
+
}
|
|
1169
|
+
},
|
|
1170
|
+
children: /*#__PURE__*/jsx(Options, {
|
|
1171
|
+
attachmentProps: attachmentProps,
|
|
1172
|
+
editor: editor,
|
|
1173
|
+
isEmojiPickerActive: isEmojiPickerActive,
|
|
1174
|
+
isLinkOptionActive: isLinkOptionActive,
|
|
1175
|
+
isTableOptionActive: isTableOptionActive,
|
|
1176
|
+
mentions: mentions,
|
|
1177
|
+
setIsEmojiPickerActive: setIsEmojiPickerActive,
|
|
1178
|
+
setIsInvalidLink: setIsInvalidLink,
|
|
1179
|
+
setIsLinkOptionActive: setIsLinkOptionActive,
|
|
1180
|
+
setIsTableOptionActive: setIsTableOptionActive,
|
|
1181
|
+
setMediaUploader: setMediaUploader,
|
|
1182
|
+
tooltips: tooltips,
|
|
1183
|
+
options: textOptions
|
|
1184
|
+
})
|
|
1185
|
+
})
|
|
1186
|
+
});
|
|
1187
|
+
};
|
|
1188
|
+
|
|
1189
|
+
var EmptyMenu = function EmptyMenu() {
|
|
1190
|
+
return /*#__PURE__*/jsx("div", {});
|
|
1191
|
+
};
|
|
1192
|
+
|
|
1193
|
+
var Progress = withT(function (_ref) {
|
|
1194
|
+
var t = _ref.t,
|
|
1195
|
+
queuedFiles = _ref.queuedFiles,
|
|
1196
|
+
cancelUpload = _ref.cancelUpload;
|
|
1197
|
+
return /*#__PURE__*/jsx("div", {
|
|
1198
|
+
className: "ne-media-uploader__wrapper",
|
|
1199
|
+
children: queuedFiles.map(function (_ref2) {
|
|
1200
|
+
var id = _ref2.id,
|
|
1201
|
+
filename = _ref2.filename,
|
|
1202
|
+
_ref2$progress = _ref2.progress,
|
|
1203
|
+
progress = _ref2$progress === void 0 ? 0 : _ref2$progress;
|
|
1204
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1205
|
+
className: "ne-media-uploader__media",
|
|
1206
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
1207
|
+
className: "ne-media-uploader__media__cancel-button-wrapper",
|
|
1208
|
+
children: /*#__PURE__*/jsx(Button$1, {
|
|
1209
|
+
"data-testid": "neeto-editor-image-upload-cancel-button",
|
|
1210
|
+
icon: Close,
|
|
1211
|
+
iconSize: 18,
|
|
1212
|
+
size: "small",
|
|
1213
|
+
style: "text",
|
|
1214
|
+
onClick: function onClick() {
|
|
1215
|
+
return cancelUpload(id);
|
|
1216
|
+
}
|
|
1217
|
+
})
|
|
1218
|
+
}), /*#__PURE__*/jsx(File, {
|
|
1219
|
+
className: "ne-media-uploader__media__info__icon",
|
|
1220
|
+
fileName: filename
|
|
1221
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
1222
|
+
className: "ne-media-uploader__media__info",
|
|
1223
|
+
children: [/*#__PURE__*/jsxs(Typography, {
|
|
1224
|
+
style: "nano",
|
|
1225
|
+
children: [progress === 100 && t("neetoEditor.localUploader.completed"), progress !== 100 && /*#__PURE__*/jsxs(Fragment, {
|
|
1226
|
+
children: [progress, "%"]
|
|
1227
|
+
})]
|
|
1228
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1229
|
+
className: "ne-media-uploader__media__progress",
|
|
1230
|
+
children: /*#__PURE__*/jsx("div", {
|
|
1231
|
+
className: "ne-media-uploader__media__progress-bar",
|
|
1232
|
+
style: {
|
|
1233
|
+
width: "".concat(progress, "%")
|
|
1234
|
+
}
|
|
1235
|
+
})
|
|
1236
|
+
}), /*#__PURE__*/jsx(Tooltip, {
|
|
1237
|
+
content: filename,
|
|
1238
|
+
position: "top",
|
|
1239
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
1240
|
+
style: "body3",
|
|
1241
|
+
children: filename
|
|
1242
|
+
})
|
|
1243
|
+
})]
|
|
1244
|
+
})]
|
|
1245
|
+
}, id);
|
|
1246
|
+
})
|
|
1247
|
+
});
|
|
1248
|
+
});
|
|
1249
|
+
|
|
1250
|
+
var LocalUploader = function LocalUploader(_ref) {
|
|
1251
|
+
var isImage = _ref.isImage,
|
|
1252
|
+
onClose = _ref.onClose,
|
|
1253
|
+
insertMediaToEditor = _ref.insertMediaToEditor,
|
|
1254
|
+
setIsUploading = _ref.setIsUploading;
|
|
1255
|
+
var _useTranslation = useTranslation(),
|
|
1256
|
+
t = _useTranslation.t;
|
|
1257
|
+
var uploadConfig = isImage ? DEFAULT_IMAGE_UPLOAD_CONFIG : DEFAULT_VIDEO_UPLOAD_CONFIG;
|
|
1258
|
+
var fileInputRef = useRef(null);
|
|
1259
|
+
var dropTargetRef = useRef(null);
|
|
1260
|
+
var _useFileUploader = useFileUploader({
|
|
1261
|
+
config: uploadConfig,
|
|
1262
|
+
setIsUploadingOnHost: setIsUploading
|
|
1263
|
+
}),
|
|
1264
|
+
addFiles = _useFileUploader.addFiles,
|
|
1265
|
+
uploadFiles = _useFileUploader.uploadFiles,
|
|
1266
|
+
queuedFiles = _useFileUploader.queuedFiles,
|
|
1267
|
+
cancelUpload = _useFileUploader.cancelUpload,
|
|
1268
|
+
isUploading = _useFileUploader.isUploading;
|
|
1269
|
+
var handleFilesDrop = /*#__PURE__*/function () {
|
|
1270
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(files) {
|
|
1271
|
+
var uploadedFiles;
|
|
1272
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1273
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1274
|
+
case 0:
|
|
1275
|
+
addFiles(files);
|
|
1276
|
+
_context.next = 3;
|
|
1277
|
+
return uploadFiles();
|
|
1278
|
+
case 3:
|
|
1279
|
+
uploadedFiles = _context.sent;
|
|
1280
|
+
uploadedFiles.forEach(insertMediaToEditor);
|
|
1281
|
+
onClose();
|
|
1282
|
+
case 6:
|
|
1283
|
+
case "end":
|
|
1284
|
+
return _context.stop();
|
|
1285
|
+
}
|
|
1286
|
+
}, _callee);
|
|
1287
|
+
}));
|
|
1288
|
+
return function handleFilesDrop(_x) {
|
|
1289
|
+
return _ref2.apply(this, arguments);
|
|
1290
|
+
};
|
|
1291
|
+
}();
|
|
1292
|
+
useDropFiles({
|
|
1293
|
+
dropTargetRef: dropTargetRef,
|
|
1294
|
+
onDrop: handleFilesDrop
|
|
1295
|
+
});
|
|
1296
|
+
setIsUploading(isUploading);
|
|
1297
|
+
var handleAddFile = /*#__PURE__*/function () {
|
|
1298
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
1299
|
+
var files, uploadedFiles;
|
|
1300
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
1301
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1302
|
+
case 0:
|
|
1303
|
+
files = _ref3.target.files;
|
|
1304
|
+
addFiles(files);
|
|
1305
|
+
_context2.next = 4;
|
|
1306
|
+
return uploadFiles();
|
|
1307
|
+
case 4:
|
|
1308
|
+
uploadedFiles = _context2.sent;
|
|
1309
|
+
uploadedFiles.forEach(insertMediaToEditor);
|
|
1310
|
+
onClose();
|
|
1311
|
+
case 7:
|
|
1312
|
+
case "end":
|
|
1313
|
+
return _context2.stop();
|
|
1314
|
+
}
|
|
1315
|
+
}, _callee2);
|
|
1316
|
+
}));
|
|
1317
|
+
return function handleAddFile(_x2) {
|
|
1318
|
+
return _ref4.apply(this, arguments);
|
|
1319
|
+
};
|
|
1320
|
+
}();
|
|
1321
|
+
return !isEmpty(queuedFiles) || isUploading ? /*#__PURE__*/jsx(Progress, {
|
|
1322
|
+
cancelUpload: cancelUpload,
|
|
1323
|
+
queuedFiles: queuedFiles
|
|
1324
|
+
}) : /*#__PURE__*/jsxs("div", {
|
|
1325
|
+
className: "ne-media-uploader__dnd",
|
|
1326
|
+
"data-testid": "neeto-editor-media-uploader-dnd",
|
|
1327
|
+
ref: dropTargetRef,
|
|
1328
|
+
tabIndex: 0,
|
|
1329
|
+
onClick: function onClick() {
|
|
1330
|
+
var _fileInputRef$current;
|
|
1331
|
+
return (_fileInputRef$current = fileInputRef.current) === null || _fileInputRef$current === void 0 ? void 0 : _fileInputRef$current.click();
|
|
1332
|
+
},
|
|
1333
|
+
children: [/*#__PURE__*/jsx("input", {
|
|
1334
|
+
multiple: true,
|
|
1335
|
+
className: "ne-media-uploader__dnd-input",
|
|
1336
|
+
"data-testid": "neeto-editor-media-uploader-input",
|
|
1337
|
+
ref: fileInputRef,
|
|
1338
|
+
type: "file",
|
|
1339
|
+
accept: isImage ? ALLOWED_IMAGE_TYPES.join(",") : ALLOWED_VIDEO_TYPES.join(","),
|
|
1340
|
+
onChange: handleAddFile
|
|
1341
|
+
}), /*#__PURE__*/jsx(ImageUpload, {
|
|
1342
|
+
className: "ne-media-uploader__dnd-icon",
|
|
1343
|
+
size: 24
|
|
1344
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
1345
|
+
style: "body2",
|
|
1346
|
+
children: t("neetoEditor.localUploader.dropFilesHere")
|
|
1347
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
1348
|
+
style: "body3",
|
|
1349
|
+
children: t("neetoEditor.localUploader.maxFileSize", {
|
|
1350
|
+
entity: convertToFileSize(uploadConfig.restrictions.maxFileSize)
|
|
1351
|
+
})
|
|
1352
|
+
})]
|
|
1353
|
+
});
|
|
1354
|
+
};
|
|
1355
|
+
|
|
1356
|
+
var VideoEmbedForm = function VideoEmbedForm(_ref) {
|
|
1357
|
+
var onEmbedVideo = _ref.onEmbedVideo,
|
|
1358
|
+
onAttachVideo = _ref.onAttachVideo,
|
|
1359
|
+
onClose = _ref.onClose;
|
|
1360
|
+
var _useTranslation = useTranslation(),
|
|
1361
|
+
t = _useTranslation.t;
|
|
1362
|
+
var initialValues = {
|
|
1363
|
+
url: ""
|
|
1364
|
+
};
|
|
1365
|
+
var onSubmit = function onSubmit(_ref2) {
|
|
1366
|
+
var url = _ref2.url;
|
|
1367
|
+
var embedUrl = validateUrl(url); // False when current url is not "embeddable"
|
|
1368
|
+
if (embedUrl) onEmbedVideo(url, embedUrl);else onAttachVideo(url);
|
|
1369
|
+
onClose();
|
|
1370
|
+
};
|
|
1371
|
+
return /*#__PURE__*/jsx("div", {
|
|
1372
|
+
className: "ne-video-embed-form",
|
|
1373
|
+
children: /*#__PURE__*/jsx(Form, {
|
|
1374
|
+
formikProps: {
|
|
1375
|
+
initialValues: initialValues,
|
|
1376
|
+
validationSchema: VIDEO_EMBED_FORM_VALIDATION_SCHEMA,
|
|
1377
|
+
onSubmit: onSubmit
|
|
1378
|
+
},
|
|
1379
|
+
children: function children(_ref3) {
|
|
1380
|
+
var dirty = _ref3.dirty,
|
|
1381
|
+
isSubmitting = _ref3.isSubmitting,
|
|
1382
|
+
resetForm = _ref3.resetForm;
|
|
1383
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
1384
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
1385
|
+
className: "ne-video-embed-form__content",
|
|
1386
|
+
children: /*#__PURE__*/jsx(Input$1, {
|
|
1387
|
+
autoFocus: true,
|
|
1388
|
+
unlimitedChars: true,
|
|
1389
|
+
"data-testid": "neeto-editor-video-embed-input",
|
|
1390
|
+
label: t("neetoEditor.common.videoUrl"),
|
|
1391
|
+
name: "url",
|
|
1392
|
+
placeholder: t("neetoEditor.placeholders.embedUrl"),
|
|
1393
|
+
size: "medium",
|
|
1394
|
+
type: "text"
|
|
1395
|
+
})
|
|
1396
|
+
}), /*#__PURE__*/jsx(ActionBlock, {
|
|
1397
|
+
cancelButtonProps: {
|
|
1398
|
+
"data-testid": "neeto-editor-video-embed-cancel",
|
|
1399
|
+
label: t("neetoEditor.common.cancel"),
|
|
1400
|
+
size: "small",
|
|
1401
|
+
onClick: function onClick() {
|
|
1402
|
+
resetForm();
|
|
1403
|
+
onClose();
|
|
1404
|
+
}
|
|
1405
|
+
},
|
|
1406
|
+
submitButtonProps: {
|
|
1407
|
+
"data-testid": "neeto-editor-video-embed-submit",
|
|
1408
|
+
disabled: !dirty,
|
|
1409
|
+
label: t("neetoEditor.common.saveChanges"),
|
|
1410
|
+
loading: isSubmitting,
|
|
1411
|
+
size: "small"
|
|
1412
|
+
}
|
|
1413
|
+
})]
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
})
|
|
1417
|
+
});
|
|
1418
|
+
};
|
|
1419
|
+
|
|
1420
|
+
var MediaUploader = function MediaUploader(_ref) {
|
|
1421
|
+
var mediaUploader = _ref.mediaUploader,
|
|
1422
|
+
onClose = _ref.onClose,
|
|
1423
|
+
editor = _ref.editor,
|
|
1424
|
+
_ref$showAssetLibrary = _ref.showAssetLibrary,
|
|
1425
|
+
showAssetLibrary = _ref$showAssetLibrary === void 0 ? true : _ref$showAssetLibrary;
|
|
1426
|
+
var _useTranslation = useTranslation(),
|
|
1427
|
+
t = _useTranslation.t;
|
|
1428
|
+
var _useState = useState("local"),
|
|
1429
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1430
|
+
activeTab = _useState2[0],
|
|
1431
|
+
setActiveTab = _useState2[1];
|
|
1432
|
+
var _useState3 = useState(false),
|
|
1433
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1434
|
+
isUploading = _useState4[0],
|
|
1435
|
+
setIsUploading = _useState4[1];
|
|
1436
|
+
var isOpen = mediaUploader.image || mediaUploader.video;
|
|
1437
|
+
var _useState5 = useState([]),
|
|
1438
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1439
|
+
tabs = _useState6[0],
|
|
1440
|
+
setTabs = _useState6[1];
|
|
1441
|
+
useEffect(function () {
|
|
1442
|
+
isOpen && setTabs(getTabs(mediaUploader));
|
|
1443
|
+
}, [mediaUploader]);
|
|
1444
|
+
var handleClose = function handleClose() {
|
|
1445
|
+
onClose();
|
|
1446
|
+
setActiveTab("local");
|
|
1447
|
+
editor.commands.focus();
|
|
1448
|
+
};
|
|
1449
|
+
var insertMediaToEditor = function insertMediaToEditor(file) {
|
|
1450
|
+
if (!editor) return;
|
|
1451
|
+
var url = file.url,
|
|
1452
|
+
_file$filename = file.filename,
|
|
1453
|
+
filename = _file$filename === void 0 ? "image" : _file$filename,
|
|
1454
|
+
_file$caption = file.caption,
|
|
1455
|
+
caption = _file$caption === void 0 ? "" : _file$caption;
|
|
1456
|
+
var mediaAttrs = {
|
|
1457
|
+
src: url,
|
|
1458
|
+
caption: caption,
|
|
1459
|
+
alt: filename
|
|
1460
|
+
};
|
|
1461
|
+
var setMedia = mediaUploader.image ? editor.chain().setFigure(mediaAttrs) : editor.chain().setVideo(mediaAttrs);
|
|
1462
|
+
setMedia.focus().command(function (_ref2) {
|
|
1463
|
+
var tr = _ref2.tr,
|
|
1464
|
+
commands = _ref2.commands;
|
|
1465
|
+
var doc = tr.doc,
|
|
1466
|
+
selection = tr.selection;
|
|
1467
|
+
var position = doc.resolve(selection.to).end() + 1;
|
|
1468
|
+
var safePosition = Math.min(position, doc.content.size);
|
|
1469
|
+
return commands.insertContentAt(safePosition, "<p></p>");
|
|
1470
|
+
}).run();
|
|
1471
|
+
};
|
|
1472
|
+
var onUploadComplete = /*#__PURE__*/function () {
|
|
1473
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(file) {
|
|
1474
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1475
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1476
|
+
case 0:
|
|
1477
|
+
if (!(isNotPresent(file.id) && isNotPresent(file.signedId))) {
|
|
1478
|
+
_context.next = 2;
|
|
1479
|
+
break;
|
|
1480
|
+
}
|
|
1481
|
+
return _context.abrupt("return");
|
|
1482
|
+
case 2:
|
|
1483
|
+
_context.prev = 2;
|
|
1484
|
+
_context.next = 5;
|
|
1485
|
+
return directUploadsApi.attach({
|
|
1486
|
+
id: file.id,
|
|
1487
|
+
signed_id: file.signedId
|
|
1488
|
+
});
|
|
1489
|
+
case 5:
|
|
1490
|
+
insertMediaToEditor(file);
|
|
1491
|
+
handleClose();
|
|
1492
|
+
_context.next = 12;
|
|
1493
|
+
break;
|
|
1494
|
+
case 9:
|
|
1495
|
+
_context.prev = 9;
|
|
1496
|
+
_context.t0 = _context["catch"](2);
|
|
1497
|
+
Toastr.error(_context.t0);
|
|
1498
|
+
case 12:
|
|
1499
|
+
case "end":
|
|
1500
|
+
return _context.stop();
|
|
1501
|
+
}
|
|
1502
|
+
}, _callee, null, [[2, 9]]);
|
|
1503
|
+
}));
|
|
1504
|
+
return function onUploadComplete(_x) {
|
|
1505
|
+
return _ref3.apply(this, arguments);
|
|
1506
|
+
};
|
|
1507
|
+
}();
|
|
1508
|
+
var onAttachVideo = function onAttachVideo(url) {
|
|
1509
|
+
var file = {
|
|
1510
|
+
url: url};
|
|
1511
|
+
insertMediaToEditor(file);
|
|
1512
|
+
};
|
|
1513
|
+
var onEmbedVideo = function onEmbedVideo(originalUrl, embedUrl) {
|
|
1514
|
+
if (!editor) return;
|
|
1515
|
+
editor.chain().focus().setExternalVideo({
|
|
1516
|
+
src: embedUrl,
|
|
1517
|
+
originalUrl: originalUrl
|
|
1518
|
+
}).run();
|
|
1519
|
+
};
|
|
1520
|
+
return /*#__PURE__*/jsx(Modal, {
|
|
1521
|
+
isOpen: isOpen,
|
|
1522
|
+
className: "ne-media-uploader-modal",
|
|
1523
|
+
closeButton: not(isUploading),
|
|
1524
|
+
closeOnOutsideClick: not(isUploading),
|
|
1525
|
+
onClose: handleClose,
|
|
1526
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
1527
|
+
className: "ne-media-uploader",
|
|
1528
|
+
children: [(mediaUploader.video || mediaUploader.image) && /*#__PURE__*/jsx("div", {
|
|
1529
|
+
className: "ne-media-uploader__header",
|
|
1530
|
+
children: /*#__PURE__*/jsxs("h2", {
|
|
1531
|
+
className: "ne-media-uploader__header-title",
|
|
1532
|
+
children: [mediaUploader.video && t("neetoEditor.menu.addVideo"), mediaUploader.image && t("neetoEditor.menu.addImage")]
|
|
1533
|
+
})
|
|
1534
|
+
}), !isNotPresent(tabs) && /*#__PURE__*/jsx(Tab, {
|
|
1535
|
+
children: tabs.map(function (_ref4) {
|
|
1536
|
+
var key = _ref4.key,
|
|
1537
|
+
title = _ref4.title;
|
|
1538
|
+
return /*#__PURE__*/jsx(Tab.Item, {
|
|
1539
|
+
active: activeTab === key,
|
|
1540
|
+
"data-testid": "neeto-editor-media-uploader-".concat(key, "-tab"),
|
|
1541
|
+
onClick: function onClick() {
|
|
1542
|
+
return setActiveTab(key);
|
|
1543
|
+
},
|
|
1544
|
+
children: title
|
|
1545
|
+
}, key);
|
|
1546
|
+
})
|
|
1547
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
1548
|
+
className: "ne-media-uploader__content",
|
|
1549
|
+
children: [mediaUploader.image && /*#__PURE__*/jsx(ImageUploader, {
|
|
1550
|
+
onUploadComplete: onUploadComplete,
|
|
1551
|
+
showAssetLibrary: showAssetLibrary,
|
|
1552
|
+
className: "ne-media-uploader__image-uploader"
|
|
1553
|
+
}), mediaUploader.video && /*#__PURE__*/jsxs(Fragment, {
|
|
1554
|
+
children: [activeTab === "local" && /*#__PURE__*/jsx(LocalUploader, {
|
|
1555
|
+
insertMediaToEditor: insertMediaToEditor,
|
|
1556
|
+
setIsUploading: setIsUploading,
|
|
1557
|
+
isImage: false,
|
|
1558
|
+
onClose: handleClose
|
|
1559
|
+
}), activeTab === "embed" && /*#__PURE__*/jsx(VideoEmbedForm, {
|
|
1560
|
+
onAttachVideo: onAttachVideo,
|
|
1561
|
+
onEmbedVideo: onEmbedVideo,
|
|
1562
|
+
onClose: handleClose
|
|
1563
|
+
})]
|
|
1564
|
+
})]
|
|
1565
|
+
})]
|
|
1566
|
+
})
|
|
1567
|
+
});
|
|
1568
|
+
};
|
|
1569
|
+
|
|
1570
|
+
var LinkAddPopOver = function LinkAddPopOver(_ref) {
|
|
1571
|
+
var isAddLinkActive = _ref.isAddLinkActive,
|
|
1572
|
+
setIsAddLinkActive = _ref.setIsAddLinkActive,
|
|
1573
|
+
editor = _ref.editor,
|
|
1574
|
+
openLinkInNewTab = _ref.openLinkInNewTab;
|
|
1575
|
+
var _editor$state$selecti = editor.state.selection,
|
|
1576
|
+
from = _editor$state$selecti.from,
|
|
1577
|
+
to = _editor$state$selecti.to;
|
|
1578
|
+
var text = editor.state.doc.textBetween(from, to, "");
|
|
1579
|
+
var _useState = useState(text),
|
|
1580
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1581
|
+
linkText = _useState2[0],
|
|
1582
|
+
setLinkText = _useState2[1];
|
|
1583
|
+
var _useState3 = useState(""),
|
|
1584
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1585
|
+
linkUrl = _useState4[0],
|
|
1586
|
+
setLinkUrl = _useState4[1];
|
|
1587
|
+
var _useState5 = useState(openLinkInNewTab),
|
|
1588
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1589
|
+
openInNewTab = _useState6[0],
|
|
1590
|
+
setOpenInNewTab = _useState6[1];
|
|
1591
|
+
var _useState7 = useState(""),
|
|
1592
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
1593
|
+
error = _useState8[0],
|
|
1594
|
+
setError = _useState8[1];
|
|
1595
|
+
var _useState9 = useState(getCursorPos(editor, to)),
|
|
1596
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
1597
|
+
popoverPosition = _useState0[0],
|
|
1598
|
+
setPopoverPosition = _useState0[1];
|
|
1599
|
+
var _useState1 = useState({
|
|
1600
|
+
top: 0,
|
|
1601
|
+
left: 0
|
|
1602
|
+
}),
|
|
1603
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
1604
|
+
arrowPosition = _useState10[0],
|
|
1605
|
+
setArrowPosition = _useState10[1];
|
|
1606
|
+
var popoverRef = useRef(null);
|
|
1607
|
+
var _useTranslation = useTranslation(),
|
|
1608
|
+
t = _useTranslation.t;
|
|
1609
|
+
var isLinkTextPresent = !isNotPresent(linkText);
|
|
1610
|
+
var isLinlUrlPresent = !isNotPresent(linkUrl);
|
|
1611
|
+
var isSubmitDisabled = !isLinkTextPresent || !isLinlUrlPresent;
|
|
1612
|
+
var popoverStyle = {
|
|
1613
|
+
display: "block",
|
|
1614
|
+
position: "fixed",
|
|
1615
|
+
top: popoverPosition.top,
|
|
1616
|
+
left: popoverPosition.left,
|
|
1617
|
+
transform: "translateY(52px) translateX(8px)"
|
|
1618
|
+
};
|
|
1619
|
+
var handleAddLink = function handleAddLink() {
|
|
1620
|
+
var _editor$view = editor.view,
|
|
1621
|
+
state = _editor$view.state,
|
|
1622
|
+
dispatch = _editor$view.dispatch;
|
|
1623
|
+
var _state$selection = state.selection,
|
|
1624
|
+
from = _state$selection.from,
|
|
1625
|
+
to = _state$selection.to;
|
|
1626
|
+
var formattedUrl = validateAndFormatUrl(linkUrl);
|
|
1627
|
+
if (!ALL_PROTOCOL_URL_REGEXP.test(formattedUrl)) {
|
|
1628
|
+
setError(t("neetoEditor.error.invalidUrl"));
|
|
1629
|
+
return;
|
|
1630
|
+
}
|
|
1631
|
+
var attrs = {
|
|
1632
|
+
href: formattedUrl,
|
|
1633
|
+
target: openInNewTab ? "_blank" : "_self"
|
|
1634
|
+
};
|
|
1635
|
+
var linkMark = state.schema.marks.link.create(attrs);
|
|
1636
|
+
var linkTextWithMark = state.schema.text(linkText, [linkMark]);
|
|
1637
|
+
var tr = state.tr.replaceWith(from, to, linkTextWithMark);
|
|
1638
|
+
dispatch(tr);
|
|
1639
|
+
removePopover();
|
|
1640
|
+
};
|
|
1641
|
+
var removePopover = function removePopover() {
|
|
1642
|
+
editor.view.focus();
|
|
1643
|
+
setIsAddLinkActive(false);
|
|
1644
|
+
};
|
|
1645
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
1646
|
+
e.stopPropagation();
|
|
1647
|
+
if (e.key === "Enter") {
|
|
1648
|
+
e.preventDefault();
|
|
1649
|
+
handleAddLink();
|
|
1650
|
+
} else if (e.key === "Escape") {
|
|
1651
|
+
removePopover();
|
|
1652
|
+
}
|
|
1653
|
+
};
|
|
1654
|
+
var updatePopoverPosition = function updatePopoverPosition() {
|
|
1655
|
+
var _getLinkPopoverPositi = getLinkPopoverPosition(editor, popoverRef),
|
|
1656
|
+
arrowPosition = _getLinkPopoverPositi.arrowPosition,
|
|
1657
|
+
popoverPosition = _getLinkPopoverPositi.popoverPosition;
|
|
1658
|
+
setPopoverPosition(popoverPosition);
|
|
1659
|
+
setArrowPosition(arrowPosition);
|
|
1660
|
+
};
|
|
1661
|
+
useOnClickOutside(popoverRef, removePopover);
|
|
1662
|
+
useEffect(function () {
|
|
1663
|
+
if (editor && isAddLinkActive) {
|
|
1664
|
+
updatePopoverPosition();
|
|
1665
|
+
}
|
|
1666
|
+
window.addEventListener("resize", removePopover);
|
|
1667
|
+
window.addEventListener("wheel", removePopover);
|
|
1668
|
+
return function () {
|
|
1669
|
+
window.removeEventListener("resize", removePopover);
|
|
1670
|
+
window.removeEventListener("wheel", removePopover);
|
|
1671
|
+
};
|
|
1672
|
+
}, []);
|
|
1673
|
+
return isAddLinkActive ? /*#__PURE__*/createPortal(/*#__PURE__*/jsxs(Fragment, {
|
|
1674
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
1675
|
+
className: "ne-link-arrow fade-in",
|
|
1676
|
+
style: {
|
|
1677
|
+
top: arrowPosition.top,
|
|
1678
|
+
left: arrowPosition.left
|
|
1679
|
+
}
|
|
1680
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
1681
|
+
className: "ne-link-popover fade-in",
|
|
1682
|
+
id: "ne-link-add-popover",
|
|
1683
|
+
ref: popoverRef,
|
|
1684
|
+
style: popoverStyle,
|
|
1685
|
+
children: [/*#__PURE__*/jsx(Input, {
|
|
1686
|
+
required: true,
|
|
1687
|
+
autoFocus: !isLinkTextPresent,
|
|
1688
|
+
"data-testid": "neeto-editor-add-link-text-input",
|
|
1689
|
+
label: t("neetoEditor.common.text"),
|
|
1690
|
+
placeholder: t("neetoEditor.placeholders.enterText"),
|
|
1691
|
+
size: "small",
|
|
1692
|
+
style: {
|
|
1693
|
+
width: "250px"
|
|
1694
|
+
},
|
|
1695
|
+
value: linkText,
|
|
1696
|
+
onChange: function onChange(_ref2) {
|
|
1697
|
+
var value = _ref2.target.value;
|
|
1698
|
+
return setLinkText(value);
|
|
1699
|
+
},
|
|
1700
|
+
onKeyDown: handleKeyDown
|
|
1701
|
+
}), /*#__PURE__*/jsx(Input, {
|
|
1702
|
+
error: error,
|
|
1703
|
+
required: true,
|
|
1704
|
+
autoFocus: isLinkTextPresent,
|
|
1705
|
+
className: "ne-link-popover__url-input",
|
|
1706
|
+
"data-testid": "neeto-editor-add-link-url-input",
|
|
1707
|
+
label: t("neetoEditor.common.url"),
|
|
1708
|
+
placeholder: t("neetoEditor.placeholders.url"),
|
|
1709
|
+
size: "small",
|
|
1710
|
+
style: {
|
|
1711
|
+
width: "250px"
|
|
1712
|
+
},
|
|
1713
|
+
value: linkUrl,
|
|
1714
|
+
onChange: function onChange(_ref3) {
|
|
1715
|
+
var value = _ref3.target.value;
|
|
1716
|
+
return setLinkUrl(value);
|
|
1717
|
+
},
|
|
1718
|
+
onFocus: function onFocus() {
|
|
1719
|
+
return setError("");
|
|
1720
|
+
},
|
|
1721
|
+
onKeyDown: handleKeyDown
|
|
1722
|
+
}), /*#__PURE__*/jsx(Checkbox, {
|
|
1723
|
+
checked: openInNewTab,
|
|
1724
|
+
className: "ne-link-popover__checkbox",
|
|
1725
|
+
"data-testid": "neeto-editor-add-link-open-in-new-tab-switch",
|
|
1726
|
+
label: t("neetoEditor.common.openInNewTab"),
|
|
1727
|
+
onChange: function onChange() {
|
|
1728
|
+
return setOpenInNewTab(not);
|
|
1729
|
+
}
|
|
1730
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
1731
|
+
className: "ne-link-popover__edit-prompt-buttons",
|
|
1732
|
+
children: [/*#__PURE__*/jsx(Button$1, {
|
|
1733
|
+
"data-testid": "neeto-editor-add-link",
|
|
1734
|
+
disabled: isSubmitDisabled,
|
|
1735
|
+
label: t("neetoEditor.common.done"),
|
|
1736
|
+
size: "small",
|
|
1737
|
+
onClick: handleAddLink
|
|
1738
|
+
}), /*#__PURE__*/jsx(Button$1, {
|
|
1739
|
+
"data-testid": "neeto-editor-link-popover-cancel",
|
|
1740
|
+
label: t("neetoEditor.common.cancel"),
|
|
1741
|
+
size: "small",
|
|
1742
|
+
style: "text",
|
|
1743
|
+
onClick: removePopover
|
|
1744
|
+
})]
|
|
1745
|
+
})]
|
|
1746
|
+
})]
|
|
1747
|
+
}), document.body) : null;
|
|
1748
|
+
};
|
|
1749
|
+
|
|
1750
|
+
var _excluded$3 = ["type"];
|
|
1751
|
+
function ownKeys$8(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1752
|
+
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1753
|
+
var Menu$3 = Dropdown$1.Menu,
|
|
1754
|
+
MenuItem$1 = Dropdown$1.MenuItem;
|
|
1755
|
+
var MoreMenu = function MoreMenu(_ref) {
|
|
1756
|
+
var groups = _ref.groups,
|
|
1757
|
+
editor = _ref.editor;
|
|
1758
|
+
return /*#__PURE__*/jsx(Dropdown$1, {
|
|
1759
|
+
buttonProps: {
|
|
1760
|
+
className: "flex-shrink-0"
|
|
1761
|
+
},
|
|
1762
|
+
buttonStyle: "text",
|
|
1763
|
+
icon: MenuHorizontal,
|
|
1764
|
+
strategy: "fixed",
|
|
1765
|
+
children: /*#__PURE__*/jsx(Menu$3, {
|
|
1766
|
+
children: groups.map(function (group) {
|
|
1767
|
+
return group.map(function (_ref2) {
|
|
1768
|
+
var type = _ref2.type,
|
|
1769
|
+
props = _objectWithoutProperties(_ref2, _excluded$3);
|
|
1770
|
+
var Component = MENU_ELEMENTS[type];
|
|
1771
|
+
if (type === MENU_ELEMENT_TYPES.BUTTON) {
|
|
1772
|
+
var Icon = props.icon;
|
|
1773
|
+
return /*#__PURE__*/jsxs(MenuItem$1.Button, _objectSpread$8(_objectSpread$8({
|
|
1774
|
+
"data-testid": "neeto-editor-fixed-menu-".concat(props.optionName, "-option"),
|
|
1775
|
+
isActive: editor.isActive(props.optionName),
|
|
1776
|
+
tabIndex: "-1",
|
|
1777
|
+
onClick: props.command
|
|
1778
|
+
}, _objectSpread$8(_objectSpread$8(_objectSpread$8({}, generateFocusProps(props.highlight)), props), {}, {
|
|
1779
|
+
editor: editor
|
|
1780
|
+
})), {}, {
|
|
1781
|
+
children: [/*#__PURE__*/jsx(Icon, {}), " ", props.label]
|
|
1782
|
+
}), props.optionName);
|
|
1783
|
+
}
|
|
1784
|
+
return /*#__PURE__*/jsx(Component, _objectSpread$8(_objectSpread$8({}, _objectSpread$8(_objectSpread$8({}, props), {}, {
|
|
1785
|
+
editor: editor
|
|
1786
|
+
}, generateFocusProps(props.highlight))), {}, {
|
|
1787
|
+
isSecondaryMenu: true
|
|
1788
|
+
}), props.optionName);
|
|
1789
|
+
});
|
|
1790
|
+
})
|
|
1791
|
+
})
|
|
1792
|
+
});
|
|
1793
|
+
};
|
|
1794
|
+
|
|
1795
|
+
var EDITOR_MARKS = [EDITOR_OPTIONS.UNDO, EDITOR_OPTIONS.REDO, "fontSizeOptions", EDITOR_OPTIONS.BOLD, EDITOR_OPTIONS.ITALIC, EDITOR_OPTIONS.UNDERLINE, EDITOR_OPTIONS.LINK, EDITOR_OPTIONS.STRIKETHROUGH, EDITOR_OPTIONS.HIGHLIGHT, EDITOR_OPTIONS.CALLOUT, "bulletList", "orderedList", "todoList", "blockquote", EDITOR_OPTIONS.CODE, "codeBlock", EDITOR_OPTIONS.TABLE, EDITOR_OPTIONS.ATTACHMENTS, EDITOR_OPTIONS.IMAGE_UPLOAD, EDITOR_OPTIONS.VIDEO_UPLOAD, EDITOR_OPTIONS.TEXT_COLOR, EDITOR_OPTIONS.EMOJI, EDITOR_OPTIONS.NEETO_KB_ARTICLE, "mentions"];
|
|
1796
|
+
|
|
1797
|
+
function ownKeys$7(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1798
|
+
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1799
|
+
var useEditorState = function useEditorState(_ref) {
|
|
1800
|
+
var editor = _ref.editor,
|
|
1801
|
+
neetoKbArticleState = _ref.neetoKbArticleState;
|
|
1802
|
+
var _useEditorStore = useEditorStore(function (store) {
|
|
1803
|
+
return {
|
|
1804
|
+
setMarksState: store["setMarksState"],
|
|
1805
|
+
marksState: store["marksState"]
|
|
1806
|
+
};
|
|
1807
|
+
}, shallow),
|
|
1808
|
+
setMarksState = _useEditorStore.setMarksState,
|
|
1809
|
+
marksState = _useEditorStore.marksState;
|
|
1810
|
+
var handleSelectionUpdate = useCallback(function (_ref2) {
|
|
1811
|
+
var editor = _ref2.editor;
|
|
1812
|
+
var activeMarks = {};
|
|
1813
|
+
EDITOR_MARKS.forEach(function (mark) {
|
|
1814
|
+
if (mark === EDITOR_OPTIONS.NEETO_KB_ARTICLE) {
|
|
1815
|
+
activeMarks[mark] = {
|
|
1816
|
+
isActive: (neetoKbArticleState === null || neetoKbArticleState === void 0 ? void 0 : neetoKbArticleState.active) || false
|
|
1817
|
+
};
|
|
1818
|
+
} else {
|
|
1819
|
+
activeMarks[mark] = {
|
|
1820
|
+
isActive: editor.isActive(mark)
|
|
1821
|
+
};
|
|
1822
|
+
}
|
|
1823
|
+
});
|
|
1824
|
+
var activeFontSizeOption = FONT_SIZE_OPTIONS.find(function (_ref3) {
|
|
1825
|
+
var level = _ref3.value;
|
|
1826
|
+
return editor.isActive("heading", {
|
|
1827
|
+
level: level
|
|
1828
|
+
});
|
|
1829
|
+
}) || last(FONT_SIZE_OPTIONS);
|
|
1830
|
+
activeMarks["fontSizeOption"] = activeFontSizeOption;
|
|
1831
|
+
setMarksState(activeMarks);
|
|
1832
|
+
}, [setMarksState, neetoKbArticleState === null || neetoKbArticleState === void 0 ? void 0 : neetoKbArticleState.active]);
|
|
1833
|
+
var updateHistoryOptionsState = useCallback(function (_ref4) {
|
|
1834
|
+
var editor = _ref4.editor;
|
|
1835
|
+
var undoOptionState = {
|
|
1836
|
+
disabled: !editor.can().undo()
|
|
1837
|
+
};
|
|
1838
|
+
var redoOptionState = {
|
|
1839
|
+
disabled: !editor.can().redo()
|
|
1840
|
+
};
|
|
1841
|
+
var updatedMarksState = _objectSpread$7(_objectSpread$7({}, marksState), {}, _defineProperty(_defineProperty({}, EDITOR_OPTIONS.UNDO, undoOptionState), EDITOR_OPTIONS.REDO, redoOptionState));
|
|
1842
|
+
setMarksState(updatedMarksState);
|
|
1843
|
+
}, [marksState, setMarksState]);
|
|
1844
|
+
useEffect(function () {
|
|
1845
|
+
if (!editor) return noop;
|
|
1846
|
+
updateHistoryOptionsState({
|
|
1847
|
+
editor: editor
|
|
1848
|
+
});
|
|
1849
|
+
editor.on("selectionUpdate", handleSelectionUpdate);
|
|
1850
|
+
editor.on("update", handleSelectionUpdate);
|
|
1851
|
+
editor.on("transaction", handleSelectionUpdate);
|
|
1852
|
+
return function () {
|
|
1853
|
+
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
1854
|
+
editor.off("update", handleSelectionUpdate);
|
|
1855
|
+
editor.off("transaction", handleSelectionUpdate);
|
|
1856
|
+
};
|
|
1857
|
+
}, [editor, handleSelectionUpdate]);
|
|
1858
|
+
|
|
1859
|
+
// Update editor state when neetoKbArticleState changes
|
|
1860
|
+
useEffect(function () {
|
|
1861
|
+
if (!editor) return;
|
|
1862
|
+
handleSelectionUpdate({
|
|
1863
|
+
editor: editor
|
|
1864
|
+
});
|
|
1865
|
+
}, [editor, neetoKbArticleState === null || neetoKbArticleState === void 0 ? void 0 : neetoKbArticleState.active, handleSelectionUpdate]);
|
|
1866
|
+
};
|
|
1867
|
+
|
|
1868
|
+
var MenuDynamicVariables = function MenuDynamicVariables(_ref) {
|
|
1869
|
+
var editor = _ref.editor,
|
|
1870
|
+
_ref$variables = _ref.variables,
|
|
1871
|
+
variables = _ref$variables === void 0 ? [] : _ref$variables,
|
|
1872
|
+
_ref$standalone = _ref.standalone,
|
|
1873
|
+
standalone = _ref$standalone === void 0 ? false : _ref$standalone;
|
|
1874
|
+
var _useTranslation = useTranslation(),
|
|
1875
|
+
t = _useTranslation.t;
|
|
1876
|
+
if (isEmpty(variables)) return null;
|
|
1877
|
+
var handleVariableClick = function handleVariableClick(item) {
|
|
1878
|
+
var category = item.category,
|
|
1879
|
+
categoryLabel = item.categoryLabel,
|
|
1880
|
+
key = item.key,
|
|
1881
|
+
label = item.label;
|
|
1882
|
+
var variableName = category ? "".concat(category, ".").concat(key) : key;
|
|
1883
|
+
var variableLabel = category ? "".concat(categoryLabel || category, ":").concat(label) : label;
|
|
1884
|
+
editor.chain().focus().setVariable({
|
|
1885
|
+
id: variableName,
|
|
1886
|
+
label: variableLabel
|
|
1887
|
+
}).run();
|
|
1888
|
+
};
|
|
1889
|
+
return /*#__PURE__*/jsx("div", {
|
|
1890
|
+
"data-testid": "neeto-editor-fixed-menu-variables",
|
|
1891
|
+
className: classnames("neeto-editor-fixed-menu__variables", {
|
|
1892
|
+
"neeto-editor-fixed-menu__variables--standalone": standalone
|
|
1893
|
+
}),
|
|
1894
|
+
children: /*#__PURE__*/jsx(DynamicVariables, {
|
|
1895
|
+
variables: variables,
|
|
1896
|
+
dropdownProps: {
|
|
1897
|
+
buttonSize: "small",
|
|
1898
|
+
buttonProps: {
|
|
1899
|
+
tooltipProps: {
|
|
1900
|
+
content: t("neetoEditor.menu.dynamicVariables"),
|
|
1901
|
+
position: "bottom"
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
},
|
|
1905
|
+
onVariableClick: handleVariableClick
|
|
1906
|
+
})
|
|
1907
|
+
});
|
|
1908
|
+
};
|
|
1909
|
+
|
|
1910
|
+
var _excluded$2 = ["type"];
|
|
1911
|
+
function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1912
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1913
|
+
var Fixed = function Fixed(_ref) {
|
|
1914
|
+
var editor = _ref.editor,
|
|
1915
|
+
options = _ref.options,
|
|
1916
|
+
mentions = _ref.mentions,
|
|
1917
|
+
_ref$variables = _ref.variables,
|
|
1918
|
+
variables = _ref$variables === void 0 ? [] : _ref$variables,
|
|
1919
|
+
setMediaUploader = _ref.setMediaUploader,
|
|
1920
|
+
mediaUploader = _ref.mediaUploader,
|
|
1921
|
+
_ref$addonCommands = _ref.addonCommands,
|
|
1922
|
+
addonCommands = _ref$addonCommands === void 0 ? [] : _ref$addonCommands,
|
|
1923
|
+
_ref$isIndependant = _ref.isIndependant,
|
|
1924
|
+
isIndependant = _ref$isIndependant === void 0 ? true : _ref$isIndependant,
|
|
1925
|
+
className = _ref.className,
|
|
1926
|
+
_ref$tooltips = _ref.tooltips,
|
|
1927
|
+
tooltips = _ref$tooltips === void 0 ? {} : _ref$tooltips,
|
|
1928
|
+
attachmentProps = _ref.attachmentProps,
|
|
1929
|
+
isEmojiPickerActive = _ref.isEmojiPickerActive,
|
|
1930
|
+
setIsEmojiPickerActive = _ref.setIsEmojiPickerActive,
|
|
1931
|
+
openLinkInNewTab = _ref.openLinkInNewTab,
|
|
1932
|
+
setIsNeetoKbArticleActive = _ref.setIsNeetoKbArticleActive,
|
|
1933
|
+
neetoKbArticleState = _ref.neetoKbArticleState,
|
|
1934
|
+
_ref$showAssetLibrary = _ref.showAssetLibrary,
|
|
1935
|
+
showAssetLibrary = _ref$showAssetLibrary === void 0 ? true : _ref$showAssetLibrary;
|
|
1936
|
+
var _useState = useState(0),
|
|
1937
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1938
|
+
focusedButtonIndex = _useState2[0],
|
|
1939
|
+
setFocusedButtonIndex = _useState2[1];
|
|
1940
|
+
var _useState3 = useState(false),
|
|
1941
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1942
|
+
isAddLinkActive = _useState4[0],
|
|
1943
|
+
setIsAddLinkActive = _useState4[1];
|
|
1944
|
+
var _useState5 = useState([]),
|
|
1945
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1946
|
+
menuItems = _useState6[0],
|
|
1947
|
+
setMenuItems = _useState6[1];
|
|
1948
|
+
var _useState7 = useState([]),
|
|
1949
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
1950
|
+
moreMenuItems = _useState8[0],
|
|
1951
|
+
setMoreMenuItems = _useState8[1];
|
|
1952
|
+
useEditorState({
|
|
1953
|
+
editor: editor,
|
|
1954
|
+
neetoKbArticleState: neetoKbArticleState
|
|
1955
|
+
});
|
|
1956
|
+
var editorRef = useRef(editor);
|
|
1957
|
+
useEffect(function () {
|
|
1958
|
+
editorRef.current = editor;
|
|
1959
|
+
}, [editor]);
|
|
1960
|
+
var menuRef = useRef(null);
|
|
1961
|
+
var menuContainerRef = useRef(null);
|
|
1962
|
+
var runEditorCommand = useCallback(function (command) {
|
|
1963
|
+
return function () {
|
|
1964
|
+
return command(editorRef.current);
|
|
1965
|
+
};
|
|
1966
|
+
}, []);
|
|
1967
|
+
var handleArrowNavigation = function handleArrowNavigation(event) {
|
|
1968
|
+
if (event.key === "ArrowRight") {
|
|
1969
|
+
event.preventDefault();
|
|
1970
|
+
setFocusedButtonIndex(function (prevIndex) {
|
|
1971
|
+
return (prevIndex + 1) % menuButtons.length;
|
|
1972
|
+
});
|
|
1973
|
+
} else if (event.key === "ArrowLeft") {
|
|
1974
|
+
event.preventDefault();
|
|
1975
|
+
setFocusedButtonIndex(function (prevIndex) {
|
|
1976
|
+
return (prevIndex - 1 + menuButtons.length) % menuButtons.length;
|
|
1977
|
+
});
|
|
1978
|
+
}
|
|
1979
|
+
};
|
|
1980
|
+
var menuButtons = useMemo(function () {
|
|
1981
|
+
var _menuRef$current;
|
|
1982
|
+
return (_menuRef$current = menuRef.current) === null || _menuRef$current === void 0 ? void 0 : _menuRef$current.querySelectorAll(".neeto-editor-fixed-menu__item");
|
|
1983
|
+
}, [menuRef.current]);
|
|
1984
|
+
useEffect(function () {
|
|
1985
|
+
menuButtons === null || menuButtons === void 0 || menuButtons[focusedButtonIndex].focus();
|
|
1986
|
+
}, [focusedButtonIndex]);
|
|
1987
|
+
useEffect(function () {
|
|
1988
|
+
menuButtons === null || menuButtons === void 0 || menuButtons.forEach(function (menuItem) {
|
|
1989
|
+
return menuItem.addEventListener("keydown", handleArrowNavigation);
|
|
1990
|
+
});
|
|
1991
|
+
return function () {
|
|
1992
|
+
return menuButtons === null || menuButtons === void 0 ? void 0 : menuButtons.forEach(function (menuItem) {
|
|
1993
|
+
return menuItem.removeEventListener("keydown", handleArrowNavigation);
|
|
1994
|
+
});
|
|
1995
|
+
};
|
|
1996
|
+
}, [menuButtons]);
|
|
1997
|
+
var menuGroups = useMemo(function () {
|
|
1998
|
+
return buildMenuOptions({
|
|
1999
|
+
tooltips: tooltips,
|
|
2000
|
+
runEditorCommand: runEditorCommand,
|
|
2001
|
+
options: options,
|
|
2002
|
+
setMediaUploader: setMediaUploader,
|
|
2003
|
+
attachmentProps: attachmentProps,
|
|
2004
|
+
setIsAddLinkActive: setIsAddLinkActive,
|
|
2005
|
+
mentions: mentions,
|
|
2006
|
+
addonCommands: addonCommands,
|
|
2007
|
+
setIsEmojiPickerActive: setIsEmojiPickerActive,
|
|
2008
|
+
isEmojiPickerActive: isEmojiPickerActive,
|
|
2009
|
+
editor: editor,
|
|
2010
|
+
setIsNeetoKbArticleActive: setIsNeetoKbArticleActive
|
|
2011
|
+
});
|
|
2012
|
+
}, [isEmojiPickerActive, mentions]);
|
|
2013
|
+
var handleResize = useCallback(function () {
|
|
2014
|
+
if (!menuRef.current) return;
|
|
2015
|
+
var _reGroupMenuItems = reGroupMenuItems(menuRef, menuGroups),
|
|
2016
|
+
visibleMenuGroups = _reGroupMenuItems.visibleMenuGroups,
|
|
2017
|
+
invisibleMenuGroups = _reGroupMenuItems.invisibleMenuGroups;
|
|
2018
|
+
setMenuItems(visibleMenuGroups);
|
|
2019
|
+
setMoreMenuItems(invisibleMenuGroups);
|
|
2020
|
+
}, [setMenuItems, menuGroups, menuRef.current]);
|
|
2021
|
+
useEffect(function () {
|
|
2022
|
+
handleResize();
|
|
2023
|
+
var menuContainer = menuContainerRef.current;
|
|
2024
|
+
var resizeObserver = new ResizeObserver(handleResize);
|
|
2025
|
+
if (menuContainer) {
|
|
2026
|
+
resizeObserver.observe(menuContainer);
|
|
2027
|
+
}
|
|
2028
|
+
return function () {
|
|
2029
|
+
if (menuContainer) resizeObserver.unobserve(menuContainer);
|
|
2030
|
+
};
|
|
2031
|
+
}, [menuContainerRef.current, handleResize, menuGroups]);
|
|
2032
|
+
if (!editor) return null;
|
|
2033
|
+
var isMediaUploaderActive = options.includes(EDITOR_OPTIONS.IMAGE_UPLOAD) || options.includes(EDITOR_OPTIONS.VIDEO_UPLOAD);
|
|
2034
|
+
return /*#__PURE__*/jsxs("div", {
|
|
2035
|
+
ref: menuContainerRef,
|
|
2036
|
+
className: classnames("neeto-editor-fixed-menu", _defineProperty({
|
|
2037
|
+
"neeto-editor-fixed-menu--independant": isIndependant
|
|
2038
|
+
}, className, className)),
|
|
2039
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
2040
|
+
className: "neeto-editor-fixed-menu__wrapper",
|
|
2041
|
+
"data-testid": "neeto-editor-fixed-menu-wrapper",
|
|
2042
|
+
ref: menuRef,
|
|
2043
|
+
children: [menuItems.map(function (group) {
|
|
2044
|
+
return group.map(function (_ref2) {
|
|
2045
|
+
var type = _ref2.type,
|
|
2046
|
+
props = _objectWithoutProperties(_ref2, _excluded$2);
|
|
2047
|
+
var Component = MENU_ELEMENTS[type];
|
|
2048
|
+
if (!Component) return null;
|
|
2049
|
+
return /*#__PURE__*/jsx(Component, _objectSpread$6({}, _objectSpread$6(_objectSpread$6({}, props), {}, {
|
|
2050
|
+
editor: editor,
|
|
2051
|
+
options: options
|
|
2052
|
+
})), props.optionName);
|
|
2053
|
+
});
|
|
2054
|
+
}), isNotEmpty(moreMenuItems) && /*#__PURE__*/jsx(MoreMenu, {
|
|
2055
|
+
editor: editor,
|
|
2056
|
+
groups: moreMenuItems
|
|
2057
|
+
})]
|
|
2058
|
+
}), /*#__PURE__*/jsx(MenuDynamicVariables, {
|
|
2059
|
+
editor: editor,
|
|
2060
|
+
variables: variables
|
|
2061
|
+
}), isAddLinkActive && /*#__PURE__*/jsx(LinkAddPopOver, {
|
|
2062
|
+
editor: editor,
|
|
2063
|
+
isAddLinkActive: isAddLinkActive,
|
|
2064
|
+
openLinkInNewTab: openLinkInNewTab,
|
|
2065
|
+
setIsAddLinkActive: setIsAddLinkActive
|
|
2066
|
+
}), isMediaUploaderActive && /*#__PURE__*/jsx(MediaUploader, {
|
|
2067
|
+
editor: editor,
|
|
2068
|
+
mediaUploader: mediaUploader,
|
|
2069
|
+
showAssetLibrary: showAssetLibrary,
|
|
2070
|
+
onClose: function onClose() {
|
|
2071
|
+
return setMediaUploader({
|
|
2072
|
+
image: false,
|
|
2073
|
+
video: false
|
|
2074
|
+
});
|
|
2075
|
+
}
|
|
2076
|
+
})]
|
|
2077
|
+
});
|
|
2078
|
+
};
|
|
2079
|
+
|
|
2080
|
+
var _excluded$1 = ["icon", "onClick", "disabled", "className", "tooltipProps"];
|
|
2081
|
+
function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2082
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2083
|
+
var Button = function Button(_ref) {
|
|
2084
|
+
var _ref$icon = _ref.icon,
|
|
2085
|
+
icon = _ref$icon === void 0 ? null : _ref$icon,
|
|
2086
|
+
_ref$onClick = _ref.onClick,
|
|
2087
|
+
_onClick = _ref$onClick === void 0 ? noop : _ref$onClick,
|
|
2088
|
+
_ref$disabled = _ref.disabled,
|
|
2089
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
2090
|
+
className = _ref.className,
|
|
2091
|
+
tooltipProps = _ref.tooltipProps,
|
|
2092
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$1);
|
|
2093
|
+
var Icon = icon;
|
|
2094
|
+
return /*#__PURE__*/jsx(Tooltip, _objectSpread$5(_objectSpread$5({
|
|
2095
|
+
disabled: !tooltipProps,
|
|
2096
|
+
onClick: function onClick() {
|
|
2097
|
+
return _onClick();
|
|
2098
|
+
}
|
|
2099
|
+
}, tooltipProps), {}, {
|
|
2100
|
+
children: /*#__PURE__*/jsx("button", _objectSpread$5(_objectSpread$5({
|
|
2101
|
+
className: classnames("ne-headless-btn", _defineProperty({}, className, className)),
|
|
2102
|
+
type: "button"
|
|
2103
|
+
}, _objectSpread$5({
|
|
2104
|
+
disabled: disabled,
|
|
2105
|
+
onClick: _onClick
|
|
2106
|
+
}, otherProps)), {}, {
|
|
2107
|
+
children: icon && /*#__PURE__*/jsx(Icon, {
|
|
2108
|
+
"aria-hidden": "true",
|
|
2109
|
+
size: 18
|
|
2110
|
+
}, "2")
|
|
2111
|
+
}))
|
|
2112
|
+
}));
|
|
2113
|
+
};
|
|
2114
|
+
|
|
2115
|
+
var _excluded = ["icon", "isOpen", "onClose", "children", "className", "onClick", "buttonProps"];
|
|
2116
|
+
function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2117
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2118
|
+
var hideOnEsc = {
|
|
2119
|
+
name: "hideOnEsc",
|
|
2120
|
+
defaultValue: true,
|
|
2121
|
+
fn: function fn(_ref) {
|
|
2122
|
+
var hide = _ref.hide,
|
|
2123
|
+
_ref$props = _ref.props,
|
|
2124
|
+
hideOnEsc = _ref$props.hideOnEsc,
|
|
2125
|
+
onClose = _ref$props.onClose;
|
|
2126
|
+
function onKeyDown(event) {
|
|
2127
|
+
if (!(event.key.toLowerCase() === "escape" && hideOnEsc)) return;
|
|
2128
|
+
onClose();
|
|
2129
|
+
hide();
|
|
2130
|
+
}
|
|
2131
|
+
return {
|
|
2132
|
+
onShow: function onShow() {
|
|
2133
|
+
document.addEventListener("keydown", onKeyDown);
|
|
2134
|
+
},
|
|
2135
|
+
onHide: function onHide() {
|
|
2136
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
2137
|
+
}
|
|
2138
|
+
};
|
|
2139
|
+
}
|
|
2140
|
+
};
|
|
2141
|
+
var Dropdown = function Dropdown(_ref2) {
|
|
2142
|
+
var icon = _ref2.icon,
|
|
2143
|
+
isOpen = _ref2.isOpen,
|
|
2144
|
+
_ref2$onClose = _ref2.onClose,
|
|
2145
|
+
onClose = _ref2$onClose === void 0 ? noop : _ref2$onClose,
|
|
2146
|
+
children = _ref2.children,
|
|
2147
|
+
className = _ref2.className,
|
|
2148
|
+
onClick = _ref2.onClick,
|
|
2149
|
+
_ref2$buttonProps = _ref2.buttonProps,
|
|
2150
|
+
buttonProps = _ref2$buttonProps === void 0 ? {} : _ref2$buttonProps,
|
|
2151
|
+
otherProps = _objectWithoutProperties(_ref2, _excluded);
|
|
2152
|
+
var _useState = useState(false),
|
|
2153
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2154
|
+
mounted = _useState2[0],
|
|
2155
|
+
setMounted = _useState2[1];
|
|
2156
|
+
return /*#__PURE__*/jsx(Tippy, _objectSpread$4(_objectSpread$4({
|
|
2157
|
+
onClose: onClose,
|
|
2158
|
+
hideOnEsc: true,
|
|
2159
|
+
interactive: true,
|
|
2160
|
+
animation: false,
|
|
2161
|
+
arrow: false,
|
|
2162
|
+
duration: 0,
|
|
2163
|
+
hideOnClick: false,
|
|
2164
|
+
maxWidth: "none",
|
|
2165
|
+
offset: 0,
|
|
2166
|
+
plugins: [hideOnEsc],
|
|
2167
|
+
popperOptions: {
|
|
2168
|
+
strategy: "fixed"
|
|
2169
|
+
},
|
|
2170
|
+
role: "dropdown",
|
|
2171
|
+
theme: "light",
|
|
2172
|
+
trigger: "click",
|
|
2173
|
+
visible: isOpen,
|
|
2174
|
+
className: classnames("ne-headless-dropdown", _defineProperty({}, className, className)),
|
|
2175
|
+
content: mounted && /*#__PURE__*/jsx("div", {
|
|
2176
|
+
className: "ne-headless-dropdown__popup",
|
|
2177
|
+
children: children
|
|
2178
|
+
}),
|
|
2179
|
+
onClickOutside: onClose,
|
|
2180
|
+
onHidden: function onHidden() {
|
|
2181
|
+
return setMounted(false);
|
|
2182
|
+
},
|
|
2183
|
+
onMount: function onMount() {
|
|
2184
|
+
return setMounted(true);
|
|
2185
|
+
}
|
|
2186
|
+
}, otherProps), {}, {
|
|
2187
|
+
children: /*#__PURE__*/jsx("span", {
|
|
2188
|
+
children: /*#__PURE__*/jsx(Button, _objectSpread$4({}, _objectSpread$4({
|
|
2189
|
+
icon: icon,
|
|
2190
|
+
onClick: onClick
|
|
2191
|
+
}, buttonProps)))
|
|
2192
|
+
})
|
|
2193
|
+
}));
|
|
2194
|
+
};
|
|
2195
|
+
|
|
2196
|
+
var Emoji = function Emoji(_ref) {
|
|
2197
|
+
var editor = _ref.editor,
|
|
2198
|
+
isActive = _ref.isActive,
|
|
2199
|
+
setActive = _ref.setActive,
|
|
2200
|
+
tooltipContent = _ref.tooltipContent;
|
|
2201
|
+
return /*#__PURE__*/jsx(Dropdown, {
|
|
2202
|
+
className: "ne-headless__emoji",
|
|
2203
|
+
icon: Smiley,
|
|
2204
|
+
isOpen: isActive,
|
|
2205
|
+
buttonProps: {
|
|
2206
|
+
tooltipProps: {
|
|
2207
|
+
content: tooltipContent,
|
|
2208
|
+
delay: [500],
|
|
2209
|
+
position: "bottom"
|
|
2210
|
+
},
|
|
2211
|
+
"data-testid": "ne-emoji-picker"
|
|
2212
|
+
},
|
|
2213
|
+
onClick: function onClick() {
|
|
2214
|
+
return setActive(function (active) {
|
|
2215
|
+
return !active;
|
|
2216
|
+
});
|
|
2217
|
+
},
|
|
2218
|
+
onClose: function onClose() {
|
|
2219
|
+
return setActive(false);
|
|
2220
|
+
},
|
|
2221
|
+
children: /*#__PURE__*/jsx(EmojiPickerMenu, {
|
|
2222
|
+
editor: editor,
|
|
2223
|
+
setActive: setActive
|
|
2224
|
+
})
|
|
2225
|
+
});
|
|
2226
|
+
};
|
|
2227
|
+
|
|
2228
|
+
var Option = function Option(_ref) {
|
|
2229
|
+
var editor = _ref.editor,
|
|
2230
|
+
optionName = _ref.optionName,
|
|
2231
|
+
command = _ref.command,
|
|
2232
|
+
disabled = _ref.disabled,
|
|
2233
|
+
Icon = _ref.Icon,
|
|
2234
|
+
isActive = _ref.isActive,
|
|
2235
|
+
setActive = _ref.setActive,
|
|
2236
|
+
tooltip = _ref.tooltip;
|
|
2237
|
+
if (optionName === EDITOR_OPTIONS.EMOJI) {
|
|
2238
|
+
return /*#__PURE__*/jsx(Emoji, {
|
|
2239
|
+
editor: editor,
|
|
2240
|
+
isActive: isActive,
|
|
2241
|
+
setActive: setActive,
|
|
2242
|
+
tooltipContent: tooltip || "Emoji"
|
|
2243
|
+
});
|
|
2244
|
+
}
|
|
2245
|
+
return /*#__PURE__*/jsx(Button, {
|
|
2246
|
+
disabled: disabled,
|
|
2247
|
+
className: classnames({
|
|
2248
|
+
"ne-headless-btn--active": isActive
|
|
2249
|
+
}),
|
|
2250
|
+
"data-testid": hyphenate(optionName),
|
|
2251
|
+
icon: Icon,
|
|
2252
|
+
tooltipProps: {
|
|
2253
|
+
content: tooltip,
|
|
2254
|
+
delay: [500],
|
|
2255
|
+
position: "bottom"
|
|
2256
|
+
},
|
|
2257
|
+
onClick: command
|
|
2258
|
+
});
|
|
2259
|
+
};
|
|
2260
|
+
|
|
2261
|
+
function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2262
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2263
|
+
var t = i18n.t;
|
|
2264
|
+
var createMenuOptions$1 = function createMenuOptions(_ref) {
|
|
2265
|
+
var editor = _ref.editor,
|
|
2266
|
+
tooltips = _ref.tooltips,
|
|
2267
|
+
setMediaUploader = _ref.setMediaUploader,
|
|
2268
|
+
attachmentProps = _ref.attachmentProps,
|
|
2269
|
+
isEmojiPickerActive = _ref.isEmojiPickerActive,
|
|
2270
|
+
setIsEmojiPickerActive = _ref.setIsEmojiPickerActive;
|
|
2271
|
+
return [{
|
|
2272
|
+
Icon: TextBold,
|
|
2273
|
+
command: function command() {
|
|
2274
|
+
return editor.chain().focus().toggleBold().run();
|
|
2275
|
+
},
|
|
2276
|
+
active: editor.isActive("bold"),
|
|
2277
|
+
optionName: "bold",
|
|
2278
|
+
tooltip: tooltips.bold || t("neetoEditor.menu.bold")
|
|
2279
|
+
}, {
|
|
2280
|
+
Icon: TextItalic,
|
|
2281
|
+
command: function command() {
|
|
2282
|
+
return editor.chain().focus().toggleItalic().run();
|
|
2283
|
+
},
|
|
2284
|
+
active: editor.isActive("italic"),
|
|
2285
|
+
optionName: "italic",
|
|
2286
|
+
tooltip: tooltips.italic || t("neetoEditor.menu.italic")
|
|
2287
|
+
}, {
|
|
2288
|
+
Icon: Underline,
|
|
2289
|
+
command: function command() {
|
|
2290
|
+
return editor.chain().focus().toggleUnderline().run();
|
|
2291
|
+
},
|
|
2292
|
+
active: editor.isActive("underline"),
|
|
2293
|
+
optionName: "underline",
|
|
2294
|
+
tooltip: tooltips.underline || t("neetoEditor.menu.underline")
|
|
2295
|
+
}, {
|
|
2296
|
+
Icon: TextCross,
|
|
2297
|
+
command: function command() {
|
|
2298
|
+
return editor.chain().focus().toggleStrike().run();
|
|
2299
|
+
},
|
|
2300
|
+
active: editor.isActive("strike"),
|
|
2301
|
+
optionName: "strike",
|
|
2302
|
+
tooltip: tooltips.strike || t("neetoEditor.menu.strike")
|
|
2303
|
+
}, {
|
|
2304
|
+
Icon: Highlight,
|
|
2305
|
+
command: function command() {
|
|
2306
|
+
return editor.chain().focus().toggleHighlight().run();
|
|
2307
|
+
},
|
|
2308
|
+
active: editor.isActive("highlight"),
|
|
2309
|
+
optionName: "highlight",
|
|
2310
|
+
tooltip: tooltips.highlight || t("neetoEditor.menu.highlight")
|
|
2311
|
+
}, {
|
|
2312
|
+
Icon: Quote,
|
|
2313
|
+
command: function command() {
|
|
2314
|
+
return editor.chain().focus().toggleBlockquote().run();
|
|
2315
|
+
},
|
|
2316
|
+
active: editor.isActive("blockquote"),
|
|
2317
|
+
optionName: "block-quote",
|
|
2318
|
+
tooltip: tooltips.blockQuote || t("neetoEditor.menu.blockQuote")
|
|
2319
|
+
}, {
|
|
2320
|
+
Icon: Code,
|
|
2321
|
+
command: function command() {
|
|
2322
|
+
return editor.chain().focus().toggleCode().run();
|
|
2323
|
+
},
|
|
2324
|
+
active: editor.isActive("code"),
|
|
2325
|
+
optionName: "code",
|
|
2326
|
+
tooltip: tooltips.code || t("neetoEditor.menu.code")
|
|
2327
|
+
}, {
|
|
2328
|
+
Icon: CodeBlock,
|
|
2329
|
+
command: function command() {
|
|
2330
|
+
return editor.chain().focus().toggleCodeBlock().run();
|
|
2331
|
+
},
|
|
2332
|
+
active: editor.isActive("codeBlock"),
|
|
2333
|
+
optionName: "code-block",
|
|
2334
|
+
tooltip: tooltips.codeBlock || t("neetoEditor.menu.codeBlock")
|
|
2335
|
+
}, {
|
|
2336
|
+
Icon: ListDot,
|
|
2337
|
+
command: function command() {
|
|
2338
|
+
return editor.chain().focus().toggleBulletList().run();
|
|
2339
|
+
},
|
|
2340
|
+
active: editor.isActive("bulletList"),
|
|
2341
|
+
optionName: "bullet-list",
|
|
2342
|
+
tooltip: tooltips.bulletList || t("neetoEditor.menu.bulletedList")
|
|
2343
|
+
}, {
|
|
2344
|
+
Icon: ListNumber,
|
|
2345
|
+
command: function command() {
|
|
2346
|
+
return editor.chain().focus().toggleOrderedList().run();
|
|
2347
|
+
},
|
|
2348
|
+
active: editor.isActive("orderedList"),
|
|
2349
|
+
optionName: "ordered-list",
|
|
2350
|
+
tooltip: tooltips.orderedList || t("neetoEditor.menu.orderedList")
|
|
2351
|
+
}, {
|
|
2352
|
+
Icon: File$1,
|
|
2353
|
+
command: attachmentProps === null || attachmentProps === void 0 ? void 0 : attachmentProps.handleUploadAttachments,
|
|
2354
|
+
disabled: attachmentProps === null || attachmentProps === void 0 ? void 0 : attachmentProps.isDisabled,
|
|
2355
|
+
optionName: "attachments",
|
|
2356
|
+
tooltip: tooltips.attachments || t("neetoEditor.menu.attachments")
|
|
2357
|
+
}, {
|
|
2358
|
+
Icon: ImageUpload,
|
|
2359
|
+
command: function command() {
|
|
2360
|
+
return setMediaUploader(assoc("image", true));
|
|
2361
|
+
},
|
|
2362
|
+
optionName: "image-upload",
|
|
2363
|
+
tooltip: tooltips.imageUpload || t("neetoEditor.menu.imageUpload")
|
|
2364
|
+
}, {
|
|
2365
|
+
Icon: Video,
|
|
2366
|
+
command: function command() {
|
|
2367
|
+
return setMediaUploader(assoc("video", true));
|
|
2368
|
+
},
|
|
2369
|
+
optionName: "video-upload",
|
|
2370
|
+
tooltip: tooltips.videoUpload || t("neetoEditor.menu.videoUpload")
|
|
2371
|
+
}, {
|
|
2372
|
+
Icon: Smiley,
|
|
2373
|
+
command: noop,
|
|
2374
|
+
optionName: "emoji",
|
|
2375
|
+
tooltip: tooltips.emoji || t("neetoEditor.menu.emoji"),
|
|
2376
|
+
isActive: isEmojiPickerActive,
|
|
2377
|
+
setActive: setIsEmojiPickerActive
|
|
2378
|
+
}, {
|
|
2379
|
+
Icon: Column,
|
|
2380
|
+
command: function command() {
|
|
2381
|
+
return editor.chain().focus().insertTable({
|
|
2382
|
+
rows: 3,
|
|
2383
|
+
cols: 3,
|
|
2384
|
+
withHeaderRow: true
|
|
2385
|
+
}).run();
|
|
2386
|
+
},
|
|
2387
|
+
optionName: "table",
|
|
2388
|
+
tooltip: tooltips.table || t("neetoEditor.menu.table")
|
|
2389
|
+
}, {
|
|
2390
|
+
Icon: Undo,
|
|
2391
|
+
command: function command() {
|
|
2392
|
+
return editor.chain().focus().undo().run();
|
|
2393
|
+
},
|
|
2394
|
+
disabled: !editor.can().undo(),
|
|
2395
|
+
optionName: "undo",
|
|
2396
|
+
tooltip: tooltips.undo || t("neetoEditor.menu.undo")
|
|
2397
|
+
}, {
|
|
2398
|
+
Icon: Redo,
|
|
2399
|
+
command: function command() {
|
|
2400
|
+
return editor.chain().focus().redo().run();
|
|
2401
|
+
},
|
|
2402
|
+
disabled: !editor.can().redo(),
|
|
2403
|
+
optionName: "redo",
|
|
2404
|
+
tooltip: tooltips.redo || t("neetoEditor.menu.redo")
|
|
2405
|
+
}];
|
|
2406
|
+
};
|
|
2407
|
+
var buildOptionsFromAddonCommands$1 = function buildOptionsFromAddonCommands(_ref2) {
|
|
2408
|
+
var editor = _ref2.editor,
|
|
2409
|
+
commands = _ref2.commands;
|
|
2410
|
+
var to = editor.state.selection.to;
|
|
2411
|
+
return commands.map(function (option) {
|
|
2412
|
+
var _option$active;
|
|
2413
|
+
return _objectSpread$3(_objectSpread$3({}, option), {}, {
|
|
2414
|
+
active: (_option$active = option.active) === null || _option$active === void 0 ? void 0 : _option$active.call(option, {
|
|
2415
|
+
editor: editor
|
|
2416
|
+
}),
|
|
2417
|
+
command: function command() {
|
|
2418
|
+
var _option$command;
|
|
2419
|
+
return (_option$command = option.command) === null || _option$command === void 0 ? void 0 : _option$command.call(option, {
|
|
2420
|
+
editor: editor,
|
|
2421
|
+
range: {
|
|
2422
|
+
from: to,
|
|
2423
|
+
to: to
|
|
2424
|
+
}
|
|
2425
|
+
});
|
|
2426
|
+
}
|
|
2427
|
+
});
|
|
2428
|
+
});
|
|
2429
|
+
};
|
|
2430
|
+
var buildMenuOptions$1 = function buildMenuOptions(_ref3) {
|
|
2431
|
+
var tooltips = _ref3.tooltips,
|
|
2432
|
+
editor = _ref3.editor,
|
|
2433
|
+
options = _ref3.options,
|
|
2434
|
+
setMediaUploader = _ref3.setMediaUploader,
|
|
2435
|
+
attachmentProps = _ref3.attachmentProps,
|
|
2436
|
+
isEmojiPickerActive = _ref3.isEmojiPickerActive,
|
|
2437
|
+
setIsEmojiPickerActive = _ref3.setIsEmojiPickerActive;
|
|
2438
|
+
var menuOptions = createMenuOptions$1({
|
|
2439
|
+
editor: editor,
|
|
2440
|
+
tooltips: tooltips,
|
|
2441
|
+
setMediaUploader: setMediaUploader,
|
|
2442
|
+
attachmentProps: attachmentProps,
|
|
2443
|
+
isEmojiPickerActive: isEmojiPickerActive,
|
|
2444
|
+
setIsEmojiPickerActive: setIsEmojiPickerActive
|
|
2445
|
+
});
|
|
2446
|
+
return options.map(function (option) {
|
|
2447
|
+
return findBy({
|
|
2448
|
+
optionName: option
|
|
2449
|
+
}, menuOptions);
|
|
2450
|
+
}).filter(Boolean);
|
|
2451
|
+
};
|
|
2452
|
+
|
|
2453
|
+
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2454
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2455
|
+
var Headless = function Headless(_ref) {
|
|
2456
|
+
var editor = _ref.editor,
|
|
2457
|
+
options = _ref.options,
|
|
2458
|
+
_ref$tooltips = _ref.tooltips,
|
|
2459
|
+
tooltips = _ref$tooltips === void 0 ? {} : _ref$tooltips,
|
|
2460
|
+
setMediaUploader = _ref.setMediaUploader,
|
|
2461
|
+
mediaUploader = _ref.mediaUploader,
|
|
2462
|
+
_ref$addonCommands = _ref.addonCommands,
|
|
2463
|
+
addonCommands = _ref$addonCommands === void 0 ? [] : _ref$addonCommands,
|
|
2464
|
+
className = _ref.className,
|
|
2465
|
+
attachmentProps = _ref.attachmentProps,
|
|
2466
|
+
isEmojiPickerActive = _ref.isEmojiPickerActive,
|
|
2467
|
+
setIsEmojiPickerActive = _ref.setIsEmojiPickerActive,
|
|
2468
|
+
_ref$showAssetLibrary = _ref.showAssetLibrary,
|
|
2469
|
+
showAssetLibrary = _ref$showAssetLibrary === void 0 ? true : _ref$showAssetLibrary;
|
|
2470
|
+
if (!editor) {
|
|
2471
|
+
return null;
|
|
2472
|
+
}
|
|
2473
|
+
var isMediaUploaderActive = options.includes(EDITOR_OPTIONS.IMAGE_UPLOAD) || options.includes(EDITOR_OPTIONS.VIDEO_UPLOAD);
|
|
2474
|
+
var menuOptions = buildMenuOptions$1({
|
|
2475
|
+
tooltips: tooltips,
|
|
2476
|
+
editor: editor,
|
|
2477
|
+
options: options,
|
|
2478
|
+
setMediaUploader: setMediaUploader,
|
|
2479
|
+
attachmentProps: attachmentProps,
|
|
2480
|
+
isEmojiPickerActive: isEmojiPickerActive,
|
|
2481
|
+
setIsEmojiPickerActive: setIsEmojiPickerActive
|
|
2482
|
+
});
|
|
2483
|
+
var addonCommandOptions = buildOptionsFromAddonCommands$1({
|
|
2484
|
+
editor: editor,
|
|
2485
|
+
commands: addonCommands
|
|
2486
|
+
});
|
|
2487
|
+
var allOptions = [].concat(_toConsumableArray(menuOptions), _toConsumableArray(addonCommandOptions));
|
|
2488
|
+
return /*#__PURE__*/jsxs("div", {
|
|
2489
|
+
className: classnames("ne-headless", _defineProperty({}, className, className)),
|
|
2490
|
+
children: [allOptions.map(function (option) {
|
|
2491
|
+
return /*#__PURE__*/createElement(Option, _objectSpread$2({
|
|
2492
|
+
editor: editor,
|
|
2493
|
+
key: option.optionName
|
|
2494
|
+
}, option));
|
|
2495
|
+
}), isMediaUploaderActive && /*#__PURE__*/jsx(MediaUploader, {
|
|
2496
|
+
editor: editor,
|
|
2497
|
+
mediaUploader: mediaUploader,
|
|
2498
|
+
showAssetLibrary: showAssetLibrary,
|
|
2499
|
+
onClose: function onClose() {
|
|
2500
|
+
return setMediaUploader({
|
|
2501
|
+
image: false,
|
|
2502
|
+
video: false
|
|
2503
|
+
});
|
|
2504
|
+
}
|
|
2505
|
+
})]
|
|
2506
|
+
});
|
|
2507
|
+
};
|
|
2508
|
+
|
|
2509
|
+
var FONT_SIZE_OPTIONS = [{
|
|
2510
|
+
label: t$1("neetoEditor.menu.heading1"),
|
|
2511
|
+
value: 1,
|
|
2512
|
+
key: "h1",
|
|
2513
|
+
icon: TextH1
|
|
2514
|
+
}, {
|
|
2515
|
+
label: t$1("neetoEditor.menu.heading2"),
|
|
2516
|
+
value: 2,
|
|
2517
|
+
key: "h2",
|
|
2518
|
+
icon: TextH2
|
|
2519
|
+
}, {
|
|
2520
|
+
label: t$1("neetoEditor.menu.heading3"),
|
|
2521
|
+
value: 3,
|
|
2522
|
+
key: "h3",
|
|
2523
|
+
icon: TextH3
|
|
2524
|
+
}, {
|
|
2525
|
+
label: t$1("neetoEditor.menu.heading4"),
|
|
2526
|
+
value: 4,
|
|
2527
|
+
key: "h4",
|
|
2528
|
+
icon: TextH4
|
|
2529
|
+
}, {
|
|
2530
|
+
label: t$1("neetoEditor.menu.heading5"),
|
|
2531
|
+
value: 5,
|
|
2532
|
+
key: "h5",
|
|
2533
|
+
icon: TextH5
|
|
2534
|
+
}, {
|
|
2535
|
+
label: t$1("neetoEditor.menu.normalText"),
|
|
2536
|
+
value: 0,
|
|
2537
|
+
key: "body2",
|
|
2538
|
+
icon: TextP
|
|
2539
|
+
}];
|
|
2540
|
+
var MENU_COMPONENTS = {
|
|
2541
|
+
fixed: Fixed,
|
|
2542
|
+
bubble: Bubble,
|
|
2543
|
+
headless: Headless,
|
|
2544
|
+
none: EmptyMenu
|
|
2545
|
+
};
|
|
2546
|
+
|
|
2547
|
+
var Menu$2 = Dropdown$1.Menu,
|
|
2548
|
+
MenuItem = Dropdown$1.MenuItem;
|
|
2549
|
+
var FontSizeOption = function FontSizeOption(_ref) {
|
|
2550
|
+
var runEditorCommand = _ref.runEditorCommand,
|
|
2551
|
+
tooltipContent = _ref.tooltipContent,
|
|
2552
|
+
label = _ref.label,
|
|
2553
|
+
_ref$options = _ref.options,
|
|
2554
|
+
options = _ref$options === void 0 ? [] : _ref$options;
|
|
2555
|
+
var dropdownRef = useRef(null);
|
|
2556
|
+
var lastOption = last(FONT_SIZE_OPTIONS);
|
|
2557
|
+
var _useEditorStore = useEditorStore(function (store) {
|
|
2558
|
+
var _store$marksState;
|
|
2559
|
+
return {
|
|
2560
|
+
fontSizeOption: (_store$marksState = store["marksState"]) === null || _store$marksState === void 0 ? void 0 : _store$marksState["fontSizeOption"]
|
|
2561
|
+
};
|
|
2562
|
+
}, shallow),
|
|
2563
|
+
_useEditorStore$fontS = _useEditorStore.fontSizeOption,
|
|
2564
|
+
activeOption = _useEditorStore$fontS === void 0 ? lastOption : _useEditorStore$fontS;
|
|
2565
|
+
var handleClick = function handleClick(level) {
|
|
2566
|
+
return level ? runEditorCommand(function (editor) {
|
|
2567
|
+
return editor.chain().focus().toggleHeading({
|
|
2568
|
+
level: level
|
|
2569
|
+
}).run();
|
|
2570
|
+
})() : runEditorCommand(function (editor) {
|
|
2571
|
+
return editor.chain().focus().setNode("paragraph").run();
|
|
2572
|
+
})();
|
|
2573
|
+
};
|
|
2574
|
+
var menuOptions = [].concat(_toConsumableArray(filterBy({
|
|
2575
|
+
key: function key(_key) {
|
|
2576
|
+
return options.includes(_key);
|
|
2577
|
+
}
|
|
2578
|
+
}, FONT_SIZE_OPTIONS)), [FONT_SIZE_OPTIONS[FONT_SIZE_OPTIONS.length - 1]]);
|
|
2579
|
+
return /*#__PURE__*/jsx(Dropdown$1, {
|
|
2580
|
+
autoWidth: true,
|
|
2581
|
+
placement: "bottom-start",
|
|
2582
|
+
strategy: "fixed",
|
|
2583
|
+
buttonProps: {
|
|
2584
|
+
icon: activeOption === null || activeOption === void 0 ? void 0 : activeOption.icon,
|
|
2585
|
+
iconPosition: "left",
|
|
2586
|
+
iconSize: 22,
|
|
2587
|
+
label: /*#__PURE__*/jsx(Down, {
|
|
2588
|
+
size: 12
|
|
2589
|
+
}),
|
|
2590
|
+
ref: dropdownRef,
|
|
2591
|
+
"data-testid": "neeto-editor-fixed-menu-font-size-option",
|
|
2592
|
+
onKeyDown: function onKeyDown(event) {
|
|
2593
|
+
var _dropdownRef$current;
|
|
2594
|
+
return event.key === "ArrowDown" && ((_dropdownRef$current = dropdownRef.current) === null || _dropdownRef$current === void 0 ? void 0 : _dropdownRef$current.click());
|
|
2595
|
+
},
|
|
2596
|
+
tooltipProps: {
|
|
2597
|
+
content: tooltipContent !== null && tooltipContent !== void 0 ? tooltipContent : label,
|
|
2598
|
+
position: "bottom"
|
|
2599
|
+
},
|
|
2600
|
+
style: "text",
|
|
2601
|
+
size: "small",
|
|
2602
|
+
className: "neeto-editor-fixed-menu__item neeto-editor-font-size__wrapper"
|
|
2603
|
+
},
|
|
2604
|
+
children: /*#__PURE__*/jsx(Menu$2, {
|
|
2605
|
+
className: "neeto-ui-flex neeto-ui-gap-1 neeto-editor-menu-font-size-options",
|
|
2606
|
+
children: menuOptions.map(function (_ref2) {
|
|
2607
|
+
var label = _ref2.label,
|
|
2608
|
+
Icon = _ref2.icon,
|
|
2609
|
+
value = _ref2.value,
|
|
2610
|
+
key = _ref2.key;
|
|
2611
|
+
return /*#__PURE__*/jsx(MenuItem.Button, {
|
|
2612
|
+
className: "neeto-editor-menu-font-size-options__item-btn",
|
|
2613
|
+
"data-testid": "neeto-editor-fixed-menu-font-size-option-".concat(key),
|
|
2614
|
+
tooltipProps: {
|
|
2615
|
+
content: label,
|
|
2616
|
+
position: "bottom"
|
|
2617
|
+
},
|
|
2618
|
+
onClick: function onClick() {
|
|
2619
|
+
return handleClick(value);
|
|
2620
|
+
},
|
|
2621
|
+
children: /*#__PURE__*/jsx(Icon, {
|
|
2622
|
+
size: 22
|
|
2623
|
+
})
|
|
2624
|
+
}, value);
|
|
2625
|
+
})
|
|
2626
|
+
})
|
|
2627
|
+
});
|
|
2628
|
+
};
|
|
2629
|
+
var FontSizeOption$1 = /*#__PURE__*/memo(FontSizeOption);
|
|
2630
|
+
|
|
2631
|
+
var ColorDot = function ColorDot(_ref) {
|
|
2632
|
+
var _colorVar$match;
|
|
2633
|
+
var colorVar = _ref.colorVar,
|
|
2634
|
+
isSelected = _ref.isSelected,
|
|
2635
|
+
onClick = _ref.onClick,
|
|
2636
|
+
isTextColor = _ref.isTextColor;
|
|
2637
|
+
var dotClass = classnames("neeto-editor-highlight-dropdown__color-dot", {
|
|
2638
|
+
"neeto-editor-highlight-dropdown__color-dot--selected": isSelected
|
|
2639
|
+
});
|
|
2640
|
+
var dotStyle = {
|
|
2641
|
+
backgroundColor: "var(".concat(colorVar, ")")
|
|
2642
|
+
};
|
|
2643
|
+
var colorNumber = ((_colorVar$match = colorVar.match(/\d+$/)) === null || _colorVar$match === void 0 ? void 0 : _colorVar$match[0]) || colorVar;
|
|
2644
|
+
return /*#__PURE__*/jsx("div", {
|
|
2645
|
+
onClick: onClick,
|
|
2646
|
+
className: dotClass,
|
|
2647
|
+
style: dotStyle,
|
|
2648
|
+
"data-testid": "neeto-editor-highlight-".concat(hyphenize(isTextColor ? "text" : "background"), "-color-dot-").concat(colorNumber)
|
|
2649
|
+
});
|
|
2650
|
+
};
|
|
2651
|
+
|
|
2652
|
+
var COLORS = {
|
|
2653
|
+
text: ["--neeto-editor-highlight-text-1", "--neeto-editor-highlight-text-2", "--neeto-editor-highlight-text-3", "--neeto-editor-highlight-text-4", "--neeto-editor-highlight-text-5", "--neeto-editor-highlight-text-6", "--neeto-editor-highlight-text-7", "--neeto-editor-highlight-text-8", "--neeto-editor-highlight-text-9", "--neeto-editor-highlight-text-10", "--neeto-editor-highlight-text-11", "--neeto-editor-highlight-text-12", "--neeto-editor-highlight-text-13", "--neeto-editor-highlight-text-14", "--neeto-editor-highlight-text-15", "--neeto-editor-highlight-text-16"],
|
|
2654
|
+
background: ["--neeto-editor-highlight-bg-1", "--neeto-editor-highlight-bg-2", "--neeto-editor-highlight-bg-3", "--neeto-editor-highlight-bg-4", "--neeto-editor-highlight-bg-5", "--neeto-editor-highlight-bg-6", "--neeto-editor-highlight-bg-7", "--neeto-editor-highlight-bg-8", "--neeto-editor-highlight-bg-9", "--neeto-editor-highlight-bg-10", "--neeto-editor-highlight-bg-11", "--neeto-editor-highlight-bg-12", "--neeto-editor-highlight-bg-13", "--neeto-editor-highlight-bg-14", "--neeto-editor-highlight-bg-15", "--neeto-editor-highlight-bg-16"]
|
|
2655
|
+
};
|
|
2656
|
+
|
|
2657
|
+
var colorSections = [{
|
|
2658
|
+
title: "Text color",
|
|
2659
|
+
colors: COLORS.text,
|
|
2660
|
+
isTextColor: true
|
|
2661
|
+
}, {
|
|
2662
|
+
title: "Background color",
|
|
2663
|
+
colors: COLORS.background,
|
|
2664
|
+
isTextColor: false
|
|
2665
|
+
}];
|
|
2666
|
+
var HighlightDropdown = function HighlightDropdown(_ref) {
|
|
2667
|
+
var editor = _ref.editor,
|
|
2668
|
+
label = _ref.label,
|
|
2669
|
+
tooltipContent = _ref.tooltipContent,
|
|
2670
|
+
runEditorCommand = _ref.runEditorCommand;
|
|
2671
|
+
var dropdownRef = useRef(null);
|
|
2672
|
+
var textColor = editor.getAttributes("textStyle").color;
|
|
2673
|
+
var backgroundColor = editor.getAttributes("textStyle").backgroundColor;
|
|
2674
|
+
var updateBackgroundColor = function updateBackgroundColor(value) {
|
|
2675
|
+
runEditorCommand(function (editor) {
|
|
2676
|
+
return editor.chain().focus().setMark("textStyle", {
|
|
2677
|
+
backgroundColor: value
|
|
2678
|
+
}).run();
|
|
2679
|
+
})();
|
|
2680
|
+
};
|
|
2681
|
+
var handleBackgroundColorClick = function handleBackgroundColorClick(colorVar, event) {
|
|
2682
|
+
event.stopPropagation();
|
|
2683
|
+
if (backgroundColor === "var(".concat(colorVar, ")")) {
|
|
2684
|
+
updateBackgroundColor(null);
|
|
2685
|
+
} else {
|
|
2686
|
+
updateBackgroundColor("var(".concat(colorVar, ")"));
|
|
2687
|
+
}
|
|
2688
|
+
};
|
|
2689
|
+
var handleTextColorClick = function handleTextColorClick(colorVar, event) {
|
|
2690
|
+
event.stopPropagation();
|
|
2691
|
+
if (textColor === "var(".concat(colorVar, ")")) {
|
|
2692
|
+
editor.chain().focus().unsetColor().run();
|
|
2693
|
+
} else {
|
|
2694
|
+
editor.chain().focus().setColor("var(".concat(colorVar, ")")).run();
|
|
2695
|
+
}
|
|
2696
|
+
};
|
|
2697
|
+
var renderColorDots = function renderColorDots(colorList) {
|
|
2698
|
+
var isTextColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
2699
|
+
return colorList.map(function (colorVar, idx) {
|
|
2700
|
+
return /*#__PURE__*/createElement(ColorDot, {
|
|
2701
|
+
colorVar: colorVar,
|
|
2702
|
+
isTextColor: isTextColor,
|
|
2703
|
+
key: idx,
|
|
2704
|
+
isSelected: isTextColor ? textColor === "var(".concat(colorVar, ")") : backgroundColor === "var(".concat(colorVar, ")"),
|
|
2705
|
+
onClick: function onClick(event) {
|
|
2706
|
+
return isTextColor ? handleTextColorClick(colorVar, event) : handleBackgroundColorClick(colorVar, event);
|
|
2707
|
+
}
|
|
2708
|
+
});
|
|
2709
|
+
});
|
|
2710
|
+
};
|
|
2711
|
+
return /*#__PURE__*/jsx(Dropdown$1, {
|
|
2712
|
+
autoWidth: true,
|
|
2713
|
+
placement: "bottom-start",
|
|
2714
|
+
strategy: "fixed",
|
|
2715
|
+
buttonProps: {
|
|
2716
|
+
icon: function icon() {
|
|
2717
|
+
return /*#__PURE__*/jsx(Highlight, {
|
|
2718
|
+
size: 18
|
|
2719
|
+
});
|
|
2720
|
+
},
|
|
2721
|
+
iconPosition: "left",
|
|
2722
|
+
iconSize: 16,
|
|
2723
|
+
label: /*#__PURE__*/jsx(Down, {
|
|
2724
|
+
size: 12
|
|
2725
|
+
}),
|
|
2726
|
+
ref: dropdownRef,
|
|
2727
|
+
"data-testid": "neeto-editor-fixed-menu-highlight-option",
|
|
2728
|
+
onKeyDown: function onKeyDown(event) {
|
|
2729
|
+
var _dropdownRef$current;
|
|
2730
|
+
return event.key === "ArrowDown" && ((_dropdownRef$current = dropdownRef.current) === null || _dropdownRef$current === void 0 ? void 0 : _dropdownRef$current.click());
|
|
2731
|
+
},
|
|
2732
|
+
tooltipProps: {
|
|
2733
|
+
content: tooltipContent !== null && tooltipContent !== void 0 ? tooltipContent : label,
|
|
2734
|
+
position: "bottom"
|
|
2735
|
+
},
|
|
2736
|
+
style: "text",
|
|
2737
|
+
size: "small",
|
|
2738
|
+
className: "neeto-editor-fixed-menu__item"
|
|
2739
|
+
},
|
|
2740
|
+
children: /*#__PURE__*/jsx(Dropdown$1.Menu, {
|
|
2741
|
+
className: "neeto-editor-highlight-dropdown",
|
|
2742
|
+
children: colorSections.map(function (_ref2) {
|
|
2743
|
+
var title = _ref2.title,
|
|
2744
|
+
colors = _ref2.colors,
|
|
2745
|
+
isTextColor = _ref2.isTextColor;
|
|
2746
|
+
return /*#__PURE__*/jsxs("div", {
|
|
2747
|
+
className: "neeto-editor-highlight-dropdown__section",
|
|
2748
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
2749
|
+
className: "neeto-editor-highlight-dropdown__section-title",
|
|
2750
|
+
style: "body2",
|
|
2751
|
+
weight: "medium",
|
|
2752
|
+
children: title
|
|
2753
|
+
}), /*#__PURE__*/jsx("div", {
|
|
2754
|
+
className: "neeto-editor-highlight-dropdown__color-grid",
|
|
2755
|
+
"data-testid": "neeto-editor-highlight-".concat(hyphenize(title), "-grid"),
|
|
2756
|
+
children: renderColorDots(colors, isTextColor)
|
|
2757
|
+
})]
|
|
2758
|
+
}, title);
|
|
2759
|
+
})
|
|
2760
|
+
})
|
|
2761
|
+
});
|
|
2762
|
+
};
|
|
2763
|
+
|
|
2764
|
+
var Menu$1 = Dropdown$1.Menu;
|
|
2765
|
+
var TableOption = function TableOption(_ref) {
|
|
2766
|
+
var editor = _ref.editor,
|
|
2767
|
+
tooltipContent = _ref.tooltipContent,
|
|
2768
|
+
_ref$isSecondaryMenu = _ref.isSecondaryMenu,
|
|
2769
|
+
isSecondaryMenu = _ref$isSecondaryMenu === void 0 ? false : _ref$isSecondaryMenu,
|
|
2770
|
+
label = _ref.label;
|
|
2771
|
+
var _useTranslation = useTranslation(),
|
|
2772
|
+
t = _useTranslation.t;
|
|
2773
|
+
var _useState = useState(false),
|
|
2774
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2775
|
+
isOpen = _useState2[0],
|
|
2776
|
+
setIsOpen = _useState2[1];
|
|
2777
|
+
var _useState3 = useState(3),
|
|
2778
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2779
|
+
rows = _useState4[0],
|
|
2780
|
+
setRows = _useState4[1];
|
|
2781
|
+
var _useState5 = useState(3),
|
|
2782
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
2783
|
+
columns = _useState6[0],
|
|
2784
|
+
setColumns = _useState6[1];
|
|
2785
|
+
var handleClose = function handleClose() {
|
|
2786
|
+
setRows(3);
|
|
2787
|
+
setColumns(3);
|
|
2788
|
+
setIsOpen(false);
|
|
2789
|
+
};
|
|
2790
|
+
var handleSubmit = function handleSubmit() {
|
|
2791
|
+
editor.chain().focus().insertTable({
|
|
2792
|
+
rows: rows,
|
|
2793
|
+
cols: columns,
|
|
2794
|
+
withHeaderRow: true
|
|
2795
|
+
}).run();
|
|
2796
|
+
handleClose();
|
|
2797
|
+
};
|
|
2798
|
+
var handleDropdownClick = function handleDropdownClick(e) {
|
|
2799
|
+
isSecondaryMenu && e.stopPropagation();
|
|
2800
|
+
setIsOpen(not);
|
|
2801
|
+
};
|
|
2802
|
+
return /*#__PURE__*/jsx(Dropdown$1, {
|
|
2803
|
+
isOpen: isOpen,
|
|
2804
|
+
buttonStyle: isOpen ? "secondary" : "text",
|
|
2805
|
+
closeOnSelect: false,
|
|
2806
|
+
"data-testid": "neeto-editor-fixed-menu-link-option",
|
|
2807
|
+
icon: Column,
|
|
2808
|
+
position: isSecondaryMenu ? "left-start" : "bottom",
|
|
2809
|
+
buttonProps: {
|
|
2810
|
+
tabIndex: -1,
|
|
2811
|
+
tooltipProps: {
|
|
2812
|
+
content: tooltipContent !== null && tooltipContent !== void 0 ? tooltipContent : label,
|
|
2813
|
+
position: "bottom"
|
|
2814
|
+
},
|
|
2815
|
+
className: "neeto-editor-fixed-menu__item",
|
|
2816
|
+
"data-testid": "neeto-editor-fixed-menu-table-option"
|
|
2817
|
+
},
|
|
2818
|
+
customTarget: isSecondaryMenu && /*#__PURE__*/jsx(SecondaryMenuTarget, {
|
|
2819
|
+
label: label,
|
|
2820
|
+
icon: Column
|
|
2821
|
+
}),
|
|
2822
|
+
onClick: handleDropdownClick,
|
|
2823
|
+
onClose: handleClose,
|
|
2824
|
+
children: /*#__PURE__*/jsxs(Menu$1, {
|
|
2825
|
+
className: "neeto-editor-table__item",
|
|
2826
|
+
children: [/*#__PURE__*/jsx(Input, {
|
|
2827
|
+
autoFocus: true,
|
|
2828
|
+
"data-testid": "neeto-editor-fixed-menu-table-rows-input",
|
|
2829
|
+
label: t("neetoEditor.menu.rows"),
|
|
2830
|
+
min: "1",
|
|
2831
|
+
placeholder: t("neetoEditor.placeholders.rows"),
|
|
2832
|
+
size: "small",
|
|
2833
|
+
type: "number",
|
|
2834
|
+
value: rows,
|
|
2835
|
+
onChange: withEventTargetValue(setRows)
|
|
2836
|
+
}), /*#__PURE__*/jsx(Input, {
|
|
2837
|
+
"data-testid": "neeto-editor-fixed-menu-table-columns-input",
|
|
2838
|
+
label: t("neetoEditor.menu.columns"),
|
|
2839
|
+
min: "1",
|
|
2840
|
+
placeholder: t("neetoEditor.placeholders.rows"),
|
|
2841
|
+
size: "small",
|
|
2842
|
+
type: "number",
|
|
2843
|
+
value: columns,
|
|
2844
|
+
onChange: withEventTargetValue(setColumns)
|
|
2845
|
+
}), /*#__PURE__*/jsx("div", {
|
|
2846
|
+
className: "neeto-editor-table-menu__button",
|
|
2847
|
+
children: /*#__PURE__*/jsx(Button$1, {
|
|
2848
|
+
className: "mt-auto",
|
|
2849
|
+
"data-testid": "neeto-editor-fixed-menu-table-option-create-button",
|
|
2850
|
+
label: t("neetoEditor.common.create"),
|
|
2851
|
+
size: "small",
|
|
2852
|
+
onClick: handleSubmit
|
|
2853
|
+
})
|
|
2854
|
+
})]
|
|
2855
|
+
})
|
|
2856
|
+
});
|
|
2857
|
+
};
|
|
2858
|
+
var TableOption$1 = /*#__PURE__*/memo(TableOption);
|
|
2859
|
+
|
|
2860
|
+
var _SHORTCUTS;
|
|
2861
|
+
var MENU_ELEMENT_TYPES = {
|
|
2862
|
+
BUTTON: "button",
|
|
2863
|
+
CALLOUT: "callout",
|
|
2864
|
+
FONT_SIZE: "fontSize",
|
|
2865
|
+
TABLE: "table",
|
|
2866
|
+
TEXT_COLOR: "textColor",
|
|
2867
|
+
EMOJI: "emoji",
|
|
2868
|
+
MENTIONS: "mentions",
|
|
2869
|
+
HIGHLIGHT: "highlight"
|
|
2870
|
+
};
|
|
2871
|
+
var SHORTCUTS = (_SHORTCUTS = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_SHORTCUTS, EDITOR_OPTIONS.BOLD, {
|
|
2872
|
+
mac: "⌘B",
|
|
2873
|
+
win: "Ctrl+B"
|
|
2874
|
+
}), EDITOR_OPTIONS.ITALIC, {
|
|
2875
|
+
mac: "⌘I",
|
|
2876
|
+
win: "Ctrl+I"
|
|
2877
|
+
}), EDITOR_OPTIONS.UNDERLINE, {
|
|
2878
|
+
mac: "⌘U",
|
|
2879
|
+
win: "Ctrl+U"
|
|
2880
|
+
}), EDITOR_OPTIONS.STRIKETHROUGH, {
|
|
2881
|
+
mac: "⌘⇧S or ⌘⇧X",
|
|
2882
|
+
win: "Ctrl+Shift+S or Ctrl+Shift+X"
|
|
2883
|
+
}), EDITOR_OPTIONS.CODE, {
|
|
2884
|
+
mac: "⌘E",
|
|
2885
|
+
win: "Ctrl+E"
|
|
2886
|
+
}), EDITOR_OPTIONS.UNDO, {
|
|
2887
|
+
mac: "⌘Z",
|
|
2888
|
+
win: "Ctrl+Z"
|
|
2889
|
+
}), EDITOR_OPTIONS.REDO, {
|
|
2890
|
+
mac: "⌘⇧Z",
|
|
2891
|
+
win: "Ctrl+Shift+Z"
|
|
2892
|
+
}), EDITOR_OPTIONS.LINK, {
|
|
2893
|
+
mac: "⌘K",
|
|
2894
|
+
win: "Ctrl+K"
|
|
2895
|
+
}), EDITOR_OPTIONS.HIGHLIGHT, {
|
|
2896
|
+
mac: "⌘⇧H",
|
|
2897
|
+
win: "Ctrl+Shift+H"
|
|
2898
|
+
}), "bulletList", {
|
|
2899
|
+
mac: "⌘⇧8",
|
|
2900
|
+
win: "Ctrl+Shift+8"
|
|
2901
|
+
}), _defineProperty(_defineProperty(_SHORTCUTS, "orderedList", {
|
|
2902
|
+
mac: "⌘⇧7",
|
|
2903
|
+
win: "Ctrl+Shift+7"
|
|
2904
|
+
}), "todoList", {
|
|
2905
|
+
mac: "⌘⇧9",
|
|
2906
|
+
win: "Ctrl+Shift+9"
|
|
2907
|
+
}));
|
|
2908
|
+
var MENU_ELEMENTS = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, MENU_ELEMENT_TYPES.BUTTON, MenuButton$1), MENU_ELEMENT_TYPES.CALLOUT, CalloutDropdown), MENU_ELEMENT_TYPES.FONT_SIZE, FontSizeOption$1), MENU_ELEMENT_TYPES.TABLE, TableOption$1), MENU_ELEMENT_TYPES.TEXT_COLOR, TextColorOption), MENU_ELEMENT_TYPES.EMOJI, EmojiOption$1), MENU_ELEMENT_TYPES.MENTIONS, Mentions$1), MENU_ELEMENT_TYPES.HIGHLIGHT, HighlightDropdown);
|
|
2909
|
+
var MENU_ELEMENT_WIDTHS = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, MENU_ELEMENT_TYPES.BUTTON, 36), MENU_ELEMENT_TYPES.CALLOUT, 23), MENU_ELEMENT_TYPES.FONT_SIZE, 103), MENU_ELEMENT_TYPES.TABLE, 36), MENU_ELEMENT_TYPES.TEXT_COLOR, 36), MENU_ELEMENT_TYPES.EMOJI, 36), MENU_ELEMENT_TYPES.MENTIONS, 36), MENU_ELEMENT_TYPES.HIGHLIGHT, 103);
|
|
2910
|
+
|
|
2911
|
+
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2912
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2913
|
+
var createMenuOptions = function createMenuOptions(_ref) {
|
|
2914
|
+
var _tooltips$fontSize, _tooltips$bold, _tooltips$italic, _tooltips$link, _tooltips$strike, _tooltips$highlight, _tooltips$highlight2, _tooltips$bulletList, _tooltips$orderedList, _tooltips$todoList, _tooltips$blockQuote, _tooltips$callout, _tooltips$callout2, _tooltips$table, _tooltips$attachments, _tooltips$neetoKbArti, _tooltips$imageUpload, _tooltips$textColor, _tooltips$emoji, _tooltips$mention, _tooltips$code, _tooltips$codeBlock, _tooltips$videoUpload, _tooltips$underline, _tooltips$undo, _tooltips$redo;
|
|
2915
|
+
var tooltips = _ref.tooltips,
|
|
2916
|
+
setMediaUploader = _ref.setMediaUploader,
|
|
2917
|
+
attachmentProps = _ref.attachmentProps,
|
|
2918
|
+
setIsAddLinkActive = _ref.setIsAddLinkActive,
|
|
2919
|
+
options = _ref.options,
|
|
2920
|
+
mentions = _ref.mentions,
|
|
2921
|
+
addonCommandOptions = _ref.addonCommandOptions,
|
|
2922
|
+
setIsEmojiPickerActive = _ref.setIsEmojiPickerActive,
|
|
2923
|
+
isEmojiPickerActive = _ref.isEmojiPickerActive,
|
|
2924
|
+
runEditorCommand = _ref.runEditorCommand,
|
|
2925
|
+
editor = _ref.editor,
|
|
2926
|
+
setIsNeetoKbArticleActive = _ref.setIsNeetoKbArticleActive;
|
|
2927
|
+
var fontSizeOptions = options.filter(function (option) {
|
|
2928
|
+
return option.match(/^h[1-6]$/);
|
|
2929
|
+
});
|
|
2930
|
+
return [
|
|
2931
|
+
// font
|
|
2932
|
+
[{
|
|
2933
|
+
type: MENU_ELEMENT_TYPES.FONT_SIZE,
|
|
2934
|
+
options: fontSizeOptions,
|
|
2935
|
+
label: (_tooltips$fontSize = tooltips.fontSize) !== null && _tooltips$fontSize !== void 0 ? _tooltips$fontSize : t$1("neetoEditor.menu.fontSize"),
|
|
2936
|
+
isEnabled: isNotEmpty(fontSizeOptions),
|
|
2937
|
+
optionName: "fontSizeOptions",
|
|
2938
|
+
runEditorCommand: runEditorCommand
|
|
2939
|
+
}, {
|
|
2940
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
2941
|
+
icon: TextBold,
|
|
2942
|
+
isEnabled: options.includes(EDITOR_OPTIONS.BOLD),
|
|
2943
|
+
command: runEditorCommand(function (editor) {
|
|
2944
|
+
return editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleBold().run();
|
|
2945
|
+
}),
|
|
2946
|
+
optionName: EDITOR_OPTIONS.BOLD,
|
|
2947
|
+
label: (_tooltips$bold = tooltips.bold) !== null && _tooltips$bold !== void 0 ? _tooltips$bold : t$1("neetoEditor.menu.bold")
|
|
2948
|
+
}, {
|
|
2949
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
2950
|
+
icon: TextItalic,
|
|
2951
|
+
isEnabled: options.includes(EDITOR_OPTIONS.ITALIC),
|
|
2952
|
+
command: runEditorCommand(function (editor) {
|
|
2953
|
+
return editor.chain().focus().toggleItalic().run();
|
|
2954
|
+
}),
|
|
2955
|
+
optionName: EDITOR_OPTIONS.ITALIC,
|
|
2956
|
+
label: (_tooltips$italic = tooltips.italic) !== null && _tooltips$italic !== void 0 ? _tooltips$italic : t$1("neetoEditor.menu.italic")
|
|
2957
|
+
}, {
|
|
2958
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
2959
|
+
icon: Link,
|
|
2960
|
+
isEnabled: options.includes(EDITOR_OPTIONS.LINK),
|
|
2961
|
+
command: function command() {
|
|
2962
|
+
return setIsAddLinkActive(not);
|
|
2963
|
+
},
|
|
2964
|
+
optionName: EDITOR_OPTIONS.LINK,
|
|
2965
|
+
label: (_tooltips$link = tooltips.link) !== null && _tooltips$link !== void 0 ? _tooltips$link : t$1("neetoEditor.menu.link")
|
|
2966
|
+
}, {
|
|
2967
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
2968
|
+
icon: TextCross,
|
|
2969
|
+
isEnabled: options.includes(EDITOR_OPTIONS.STRIKETHROUGH),
|
|
2970
|
+
command: runEditorCommand(function (editor) {
|
|
2971
|
+
return editor.chain().focus().toggleStrike().run();
|
|
2972
|
+
}),
|
|
2973
|
+
optionName: EDITOR_OPTIONS.STRIKETHROUGH,
|
|
2974
|
+
label: (_tooltips$strike = tooltips.strike) !== null && _tooltips$strike !== void 0 ? _tooltips$strike : t$1("neetoEditor.menu.strike")
|
|
2975
|
+
}, {
|
|
2976
|
+
type: MENU_ELEMENT_TYPES.HIGHLIGHT,
|
|
2977
|
+
icon: Highlight,
|
|
2978
|
+
label: (_tooltips$highlight = tooltips.highlight) !== null && _tooltips$highlight !== void 0 ? _tooltips$highlight : t$1("neetoEditor.menu.highlight"),
|
|
2979
|
+
isEnabled: options.includes(EDITOR_OPTIONS.HIGHLIGHT),
|
|
2980
|
+
optionName: EDITOR_OPTIONS.HIGHLIGHT,
|
|
2981
|
+
editor: editor,
|
|
2982
|
+
runEditorCommand: runEditorCommand,
|
|
2983
|
+
tooltipContent: (_tooltips$highlight2 = tooltips.highlight) !== null && _tooltips$highlight2 !== void 0 ? _tooltips$highlight2 : t$1("neetoEditor.menu.highlight")
|
|
2984
|
+
}],
|
|
2985
|
+
// list
|
|
2986
|
+
[{
|
|
2987
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
2988
|
+
icon: ListDot,
|
|
2989
|
+
command: runEditorCommand(function (editor) {
|
|
2990
|
+
return editor.chain().focus().toggleBulletList().run();
|
|
2991
|
+
}),
|
|
2992
|
+
isEnabled: options.includes(EDITOR_OPTIONS.LIST_BULLETS),
|
|
2993
|
+
optionName: "bulletList",
|
|
2994
|
+
highlight: true,
|
|
2995
|
+
label: (_tooltips$bulletList = tooltips.bulletList) !== null && _tooltips$bulletList !== void 0 ? _tooltips$bulletList : t$1("neetoEditor.menu.bulletedList")
|
|
2996
|
+
}, {
|
|
2997
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
2998
|
+
icon: ListNumber,
|
|
2999
|
+
command: runEditorCommand(function (editor) {
|
|
3000
|
+
return editor.chain().focus().toggleOrderedList().run();
|
|
3001
|
+
}),
|
|
3002
|
+
isEnabled: options.includes(EDITOR_OPTIONS.LIST_ORDERED),
|
|
3003
|
+
optionName: "orderedList",
|
|
3004
|
+
highlight: true,
|
|
3005
|
+
label: (_tooltips$orderedList = tooltips.orderedList) !== null && _tooltips$orderedList !== void 0 ? _tooltips$orderedList : t$1("neetoEditor.menu.orderedList")
|
|
3006
|
+
}, {
|
|
3007
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
3008
|
+
icon: Checkbox$1,
|
|
3009
|
+
command: runEditorCommand(function (editor) {
|
|
3010
|
+
return editor.chain().focus().toggleTaskList().run();
|
|
3011
|
+
}),
|
|
3012
|
+
isEnabled: options.includes(EDITOR_OPTIONS.TODO_LIST),
|
|
3013
|
+
optionName: "todoList",
|
|
3014
|
+
highlight: true,
|
|
3015
|
+
label: (_tooltips$todoList = tooltips.todoList) !== null && _tooltips$todoList !== void 0 ? _tooltips$todoList : t$1("neetoEditor.menu.todoList")
|
|
3016
|
+
}],
|
|
3017
|
+
// block
|
|
3018
|
+
[{
|
|
3019
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
3020
|
+
icon: Quote,
|
|
3021
|
+
command: runEditorCommand(function (editor) {
|
|
3022
|
+
return editor.chain().focus().toggleBlockquote().run();
|
|
3023
|
+
}),
|
|
3024
|
+
isEnabled: options.includes(EDITOR_OPTIONS.BLOCKQUOTE),
|
|
3025
|
+
optionName: "blockquote",
|
|
3026
|
+
highlight: true,
|
|
3027
|
+
label: (_tooltips$blockQuote = tooltips.blockQuote) !== null && _tooltips$blockQuote !== void 0 ? _tooltips$blockQuote : t$1("neetoEditor.menu.blockQuote")
|
|
3028
|
+
}, {
|
|
3029
|
+
type: MENU_ELEMENT_TYPES.CALLOUT,
|
|
3030
|
+
label: (_tooltips$callout = tooltips.callout) !== null && _tooltips$callout !== void 0 ? _tooltips$callout : t$1("neetoEditor.menu.callout"),
|
|
3031
|
+
isEnabled: options.includes(EDITOR_OPTIONS.CALLOUT),
|
|
3032
|
+
optionName: EDITOR_OPTIONS.CALLOUT,
|
|
3033
|
+
editor: editor,
|
|
3034
|
+
runEditorCommand: runEditorCommand,
|
|
3035
|
+
tooltipContent: (_tooltips$callout2 = tooltips.callout) !== null && _tooltips$callout2 !== void 0 ? _tooltips$callout2 : t$1("neetoEditor.menu.callout")
|
|
3036
|
+
}],
|
|
3037
|
+
// misc
|
|
3038
|
+
[{
|
|
3039
|
+
type: MENU_ELEMENT_TYPES.TABLE,
|
|
3040
|
+
label: (_tooltips$table = tooltips.table) !== null && _tooltips$table !== void 0 ? _tooltips$table : t$1("neetoEditor.menu.table"),
|
|
3041
|
+
isEnabled: options.includes(EDITOR_OPTIONS.TABLE),
|
|
3042
|
+
optionName: EDITOR_OPTIONS.TABLE
|
|
3043
|
+
}, {
|
|
3044
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
3045
|
+
icon: Attachment,
|
|
3046
|
+
command: function command() {
|
|
3047
|
+
return attachmentProps === null || attachmentProps === void 0 ? void 0 : attachmentProps.handleUploadAttachments();
|
|
3048
|
+
},
|
|
3049
|
+
disabled: attachmentProps === null || attachmentProps === void 0 ? void 0 : attachmentProps.isDisabled,
|
|
3050
|
+
isEnabled: options.includes(EDITOR_OPTIONS.ATTACHMENTS),
|
|
3051
|
+
optionName: EDITOR_OPTIONS.ATTACHMENTS,
|
|
3052
|
+
label: (_tooltips$attachments = tooltips.attachments) !== null && _tooltips$attachments !== void 0 ? _tooltips$attachments : t$1("neetoEditor.menu.attachments")
|
|
3053
|
+
}, {
|
|
3054
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
3055
|
+
icon: File$1,
|
|
3056
|
+
command: function command() {
|
|
3057
|
+
if (!editor || !setIsNeetoKbArticleActive) return;
|
|
3058
|
+
var _editor$state$selecti = editor.state.selection,
|
|
3059
|
+
from = _editor$state$selecti.from,
|
|
3060
|
+
to = _editor$state$selecti.to;
|
|
3061
|
+
var cursorPos = editor.view.coordsAtPos(from);
|
|
3062
|
+
setIsNeetoKbArticleActive({
|
|
3063
|
+
active: true,
|
|
3064
|
+
editor: editor,
|
|
3065
|
+
range: {
|
|
3066
|
+
from: from,
|
|
3067
|
+
to: to
|
|
3068
|
+
},
|
|
3069
|
+
cursorPos: cursorPos
|
|
3070
|
+
});
|
|
3071
|
+
},
|
|
3072
|
+
isEnabled: options.includes(EDITOR_OPTIONS.NEETO_KB_ARTICLE),
|
|
3073
|
+
optionName: EDITOR_OPTIONS.NEETO_KB_ARTICLE,
|
|
3074
|
+
label: (_tooltips$neetoKbArti = tooltips.neetoKbArticle) !== null && _tooltips$neetoKbArti !== void 0 ? _tooltips$neetoKbArti : t$1("neetoEditor.menu.linkToNeetoKbArticle")
|
|
3075
|
+
}, {
|
|
3076
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
3077
|
+
icon: ImageUpload,
|
|
3078
|
+
command: function command() {
|
|
3079
|
+
return setMediaUploader(assoc("image", true));
|
|
3080
|
+
},
|
|
3081
|
+
isEnabled: options.includes(EDITOR_OPTIONS.IMAGE_UPLOAD),
|
|
3082
|
+
optionName: EDITOR_OPTIONS.IMAGE_UPLOAD,
|
|
3083
|
+
label: (_tooltips$imageUpload = tooltips.imageUpload) !== null && _tooltips$imageUpload !== void 0 ? _tooltips$imageUpload : t$1("neetoEditor.menu.imageUpload")
|
|
3084
|
+
}],
|
|
3085
|
+
// extras
|
|
3086
|
+
[{
|
|
3087
|
+
type: MENU_ELEMENT_TYPES.TEXT_COLOR,
|
|
3088
|
+
label: (_tooltips$textColor = tooltips.textColor) !== null && _tooltips$textColor !== void 0 ? _tooltips$textColor : t$1("neetoEditor.menu.textColor"),
|
|
3089
|
+
isEnabled: options.includes(EDITOR_OPTIONS.TEXT_COLOR),
|
|
3090
|
+
optionName: EDITOR_OPTIONS.TEXT_COLOR
|
|
3091
|
+
}, {
|
|
3092
|
+
type: MENU_ELEMENT_TYPES.EMOJI,
|
|
3093
|
+
label: (_tooltips$emoji = tooltips.emoji) !== null && _tooltips$emoji !== void 0 ? _tooltips$emoji : t$1("neetoEditor.menu.emoji"),
|
|
3094
|
+
isEnabled: options.includes(EDITOR_OPTIONS.EMOJI),
|
|
3095
|
+
optionName: EDITOR_OPTIONS.EMOJI,
|
|
3096
|
+
setActive: setIsEmojiPickerActive,
|
|
3097
|
+
isActive: isEmojiPickerActive
|
|
3098
|
+
}, {
|
|
3099
|
+
type: MENU_ELEMENT_TYPES.MENTIONS,
|
|
3100
|
+
label: (_tooltips$mention = tooltips.mention) !== null && _tooltips$mention !== void 0 ? _tooltips$mention : t$1("neetoEditor.menu.mention"),
|
|
3101
|
+
isEnabled: isNotEmpty(mentions),
|
|
3102
|
+
optionName: "mentions",
|
|
3103
|
+
mentions: mentions
|
|
3104
|
+
}, {
|
|
3105
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
3106
|
+
icon: Code,
|
|
3107
|
+
command: runEditorCommand(function (editor) {
|
|
3108
|
+
return editor.chain().focus().toggleCode().run();
|
|
3109
|
+
}),
|
|
3110
|
+
isEnabled: options.includes(EDITOR_OPTIONS.CODE),
|
|
3111
|
+
optionName: EDITOR_OPTIONS.CODE,
|
|
3112
|
+
label: (_tooltips$code = tooltips.code) !== null && _tooltips$code !== void 0 ? _tooltips$code : t$1("neetoEditor.menu.code")
|
|
3113
|
+
}, {
|
|
3114
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
3115
|
+
icon: CodeBlock,
|
|
3116
|
+
command: runEditorCommand(function (editor) {
|
|
3117
|
+
return editor.chain().focus().toggleCodeBlock().run();
|
|
3118
|
+
}),
|
|
3119
|
+
isEnabled: options.includes(EDITOR_OPTIONS.CODE_BLOCK),
|
|
3120
|
+
optionName: "codeBlock",
|
|
3121
|
+
label: (_tooltips$codeBlock = tooltips.codeBlock) !== null && _tooltips$codeBlock !== void 0 ? _tooltips$codeBlock : t$1("neetoEditor.menu.codeBlock")
|
|
3122
|
+
}, {
|
|
3123
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
3124
|
+
icon: Video,
|
|
3125
|
+
command: function command() {
|
|
3126
|
+
return setMediaUploader(assoc("video", true));
|
|
3127
|
+
},
|
|
3128
|
+
isEnabled: options.includes(EDITOR_OPTIONS.VIDEO_UPLOAD),
|
|
3129
|
+
optionName: EDITOR_OPTIONS.VIDEO_UPLOAD,
|
|
3130
|
+
label: (_tooltips$videoUpload = tooltips.videoUpload) !== null && _tooltips$videoUpload !== void 0 ? _tooltips$videoUpload : t$1("neetoEditor.menu.videoUpload")
|
|
3131
|
+
}, {
|
|
3132
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
3133
|
+
icon: Underline,
|
|
3134
|
+
isEnabled: options.includes(EDITOR_OPTIONS.UNDERLINE),
|
|
3135
|
+
command: runEditorCommand(function (editor) {
|
|
3136
|
+
return editor.chain().focus().toggleUnderline().run();
|
|
3137
|
+
}),
|
|
3138
|
+
optionName: EDITOR_OPTIONS.UNDERLINE,
|
|
3139
|
+
label: (_tooltips$underline = tooltips.underline) !== null && _tooltips$underline !== void 0 ? _tooltips$underline : t$1("neetoEditor.menu.underline")
|
|
3140
|
+
}], //addons
|
|
3141
|
+
_toConsumableArray(addonCommandOptions),
|
|
3142
|
+
// history
|
|
3143
|
+
[{
|
|
3144
|
+
icon: Undo,
|
|
3145
|
+
command: runEditorCommand(function (editor) {
|
|
3146
|
+
return editor.chain().focus().undo().run();
|
|
3147
|
+
}),
|
|
3148
|
+
isEnabled: options.includes(EDITOR_OPTIONS.UNDO),
|
|
3149
|
+
optionName: EDITOR_OPTIONS.UNDO,
|
|
3150
|
+
label: (_tooltips$undo = tooltips.undo) !== null && _tooltips$undo !== void 0 ? _tooltips$undo : t$1("neetoEditor.menu.undo"),
|
|
3151
|
+
type: MENU_ELEMENT_TYPES.BUTTON
|
|
3152
|
+
}, {
|
|
3153
|
+
icon: Redo,
|
|
3154
|
+
command: runEditorCommand(function (editor) {
|
|
3155
|
+
return editor.chain().focus().redo().run();
|
|
3156
|
+
}),
|
|
3157
|
+
isEnabled: options.includes(EDITOR_OPTIONS.REDO),
|
|
3158
|
+
optionName: EDITOR_OPTIONS.REDO,
|
|
3159
|
+
label: (_tooltips$redo = tooltips.redo) !== null && _tooltips$redo !== void 0 ? _tooltips$redo : t$1("neetoEditor.menu.redo"),
|
|
3160
|
+
type: MENU_ELEMENT_TYPES.BUTTON
|
|
3161
|
+
}]];
|
|
3162
|
+
};
|
|
3163
|
+
var buildOptionsFromAddonCommands = function buildOptionsFromAddonCommands(_ref2) {
|
|
3164
|
+
var commands = _ref2.commands,
|
|
3165
|
+
runEditorCommand = _ref2.runEditorCommand;
|
|
3166
|
+
return commands.map(function (option) {
|
|
3167
|
+
return _objectSpread$1(_objectSpread$1({}, option), {}, {
|
|
3168
|
+
type: MENU_ELEMENT_TYPES.BUTTON,
|
|
3169
|
+
command: runEditorCommand(function (editor) {
|
|
3170
|
+
var _option$command, _editor$state, _editor$state2;
|
|
3171
|
+
return (_option$command = option.command) === null || _option$command === void 0 ? void 0 : _option$command.call(option, {
|
|
3172
|
+
editor: editor,
|
|
3173
|
+
range: {
|
|
3174
|
+
from: (_editor$state = editor.state) === null || _editor$state === void 0 || (_editor$state = _editor$state.selection) === null || _editor$state === void 0 ? void 0 : _editor$state.to,
|
|
3175
|
+
to: (_editor$state2 = editor.state) === null || _editor$state2 === void 0 ? void 0 : _editor$state2.selection.to
|
|
3176
|
+
}
|
|
3177
|
+
});
|
|
3178
|
+
})
|
|
3179
|
+
});
|
|
3180
|
+
});
|
|
3181
|
+
};
|
|
3182
|
+
var buildMenuOptions = function buildMenuOptions(_ref3) {
|
|
3183
|
+
var tooltips = _ref3.tooltips,
|
|
3184
|
+
options = _ref3.options,
|
|
3185
|
+
setMediaUploader = _ref3.setMediaUploader,
|
|
3186
|
+
attachmentProps = _ref3.attachmentProps,
|
|
3187
|
+
setIsAddLinkActive = _ref3.setIsAddLinkActive,
|
|
3188
|
+
_ref3$mentions = _ref3.mentions,
|
|
3189
|
+
mentions = _ref3$mentions === void 0 ? [] : _ref3$mentions,
|
|
3190
|
+
addonCommands = _ref3.addonCommands,
|
|
3191
|
+
setIsEmojiPickerActive = _ref3.setIsEmojiPickerActive,
|
|
3192
|
+
isEmojiPickerActive = _ref3.isEmojiPickerActive,
|
|
3193
|
+
runEditorCommand = _ref3.runEditorCommand,
|
|
3194
|
+
editor = _ref3.editor,
|
|
3195
|
+
setIsNeetoKbArticleActive = _ref3.setIsNeetoKbArticleActive;
|
|
3196
|
+
var addonCommandOptions = buildOptionsFromAddonCommands({
|
|
3197
|
+
commands: addonCommands,
|
|
3198
|
+
runEditorCommand: runEditorCommand
|
|
3199
|
+
});
|
|
3200
|
+
var menuOptions = createMenuOptions({
|
|
3201
|
+
tooltips: tooltips,
|
|
3202
|
+
setMediaUploader: setMediaUploader,
|
|
3203
|
+
attachmentProps: attachmentProps,
|
|
3204
|
+
setIsAddLinkActive: setIsAddLinkActive,
|
|
3205
|
+
options: options,
|
|
3206
|
+
mentions: mentions,
|
|
3207
|
+
addonCommandOptions: addonCommandOptions,
|
|
3208
|
+
setIsEmojiPickerActive: setIsEmojiPickerActive,
|
|
3209
|
+
isEmojiPickerActive: isEmojiPickerActive,
|
|
3210
|
+
runEditorCommand: runEditorCommand,
|
|
3211
|
+
editor: editor,
|
|
3212
|
+
setIsNeetoKbArticleActive: setIsNeetoKbArticleActive
|
|
3213
|
+
});
|
|
3214
|
+
return menuOptions.map(function (option) {
|
|
3215
|
+
return option.filter(prop("isEnabled"));
|
|
3216
|
+
});
|
|
3217
|
+
};
|
|
3218
|
+
var getCursorPos = function getCursorPos(editor, to) {
|
|
3219
|
+
return editor === null || editor === void 0 ? void 0 : editor.view.coordsAtPos(to);
|
|
3220
|
+
};
|
|
3221
|
+
var reGroupMenuItems = function reGroupMenuItems(menuRef, menuGroups) {
|
|
3222
|
+
var toolbarWidth = menuRef.current.offsetWidth;
|
|
3223
|
+
var totalWidth = 0;
|
|
3224
|
+
var visibleMenuGroups = [];
|
|
3225
|
+
var invisibleMenuGroups = [];
|
|
3226
|
+
menuGroups.forEach(function (group, groupIndex) {
|
|
3227
|
+
group.forEach(function (item, itemIndex) {
|
|
3228
|
+
var width = MENU_ELEMENT_WIDTHS[item.type];
|
|
3229
|
+
if (totalWidth + width < toolbarWidth) {
|
|
3230
|
+
var _visibleMenuGroups$gr;
|
|
3231
|
+
totalWidth += width;
|
|
3232
|
+
visibleMenuGroups[groupIndex] = (_visibleMenuGroups$gr = visibleMenuGroups[groupIndex]) !== null && _visibleMenuGroups$gr !== void 0 ? _visibleMenuGroups$gr : [];
|
|
3233
|
+
visibleMenuGroups[groupIndex][itemIndex] = item;
|
|
3234
|
+
} else {
|
|
3235
|
+
var _invisibleMenuGroups$;
|
|
3236
|
+
var visibleMenuGroupsLength = visibleMenuGroups.length;
|
|
3237
|
+
var index = groupIndex - visibleMenuGroupsLength + 1;
|
|
3238
|
+
invisibleMenuGroups[index] = (_invisibleMenuGroups$ = invisibleMenuGroups[index]) !== null && _invisibleMenuGroups$ !== void 0 ? _invisibleMenuGroups$ : [];
|
|
3239
|
+
invisibleMenuGroups[index][itemIndex] = item;
|
|
3240
|
+
}
|
|
3241
|
+
});
|
|
3242
|
+
});
|
|
3243
|
+
return {
|
|
3244
|
+
visibleMenuGroups: visibleMenuGroups,
|
|
3245
|
+
invisibleMenuGroups: invisibleMenuGroups
|
|
3246
|
+
};
|
|
3247
|
+
};
|
|
3248
|
+
var getLinkPopoverPosition = function getLinkPopoverPosition(editor, popoverRef) {
|
|
3249
|
+
var _editor$view$state$se = editor.view.state.selection,
|
|
3250
|
+
selectionEnd = _editor$view$state$se.$to.pos,
|
|
3251
|
+
selectionStart = _editor$view$state$se.$from.pos;
|
|
3252
|
+
var selectionLength = selectionEnd - selectionStart;
|
|
3253
|
+
var offset = 0;
|
|
3254
|
+
if (selectionLength > 1) offset = Math.round(selectionLength / 2);
|
|
3255
|
+
if (selectionLength === 1) offset = 1;
|
|
3256
|
+
|
|
3257
|
+
// Calculate the arrow position
|
|
3258
|
+
var arrowCoords = editor.view.coordsAtPos(selectionStart + offset);
|
|
3259
|
+
var arrowPosition = {
|
|
3260
|
+
top: "".concat(arrowCoords.top + 21, "px"),
|
|
3261
|
+
left: "".concat(arrowCoords.left - 8.5, "px")
|
|
3262
|
+
};
|
|
3263
|
+
|
|
3264
|
+
// Calculate the popover position
|
|
3265
|
+
var popoverCoords = editor.view.coordsAtPos(selectionStart);
|
|
3266
|
+
var adjustedLeft = popoverCoords === null || popoverCoords === void 0 ? void 0 : popoverCoords.left,
|
|
3267
|
+
adjustedTop = popoverCoords === null || popoverCoords === void 0 ? void 0 : popoverCoords.top;
|
|
3268
|
+
if (popoverRef !== null && popoverRef !== void 0 && popoverRef.current) {
|
|
3269
|
+
var _popoverRef$current;
|
|
3270
|
+
var popoverRect = (_popoverRef$current = popoverRef.current) === null || _popoverRef$current === void 0 ? void 0 : _popoverRef$current.getBoundingClientRect();
|
|
3271
|
+
var screenWidth = window.innerWidth;
|
|
3272
|
+
var screenHeight = window.innerHeight;
|
|
3273
|
+
var maxLeft = screenWidth - popoverRect.width;
|
|
3274
|
+
var maxTop = screenHeight - popoverRect.height - 50;
|
|
3275
|
+
adjustedLeft = popoverCoords !== null && popoverCoords !== void 0 && popoverCoords.left ? Math.min(popoverCoords.left - 50, maxLeft) : 0;
|
|
3276
|
+
adjustedTop = popoverCoords !== null && popoverCoords !== void 0 && popoverCoords.top ? Math.min(popoverCoords.top - 22, maxTop) : 0;
|
|
3277
|
+
} else {
|
|
3278
|
+
adjustedLeft = popoverCoords.left - 50;
|
|
3279
|
+
adjustedTop = popoverCoords.top - 22;
|
|
3280
|
+
}
|
|
3281
|
+
var popoverPosition = {
|
|
3282
|
+
top: "".concat(adjustedTop, "px"),
|
|
3283
|
+
left: "".concat(adjustedLeft, "px")
|
|
3284
|
+
};
|
|
3285
|
+
return {
|
|
3286
|
+
arrowPosition: arrowPosition,
|
|
3287
|
+
popoverPosition: popoverPosition
|
|
3288
|
+
};
|
|
3289
|
+
};
|
|
3290
|
+
function renderTooltipContent(label, optionName) {
|
|
3291
|
+
var shortcut = SHORTCUTS[optionName];
|
|
3292
|
+
if (!shortcut) return label;
|
|
3293
|
+
var isMac = function isMac() {
|
|
3294
|
+
return typeof window !== "undefined" && /Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent);
|
|
3295
|
+
};
|
|
3296
|
+
var key = isMac() ? shortcut.mac : shortcut.win;
|
|
3297
|
+
return "".concat(label, " (").concat(key, ")");
|
|
3298
|
+
}
|
|
3299
|
+
|
|
3300
|
+
var css = ".neeto-editor-fixed-menu{background-color:rgb(var(--neeto-ui-white));border:thin solid rgb(var(--neeto-ui-gray-400));border-bottom:none;border-radius:var(--neeto-ui-rounded) var(--neeto-ui-rounded) 0 0;display:flex;position:relative}.neeto-editor-fixed-menu--independant{border-bottom:thin solid rgb(var(--neeto-ui-gray-400));border-radius:0;border-radius:initial}.neeto-editor-fixed-menu--independant .neeto-editor-fixed-menu__wrapper{border-bottom:0!important}.neeto-editor-fixed-menu--independant .neeto-editor-fixed-menu__wrapper button.neeto-editor-fixed-menu__item .neeto-ui-btn__icon path{stroke-width:1.8px}.neeto-editor-fixed-menu__item{border-radius:0}.neeto-editor-fixed-menu button.neeto-editor-fixed-menu__item{--neeto-ui-btn-border-radius:0;--neeto-ui-btn-icon-size:22px;--neeto-ui-btn-padding-x:0;--neeto-ui-btn-padding-y:0;--neeto-ui-btn-focus-box-shadow:none;align-items:center;height:36px;justify-content:center;min-width:-moz-fit-content;min-width:fit-content;padding:0;width:36px}.neeto-editor-fixed-menu button.neeto-editor-fixed-menu__item .neeto-ui-btn__icon{color:rgb(var(--neeto-ui-black))}.neeto-editor-fixed-menu button.neeto-editor-fixed-menu__item .neeto-ui-btn__icon path{stroke-width:1.5px}.neeto-editor-fixed-menu button.neeto-editor-fixed-menu__item:hover{background-color:rgb(var(--neeto-ui-gray-100))}.neeto-editor-fixed-menu button.neeto-editor-fixed-menu__item.neeto-ui-btn--style-secondary{background-color:rgb(var(--neeto-ui-accent-100))}.neeto-editor-fixed-menu button.neeto-editor-fixed-menu__item.neeto-ui-btn--style-secondary .neeto-ui-btn__icon{color:rgb(var(--neeto-ui-accent-800))}.neeto-editor-fixed-menu__wrapper{align-items:center;border-bottom:thin solid rgb(var(--neeto-ui-gray-400));display:flex;flex-grow:1;justify-content:flex-start;padding:0 2px;width:100%}.neeto-editor-fixed-menu__wrapper__button-group{display:flex}.neeto-editor-fixed-menu__variables{bottom:-42px;inset-inline-end:8px;position:absolute;z-index:10}.neeto-editor-fixed-menu__variables .neeto-editor-menu__item{background-color:rgb(var(--neeto-ui-gray-700));border-radius:var(--neeto-ui-rounded-sm);padding:4px}.neeto-editor-fixed-menu__variables .neeto-editor-menu__item.active,.neeto-editor-fixed-menu__variables .neeto-editor-menu__item:hover{background-color:rgb(var(--neeto-ui-gray-600))}.neeto-editor-fixed-menu__variables--standalone{bottom:auto;inset-inline-end:0;position:absolute;top:8px;z-index:10}.neeto-editor-fixed-menu__right-options{display:flex}.neeto-editor-fixed-menu__emoji-dropdown{max-height:none!important}.neeto-editor-fixed-menu__separator{display:flex;height:28px;width:32px}.neeto-editor-fixed-menu__separator span{width:100%}.neeto-editor-fixed-menu__separator span:first-child{border-inline-end:1px solid rgb(var(--neeto-ui-gray-200))}.neeto-editor-text-color-option__options-group{align-items:center;display:flex;gap:8px;margin-block:8px;margin-inline:4px}.neeto-editor-text-color-option__options-group__input{max-width:120px}.neeto-editor-text-color-option__options-group__reset-button{align-self:center}.react-colorful{width:100%!important}.neeto-editor-menu__item{align-items:center;border-radius:2px;cursor:pointer;display:flex;flex-direction:row;gap:4px;justify-content:center;padding:8px;transition:var(--neeto-ui-transition)}.neeto-editor-menu__item p{color:rgb(var(--neeto-ui-gray-600));font-size:var(--neeto-ui-text-xs);line-height:1;white-space:nowrap}.neeto-editor-menu__item.active,.neeto-editor-menu__item:hover{background-color:rgb(var(--neeto-ui-gray-200))}.neeto-editor-menu__item:focus,.neeto-editor-menu__item:focus-visible{outline:rgb(var(--neeto-ui-gray-300)) auto 1px}.neeto-editor-menu__item input[type=color]{height:0;visibility:hidden;width:0}.neeto-editor-menu__item:disabled{background-color:rgb(var(--neeto-ui-gray-100));opacity:.5}.neeto-editor-link__item{align-items:flex-start;justify-content:flex-start}.neeto-editor-link__item,.neeto-editor-table__item{display:flex!important;flex-direction:row;gap:8px;padding:8px!important}.neeto-editor-table__item{min-width:210px}.neeto-editor-table__item input{max-width:60px!important}.neeto-editor-table__options-menu{display:flex;flex-direction:column;gap:8px;max-height:150px!important;overflow:scroll;padding:8px!important}.neeto-editor-font-size__wrapper{font-size:16px;font-weight:var(--neeto-ui-font-normal)!important;padding-inline-end:4px!important;padding-inline-start:4px!important}.tippy-box[data-theme~=neeto-editor-bubble-menu-tippy-box]{box-shadow:none!important}.tippy-box[data-theme~=neeto-editor-bubble-menu-tippy-box] .tippy-content{padding:0!important}.tippy-box[data-theme~=neeto-editor-common-submenu-tippy-box]{box-shadow:none!important}.tippy-box[data-theme~=neeto-editor-common-submenu-tippy-box] .tippy-content{padding:0!important}.neeto-editor-bubble-menu{align-items:center;background:rgb(var(--neeto-ui-white));border:1px solid rgb(var(--neeto-ui-gray-400));border-radius:var(--neeto-ui-rounded);display:flex;flex-direction:row;gap:0;justify-content:flex-start;overflow-x:auto;padding:0;position:relative}.neeto-editor-bubble-menu>.neeto-editor-bubble-menu__item:first-child,.neeto-editor-bubble-menu>.neeto-editor-fixed-menu__item:first-child,.neeto-editor-bubble-menu>.neeto-editor-table-bubble-menu__item:first-child{border-bottom-left-radius:var(--neeto-ui-rounded);border-top-left-radius:var(--neeto-ui-rounded)}.neeto-editor-bubble-menu>.neeto-editor-bubble-menu__item:last-child,.neeto-editor-bubble-menu>.neeto-editor-fixed-menu__item:last-child,.neeto-editor-bubble-menu>.neeto-editor-table-bubble-menu__item:last-child{border-bottom-right-radius:var(--neeto-ui-rounded);border-top-right-radius:var(--neeto-ui-rounded)}.neeto-editor-bubble-menu button.neeto-editor-bubble-menu__item,.neeto-editor-bubble-menu button.neeto-editor-fixed-menu__item,.neeto-editor-bubble-menu button.neeto-editor-table-bubble-menu__item{--neeto-ui-btn-border-radius:0;--neeto-ui-btn-icon-size:22px;--neeto-ui-btn-padding-x:0;--neeto-ui-btn-padding-y:0;--neeto-ui-btn-focus-box-shadow:none;align-items:center;color:rgb(var(--neeto-ui-black))!important;flex-shrink:0;height:36px;justify-content:center;min-width:-moz-fit-content;min-width:fit-content;width:36px}.neeto-editor-bubble-menu button.neeto-editor-bubble-menu__item .neeto-ui-btn__icon,.neeto-editor-bubble-menu button.neeto-editor-fixed-menu__item .neeto-ui-btn__icon,.neeto-editor-bubble-menu button.neeto-editor-table-bubble-menu__item .neeto-ui-btn__icon{color:rgb(var(--neeto-ui-black))}.neeto-editor-bubble-menu button.neeto-editor-bubble-menu__item .neeto-ui-btn__icon path,.neeto-editor-bubble-menu button.neeto-editor-fixed-menu__item .neeto-ui-btn__icon path,.neeto-editor-bubble-menu button.neeto-editor-table-bubble-menu__item .neeto-ui-btn__icon path{stroke-width:1.5px}.neeto-editor-bubble-menu button.neeto-editor-bubble-menu__item.active,.neeto-editor-bubble-menu button.neeto-editor-bubble-menu__item:active,.neeto-editor-bubble-menu button.neeto-editor-bubble-menu__item:hover,.neeto-editor-bubble-menu button.neeto-editor-fixed-menu__item.active,.neeto-editor-bubble-menu button.neeto-editor-fixed-menu__item:active,.neeto-editor-bubble-menu button.neeto-editor-fixed-menu__item:hover,.neeto-editor-bubble-menu button.neeto-editor-table-bubble-menu__item.active,.neeto-editor-bubble-menu button.neeto-editor-table-bubble-menu__item:active,.neeto-editor-bubble-menu button.neeto-editor-table-bubble-menu__item:hover{background-color:rgb(var(--neeto-ui-gray-100))}.neeto-editor-bubble-menu button.neeto-editor-bubble-menu__item.neeto-ui-btn--style-secondary{background-color:rgb(var(--neeto-ui-accent-100))!important}.neeto-editor-bubble-menu button.neeto-editor-bubble-menu__item.neeto-ui-btn--style-secondary .neeto-ui-btn__icon{color:rgb(var(--neeto-ui-accent-800))!important}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__link{align-items:center;display:flex;gap:6px;justify-content:space-between;padding:6px;width:256px}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__link .neeto-editor-bubble-menu-link__input{background-color:transparent;background-color:var(--neeto-ui-input-bg-color);border:var(--neeto-ui-input-border-width) solid var(--neeto-ui-input-border-color);border-radius:var(--neeto-ui-input-border-radius);color:var(--neeto-ui-input-color);font-size:var(--neeto-ui-input-font-size);height:28px;line-height:1.2;outline:none;transition:var(--neeto-ui-transition);width:100%}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__link .neeto-editor-bubble-menu-link__input::-moz-placeholder{color:rgba(.4);color:rgba(var(--neeto-ui-white,.4))}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__link .neeto-editor-bubble-menu-link__input::placeholder{color:rgba(.4);color:rgba(var(--neeto-ui-white,.4))}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__link .ne-btn--icon-only{min-height:0;opacity:.8;padding:0}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__link .ne-btn--icon-only:hover{opacity:1}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__table{align-items:flex-start;display:flex;gap:6px;justify-content:space-between;max-width:256px;padding:4px}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__table input{background-color:var(--neeto-ui-input-bg-color);border:var(--neeto-ui-input-border-width) solid var(--neeto-ui-input-border-color);border-radius:var(--neeto-ui-input-border-radius);color:var(--neeto-ui-input-color);font-size:var(--neeto-ui-input-font-size);height:28px;line-height:1.2;outline:none;padding-block:3px;padding-inline:5px;transition:var(--neeto-ui-transition);width:60px}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__table input::-moz-placeholder{color:rgb(var(--neeto-ui-gray-500))}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__table input::placeholder{color:rgb(var(--neeto-ui-gray-500))}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__table__menu-item{display:flex;flex-direction:column;gap:6px}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__table__input-label{color:rgb(var(--neeto-ui-gray-800))}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__table__buttons{align-self:flex-end;display:flex;gap:4px;justify-content:space-between}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__table__options{display:flex;flex-direction:column;gap:2px;max-height:190px;overflow:scroll}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__dropdown-target{align-items:center;display:flex;font-size:var(--neeto-ui-text-xs);gap:4px;line-height:var(--neeto-ui-leading-normal);white-space:nowrap}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__dropdown{align-items:flex-start;display:flex;flex-direction:column}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__dropdown .neeto-editor-bubble-menu__dropdown-item{font-size:var(--neeto-ui-text-xs);padding-block:8px;padding-inline:12px;text-align:start;width:100%}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__dropdown .neeto-editor-bubble-menu__dropdown-item:first-child{border-top-left-radius:var(--neeto-ui-rounded);border-top-right-radius:var(--neeto-ui-rounded)}.neeto-editor-bubble-menu .neeto-editor-bubble-menu__dropdown .neeto-editor-bubble-menu__dropdown-item:last-child{border-bottom-left-radius:var(--neeto-ui-rounded);border-bottom-right-radius:var(--neeto-ui-rounded)}.neeto-editor-bubble-menu-animate-shake{animation:shake 1s linear infinite alternate both}.neeto-editor-table-menu__button{align-items:flex-end;display:flex}.neeto-editor__image-menu .neeto-ui-dropdown__popup{display:flex;min-width:0;min-width:auto}.neeto-editor__image-menu .neeto-ui-dropdown__popup .neeto-ui-btn .neeto-ui-btn__icon{height:18px!important;width:18px!important}.neeto-editor__image-menu-btn{border-radius:100%;inset-inline-end:6px;position:absolute!important;top:6px;z-index:1}.neeto-editor-menu-font-size-options{padding:8px!important}.neeto-editor-menu-font-size-options .neeto-ui-dropdown__popup-menu-item{background-color:transparent!important}.neeto-editor-menu-font-size-options .neeto-editor-menu-font-size-options__item-btn{border-radius:var(--neeto-ui-btn-border-radius)!important;justify-content:center;min-height:34px;min-width:34px;overflow:hidden;padding-inline-end:0!important;padding-inline-start:0!important;text-align:center}.neeto-editor-menu-font-size-options .neeto-editor-menu-font-size-options__item-btn--selected{background-color:rgb(var(--neeto-ui-accent-100))!important;color:rgb(var(--neeto-ui-accent-800))!important}.neeto-editor-table-bubble-menu__dropdown .neeto-ui-dropdown__popup{min-width:auto}.neeto-editor-table-bubble-menu__dropdown .neeto-ui-dropdown__popup .neeto-ui-dropdown__popup-menu{--neeto-ui-btn-border-radius:0;padding:0}.neeto-editor-fixed-menu-standalone-variables-wrapper{position:relative}";
|
|
3301
|
+
n(css,{});
|
|
3302
|
+
|
|
3303
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3304
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3305
|
+
var Menu = function Menu(props) {
|
|
3306
|
+
var _useState = useState(false),
|
|
3307
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3308
|
+
isEmojiPickerActive = _useState2[0],
|
|
3309
|
+
setIsEmojiPickerActive = _useState2[1];
|
|
3310
|
+
var _useState3 = useState({
|
|
3311
|
+
image: false,
|
|
3312
|
+
video: false
|
|
3313
|
+
}),
|
|
3314
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
3315
|
+
mediaUploader = _useState4[0],
|
|
3316
|
+
setMediaUploader = _useState4[1];
|
|
3317
|
+
var _props$menuType = props.menuType,
|
|
3318
|
+
menuType = _props$menuType === void 0 ? "fixed" : _props$menuType,
|
|
3319
|
+
_props$addons = props.addons,
|
|
3320
|
+
addons = _props$addons === void 0 ? [] : _props$addons,
|
|
3321
|
+
_props$options = props.options,
|
|
3322
|
+
options = _props$options === void 0 ? [] : _props$options,
|
|
3323
|
+
_props$editorSecrets = props.editorSecrets,
|
|
3324
|
+
editorSecrets = _props$editorSecrets === void 0 ? {} : _props$editorSecrets,
|
|
3325
|
+
attachmentProps = props.attachmentProps,
|
|
3326
|
+
_props$defaults = props.defaults,
|
|
3327
|
+
defaults = _props$defaults === void 0 ? DEFAULT_EDITOR_OPTIONS : _props$defaults;
|
|
3328
|
+
var MenuComponent = useMemo(function () {
|
|
3329
|
+
return MENU_COMPONENTS[menuType];
|
|
3330
|
+
}, [menuType]);
|
|
3331
|
+
var menuOptions = isEmpty(options) ? [].concat(_toConsumableArray(defaults), _toConsumableArray(addons)) : options;
|
|
3332
|
+
useEffect(function () {
|
|
3333
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
3334
|
+
if ((e.metaKey || e.ctrlKey) && e.altKey) {
|
|
3335
|
+
if (e.code === "KeyE") {
|
|
3336
|
+
setIsEmojiPickerActive(function (prevState) {
|
|
3337
|
+
return !prevState;
|
|
3338
|
+
});
|
|
3339
|
+
} else if (e.code === "KeyA") {
|
|
3340
|
+
not(attachmentProps === null || attachmentProps === void 0 ? void 0 : attachmentProps.isDisabled) && (attachmentProps === null || attachmentProps === void 0 ? void 0 : attachmentProps.handleUploadAttachments());
|
|
3341
|
+
} else if (e.code === "KeyK") {
|
|
3342
|
+
setMediaUploader(assoc("image", true));
|
|
3343
|
+
} else if (e.code === "KeyV") {
|
|
3344
|
+
setMediaUploader(assoc("video", true));
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
};
|
|
3348
|
+
if (menuType !== "none") {
|
|
3349
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
3350
|
+
}
|
|
3351
|
+
return function () {
|
|
3352
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
3353
|
+
};
|
|
3354
|
+
}, []);
|
|
3355
|
+
return /*#__PURE__*/jsx(MenuComponent, _objectSpread(_objectSpread({}, _objectSpread(_objectSpread({}, props), {}, {
|
|
3356
|
+
attachmentProps: attachmentProps,
|
|
3357
|
+
isEmojiPickerActive: isEmojiPickerActive,
|
|
3358
|
+
mediaUploader: mediaUploader,
|
|
3359
|
+
setIsEmojiPickerActive: setIsEmojiPickerActive,
|
|
3360
|
+
setMediaUploader: setMediaUploader
|
|
3361
|
+
})), {}, {
|
|
3362
|
+
options: menuOptions,
|
|
3363
|
+
unsplashApiKey: editorSecrets.unsplash
|
|
3364
|
+
}));
|
|
3365
|
+
};
|
|
3366
|
+
|
|
3367
|
+
export { CALLOUT_TYPES as C, EmojiPickerMenu as E, LinkAddPopOver as L, Menu as M, MenuDynamicVariables as a, MediaUploader as b, getLinkPopoverPosition as g, validateUrl as v };
|
|
3368
|
+
//# sourceMappingURL=chunk-DcFvJOrc.js.map
|