@squiz/formatted-text-editor 1.12.0-alpha.9 → 1.12.1-alpha.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.
- package/.eslintrc.json +34 -0
- package/CHANGELOG.md +48 -0
- package/README.md +18 -56
- package/build.js +21 -0
- package/cypress/e2e/bold.spec.cy.ts +18 -0
- package/cypress/global.d.ts +9 -0
- package/cypress/support/commands.ts +130 -0
- package/cypress/support/e2e.ts +20 -0
- package/cypress/tsconfig.json +8 -0
- package/cypress.config.ts +7 -0
- package/demo/App.tsx +39 -0
- package/demo/index.html +13 -0
- package/demo/index.scss +40 -0
- package/demo/main.tsx +10 -0
- package/demo/public/favicon-dxp.svg +3 -0
- package/demo/vite-env.d.ts +1 -0
- package/file-transformer.js +1 -0
- package/jest.bootstrap.ts +3 -0
- package/jest.config.ts +30 -0
- package/lib/Editor/Editor.d.ts +4 -2
- package/lib/Editor/Editor.js +11 -14
- package/lib/EditorToolbar/FloatingToolbar.d.ts +1 -0
- package/lib/EditorToolbar/FloatingToolbar.js +31 -0
- package/lib/EditorToolbar/Toolbar.d.ts +1 -0
- package/lib/EditorToolbar/Toolbar.js +25 -0
- package/lib/EditorToolbar/Tools/Link/Form/LinkForm.d.ts +10 -0
- package/lib/EditorToolbar/Tools/Link/Form/LinkForm.js +23 -0
- package/lib/EditorToolbar/Tools/Link/LinkButton.d.ts +5 -0
- package/lib/EditorToolbar/Tools/Link/LinkButton.js +34 -0
- package/lib/EditorToolbar/Tools/Link/LinkModal.d.ts +8 -0
- package/lib/EditorToolbar/Tools/Link/LinkModal.js +14 -0
- package/lib/EditorToolbar/Tools/Link/RemoveLinkButton.d.ts +2 -0
- package/lib/EditorToolbar/Tools/Link/RemoveLinkButton.js +16 -0
- package/lib/EditorToolbar/Tools/Redo/RedoButton.d.ts +2 -0
- package/lib/EditorToolbar/Tools/Redo/RedoButton.js +16 -0
- package/lib/EditorToolbar/Tools/TextType/Heading/HeadingButton.d.ts +5 -0
- package/lib/EditorToolbar/Tools/TextType/Heading/HeadingButton.js +32 -0
- package/lib/EditorToolbar/Tools/TextType/Paragraph/ParagraphButton.d.ts +2 -0
- package/lib/EditorToolbar/Tools/TextType/Paragraph/ParagraphButton.js +16 -0
- package/lib/EditorToolbar/Tools/TextType/Preformatted/PreformattedButton.d.ts +2 -0
- package/lib/EditorToolbar/Tools/TextType/Preformatted/PreformattedButton.js +16 -0
- package/lib/EditorToolbar/Tools/TextType/TextTypeDropdown.d.ts +2 -0
- package/lib/EditorToolbar/Tools/TextType/TextTypeDropdown.js +35 -0
- package/lib/EditorToolbar/Tools/Undo/UndoButton.d.ts +2 -0
- package/lib/EditorToolbar/Tools/Undo/UndoButton.js +16 -0
- package/lib/EditorToolbar/index.d.ts +2 -0
- package/lib/EditorToolbar/index.js +2 -0
- package/lib/Extensions/Extensions.d.ts +4 -0
- package/lib/Extensions/Extensions.js +20 -0
- package/lib/Extensions/LinkExtension/LinkExtension.d.ts +16 -0
- package/lib/Extensions/LinkExtension/LinkExtension.js +91 -0
- package/lib/Extensions/PreformattedExtension/PreformattedExtension.d.ts +10 -0
- package/lib/Extensions/PreformattedExtension/PreformattedExtension.js +46 -0
- package/lib/FormattedTextEditor.d.ts +2 -2
- package/lib/FormattedTextEditor.js +1 -6
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/useExtensionNames.d.ts +1 -0
- package/lib/hooks/useExtensionNames.js +12 -0
- package/lib/index.css +786 -3689
- package/lib/ui/Inputs/Select/Select.d.ts +12 -0
- package/lib/ui/Inputs/Select/Select.js +23 -0
- package/lib/ui/Inputs/Text/TextInput.d.ts +4 -0
- package/lib/ui/Inputs/Text/TextInput.js +7 -0
- package/lib/ui/Modal/FormModal.d.ts +5 -0
- package/lib/ui/Modal/FormModal.js +11 -0
- package/lib/ui/Modal/Modal.d.ts +10 -0
- package/lib/ui/Modal/Modal.js +48 -0
- package/lib/ui/ToolbarButton/ToolbarButton.d.ts +1 -1
- package/lib/ui/ToolbarButton/ToolbarButton.js +1 -1
- package/lib/ui/ToolbarDropdown/ToolbarDropdown.d.ts +6 -0
- package/lib/ui/ToolbarDropdown/ToolbarDropdown.js +20 -0
- package/lib/ui/ToolbarDropdownButton/ToolbarDropdownButton.d.ts +9 -0
- package/lib/ui/ToolbarDropdownButton/ToolbarDropdownButton.js +8 -0
- package/lib/utils/createToolbarPositioner.d.ts +18 -0
- package/lib/utils/createToolbarPositioner.js +81 -0
- package/lib/utils/getCursorRect.d.ts +2 -0
- package/lib/utils/getCursorRect.js +3 -0
- package/package.json +22 -13
- package/postcss.config.js +12 -0
- package/src/Editor/Editor.mock.tsx +43 -0
- package/src/Editor/Editor.spec.tsx +254 -0
- package/src/Editor/Editor.tsx +46 -0
- package/src/Editor/_editor.scss +82 -0
- package/src/EditorToolbar/FloatingToolbar.spec.tsx +30 -0
- package/src/EditorToolbar/FloatingToolbar.tsx +40 -0
- package/src/EditorToolbar/Toolbar.tsx +33 -0
- package/src/EditorToolbar/Tools/Bold/BoldButton.spec.tsx +19 -0
- package/src/EditorToolbar/Tools/Bold/BoldButton.tsx +30 -0
- package/src/EditorToolbar/Tools/Italic/ItalicButton.spec.tsx +19 -0
- package/src/EditorToolbar/Tools/Italic/ItalicButton.tsx +30 -0
- package/src/EditorToolbar/Tools/Link/Form/LinkForm.spec.tsx +30 -0
- package/src/EditorToolbar/Tools/Link/Form/LinkForm.tsx +48 -0
- package/src/EditorToolbar/Tools/Link/LinkButton.spec.tsx +277 -0
- package/src/EditorToolbar/Tools/Link/LinkButton.tsx +56 -0
- package/src/EditorToolbar/Tools/Link/LinkModal.tsx +29 -0
- package/src/EditorToolbar/Tools/Link/RemoveLinkButton.spec.tsx +46 -0
- package/src/EditorToolbar/Tools/Link/RemoveLinkButton.tsx +27 -0
- package/src/EditorToolbar/Tools/Redo/RedoButton.spec.tsx +59 -0
- package/src/EditorToolbar/Tools/Redo/RedoButton.tsx +30 -0
- package/src/EditorToolbar/Tools/TextAlign/CenterAlign/CenterAlignButton.spec.tsx +39 -0
- package/src/EditorToolbar/Tools/TextAlign/CenterAlign/CenterAlignButton.tsx +31 -0
- package/src/EditorToolbar/Tools/TextAlign/JustifyAlign/JustifyAlignButton.spec.tsx +39 -0
- package/src/EditorToolbar/Tools/TextAlign/JustifyAlign/JustifyAlignButton.tsx +31 -0
- package/src/EditorToolbar/Tools/TextAlign/LeftAlign/LeftAlignButton.spec.tsx +39 -0
- package/src/EditorToolbar/Tools/TextAlign/LeftAlign/LeftAlignButton.tsx +31 -0
- package/src/EditorToolbar/Tools/TextAlign/RightAlign/RightAlignButton.spec.tsx +39 -0
- package/src/EditorToolbar/Tools/TextAlign/RightAlign/RightAlignButton.tsx +31 -0
- package/src/EditorToolbar/Tools/TextAlign/TextAlignButtons.tsx +21 -0
- package/src/EditorToolbar/Tools/TextType/Heading/HeadingButton.spec.tsx +56 -0
- package/src/EditorToolbar/Tools/TextType/Heading/HeadingButton.tsx +52 -0
- package/src/EditorToolbar/Tools/TextType/Paragraph/ParagraphButton.spec.tsx +30 -0
- package/src/EditorToolbar/Tools/TextType/Paragraph/ParagraphButton.tsx +25 -0
- package/src/EditorToolbar/Tools/TextType/Preformatted/PreformattedButton.spec.tsx +47 -0
- package/src/EditorToolbar/Tools/TextType/Preformatted/PreformattedButton.tsx +30 -0
- package/src/EditorToolbar/Tools/TextType/TextTypeDropdown.spec.tsx +51 -0
- package/src/EditorToolbar/Tools/TextType/TextTypeDropdown.tsx +44 -0
- package/src/EditorToolbar/Tools/Underline/Underline.spec.tsx +19 -0
- package/src/EditorToolbar/Tools/Underline/UnderlineButton.tsx +30 -0
- package/src/EditorToolbar/Tools/Undo/UndoButton.spec.tsx +49 -0
- package/src/EditorToolbar/Tools/Undo/UndoButton.tsx +30 -0
- package/src/EditorToolbar/_floating-toolbar.scss +4 -0
- package/src/EditorToolbar/_toolbar.scss +16 -0
- package/src/EditorToolbar/index.ts +2 -0
- package/src/Extensions/Extensions.ts +29 -0
- package/src/Extensions/LinkExtension/LinkExtension.ts +116 -0
- package/src/Extensions/PreformattedExtension/PreformattedExtension.ts +50 -0
- package/src/FormattedTextEditor.spec.tsx +10 -0
- package/src/FormattedTextEditor.tsx +3 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useExtensionNames.ts +15 -0
- package/src/index.scss +19 -0
- package/src/index.ts +3 -0
- package/src/ui/Inputs/Select/Select.spec.tsx +30 -0
- package/src/ui/Inputs/Select/Select.tsx +66 -0
- package/src/ui/Inputs/Text/TextInput.spec.tsx +43 -0
- package/src/ui/Inputs/Text/TextInput.tsx +20 -0
- package/src/ui/Modal/FormModal.spec.tsx +20 -0
- package/src/ui/Modal/FormModal.tsx +17 -0
- package/src/ui/Modal/Modal.spec.tsx +113 -0
- package/src/ui/Modal/Modal.tsx +97 -0
- package/src/ui/Modal/_modal.scss +24 -0
- package/src/ui/ToolbarButton/ToolbarButton.tsx +26 -0
- package/src/ui/ToolbarButton/_toolbar-button.scss +17 -0
- package/src/ui/ToolbarDropdown/ToolbarDropdown.spec.tsx +78 -0
- package/src/ui/ToolbarDropdown/ToolbarDropdown.tsx +42 -0
- package/src/ui/ToolbarDropdown/_toolbar-dropdown.scss +32 -0
- package/src/ui/ToolbarDropdownButton/ToolbarDropdownButton.spec.tsx +48 -0
- package/src/ui/ToolbarDropdownButton/ToolbarDropdownButton.tsx +29 -0
- package/src/ui/ToolbarDropdownButton/_toolbar-dropdown-button.scss +14 -0
- package/src/ui/_buttons.scss +19 -0
- package/src/ui/_forms.scss +16 -0
- package/src/utils/createToolbarPositioner.ts +115 -0
- package/src/utils/getCursorRect.ts +5 -0
- package/tailwind.config.cjs +83 -0
- package/tests/index.ts +2 -0
- package/tests/renderWithEditor.tsx +110 -0
- package/tests/select.tsx +16 -0
- package/tsconfig.json +22 -0
- package/vite.config.ts +19 -0
- package/lib/EditorToolbar/EditorToolbar.d.ts +0 -7
- package/lib/EditorToolbar/EditorToolbar.js +0 -21
package/tests/select.tsx
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
import { fireEvent } from '@testing-library/react';
|
2
|
+
|
3
|
+
export const select = (element: Element, optionText: string) => {
|
4
|
+
fireEvent.click(element);
|
5
|
+
|
6
|
+
const menuItems = element.parentElement ? Array.from(element.parentElement.querySelectorAll('li')) : [];
|
7
|
+
const itemToSelect = Array.from(menuItems).find((item) => item.textContent === optionText);
|
8
|
+
|
9
|
+
if (menuItems.length === 0) {
|
10
|
+
throw new Error('Cannot find menu items for select field.');
|
11
|
+
} else if (!itemToSelect) {
|
12
|
+
throw new Error(`Cannot find option with text ${optionText} in select field.`);
|
13
|
+
}
|
14
|
+
|
15
|
+
fireEvent.click(itemToSelect);
|
16
|
+
};
|
package/tsconfig.json
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "ESNext",
|
4
|
+
"useDefineForClassFields": true,
|
5
|
+
"experimentalDecorators": true,
|
6
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
7
|
+
"allowJs": false,
|
8
|
+
"skipLibCheck": true,
|
9
|
+
"esModuleInterop": true,
|
10
|
+
"allowSyntheticDefaultImports": true,
|
11
|
+
"strict": true,
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
13
|
+
"module": "ESNext",
|
14
|
+
"moduleResolution": "Node",
|
15
|
+
"resolveJsonModule": true,
|
16
|
+
"isolatedModules": true,
|
17
|
+
"jsx": "react",
|
18
|
+
"declaration": true,
|
19
|
+
"outDir": "./lib"
|
20
|
+
},
|
21
|
+
"files": ["src/index.ts"]
|
22
|
+
}
|
package/vite.config.ts
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
import { defineConfig } from 'vite';
|
2
|
+
import react from '@vitejs/plugin-react';
|
3
|
+
|
4
|
+
// https://vitejs.dev/config/
|
5
|
+
export default defineConfig({
|
6
|
+
root: 'demo',
|
7
|
+
build: {
|
8
|
+
outDir: 'build/demo',
|
9
|
+
},
|
10
|
+
plugins: [
|
11
|
+
react({
|
12
|
+
babel: {
|
13
|
+
parserOpts: {
|
14
|
+
plugins: ['decorators-legacy'],
|
15
|
+
},
|
16
|
+
},
|
17
|
+
}),
|
18
|
+
],
|
19
|
+
});
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { Toolbar, FloatingToolbar } from '@remirror/react-components';
|
3
|
-
import ItalicButton from './Tools/Italic/ItalicButton';
|
4
|
-
import UnderlineButton from './Tools/Underline/UnderlineButton';
|
5
|
-
import BoldButton from './Tools/Bold/BoldButton';
|
6
|
-
import TextAlignButtons from './Tools/TextAlign/TextAlignButtons';
|
7
|
-
// The editor main toolbar
|
8
|
-
export const EditorToolbar = ({ manager, isPopover }) => {
|
9
|
-
const extensionNames = {};
|
10
|
-
manager.extensions.forEach((extension) => {
|
11
|
-
extensionNames[extension.name] = true;
|
12
|
-
});
|
13
|
-
return (React.createElement(React.Fragment, null, !isPopover ? (React.createElement(Toolbar, { className: "remirror-toolbar editor-toolbar" },
|
14
|
-
extensionNames.bold && React.createElement(BoldButton, null),
|
15
|
-
extensionNames.italic && React.createElement(ItalicButton, null),
|
16
|
-
extensionNames.underline && React.createElement(UnderlineButton, null),
|
17
|
-
extensionNames.nodeFormatting && React.createElement(TextAlignButtons, null))) : (React.createElement(FloatingToolbar, { className: "remirror-floating-popover" },
|
18
|
-
extensionNames.bold && React.createElement(BoldButton, null),
|
19
|
-
extensionNames.italic && React.createElement(ItalicButton, null),
|
20
|
-
extensionNames.underline && React.createElement(UnderlineButton, null)))));
|
21
|
-
};
|