@domternal/core 0.2.0 → 0.2.1
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 +23 -84
- package/dist/index.cjs +14 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/package.json +11 -13
package/README.md
CHANGED
|
@@ -1,96 +1,35 @@
|
|
|
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 [ProseMirror](https://prosemirror.net/). Framework-agnostic headless core with first-class **Angular** support. 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
7
|
|
|
7
|
-
|
|
8
|
+
**[Website](https://domternal.dev)** · **[Documentation](https://domternal.dev/v1/introduction)** · **[StackBlitz (Vanilla TS)](https://stackblitz.com/edit/domternal-vanilla-full-example)** · **[StackBlitz (Angular)](https://stackblitz.com/edit/domternal-angular-full-example)**
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
npm install @domternal/core
|
|
11
|
-
```
|
|
10
|
+
## Features
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
See [Packages & Bundle Size](https://domternal.dev/v1/packages) for a full breakdown of all packages and what each one includes.
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
- **Headless core** - use with any framework or vanilla JS/TS
|
|
15
|
+
- **Angular components** - editor, toolbar, bubble menu, floating menu, emoji picker (signals, OnPush, zoneless-ready)
|
|
16
|
+
- **57 extensions across 10 packages** - 23 nodes, 9 marks, and 25 behavior extensions
|
|
17
|
+
- **140+ chainable commands** - `editor.chain().focus().toggleBold().run()`
|
|
18
|
+
- **Full table support** - cell merging, column resize, row/column controls, cell toolbar, all free and MIT licensed
|
|
19
|
+
- **Tree-shakeable** - import only what you use, your bundler strips the rest
|
|
20
|
+
- **~38 KB gzipped** (own code), [~108 KB total](https://domternal.dev/v1/packages) with ProseMirror
|
|
21
|
+
- **TypeScript first** - 100% typed, zero `any`
|
|
22
|
+
- **4,200+ tests** - 2,675 unit tests and 1,550 E2E tests across 34 Playwright specs
|
|
23
|
+
- **Light and dark theme** - 70+ CSS custom properties for full visual control
|
|
24
|
+
- **Inline styles export** - `getHTML({ styled: true })` produces inline CSS ready for email clients, CMS, and Google Docs
|
|
25
|
+
- **SSR helpers** - `generateHTML`, `generateJSON`, `generateText` for server-side rendering
|
|
16
26
|
|
|
17
|
-
|
|
27
|
+
## Documentation
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
element: document.getElementById('editor')!,
|
|
24
|
-
extensions: [Document, Text, Paragraph, Bold, Italic, Underline],
|
|
25
|
-
content: '<p>Hello <strong>World</strong>!</p>',
|
|
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 |
|
|
29
|
+
- [Getting Started](https://domternal.dev/v1/getting-started) - install and create your first editor
|
|
30
|
+
- [Introduction](https://domternal.dev/v1/introduction) - core concepts, architecture, and design decisions
|
|
31
|
+
- [Packages & Bundle Size](https://domternal.dev/v1/packages) - what each package includes and bundle size breakdown
|
|
32
|
+
- [Blog](https://domternal.dev/blog)
|
|
94
33
|
|
|
95
34
|
## License
|
|
96
35
|
|
package/dist/index.cjs
CHANGED
|
@@ -5047,6 +5047,20 @@ var HardBreak = Node.create({
|
|
|
5047
5047
|
}
|
|
5048
5048
|
};
|
|
5049
5049
|
},
|
|
5050
|
+
addToolbarItems() {
|
|
5051
|
+
return [
|
|
5052
|
+
{
|
|
5053
|
+
type: "button",
|
|
5054
|
+
name: "hardBreak",
|
|
5055
|
+
command: "setHardBreak",
|
|
5056
|
+
icon: "linkBreak",
|
|
5057
|
+
label: "Hard Break",
|
|
5058
|
+
shortcut: "Shift-Enter",
|
|
5059
|
+
group: "insert",
|
|
5060
|
+
priority: 50
|
|
5061
|
+
}
|
|
5062
|
+
];
|
|
5063
|
+
},
|
|
5050
5064
|
addKeyboardShortcuts() {
|
|
5051
5065
|
const { editor } = this;
|
|
5052
5066
|
return {
|