@squiz/formatted-text-editor 1.12.0-alpha.40 → 1.12.0-alpha.9
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/README.md +56 -18
- package/lib/Editor/Editor.js +9 -3
- package/lib/EditorToolbar/EditorToolbar.js +1 -9
- package/lib/index.css +94 -800
- package/package.json +8 -12
- package/.eslintrc.json +0 -34
- package/CHANGELOG.md +0 -48
- package/build.js +0 -21
- package/cypress/e2e/bold.spec.cy.ts +0 -18
- package/cypress/global.d.ts +0 -9
- package/cypress/support/commands.ts +0 -130
- package/cypress/support/e2e.ts +0 -20
- package/cypress/tsconfig.json +0 -8
- package/cypress.config.ts +0 -7
- package/demo/App.tsx +0 -12
- package/demo/index.html +0 -13
- package/demo/index.scss +0 -1
- package/demo/main.tsx +0 -10
- package/demo/public/favicon-dxp.svg +0 -3
- package/demo/vite-env.d.ts +0 -1
- package/file-transformer.js +0 -1
- package/jest.config.ts +0 -27
- package/lib/EditorToolbar/Tools/Redo/RedoButton.d.ts +0 -2
- package/lib/EditorToolbar/Tools/Redo/RedoButton.js +0 -16
- package/lib/EditorToolbar/Tools/TextType/Heading/HeadingButton.d.ts +0 -5
- package/lib/EditorToolbar/Tools/TextType/Heading/HeadingButton.js +0 -32
- package/lib/EditorToolbar/Tools/TextType/Paragraph/ParagraphButton.d.ts +0 -2
- package/lib/EditorToolbar/Tools/TextType/Paragraph/ParagraphButton.js +0 -17
- package/lib/EditorToolbar/Tools/TextType/Preformatted/PreformattedButton.d.ts +0 -2
- package/lib/EditorToolbar/Tools/TextType/Preformatted/PreformattedButton.js +0 -16
- package/lib/EditorToolbar/Tools/TextType/TextTypeDropdown.d.ts +0 -2
- package/lib/EditorToolbar/Tools/TextType/TextTypeDropdown.js +0 -35
- package/lib/EditorToolbar/Tools/Undo/UndoButton.d.ts +0 -2
- package/lib/EditorToolbar/Tools/Undo/UndoButton.js +0 -16
- package/lib/Extensions/Extensions.d.ts +0 -3
- package/lib/Extensions/Extensions.js +0 -13
- package/lib/Extensions/PreformattedExtension/PreformattedExtension.d.ts +0 -10
- package/lib/Extensions/PreformattedExtension/PreformattedExtension.js +0 -46
- package/lib/ui/DropdownButton/DropdownButton.d.ts +0 -9
- package/lib/ui/DropdownButton/DropdownButton.js +0 -8
- package/lib/ui/ToolbarDropdown/ToolbarDropdown.d.ts +0 -7
- package/lib/ui/ToolbarDropdown/ToolbarDropdown.js +0 -12
- package/postcss.config.js +0 -3
- package/src/Editor/Editor.mock.tsx +0 -40
- package/src/Editor/Editor.spec.tsx +0 -254
- package/src/Editor/Editor.tsx +0 -32
- package/src/Editor/_editor.scss +0 -75
- package/src/EditorToolbar/EditorToolbar.tsx +0 -51
- package/src/EditorToolbar/Tools/Bold/BoldButton.spec.tsx +0 -19
- package/src/EditorToolbar/Tools/Bold/BoldButton.tsx +0 -30
- package/src/EditorToolbar/Tools/Italic/ItalicButton.spec.tsx +0 -19
- package/src/EditorToolbar/Tools/Italic/ItalicButton.tsx +0 -30
- package/src/EditorToolbar/Tools/Redo/RedoButton.spec.tsx +0 -59
- package/src/EditorToolbar/Tools/Redo/RedoButton.tsx +0 -30
- package/src/EditorToolbar/Tools/TextAlign/CenterAlign/CenterAlignButton.tsx +0 -31
- package/src/EditorToolbar/Tools/TextAlign/JustifyAlign/JustifyAlignButton.tsx +0 -31
- package/src/EditorToolbar/Tools/TextAlign/LeftAlign/LeftAlignButton.tsx +0 -31
- package/src/EditorToolbar/Tools/TextAlign/RightAlign/RightAlignButton.tsx +0 -31
- package/src/EditorToolbar/Tools/TextAlign/TextAlignButtons.tsx +0 -21
- package/src/EditorToolbar/Tools/TextType/Heading/HeadingButton.tsx +0 -52
- package/src/EditorToolbar/Tools/TextType/Paragraph/ParagraphButton.tsx +0 -26
- package/src/EditorToolbar/Tools/TextType/Preformatted/PreformattedButton.tsx +0 -30
- package/src/EditorToolbar/Tools/TextType/TextTypeDropdown.tsx +0 -44
- package/src/EditorToolbar/Tools/Underline/Underline.spec.tsx +0 -19
- package/src/EditorToolbar/Tools/Underline/UnderlineButton.tsx +0 -30
- package/src/EditorToolbar/Tools/Undo/UndoButton.spec.tsx +0 -49
- package/src/EditorToolbar/Tools/Undo/UndoButton.tsx +0 -30
- package/src/EditorToolbar/_editor-toolbar.scss +0 -19
- package/src/Extensions/Extensions.tsx +0 -24
- package/src/Extensions/PreformattedExtension/PreformattedExtension.tsx +0 -50
- package/src/FormattedTextEditor.spec.tsx +0 -10
- package/src/FormattedTextEditor.tsx +0 -12
- package/src/index.scss +0 -15
- package/src/index.ts +0 -3
- package/src/ui/DropdownButton/DropdownButton.tsx +0 -28
- package/src/ui/DropdownButton/_dropdown-button.scss +0 -7
- package/src/ui/ToolbarButton/ToolbarButton.tsx +0 -26
- package/src/ui/ToolbarButton/_toolbar-button.scss +0 -37
- package/src/ui/ToolbarDropdown/ToolbarDropdown.tsx +0 -32
- package/src/ui/ToolbarDropdown/_toolbar-dropdown.scss +0 -27
- package/tailwind.config.cjs +0 -62
- package/tsconfig.json +0 -22
- package/vite.config.ts +0 -19
package/README.md
CHANGED
@@ -1,39 +1,44 @@
|
|
1
1
|
# DXP Formatted text editor component
|
2
2
|
|
3
|
-
|
3
|
+
The Squiz DXP formatted text editor, built using [Remirror](https://remirror.io/) React library.
|
4
4
|
|
5
|
-
|
5
|
+
It is intended that this package is used for implementing rich text editor capabilities using the DXP Content Store.
|
6
|
+
|
7
|
+
## Tools and requirements
|
8
|
+
|
9
|
+
Tools that relate to standards, publishing and code base health should be available from the monorepo root. Package specific tools and requirements will be listed below.
|
6
10
|
|
7
11
|
### Requirements
|
8
12
|
|
9
|
-
|
10
|
-
- [Node/NPM](https://nodejs.org/en/)
|
13
|
+
There are no tools that you need locally that are specific to this repo. Please refer to the monorepo README for more information.
|
11
14
|
|
12
|
-
###
|
15
|
+
### Optional tools
|
13
16
|
|
14
|
-
Provided you have `Volta` installed as soon as you are in the `formatted-text-editor` directory you should be on the correct Node version.
|
15
|
-
See the `package.json` for the specific version.
|
17
|
+
- [Volta](https://volta.sh/): Provided you have `Volta` installed as soon as you are in the `formatted-text-editor` directory you should be on the correct Node version.
|
16
18
|
|
17
|
-
|
19
|
+
## Working locally
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
### Installation
|
22
|
+
|
23
|
+
Please refer to the monorepo README for getting up and running.
|
24
|
+
|
25
|
+
### Local development
|
26
|
+
|
27
|
+
You can preview the formatted text editor in your local environment by running the following command from the `packages/formatted-text-editor` directory:
|
22
28
|
|
23
29
|
```sh
|
24
30
|
npm run dev
|
25
31
|
```
|
32
|
+
|
26
33
|
This will expose `http://localhost:5173/` and this can be viewed in the browser.
|
27
34
|
|
28
35
|
> TIP: Make sure you have already installed the node modules at the root level of the repo.
|
29
36
|
|
30
|
-
|
31
|
-
|
32
|
-
## Testing
|
37
|
+
### Testing
|
33
38
|
|
34
39
|
Tests must be written when contributing to this package. Tests are automatically run in CI and test failure will result in unmerged code.
|
35
40
|
|
36
|
-
|
41
|
+
#### Unit testing
|
37
42
|
|
38
43
|
This package using Jest to perform Unit testing. In addition to Jest we are using a few Testing Library utilities:
|
39
44
|
|
@@ -51,9 +56,7 @@ Or if you'd like to "watch" for changes:
|
|
51
56
|
npm run test:watch
|
52
57
|
```
|
53
58
|
|
54
|
-
|
55
|
-
|
56
|
-
### End to end testing
|
59
|
+
#### End to end testing
|
57
60
|
|
58
61
|
This package uses [Cypress](https://docs.cypress.io/) for end to end testing.
|
59
62
|
|
@@ -62,3 +65,38 @@ To run tests locally you can run:
|
|
62
65
|
npm run test:e2e
|
63
66
|
```
|
64
67
|
Cypress is configured to look at a preview dev environment on `http://localhost:8080`.
|
68
|
+
|
69
|
+
|
70
|
+
## Publishing
|
71
|
+
|
72
|
+
This package will be automatically compiled and published following the process defined by the monorepo. Please see the README at the root of the monorepo for more details.
|
73
|
+
|
74
|
+
We may manually publish this repo following these steps (please note that you should only ever do this from the `develop` branch):
|
75
|
+
|
76
|
+
1. Run a clean, CI install, compile and publish from the root directory
|
77
|
+
|
78
|
+
```
|
79
|
+
npm run clean:all
|
80
|
+
npm ci
|
81
|
+
npm run compile
|
82
|
+
npx lerna publish -y --conventional-commits --ci --exact --conventional-prerelease
|
83
|
+
```
|
84
|
+
|
85
|
+
2. Move into the editor directory and check that the lib directory looks correct for publishing
|
86
|
+
|
87
|
+
```
|
88
|
+
cd packages/formatted-text-editor
|
89
|
+
ls -la packages/formatted-text-editor/lib
|
90
|
+
```
|
91
|
+
|
92
|
+
3. Execute the NPM publishing command from the package. Watch for any errors in the console
|
93
|
+
|
94
|
+
```
|
95
|
+
npm publish
|
96
|
+
```
|
97
|
+
|
98
|
+
4. Check that the package was published and pushed to NPM
|
99
|
+
|
100
|
+
```
|
101
|
+
npm view @squiz/formatted-text-editor
|
102
|
+
```
|
package/lib/Editor/Editor.js
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import { BoldExtension, ItalicExtension, NodeFormattingExtension, UnderlineExtension, wysiwygPreset, } from 'remirror/extensions';
|
2
3
|
import { EditorComponent, Remirror, useRemirror } from '@remirror/react';
|
3
4
|
import { EditorToolbar } from '../EditorToolbar/EditorToolbar';
|
4
|
-
import { Extensions } from '../Extensions/Extensions';
|
5
5
|
const Editor = ({ content }) => {
|
6
6
|
const { manager, state, setState } = useRemirror({
|
7
|
-
extensions:
|
7
|
+
extensions: () => [
|
8
|
+
...wysiwygPreset(),
|
9
|
+
new BoldExtension(),
|
10
|
+
new ItalicExtension(),
|
11
|
+
new NodeFormattingExtension(),
|
12
|
+
new UnderlineExtension(),
|
13
|
+
],
|
8
14
|
content,
|
9
15
|
selection: 'start',
|
10
16
|
stringHandler: 'html',
|
@@ -12,7 +18,7 @@ const Editor = ({ content }) => {
|
|
12
18
|
const handleChange = (parameter) => {
|
13
19
|
setState(parameter.state);
|
14
20
|
};
|
15
|
-
return (React.createElement(Remirror, { manager: manager, state: state, onChange: handleChange, placeholder: "Write something"
|
21
|
+
return (React.createElement(Remirror, { manager: manager, state: state, onChange: handleChange, placeholder: "Write something" },
|
16
22
|
React.createElement(EditorToolbar, { manager: manager }),
|
17
23
|
React.createElement(EditorComponent, null),
|
18
24
|
React.createElement(EditorToolbar, { manager: manager, isPopover: true })));
|
@@ -1,12 +1,9 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { Toolbar, FloatingToolbar
|
2
|
+
import { Toolbar, FloatingToolbar } from '@remirror/react-components';
|
3
3
|
import ItalicButton from './Tools/Italic/ItalicButton';
|
4
4
|
import UnderlineButton from './Tools/Underline/UnderlineButton';
|
5
5
|
import BoldButton from './Tools/Bold/BoldButton';
|
6
6
|
import TextAlignButtons from './Tools/TextAlign/TextAlignButtons';
|
7
|
-
import UndoButton from './Tools/Undo/UndoButton';
|
8
|
-
import RedoButton from './Tools/Redo/RedoButton';
|
9
|
-
import TextTypeDropdown from './Tools/TextType/TextTypeDropdown';
|
10
7
|
// The editor main toolbar
|
11
8
|
export const EditorToolbar = ({ manager, isPopover }) => {
|
12
9
|
const extensionNames = {};
|
@@ -14,11 +11,6 @@ export const EditorToolbar = ({ manager, isPopover }) => {
|
|
14
11
|
extensionNames[extension.name] = true;
|
15
12
|
});
|
16
13
|
return (React.createElement(React.Fragment, null, !isPopover ? (React.createElement(Toolbar, { className: "remirror-toolbar editor-toolbar" },
|
17
|
-
extensionNames.history && (React.createElement(React.Fragment, null,
|
18
|
-
React.createElement(UndoButton, null),
|
19
|
-
React.createElement(RedoButton, null),
|
20
|
-
React.createElement(VerticalDivider, { className: "editor-divider" }))),
|
21
|
-
extensionNames.heading && extensionNames.paragraph && extensionNames.preformatted && React.createElement(TextTypeDropdown, null),
|
22
14
|
extensionNames.bold && React.createElement(BoldButton, null),
|
23
15
|
extensionNames.italic && React.createElement(ItalicButton, null),
|
24
16
|
extensionNames.underline && React.createElement(UnderlineButton, null),
|