@squiz/formatted-text-editor 1.12.0-alpha.40 → 1.12.0-alpha.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jest.config.ts +2 -0
- package/lib/EditorToolbar/EditorToolbar.js +3 -1
- package/lib/EditorToolbar/Tools/Link/Form/LinkForm.d.ts +3 -0
- package/lib/EditorToolbar/Tools/Link/Form/LinkForm.js +29 -0
- package/lib/EditorToolbar/Tools/Link/LinkButton.d.ts +7 -0
- package/lib/EditorToolbar/Tools/Link/LinkButton.js +8 -0
- package/lib/EditorToolbar/Tools/Link/Trigger/TriggerLinkModal.d.ts +3 -0
- package/lib/EditorToolbar/Tools/Link/Trigger/TriggerLinkModal.js +12 -0
- package/lib/index.css +401 -3744
- package/lib/ui/Inputs/Select/Select.d.ts +12 -0
- package/lib/ui/Inputs/Select/Select.js +19 -0
- package/lib/ui/Inputs/Text/TextInput.d.ts +8 -0
- package/lib/ui/Inputs/Text/TextInput.js +6 -0
- package/lib/ui/Modal/Modal.d.ts +9 -0
- package/lib/ui/Modal/Modal.js +30 -0
- package/lib/ui/ToolbarButton/ToolbarButton.js +1 -1
- package/package.json +10 -7
- package/src/Editor/_editor.scss +16 -9
- package/src/EditorToolbar/EditorToolbar.tsx +2 -0
- package/src/EditorToolbar/Tools/Bold/BoldButton.spec.tsx +1 -1
- package/src/EditorToolbar/Tools/Italic/ItalicButton.spec.tsx +1 -1
- package/src/EditorToolbar/Tools/Link/Form/LinkForm.spec.tsx +21 -0
- package/src/EditorToolbar/Tools/Link/Form/LinkForm.tsx +41 -0
- package/src/EditorToolbar/Tools/Link/LinkButton.spec.tsx +26 -0
- package/src/EditorToolbar/Tools/Link/LinkButton.tsx +25 -0
- package/src/EditorToolbar/Tools/Link/Trigger/TriggerLinkModal.spec.tsx +41 -0
- package/src/EditorToolbar/Tools/Link/Trigger/TriggerLinkModal.tsx +21 -0
- package/src/EditorToolbar/Tools/Underline/Underline.spec.tsx +1 -1
- package/src/EditorToolbar/_editor-toolbar.scss +1 -1
- package/src/index.scss +5 -2
- package/src/ui/DropdownButton/_dropdown-button.scss +3 -2
- package/src/ui/Inputs/Select/Select.spec.tsx +24 -0
- package/src/ui/Inputs/Select/Select.tsx +67 -0
- package/src/ui/Inputs/Text/TextInput.spec.tsx +43 -0
- package/src/ui/Inputs/Text/TextInput.tsx +20 -0
- package/src/ui/Modal/Modal.spec.tsx +75 -0
- package/src/ui/Modal/Modal.tsx +70 -0
- package/src/ui/Modal/_modal.scss +24 -0
- package/src/ui/ToolbarButton/ToolbarButton.tsx +1 -1
- package/src/ui/ToolbarButton/_toolbar-button.scss +5 -25
- package/src/ui/_buttons.scss +19 -0
- package/src/ui/_forms.scss +16 -0
- package/tailwind.config.cjs +23 -0
package/jest.config.ts
CHANGED
@@ -14,6 +14,8 @@ export default {
|
|
14
14
|
moduleNameMapper: {
|
15
15
|
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|css|scss)$':
|
16
16
|
'<rootDir>/file-transformer.js',
|
17
|
+
'^react($|/.+)': '<rootDir>/node_modules/react$1',
|
18
|
+
'^react-dom($|/.+)': '<rootDir>/node_modules/react-dom$1',
|
17
19
|
},
|
18
20
|
// TODO: enable once directory structure is sorted and we have tests/more complete code being written.
|
19
21
|
// coverageThreshold: {
|
@@ -7,6 +7,7 @@ import TextAlignButtons from './Tools/TextAlign/TextAlignButtons';
|
|
7
7
|
import UndoButton from './Tools/Undo/UndoButton';
|
8
8
|
import RedoButton from './Tools/Redo/RedoButton';
|
9
9
|
import TextTypeDropdown from './Tools/TextType/TextTypeDropdown';
|
10
|
+
import TriggerLinkModal from './Tools/Link/Trigger/TriggerLinkModal';
|
10
11
|
// The editor main toolbar
|
11
12
|
export const EditorToolbar = ({ manager, isPopover }) => {
|
12
13
|
const extensionNames = {};
|
@@ -22,7 +23,8 @@ export const EditorToolbar = ({ manager, isPopover }) => {
|
|
22
23
|
extensionNames.bold && React.createElement(BoldButton, null),
|
23
24
|
extensionNames.italic && React.createElement(ItalicButton, null),
|
24
25
|
extensionNames.underline && React.createElement(UnderlineButton, null),
|
25
|
-
extensionNames.nodeFormatting && React.createElement(TextAlignButtons, null)
|
26
|
+
extensionNames.nodeFormatting && React.createElement(TextAlignButtons, null),
|
27
|
+
React.createElement(TriggerLinkModal, null))) : (React.createElement(FloatingToolbar, { className: "remirror-floating-popover" },
|
26
28
|
extensionNames.bold && React.createElement(BoldButton, null),
|
27
29
|
extensionNames.italic && React.createElement(ItalicButton, null),
|
28
30
|
extensionNames.underline && React.createElement(UnderlineButton, null)))));
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import React, { useState } from 'react';
|
2
|
+
import { TextInput } from '../../../../ui/Inputs/Text/TextInput';
|
3
|
+
import { Select } from '../../../../ui/Inputs/Select/Select';
|
4
|
+
const selectOptions = [
|
5
|
+
{ id: 1, name: 'Current window', key: '_blank' },
|
6
|
+
{ id: 2, name: 'New window', key: '_parent' },
|
7
|
+
];
|
8
|
+
const LinkForm = () => {
|
9
|
+
const [formValues, setFormValues] = useState({
|
10
|
+
href: '',
|
11
|
+
target: selectOptions[0],
|
12
|
+
title: '',
|
13
|
+
text: '',
|
14
|
+
});
|
15
|
+
const handleChange = (event) => {
|
16
|
+
const { name, value } = event.target;
|
17
|
+
setFormValues({ ...formValues, [name]: value });
|
18
|
+
};
|
19
|
+
return (React.createElement("form", { action: "", method: "post", className: "sds-form" },
|
20
|
+
React.createElement("div", { className: "sds-form-group mb-2" },
|
21
|
+
React.createElement(TextInput, { id: "href", label: "URL", value: formValues.href, onChange: handleChange })),
|
22
|
+
React.createElement("div", { className: "sds-form-group mb-2" },
|
23
|
+
React.createElement(TextInput, { id: "text", label: "Text", value: formValues.text, onChange: handleChange })),
|
24
|
+
React.createElement("div", { className: "sds-form-group mb-2" },
|
25
|
+
React.createElement(TextInput, { id: "title", label: "Title", value: formValues.title, onChange: handleChange })),
|
26
|
+
React.createElement("div", { className: "sds-form-group mb-0" },
|
27
|
+
React.createElement(Select, { id: "target", label: "Target", value: formValues.target, options: selectOptions }))));
|
28
|
+
};
|
29
|
+
export default LinkForm;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import ToolbarButton from '../../../ui/ToolbarButton/ToolbarButton';
|
3
|
+
import InsertLinkRoundedIcon from '@mui/icons-material/InsertLinkRounded';
|
4
|
+
const LinkButton = ({ onClick, showModal, enabled }) => {
|
5
|
+
const active = showModal;
|
6
|
+
return (React.createElement(ToolbarButton, { handleOnClick: onClick, isDisabled: !enabled, isActive: active, icon: React.createElement(InsertLinkRoundedIcon, null), label: `Link` }));
|
7
|
+
};
|
8
|
+
export default LinkButton;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import React, { useState } from 'react';
|
2
|
+
import LinkButton from '../LinkButton';
|
3
|
+
import Modal from '../../../../ui/Modal/Modal';
|
4
|
+
import LinkForm from '../Form/LinkForm';
|
5
|
+
const TriggerLinkModal = () => {
|
6
|
+
const [showModal, setShowModal] = useState(false);
|
7
|
+
return (React.createElement(React.Fragment, null,
|
8
|
+
React.createElement(LinkButton, { showModal: showModal, onClick: () => setShowModal(true), enabled: true }),
|
9
|
+
showModal ? (React.createElement(Modal, { onCancel: () => setShowModal(false), onSubmit: () => console.log('Sumbmit form') },
|
10
|
+
React.createElement(LinkForm, null))) : null));
|
11
|
+
};
|
12
|
+
export default TriggerLinkModal;
|