@squiz/formatted-text-editor 2.2.11 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +2 -1
  3. package/src/ui/Fields/MatrixAsset/MatrixAsset.spec.tsx +1 -1
  4. package/src/ui/Fields/ResourceBrowserSelector/ResourceBrowserSelector.spec.tsx +2 -2
  5. package/lib/Editor/Editor.d.ts +0 -16
  6. package/lib/Editor/Editor.js +0 -85
  7. package/lib/Editor/EditorContext.d.ts +0 -10
  8. package/lib/Editor/EditorContext.js +0 -16
  9. package/lib/EditorToolbar/FloatingToolbar.d.ts +0 -2
  10. package/lib/EditorToolbar/FloatingToolbar.js +0 -76
  11. package/lib/EditorToolbar/Toolbar.d.ts +0 -7
  12. package/lib/EditorToolbar/Toolbar.js +0 -49
  13. package/lib/EditorToolbar/Tools/Bold/BoldButton.d.ts +0 -3
  14. package/lib/EditorToolbar/Tools/Bold/BoldButton.js +0 -23
  15. package/lib/EditorToolbar/Tools/ClearFormatting/ClearFormattingButton.d.ts +0 -3
  16. package/lib/EditorToolbar/Tools/ClearFormatting/ClearFormattingButton.js +0 -57
  17. package/lib/EditorToolbar/Tools/ContentTools/ContentToolsDropdown.d.ts +0 -3
  18. package/lib/EditorToolbar/Tools/ContentTools/ContentToolsDropdown.js +0 -104
  19. package/lib/EditorToolbar/Tools/HorizontalLine/HorizontalLineButton.d.ts +0 -3
  20. package/lib/EditorToolbar/Tools/HorizontalLine/HorizontalLineButton.js +0 -25
  21. package/lib/EditorToolbar/Tools/Image/Form/ImageForm.d.ts +0 -19
  22. package/lib/EditorToolbar/Tools/Image/Form/ImageForm.js +0 -186
  23. package/lib/EditorToolbar/Tools/Image/ImageButton.d.ts +0 -6
  24. package/lib/EditorToolbar/Tools/Image/ImageButton.js +0 -79
  25. package/lib/EditorToolbar/Tools/Image/ImageModal.d.ts +0 -9
  26. package/lib/EditorToolbar/Tools/Image/ImageModal.js +0 -26
  27. package/lib/EditorToolbar/Tools/Italic/ItalicButton.d.ts +0 -3
  28. package/lib/EditorToolbar/Tools/Italic/ItalicButton.js +0 -23
  29. package/lib/EditorToolbar/Tools/Link/Form/LinkForm.d.ts +0 -19
  30. package/lib/EditorToolbar/Tools/Link/Form/LinkForm.js +0 -63
  31. package/lib/EditorToolbar/Tools/Link/LinkButton.d.ts +0 -6
  32. package/lib/EditorToolbar/Tools/Link/LinkButton.js +0 -71
  33. package/lib/EditorToolbar/Tools/Link/LinkModal.d.ts +0 -9
  34. package/lib/EditorToolbar/Tools/Link/LinkModal.js +0 -27
  35. package/lib/EditorToolbar/Tools/Link/RemoveLinkButton.d.ts +0 -4
  36. package/lib/EditorToolbar/Tools/Link/RemoveLinkButton.js +0 -54
  37. package/lib/EditorToolbar/Tools/Lists/ListButtons.d.ts +0 -3
  38. package/lib/EditorToolbar/Tools/Lists/ListButtons.js +0 -14
  39. package/lib/EditorToolbar/Tools/Lists/OrderedList/OrderedListButton.d.ts +0 -3
  40. package/lib/EditorToolbar/Tools/Lists/OrderedList/OrderedListButton.js +0 -22
  41. package/lib/EditorToolbar/Tools/Lists/UnorderedList/UnorderedListButton.d.ts +0 -3
  42. package/lib/EditorToolbar/Tools/Lists/UnorderedList/UnorderedListButton.js +0 -22
  43. package/lib/EditorToolbar/Tools/Redo/RedoButton.d.ts +0 -3
  44. package/lib/EditorToolbar/Tools/Redo/RedoButton.js +0 -22
  45. package/lib/EditorToolbar/Tools/Table/TableButton.d.ts +0 -3
  46. package/lib/EditorToolbar/Tools/Table/TableButton.js +0 -20
  47. package/lib/EditorToolbar/Tools/TextAlign/CenterAlign/CenterAlignButton.d.ts +0 -3
  48. package/lib/EditorToolbar/Tools/TextAlign/CenterAlign/CenterAlignButton.js +0 -22
  49. package/lib/EditorToolbar/Tools/TextAlign/JustifyAlign/JustifyAlignButton.d.ts +0 -3
  50. package/lib/EditorToolbar/Tools/TextAlign/JustifyAlign/JustifyAlignButton.js +0 -22
  51. package/lib/EditorToolbar/Tools/TextAlign/LeftAlign/LeftAlignButton.d.ts +0 -3
  52. package/lib/EditorToolbar/Tools/TextAlign/LeftAlign/LeftAlignButton.js +0 -22
  53. package/lib/EditorToolbar/Tools/TextAlign/RightAlign/RightAlignButton.d.ts +0 -3
  54. package/lib/EditorToolbar/Tools/TextAlign/RightAlign/RightAlignButton.js +0 -22
  55. package/lib/EditorToolbar/Tools/TextAlign/TextAlignButtons.d.ts +0 -3
  56. package/lib/EditorToolbar/Tools/TextAlign/TextAlignButtons.js +0 -21
  57. package/lib/EditorToolbar/Tools/TextType/CodeBlock/CodeBlockButton.d.ts +0 -3
  58. package/lib/EditorToolbar/Tools/TextType/CodeBlock/CodeBlockButton.js +0 -22
  59. package/lib/EditorToolbar/Tools/TextType/Heading/HeadingButton.d.ts +0 -6
  60. package/lib/EditorToolbar/Tools/TextType/Heading/HeadingButton.js +0 -37
  61. package/lib/EditorToolbar/Tools/TextType/Paragraph/ParagraphButton.d.ts +0 -3
  62. package/lib/EditorToolbar/Tools/TextType/Paragraph/ParagraphButton.js +0 -21
  63. package/lib/EditorToolbar/Tools/TextType/Preformatted/PreformattedButton.d.ts +0 -3
  64. package/lib/EditorToolbar/Tools/TextType/Preformatted/PreformattedButton.js +0 -22
  65. package/lib/EditorToolbar/Tools/TextType/TextTypeDropdown.d.ts +0 -3
  66. package/lib/EditorToolbar/Tools/TextType/TextTypeDropdown.js +0 -46
  67. package/lib/EditorToolbar/Tools/Underline/UnderlineButton.d.ts +0 -3
  68. package/lib/EditorToolbar/Tools/Underline/UnderlineButton.js +0 -23
  69. package/lib/EditorToolbar/Tools/Undo/UndoButton.d.ts +0 -3
  70. package/lib/EditorToolbar/Tools/Undo/UndoButton.js +0 -22
  71. package/lib/EditorToolbar/index.d.ts +0 -2
  72. package/lib/EditorToolbar/index.js +0 -18
  73. package/lib/Extensions/ClearFormattingExtension/ClearFormattingExtension.d.ts +0 -5
  74. package/lib/Extensions/ClearFormattingExtension/ClearFormattingExtension.js +0 -63
  75. package/lib/Extensions/CodeBlockExtension/CodeBlockExtension.d.ts +0 -5
  76. package/lib/Extensions/CodeBlockExtension/CodeBlockExtension.js +0 -30
  77. package/lib/Extensions/CommandsExtension/CommandsExtension.d.ts +0 -20
  78. package/lib/Extensions/CommandsExtension/CommandsExtension.js +0 -52
  79. package/lib/Extensions/Extensions.d.ts +0 -18
  80. package/lib/Extensions/Extensions.js +0 -76
  81. package/lib/Extensions/FetchUrlExtension/FetchUrlExtension.d.ts +0 -12
  82. package/lib/Extensions/FetchUrlExtension/FetchUrlExtension.js +0 -69
  83. package/lib/Extensions/ImageExtension/AssetImageExtension.d.ts +0 -17
  84. package/lib/Extensions/ImageExtension/AssetImageExtension.js +0 -91
  85. package/lib/Extensions/ImageExtension/DAMImageExtension.d.ts +0 -17
  86. package/lib/Extensions/ImageExtension/DAMImageExtension.js +0 -97
  87. package/lib/Extensions/ImageExtension/ImageExtension.d.ts +0 -7
  88. package/lib/Extensions/ImageExtension/ImageExtension.js +0 -18
  89. package/lib/Extensions/LinkExtension/AssetLinkExtension.d.ts +0 -27
  90. package/lib/Extensions/LinkExtension/AssetLinkExtension.js +0 -101
  91. package/lib/Extensions/LinkExtension/LinkExtension.d.ts +0 -23
  92. package/lib/Extensions/LinkExtension/LinkExtension.js +0 -87
  93. package/lib/Extensions/LinkExtension/common.d.ts +0 -7
  94. package/lib/Extensions/LinkExtension/common.js +0 -14
  95. package/lib/Extensions/PreformattedExtension/PreformattedExtension.d.ts +0 -12
  96. package/lib/Extensions/PreformattedExtension/PreformattedExtension.js +0 -76
  97. package/lib/Extensions/UnsuportedExtension/UnsupportedNodeExtension.d.ts +0 -10
  98. package/lib/Extensions/UnsuportedExtension/UnsupportedNodeExtension.js +0 -76
  99. package/lib/Icons/AiIcon.d.ts +0 -2
  100. package/lib/Icons/AiIcon.js +0 -60
  101. package/lib/hooks/index.d.ts +0 -2
  102. package/lib/hooks/index.js +0 -18
  103. package/lib/hooks/useExpandedSelection.d.ts +0 -23
  104. package/lib/hooks/useExpandedSelection.js +0 -37
  105. package/lib/hooks/useExtensionNames.d.ts +0 -1
  106. package/lib/hooks/useExtensionNames.js +0 -16
  107. package/lib/hooks/useFocus.d.ts +0 -8
  108. package/lib/hooks/useFocus.js +0 -43
  109. package/lib/index.css +0 -5889
  110. package/lib/index.d.ts +0 -8
  111. package/lib/index.js +0 -16
  112. package/lib/types.d.ts +0 -7
  113. package/lib/types.js +0 -2
  114. package/lib/ui/Button/Button.d.ts +0 -12
  115. package/lib/ui/Button/Button.js +0 -13
  116. package/lib/ui/CollapseBox/CollapseBox.d.ts +0 -7
  117. package/lib/ui/CollapseBox/CollapseBox.js +0 -48
  118. package/lib/ui/Fields/Checkbox/Checkbox.d.ts +0 -9
  119. package/lib/ui/Fields/Checkbox/Checkbox.js +0 -47
  120. package/lib/ui/Fields/Input/Input.d.ts +0 -3
  121. package/lib/ui/Fields/Input/Input.js +0 -33
  122. package/lib/ui/Fields/InputContainer/InputContainer.d.ts +0 -9
  123. package/lib/ui/Fields/InputContainer/InputContainer.js +0 -16
  124. package/lib/ui/Fields/MatrixAsset/MatrixAsset.d.ts +0 -19
  125. package/lib/ui/Fields/MatrixAsset/MatrixAsset.js +0 -30
  126. package/lib/ui/Fields/ResourceBrowserSelector/ResourceBrowserSelector.d.ts +0 -28
  127. package/lib/ui/Fields/ResourceBrowserSelector/ResourceBrowserSelector.js +0 -88
  128. package/lib/ui/Modal/FormModal.d.ts +0 -5
  129. package/lib/ui/Modal/FormModal.js +0 -39
  130. package/lib/ui/Modal/Modal.d.ts +0 -11
  131. package/lib/ui/Modal/Modal.js +0 -79
  132. package/lib/ui/Tabs/Tabs.d.ts +0 -11
  133. package/lib/ui/Tabs/Tabs.js +0 -46
  134. package/lib/ui/ToolbarDropdown/ToolbarDropdown.d.ts +0 -7
  135. package/lib/ui/ToolbarDropdown/ToolbarDropdown.js +0 -48
  136. package/lib/ui/ToolbarDropdownButton/ToolbarDropdownButton.d.ts +0 -11
  137. package/lib/ui/ToolbarDropdownButton/ToolbarDropdownButton.js +0 -15
  138. package/lib/utils/converters/htmlToSquizNode/htmlToSquizNode.d.ts +0 -5
  139. package/lib/utils/converters/htmlToSquizNode/htmlToSquizNode.js +0 -23
  140. package/lib/utils/converters/htmlToSquizNode/htmlToSquizNode.props.d.ts +0 -3
  141. package/lib/utils/converters/htmlToSquizNode/htmlToSquizNode.props.js +0 -2
  142. package/lib/utils/converters/remirrorNodeToSquizNode/remirrorNodeToSquizNode.d.ts +0 -11
  143. package/lib/utils/converters/remirrorNodeToSquizNode/remirrorNodeToSquizNode.js +0 -238
  144. package/lib/utils/converters/squizNodeToRemirrorNode/squizNodeToRemirrorNode.d.ts +0 -9
  145. package/lib/utils/converters/squizNodeToRemirrorNode/squizNodeToRemirrorNode.js +0 -214
  146. package/lib/utils/createToolbarPositioner.d.ts +0 -18
  147. package/lib/utils/createToolbarPositioner.js +0 -96
  148. package/lib/utils/getCursorRect.d.ts +0 -2
  149. package/lib/utils/getCursorRect.js +0 -7
  150. package/lib/utils/getMarkNamesByGroup.d.ts +0 -2
  151. package/lib/utils/getMarkNamesByGroup.js +0 -9
  152. package/lib/utils/getNodeNamesByGroup.d.ts +0 -2
  153. package/lib/utils/getNodeNamesByGroup.js +0 -9
  154. package/lib/utils/getShortcutSymbol.d.ts +0 -1
  155. package/lib/utils/getShortcutSymbol.js +0 -8
  156. package/lib/utils/undefinedIfEmpty.d.ts +0 -1
  157. package/lib/utils/undefinedIfEmpty.js +0 -7
  158. package/lib/utils/validation.d.ts +0 -3
  159. package/lib/utils/validation.js +0 -16
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createToolbarPositioner = void 0;
4
- const extensions_1 = require("remirror/extensions");
5
- const remirror_1 = require("remirror");
6
- const getCursorRect_1 = require("./getCursorRect");
7
- /* istanbul ignore next */
8
- const createToolbarPositioner = ({ types }) => {
9
- // Inspired by "createMarkPositioner".
10
- // See: https://github.com/remirror/remirror/blob/107cba/packages/remirror__extension-positioner/src/core-positioners.ts#L267
11
- return extensions_1.Positioner.create({
12
- hasChanged: extensions_1.hasStateChanged,
13
- getActive: (props) => {
14
- const { state, view } = props;
15
- try {
16
- const selection = (0, remirror_1.getTextSelection)(state.selection, state.doc);
17
- const cursor = { from: view.coordsAtPos(selection.from), to: view.coordsAtPos(selection.to) };
18
- const data = {
19
- isSelectionInView: (0, extensions_1.isPositionVisible)((0, getCursorRect_1.getCursorRect)(cursor.from), view.dom) ||
20
- (0, extensions_1.isPositionVisible)((0, getCursorRect_1.getCursorRect)(cursor.to), view.dom),
21
- cursor: cursor,
22
- visible: false,
23
- marks: {},
24
- };
25
- data.visible = !selection.empty && data.isSelectionInView;
26
- types.forEach((type) => {
27
- const markRange = (0, remirror_1.getMarkRange)(selection.$from, type, selection.$to);
28
- if (!markRange) {
29
- data.marks[type] = { isActive: false, isExclusivelyActive: false };
30
- return;
31
- }
32
- // exclusively active =
33
- // the entire selection has the mark applied.
34
- // active =
35
- // at least part of the selection has the mark applied. "getMarkRanges" will return an empty array
36
- // if this isn't the case. if there is no selection the cursor must be within the bounds of the mark,
37
- // not on the edges.
38
- const isExclusivelyActive = selection.empty
39
- ? selection.from > markRange.from && selection.to < markRange.to
40
- : selection.from >= markRange.from && selection.to <= markRange.to;
41
- const isActive = selection.empty ? selection.from > markRange.from && selection.to < markRange.to : true;
42
- // the toolbar will be visible if there is either a selection, or we are within the bounds of a mark
43
- // we have formatting tools for.
44
- data.visible = data.visible || isExclusivelyActive;
45
- data.marks[type] = { isExclusivelyActive, isActive };
46
- });
47
- return data.visible ? [data] : extensions_1.Positioner.EMPTY;
48
- }
49
- catch {
50
- return extensions_1.Positioner.EMPTY;
51
- }
52
- },
53
- getPosition: (props) => {
54
- const { element, data, view } = props;
55
- const { cursor, visible } = data;
56
- const { from, to } = cursor;
57
- const parent = element.offsetParent ?? view.dom;
58
- const parentRect = parent.getBoundingClientRect();
59
- const height = Math.abs(to.bottom - from.top);
60
- // Hack to get JSDOM to work, positioning doesn't work great here.
61
- if (isNaN(parentRect.top)) {
62
- return {
63
- rect: new DOMRect(0, 0, 0, 0),
64
- y: 0,
65
- x: 0,
66
- height: 0,
67
- width: 0,
68
- visible: false,
69
- };
70
- }
71
- // True when the selection spans multiple lines.
72
- const spansMultipleLines = height > from.bottom - from.top;
73
- // The position furthest to the left.
74
- const leftmost = Math.min(from.left, to.left);
75
- // The position nearest the top.
76
- const topmost = Math.min(from.top, to.top);
77
- const bottommost = Math.max(from.bottom, to.bottom);
78
- const left = parent.scrollLeft + (spansMultipleLines ? to.left - parentRect.left : leftmost - parentRect.left);
79
- const top = parent.scrollTop + topmost - parentRect.top;
80
- const width = spansMultipleLines ? 1 : Math.abs(from.left - to.right);
81
- const rect = new DOMRect(spansMultipleLines ? to.left : leftmost, topmost, width, height);
82
- // Get header toolbar by class inside the current element/editor
83
- const headerToolbar = element.parentElement?.getElementsByClassName('header-toolbar')?.[0];
84
- const headerBarRects = headerToolbar?.getBoundingClientRect();
85
- const headerBarHeight = headerBarRects?.height ?? 0;
86
- const headerBarBottom = (headerBarRects?.top ?? 0) + headerBarHeight;
87
- // If floating toolbar will overlap fixed toolbar, set position to under selection
88
- const isOverlapping = headerBarBottom + headerBarHeight > topmost;
89
- // This is a good bottom position instead of it being on top of the toolbar when there is an overlap
90
- const bottomPosition = parent.scrollTop + bottommost - parentRect.top + 62;
91
- const y = isOverlapping ? bottomPosition : top;
92
- return { rect, y, x: left, height, width, visible };
93
- },
94
- });
95
- };
96
- exports.createToolbarPositioner = createToolbarPositioner;
@@ -1,2 +0,0 @@
1
- import { Coords } from 'remirror';
2
- export declare const getCursorRect: (coords: Coords) => DOMRect;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCursorRect = void 0;
4
- const getCursorRect = (coords) => {
5
- return new DOMRect(coords.left, coords.top, 1, coords.top - coords.bottom);
6
- };
7
- exports.getCursorRect = getCursorRect;
@@ -1,2 +0,0 @@
1
- import { EditorSchema, ExtensionTagType } from '@remirror/core';
2
- export declare const getMarkNamesByGroup: (schema: EditorSchema, group: ExtensionTagType) => string[];
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMarkNamesByGroup = void 0;
4
- const getMarkNamesByGroup = (schema, group) => {
5
- return Object.values(schema.marks)
6
- .filter((mark) => mark.spec.group?.includes(group))
7
- .map((mark) => mark.name);
8
- };
9
- exports.getMarkNamesByGroup = getMarkNamesByGroup;
@@ -1,2 +0,0 @@
1
- import { EditorSchema, ExtensionTagType } from '@remirror/core';
2
- export declare const getNodeNamesByGroup: (schema: EditorSchema, group: ExtensionTagType) => string[];
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNodeNamesByGroup = void 0;
4
- const getNodeNamesByGroup = (schema, group) => {
5
- return Object.values(schema.nodes)
6
- .filter((node) => node.spec.group?.includes(group))
7
- .map((node) => node.name);
8
- };
9
- exports.getNodeNamesByGroup = getNodeNamesByGroup;
@@ -1 +0,0 @@
1
- export declare const getShortcutSymbol: () => string;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getShortcutSymbol = void 0;
4
- const getShortcutSymbol = () => {
5
- // If we can detect Mac then we return "⌘" otherwise default to "Ctrl"
6
- return window.navigator.userAgent.toLowerCase().indexOf('mac') > -1 ? '⌘' : 'Ctrl';
7
- };
8
- exports.getShortcutSymbol = getShortcutSymbol;
@@ -1 +0,0 @@
1
- export declare const undefinedIfEmpty: <T extends object>(object: T) => T | undefined;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.undefinedIfEmpty = void 0;
4
- const undefinedIfEmpty = (object) => {
5
- return Object.keys(object).length > 0 ? object : undefined;
6
- };
7
- exports.undefinedIfEmpty = undefinedIfEmpty;
@@ -1,3 +0,0 @@
1
- export declare const noEmptySpacesValidation: (value: string | undefined) => "Empty space is not allowed" | undefined;
2
- export declare const hasProperties: <T>(message: string, properties: (keyof T)[]) => (value: T) => string | undefined;
3
- export declare const regexDataURI: RegExp;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.regexDataURI = exports.hasProperties = exports.noEmptySpacesValidation = void 0;
4
- const noEmptySpacesValidation = (value) => {
5
- if (value && !(value.trim().length > 0)) {
6
- return 'Empty space is not allowed';
7
- }
8
- };
9
- exports.noEmptySpacesValidation = noEmptySpacesValidation;
10
- const hasProperties = (message, properties) => (value) => {
11
- if (!value || properties.filter((property) => value[property]).length !== properties.length) {
12
- return message;
13
- }
14
- };
15
- exports.hasProperties = hasProperties;
16
- exports.regexDataURI = /^data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@/?%\s]*)$/i;