@innoviatech/lexical-text-editor 0.0.4 → 0.0.6

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.
@@ -1,3 +1,4 @@
1
+ import { ImageComponent } from "../components/ImageComponent";
1
2
  import {
2
3
  DecoratorNode,
3
4
  type DOMConversionMap,
@@ -7,7 +8,6 @@ import {
7
8
  $applyNodeReplacement,
8
9
  } from "lexical";
9
10
  import type { JSX } from "react";
10
- import { ImageComponent } from "../components/ImageComponent";
11
11
 
12
12
  export interface SerializedImageNode {
13
13
  type: "image";
@@ -157,154 +157,3 @@ export class ImageNode extends DecoratorNode<JSX.Element> {
157
157
  }
158
158
 
159
159
 
160
-
161
-
162
-
163
-
164
- // import {
165
- // DecoratorNode,
166
- // type DOMConversionMap,
167
- // type DOMConversionOutput,
168
- // type DOMExportOutput,
169
- // type NodeKey,
170
- // } from "lexical";
171
- // import type { JSX } from "react";
172
-
173
- // export interface SerializedImageNode {
174
- // type: "image";
175
- // version: 1;
176
- // src: string;
177
- // altText: string;
178
- // maxWidth: number;
179
- // width?: number | "inherit";
180
- // height?: number | "inherit";
181
- // }
182
-
183
- // export const $createImageNode = ({
184
- // altText,
185
- // height,
186
- // maxWidth = 400,
187
- // width,
188
- // src,
189
- // }: {
190
- // altText: string;
191
- // height?: number;
192
- // maxWidth?: number;
193
- // src: string;
194
- // width?: number;
195
- // }) => {
196
- // return new ImageNode({ altText, height, maxWidth, src, width });
197
- // };
198
-
199
- // const convertImageElement = (domNode: Node): DOMConversionOutput | null => {
200
- // if (domNode instanceof HTMLImageElement) {
201
- // const { src, alt } = domNode;
202
- // const node = $createImageNode({ src, altText: alt });
203
- // return { node };
204
- // }
205
- // return null;
206
- // };
207
-
208
- // export class ImageNode extends DecoratorNode<JSX.Element> {
209
- // __src: string;
210
- // __altText: string;
211
- // __height?: "inherit" | number;
212
- // __width?: "inherit" | number;
213
- // __maxWidth: number;
214
-
215
- // constructor({
216
- // src = "",
217
- // altText = "",
218
- // maxWidth = 400,
219
- // width,
220
- // height,
221
- // key,
222
- // }: {
223
- // src?: string;
224
- // altText?: string;
225
- // maxWidth?: number;
226
- // width?: "inherit" | number;
227
- // height?: "inherit" | number;
228
- // key?: NodeKey;
229
- // } = {}) {
230
- // super(key);
231
- // this.__altText = altText;
232
- // this.__src = src;
233
- // this.__maxWidth = maxWidth;
234
- // this.__height = height;
235
- // this.__width = width;
236
- // }
237
-
238
- // static getType(): string {
239
- // return "image";
240
- // }
241
-
242
- // static clone(node: ImageNode): ImageNode {
243
- // return new ImageNode({
244
- // altText: node.__altText,
245
- // src: node.__src,
246
- // height: node.__height,
247
- // width: node.__width,
248
- // maxWidth: node.__maxWidth,
249
- // key: node.getKey(),
250
- // });
251
- // }
252
-
253
- // decorate(): JSX.Element {
254
- // return (
255
- // <img
256
- // src={this.__src}
257
- // alt={this.__altText}
258
- // style={{
259
- // width: this.__width,
260
- // height: this.__height,
261
- // maxWidth: this.__maxWidth,
262
- // }}
263
- // />
264
- // );
265
- // }
266
-
267
- // createDOM(): HTMLElement {
268
- // const span = document.createElement("span");
269
- // return span;
270
- // }
271
-
272
- // exportDOM(): DOMExportOutput {
273
- // const image = document.createElement("img");
274
- // image.setAttribute("src", this.__src);
275
- // image.setAttribute("alt", this.__altText);
276
- // return { element: image };
277
- // }
278
-
279
- // static importDOM(): DOMConversionMap | null {
280
- // return {
281
- // img: () => {
282
- // return { conversion: convertImageElement, priority: 0 };
283
- // },
284
- // };
285
- // }
286
-
287
- // /** New: export to JSON */
288
- // exportJSON(): SerializedImageNode {
289
- // return {
290
- // type: "image",
291
- // version: 1,
292
- // src: this.__src,
293
- // altText: this.__altText,
294
- // maxWidth: this.__maxWidth,
295
- // width: this.__width,
296
- // height: this.__height,
297
- // };
298
- // }
299
-
300
- // /** New: import from JSON */
301
- // static importJSON(serializedNode: SerializedImageNode): ImageNode {
302
- // return new ImageNode({
303
- // src: serializedNode.src,
304
- // altText: serializedNode.altText,
305
- // maxWidth: serializedNode.maxWidth,
306
- // width: serializedNode.width,
307
- // height: serializedNode.height,
308
- // });
309
- // }
310
- // }
@@ -1,4 +1,3 @@
1
- "use client";
2
1
 
3
2
  import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
4
3
  import { $insertNodes } from "lexical";
@@ -1,4 +1,3 @@
1
- "use client";
2
1
 
3
2
  import { Button } from "../components/ui/button";
4
3
  import {
@@ -1,3 +1,39 @@
1
+ /* Only include Tailwind directives and component-specific styles */
2
+ @tailwind base;
3
+ @tailwind components;
4
+ @tailwind utilities;
5
+
6
+ /* Component-specific styles - scoped to your editor */
7
+ .lexical-text-editor {
8
+ /* Custom scrollbar styles - scoped to editor only */
9
+ scrollbar-width: thin;
10
+ scrollbar-color: rgb(156 163 175) transparent;
11
+ }
12
+
13
+ .lexical-text-editor::-webkit-scrollbar {
14
+ width: 6px;
15
+ }
16
+
17
+ .lexical-text-editor::-webkit-scrollbar-track {
18
+ background: transparent;
19
+ }
20
+
21
+ .lexical-text-editor::-webkit-scrollbar-thumb {
22
+ background-color: rgb(156 163 175);
23
+ border-radius: 3px;
24
+ }
25
+
26
+ .lexical-text-editor::-webkit-scrollbar-thumb:hover {
27
+ background-color: rgb(107 114 128);
28
+ }
29
+
30
+ /* Lexical editor specific styles - scoped properly */
31
+ .lexical-text-editor [contenteditable="true"] {
32
+ outline: none;
33
+ }
34
+
35
+ /* Remove all these global styles - they will break consumer's app */
36
+ /*
1
37
  body{
2
38
  width: 100%;
3
39
  height: 100%;
@@ -5,8 +41,6 @@ body{
5
41
  box-sizing: border-box;
6
42
  }
7
43
 
8
-
9
-
10
44
  #root {
11
45
  width: 100%;
12
46
  height: 100%;
@@ -50,50 +84,54 @@ body{
50
84
  .read-the-docs {
51
85
  color: #888;
52
86
  }
87
+ */
53
88
 
54
- h1 {
55
- font-size: 2em; /* 32px */
56
- margin: 0.5em 0; /* ~10.7px top/bottom */
89
+ /* Heading styles - make them more specific to your editor */
90
+ .lexical-text-editor h1 {
91
+ font-size: 2em;
92
+ margin: 0.5em 0;
57
93
  font-weight: bold;
58
94
  }
59
95
 
60
- h2 {
61
- font-size: 1.8em; /* 24px */
62
- margin: 0.5em 0; /* ~13.3px */
96
+ .lexical-text-editor h2 {
97
+ font-size: 1.8em;
98
+ margin: 0.5em 0;
63
99
  font-weight: bold;
64
100
  }
65
101
 
66
- h3 {
67
- font-size: 1.6em; /* ~18.7px */
68
- margin: 0.2em 0; /* 16px */
102
+ .lexical-text-editor h3 {
103
+ font-size: 1.6em;
104
+ margin: 0.2em 0;
69
105
  font-weight: bold;
70
106
  }
71
107
 
72
- h4 {
73
- font-size: 1.4em; /* 16px */
74
- margin: 0.2em 0; /* ~21.3px */
108
+ .lexical-text-editor h4 {
109
+ font-size: 1.4em;
110
+ margin: 0.2em 0;
75
111
  font-weight: bold;
76
112
  }
77
113
 
78
- h5 {
79
- font-size: 1.2em; /* ~13.3px */
80
- margin: 0.2em 0; /* ~26.7px */
114
+ .lexical-text-editor h5 {
115
+ font-size: 1.2em;
116
+ margin: 0.2em 0;
81
117
  font-weight: bold;
82
118
  }
83
119
 
84
- h6 {
85
- font-size: 1em; /* ~10.7px */
86
- margin: 0.2em 0; /* ~37.3px */
120
+ .lexical-text-editor h6 {
121
+ font-size: 1em;
122
+ margin: 0.2em 0;
87
123
  font-weight: bold;
88
124
  }
89
125
 
90
-
91
- /* -------------------- Scroll Bar --------------------------- */
92
-
126
+ /* Alternative scrollbar class if you need it */
127
+ .scrollbar-thin {
128
+ scrollbar-width: thin;
129
+ scrollbar-color: #a5acb6 transparent;
130
+ }
93
131
 
94
132
  .scrollbar-thin::-webkit-scrollbar {
95
133
  width: 4px;
96
- height: 4px;
134
+ height: 4px;
97
135
  }
98
136
 
99
137
  .scrollbar-thin::-webkit-scrollbar-track {
@@ -103,9 +141,4 @@ h6 {
103
141
  .scrollbar-thin::-webkit-scrollbar-thumb {
104
142
  background-color: #a5acb6;
105
143
  border-radius: 9999px;
106
- }
107
-
108
- .scrollbar-thin {
109
- scrollbar-width: thin;
110
- scrollbar-color: #a5acb6 transparent;
111
- }
144
+ }
@@ -0,0 +1,34 @@
1
+ // Fix for class-variance-authority
2
+ declare module 'class-variance-authority' {
3
+ export type VariantProps<T> = {
4
+ [K in keyof T]?: T[K] extends Record<string, any> ? keyof T[K] : never;
5
+ };
6
+
7
+ export function cva<T extends Record<string, any>>(
8
+ base: string,
9
+ config?: { variants?: T; defaultVariants?: { [K in keyof T]?: keyof T[K] } }
10
+ ): (props?: { [K in keyof T]?: keyof T[K] } & { className?: string }) => string;
11
+ }
12
+
13
+ // Other declarations remain the same...
14
+ declare module 'react-icons/ai';
15
+ declare module 'react-icons/bs';
16
+ declare module 'react-icons/io';
17
+ declare module 'react-icons/io5';
18
+ declare module 'react-icons/fa';
19
+ declare module 'react-icons/rx';
20
+ declare module 'react-icons/tb';
21
+ declare module 'react-icons/pi';
22
+ declare module 'react-icons/hi2';
23
+ declare module 'react-icons/ti';
24
+ declare module 'react-icons/vsc';
25
+ declare module 'react-color';
26
+ declare module 'lucide-react';
27
+ declare module '@radix-ui/react-slot';
28
+ declare module '@radix-ui/react-tooltip';
29
+ declare module '@radix-ui/react-popover';
30
+ declare module '@radix-ui/react-dialog';
31
+ declare module '@radix-ui/react-scroll-area';
32
+ declare module 'cmdk';
33
+ declare module 'clsx';
34
+ declare module 'tailwind-merge';
@@ -0,0 +1,11 @@
1
+ declare module 'react-color';
2
+ declare module 'lucide-react';
3
+ declare module '@radix-ui/react-slot';
4
+ declare module '@radix-ui/react-tooltip';
5
+ declare module '@radix-ui/react-popover';
6
+ declare module '@radix-ui/react-dialog';
7
+ declare module '@radix-ui/react-scroll-area';
8
+ declare module 'cmdk';
9
+ declare module 'clsx';
10
+ declare module 'tailwind-merge';
11
+ declare module 'class-variance-authority';
@@ -0,0 +1,11 @@
1
+ declare module 'react-icons/ai';
2
+ declare module 'react-icons/bs';
3
+ declare module 'react-icons/io';
4
+ declare module 'react-icons/io5';
5
+ declare module 'react-icons/fa';
6
+ declare module 'react-icons/rx';
7
+ declare module 'react-icons/tb';
8
+ declare module 'react-icons/pi';
9
+ declare module 'react-icons/hi2';
10
+ declare module 'react-icons/ti';
11
+ declare module 'react-icons/vsc';
@@ -0,0 +1,10 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ export default {
3
+ content: [
4
+ "./src/**/*.{js,ts,jsx,tsx}",
5
+ ],
6
+ theme: {
7
+ extend: {},
8
+ },
9
+ plugins: [],
10
+ }
package/tsconfig.json CHANGED
@@ -1,19 +1,32 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "es5",
4
- "lib": ["DOM", "DOM.Iterable", "ESNext"],
5
- "allowJs": true,
6
- "skipLibCheck": true,
7
- "esModuleInterop": true,
8
- "allowSyntheticDefaultImports": true,
9
- "strict": true,
10
- "forceConsistentCasingInFileNames": true,
3
+ "target": "ES2020",
4
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
11
5
  "module": "ESNext",
6
+ "skipLibCheck": true,
12
7
  "moduleResolution": "node",
8
+ "allowImportingTsExtensions": false,
13
9
  "resolveJsonModule": true,
14
10
  "isolatedModules": true,
15
- "noEmit": true,
11
+ "noEmit": false,
16
12
  "jsx": "react-jsx",
13
+ "declaration": true,
14
+ "outDir": "dist",
15
+ "strict": false,
16
+ "noUnusedLocals": false,
17
+ "noUnusedParameters": false,
18
+ "noFallthroughCasesInSwitch": true,
19
+ "esModuleInterop": true,
20
+ "allowSyntheticDefaultImports": true,
21
+ "forceConsistentCasingInFileNames": true
17
22
  },
18
- "include": ["src"]
23
+ "include": [
24
+ "src/**/*"
25
+ ],
26
+ "exclude": [
27
+ "dist",
28
+ "node_modules",
29
+ "**/*.stories.*",
30
+ "**/*.test.*"
31
+ ]
19
32
  }
package/dist/index.css DELETED
@@ -1,111 +0,0 @@
1
- body{
2
- width: 100%;
3
- height: 100%;
4
- margin: 0 auto;
5
- box-sizing: border-box;
6
- }
7
-
8
-
9
-
10
- #root {
11
- width: 100%;
12
- height: 100%;
13
- margin: 0 auto;
14
- padding: 2rem;
15
- text-align: center;
16
- }
17
-
18
- .logo {
19
- height: 6em;
20
- padding: 1.5em;
21
- will-change: filter;
22
- transition: filter 300ms;
23
- }
24
- .logo:hover {
25
- filter: drop-shadow(0 0 2em #646cffaa);
26
- }
27
- .logo.react:hover {
28
- filter: drop-shadow(0 0 2em #61dafbaa);
29
- }
30
-
31
- @keyframes logo-spin {
32
- from {
33
- transform: rotate(0deg);
34
- }
35
- to {
36
- transform: rotate(360deg);
37
- }
38
- }
39
-
40
- @media (prefers-reduced-motion: no-preference) {
41
- a:nth-of-type(2) .logo {
42
- animation: logo-spin infinite 20s linear;
43
- }
44
- }
45
-
46
- .card {
47
- padding: 2em;
48
- }
49
-
50
- .read-the-docs {
51
- color: #888;
52
- }
53
-
54
- h1 {
55
- font-size: 2em; /* 32px */
56
- margin: 0.5em 0; /* ~10.7px top/bottom */
57
- font-weight: bold;
58
- }
59
-
60
- h2 {
61
- font-size: 1.8em; /* 24px */
62
- margin: 0.5em 0; /* ~13.3px */
63
- font-weight: bold;
64
- }
65
-
66
- h3 {
67
- font-size: 1.6em; /* ~18.7px */
68
- margin: 0.2em 0; /* 16px */
69
- font-weight: bold;
70
- }
71
-
72
- h4 {
73
- font-size: 1.4em; /* 16px */
74
- margin: 0.2em 0; /* ~21.3px */
75
- font-weight: bold;
76
- }
77
-
78
- h5 {
79
- font-size: 1.2em; /* ~13.3px */
80
- margin: 0.2em 0; /* ~26.7px */
81
- font-weight: bold;
82
- }
83
-
84
- h6 {
85
- font-size: 1em; /* ~10.7px */
86
- margin: 0.2em 0; /* ~37.3px */
87
- font-weight: bold;
88
- }
89
-
90
-
91
- /* -------------------- Scroll Bar --------------------------- */
92
-
93
-
94
- .scrollbar-thin::-webkit-scrollbar {
95
- width: 4px;
96
- height: 4px;
97
- }
98
-
99
- .scrollbar-thin::-webkit-scrollbar-track {
100
- background: transparent;
101
- }
102
-
103
- .scrollbar-thin::-webkit-scrollbar-thumb {
104
- background-color: #a5acb6;
105
- border-radius: 9999px;
106
- }
107
-
108
- .scrollbar-thin {
109
- scrollbar-width: thin;
110
- scrollbar-color: #a5acb6 transparent;
111
- }
package/dist/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
-
3
- interface LexiTexProps {
4
- value: string;
5
- onChange: (value: string) => void;
6
- placeholder?: string;
7
- name: string;
8
- }
9
- declare const LexicalTextEditor: React.FC<LexiTexProps>;
10
-
11
- export { LexicalTextEditor as default };