@squiz/formatted-text-editor 1.21.1-alpha.2 → 1.21.1-alpha.20

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 (142) hide show
  1. package/demo/App.tsx +45 -10
  2. package/demo/index.scss +11 -10
  3. package/lib/Editor/Editor.js +38 -6
  4. package/lib/Editor/EditorContext.d.ts +10 -0
  5. package/lib/Editor/EditorContext.js +15 -0
  6. package/lib/EditorToolbar/FloatingToolbar.js +11 -5
  7. package/lib/EditorToolbar/Toolbar.js +3 -1
  8. package/lib/EditorToolbar/Tools/Bold/BoldButton.js +2 -2
  9. package/lib/EditorToolbar/Tools/Image/Form/ImageForm.d.ts +17 -0
  10. package/lib/EditorToolbar/Tools/Image/Form/ImageForm.js +82 -0
  11. package/lib/EditorToolbar/Tools/Image/ImageButton.d.ts +5 -0
  12. package/lib/EditorToolbar/Tools/Image/ImageButton.js +76 -0
  13. package/lib/EditorToolbar/Tools/Image/ImageModal.d.ts +8 -0
  14. package/lib/EditorToolbar/Tools/Image/ImageModal.js +16 -0
  15. package/lib/EditorToolbar/Tools/Italic/ItalicButton.js +2 -2
  16. package/lib/EditorToolbar/Tools/Link/Form/LinkForm.d.ts +14 -5
  17. package/lib/EditorToolbar/Tools/Link/Form/LinkForm.js +67 -15
  18. package/lib/EditorToolbar/Tools/Link/LinkButton.js +13 -10
  19. package/lib/EditorToolbar/Tools/Link/LinkModal.js +12 -5
  20. package/lib/EditorToolbar/Tools/Link/RemoveLinkButton.js +2 -9
  21. package/lib/EditorToolbar/Tools/Redo/RedoButton.js +2 -2
  22. package/lib/EditorToolbar/Tools/TextAlign/CenterAlign/CenterAlignButton.js +2 -2
  23. package/lib/EditorToolbar/Tools/TextAlign/JustifyAlign/JustifyAlignButton.js +2 -2
  24. package/lib/EditorToolbar/Tools/TextAlign/LeftAlign/LeftAlignButton.js +2 -2
  25. package/lib/EditorToolbar/Tools/TextAlign/RightAlign/RightAlignButton.js +2 -2
  26. package/lib/EditorToolbar/Tools/Underline/UnderlineButton.js +2 -2
  27. package/lib/EditorToolbar/Tools/Undo/UndoButton.js +2 -2
  28. package/lib/Extensions/CommandsExtension/CommandsExtension.d.ts +20 -0
  29. package/lib/Extensions/CommandsExtension/CommandsExtension.js +52 -0
  30. package/lib/Extensions/Extensions.d.ts +7 -4
  31. package/lib/Extensions/Extensions.js +32 -19
  32. package/lib/Extensions/ImageExtension/ImageExtension.d.ts +10 -0
  33. package/lib/Extensions/ImageExtension/ImageExtension.js +92 -0
  34. package/lib/Extensions/LinkExtension/AssetLinkExtension.d.ts +26 -0
  35. package/lib/Extensions/LinkExtension/AssetLinkExtension.js +102 -0
  36. package/lib/Extensions/LinkExtension/LinkExtension.d.ts +21 -12
  37. package/lib/Extensions/LinkExtension/LinkExtension.js +63 -65
  38. package/lib/Extensions/LinkExtension/common.d.ts +7 -0
  39. package/lib/Extensions/LinkExtension/common.js +14 -0
  40. package/lib/Extensions/PreformattedExtension/PreformattedExtension.d.ts +1 -1
  41. package/lib/hooks/index.d.ts +1 -0
  42. package/lib/hooks/index.js +1 -0
  43. package/lib/hooks/useExpandedSelection.d.ts +23 -0
  44. package/lib/hooks/useExpandedSelection.js +37 -0
  45. package/lib/index.css +157 -75
  46. package/lib/index.d.ts +5 -2
  47. package/lib/index.js +9 -3
  48. package/lib/types.d.ts +3 -0
  49. package/lib/types.js +2 -0
  50. package/lib/ui/Button/Button.d.ts +11 -0
  51. package/lib/ui/{ToolbarButton/ToolbarButton.js → Button/Button.js} +6 -3
  52. package/lib/ui/Fields/Input/Input.d.ts +5 -0
  53. package/lib/ui/{Inputs/Text/TextInput.js → Fields/Input/Input.js} +10 -5
  54. package/lib/ui/Modal/Modal.js +2 -1
  55. package/lib/utils/converters/remirrorNodeToSquizNode/remirrorNodeToSquizNode.d.ts +9 -0
  56. package/lib/utils/converters/remirrorNodeToSquizNode/remirrorNodeToSquizNode.js +165 -0
  57. package/lib/utils/converters/squizNodeToRemirrorNode/squizNodeToRemirrorNode.d.ts +9 -0
  58. package/lib/utils/converters/squizNodeToRemirrorNode/squizNodeToRemirrorNode.js +129 -0
  59. package/lib/utils/undefinedIfEmpty.d.ts +1 -0
  60. package/lib/utils/undefinedIfEmpty.js +7 -0
  61. package/package.json +9 -4
  62. package/src/Editor/Editor.spec.tsx +78 -18
  63. package/src/Editor/Editor.tsx +20 -7
  64. package/src/Editor/EditorContext.spec.tsx +26 -0
  65. package/src/Editor/EditorContext.ts +19 -0
  66. package/src/Editor/_editor.scss +16 -53
  67. package/src/EditorToolbar/FloatingToolbar.spec.tsx +2 -3
  68. package/src/EditorToolbar/FloatingToolbar.tsx +18 -6
  69. package/src/EditorToolbar/Toolbar.tsx +2 -0
  70. package/src/EditorToolbar/Tools/Bold/BoldButton.spec.tsx +1 -1
  71. package/src/EditorToolbar/Tools/Bold/BoldButton.tsx +2 -2
  72. package/src/EditorToolbar/Tools/Image/Form/ImageForm.spec.tsx +77 -0
  73. package/src/EditorToolbar/Tools/Image/Form/ImageForm.tsx +90 -0
  74. package/src/EditorToolbar/Tools/Image/ImageButton.spec.tsx +135 -0
  75. package/src/EditorToolbar/Tools/Image/ImageButton.tsx +71 -0
  76. package/src/EditorToolbar/Tools/Image/ImageModal.spec.tsx +83 -0
  77. package/src/EditorToolbar/Tools/Image/ImageModal.tsx +24 -0
  78. package/src/EditorToolbar/Tools/Italic/ItalicButton.spec.tsx +1 -1
  79. package/src/EditorToolbar/Tools/Italic/ItalicButton.tsx +2 -2
  80. package/src/EditorToolbar/Tools/Link/Form/LinkForm.spec.tsx +37 -9
  81. package/src/EditorToolbar/Tools/Link/Form/LinkForm.tsx +97 -27
  82. package/src/EditorToolbar/Tools/Link/LinkButton.spec.tsx +104 -26
  83. package/src/EditorToolbar/Tools/Link/LinkButton.tsx +19 -13
  84. package/src/EditorToolbar/Tools/Link/LinkModal.tsx +13 -6
  85. package/src/EditorToolbar/Tools/Link/RemoveLinkButton.spec.tsx +26 -26
  86. package/src/EditorToolbar/Tools/Link/RemoveLinkButton.tsx +4 -12
  87. package/src/EditorToolbar/Tools/Redo/RedoButton.tsx +2 -2
  88. package/src/EditorToolbar/Tools/TextAlign/CenterAlign/CenterAlignButton.tsx +2 -2
  89. package/src/EditorToolbar/Tools/TextAlign/JustifyAlign/JustifyAlignButton.tsx +2 -2
  90. package/src/EditorToolbar/Tools/TextAlign/LeftAlign/LeftAlignButton.tsx +2 -2
  91. package/src/EditorToolbar/Tools/TextAlign/RightAlign/RightAlignButton.tsx +2 -2
  92. package/src/EditorToolbar/Tools/Underline/Underline.spec.tsx +1 -1
  93. package/src/EditorToolbar/Tools/Underline/UnderlineButton.tsx +2 -2
  94. package/src/EditorToolbar/Tools/Undo/UndoButton.spec.tsx +22 -1
  95. package/src/EditorToolbar/Tools/Undo/UndoButton.tsx +2 -2
  96. package/src/EditorToolbar/_floating-toolbar.scss +5 -0
  97. package/src/EditorToolbar/_toolbar.scss +11 -5
  98. package/src/Extensions/CommandsExtension/CommandsExtension.ts +54 -0
  99. package/src/Extensions/Extensions.ts +32 -17
  100. package/src/Extensions/ImageExtension/ImageExtension.ts +112 -0
  101. package/src/Extensions/LinkExtension/AssetLinkExtension.spec.ts +104 -0
  102. package/src/Extensions/LinkExtension/AssetLinkExtension.ts +128 -0
  103. package/src/Extensions/LinkExtension/LinkExtension.spec.ts +68 -0
  104. package/src/Extensions/LinkExtension/LinkExtension.ts +88 -82
  105. package/src/Extensions/LinkExtension/common.ts +10 -0
  106. package/src/hooks/index.ts +1 -0
  107. package/src/hooks/useExpandedSelection.ts +44 -0
  108. package/src/index.scss +2 -2
  109. package/src/index.ts +5 -2
  110. package/src/types.ts +5 -0
  111. package/src/ui/Button/Button.spec.tsx +44 -0
  112. package/src/ui/Button/Button.tsx +29 -0
  113. package/src/ui/{_buttons.scss → Button/_button.scss} +19 -1
  114. package/src/ui/{Inputs/Text/TextInput.spec.tsx → Fields/Input/Input.spec.tsx} +8 -8
  115. package/src/ui/Fields/Input/Input.tsx +34 -0
  116. package/src/ui/Modal/Modal.tsx +2 -1
  117. package/src/ui/ToolbarDropdown/_toolbar-dropdown.scss +1 -1
  118. package/src/ui/_forms.scss +14 -0
  119. package/src/ui/_typography.scss +46 -0
  120. package/src/utils/converters/mocks/squizNodeJson.mock.ts +252 -0
  121. package/src/utils/converters/remirrorNodeToSquizNode/remirrorNodeToSquizNode.spec.ts +480 -0
  122. package/src/utils/converters/remirrorNodeToSquizNode/remirrorNodeToSquizNode.ts +202 -0
  123. package/src/utils/converters/squizNodeToRemirrorNode/squizNodeToRemirrorNode.spec.ts +329 -0
  124. package/src/utils/converters/squizNodeToRemirrorNode/squizNodeToRemirrorNode.ts +151 -0
  125. package/src/utils/undefinedIfEmpty.spec.ts +12 -0
  126. package/src/utils/undefinedIfEmpty.ts +3 -0
  127. package/tailwind.config.cjs +3 -0
  128. package/tests/renderWithEditor.tsx +28 -15
  129. package/lib/FormattedTextEditor.d.ts +0 -2
  130. package/lib/FormattedTextEditor.js +0 -7
  131. package/lib/ui/Inputs/Text/TextInput.d.ts +0 -4
  132. package/lib/ui/ToolbarButton/ToolbarButton.d.ts +0 -10
  133. package/src/Editor/Editor.mock.tsx +0 -43
  134. package/src/FormattedTextEditor.spec.tsx +0 -10
  135. package/src/FormattedTextEditor.tsx +0 -3
  136. package/src/ui/Inputs/Text/TextInput.tsx +0 -20
  137. package/src/ui/ToolbarButton/ToolbarButton.tsx +0 -26
  138. package/src/ui/ToolbarButton/_toolbar-button.scss +0 -17
  139. /package/lib/ui/{Inputs → Fields}/Select/Select.d.ts +0 -0
  140. /package/lib/ui/{Inputs → Fields}/Select/Select.js +0 -0
  141. /package/src/ui/{Inputs → Fields}/Select/Select.spec.tsx +0 -0
  142. /package/src/ui/{Inputs → Fields}/Select/Select.tsx +0 -0
@@ -1,18 +1,31 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
9
  exports.LinkExtension = void 0;
4
10
  const remirror_1 = require("remirror");
5
11
  const core_1 = require("@remirror/core");
6
- const extensions_1 = require("remirror/extensions");
7
- class LinkExtension extends extensions_1.LinkExtension {
12
+ const common_1 = require("./common");
13
+ const CommandsExtension_1 = require("../CommandsExtension/CommandsExtension");
14
+ const Extensions_1 = require("../Extensions");
15
+ let LinkExtension = class LinkExtension extends core_1.MarkExtension {
16
+ get name() {
17
+ return Extensions_1.MarkName.Link;
18
+ }
8
19
  createMarkSpec(extra, override) {
9
- const spec = super.createMarkSpec(extra, override);
10
20
  return {
11
- ...spec,
12
- excludes: undefined,
21
+ inclusive: false,
22
+ excludes: 'assetLink',
23
+ ...override,
13
24
  attrs: {
14
- ...spec.attrs,
25
+ ...extra.defaults(),
26
+ href: {},
15
27
  title: { default: undefined },
28
+ target: { default: this.options.defaultTarget },
16
29
  },
17
30
  parseDOM: [
18
31
  {
@@ -23,75 +36,60 @@ class LinkExtension extends extensions_1.LinkExtension {
23
36
  }
24
37
  return {
25
38
  ...extra.parse(node),
26
- auto: false,
27
39
  href: node.getAttribute('href'),
28
- target: node.getAttribute('target'),
29
40
  title: node.getAttribute('title'),
41
+ target: (0, common_1.validateTarget)(node.getAttribute('target'), this.options.supportedTargets, this.options.defaultTarget),
30
42
  };
31
43
  },
32
44
  },
33
45
  ],
46
+ toDOM: (node) => {
47
+ const { target, ...rest } = (0, core_1.omitExtraAttributes)(node.attrs, extra);
48
+ const rel = 'noopener noreferrer nofollow';
49
+ const attrs = {
50
+ ...extra.dom(node),
51
+ ...rest,
52
+ rel,
53
+ target: (0, common_1.validateTarget)(target, this.options.supportedTargets, this.options.defaultTarget),
54
+ };
55
+ return ['a', attrs, 0];
56
+ },
34
57
  };
35
58
  }
36
- shortcut({ tr }) {
37
- // override parent implementation to allow a link to be inserted without requiring a text selection first.
38
- const { from, to, $from } = tr.selection;
39
- const mark = (0, core_1.getMarkRange)($from, this.type);
40
- const selectedText = tr.doc.textBetween(from, to);
41
- this.options.onShortcut({
42
- activeLink: mark ? { attrs: mark.mark.attrs, from: mark.from, to: mark.to } : undefined,
43
- selectedText,
44
- from,
45
- to,
46
- });
59
+ shortcut(_) {
60
+ this.options.onShortcut();
47
61
  return true;
48
62
  }
49
- selectLink() {
50
- // parent implementation selects only the link text, this mimics closer to Google Docs where
51
- // the select text is widened to include the link but retains non-link selected text as well.
52
- return (props) => {
53
- const { tr } = props;
54
- const ranges = (0, remirror_1.getMarkRanges)(tr.selection, this.type);
55
- if (ranges.length === 0) {
56
- return false;
57
- }
58
- // work out the start position of the first link and end position of the last link in the selection.
59
- const from = Math.min(tr.selection.from, ...ranges.map((range) => range.from));
60
- const to = Math.max(tr.selection.to, ...ranges.map((range) => range.to));
61
- // don't need to widen the selection, return early.
62
- if (tr.selection.from === from && tr.selection.to === to) {
63
- return false;
64
- }
65
- // widen the selection to make sure the full link is included.
66
- this.store.commands.selectText.original({ from, to })(props);
67
- return true;
68
- };
63
+ updateLink({ text, attrs, range }) {
64
+ return this.store.getExtension(CommandsExtension_1.CommandsExtension).updateMark({
65
+ attrs,
66
+ text,
67
+ range,
68
+ mark: this.type,
69
+ removeMark: !attrs.href,
70
+ });
69
71
  }
70
- updateLink(options) {
71
- const { text, ...attrs } = options;
72
- return (props) => {
73
- const { tr, dispatch, view } = props;
74
- const range = { from: tr.selection.from, to: tr.selection.to };
75
- const selectedText = tr.doc.textBetween(range.from, range.to);
76
- if (text !== selectedText) {
77
- // update the text in the editor if it was updated, update the range to cover the length of the new text.
78
- tr.insertText(text);
79
- range.to = range.from + text.length;
80
- }
81
- // apply the link, or remove it if no URL was provided.
82
- if (attrs.href.length > 0) {
83
- tr.addMark(range.from, range.to, this.type.create(attrs));
84
- }
85
- else {
86
- tr.removeMark(range.from, range.to, this.type);
87
- }
88
- // move the cursor to the end of the link and re-focus the editor.
89
- tr.setSelection((0, core_1.getTextSelection)({ from: range.to, to: range.to }, tr.doc));
90
- // apply the transaction.
91
- dispatch?.(tr);
92
- view?.focus();
93
- return true;
94
- };
72
+ removeLink() {
73
+ return (0, core_1.removeMark)({ type: this.type });
95
74
  }
96
- }
75
+ };
76
+ __decorate([
77
+ (0, core_1.keyBinding)({ shortcut: core_1.NamedShortcut.InsertLink })
78
+ ], LinkExtension.prototype, "shortcut", null);
79
+ __decorate([
80
+ (0, core_1.command)()
81
+ ], LinkExtension.prototype, "updateLink", null);
82
+ __decorate([
83
+ (0, core_1.command)()
84
+ ], LinkExtension.prototype, "removeLink", null);
85
+ LinkExtension = __decorate([
86
+ (0, core_1.extension)({
87
+ defaultOptions: {
88
+ defaultTarget: common_1.LinkTarget.Self,
89
+ supportedTargets: [common_1.LinkTarget.Self, common_1.LinkTarget.Blank],
90
+ },
91
+ handlerKeys: ['onShortcut'],
92
+ defaultPriority: remirror_1.ExtensionPriority.Medium,
93
+ })
94
+ ], LinkExtension);
97
95
  exports.LinkExtension = LinkExtension;
@@ -0,0 +1,7 @@
1
+ export declare enum LinkTarget {
2
+ Self = "_self",
3
+ Blank = "_blank",
4
+ Parent = "_parent",
5
+ Top = "_top"
6
+ }
7
+ export declare const validateTarget: (target: unknown, supportedTargets: LinkTarget[], defaultTarget: LinkTarget) => LinkTarget;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateTarget = exports.LinkTarget = void 0;
4
+ var LinkTarget;
5
+ (function (LinkTarget) {
6
+ LinkTarget["Self"] = "_self";
7
+ LinkTarget["Blank"] = "_blank";
8
+ LinkTarget["Parent"] = "_parent";
9
+ LinkTarget["Top"] = "_top";
10
+ })(LinkTarget = exports.LinkTarget || (exports.LinkTarget = {}));
11
+ const validateTarget = (target, supportedTargets, defaultTarget) => {
12
+ return supportedTargets.includes(target) ? target : defaultTarget;
13
+ };
14
+ exports.validateTarget = validateTarget;
@@ -1,7 +1,7 @@
1
1
  import { ApplySchemaAttributes, CommandFunction, NodeExtension, NodeExtensionSpec, NodeSpecOverride } from '@remirror/core';
2
2
  export declare class PreformattedExtension extends NodeExtension {
3
3
  get name(): "preformatted";
4
- createTags(): ("formattingNode" | "block" | "textBlock")[];
4
+ createTags(): ("block" | "formattingNode" | "textBlock")[];
5
5
  createNodeSpec(extra: ApplySchemaAttributes, override: NodeSpecOverride): NodeExtensionSpec;
6
6
  /**
7
7
  * Toggle the <pre> for the current block.
@@ -1 +1,2 @@
1
1
  export * from './useExtensionNames';
2
+ export * from './useExpandedSelection';
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./useExtensionNames"), exports);
18
+ __exportStar(require("./useExpandedSelection"), exports);
@@ -0,0 +1,23 @@
1
+ import { Selection } from '@remirror/core';
2
+ import { Mark, MarkType } from 'remirror';
3
+ export type ExpandedSelection = {
4
+ selection: Selection;
5
+ marks: Mark[];
6
+ };
7
+ /**
8
+ * Returns a single range that is either:
9
+ * 1. The current selection if the current selection does not contain any of the indicated marks.
10
+ * 2. An expanded version of the current selection if the range contains any of the indicated marks.
11
+ *
12
+ * For example, given the content:
13
+ *
14
+ * <strong>Bold</strong> regular <u>underline</u> <u>more underline</u>
15
+ *
16
+ * If the marks passed in are 'bold' and 'underline' and the text "old regular under" is selected
17
+ * the returned range will be "Bold regular underline".
18
+ *
19
+ * @param {(MarkType|string)[]} markTypes
20
+ *
21
+ * @return {ExpandedSelection}
22
+ */
23
+ export declare const useExpandedSelection: (markTypes: (MarkType | string)[]) => ExpandedSelection;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useExpandedSelection = void 0;
4
+ const remirror_1 = require("remirror");
5
+ const react_1 = require("@remirror/react");
6
+ /**
7
+ * Returns a single range that is either:
8
+ * 1. The current selection if the current selection does not contain any of the indicated marks.
9
+ * 2. An expanded version of the current selection if the range contains any of the indicated marks.
10
+ *
11
+ * For example, given the content:
12
+ *
13
+ * <strong>Bold</strong> regular <u>underline</u> <u>more underline</u>
14
+ *
15
+ * If the marks passed in are 'bold' and 'underline' and the text "old regular under" is selected
16
+ * the returned range will be "Bold regular underline".
17
+ *
18
+ * @param {(MarkType|string)[]} markTypes
19
+ *
20
+ * @return {ExpandedSelection}
21
+ */
22
+ const useExpandedSelection = (markTypes) => {
23
+ const { doc, selection } = (0, react_1.useEditorState)();
24
+ const ranges = [];
25
+ markTypes.forEach((markType) => {
26
+ ranges.push(...(0, remirror_1.getMarkRanges)(selection, markType));
27
+ });
28
+ if (ranges.length === 0) {
29
+ return { selection, marks: [] };
30
+ }
31
+ // work out the start position of the first link and end position of the last link in the selection.
32
+ const from = Math.min(selection.from, ...ranges.map((range) => range.from));
33
+ const to = Math.max(selection.to, ...ranges.map((range) => range.to));
34
+ const marks = ranges.map((range) => range.mark);
35
+ return { selection: (0, remirror_1.getTextSelection)({ from, to }, doc), marks };
36
+ };
37
+ exports.useExpandedSelection = useExpandedSelection;
package/lib/index.css CHANGED
@@ -376,6 +376,10 @@
376
376
  .squiz-fte-scope .z-40 {
377
377
  z-index: 40 !important;
378
378
  }
379
+ .squiz-fte-scope .mx-1 {
380
+ margin-left: 0.25rem !important;
381
+ margin-right: 0.25rem !important;
382
+ }
379
383
  .squiz-fte-scope .mx-auto {
380
384
  margin-left: auto !important;
381
385
  margin-right: auto !important;
@@ -437,6 +441,12 @@
437
441
  -moz-user-select: none !important;
438
442
  user-select: none !important;
439
443
  }
444
+ .squiz-fte-scope .flex-row {
445
+ flex-direction: row !important;
446
+ }
447
+ .squiz-fte-scope .items-end {
448
+ align-items: flex-end !important;
449
+ }
440
450
  .squiz-fte-scope .items-center {
441
451
  align-items: center !important;
442
452
  }
@@ -566,6 +576,47 @@
566
576
  --tw-blur: blur(8px) !important;
567
577
  filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow) !important;
568
578
  }
579
+ .squiz-fte-scope a {
580
+ --tw-text-opacity: 1;
581
+ color: rgb(7 116 210 / var(--tw-text-opacity));
582
+ text-decoration: underline;
583
+ }
584
+ .squiz-fte-scope h1 {
585
+ font-size: 1.625rem;
586
+ font-weight: 600;
587
+ letter-spacing: -0.2px;
588
+ line-height: 2rem;
589
+ }
590
+ .squiz-fte-scope h2 {
591
+ font-size: 1.25rem;
592
+ font-weight: 600;
593
+ letter-spacing: -0.5px;
594
+ line-height: 1.5rem;
595
+ }
596
+ .squiz-fte-scope h3 {
597
+ font-size: 1.125rem;
598
+ font-weight: 600;
599
+ letter-spacing: -0.2px;
600
+ line-height: 1.375rem;
601
+ }
602
+ .squiz-fte-scope h4 {
603
+ font-size: 1rem;
604
+ font-weight: 700;
605
+ letter-spacing: -0.2px;
606
+ line-height: 1.25rem;
607
+ }
608
+ .squiz-fte-scope h5 {
609
+ font-size: 1rem;
610
+ font-weight: 600;
611
+ letter-spacing: -0.2px;
612
+ line-height: 1.25rem;
613
+ }
614
+ .squiz-fte-scope h6 {
615
+ font-size: 0.875rem;
616
+ font-weight: 600;
617
+ letter-spacing: -0.2px;
618
+ line-height: 1.25rem;
619
+ }
569
620
  .squiz-fte-scope .squiz-fte-form-group {
570
621
  display: flex;
571
622
  flex-direction: column;
@@ -611,33 +662,23 @@
611
662
  .squiz-fte-scope .squiz-fte-form-control:active {
612
663
  box-shadow: none;
613
664
  }
614
- .squiz-fte-scope .squiz-fte-btn {
615
- border-radius: 4px;
616
- font-weight: 400;
617
- transition-property: all;
618
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
619
- transition-duration: 150ms;
620
- transition-timing-function: linear;
621
- display: flex;
622
- align-items: center;
623
- text-align: center;
624
- white-space: nowrap;
625
- vertical-align: middle;
626
- touch-action: manipulation;
627
- cursor: pointer;
628
- background-image: none;
629
- border: 1px solid transparent;
630
- padding: 6px 12px;
665
+ .squiz-fte-scope .squiz-fte-invalid-form-field .squiz-fte-form-control {
666
+ --tw-border-opacity: 1;
667
+ border-color: rgb(215 35 33 / var(--tw-border-opacity));
668
+ background-repeat: no-repeat;
669
+ background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjQiIHdpZHRoPSIyNCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0ibm9uZSIvPjxnIGNsYXNzPSJjdXJyZW50TGF5ZXIiPjxwYXRoIGQ9Ik00LjQ3IDIxaDE1LjA2YzEuNTQgMCAyLjUtMS42NyAxLjczLTNMMTMuNzMgNC45OWMtLjc3LTEuMzMtMi42OS0xLjMzLTMuNDYgMEwyLjc0IDE4Yy0uNzcgMS4zMy4xOSAzIDEuNzMgM3pNMTIgMTRjLS41NSAwLTEtLjQ1LTEtMXYtMmMwLS41NS40NS0xIDEtMXMxIC40NSAxIDF2MmMwIC41NS0uNDUgMS0xIDF6bTEgNGgtMnYtMmgydjJ6IiBjbGFzcz0ic2VsZWN0ZWQiIGZpbGw9IiNkNzIzMjEiLz48L2c+PC9zdmc+);
670
+ background-position: top 0.25rem right 0.25rem;
671
+ background-size: 1.5rem;
631
672
  }
632
- .squiz-fte-scope .squiz-fte-btn.disabled,
633
- .squiz-fte-scope .squiz-fte-btn[disabled] {
634
- cursor: not-allowed;
635
- opacity: 0.5;
673
+ .squiz-fte-scope .squiz-fte-form-error {
674
+ --tw-text-opacity: 1;
675
+ color: rgb(215 35 33 / var(--tw-text-opacity));
676
+ font-size: 13px;
677
+ line-height: 1.23;
678
+ padding-top: 0.25rem;
636
679
  }
637
680
  .squiz-fte-scope .formatted-text-editor {
638
681
  font-family: "Open Sans" !important;
639
- }
640
- .squiz-fte-scope .formatted-text-editor.editor-wrapper {
641
682
  border-radius: 4px;
642
683
  border-width: 2px;
643
684
  border-style: solid;
@@ -649,7 +690,7 @@
649
690
  .squiz-fte-scope .formatted-text-editor .remirror-editor-wrapper {
650
691
  padding-top: 0px;
651
692
  --tw-text-opacity: 1;
652
- color: rgb(112 112 112 / var(--tw-text-opacity));
693
+ color: rgb(61 61 61 / var(--tw-text-opacity));
653
694
  }
654
695
  .squiz-fte-scope .formatted-text-editor .remirror-editor {
655
696
  border-bottom-right-radius: 4px;
@@ -663,7 +704,8 @@
663
704
  var(--tw-ring-offset-shadow, 0 0 #0000),
664
705
  var(--tw-ring-shadow, 0 0 #0000),
665
706
  var(--tw-shadow);
666
- min-height: 6rem;
707
+ overflow: auto;
708
+ min-height: 15vh;
667
709
  }
668
710
  .squiz-fte-scope .formatted-text-editor .remirror-editor:active,
669
711
  .squiz-fte-scope .formatted-text-editor .remirror-editor:focus {
@@ -672,6 +714,14 @@
672
714
  .squiz-fte-scope .formatted-text-editor .remirror-editor p {
673
715
  display: block;
674
716
  }
717
+ .squiz-fte-scope .formatted-text-editor--is-disabled .remirror-editor {
718
+ cursor: not-allowed;
719
+ --tw-bg-opacity: 1;
720
+ background-color: rgb(224 224 224 / var(--tw-bg-opacity));
721
+ }
722
+ .squiz-fte-scope .formatted-text-editor--is-disabled .remirror-is-empty:first-of-type::before {
723
+ display: none;
724
+ }
675
725
  .squiz-fte-scope .formatted-text-editor .remirror-is-empty:first-of-type::before {
676
726
  position: absolute;
677
727
  pointer-events: none;
@@ -681,48 +731,14 @@
681
731
  --tw-text-opacity: 1;
682
732
  color: rgb(148 148 148 / var(--tw-text-opacity));
683
733
  }
684
- .squiz-fte-scope a {
685
- --tw-text-opacity: 1;
686
- color: rgb(7 116 210 / var(--tw-text-opacity));
687
- text-decoration: underline;
688
- }
689
- .squiz-fte-scope .remirror-theme h1 {
690
- font-size: 1.625rem;
691
- font-weight: 600;
692
- letter-spacing: -0.2px;
693
- line-height: 2rem;
694
- }
695
- .squiz-fte-scope .remirror-theme h2 {
696
- font-size: 1.25rem;
697
- font-weight: 600;
698
- letter-spacing: -0.5px;
699
- line-height: 1.5rem;
700
- }
701
- .squiz-fte-scope .remirror-theme h3 {
702
- font-size: 1.125rem;
703
- font-weight: 600;
704
- letter-spacing: -0.2px;
705
- line-height: 1.375rem;
706
- }
707
- .squiz-fte-scope .remirror-theme h4 {
708
- font-size: 1rem;
709
- font-weight: 700;
710
- letter-spacing: -0.2px;
711
- line-height: 1.25rem;
712
- }
713
- .squiz-fte-scope .remirror-theme h5 {
714
- font-size: 1rem;
715
- font-weight: 600;
716
- letter-spacing: -0.2px;
717
- line-height: 1.25rem;
718
- }
719
- .squiz-fte-scope .remirror-theme h6 {
720
- font-size: 0.875rem;
721
- font-weight: 600;
722
- letter-spacing: -0.2px;
723
- line-height: 1.25rem;
734
+ .squiz-fte-scope .formatted-text-editor .ProseMirror-selectednode {
735
+ border-width: 2px;
736
+ border-style: solid;
737
+ --tw-border-opacity: 1;
738
+ border-color: rgb(7 116 210 / var(--tw-border-opacity));
724
739
  }
725
- .squiz-fte-scope .editor-toolbar {
740
+ .squiz-fte-scope .editor-toolbar,
741
+ .squiz-fte-scope__floating-popover {
726
742
  border-bottom-width: 2px;
727
743
  border-style: solid;
728
744
  --tw-border-opacity: 1;
@@ -733,10 +749,12 @@
733
749
  display: flex;
734
750
  justify-items: center;
735
751
  }
736
- .squiz-fte-scope .editor-toolbar > *:not(:first-child, .editor-divider) {
752
+ .squiz-fte-scope .editor-toolbar > *:not(:first-child, .editor-divider),
753
+ .squiz-fte-scope .squiz-fte-scope__floating-popover > *:not(:first-child, .editor-divider) {
737
754
  margin: 0 0 0 2px;
738
755
  }
739
- .squiz-fte-scope .editor-divider {
756
+ .squiz-fte-scope .editor-toolbar .editor-divider,
757
+ .squiz-fte-scope .squiz-fte-scope__floating-popover .editor-divider {
740
758
  margin-top: -0.25rem;
741
759
  margin-bottom: -0.25rem;
742
760
  margin-left: 0.25rem;
@@ -745,6 +763,14 @@
745
763
  margin-right: 2px;
746
764
  height: auto;
747
765
  }
766
+ .squiz-fte-scope .editor-toolbar .squiz-fte-btn,
767
+ .squiz-fte-scope .squiz-fte-scope__floating-popover .squiz-fte-btn {
768
+ padding: 0.25rem;
769
+ }
770
+ .squiz-fte-scope .editor-toolbar .squiz-fte-btn ~ .squiz-fte-btn,
771
+ .squiz-fte-scope .squiz-fte-scope__floating-popover .squiz-fte-btn ~ .squiz-fte-btn {
772
+ margin-left: 2px;
773
+ }
748
774
  .squiz-fte-scope__floating-popover {
749
775
  display: flex;
750
776
  border-radius: 6px;
@@ -761,22 +787,49 @@
761
787
  var(--tw-ring-shadow, 0 0 #0000),
762
788
  var(--tw-shadow);
763
789
  }
764
- .squiz-fte-scope .toolbar-button {
790
+ .squiz-fte-scope .squiz-fte-scope__floating-popover .editor-divider {
791
+ margin-top: 0px;
792
+ margin-bottom: 0px;
793
+ }
794
+ .squiz-fte-scope .squiz-fte-btn {
795
+ border-radius: 4px;
765
796
  --tw-bg-opacity: 1;
766
797
  background-color: rgb(255 255 255 / var(--tw-bg-opacity));
767
- padding: 0.25rem;
798
+ font-weight: 400;
768
799
  --tw-text-opacity: 1;
769
800
  color: rgb(112 112 112 / var(--tw-text-opacity));
801
+ transition-property: all;
802
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
803
+ transition-duration: 150ms;
804
+ transition-timing-function: linear;
805
+ display: flex;
806
+ align-items: center;
807
+ text-align: center;
808
+ white-space: nowrap;
809
+ vertical-align: middle;
810
+ touch-action: manipulation;
811
+ cursor: pointer;
812
+ background-image: none;
813
+ border: 1px solid transparent;
814
+ padding: 6px 12px;
770
815
  }
771
- .squiz-fte-scope .toolbar-button ~ .toolbar-button {
816
+ .squiz-fte-scope .squiz-fte-btn--is-icon {
817
+ padding: 6px;
818
+ }
819
+ .squiz-fte-scope .squiz-fte-btn ~ .squiz-fte-btn {
772
820
  margin-left: 2px;
773
821
  }
774
- .squiz-fte-scope .toolbar-button:hover,
775
- .squiz-fte-scope .toolbar-button:focus {
822
+ .squiz-fte-scope .squiz-fte-btn.disabled,
823
+ .squiz-fte-scope .squiz-fte-btn[disabled] {
824
+ cursor: not-allowed;
825
+ opacity: 0.5;
826
+ }
827
+ .squiz-fte-scope .squiz-fte-btn:hover,
828
+ .squiz-fte-scope .squiz-fte-btn:focus {
776
829
  background-color: rgba(0, 0, 0, 0.04);
777
830
  }
778
- .squiz-fte-scope .toolbar-button.is-active,
779
- .squiz-fte-scope .toolbar-button:active {
831
+ .squiz-fte-scope .squiz-fte-btn--is-active,
832
+ .squiz-fte-scope .squiz-fte-btn:active {
780
833
  --tw-bg-opacity: 1;
781
834
  background-color: rgb(230 241 250 / var(--tw-bg-opacity));
782
835
  --tw-text-opacity: 1;
@@ -785,6 +838,7 @@
785
838
  .squiz-fte-scope .toolbar-dropdown__button {
786
839
  display: flex;
787
840
  align-items: center;
841
+ border-radius: 4px;
788
842
  font-family:
789
843
  Open Sans,
790
844
  Arial,
@@ -899,8 +953,23 @@
899
953
  }
900
954
  .squiz-fte-scope .squiz-fte-modal-footer__button {
901
955
  font-size: 0.875rem;
956
+ font-weight: 700;
957
+ }
958
+ .squiz-fte-scope .editor-toolbar .squiz-fte-modal-footer__button,
959
+ .squiz-fte-scope .squiz-fte-scope__floating-popover .squiz-fte-modal-footer__button {
960
+ padding: 0.25rem;
961
+ }
962
+ .squiz-fte-scope .editor-toolbar .squiz-fte-modal-footer__button ~ .squiz-fte-btn,
963
+ .squiz-fte-scope .squiz-fte-scope__floating-popover .squiz-fte-modal-footer__button ~ .squiz-fte-btn {
964
+ margin-left: 2px;
965
+ }
966
+ .squiz-fte-scope .squiz-fte-modal-footer__button {
902
967
  border-radius: 4px;
968
+ --tw-bg-opacity: 1;
969
+ background-color: rgb(255 255 255 / var(--tw-bg-opacity));
903
970
  font-weight: 400;
971
+ --tw-text-opacity: 1;
972
+ color: rgb(112 112 112 / var(--tw-text-opacity));
904
973
  transition-property: all;
905
974
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
906
975
  transition-duration: 150ms;
@@ -916,11 +985,24 @@
916
985
  border: 1px solid transparent;
917
986
  padding: 6px 12px;
918
987
  }
988
+ .squiz-fte-scope .squiz-fte-modal-footer__button ~ .squiz-fte-btn {
989
+ margin-left: 2px;
990
+ }
919
991
  .squiz-fte-scope .squiz-fte-modal-footer__button.disabled,
920
992
  .squiz-fte-scope .squiz-fte-modal-footer__button[disabled] {
921
993
  cursor: not-allowed;
922
994
  opacity: 0.5;
923
995
  }
996
+ .squiz-fte-scope .squiz-fte-modal-footer__button:hover,
997
+ .squiz-fte-scope .squiz-fte-modal-footer__button:focus {
998
+ background-color: rgba(0, 0, 0, 0.04);
999
+ }
1000
+ .squiz-fte-scope .squiz-fte-modal-footer__button:active {
1001
+ --tw-bg-opacity: 1;
1002
+ background-color: rgb(230 241 250 / var(--tw-bg-opacity));
1003
+ --tw-text-opacity: 1;
1004
+ color: rgb(7 116 210 / var(--tw-text-opacity));
1005
+ }
924
1006
  .squiz-fte-scope .hover\:bg-blue-400:hover {
925
1007
  --tw-bg-opacity: 1 !important;
926
1008
  background-color: rgb(4 73 133 / var(--tw-bg-opacity)) !important;
package/lib/index.d.ts CHANGED
@@ -1,2 +1,5 @@
1
- import FormattedTextEditor from './FormattedTextEditor';
2
- export { FormattedTextEditor };
1
+ import Editor from './Editor/Editor';
2
+ import { EditorContext } from './Editor/EditorContext';
3
+ import { remirrorNodeToSquizNode } from './utils/converters/remirrorNodeToSquizNode/remirrorNodeToSquizNode';
4
+ import { squizNodeToRemirrorNode } from './utils/converters/squizNodeToRemirrorNode/squizNodeToRemirrorNode';
5
+ export { Editor, EditorContext, remirrorNodeToSquizNode, squizNodeToRemirrorNode };
package/lib/index.js CHANGED
@@ -3,6 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FormattedTextEditor = void 0;
7
- const FormattedTextEditor_1 = __importDefault(require("./FormattedTextEditor"));
8
- exports.FormattedTextEditor = FormattedTextEditor_1.default;
6
+ exports.squizNodeToRemirrorNode = exports.remirrorNodeToSquizNode = exports.EditorContext = exports.Editor = void 0;
7
+ const Editor_1 = __importDefault(require("./Editor/Editor"));
8
+ exports.Editor = Editor_1.default;
9
+ const EditorContext_1 = require("./Editor/EditorContext");
10
+ Object.defineProperty(exports, "EditorContext", { enumerable: true, get: function () { return EditorContext_1.EditorContext; } });
11
+ const remirrorNodeToSquizNode_1 = require("./utils/converters/remirrorNodeToSquizNode/remirrorNodeToSquizNode");
12
+ Object.defineProperty(exports, "remirrorNodeToSquizNode", { enumerable: true, get: function () { return remirrorNodeToSquizNode_1.remirrorNodeToSquizNode; } });
13
+ const squizNodeToRemirrorNode_1 = require("./utils/converters/squizNodeToRemirrorNode/squizNodeToRemirrorNode");
14
+ Object.defineProperty(exports, "squizNodeToRemirrorNode", { enumerable: true, get: function () { return squizNodeToRemirrorNode_1.squizNodeToRemirrorNode; } });
package/lib/types.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export type DeepPartial<T> = T extends Record<string, unknown> ? {
2
+ [P in keyof T]?: DeepPartial<T[P]>;
3
+ } : T;
package/lib/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ import { ReactElement } from 'react';
2
+ type ButtonProps = {
3
+ handleOnClick: () => void;
4
+ isDisabled?: boolean;
5
+ isActive: boolean;
6
+ label: string;
7
+ text?: string;
8
+ icon?: ReactElement;
9
+ };
10
+ declare const Button: ({ handleOnClick, isDisabled, isActive, label, text, icon }: ButtonProps) => JSX.Element;
11
+ export default Button;
@@ -4,7 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
- const ToolbarButton = ({ handleOnClick, isDisabled, isActive, icon, label }) => {
8
- return (react_1.default.createElement("button", { "aria-label": label, title: label, type: "button", onClick: handleOnClick, disabled: isDisabled, className: `squiz-fte-btn toolbar-button ${isActive ? 'is-active' : ''}` }, icon));
7
+ const clsx_1 = __importDefault(require("clsx"));
8
+ const Button = ({ handleOnClick, isDisabled, isActive, label, text, icon }) => {
9
+ return (react_1.default.createElement("button", { "aria-label": label, title: label, type: "button", onClick: handleOnClick, disabled: isDisabled, className: (0, clsx_1.default)('squiz-fte-btn', isActive && 'squiz-fte-btn--is-active', icon && ' squiz-fte-btn--is-icon') },
10
+ text && react_1.default.createElement("span", null, text),
11
+ icon && icon));
9
12
  };
10
- exports.default = ToolbarButton;
13
+ exports.default = Button;