@domternal/core 0.2.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Domternal contributors
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 ADDED
@@ -0,0 +1,97 @@
1
+ # @domternal/core
2
+
3
+ Lightweight, framework-agnostic rich text editor engine with 13 nodes, 9 marks, 25 extensions, 112+ chainable commands, and 45 built-in icons.
4
+
5
+ Part of the [Domternal](https://github.com/domternal/domternal) toolkit. Full docs at [domternal.dev](https://domternal.dev).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @domternal/core
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ### Headless (Vanilla JS/TS)
16
+
17
+ Import only the extensions you need for full control and zero bloat:
18
+
19
+ ```ts
20
+ import { Editor, Document, Text, Paragraph, Bold, Italic, Underline } from '@domternal/core';
21
+
22
+ const editor = new Editor({
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 |
94
+
95
+ ## License
96
+
97
+ [MIT](https://github.com/domternal/domternal/blob/main/LICENSE)