@astryx-vue/richtext 0.0.0-stage → 0.5.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/package.json CHANGED
@@ -1,6 +1,143 @@
1
1
  {
2
2
  "name": "@astryx-vue/richtext",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "type": "module",
4
+ "version": "0.5.1",
5
+ "description": "Astryx rich text for Vue — Lexical nodes and lossless Markdown import/export. Not affiliated with Meta.",
6
+ "author": "ShenQingchuan",
7
+ "license": "MIT",
8
+ "homepage": "https://astryx-vue.pages.dev",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/astryx-vue/astryx-vue.git",
12
+ "directory": "packages/richtext"
13
+ },
14
+ "bugs": "https://github.com/astryx-vue/astryx-vue/issues",
15
+ "keywords": [
16
+ "vue",
17
+ "vue3",
18
+ "design-system",
19
+ "astryx",
20
+ "richtext",
21
+ "rich-text",
22
+ "editor",
23
+ "lexical",
24
+ "markdown"
25
+ ],
26
+ "sideEffects": [
27
+ "**/*.css"
28
+ ],
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js"
33
+ },
34
+ "./markdown": {
35
+ "types": "./dist/markdown.d.ts",
36
+ "import": "./dist/markdown.js"
37
+ },
38
+ "./package.json": "./package.json",
39
+ "./richtext.css": {
40
+ "types": "./css.d.ts",
41
+ "default": "./richtext.css"
42
+ },
43
+ "./styles/*.css": "./styles/*.css"
44
+ },
45
+ "main": "./dist/index.js",
46
+ "types": "./dist/index.d.ts",
47
+ "files": [
48
+ "README.md",
49
+ "css.d.ts",
50
+ "dist",
51
+ "richtext.css",
52
+ "styles"
53
+ ],
54
+ "peerDependencies": {
55
+ "@lexical/code": "0.52.0",
56
+ "@lexical/extension": "0.52.0",
57
+ "@lexical/headless": "0.52.0",
58
+ "@lexical/history": "0.52.0",
59
+ "@lexical/html": "0.52.0",
60
+ "@lexical/link": "0.52.0",
61
+ "@lexical/list": "0.52.0",
62
+ "@lexical/markdown": "0.52.0",
63
+ "@lexical/rich-text": "0.52.0",
64
+ "@lexical/selection": "0.52.0",
65
+ "@lexical/table": "0.52.0",
66
+ "@lexical/utils": "0.52.0",
67
+ "lexical": "0.52.0",
68
+ "vue": "^3.5.0",
69
+ "@astryx-vue/core": "^0.5.1"
70
+ },
71
+ "peerDependenciesMeta": {
72
+ "@lexical/code": {
73
+ "optional": true
74
+ },
75
+ "@lexical/extension": {
76
+ "optional": true
77
+ },
78
+ "@lexical/headless": {
79
+ "optional": true
80
+ },
81
+ "@lexical/history": {
82
+ "optional": true
83
+ },
84
+ "@lexical/html": {
85
+ "optional": true
86
+ },
87
+ "@lexical/link": {
88
+ "optional": true
89
+ },
90
+ "@lexical/list": {
91
+ "optional": true
92
+ },
93
+ "@lexical/markdown": {
94
+ "optional": true
95
+ },
96
+ "@lexical/rich-text": {
97
+ "optional": true
98
+ },
99
+ "@lexical/selection": {
100
+ "optional": true
101
+ },
102
+ "@lexical/table": {
103
+ "optional": true
104
+ },
105
+ "@lexical/utils": {
106
+ "optional": true
107
+ },
108
+ "lexical": {
109
+ "optional": true
110
+ }
111
+ },
112
+ "devDependencies": {
113
+ "@lexical/code": "0.52.0",
114
+ "@lexical/extension": "0.52.0",
115
+ "@lexical/headless": "0.52.0",
116
+ "@lexical/history": "0.52.0",
117
+ "@lexical/html": "0.52.0",
118
+ "@lexical/link": "0.52.0",
119
+ "@lexical/list": "0.52.0",
120
+ "@lexical/markdown": "0.52.0",
121
+ "@lexical/rich-text": "0.52.0",
122
+ "@lexical/selection": "0.52.0",
123
+ "@lexical/table": "0.52.0",
124
+ "@lexical/utils": "0.52.0",
125
+ "@types/node": "26.6.4",
126
+ "@vue/compiler-sfc": "3.5.43",
127
+ "lexical": "0.52.0",
128
+ "tsdown": "0.23.0",
129
+ "typescript": "npm:@typescript/typescript6@6.0.2",
130
+ "unplugin-vue": "8.0.0",
131
+ "vue": "3.5.43",
132
+ "vue-tsc": "3.3.12",
133
+ "@astryx-vue/core": "^0.5.1"
134
+ },
135
+ "publishConfig": {
136
+ "access": "public"
137
+ },
138
+ "scripts": {
139
+ "build": "tsdown",
140
+ "dev": "tsdown --watch",
141
+ "typecheck": "vue-tsc --noEmit -p tsconfig.json"
142
+ }
6
143
  }
package/richtext.css ADDED
@@ -0,0 +1,5 @@
1
+ /* 富文本包的全部样式。按需引入时也可以只引 styles/ 下的单份文件。 */
2
+ @import './styles/richtext-document.css';
3
+ @import './styles/richtext-editor.css';
4
+ @import './styles/richtext-toolbar.css';
5
+ @import './styles/richtext-view.css';
@@ -0,0 +1,269 @@
1
+ @layer astryx.reset, astryx.tokens, astryx.base, astryx.components, astryx.overrides;
2
+
3
+ /*
4
+ * 文档内容的样式:段落、标题、引用、列表、链接、行内文字、分割线、代码块、表格。
5
+ * 间距和字号跟 core 的 Markdown 一致,所以同一段内容在编辑器里和在 Markdown 里排出来一样。
6
+ * 编辑器和只读视图共用这份样式。
7
+ */
8
+ @layer astryx.components {
9
+ .astryx-richtext__paragraph,
10
+ .astryx-richtext__heading,
11
+ .astryx-richtext__quote,
12
+ .astryx-richtext__list,
13
+ .astryx-richtext__code {
14
+ /* Lexical 给每个顶层块都标 dir="auto",会按首个强字符决定方向;这里改成跟随外层。 */
15
+ direction: inherit;
16
+ }
17
+
18
+ .astryx-richtext__paragraph {
19
+ max-width: var(--astryx-richtext-measure, 680px);
20
+ margin-block: var(--astryx-spacing-3, 12px);
21
+ font-weight: inherit;
22
+ color: inherit;
23
+ }
24
+
25
+ .astryx-richtext__paragraph:first-child,
26
+ .astryx-richtext__paragraph:has(+ [data-lexical-decorator-boundary]:last-child) {
27
+ margin-block-start: 0;
28
+ }
29
+
30
+ [data-lexical-decorator-boundary]:first-child + .astryx-richtext__paragraph {
31
+ margin-block-start: 0;
32
+ }
33
+
34
+ .astryx-richtext__paragraph:last-child {
35
+ margin-block-end: 0;
36
+ }
37
+
38
+ .astryx-richtext__heading {
39
+ max-width: var(--astryx-richtext-measure, 680px);
40
+ font-family: var(--astryx-font-family-heading, inherit);
41
+ margin-block: var(--_rt-heading-top, var(--astryx-spacing-4, 16px)) var(--_rt-heading-bottom, var(--astryx-spacing-2, 8px));
42
+ }
43
+
44
+ .astryx-richtext__h1,
45
+ .astryx-richtext__h2,
46
+ .astryx-richtext__h3 {
47
+ --_rt-heading-top: var(--astryx-spacing-6, 24px);
48
+ --_rt-heading-bottom: var(--astryx-spacing-3, 12px);
49
+ }
50
+
51
+ .astryx-richtext__heading:first-child {
52
+ margin-block-start: 0;
53
+ }
54
+
55
+ .astryx-richtext__heading:last-child {
56
+ margin-block-end: 0;
57
+ }
58
+
59
+ .astryx-richtext__h1 { font-size: var(--astryx-text-heading-1-size, 1.5rem); font-weight: var(--astryx-text-heading-1-weight, 600); line-height: var(--astryx-text-heading-1-leading, 1.3333); }
60
+ .astryx-richtext__h2 { font-size: var(--astryx-text-heading-2-size, 1.25rem); font-weight: var(--astryx-text-heading-2-weight, 600); line-height: var(--astryx-text-heading-2-leading, 1.4); }
61
+ .astryx-richtext__h3 { font-size: var(--astryx-text-heading-3-size, 1.0625rem); font-weight: var(--astryx-text-heading-3-weight, 600); line-height: var(--astryx-text-heading-3-leading, 1.4118); }
62
+ .astryx-richtext__h4 { font-size: var(--astryx-text-heading-4-size, 0.875rem); font-weight: var(--astryx-text-heading-4-weight, 600); line-height: var(--astryx-text-heading-4-leading, 1.4286); }
63
+ .astryx-richtext__h5 { font-size: var(--astryx-text-heading-5-size, 0.75rem); font-weight: var(--astryx-text-heading-5-weight, 600); line-height: var(--astryx-text-heading-5-leading, 1.6667); }
64
+ .astryx-richtext__h6 { font-size: var(--astryx-text-heading-6-size, 0.625rem); font-weight: var(--astryx-text-heading-6-weight, 600); line-height: var(--astryx-text-heading-6-leading, 1.6); }
65
+
66
+ .astryx-richtext__quote {
67
+ max-width: var(--astryx-richtext-measure, 680px);
68
+ margin-block: var(--astryx-spacing-4, 16px);
69
+ margin-inline: 0;
70
+ padding-inline-start: var(--astryx-spacing-4, 16px);
71
+ border-inline-start: 2px solid var(--astryx-color-border-emphasized, #d4d4d4);
72
+ color: var(--astryx-color-text-secondary, #525252);
73
+ }
74
+
75
+ .astryx-richtext__quote:first-child { margin-block-start: 0; }
76
+ .astryx-richtext__quote:last-child { margin-block-end: 0; }
77
+
78
+ .astryx-richtext__list {
79
+ max-width: var(--astryx-richtext-measure, 680px);
80
+ margin-block: var(--astryx-spacing-3, 12px);
81
+ padding-inline-start: var(--astryx-spacing-6, 24px);
82
+ list-style-position: outside;
83
+ }
84
+
85
+ .astryx-richtext__list:first-child { margin-block-start: 0; }
86
+ .astryx-richtext__list:last-child { margin-block-end: 0; }
87
+
88
+ /* 嵌套深度决定标记:n 层嵌套按 n % 3 取圆点、空心圆、方块,或数字、小写字母、小写罗马数字。 */
89
+ .astryx-richtext__ul-0 { list-style-type: disc; }
90
+ .astryx-richtext__ul-1 { list-style-type: circle; }
91
+ .astryx-richtext__ul-2 { list-style-type: square; }
92
+ .astryx-richtext__ol-0 { list-style-type: decimal; }
93
+ .astryx-richtext__ol-1 { list-style-type: lower-alpha; }
94
+ .astryx-richtext__ol-2 { list-style-type: lower-roman; }
95
+
96
+ /* 列表项的间距跟 core Markdown 的紧凑列表一致:上下各 4px 内边距,行间 2px。
97
+ Lexical 把嵌套列表放进父项后面单独的一项里,这一项没有标记、不加上内边距。 */
98
+ .astryx-richtext__list-item {
99
+ margin-block: 0 var(--astryx-spacing-0-5, 2px);
100
+ padding-block: var(--astryx-spacing-1, 4px);
101
+ list-style-type: inherit;
102
+ }
103
+
104
+ .astryx-richtext__list-item:last-child { margin-block-end: 0; }
105
+
106
+ .astryx-richtext__list-item:has(> ul, > ol) {
107
+ margin-block-start: var(--astryx-spacing-2, 8px);
108
+ padding-block-start: 0;
109
+ list-style-type: none;
110
+ }
111
+
112
+ .astryx-richtext__link {
113
+ color: var(--astryx-color-text-accent, #0b5cd5);
114
+ text-decoration: underline;
115
+ cursor: pointer;
116
+ }
117
+
118
+ .astryx-richtext__bold { font-weight: var(--astryx-font-weight-semibold, 600); }
119
+ .astryx-richtext__italic { font-style: italic; }
120
+ .astryx-richtext__underline { text-decoration: underline; }
121
+ .astryx-richtext__strikethrough { text-decoration: line-through; }
122
+
123
+ .astryx-richtext__inline-code {
124
+ padding-inline: var(--astryx-spacing-1, 4px);
125
+ border-radius: var(--astryx-radius-inner, 0.375rem);
126
+ background-color: var(--astryx-color-background-muted, #f5f5f5);
127
+ font-family: var(--astryx-font-family-code, ui-monospace, monospace);
128
+ }
129
+
130
+ .astryx-richtext__hr {
131
+ margin-block: var(--astryx-spacing-6, 24px);
132
+ border: 0;
133
+ border-block-start: var(--astryx-border-width, 1px) solid var(--astryx-color-border, #ebebeb);
134
+ }
135
+
136
+ .astryx-richtext__hr:first-child { margin-block-start: 0; }
137
+ .astryx-richtext__hr:last-child { margin-block-end: 0; }
138
+
139
+ /* 选中的分割线或 Markdown 插件节点显示焦点环,用户看得出按退格会删掉什么。 */
140
+ .astryx-richtext__selected {
141
+ outline: var(--astryx-focus-outline-width, 2px) var(--astryx-focus-outline-style, solid) var(--astryx-focus-outline-color, #0b5cd5);
142
+ outline-offset: var(--astryx-focus-outline-offset, 2px);
143
+ }
144
+
145
+ /* 围栏代码块,外框跟 core 的 CodeBlock 一致。长行折行而不是滚动:编辑区里的滚动区
146
+ 拿不到键盘焦点,键盘用户就没法滚动它。 */
147
+ .astryx-richtext__code {
148
+ display: block;
149
+ box-sizing: border-box;
150
+ width: fit-content;
151
+ min-width: min(var(--astryx-richtext-measure, 680px), 100%);
152
+ max-width: 100%;
153
+ margin-block: var(--astryx-spacing-4, 16px);
154
+ padding: var(--astryx-spacing-3, 12px) var(--astryx-spacing-4, 16px);
155
+ border: var(--astryx-border-width, 1px) solid var(--astryx-code-block-border, #00000014);
156
+ border-radius: var(--astryx-radius-element, 0.625rem);
157
+ background-color: var(--astryx-code-block-background, #ffffff);
158
+ font-family: var(--astryx-font-family-code, ui-monospace, monospace);
159
+ font-size: var(--astryx-text-code-size, 0.8125rem);
160
+ line-height: var(--astryx-text-code-leading, 1.5);
161
+ white-space: pre-wrap;
162
+ word-break: break-all;
163
+ overflow-wrap: break-word;
164
+ }
165
+
166
+ .astryx-richtext__code:first-child { margin-block-start: 0; }
167
+ .astryx-richtext__code:last-child { margin-block-end: 0; }
168
+
169
+ /* 标出了语言的代码块,顶部给标题栏留位置:标题栏上下各 8px 加一个小号控件,再加正文的 12px。
170
+ 不写进 padding 简写里,是为了让「标题栏占多高」这一件事只在这里出现一次。 */
171
+ .astryx-richtext__code[data-language]:not([data-language='plaintext']) {
172
+ padding-block-start: calc(var(--astryx-spacing-2, 8px) + var(--astryx-size-element-sm, 24px) + var(--astryx-spacing-2, 8px) + var(--astryx-spacing-3, 12px));
173
+ }
174
+
175
+ /* GFM 表格:表头半粗、次要颜色;每行下面一条分隔线,最后一行除外;表格太宽就在自己的容器里横向滚动。 */
176
+ .astryx-richtext__table-wrap {
177
+ display: grid;
178
+ grid-template-columns: minmax(0, 1fr);
179
+ max-width: 100%;
180
+ margin-block: var(--astryx-spacing-4, 16px);
181
+ overflow-x: auto;
182
+ }
183
+
184
+ .astryx-richtext__table-wrap:first-child { margin-block-start: 0; }
185
+ .astryx-richtext__table-wrap:last-child { margin-block-end: 0; }
186
+
187
+ .astryx-richtext__table {
188
+ width: 100%;
189
+ border-collapse: collapse;
190
+ }
191
+
192
+ .astryx-richtext__table-row {
193
+ border-block-end: 1px solid var(--astryx-color-border, #ebebeb);
194
+ }
195
+
196
+ .astryx-richtext__table-row:last-child { border-block-end-color: transparent; }
197
+
198
+ .astryx-richtext__table-cell {
199
+ box-sizing: content-box;
200
+ padding: var(--astryx-spacing-2, 8px);
201
+ text-align: start;
202
+ vertical-align: middle;
203
+ overflow-wrap: break-word;
204
+ }
205
+
206
+ /* 格子里的段落不留上下外边距:外边距是段落和段落之间的间距,格子里只有这一段,留着会把格子撑成两倍高。 */
207
+ .astryx-richtext__table-cell > .astryx-richtext__paragraph {
208
+ margin-block: 0;
209
+ max-width: none;
210
+ }
211
+
212
+ .astryx-richtext__table-cell-header {
213
+ font-weight: var(--astryx-font-weight-semibold, 600);
214
+ color: var(--astryx-color-text-secondary, #525252);
215
+ }
216
+
217
+ /* 选中的单元格画一圈外框,而不是铺底色:底色在文字后面,会拉低文字对比度。
218
+ outline 不占位置,文档排版不会因此移动;负偏移把环收在自己的格子里。 */
219
+ .astryx-richtext__table-cell-selected {
220
+ outline: var(--astryx-focus-outline-width, 2px) var(--astryx-focus-outline-style, solid) var(--astryx-focus-outline-color, #0b5cd5);
221
+ outline-offset: calc(-1 * var(--astryx-focus-outline-width, 2px));
222
+ }
223
+ }
224
+
225
+ @layer astryx.components {
226
+ /* 任务项:不画列表标记,给勾选框留位置。项的文字从列表边缘往里 28px 开始:
227
+ core 小号勾选框 20px 加 8px 的间隔,和 core Markdown 的任务列表一致。 */
228
+ .astryx-richtext__list-item[data-richtext-task] {
229
+ margin-inline-start: calc(-1 * var(--astryx-spacing-6, 24px));
230
+ padding-inline-start: calc(20px + var(--astryx-spacing-2, 8px));
231
+ list-style-type: none;
232
+ }
233
+
234
+ /* 代码块标题栏:和 core CodeBlock 的紧凑标题栏一致,上下各 8px,两侧 16px。 */
235
+ .astryx-richtext-code-header {
236
+ display: flex;
237
+ align-items: center;
238
+ justify-content: space-between;
239
+ box-sizing: border-box;
240
+ padding: var(--astryx-spacing-2, 8px) var(--astryx-spacing-4, 16px);
241
+ }
242
+
243
+ /* 没写语言:只有复制按钮,贴在右上角,离角 8px;容器不挡住下面代码的点击。 */
244
+ .astryx-richtext-code-header--corner {
245
+ justify-content: flex-end;
246
+ padding: var(--astryx-spacing-2, 8px);
247
+ pointer-events: none;
248
+ }
249
+
250
+ .astryx-richtext-code-header--corner .astryx-richtext-code-header__copy {
251
+ pointer-events: auto;
252
+ }
253
+
254
+ .astryx-richtext-code-header__title {
255
+ min-width: 0;
256
+ overflow: hidden;
257
+ text-overflow: ellipsis;
258
+ white-space: nowrap;
259
+ font-family: var(--astryx-font-family-code, ui-monospace, monospace);
260
+ font-size: var(--astryx-text-supporting-size, 0.75rem);
261
+ font-weight: var(--astryx-font-weight-medium, 500);
262
+ line-height: var(--astryx-text-supporting-leading, 1.5);
263
+ color: var(--astryx-code-syntax-comment, #6a6a6a);
264
+ }
265
+
266
+ .astryx-richtext-code-header__copy {
267
+ color: var(--astryx-code-syntax-comment, #6a6a6a);
268
+ }
269
+ }
@@ -0,0 +1,117 @@
1
+ @layer astryx.reset, astryx.tokens, astryx.base, astryx.components, astryx.overrides;
2
+
3
+ /*
4
+ * 编辑器的外框。边框、悬停、聚焦、状态色和 core 的 TextArea 用同一套变量,
5
+ * 所以放在表单里和其他输入框长得一样。
6
+ */
7
+ @layer astryx.components {
8
+ .astryx-richtext-editor {
9
+ /* 自己是一个新的容器边界,里面的工具栏不会继承外层 Section 的内边距。 */
10
+ --astryx-container-padding-inline-start: 0px;
11
+ --astryx-container-padding-inline-end: 0px;
12
+ --astryx-container-padding-block-start: 0px;
13
+ --astryx-container-padding-block-end: 0px;
14
+
15
+ box-sizing: border-box;
16
+ position: relative;
17
+ z-index: 1;
18
+ display: flex;
19
+ flex-direction: column;
20
+ align-items: stretch;
21
+ min-width: 0;
22
+ border: 1px solid var(--astryx-input-status-color, var(--astryx-input-border, #d4d4d4));
23
+ border-radius: var(--astryx-radius-element, 0.625rem);
24
+ color: var(--astryx-color-text-primary, #171717);
25
+ background: var(--astryx-input-background, #fff);
26
+ transition: border-color 130ms cubic-bezier(0.24, 1, 0.4, 1);
27
+ }
28
+
29
+ .astryx-richtext-editor[data-status='error'] { --astryx-input-status-color: var(--astryx-input-error, #e33f4a); }
30
+ .astryx-richtext-editor[data-status='warning'] { --astryx-input-status-color: var(--astryx-input-warning, #a67a00); }
31
+ .astryx-richtext-editor[data-status='success'] { --astryx-input-status-color: var(--astryx-input-success, #198100); }
32
+
33
+ @media (hover: hover) {
34
+ .astryx-richtext-editor:not([data-disabled='true']):hover:not(:focus-within) {
35
+ box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--astryx-input-status-color, var(--astryx-input-border, #d4d4d4)) 30%, transparent);
36
+ }
37
+ }
38
+
39
+ /* 聚焦样式和 core 的输入框(TextArea、BorderedControl)用同一套变量,换主题时一起变。 */
40
+ .astryx-richtext-editor:focus-within {
41
+ border-color: var(--astryx-input-status-color, var(--astryx-input-focus, #262626));
42
+ box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--astryx-input-status-color, var(--astryx-input-focus, #262626)) 15%, transparent);
43
+ }
44
+
45
+ /* 只有禁用才变淡:只读的编辑器内容保持原样不透明,仍能用键盘走到。 */
46
+ .astryx-richtext-editor[data-disabled='true'] {
47
+ opacity: 0.5;
48
+ cursor: default;
49
+ }
50
+
51
+ .astryx-richtext-editor__body {
52
+ box-sizing: border-box;
53
+ position: relative;
54
+ width: 100%;
55
+ padding: var(--astryx-spacing-1, 4px) var(--astryx-spacing-2, 8px);
56
+ }
57
+
58
+ .astryx-richtext-editor[data-size='lg'] .astryx-richtext-editor__body {
59
+ padding-block: var(--astryx-spacing-2, 8px);
60
+ }
61
+
62
+ .astryx-richtext-editor[data-with-toolbar] .astryx-richtext-editor__body {
63
+ border-block-start: 1px solid var(--astryx-color-border, #ebebeb);
64
+ }
65
+
66
+ .astryx-richtext-editor__root {
67
+ position: relative;
68
+ width: 100%;
69
+ font-family: var(--astryx-font-family-body, inherit);
70
+ font-size: var(--astryx-text-body-size, 0.875rem);
71
+ line-height: var(--astryx-text-body-leading, 1.4286);
72
+ }
73
+
74
+ /* iOS Safari 在聚焦的输入控件字号低于 16px 时会放大页面。只在触屏的 iOS 上抬到 16px。 */
75
+ @media (pointer: coarse) {
76
+ @supports (-webkit-touch-callout: none) {
77
+ .astryx-richtext-editor__root {
78
+ font-size: max(1rem, var(--astryx-text-body-size, 0.875rem));
79
+ }
80
+ }
81
+ }
82
+
83
+ .astryx-richtext-editor__content {
84
+ display: block;
85
+ box-sizing: border-box;
86
+ width: 100%;
87
+ min-height: var(--astryx-richtext-min-height, 4.5rem);
88
+ padding: 0;
89
+ border: 0;
90
+ outline: none;
91
+ color: var(--astryx-color-text-primary, #171717);
92
+ white-space: pre-wrap;
93
+ overflow-wrap: break-word;
94
+ }
95
+
96
+ .astryx-richtext-editor__placeholder {
97
+ position: absolute;
98
+ inset-block-start: 0;
99
+ inset-inline-start: 0;
100
+ pointer-events: none;
101
+ user-select: none;
102
+ color: var(--astryx-color-text-secondary, #525252);
103
+ }
104
+
105
+ .astryx-richtext-editor__counter {
106
+ display: flex;
107
+ justify-content: flex-end;
108
+ margin-block-start: var(--astryx-spacing-1, 4px);
109
+ font-family: var(--astryx-font-family-body, inherit);
110
+ font-size: var(--astryx-text-supporting-size, 0.75rem);
111
+ color: var(--astryx-color-text-secondary, #525252);
112
+ }
113
+
114
+ .astryx-richtext-editor__counter[data-over='true'] {
115
+ color: var(--astryx-color-error, #e33f4a);
116
+ }
117
+ }
@@ -0,0 +1,54 @@
1
+ @layer astryx.reset, astryx.tokens, astryx.base, astryx.components, astryx.overrides;
2
+
3
+ @layer astryx.components {
4
+ /*
5
+ * core 的 Toolbar 上下各有 8px 内边距。这条工具栏背景透明,往上下各缩进 4px,
6
+ * 控件和下面的编辑区之间就只剩 4px 的间隙。
7
+ */
8
+ .astryx-richtext-toolbar {
9
+ --astryx-section-padding-inline-start: var(--astryx-spacing-1, 4px);
10
+ --astryx-section-padding-inline-end: var(--astryx-spacing-1, 4px);
11
+ margin-block: calc(-1 * var(--astryx-spacing-1, 4px));
12
+ }
13
+
14
+ /* 放不下时这一行自己横向滚动,控件各自保持宽度,不被挤扁。 */
15
+ .astryx-richtext-toolbar__actions {
16
+ flex: 1 1 0%;
17
+ width: 0;
18
+ max-width: 100%;
19
+ min-width: 0;
20
+ overflow-x: auto;
21
+ overflow-y: hidden;
22
+ overscroll-behavior-x: contain;
23
+ scrollbar-width: thin;
24
+ }
25
+
26
+ /* 块格式下拉的字段可以收缩,会把标签挤成一条缝;放进一个不许收缩的槽里。 */
27
+ .astryx-richtext-toolbar__fixed {
28
+ display: flex;
29
+ flex-shrink: 0;
30
+ }
31
+
32
+ /* 竖分隔线默认高度是 100%,要父元素有确定高度;这里让它拉伸到整行高度。 */
33
+ .astryx-richtext-toolbar__divider {
34
+ align-self: stretch;
35
+ height: auto;
36
+ }
37
+
38
+ .astryx-richtext-toolbar__glyph {
39
+ display: inline-flex;
40
+ align-items: center;
41
+ justify-content: center;
42
+ }
43
+
44
+ /* 撤销、重做指向时间的前后,从右往左排版时要镜像。 */
45
+ [dir='rtl'] .astryx-richtext-toolbar__glyph[data-directional] {
46
+ transform: scaleX(-1);
47
+ }
48
+
49
+ .astryx-richtext-toolbar__text-glyph {
50
+ font-size: var(--astryx-text-supporting-size, 0.75rem);
51
+ font-weight: var(--astryx-font-weight-bold, 700);
52
+ font-variant-numeric: tabular-nums;
53
+ }
54
+ }
@@ -0,0 +1,23 @@
1
+ @layer astryx.reset, astryx.tokens, astryx.base, astryx.components, astryx.overrides;
2
+
3
+ @layer astryx.components {
4
+ /*
5
+ * 只读视图的根:叠在内容上的代码块标题栏和任务勾选框要相对它定位。
6
+ * 文字用文档的正文样式,和 core Markdown、编辑器一致;不设的话,主题没给字号的块
7
+ * (列表项、引用、表格单元格)会用宿主页面的字体。
8
+ */
9
+ .astryx-richtext-view {
10
+ position: relative;
11
+ width: 100%;
12
+ color: var(--astryx-color-text-primary, #171717);
13
+ font-family: var(--astryx-font-family-body, inherit);
14
+ font-size: var(--astryx-text-body-size, 0.875rem);
15
+ line-height: var(--astryx-text-body-leading, 1.4286);
16
+ }
17
+
18
+ .astryx-richtext-view__content {
19
+ outline: none;
20
+ white-space: pre-wrap;
21
+ overflow-wrap: break-word;
22
+ }
23
+ }