@oix1987/yjd 2.1.1 → 2.1.2

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 CHANGED
@@ -27,12 +27,16 @@ Every preset is built from the same `/core` entry — pick a profile, tree-shake
27
27
  | Preset | Includes | Size |
28
28
  |---|---|---|
29
29
  | Minimal | bold · italic · underline · link | **~16 KB** |
30
- | Bubble | floating bar, no toolbar + slash menu | **~21 KB** |
30
+ | Comment box | bold · italic · link · list · image · mention + `fromTextarea` | **~26 KB** |
31
31
  | Basic | + strike · headings · lists · align | **~25 KB** |
32
32
  | Standard | + colour · image · table · find · code view | **~38 KB** |
33
- | Full | everything (CSS inlined) | **~54 KB** |
33
+ | Full (all-in-one) | everything, CSS inlined | **~64 KB** |
34
34
 
35
- > For comparison, Quill 2 is ~60 KB. The stylesheet (~8 KB gzip) ships once and is cached, kept out of the JS.
35
+ > All figures are measured gzip. Tree-shake from the `/core` entry to land near the
36
+ > top of the table; the all-in-one default (`import yjd from '@oix1987/yjd'`) is the
37
+ > ~64 KB row because it registers every format/module and inlines the CSS. For
38
+ > comparison, Quill 2 is ~60 KB. The standalone stylesheet is ~10 KB gzip — link it
39
+ > once (and skip `StylesLoader`) to keep it out of the JS.
36
40
 
37
41
  ## Install
38
42
 
@@ -93,6 +97,30 @@ new Editor('#editor', {
93
97
  <link rel="stylesheet" href="@oix1987/yjd/lib/styles.min.css">
94
98
  ```
95
99
 
100
+ ### Lightweight comment box (~26 KB)
101
+
102
+ `Editor.fromTextarea`, `renderStatic` and the Markdown/JSON helpers all live in
103
+ `/core`, so a comment box pulls only the formats/modules you register — not the
104
+ whole editor. Link the stylesheet (don't import `StylesLoader`) to keep CSS out
105
+ of the JS.
106
+
107
+ ```js
108
+ import { Editor, registry, Bold, Italic, Link, List, Image, Mention, Toolbar, History }
109
+ from '@oix1987/yjd/core';
110
+
111
+ [['formats/bold', Bold], ['formats/italic', Italic], ['formats/link', Link],
112
+ ['formats/list', List], ['formats/image', Image],
113
+ ['modules/mention', Mention], ['modules/toolbar', Toolbar], ['modules/history', History]]
114
+ .forEach(([k, v]) => registry.register(k, v));
115
+
116
+ const ed = Editor.fromTextarea('#comment', {
117
+ format: 'markdown',
118
+ toolbar1: [{ group: 'insert', items: ['bold', 'italic', 'link', 'list', 'image', 'emoji'] }],
119
+ mention: { source: (q) => fetchUsers(q) },
120
+ submit: { onEnter: (html) => post(html) },
121
+ });
122
+ ```
123
+
96
124
  ## Options
97
125
 
98
126
  | Option | Type | Description |