nam-rich-text-editor 9.0.0 → 9.0.2

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 CHANGED
@@ -5,15 +5,19 @@ A custom rich text editor similar to Word, built with JavaScript and TypeScript.
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install rich-text-editor
8
+ npm install nam-rich-text-editor
9
9
  ```
10
10
 
11
11
  ## Usage
12
12
 
13
+ ### As a Class
14
+
13
15
  ```javascript
14
- import { RichTextEditor } from "rich-text-editor";
16
+ import { RichTextEditor } from "nam-rich-text-editor";
15
17
 
16
- const editor = new RichTextEditor("editor-container");
18
+ const editor = new RichTextEditor();
19
+ const editorElement = editor.getElement();
20
+ document.body.appendChild(editorElement);
17
21
 
18
22
  // Get HTML content
19
23
  const html = editor.getHTML();
@@ -22,10 +26,24 @@ const html = editor.getHTML();
22
26
  editor.setHTML("<p>Hello <strong>world</strong>!</p>");
23
27
  ```
24
28
 
25
- Add a div with id 'editor-container' in your HTML:
29
+ ### As a React Component
30
+
31
+ ```jsx
32
+ import React from "react";
33
+ import { RichTextEditorComponent } from "nam-rich-text-editor";
34
+
35
+ const MyEditor = () => {
36
+ const handleChange = (html) => {
37
+ console.log("HTML content:", html);
38
+ };
26
39
 
27
- ```html
28
- <div id="editor-container"></div>
40
+ return (
41
+ <RichTextEditorComponent
42
+ onChange={handleChange}
43
+ initialValue="<p>Start editing...</p>"
44
+ />
45
+ );
46
+ };
29
47
  ```
30
48
 
31
49
  ## Features
@@ -2,7 +2,8 @@ export declare class RichTextEditor {
2
2
  private container;
3
3
  private toolbar;
4
4
  private editor;
5
- constructor(containerId: string);
5
+ constructor();
6
+ getElement(): HTMLElement;
6
7
  getHTML(): string;
7
8
  setHTML(html: string): void;
8
9
  }
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ interface RichTextEditorProps {
3
+ onChange?: (html: string) => void;
4
+ initialValue?: string;
5
+ }
6
+ declare const RichTextEditorComponent: React.FC<RichTextEditorProps>;
7
+ export default RichTextEditorComponent;
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { RichTextEditor } from "./RichTextEditor";
2
+ export { default as RichTextEditorComponent } from "./RichTextEditorComponent";
package/dist/main.d.ts CHANGED
@@ -1 +1 @@
1
- import "./style.css";
1
+ export {};