@bigbinary/neeto-editor-frontend 2.2.5 → 2.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/app/javascript/src/translations/ar.json +2 -1
  2. package/app/javascript/src/translations/bg.json +2 -1
  3. package/app/javascript/src/translations/ca.json +2 -1
  4. package/app/javascript/src/translations/cs.json +2 -1
  5. package/app/javascript/src/translations/da.json +2 -1
  6. package/app/javascript/src/translations/de.json +2 -1
  7. package/app/javascript/src/translations/en.json +2 -1
  8. package/app/javascript/src/translations/es-MX.json +2 -1
  9. package/app/javascript/src/translations/es.json +2 -1
  10. package/app/javascript/src/translations/et.json +2 -1
  11. package/app/javascript/src/translations/fi.json +2 -1
  12. package/app/javascript/src/translations/fil.json +2 -1
  13. package/app/javascript/src/translations/fr.json +2 -1
  14. package/app/javascript/src/translations/he.json +2 -1
  15. package/app/javascript/src/translations/hi.json +2 -1
  16. package/app/javascript/src/translations/hr.json +2 -1
  17. package/app/javascript/src/translations/hu.json +2 -1
  18. package/app/javascript/src/translations/id.json +2 -1
  19. package/app/javascript/src/translations/it.json +2 -1
  20. package/app/javascript/src/translations/ja.json +2 -1
  21. package/app/javascript/src/translations/ko.json +2 -1
  22. package/app/javascript/src/translations/lv.json +2 -1
  23. package/app/javascript/src/translations/nl.json +2 -1
  24. package/app/javascript/src/translations/pl.json +2 -1
  25. package/app/javascript/src/translations/pt-BR.json +2 -1
  26. package/app/javascript/src/translations/pt.json +2 -1
  27. package/app/javascript/src/translations/ro.json +2 -1
  28. package/app/javascript/src/translations/ru.json +2 -1
  29. package/app/javascript/src/translations/sk.json +2 -1
  30. package/app/javascript/src/translations/sl.json +2 -1
  31. package/app/javascript/src/translations/sv.json +2 -1
  32. package/app/javascript/src/translations/th.json +2 -1
  33. package/app/javascript/src/translations/tr.json +2 -1
  34. package/app/javascript/src/translations/uk.json +2 -1
  35. package/app/javascript/src/translations/vi.json +2 -1
  36. package/app/javascript/src/translations/zh-CN.json +2 -1
  37. package/app/javascript/src/translations/zh-TW.json +2 -1
  38. package/dist/.ready +1 -1
  39. package/dist/Attachments.js +4 -4
  40. package/dist/Editor.js +8 -8
  41. package/dist/EditorContent.js +2 -2
  42. package/dist/FormikEditor.js +8 -8
  43. package/dist/Menu.js +6 -6
  44. package/dist/{chunk-UwzgbfZD.js → chunk-71BzByG6.js} +2 -1
  45. package/dist/chunk-71BzByG6.js.map +1 -0
  46. package/dist/{chunk-C_4zmIBQ.js → chunk-B-DmzF0q.js} +3 -3
  47. package/dist/{chunk-C_4zmIBQ.js.map → chunk-B-DmzF0q.js.map} +1 -1
  48. package/dist/{chunk-BozdxlzB.js → chunk-BE7om7ts.js} +2 -2
  49. package/dist/{chunk-BozdxlzB.js.map → chunk-BE7om7ts.js.map} +1 -1
  50. package/dist/{chunk-CLjWv4gG.js → chunk-BEopbFak.js} +5 -5
  51. package/dist/{chunk-CLjWv4gG.js.map → chunk-BEopbFak.js.map} +1 -1
  52. package/dist/chunk-BFj2DeQe.js +24 -0
  53. package/dist/chunk-BFj2DeQe.js.map +1 -0
  54. package/dist/{chunk-DwQ7NJtm.js → chunk-BlvmXrHo.js} +5 -5
  55. package/dist/chunk-BlvmXrHo.js.map +1 -0
  56. package/dist/{chunk-AexVHCkr.js → chunk-Bq_ijJy6.js} +5 -5
  57. package/dist/{chunk-AexVHCkr.js.map → chunk-Bq_ijJy6.js.map} +1 -1
  58. package/dist/{chunk-yBvbLjSM.js → chunk-Bqh1Tsc6.js} +3 -3
  59. package/dist/{chunk-yBvbLjSM.js.map → chunk-Bqh1Tsc6.js.map} +1 -1
  60. package/dist/{chunk-Bktpw5vs.js → chunk-Bskj5cbo.js} +6 -6
  61. package/dist/{chunk-Bktpw5vs.js.map → chunk-Bskj5cbo.js.map} +1 -1
  62. package/dist/{chunk-GA-wADEN.js → chunk-CMfrTj8Z.js} +3 -3
  63. package/dist/{chunk-GA-wADEN.js.map → chunk-CMfrTj8Z.js.map} +1 -1
  64. package/dist/chunk-CXFFqMSB.js +21232 -0
  65. package/dist/chunk-CXFFqMSB.js.map +1 -0
  66. package/dist/{chunk-D37Dlp9s.js → chunk-CYmA2oQ8.js} +5 -5
  67. package/dist/{chunk-D37Dlp9s.js.map → chunk-CYmA2oQ8.js.map} +1 -1
  68. package/dist/{chunk-CNIDH-FD.js → chunk-Dwn1Kihg.js} +2 -2
  69. package/dist/{chunk-CNIDH-FD.js.map → chunk-Dwn1Kihg.js.map} +1 -1
  70. package/dist/{chunk-BIgc5m-h.js → chunk-EjoZ4e18.js} +4 -4
  71. package/dist/{chunk-BIgc5m-h.js.map → chunk-EjoZ4e18.js.map} +1 -1
  72. package/dist/{chunk-CivYrffM.js → chunk-PFB_80PR.js} +4 -4
  73. package/dist/{chunk-CivYrffM.js.map → chunk-PFB_80PR.js.map} +1 -1
  74. package/dist/{chunk-BHi0J28T.js → chunk-Verd5n0p.js} +7 -6
  75. package/dist/chunk-Verd5n0p.js.map +1 -0
  76. package/dist/cjs/Attachments.cjs.js +4 -4
  77. package/dist/cjs/Editor.cjs.js +8 -8
  78. package/dist/cjs/EditorContent.cjs.js +2 -2
  79. package/dist/cjs/FormikEditor.cjs.js +8 -8
  80. package/dist/cjs/Menu.cjs.js +6 -6
  81. package/dist/cjs/chunk-BIjq_wPr.cjs.js +21279 -0
  82. package/dist/cjs/chunk-BIjq_wPr.cjs.js.map +1 -0
  83. package/dist/cjs/{chunk-Cr0FBhRs.cjs.js → chunk-BhQA4bH9.cjs.js} +7 -6
  84. package/dist/cjs/chunk-BhQA4bH9.cjs.js.map +1 -0
  85. package/dist/cjs/{chunk-BfHU_Ynq.cjs.js → chunk-CE1t-vbx.cjs.js} +5 -5
  86. package/dist/cjs/{chunk-BfHU_Ynq.cjs.js.map → chunk-CE1t-vbx.cjs.js.map} +1 -1
  87. package/dist/cjs/{chunk-CKbuSSOi.cjs.js → chunk-CVJLunrU.cjs.js} +6 -6
  88. package/dist/cjs/{chunk-CKbuSSOi.cjs.js.map → chunk-CVJLunrU.cjs.js.map} +1 -1
  89. package/dist/cjs/{chunk-Niprqtd_.cjs.js → chunk-CgYpFN-j.cjs.js} +3 -3
  90. package/dist/cjs/{chunk-Niprqtd_.cjs.js.map → chunk-CgYpFN-j.cjs.js.map} +1 -1
  91. package/dist/cjs/{chunk-CfiRFXt2.cjs.js → chunk-Crr-dv3q.cjs.js} +4 -3
  92. package/dist/cjs/{chunk-CfiRFXt2.cjs.js.map → chunk-Crr-dv3q.cjs.js.map} +1 -1
  93. package/dist/cjs/chunk-CvnWF5Pm.cjs.js +26 -0
  94. package/dist/cjs/chunk-CvnWF5Pm.cjs.js.map +1 -0
  95. package/dist/cjs/{chunk-Df43FB6u.cjs.js → chunk-D-AVd9c9.cjs.js} +5 -5
  96. package/dist/cjs/{chunk-Df43FB6u.cjs.js.map → chunk-D-AVd9c9.cjs.js.map} +1 -1
  97. package/dist/cjs/{chunk-CpQ8t9br.cjs.js → chunk-D2INvafM.cjs.js} +3 -3
  98. package/dist/cjs/{chunk-CpQ8t9br.cjs.js.map → chunk-D2INvafM.cjs.js.map} +1 -1
  99. package/dist/cjs/{chunk-DuwgLqpD.cjs.js → chunk-DIpshzqU.cjs.js} +5 -5
  100. package/dist/cjs/{chunk-DuwgLqpD.cjs.js.map → chunk-DIpshzqU.cjs.js.map} +1 -1
  101. package/dist/cjs/{chunk-BxKa_XOs.cjs.js → chunk-DO6eyguX.cjs.js} +2 -1
  102. package/dist/cjs/chunk-DO6eyguX.cjs.js.map +1 -0
  103. package/dist/cjs/{chunk-CAaxrndK.cjs.js → chunk-DOiH1lXw.cjs.js} +4 -4
  104. package/dist/cjs/{chunk-CAaxrndK.cjs.js.map → chunk-DOiH1lXw.cjs.js.map} +1 -1
  105. package/dist/cjs/{chunk-Ct6vCCZ0.cjs.js → chunk-DnoebPXq.cjs.js} +5 -4
  106. package/dist/cjs/chunk-DnoebPXq.cjs.js.map +1 -0
  107. package/dist/cjs/{chunk-Df33Mipq.cjs.js → chunk-DoDh8RsI.cjs.js} +2 -2
  108. package/dist/cjs/{chunk-Df33Mipq.cjs.js.map → chunk-DoDh8RsI.cjs.js.map} +1 -1
  109. package/dist/cjs/{chunk-CQ-j2kAX.cjs.js → chunk-G_6vNGIP.cjs.js} +2 -2
  110. package/dist/cjs/{chunk-CQ-j2kAX.cjs.js.map → chunk-G_6vNGIP.cjs.js.map} +1 -1
  111. package/dist/cjs/{chunk-CkSG3yNC.cjs.js → chunk-z7T8oExT.cjs.js} +3 -3
  112. package/dist/cjs/{chunk-CkSG3yNC.cjs.js.map → chunk-z7T8oExT.cjs.js.map} +1 -1
  113. package/dist/cjs/constants.cjs.js +2 -2
  114. package/dist/cjs/index.cjs.js +8 -8
  115. package/dist/cjs/utils.cjs.js +3 -3
  116. package/dist/cjs/v2/Attachments.cjs.js +4 -4
  117. package/dist/cjs/v2/Editor.cjs.js +654 -25
  118. package/dist/cjs/v2/Editor.cjs.js.map +1 -1
  119. package/dist/cjs/v2/EditorContent.cjs.js +3 -3
  120. package/dist/cjs/v2/FormikEditor.cjs.js +9 -9
  121. package/dist/cjs/v2/Menu.cjs.js +4 -4
  122. package/dist/cjs/v2/constants.cjs.js +2 -2
  123. package/dist/cjs/v2/index.cjs.js +8 -8
  124. package/dist/cjs/v2/utils.cjs.js +3 -3
  125. package/dist/constants.js +2 -2
  126. package/dist/editor-stats.html +1 -19
  127. package/dist/index.js +8 -8
  128. package/dist/utils.js +3 -3
  129. package/dist/v2/Attachments.js +4 -4
  130. package/dist/v2/Editor.js +658 -29
  131. package/dist/v2/Editor.js.map +1 -1
  132. package/dist/v2/EditorContent.js +3 -3
  133. package/dist/v2/FormikEditor.js +9 -9
  134. package/dist/v2/Menu.js +4 -4
  135. package/dist/v2/constants.js +2 -2
  136. package/dist/v2/editor-content-styles.js +1 -1
  137. package/dist/v2/editor-content.min.css +1 -1
  138. package/dist/v2/index.js +8 -8
  139. package/dist/v2/styles.css +1 -1
  140. package/dist/v2/styles.js +1 -1
  141. package/dist/v2/utils.js +3 -3
  142. package/package.json +12 -11
  143. package/dist/chunk-BHi0J28T.js.map +0 -1
  144. package/dist/chunk-DwQ7NJtm.js.map +0 -1
  145. package/dist/chunk-UwzgbfZD.js.map +0 -1
  146. package/dist/cjs/chunk-BxKa_XOs.cjs.js.map +0 -1
  147. package/dist/cjs/chunk-Cr0FBhRs.cjs.js.map +0 -1
  148. package/dist/cjs/chunk-Ct6vCCZ0.cjs.js.map +0 -1
package/dist/v2/Editor.js CHANGED
@@ -2,29 +2,32 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
2
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
3
3
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
4
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
- import React__default, { memo, useState, useRef, useCallback, useEffect, createElement, forwardRef, useImperativeHandle } from 'react';
6
- import { DropdownMenu, Input, Button, Spinner, Tooltip, Toastr, Avatar, Typography, Select, Dialog, Checkbox as Checkbox$1, Label } from '@bigbinary/neeto-atoms';
7
- import { a as useEditorState, E as Extension, N as NodeViewWrapper, b as NodeViewContent, c as Node, R as ReactNodeViewRenderer, m as mergeAttributes, D as DecorationSet, d as Decoration, f as ReactRenderer, e as emojiPickerApi, h as markInputRule, I as InputRule, r as resetFocussedNode, i as highlightFocussedNode, ap as isInTable, aq as selectedRect, ar as findTable, as as TableMap, at as addRow, P as PasteRule, B as BubbleMenu, j as getMarkType, k as getMarkRange, l as useEditor, n as EditorContent, o as EditorView } from '../chunk-B5LsYrmv.js';
5
+ import React__default, { memo, useState, Suspense, lazy, useRef, useCallback, useEffect, createElement, forwardRef, useImperativeHandle } from 'react';
6
+ import { a as useEditorState, N as NodeViewWrapper, c as Node, R as ReactNodeViewRenderer, E as Extension, b as NodeViewContent, m as mergeAttributes, D as DecorationSet, d as Decoration, f as ReactRenderer, e as emojiPickerApi, h as markInputRule, I as InputRule, r as resetFocussedNode, i as highlightFocussedNode, ap as isInTable, aq as selectedRect, ar as findTable, as as TableMap, at as addRow, P as PasteRule, B as BubbleMenu, j as getMarkType, k as getMarkRange, l as useEditor, n as EditorContent, o as EditorView } from '../chunk-B5LsYrmv.js';
8
7
  import classnames from 'classnames';
9
- import { isNotPresent, findBy, isNotEmpty, isPresent, noop, slugify } from '@bigbinary/neeto-cist';
8
+ import { Spinner, Tooltip, Button, Toastr, DropdownMenu, Input, Avatar, Typography, Select, Dialog, Checkbox as Checkbox$1, Label } from '@bigbinary/neeto-atoms';
9
+ import { isNotPresent, isPresent, noop, findBy, isNotEmpty, slugify } from '@bigbinary/neeto-cist';
10
10
  import { useOnClickOutside, withT, useFuncDebounce } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
11
11
  import { createPortal } from 'react-dom';
12
- import { B as BulletList$1, s as src_default, a as src_default$1, R as Resizable, b as src_default$2, L as Link$1, c as scrollHandler, d as src_default$3, O as OrderedList$1, e as src_default$4, f as fuzzySearch, T as Table$2, g as TaskList, h as TaskItem, i as getVariableDisplay, j as getVideoDimension, C as CharacterCount, k as src_default$5, l as src_default$6, m as safeSplitBlock, n as safeListKeymap, o as TextStyle, p as src_default$7, F as Focus, q as src_default$8, r as TableRow, t as TableHeader, u as TableCell, v as Color, w as ListItem, x as src_default$9, y as src_default$a, z as useFetchKbArticles, K as useEditorWarnings, N as useDeletedArticles } from '../chunk-BozdxlzB.js';
13
- import { D as DIRECT_UPLOAD_ENDPOINT, E as EDITOR_OPTIONS, C as COMBINED_REGEX, a as EDITOR_SIZES } from '../chunk-UwzgbfZD.js';
12
+ import { B as BulletList$1, s as src_default, a as src_default$1, R as Resizable, b as src_default$2, L as Link$1, c as scrollHandler, d as src_default$3, O as OrderedList$1, e as src_default$4, f as fuzzySearch, T as Table$2, g as TaskList, h as TaskItem, i as getVariableDisplay, j as getVideoDimension, C as CharacterCount, k as src_default$5, l as src_default$6, m as safeSplitBlock, n as safeListKeymap, o as TextStyle, p as src_default$7, F as Focus, q as src_default$8, r as TableRow, t as TableHeader, u as TableCell, v as Color, w as ListItem, x as src_default$9, y as src_default$a, z as useFetchKbArticles, K as useEditorWarnings, N as useDeletedArticles } from '../chunk-BE7om7ts.js';
13
+ import { D as DIRECT_UPLOAD_ENDPOINT, E as EDITOR_OPTIONS, C as COMBINED_REGEX, a as EDITOR_SIZES } from '../chunk-71BzByG6.js';
14
14
  import { S as Slice, F as Fragment$1 } from '../chunk-C9H9LYpP.js';
15
- import '../chunk-CNIDH-FD.js';
16
- import { is, intersection, difference, union, isEmpty, isNil, mergeRight, assoc, equals } from 'ramda';
15
+ import '../chunk-Dwn1Kihg.js';
16
+ import { is, isEmpty, intersection, difference, union, isNil, mergeRight, assoc, equals } from 'ramda';
17
17
  import ReactDOM from 'react-dom/server';
18
18
  import { l as lowlight, d as decodeHtmlEntities, r as removeEmptyTags } from '../chunk-LtUevT4I.js';
19
19
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
20
- import { C as CALLOUT_TYPES, E as EmojiPickerMenu, g as getSuggestionAppendTo, v as validateUrl, b as buildLevelsFromOptions, c as getLinkPopoverPosition, L as LINK_VALIDATION_SCHEMA, d as validateAndFormatUrl, D as DEFAULT_EDITOR_OPTIONS, e as getEditorStyles, M as Menu$3, f as MenuDynamicVariables, h as MediaUploader, j as LinkAddPopOver, k as transformPastedHTML, l as handlePaste, m as clipboardTextParser, s as setInitialPosition } from '../chunk-CivYrffM.js';
20
+ import { C as CALLOUT_TYPES, E as EmojiPickerMenu, g as getSuggestionAppendTo, v as validateUrl, b as buildLevelsFromOptions, c as getLinkPopoverPosition, L as LINK_VALIDATION_SCHEMA, d as validateAndFormatUrl, D as DEFAULT_EDITOR_OPTIONS, e as getEditorStyles, M as Menu$3, f as MenuDynamicVariables, h as MediaUploader, j as LinkAddPopOver, k as transformPastedHTML, l as handlePaste, m as clipboardTextParser, s as setInitialPosition } from '../chunk-PFB_80PR.js';
21
+ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
22
+ import { P as Plugin, g as PluginKey, S as Selection, T as TextSelection } from '../chunk-DqSrbxqC.js';
23
+ import { t } from 'i18next';
24
+ import { D as DirectUpload, g as getRandomString } from '../chunk-Verd5n0p.js';
25
+ import { c as checkPreviewAvailability, d as downloadFile, b as buildFileUploadConfig, A as Attachments } from '../chunk-BlvmXrHo.js';
26
+ import { F as File$1, c as convertToFileSize, s as selectFiles, h as DEFAULT_ASPECT_RATIO } from '../chunk-EjoZ4e18.js';
27
+ import { Eye, Download, ExternalLink, Trash2, ChevronDown, Highlighter, X, Ratio, Ellipsis, AlignLeft, AlignCenter, AlignRight, RectangleHorizontal, RectangleVertical, Square, SquareDashed, Minus as Minus$1, Plus, BookOpen, Pencil } from 'lucide-react';
28
+ import { useTranslation } from 'react-i18next';
21
29
  import Megaphone from '@bigbinary/neeto-icons/misc/Megaphone';
22
- import { g as PluginKey, P as Plugin, S as Selection, T as TextSelection } from '../chunk-DqSrbxqC.js';
23
- import { ChevronDown, Highlighter, X, Ratio, Ellipsis, AlignLeft, AlignCenter, AlignRight, RectangleHorizontal, RectangleVertical, Square, SquareDashed, Trash2, Minus as Minus$1, Plus, BookOpen, Pencil } from 'lucide-react';
24
30
  import CopyToClipboardButton from '@bigbinary/neeto-molecules/v2/CopyToClipboardButton';
25
- import { useTranslation } from 'react-i18next';
26
- import { t } from 'i18next';
27
- import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
28
31
  import '@babel/runtime/helpers/readOnlyError';
29
32
  import tippy from 'tippy.js';
30
33
  import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
@@ -34,7 +37,6 @@ import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
34
37
  import _inherits from '@babel/runtime/helpers/inherits';
35
38
  import { init, SearchIndex } from 'emoji-mart';
36
39
  import { globalProps } from '@bigbinary/neeto-commons-frontend/v2/initializers';
37
- import { D as DirectUpload } from '../chunk-BHi0J28T.js';
38
40
  import Tippy from '@tippyjs/react';
39
41
  import TextP from '@bigbinary/neeto-icons/TextP';
40
42
  import TextH1 from '@bigbinary/neeto-icons/TextH1';
@@ -59,12 +61,10 @@ import Underline from '@bigbinary/neeto-icons/Underline';
59
61
  import Link$2 from '@bigbinary/neeto-icons/Link';
60
62
  import Attachment from '@bigbinary/neeto-icons/Attachment';
61
63
  import MessageSquare from '@bigbinary/neeto-icons/MessageSquare';
62
- import File from '@bigbinary/neeto-icons/File';
63
- import { h as DEFAULT_ASPECT_RATIO } from '../chunk-BIgc5m-h.js';
64
+ import File$2 from '@bigbinary/neeto-icons/File';
64
65
  import _typeof from '@babel/runtime/helpers/typeof';
65
66
  import Search from '@bigbinary/neeto-molecules/v2/Search';
66
67
  import { Form, Input as Input$1 } from '@bigbinary/neeto-atoms/formik';
67
- import { A as Attachments } from '../chunk-DwQ7NJtm.js';
68
68
  import 'axios';
69
69
  import '@bigbinary/neeto-commons-frontend/react-utils';
70
70
  import 'zustand';
@@ -79,6 +79,7 @@ import 'react-colorful';
79
79
  import '@bigbinary/neeto-image-uploader-frontend/v2/ImageUploader';
80
80
  import 'zustand/shallow';
81
81
  import '@bigbinary/neeto-molecules/v2/DynamicVariables';
82
+ import '@bigbinary/neeto-commons-frontend/v2/react-utils/useOnClickOutside';
82
83
  import '@bigbinary/neeto-icons/LeftAlign';
83
84
  import '@bigbinary/neeto-icons/CenterAlign';
84
85
  import '@bigbinary/neeto-icons/RightAlign';
@@ -91,7 +92,6 @@ import '@bigbinary/neeto-icons/AspectRatio169';
91
92
  import '@bigbinary/neeto-icons/AspectRatio916';
92
93
  import '@bigbinary/neeto-icons/AspectRatio43';
93
94
  import '@bigbinary/neeto-icons/AspectRatio32';
94
- import '@bigbinary/neeto-commons-frontend/v2/react-utils/useOnClickOutside';
95
95
 
96
96
  var ErrorWrapper = function ErrorWrapper(_ref) {
97
97
  var error = _ref.error,
@@ -148,6 +148,604 @@ var CharacterCountWrapper = function CharacterCountWrapper(_ref) {
148
148
  });
149
149
  };
150
150
 
151
+ var NODE_NAME = "attachment";
152
+
153
+ // Files larger than this are shown as a chip, never as an inline preview.
154
+ var DEFAULT_INLINE_PREVIEW_MAX_SIZE = 20 * 1024 * 1024;
155
+ var PDF_THUMBNAIL_WIDTH = 800;
156
+ var PREVIEW_TYPES = {
157
+ IMAGE: "image",
158
+ VIDEO: "video",
159
+ PDF: "pdf"
160
+ };
161
+ var INLINE_PREVIEW_IMAGE_TYPES = ["image/jpeg", "image/jpg", "image/png", "image/gif", "image/webp"];
162
+ var PDF_CONTENT_TYPE = "application/pdf";
163
+
164
+ var _excluded$5 = ["data"];
165
+ function _regenerator$4() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2$4(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = false, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = true, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), true), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2$4(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2$4(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2$4(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2$4(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2$4(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2$4(u), _regeneratorDefine2$4(u, o, "Generator"), _regeneratorDefine2$4(u, n, function () { return this; }), _regeneratorDefine2$4(u, "toString", function () { return "[object Generator]"; }), (_regenerator$4 = function _regenerator() { return { w: i, m: f }; })(); }
166
+ function _regeneratorDefine2$4(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2$4 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2$4(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2$4(e, r, n, t); }
167
+
168
+ // pdf.js normally runs in a web worker loaded from a separate file, which a
169
+ // host app bundling this package can't be relied on to serve. Exposing the
170
+ // worker module on `globalThis.pdfjsWorker` makes pdf.js run it in-page.
171
+ var loadPdfjs = /*#__PURE__*/function () {
172
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator$4().m(function _callee() {
173
+ var _globalThis$pdfjsWork;
174
+ var _yield$Promise$all, _yield$Promise$all2, pdfjs, worker;
175
+ return _regenerator$4().w(function (_context) {
176
+ while (1) switch (_context.n) {
177
+ case 0:
178
+ _context.n = 1;
179
+ return Promise.all([import('../chunk-CXFFqMSB.js'), import('../chunk-BFj2DeQe.js')]);
180
+ case 1:
181
+ _yield$Promise$all = _context.v;
182
+ _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
183
+ pdfjs = _yield$Promise$all2[0];
184
+ worker = _yield$Promise$all2[1];
185
+ (_globalThis$pdfjsWork = globalThis.pdfjsWorker) !== null && _globalThis$pdfjsWork !== void 0 ? _globalThis$pdfjsWork : globalThis.pdfjsWorker = worker;
186
+ return _context.a(2, pdfjs);
187
+ }
188
+ }, _callee);
189
+ }));
190
+ return function loadPdfjs() {
191
+ return _ref.apply(this, arguments);
192
+ };
193
+ }();
194
+ var canvasToBlob = function canvasToBlob(canvas) {
195
+ return new Promise(function (resolve) {
196
+ return canvas.toBlob(resolve, "image/png");
197
+ });
198
+ };
199
+ var getPreviewType = function getPreviewType(_ref2, maxSize) {
200
+ var contentType = _ref2.contentType,
201
+ size = _ref2.size,
202
+ thumbnailUrl = _ref2.thumbnailUrl;
203
+ if (!contentType || isPresent(size) && Number(size) > maxSize) return null;
204
+ if (INLINE_PREVIEW_IMAGE_TYPES.includes(contentType)) {
205
+ return PREVIEW_TYPES.IMAGE;
206
+ }
207
+ if (contentType.startsWith("video/")) return PREVIEW_TYPES.VIDEO;
208
+ if (contentType === PDF_CONTENT_TYPE && isPresent(thumbnailUrl)) {
209
+ return PREVIEW_TYPES.PDF;
210
+ }
211
+ return null;
212
+ };
213
+ var getPreviewSrc = function getPreviewSrc(_ref3, previewType) {
214
+ var url = _ref3.url,
215
+ thumbnailUrl = _ref3.thumbnailUrl;
216
+ return previewType === PREVIEW_TYPES.PDF ? thumbnailUrl : url;
217
+ };
218
+ var uploadFile = /*#__PURE__*/function () {
219
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator$4().m(function _callee2(file, endpoint) {
220
+ var _data$blob_url, _data$signed_id;
221
+ var _yield$DirectUpload$c, _yield$DirectUpload$c2, data, response;
222
+ return _regenerator$4().w(function (_context2) {
223
+ while (1) switch (_context2.n) {
224
+ case 0:
225
+ _context2.n = 1;
226
+ return new DirectUpload({
227
+ file: file,
228
+ url: endpoint
229
+ }).create();
230
+ case 1:
231
+ _yield$DirectUpload$c = _context2.v;
232
+ _yield$DirectUpload$c2 = _yield$DirectUpload$c.data;
233
+ data = _yield$DirectUpload$c2 === void 0 ? {} : _yield$DirectUpload$c2;
234
+ response = _objectWithoutProperties(_yield$DirectUpload$c, _excluded$5);
235
+ return _context2.a(2, {
236
+ url: (_data$blob_url = data.blob_url) !== null && _data$blob_url !== void 0 ? _data$blob_url : response.blob_url,
237
+ signedId: (_data$signed_id = data.signed_id) !== null && _data$signed_id !== void 0 ? _data$signed_id : response.signed_id
238
+ });
239
+ }
240
+ }, _callee2);
241
+ }));
242
+ return function uploadFile(_x, _x2) {
243
+ return _ref4.apply(this, arguments);
244
+ };
245
+ }();
246
+ var generatePdfThumbnail = /*#__PURE__*/function () {
247
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator$4().m(function _callee3(file) {
248
+ var pdfjs, pdf, page, _page$getViewport, width, viewport, canvas, blob, name, _t, _t2;
249
+ return _regenerator$4().w(function (_context3) {
250
+ while (1) switch (_context3.p = _context3.n) {
251
+ case 0:
252
+ _context3.n = 1;
253
+ return loadPdfjs();
254
+ case 1:
255
+ pdfjs = _context3.v;
256
+ _t = pdfjs;
257
+ _context3.n = 2;
258
+ return file.arrayBuffer();
259
+ case 2:
260
+ _t2 = _context3.v;
261
+ _context3.n = 3;
262
+ return _t.getDocument.call(_t, {
263
+ data: _t2
264
+ }).promise;
265
+ case 3:
266
+ pdf = _context3.v;
267
+ _context3.p = 4;
268
+ _context3.n = 5;
269
+ return pdf.getPage(1);
270
+ case 5:
271
+ page = _context3.v;
272
+ _page$getViewport = page.getViewport({
273
+ scale: 1
274
+ }), width = _page$getViewport.width;
275
+ viewport = page.getViewport({
276
+ scale: PDF_THUMBNAIL_WIDTH / width
277
+ });
278
+ canvas = document.createElement("canvas");
279
+ canvas.width = viewport.width;
280
+ canvas.height = viewport.height;
281
+ _context3.n = 6;
282
+ return page.render({
283
+ canvasContext: canvas.getContext("2d"),
284
+ viewport: viewport
285
+ }).promise;
286
+ case 6:
287
+ _context3.n = 7;
288
+ return canvasToBlob(canvas);
289
+ case 7:
290
+ blob = _context3.v;
291
+ if (blob) {
292
+ _context3.n = 8;
293
+ break;
294
+ }
295
+ return _context3.a(2, null);
296
+ case 8:
297
+ name = "".concat(file.name.replace(/\.pdf$/i, ""), "-preview.png");
298
+ return _context3.a(2, new File([blob], name, {
299
+ type: "image/png"
300
+ }));
301
+ case 9:
302
+ _context3.p = 9;
303
+ pdf.destroy();
304
+ return _context3.f(9);
305
+ case 10:
306
+ return _context3.a(2);
307
+ }
308
+ }, _callee3, null, [[4,, 9, 10]]);
309
+ }));
310
+ return function generatePdfThumbnail(_x3) {
311
+ return _ref5.apply(this, arguments);
312
+ };
313
+ }();
314
+ var findNodePosByUploadId = function findNodePosByUploadId(doc, uploadId) {
315
+ var foundPos = -1;
316
+ doc.descendants(function (node, pos) {
317
+ var _node$attrs;
318
+ if (foundPos !== -1) return false;
319
+ if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.uploadId) === uploadId) foundPos = pos;
320
+ return foundPos === -1;
321
+ });
322
+ return foundPos;
323
+ };
324
+ var countAttachmentNodes = function countAttachmentNodes(doc, nodeName) {
325
+ var count = 0;
326
+ doc.descendants(function (node) {
327
+ if (node.type.name === nodeName) count += 1;
328
+ });
329
+ return count;
330
+ };
331
+
332
+ var Preview = /*#__PURE__*/lazy(function () {
333
+ return import('../chunk-Bq_ijJy6.js');
334
+ });
335
+ var AttachmentComponent = function AttachmentComponent(_ref) {
336
+ var node = _ref.node,
337
+ extension = _ref.extension,
338
+ editor = _ref.editor,
339
+ deleteNode = _ref.deleteNode;
340
+ var _useTranslation = useTranslation(),
341
+ t = _useTranslation.t;
342
+ var _useState = useState(false),
343
+ _useState2 = _slicedToArray(_useState, 2),
344
+ isPreviewOpen = _useState2[0],
345
+ setIsPreviewOpen = _useState2[1];
346
+ var _node$attrs = node.attrs,
347
+ url = _node$attrs.url,
348
+ filename = _node$attrs.filename,
349
+ contentType = _node$attrs.contentType,
350
+ size = _node$attrs.size,
351
+ signedId = _node$attrs.signedId,
352
+ uploadId = _node$attrs.uploadId;
353
+ var attachment = {
354
+ url: url,
355
+ filename: filename,
356
+ contentType: contentType,
357
+ size: size,
358
+ signedId: signedId
359
+ };
360
+ var previewType = getPreviewType(node.attrs, extension.options.previewMaxSize);
361
+ var previewSrc = getPreviewSrc(node.attrs, previewType);
362
+ var canView = checkPreviewAvailability(contentType);
363
+ var actions = [canView && {
364
+ key: "view",
365
+ icon: Eye,
366
+ label: t("neetoEditor.attachments.view"),
367
+ onClick: function onClick() {
368
+ return setIsPreviewOpen(true);
369
+ }
370
+ }, {
371
+ key: "download",
372
+ icon: Download,
373
+ label: t("neetoEditor.common.download"),
374
+ onClick: function onClick() {
375
+ return downloadFile(url, filename);
376
+ }
377
+ }, {
378
+ key: "open",
379
+ icon: ExternalLink,
380
+ label: t("neetoEditor.common.openInNewTab"),
381
+ onClick: function onClick() {
382
+ return window.open(url, "_blank", "noopener,noreferrer");
383
+ }
384
+ }, editor.isEditable && {
385
+ key: "delete",
386
+ icon: Trash2,
387
+ label: t("neetoEditor.menu.delete"),
388
+ onClick: deleteNode
389
+ }].filter(Boolean);
390
+ if (uploadId) {
391
+ return /*#__PURE__*/jsx(NodeViewWrapper, {
392
+ className: "neeto-editor__attachment neeto-editor__attachment--uploading",
393
+ "data-testid": "neeto-editor-attachment-uploading",
394
+ children: /*#__PURE__*/jsxs("div", {
395
+ className: "neeto-editor__attachment-file",
396
+ children: [/*#__PURE__*/jsx(Spinner, {}), /*#__PURE__*/jsx("span", {
397
+ className: "neeto-editor__attachment-name",
398
+ children: filename
399
+ }), /*#__PURE__*/jsx("span", {
400
+ className: "neeto-editor__attachment-size",
401
+ children: t("neetoEditor.attachments.uploading")
402
+ })]
403
+ })
404
+ });
405
+ }
406
+ return /*#__PURE__*/jsxs(NodeViewWrapper, {
407
+ "data-drag-handle": true,
408
+ className: "neeto-editor__attachment",
409
+ "data-testid": "neeto-editor-attachment",
410
+ children: [previewType && /*#__PURE__*/jsx("div", {
411
+ className: "neeto-editor__attachment-preview",
412
+ onClick: previewType === PREVIEW_TYPES.VIDEO ? noop : function () {
413
+ return setIsPreviewOpen(true);
414
+ },
415
+ children: previewType === PREVIEW_TYPES.VIDEO ? /*#__PURE__*/jsx("video", {
416
+ controls: true,
417
+ playsInline: true,
418
+ preload: "metadata",
419
+ src: previewSrc
420
+ }) : /*#__PURE__*/jsx("img", {
421
+ alt: filename,
422
+ draggable: false,
423
+ src: previewSrc
424
+ })
425
+ }), /*#__PURE__*/jsxs("div", {
426
+ className: "neeto-editor__attachment-file",
427
+ children: [/*#__PURE__*/jsx(File$1, {
428
+ className: "neeto-editor__attachment-icon",
429
+ fileName: filename
430
+ }), /*#__PURE__*/jsx("span", {
431
+ className: "neeto-editor__attachment-name",
432
+ children: filename
433
+ }), size && /*#__PURE__*/jsx("span", {
434
+ className: "neeto-editor__attachment-size",
435
+ children: convertToFileSize(Number(size))
436
+ }), /*#__PURE__*/jsx("div", {
437
+ className: "neeto-editor__attachment-actions",
438
+ children: actions.map(function (_ref2) {
439
+ var key = _ref2.key,
440
+ icon = _ref2.icon,
441
+ label = _ref2.label,
442
+ onClick = _ref2.onClick;
443
+ return /*#__PURE__*/jsx(Tooltip, {
444
+ content: label,
445
+ position: "top",
446
+ children: /*#__PURE__*/jsx(Button, {
447
+ icon: icon,
448
+ onClick: onClick,
449
+ "aria-label": label,
450
+ "data-testid": "neeto-editor-attachment-".concat(key, "-button"),
451
+ size: "sm",
452
+ variant: "ghost"
453
+ })
454
+ }, key);
455
+ })
456
+ })]
457
+ }), /*#__PURE__*/jsx(Suspense, {
458
+ fallback: /*#__PURE__*/jsx("span", {}),
459
+ children: isPreviewOpen && /*#__PURE__*/jsx(Preview, {
460
+ attachments: [attachment],
461
+ selectedAttachment: attachment,
462
+ setDidFetchPreviewBundle: noop,
463
+ setSelectedAttachment: noop,
464
+ onClose: function onClose() {
465
+ return setIsPreviewOpen(false);
466
+ }
467
+ })
468
+ })]
469
+ });
470
+ };
471
+
472
+ function ownKeys$j(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; }
473
+ function _objectSpread$j(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$j(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$j(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
474
+ function _regenerator$3() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2$3(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = false, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = true, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), true), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2$3(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2$3(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2$3(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2$3(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2$3(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2$3(u), _regeneratorDefine2$3(u, o, "Generator"), _regeneratorDefine2$3(u, n, function () { return this; }), _regeneratorDefine2$3(u, "toString", function () { return "[object Generator]"; }), (_regenerator$3 = function _regenerator() { return { w: i, m: f }; })(); }
475
+ function _regeneratorDefine2$3(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2$3 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2$3(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2$3(e, r, n, t); }
476
+ var dataAttribute = function dataAttribute(name, attribute) {
477
+ return {
478
+ "default": null,
479
+ parseHTML: function parseHTML(element) {
480
+ return element.getAttribute(attribute);
481
+ },
482
+ renderHTML: function renderHTML(attributes) {
483
+ return attributes[name] ? _defineProperty({}, attribute, attributes[name]) : {};
484
+ }
485
+ };
486
+ };
487
+ var uploadThumbnail = /*#__PURE__*/function () {
488
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator$3().m(function _callee(file, endpoint) {
489
+ var thumbnail, _t, _t2;
490
+ return _regenerator$3().w(function (_context) {
491
+ while (1) switch (_context.p = _context.n) {
492
+ case 0:
493
+ _context.p = 0;
494
+ _context.n = 1;
495
+ return generatePdfThumbnail(file);
496
+ case 1:
497
+ thumbnail = _context.v;
498
+ if (!thumbnail) {
499
+ _context.n = 3;
500
+ break;
501
+ }
502
+ _context.n = 2;
503
+ return uploadFile(thumbnail, endpoint);
504
+ case 2:
505
+ _t = _context.v.url;
506
+ _context.n = 4;
507
+ break;
508
+ case 3:
509
+ _t = null;
510
+ case 4:
511
+ return _context.a(2, _t);
512
+ case 5:
513
+ _context.p = 5;
514
+ _t2 = _context.v;
515
+ // A missing thumbnail only means the PDF is shown as a chip.
516
+ // eslint-disable-next-line no-console
517
+ console.error("Failed to generate the PDF thumbnail", _t2);
518
+ return _context.a(2, null);
519
+ }
520
+ }, _callee, null, [[0, 5]]);
521
+ }));
522
+ return function uploadThumbnail(_x, _x2) {
523
+ return _ref2.apply(this, arguments);
524
+ };
525
+ }();
526
+ var AttachmentExtension = Node.create({
527
+ name: NODE_NAME,
528
+ group: "block",
529
+ atom: true,
530
+ draggable: true,
531
+ selectable: true,
532
+ addOptions: function addOptions() {
533
+ return {
534
+ config: {},
535
+ previewMaxSize: DEFAULT_INLINE_PREVIEW_MAX_SIZE,
536
+ getExternalAttachmentsCount: function getExternalAttachmentsCount() {
537
+ return 0;
538
+ },
539
+ setIsUploading: function setIsUploading() {}
540
+ };
541
+ },
542
+ addStorage: function addStorage() {
543
+ return {
544
+ pendingUploadsCount: 0
545
+ };
546
+ },
547
+ addAttributes: function addAttributes() {
548
+ return {
549
+ url: dataAttribute("url", "data-url"),
550
+ filename: dataAttribute("filename", "data-filename"),
551
+ contentType: dataAttribute("contentType", "data-content-type"),
552
+ size: dataAttribute("size", "data-size"),
553
+ signedId: dataAttribute("signedId", "data-signed-id"),
554
+ thumbnailUrl: dataAttribute("thumbnailUrl", "data-thumbnail-url"),
555
+ uploadId: {
556
+ "default": null,
557
+ rendered: false
558
+ }
559
+ };
560
+ },
561
+ parseHTML: function parseHTML() {
562
+ return [{
563
+ tag: "div[data-attachment]"
564
+ }];
565
+ },
566
+ renderHTML: function renderHTML(_ref3) {
567
+ var node = _ref3.node,
568
+ HTMLAttributes = _ref3.HTMLAttributes;
569
+ var _node$attrs = node.attrs,
570
+ url = _node$attrs.url,
571
+ filename = _node$attrs.filename,
572
+ size = _node$attrs.size;
573
+
574
+ // Still uploading: leave nothing behind in the saved HTML.
575
+ if (!url) return ["span"];
576
+ var previewType = getPreviewType(node.attrs, this.options.previewMaxSize);
577
+ var linkAttrs = {
578
+ href: url,
579
+ target: "_blank",
580
+ rel: "noopener noreferrer"
581
+ };
582
+ var previewSrc = getPreviewSrc(node.attrs, previewType);
583
+ var preview = previewType === PREVIEW_TYPES.VIDEO ? ["video", {
584
+ src: previewSrc,
585
+ controls: true,
586
+ playsinline: true,
587
+ preload: "metadata"
588
+ }] : ["a", linkAttrs, ["img", {
589
+ src: previewSrc,
590
+ alt: filename,
591
+ loading: "lazy"
592
+ }]];
593
+ var file = ["a", _objectSpread$j(_objectSpread$j({}, linkAttrs), {}, {
594
+ "class": "neeto-editor__attachment-file"
595
+ }), ["span", {
596
+ "class": "neeto-editor__attachment-name"
597
+ }, filename]].concat(_toConsumableArray(size ? [["span", {
598
+ "class": "neeto-editor__attachment-size"
599
+ }, convertToFileSize(Number(size))]] : []));
600
+ return ["div", _objectSpread$j(_objectSpread$j({}, HTMLAttributes), {}, {
601
+ "data-attachment": "",
602
+ "class": "neeto-editor__attachment"
603
+ })].concat(_toConsumableArray(previewType ? [["div", {
604
+ "class": "neeto-editor__attachment-preview"
605
+ }, preview]] : []), [file]);
606
+ },
607
+ addNodeView: function addNodeView() {
608
+ return ReactNodeViewRenderer(AttachmentComponent);
609
+ },
610
+ addCommands: function addCommands() {
611
+ var _this = this;
612
+ return {
613
+ uploadAttachments: function uploadAttachments(files, position) {
614
+ return function (_ref4) {
615
+ var editor = _ref4.editor;
616
+ _this.storage.uploadFiles(editor, Array.from(files), position);
617
+ return true;
618
+ };
619
+ }
620
+ };
621
+ },
622
+ onCreate: function onCreate() {
623
+ var options = this.options,
624
+ storage = this.storage;
625
+ var config = buildFileUploadConfig(options.config);
626
+ var endpoint = config.directUploadEndpoint;
627
+ var updateUploadingState = function updateUploadingState(delta) {
628
+ storage.pendingUploadsCount += delta;
629
+ options.setIsUploading(storage.pendingUploadsCount > 0);
630
+ };
631
+ var replacePlaceholder = function replacePlaceholder(editor, uploadId, attrs) {
632
+ if (editor.isDestroyed) return;
633
+ var state = editor.state,
634
+ view = editor.view;
635
+ var pos = findNodePosByUploadId(state.doc, uploadId);
636
+ if (pos === -1) return; // Removed by the user while uploading.
637
+
638
+ var node = state.doc.nodeAt(pos);
639
+ var tr = attrs ? state.tr.setNodeMarkup(pos, undefined, _objectSpread$j(_objectSpread$j({}, node.attrs), attrs)) : state.tr["delete"](pos, pos + node.nodeSize);
640
+ view.dispatch(tr.setMeta("addToHistory", false));
641
+ };
642
+ var uploadPlaceholder = /*#__PURE__*/function () {
643
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator$3().m(function _callee2(editor, _ref5) {
644
+ var file, uploadId, shouldGenerateThumbnail, _yield$Promise$all, _yield$Promise$all2, uploaded, thumbnailUrl, _t3;
645
+ return _regenerator$3().w(function (_context2) {
646
+ while (1) switch (_context2.p = _context2.n) {
647
+ case 0:
648
+ file = _ref5.file, uploadId = _ref5.uploadId;
649
+ _context2.p = 1;
650
+ shouldGenerateThumbnail = file.type === PDF_CONTENT_TYPE && file.size <= options.previewMaxSize;
651
+ _context2.n = 2;
652
+ return Promise.all([uploadFile(file, endpoint), shouldGenerateThumbnail ? uploadThumbnail(file, endpoint) : null]);
653
+ case 2:
654
+ _yield$Promise$all = _context2.v;
655
+ _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
656
+ uploaded = _yield$Promise$all2[0];
657
+ thumbnailUrl = _yield$Promise$all2[1];
658
+ replacePlaceholder(editor, uploadId, _objectSpread$j(_objectSpread$j({}, uploaded), {}, {
659
+ thumbnailUrl: thumbnailUrl,
660
+ uploadId: null
661
+ }));
662
+ _context2.n = 4;
663
+ break;
664
+ case 3:
665
+ _context2.p = 3;
666
+ _t3 = _context2.v;
667
+ // eslint-disable-next-line no-console
668
+ console.error("Attachment upload failed", _t3);
669
+ replacePlaceholder(editor, uploadId, null);
670
+ Toastr.error(t("neetoEditor.error.uploadFileFailed"));
671
+ case 4:
672
+ _context2.p = 4;
673
+ updateUploadingState(-1);
674
+ return _context2.f(4);
675
+ case 5:
676
+ return _context2.a(2);
677
+ }
678
+ }, _callee2, null, [[1, 3, 4, 5]]);
679
+ }));
680
+ return function uploadPlaceholder(_x3, _x4) {
681
+ return _ref6.apply(this, arguments);
682
+ };
683
+ }();
684
+ storage.uploadFiles = function (editor, files, position) {
685
+ var selectedFiles = selectFiles({
686
+ previousAttachmentsCount: countAttachmentNodes(editor.state.doc, NODE_NAME) + options.getExternalAttachmentsCount(),
687
+ config: config,
688
+ files: files
689
+ });
690
+ if (isEmpty(selectedFiles)) return;
691
+ var placeholders = selectedFiles.map(function (file) {
692
+ return {
693
+ file: file,
694
+ uploadId: getRandomString()
695
+ };
696
+ });
697
+ var nodes = placeholders.map(function (_ref7) {
698
+ var file = _ref7.file,
699
+ uploadId = _ref7.uploadId;
700
+ return {
701
+ type: NODE_NAME,
702
+ attrs: {
703
+ uploadId: uploadId,
704
+ filename: file.name,
705
+ contentType: file.type,
706
+ size: file.size
707
+ }
708
+ };
709
+ });
710
+ editor.chain().focus().insertContentAt(position !== null && position !== void 0 ? position : editor.state.selection, nodes).run();
711
+ updateUploadingState(placeholders.length);
712
+ placeholders.forEach(function (placeholder) {
713
+ return uploadPlaceholder(editor, placeholder);
714
+ });
715
+ };
716
+ },
717
+ addProseMirrorPlugins: function addProseMirrorPlugins() {
718
+ var editor = this.editor,
719
+ storage = this.storage;
720
+ return [new Plugin({
721
+ props: {
722
+ handleDrop: function handleDrop(view, event, _slice, moved) {
723
+ var _event$dataTransfer$f, _event$dataTransfer;
724
+ var files = Array.from((_event$dataTransfer$f = (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.files) !== null && _event$dataTransfer$f !== void 0 ? _event$dataTransfer$f : []);
725
+ if (moved || isEmpty(files)) return false;
726
+ var coordinates = view.posAtCoords({
727
+ left: event.clientX,
728
+ top: event.clientY
729
+ });
730
+ event.preventDefault();
731
+ storage.uploadFiles(editor, files, coordinates === null || coordinates === void 0 ? void 0 : coordinates.pos);
732
+ return true;
733
+ },
734
+ // Pasted images are handled by the image extension.
735
+ handlePaste: function handlePaste(_view, event) {
736
+ var _event$clipboardData$, _event$clipboardData;
737
+ var files = Array.from((_event$clipboardData$ = (_event$clipboardData = event.clipboardData) === null || _event$clipboardData === void 0 ? void 0 : _event$clipboardData.files) !== null && _event$clipboardData$ !== void 0 ? _event$clipboardData$ : []).filter(function (file) {
738
+ return !/image/i.test(file.type);
739
+ });
740
+ if (isEmpty(files)) return false;
741
+ storage.uploadFiles(editor, files);
742
+ return true;
743
+ }
744
+ }
745
+ })];
746
+ }
747
+ });
748
+
151
749
  var HighlightInternal = Extension.create({
152
750
  name: "HighlightInternal",
153
751
  addOptions: function addOptions() {
@@ -3061,7 +3659,7 @@ var MENU_ITEMS = [{
3061
3659
  optionName: EDITOR_OPTIONS.NEETO_KB_ARTICLE,
3062
3660
  title: t("neetoEditor.menu.linkToNeetoKbArticle"),
3063
3661
  description: t("neetoEditor.menu.linkToNeetoKbArticleDescription"),
3064
- Icon: File,
3662
+ Icon: File$2,
3065
3663
  command: noop
3066
3664
  }, {
3067
3665
  optionName: EDITOR_OPTIONS.ATTACHMENTS,
@@ -4850,7 +5448,8 @@ var useCustomExtensions = function useCustomExtensions(_ref) {
4850
5448
  collaborationProvider = _ref.collaborationProvider,
4851
5449
  setIsNeetoKbArticleActive = _ref.setIsNeetoKbArticleActive,
4852
5450
  containerRef = _ref.containerRef,
4853
- appendSuggestionsToBody = _ref.appendSuggestionsToBody;
5451
+ appendSuggestionsToBody = _ref.appendSuggestionsToBody,
5452
+ inlineAttachmentsOptions = _ref.inlineAttachmentsOptions;
4854
5453
  var customExtensions = [EditorContainer.configure({
4855
5454
  containerRef: containerRef,
4856
5455
  appendSuggestionsToBody: appendSuggestionsToBody
@@ -4897,6 +5496,9 @@ var useCustomExtensions = function useCustomExtensions(_ref) {
4897
5496
  if (options.includes(EDITOR_OPTIONS.VIDEO_UPLOAD)) {
4898
5497
  customExtensions.push(UnifiedVideoExtension);
4899
5498
  }
5499
+ if (options.includes(EDITOR_OPTIONS.INLINE_ATTACHMENTS)) {
5500
+ customExtensions.push(AttachmentExtension.configure(inlineAttachmentsOptions));
5501
+ }
4900
5502
  if (options.includes(EDITOR_OPTIONS.NEETO_KB_ARTICLE)) {
4901
5503
  customExtensions.push(DeletedArticleDecoration.configure({
4902
5504
  deletedArticleIds: new Set()
@@ -5991,7 +6593,7 @@ var _excluded = ["addonCommands", "addons", "attachments", "attachmentsConfig",
5991
6593
  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; }
5992
6594
  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; }
5993
6595
  var Editor = function Editor(_ref, ref) {
5994
- var _wrapperRef$current;
6596
+ var _attachmentsConfig$re, _attachmentsConfig$re2, _wrapperRef$current;
5995
6597
  var _ref$addonCommands = _ref.addonCommands,
5996
6598
  addonCommands = _ref$addonCommands === void 0 ? [] : _ref$addonCommands,
5997
6599
  _ref$addons = _ref.addons,
@@ -6080,6 +6682,10 @@ var Editor = function Editor(_ref, ref) {
6080
6682
  var wrapperRef = useRef(null);
6081
6683
  var isArticleOptActive = addons.includes(EDITOR_OPTIONS.NEETO_KB_ARTICLE);
6082
6684
  var isAttachmentsActive = addons.includes(EDITOR_OPTIONS.ATTACHMENTS);
6685
+ var isInlineAttachmentsActive = addons.includes(EDITOR_OPTIONS.INLINE_ATTACHMENTS);
6686
+
6687
+ // Inline attachments reuse the attachments toolbar button and slash command.
6688
+ var menuAddons = isInlineAttachmentsActive && !isAttachmentsActive ? [].concat(_toConsumableArray(addons), [EDITOR_OPTIONS.ATTACHMENTS]) : addons;
6083
6689
  var isMediaUploaderActive = addons.includes(EDITOR_OPTIONS.IMAGE_UPLOAD) || addons.includes(EDITOR_OPTIONS.VIDEO_UPLOAD);
6084
6690
  var isFixedMenuActive = menuType === "fixed";
6085
6691
  var isBubbleMenuActive = menuType === "bubble";
@@ -6106,13 +6712,23 @@ var Editor = function Editor(_ref, ref) {
6106
6712
  neetoKbArticleState = _useState8[0],
6107
6713
  setNeetoKbArticleState = _useState8[1];
6108
6714
  var addAttachmentsRef = useRef(null);
6715
+ var inlineAttachmentInputRef = useRef(null);
6716
+ var attachmentsCountRef = useRef(attachments.length);
6717
+ attachmentsCountRef.current = attachments.length;
6109
6718
  var attachmentProps = {
6110
6719
  handleUploadAttachments: function handleUploadAttachments() {
6111
- var _addAttachmentsRef$cu;
6112
- return (_addAttachmentsRef$cu = addAttachmentsRef.current) === null || _addAttachmentsRef$cu === void 0 ? void 0 : _addAttachmentsRef$cu.handleUploadAttachments();
6720
+ var _inlineAttachmentInpu, _addAttachmentsRef$cu;
6721
+ return isInlineAttachmentsActive ? (_inlineAttachmentInpu = inlineAttachmentInputRef.current) === null || _inlineAttachmentInpu === void 0 ? void 0 : _inlineAttachmentInpu.click() : (_addAttachmentsRef$cu = addAttachmentsRef.current) === null || _addAttachmentsRef$cu === void 0 ? void 0 : _addAttachmentsRef$cu.handleUploadAttachments();
6113
6722
  },
6114
6723
  isDisabled: isAttachmentsUploading
6115
6724
  };
6725
+ var inlineAttachmentsOptions = {
6726
+ config: attachmentsConfig,
6727
+ getExternalAttachmentsCount: function getExternalAttachmentsCount() {
6728
+ return attachmentsCountRef.current;
6729
+ },
6730
+ setIsUploading: setIsAttachmentsUploading
6731
+ };
6116
6732
  var debouncedOnChangeHandler = useFuncDebounce(function (_ref2) {
6117
6733
  var editor = _ref2.editor;
6118
6734
  if (!editor.isDestroyed) onChange(editor.getHTML());
@@ -6135,7 +6751,7 @@ var Editor = function Editor(_ref, ref) {
6135
6751
  mentions: mentions,
6136
6752
  variables: variables,
6137
6753
  isSlashCommandsActive: isSlashCommandsActive,
6138
- options: [].concat(_toConsumableArray(defaults), _toConsumableArray(addons)),
6754
+ options: [].concat(_toConsumableArray(defaults), _toConsumableArray(menuAddons)),
6139
6755
  addonCommands: addonCommands,
6140
6756
  onSubmit: onSubmit,
6141
6757
  keyboardShortcuts: keyboardShortcuts,
@@ -6148,7 +6764,8 @@ var Editor = function Editor(_ref, ref) {
6148
6764
  collaborationProvider: collaborationProvider,
6149
6765
  setIsNeetoKbArticleActive: setNeetoKbArticleState,
6150
6766
  containerRef: wrapperRef,
6151
- appendSuggestionsToBody: appendSuggestionsToBody
6767
+ appendSuggestionsToBody: appendSuggestionsToBody,
6768
+ inlineAttachmentsOptions: inlineAttachmentsOptions
6152
6769
  });
6153
6770
  useEditorWarnings({
6154
6771
  initialValue: initialValue
@@ -6233,6 +6850,10 @@ var Editor = function Editor(_ref, ref) {
6233
6850
  if (!editor || !deletedArticlesHook.deletedArticleIds.size) return;
6234
6851
  editor.commands.updateDeletedArticles(deletedArticlesHook.deletedArticleIds);
6235
6852
  }, [editor, deletedArticlesHook.deletedArticleIds]);
6853
+ var handleInlineAttachmentsChange = function handleInlineAttachmentsChange(event) {
6854
+ editor === null || editor === void 0 || editor.commands.uploadAttachments(event.target.files);
6855
+ event.target.value = null;
6856
+ };
6236
6857
  EditorView.prototype.updateState = function updateState(state) {
6237
6858
  if (!this.docView) return;
6238
6859
  this.updateStateInner(state, this.state.plugins !== state.plugins);
@@ -6252,7 +6873,6 @@ var Editor = function Editor(_ref, ref) {
6252
6873
  children: /*#__PURE__*/jsxs(Fragment, {
6253
6874
  children: [menuType !== "none" && /*#__PURE__*/jsx(Menu$3, {
6254
6875
  addonCommands: addonCommands,
6255
- addons: addons,
6256
6876
  attachmentProps: attachmentProps,
6257
6877
  defaults: defaults,
6258
6878
  editor: editor,
@@ -6264,6 +6884,7 @@ var Editor = function Editor(_ref, ref) {
6264
6884
  showAssetLibrary: showAssetLibrary,
6265
6885
  tooltips: tooltips,
6266
6886
  variables: variables,
6887
+ addons: menuAddons,
6267
6888
  className: menuClassName,
6268
6889
  containerRef: wrapperRef,
6269
6890
  isIndependant: isMenuIndependent,
@@ -6289,10 +6910,18 @@ var Editor = function Editor(_ref, ref) {
6289
6910
  video: false
6290
6911
  });
6291
6912
  }
6292
- }), isAttachmentsActive && /*#__PURE__*/jsx(Attachments, _objectSpread({
6913
+ }), isInlineAttachmentsActive && /*#__PURE__*/jsx("input", {
6914
+ hidden: true,
6915
+ "data-testid": "neeto-editor-inline-attachments-input",
6916
+ multiple: ((_attachmentsConfig$re = attachmentsConfig.restrictions) === null || _attachmentsConfig$re === void 0 ? void 0 : _attachmentsConfig$re.maxNumberOfFiles) !== 1,
6917
+ ref: inlineAttachmentInputRef,
6918
+ type: "file",
6919
+ accept: (_attachmentsConfig$re2 = attachmentsConfig.restrictions) === null || _attachmentsConfig$re2 === void 0 || (_attachmentsConfig$re2 = _attachmentsConfig$re2.allowedFileTypes) === null || _attachmentsConfig$re2 === void 0 ? void 0 : _attachmentsConfig$re2.join(","),
6920
+ onChange: handleInlineAttachmentsChange
6921
+ }), isAttachmentsActive && (!isInlineAttachmentsActive || isNotEmpty(attachments)) && /*#__PURE__*/jsx(Attachments, _objectSpread({
6293
6922
  attachments: attachments,
6294
6923
  config: attachmentsConfig,
6295
- dragDropRef: wrapperRef,
6924
+ dragDropRef: isInlineAttachmentsActive ? null : wrapperRef,
6296
6925
  isIndependent: false,
6297
6926
  ref: addAttachmentsRef,
6298
6927
  setIsUploading: setIsAttachmentsUploading,