@domternal/core 0.2.0 → 0.3.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/README.md +26 -84
- package/dist/helpers/inputRulesPlugin.d.ts.map +1 -0
- package/dist/index.cjs +366 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +177 -1
- package/dist/index.d.ts +177 -1
- package/dist/index.js +363 -64
- package/dist/index.js.map +1 -1
- package/dist/nodes/HorizontalRule.d.ts.map +1 -0
- package/package.json +11 -13
package/README.md
CHANGED
|
@@ -1,97 +1,39 @@
|
|
|
1
1
|
# @domternal/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@domternal/core)
|
|
4
|
+
[](https://github.com/domternal/domternal/blob/main/LICENSE)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
A lightweight, extensible rich text editor toolkit built on <u>[ProseMirror](https://prosemirror.net/)</u>. Framework-agnostic headless core with first-class Angular support.
|
|
7
|
+
Use it headless with vanilla JS/TS, add the built-in toolbar and theme, or drop in ready-made Angular components. Fully tree-shakeable, import only what you use, unused extensions are stripped from your bundle.
|
|
6
8
|
|
|
7
|
-
##
|
|
9
|
+
## Links
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
npm install @domternal/core
|
|
11
|
-
```
|
|
11
|
+
<u>[Website](https://domternal.dev)</u> • <u>[Documentation](https://domternal.dev/v1/introduction)</u> • <u>[StackBlitz (Vanilla TS)](https://stackblitz.com/edit/domternal-vanilla-full-example)</u> • <u>[StackBlitz (Angular)](https://stackblitz.com/edit/domternal-angular-full-example)</u>
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Features
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
See <u>[Packages & Bundle Size](https://domternal.dev/v1/packages)</u> for a full breakdown of all packages and what each one includes.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
- **Headless core** - use with any framework or vanilla JS/TS
|
|
18
|
+
- **Angular components** - editor, toolbar, bubble menu, floating menu, emoji picker (signals, OnPush, zoneless-ready)
|
|
19
|
+
- **57 extensions across 10 packages** - 23 nodes, 9 marks, and 25 behavior extensions
|
|
20
|
+
- **140+ chainable commands** - `editor.chain().focus().toggleBold().run()`
|
|
21
|
+
- **Full table support** - cell merging, column resize, row/column controls, cell toolbar, all free and MIT licensed
|
|
22
|
+
- **Tree-shakeable** - import only what you use, your bundler strips the rest
|
|
23
|
+
- **~38 KB gzipped** (own code), <u>[~108 KB total](https://domternal.dev/v1/packages)</u> with ProseMirror
|
|
24
|
+
- **TypeScript first** - 100% typed, zero `any`
|
|
25
|
+
- **4,400+ tests** - 2,687 unit tests and 1,796 E2E tests across 37 Playwright specs
|
|
26
|
+
- **Light and dark theme** - 70+ CSS custom properties for full visual control
|
|
27
|
+
- **Inline styles export** - `getHTML({ styled: true })` produces inline CSS ready for email clients, CMS, and Google Docs
|
|
28
|
+
- **SSR helpers** - `generateHTML`, `generateJSON`, `generateText` for server-side rendering
|
|
18
29
|
|
|
19
|
-
|
|
20
|
-
import { Editor, Document, Text, Paragraph, Bold, Italic, Underline } from '@domternal/core';
|
|
30
|
+
## Documentation
|
|
21
31
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### With Theme and Toolbar
|
|
30
|
-
|
|
31
|
-
Use `StarterKit` for a batteries-included setup, and pair it with `@domternal/theme` for styled UI:
|
|
32
|
-
|
|
33
|
-
```html
|
|
34
|
-
<div id="editor" class="dm-editor"></div>
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
import { Editor, StarterKit, defaultIcons } from '@domternal/core';
|
|
39
|
-
import '@domternal/theme';
|
|
40
|
-
|
|
41
|
-
const editorEl = document.getElementById('editor')!;
|
|
42
|
-
|
|
43
|
-
// Toolbar
|
|
44
|
-
const toolbar = document.createElement('div');
|
|
45
|
-
toolbar.className = 'dm-toolbar';
|
|
46
|
-
toolbar.innerHTML = `<div class="dm-toolbar-group">
|
|
47
|
-
<button class="dm-toolbar-button" data-mark="bold">${defaultIcons.textB}</button>
|
|
48
|
-
<button class="dm-toolbar-button" data-mark="italic">${defaultIcons.textItalic}</button>
|
|
49
|
-
<button class="dm-toolbar-button" data-mark="underline">${defaultIcons.textUnderline}</button>
|
|
50
|
-
</div>`;
|
|
51
|
-
editorEl.before(toolbar);
|
|
52
|
-
|
|
53
|
-
// Editor
|
|
54
|
-
const editor = new Editor({
|
|
55
|
-
element: editorEl,
|
|
56
|
-
extensions: [StarterKit],
|
|
57
|
-
content: '<p>Hello world</p>',
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Toggle marks on click (event delegation)
|
|
61
|
-
toolbar.addEventListener('click', (e) => {
|
|
62
|
-
const btn = (e.target as Element).closest<HTMLButtonElement>('[data-mark]');
|
|
63
|
-
if (!btn) return;
|
|
64
|
-
editor.chain().focus().toggleMark(btn.dataset.mark!).run();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// Active state sync
|
|
68
|
-
editor.on('transaction', () => {
|
|
69
|
-
toolbar.querySelectorAll<HTMLButtonElement>('[data-mark]').forEach((btn) => {
|
|
70
|
-
btn.classList.toggle('dm-toolbar-button--active', editor.isActive(btn.dataset.mark!));
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### StarterKit Contents
|
|
76
|
-
|
|
77
|
-
Every extension in the kit can be disabled with `false` or configured with options:
|
|
78
|
-
|
|
79
|
-
```ts
|
|
80
|
-
StarterKit.configure({
|
|
81
|
-
codeBlock: false, // disable an extension
|
|
82
|
-
heading: { levels: [1, 2, 3, 4] }, // limit heading levels
|
|
83
|
-
history: { depth: 50 }, // configure undo stack
|
|
84
|
-
link: { openOnClick: false }, // keep links non-clickable while editing
|
|
85
|
-
linkPopover: false, // disable the built-in link popover
|
|
86
|
-
})
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
| Category | Included |
|
|
90
|
-
|---|---|
|
|
91
|
-
| **Nodes** | Document, Text, Paragraph, Heading, Blockquote, CodeBlock, BulletList, OrderedList, ListItem, TaskList, TaskItem, HorizontalRule, HardBreak |
|
|
92
|
-
| **Marks** | Bold, Italic, Underline, Strike, Code, Link |
|
|
93
|
-
| **Behaviors** | BaseKeymap, History, Dropcursor, Gapcursor, TrailingNode, ListKeymap, LinkPopover |
|
|
32
|
+
- <u>[Getting Started](https://domternal.dev/v1/getting-started)</u> - install and create your first editor
|
|
33
|
+
- <u>[Introduction](https://domternal.dev/v1/introduction)</u> - core concepts, architecture, and design decisions
|
|
34
|
+
- <u>[Packages & Bundle Size](https://domternal.dev/v1/packages)</u> - what each package includes and bundle size breakdown
|
|
35
|
+
- <u>[Blog](https://domternal.dev/blog)</u>
|
|
94
36
|
|
|
95
37
|
## License
|
|
96
38
|
|
|
97
|
-
[MIT](https://github.com/domternal/domternal/blob/main/LICENSE)
|
|
39
|
+
<u>[MIT](https://github.com/domternal/domternal/blob/main/LICENSE)</u>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputRulesPlugin.d.ts","sourceRoot":"","sources":["../../src/helpers/inputRulesPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AA6G1D;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,SAAS,EAAE,CAAA;CAAE,GAAG,MAAM,CA4C1E"}
|