@novaprose/core 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +106 -2
- package/dist/chunk-TKR3C5IJ.js +1449 -0
- package/dist/chunk-TKR3C5IJ.js.map +1 -0
- package/dist/chunk-ZF2JR3JH.js +80 -0
- package/dist/chunk-ZF2JR3JH.js.map +1 -0
- package/dist/index.cjs +6003 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1190 -0
- package/dist/index.d.ts +1190 -0
- package/dist/index.js +4199 -0
- package/dist/index.js.map +1 -0
- package/dist/insertdatetime-C4MAC5L7.js +64 -0
- package/dist/insertdatetime-C4MAC5L7.js.map +1 -0
- package/dist/quickbars-XK4QCQ6F.js +92 -0
- package/dist/quickbars-XK4QCQ6F.js.map +1 -0
- package/package.json +64 -3
- package/src/style.css +1551 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NovaProse authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,107 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @novaprose/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**NovaProse** is an embeddable rich text (WYSIWYG) editor built on [ProseMirror](https://prosemirror.net).
|
|
4
|
+
It is an open-source (MIT) alternative to TinyMCE: toolbar, plugin and option names follow the
|
|
5
|
+
conventions you already know, while the output is clean, deterministic HTML.
|
|
6
|
+
|
|
7
|
+
> **Status: 0.x preview.** The API may change between minor versions until 1.0.
|
|
8
|
+
|
|
9
|
+
- **Secure by default.** Every link and image URL is checked on input _and_ on output, dangerous
|
|
10
|
+
markup is dropped, and the UI never injects user content with `innerHTML`.
|
|
11
|
+
- **Deterministic HTML.** `getHTML()` produces the same string in every browser, so diffs and
|
|
12
|
+
snapshot tests stay stable.
|
|
13
|
+
- **Accessible.** ARIA roles, full keyboard support (Alt+F10 toolbar, Alt+F9 menu bar, Esc),
|
|
14
|
+
visible focus, screen-reader labels.
|
|
15
|
+
- **Complete out of the box.** Tables, images with upload and resize, links, colors, fonts, line
|
|
16
|
+
height, search and replace, source code view, fullscreen, menu bar, slash commands, Markdown
|
|
17
|
+
shortcuts, paste sanitizing (anything outside the schema is dropped), English and Russian UI,
|
|
18
|
+
light and dark theme. Dedicated Word and Excel paste cleanup is on the roadmap.
|
|
19
|
+
- **Small.** About 120 KB gzip including ProseMirror and tables. Optional plugins load lazily.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @novaprose/core
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { createEditor } from '@novaprose/core';
|
|
29
|
+
import '@novaprose/core/style.css';
|
|
30
|
+
|
|
31
|
+
const editor = createEditor({
|
|
32
|
+
element: document.querySelector('#editor')!,
|
|
33
|
+
content: '<p>Hello, world</p>',
|
|
34
|
+
placeholder: 'Start typing…',
|
|
35
|
+
// Familiar toolbar syntax; "|" separates groups. Items that don't fit move into "⋯".
|
|
36
|
+
toolbar:
|
|
37
|
+
'undo redo | blocks | bold italic underline | forecolor backcolor | link image table | bullist numlist',
|
|
38
|
+
// Upload pasted, dropped and picked images to your server.
|
|
39
|
+
uploadImage: async (file) => {
|
|
40
|
+
const body = new FormData();
|
|
41
|
+
body.append('file', file);
|
|
42
|
+
const response = await fetch('/upload', { method: 'POST', body });
|
|
43
|
+
return (await response.json()).url;
|
|
44
|
+
},
|
|
45
|
+
onChange: (e) => console.log(e.getHTML()),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
editor.exec('bold');
|
|
49
|
+
editor.getHTML();
|
|
50
|
+
editor.destroy();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Using a framework? See [`@novaprose/react`](https://www.npmjs.com/package/@novaprose/react),
|
|
54
|
+
[`@novaprose/vue`](https://www.npmjs.com/package/@novaprose/vue),
|
|
55
|
+
[`@novaprose/angular`](https://www.npmjs.com/package/@novaprose/angular) or the framework-agnostic
|
|
56
|
+
[`@novaprose/web-component`](https://www.npmjs.com/package/@novaprose/web-component) (also for
|
|
57
|
+
Svelte, Astro and server-rendered pages, with a CDN build).
|
|
58
|
+
|
|
59
|
+
## Options
|
|
60
|
+
|
|
61
|
+
| Option | Description |
|
|
62
|
+
| ---------------------------------------------------- | -------------------------------------------------------------------------------- |
|
|
63
|
+
| `element` | container to mount into (required) |
|
|
64
|
+
| `content` | initial HTML string or document JSON |
|
|
65
|
+
| `toolbar` | string (`'bold italic \| link'`), array of groups, or `false` |
|
|
66
|
+
| `toolbarMode` | `'sliding'` (default) or `'wrap'` |
|
|
67
|
+
| `mode` | `'classic'`, `'inline'` (toolbar on focus) or `'distraction-free'` (quick bars) |
|
|
68
|
+
| `menubar`, `menu` | File · Edit · View · Insert · Format · Table · Help menus, customizable |
|
|
69
|
+
| `statusbar` | word count and path; `false` to hide |
|
|
70
|
+
| `placeholder`, `editable`, `language` | placeholder text, read-only mode, UI language (`en`, `ru` or your own) |
|
|
71
|
+
| `uploadImage` | `(file, progress) => Promise<url>` |
|
|
72
|
+
| `fontFamilies`, `fontSizes`, `lineHeights`, `colors` | lists for the corresponding pickers |
|
|
73
|
+
| `plugins`, `pluginOptions` | plugin objects or names of built-in lazy plugins (`insertdatetime`, `quickbars`) |
|
|
74
|
+
| `validElements`, `invalidElements`, `validStyles` | restrict content, like TinyMCE `valid_elements` / `invalid_elements` |
|
|
75
|
+
| `pastePreprocess`, `pastePostprocess`, `pasteAsText` | paste hooks and plain-text mode |
|
|
76
|
+
| `setup`, `onChange` | access the instance before first render; change callback |
|
|
77
|
+
| `prosemirrorPlugins` | raw ProseMirror plugins for advanced use |
|
|
78
|
+
|
|
79
|
+
## API
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
editor.getHTML();
|
|
83
|
+
editor.getJSON();
|
|
84
|
+
editor.getText();
|
|
85
|
+
editor.isEmpty();
|
|
86
|
+
editor.setContent(html, { addToHistory: false });
|
|
87
|
+
editor.exec('bold');
|
|
88
|
+
editor.can('undo');
|
|
89
|
+
editor.isActive('h2');
|
|
90
|
+
editor.setEditable(false);
|
|
91
|
+
editor.focus();
|
|
92
|
+
editor.on('change' | 'selectionChange' | 'focus' | 'blur' | 'editableChange' | 'destroy', handler);
|
|
93
|
+
editor.ui.registry.addButton('signature', { text: 'Sign', onAction: (e) => e.exec('bold') });
|
|
94
|
+
editor.destroy();
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Command names (`bold`, `italic`, `h1`…`h6`, `bulletList`, `alignCenter`, `undo`…) are part of the
|
|
98
|
+
public API and stay stable across minor versions.
|
|
99
|
+
|
|
100
|
+
## Server-side rendering
|
|
101
|
+
|
|
102
|
+
Importing the package never touches `window` or `document`, so it is safe in SSR bundles. Create
|
|
103
|
+
the editor only in the browser.
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
MIT
|