@daneshnaik/rich-text-editor 1.0.2 → 1.0.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/README.md +66 -0
- package/dist/rich-text-editor.js +1031 -977
- package/dist/rich-text-editor.umd.cjs +2 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,6 +84,72 @@ function App() {
|
|
|
84
84
|
export default App;
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
+
### Exporting / Printing (Only toolbar + page)
|
|
88
|
+
|
|
89
|
+
The package includes CSS helpers so consumers can print or export only the editor canvas and toolbar (no surrounding app chrome).
|
|
90
|
+
|
|
91
|
+
- Print: the package defines `@media print` rules that automatically hide other page content and show only `.editor-toolbar` and `.editor-container`.
|
|
92
|
+
- Programmatic export: use the `export-only` helper class on `document.body` to hide everything except the editor, then trigger `window.print()` or your capture routine.
|
|
93
|
+
|
|
94
|
+
Example button (optional):
|
|
95
|
+
|
|
96
|
+
```jsx
|
|
97
|
+
import React from 'react';
|
|
98
|
+
import ExportButton from './components/ExportButton'; // or from package export when bundled
|
|
99
|
+
|
|
100
|
+
function MyEditorPage() {
|
|
101
|
+
return (
|
|
102
|
+
<div>
|
|
103
|
+
<RichTextEditor />
|
|
104
|
+
<ExportButton />
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export default MyEditorPage;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
If you're bundling the library for npm, include the `ExportButton` in your published module exports so consumers can import it directly from the package.
|
|
113
|
+
|
|
114
|
+
### New: sizing & drag-and-drop support
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
The editor now accepts a few props to allow consuming apps to control the editor canvas size and to support drag-and-drop from the host application.
|
|
118
|
+
|
|
119
|
+
- `width` (string): set the page width (e.g. `800px` or `100%`).
|
|
120
|
+
- `height` (string): set the minimum page height (e.g. `1123px`).
|
|
121
|
+
- `fullBleed` (boolean, default: `true`): when `true`, removes the side gutters so the page sits edge-to-edge in its container. The editor now defaults to full-bleed so embedding apps receive the editor + toolbar only (no centered page gaps).
|
|
122
|
+
- `onComponentDrop` (function): optional callback called when something is dropped onto the editor. Receives `(info, event)` where `info` contains `{ html, text, files, types }`.
|
|
123
|
+
|
|
124
|
+
Example usage:
|
|
125
|
+
|
|
126
|
+
```jsx
|
|
127
|
+
import React from 'react';
|
|
128
|
+
import RichTextEditor from '@daneshnaik/rich-text-editor';
|
|
129
|
+
import ExportButton from '@daneshnaik/rich-text-editor/ExportButton';
|
|
130
|
+
import '@daneshnaik/rich-text-editor/dist/style.css';
|
|
131
|
+
|
|
132
|
+
function MyEditorPage() {
|
|
133
|
+
const handleDrop = (info, ev) => {
|
|
134
|
+
// info.html / info.text / info.files available
|
|
135
|
+
console.log('dropped', info);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<div style={{ width: '100%', height: '100vh' }}>
|
|
140
|
+
<RichTextEditor width="100%" height="900px" fullBleed={true} onComponentDrop={handleDrop} />
|
|
141
|
+
<ExportButton />
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export default MyEditorPage;
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Notes:
|
|
150
|
+
- If the dropped data contains `text/html`, it will be inserted as HTML at the caret location. Plain text is inserted as text. Image files dropped will be read and inserted as data-URL images.
|
|
151
|
+
- The `fullBleed` mode keeps the editor from centering and removes left/right page gutters; you can also pass an exact `width` to control the page size.
|
|
152
|
+
|
|
87
153
|
## Requirements
|
|
88
154
|
|
|
89
155
|
- React 18.0.0 or higher
|