@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 CHANGED
@@ -1,60 +1,59 @@
1
1
  {
2
- "name": "@overlap/rte",
3
- "version": "0.1.2",
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
- "src"
11
- ],
12
- "type": "module",
13
- "scripts": {
14
- "build": "rollup -c",
15
- "dev": "rollup -c -w",
16
- "prepublishOnly": "npm run build",
17
- "bump": "node tools/scripts/bumpVersion.mjs",
18
- "publish:package": "node tools/scripts/publish.mjs"
19
- },
20
- "keywords": [
21
- "react",
22
- "rich-text-editor",
23
- "rte",
24
- "contenteditable",
25
- "editor"
26
- ],
27
- "author": "Almir Nakicevic <a.nakicevic@overlap.at>",
28
- "repository": {
29
- "type": "git",
30
- "url": "git+https://github.com/overlap-dev/rte.git"
31
- },
32
- "publishConfig": {
33
- "access": "public"
34
- },
35
- "peerDependencies": {
36
- "react": ">=18.0.0",
37
- "react-dom": ">=18.0.0"
38
- },
39
- "dependencies": {
40
- "tslib": "^2.8.1"
41
- },
42
- "devDependencies": {
43
- "@rollup/plugin-commonjs": "^25.0.7",
44
- "@rollup/plugin-node-resolve": "^15.2.3",
45
- "@rollup/plugin-typescript": "^11.1.5",
46
- "@types/react": "^18.2.43",
47
- "@types/react-dom": "^18.2.17",
48
- "rollup": "^4.6.1",
49
- "rollup-plugin-copy": "^3.5.0",
50
- "rollup-plugin-dts": "^6.1.0",
51
- "typescript": "^5.3.3"
52
- },
53
- "directories": {
54
- "example": "example"
55
- },
56
- "bugs": {
57
- "url": "https://github.com/overlap-dev/rte/issues"
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
-
@@ -1,2 +0,0 @@
1
- @import '../styles.css';
2
-