@overlap/rte 0.1.2 → 0.1.4
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/package.json +57 -58
- package/src/components/Dropdown.tsx +0 -103
- package/src/components/Editor.css +0 -2
- package/src/components/Editor.tsx +0 -828
- package/src/components/FloatingToolbar.tsx +0 -214
- package/src/components/IconWrapper.tsx +0 -14
- package/src/components/Icons.tsx +0 -374
- package/src/components/Toolbar.tsx +0 -137
- package/src/components/index.ts +0 -3
- package/src/index.ts +0 -19
- package/src/plugins/base.tsx +0 -91
- package/src/plugins/blockFormat.tsx +0 -194
- package/src/plugins/clearFormatting.tsx +0 -31
- package/src/plugins/colors.tsx +0 -122
- package/src/plugins/fontSize.tsx +0 -81
- package/src/plugins/headings.tsx +0 -87
- package/src/plugins/image.tsx +0 -189
- package/src/plugins/index.tsx +0 -161
- package/src/plugins/listIndent.tsx +0 -90
- package/src/plugins/optional.tsx +0 -243
- package/src/styles.css +0 -638
- package/src/types.ts +0 -95
- package/src/utils/clearFormatting.ts +0 -244
- package/src/utils/content.ts +0 -290
- package/src/utils/history.ts +0 -59
- package/src/utils/listIndent.ts +0 -171
- package/src/utils/stateReflection.ts +0 -175
package/package.json
CHANGED
|
@@ -1,60 +1,59 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"homepage": "https://github.com/overlap-dev/rte#readme"
|
|
2
|
+
"name": "@overlap/rte",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "A lightweight, extensible Rich Text Editor for React",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "rollup -c",
|
|
14
|
+
"dev": "rollup -c -w",
|
|
15
|
+
"prepublishOnly": "npm run build",
|
|
16
|
+
"bump": "node tools/scripts/bumpVersion.mjs",
|
|
17
|
+
"publish:package": "node tools/scripts/publish.mjs"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"react",
|
|
21
|
+
"rich-text-editor",
|
|
22
|
+
"rte",
|
|
23
|
+
"contenteditable",
|
|
24
|
+
"editor"
|
|
25
|
+
],
|
|
26
|
+
"author": "Almir Nakicevic <a.nakicevic@overlap.at>",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/overlap-dev/rte.git"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"react": ">=18.0.0",
|
|
36
|
+
"react-dom": ">=18.0.0"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"tslib": "^2.8.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
43
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
44
|
+
"@rollup/plugin-typescript": "^11.1.5",
|
|
45
|
+
"@types/react": "^18.2.43",
|
|
46
|
+
"@types/react-dom": "^18.2.17",
|
|
47
|
+
"rollup": "^4.6.1",
|
|
48
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
49
|
+
"rollup-plugin-dts": "^6.1.0",
|
|
50
|
+
"typescript": "^5.3.3"
|
|
51
|
+
},
|
|
52
|
+
"directories": {
|
|
53
|
+
"example": "example"
|
|
54
|
+
},
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/overlap-dev/rte/issues"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://github.com/overlap-dev/rte#readme"
|
|
60
59
|
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
-
import { Icon } from './Icons';
|
|
3
|
-
|
|
4
|
-
interface DropdownProps {
|
|
5
|
-
icon: string;
|
|
6
|
-
label: string;
|
|
7
|
-
options: Array<{ value: string; label: string; icon?: string; color?: string; preview?: string; headingPreview?: string }>;
|
|
8
|
-
onSelect: (value: string) => void;
|
|
9
|
-
currentValue?: string;
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const Dropdown: React.FC<DropdownProps> = ({
|
|
14
|
-
icon,
|
|
15
|
-
label,
|
|
16
|
-
options,
|
|
17
|
-
onSelect,
|
|
18
|
-
currentValue,
|
|
19
|
-
disabled,
|
|
20
|
-
}) => {
|
|
21
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
22
|
-
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
23
|
-
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
const handleClickOutside = (event: MouseEvent) => {
|
|
26
|
-
if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {
|
|
27
|
-
setIsOpen(false);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
if (isOpen) {
|
|
32
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return () => {
|
|
36
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
37
|
-
};
|
|
38
|
-
}, [isOpen]);
|
|
39
|
-
|
|
40
|
-
const handleSelect = (value: string) => {
|
|
41
|
-
onSelect(value);
|
|
42
|
-
setIsOpen(false);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const currentOption = options.find(opt => opt.value === currentValue);
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<div className="rte-dropdown" ref={dropdownRef}>
|
|
49
|
-
<button
|
|
50
|
-
type="button"
|
|
51
|
-
onClick={() => !disabled && setIsOpen(!isOpen)}
|
|
52
|
-
disabled={disabled}
|
|
53
|
-
className={`rte-toolbar-button rte-dropdown-button ${currentOption ? 'rte-dropdown-button-has-value' : ''}`}
|
|
54
|
-
title={label}
|
|
55
|
-
aria-label={label}
|
|
56
|
-
>
|
|
57
|
-
<Icon icon={icon} width={18} height={18} />
|
|
58
|
-
{currentOption && (
|
|
59
|
-
<span className="rte-dropdown-value">{currentOption.label}</span>
|
|
60
|
-
)}
|
|
61
|
-
</button>
|
|
62
|
-
{isOpen && (
|
|
63
|
-
<div className="rte-dropdown-menu">
|
|
64
|
-
{options.map((option) => (
|
|
65
|
-
<button
|
|
66
|
-
key={option.value}
|
|
67
|
-
type="button"
|
|
68
|
-
className={`rte-dropdown-item ${currentValue === option.value ? 'rte-dropdown-item-active' : ''}`}
|
|
69
|
-
onClick={() => handleSelect(option.value)}
|
|
70
|
-
>
|
|
71
|
-
{option.color && (
|
|
72
|
-
<span
|
|
73
|
-
className={`rte-dropdown-color-preview ${currentValue === option.value ? 'active' : ''}`}
|
|
74
|
-
style={{ backgroundColor: option.color }}
|
|
75
|
-
/>
|
|
76
|
-
)}
|
|
77
|
-
{option.preview && !option.headingPreview && (
|
|
78
|
-
<span
|
|
79
|
-
className="rte-dropdown-fontsize-preview"
|
|
80
|
-
style={{ fontSize: `${option.preview}px` }}
|
|
81
|
-
>
|
|
82
|
-
Aa
|
|
83
|
-
</span>
|
|
84
|
-
)}
|
|
85
|
-
{option.headingPreview && (
|
|
86
|
-
<span
|
|
87
|
-
className={`rte-dropdown-heading-preview ${option.headingPreview}`}
|
|
88
|
-
>
|
|
89
|
-
{option.headingPreview === 'p' ? 'Normal' : option.headingPreview.toUpperCase()}
|
|
90
|
-
</span>
|
|
91
|
-
)}
|
|
92
|
-
{option.icon && <Icon icon={option.icon} width={16} height={16} />}
|
|
93
|
-
<span style={{ flex: 1, fontWeight: currentValue === option.value ? 600 : 400 }}>
|
|
94
|
-
{option.label}
|
|
95
|
-
</span>
|
|
96
|
-
</button>
|
|
97
|
-
))}
|
|
98
|
-
</div>
|
|
99
|
-
)}
|
|
100
|
-
</div>
|
|
101
|
-
);
|
|
102
|
-
};
|
|
103
|
-
|