@atri-editor/core 0.1.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 +21 -0
- package/README.md +42 -0
- package/dist/AtriEditor.d.ts +192 -0
- package/dist/AtriEditor.d.ts.map +1 -0
- package/dist/AtriEditorElement.d.ts +84 -0
- package/dist/AtriEditorElement.d.ts.map +1 -0
- package/dist/ai/AICommandMenu.d.ts +59 -0
- package/dist/ai/AICommandMenu.d.ts.map +1 -0
- package/dist/ai/AIInterceptor.d.ts +39 -0
- package/dist/ai/AIInterceptor.d.ts.map +1 -0
- package/dist/ai/AIService.d.ts +42 -0
- package/dist/ai/AIService.d.ts.map +1 -0
- package/dist/ai/index.d.ts +5 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/core/CoreEditor.d.ts +100 -0
- package/dist/core/CoreEditor.d.ts.map +1 -0
- package/dist/core/ExtensionManager.d.ts +47 -0
- package/dist/core/ExtensionManager.d.ts.map +1 -0
- package/dist/core/I18nManager.d.ts +21 -0
- package/dist/core/I18nManager.d.ts.map +1 -0
- package/dist/core/MarkdownService.d.ts +42 -0
- package/dist/core/MarkdownService.d.ts.map +1 -0
- package/dist/core/ThemeManager.d.ts +30 -0
- package/dist/core/ThemeManager.d.ts.map +1 -0
- package/dist/core/ToolbarManager.d.ts +69 -0
- package/dist/core/ToolbarManager.d.ts.map +1 -0
- package/dist/core/bubble-toolbar.d.ts +38 -0
- package/dist/core/bubble-toolbar.d.ts.map +1 -0
- package/dist/core/icons.d.ts +6 -0
- package/dist/core/icons.d.ts.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/extensions/AtriImage.d.ts +2 -0
- package/dist/extensions/AtriImage.d.ts.map +1 -0
- package/dist/extensions/Attachment.d.ts +24 -0
- package/dist/extensions/Attachment.d.ts.map +1 -0
- package/dist/extensions/AttachmentLink.d.ts +19 -0
- package/dist/extensions/AttachmentLink.d.ts.map +1 -0
- package/dist/extensions/MediaFiles.d.ts +13 -0
- package/dist/extensions/MediaFiles.d.ts.map +1 -0
- package/dist/extensions/attachment-attrs.d.ts +29 -0
- package/dist/extensions/attachment-attrs.d.ts.map +1 -0
- package/dist/extensions/media.d.ts +10 -0
- package/dist/extensions/media.d.ts.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3489 -0
- package/dist/index.js.map +1 -0
- package/dist/media/InsertPanel.d.ts +59 -0
- package/dist/media/InsertPanel.d.ts.map +1 -0
- package/dist/media/MediaRuntime.d.ts +113 -0
- package/dist/media/MediaRuntime.d.ts.map +1 -0
- package/dist/media/MediaStatusStrip.d.ts +20 -0
- package/dist/media/MediaStatusStrip.d.ts.map +1 -0
- package/dist/media/Uploader.d.ts +12 -0
- package/dist/media/Uploader.d.ts.map +1 -0
- package/dist/media/file-policy.d.ts +34 -0
- package/dist/media/file-policy.d.ts.map +1 -0
- package/dist/media/insert-position.d.ts +13 -0
- package/dist/media/insert-position.d.ts.map +1 -0
- package/dist/style.css +578 -0
- package/dist/types/ai.d.ts +76 -0
- package/dist/types/ai.d.ts.map +1 -0
- package/dist/types/editor.d.ts +140 -0
- package/dist/types/editor.d.ts.map +1 -0
- package/dist/types/events.d.ts +26 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/extension.d.ts +61 -0
- package/dist/types/extension.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/markdown.d.ts +29 -0
- package/dist/types/markdown.d.ts.map +1 -0
- package/dist/types/media.d.ts +149 -0
- package/dist/types/media.d.ts.map +1 -0
- package/dist/utils/dom.d.ts +16 -0
- package/dist/utils/dom.d.ts.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/markdown.d.ts +14 -0
- package/dist/utils/markdown.d.ts.map +1 -0
- package/dist/utils/selection.d.ts +17 -0
- package/dist/utils/selection.d.ts.map +1 -0
- package/package.json +63 -0
- package/styles.d.ts +6 -0
package/dist/style.css
ADDED
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
.atri-editor-content [data-resize-wrapper] {
|
|
2
|
+
width: fit-content;
|
|
3
|
+
max-width: 100%;
|
|
4
|
+
line-height: 0;
|
|
5
|
+
}
|
|
6
|
+
.atri-editor-content [data-resize-handle] {
|
|
7
|
+
width: 10px;
|
|
8
|
+
height: 10px;
|
|
9
|
+
background-color: var(--atri-bg-color);
|
|
10
|
+
border: 1px solid var(--atri-border-color-hover);
|
|
11
|
+
border-radius: 50%;
|
|
12
|
+
transform: translate(-50%, -50%);
|
|
13
|
+
opacity: 0;
|
|
14
|
+
transition: opacity 0.2s ease;
|
|
15
|
+
}
|
|
16
|
+
.atri-editor-content [data-resize-wrapper]:hover [data-resize-handle],
|
|
17
|
+
.atri-editor-content .ProseMirror-selectednode [data-resize-handle] {
|
|
18
|
+
opacity: 1;
|
|
19
|
+
}
|
|
20
|
+
.atri-editor-content .ProseMirror-selectednode[data-resize-container] > [data-resize-wrapper],
|
|
21
|
+
.atri-editor-content .atri-attachment.ProseMirror-selectednode {
|
|
22
|
+
outline: 2px solid var(--atri-color-primary);
|
|
23
|
+
outline-offset: 2px;
|
|
24
|
+
}
|
|
25
|
+
.atri-editor-content [data-resize-handle=top-left],
|
|
26
|
+
.atri-editor-content [data-resize-handle=bottom-right] {
|
|
27
|
+
cursor: nwse-resize;
|
|
28
|
+
}
|
|
29
|
+
.atri-editor-content [data-resize-handle=top-right],
|
|
30
|
+
.atri-editor-content [data-resize-handle=bottom-left] {
|
|
31
|
+
cursor: nesw-resize;
|
|
32
|
+
}
|
|
33
|
+
.atri-editor-content [data-resize-handle=top-right],
|
|
34
|
+
.atri-editor-content [data-resize-handle=bottom-right] {
|
|
35
|
+
transform: translate(50%, -50%);
|
|
36
|
+
}
|
|
37
|
+
.atri-editor-content [data-resize-handle=bottom-left] {
|
|
38
|
+
transform: translate(-50%, 50%);
|
|
39
|
+
}
|
|
40
|
+
.atri-editor-content [data-resize-handle=bottom-right] {
|
|
41
|
+
transform: translate(50%, 50%);
|
|
42
|
+
}
|
|
43
|
+
.atri-editor-content .atri-attachment {
|
|
44
|
+
position: relative;
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
gap: 8px;
|
|
48
|
+
margin: 12px 0;
|
|
49
|
+
padding: 8px 12px;
|
|
50
|
+
background-color: var(--atri-bg-color-secondary);
|
|
51
|
+
border: 1px solid var(--atri-border-color);
|
|
52
|
+
border-radius: 4px;
|
|
53
|
+
user-select: none;
|
|
54
|
+
}
|
|
55
|
+
.atri-editor-content .atri-attachment[data-atri-upload-status=uploading] {
|
|
56
|
+
border-color: var(--atri-color-primary);
|
|
57
|
+
}
|
|
58
|
+
.atri-editor-content .atri-attachment[data-atri-upload-status=error] {
|
|
59
|
+
border-color: var(--atri-color-error);
|
|
60
|
+
}
|
|
61
|
+
.atri-editor-content .atri-attachment-icon {
|
|
62
|
+
flex: none;
|
|
63
|
+
width: 24px;
|
|
64
|
+
height: 24px;
|
|
65
|
+
background-color: var(--atri-text-color-secondary);
|
|
66
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z'/%3E%3Cpath d='M14 2v4a2 2 0 0 0 2 2h4'/%3E%3Cpath d='M10 9H8'/%3E%3Cpath d='M16 13H8'/%3E%3Cpath d='M16 17H8'/%3E%3C/svg%3E") center/contain no-repeat;
|
|
67
|
+
}
|
|
68
|
+
.atri-editor-content .atri-attachment-body {
|
|
69
|
+
display: flex;
|
|
70
|
+
flex: 1;
|
|
71
|
+
flex-direction: column;
|
|
72
|
+
gap: 2px;
|
|
73
|
+
min-width: 0;
|
|
74
|
+
}
|
|
75
|
+
.atri-editor-content .atri-attachment-name {
|
|
76
|
+
min-width: 0;
|
|
77
|
+
overflow-wrap: anywhere;
|
|
78
|
+
color: var(--atri-text-color);
|
|
79
|
+
}
|
|
80
|
+
.atri-editor-content .atri-attachment-size {
|
|
81
|
+
font-size: 12px;
|
|
82
|
+
color: var(--atri-text-color-secondary);
|
|
83
|
+
}
|
|
84
|
+
.atri-editor-content .atri-attachment-progress {
|
|
85
|
+
display: block;
|
|
86
|
+
position: absolute;
|
|
87
|
+
left: 12px;
|
|
88
|
+
right: 12px;
|
|
89
|
+
bottom: 3px;
|
|
90
|
+
height: 2px;
|
|
91
|
+
border-radius: 1px;
|
|
92
|
+
background-color: var(--atri-border-color);
|
|
93
|
+
overflow: hidden;
|
|
94
|
+
}
|
|
95
|
+
.atri-editor-content .atri-attachment-progress-bar {
|
|
96
|
+
display: block;
|
|
97
|
+
width: 40%;
|
|
98
|
+
height: 100%;
|
|
99
|
+
background-color: var(--atri-color-primary);
|
|
100
|
+
animation: atri-upload-indeterminate 1.1s ease-in-out infinite;
|
|
101
|
+
}
|
|
102
|
+
.atri-editor-content .atri-attachment[data-atri-upload-progress] .atri-attachment-progress-bar {
|
|
103
|
+
width: var(--atri-upload-progress);
|
|
104
|
+
animation: none;
|
|
105
|
+
}
|
|
106
|
+
.atri-editor-content .atri-attachment[data-atri-upload-status=error] .atri-attachment-progress-bar {
|
|
107
|
+
width: 100%;
|
|
108
|
+
transform: none;
|
|
109
|
+
animation: none;
|
|
110
|
+
background-color: var(--atri-color-error);
|
|
111
|
+
}
|
|
112
|
+
.atri-editor-content img[data-atri-upload-status=uploading] {
|
|
113
|
+
opacity: 0.55;
|
|
114
|
+
}
|
|
115
|
+
.atri-editor-content img[data-atri-upload-status=error] {
|
|
116
|
+
outline: 1px solid var(--atri-color-error);
|
|
117
|
+
opacity: 0.7;
|
|
118
|
+
}
|
|
119
|
+
.atri-editor-content .atri-attachment-link {
|
|
120
|
+
display: inline-flex;
|
|
121
|
+
align-items: center;
|
|
122
|
+
gap: 4px;
|
|
123
|
+
color: var(--atri-color-primary);
|
|
124
|
+
text-decoration: underline;
|
|
125
|
+
cursor: pointer;
|
|
126
|
+
user-select: none;
|
|
127
|
+
}
|
|
128
|
+
.atri-editor-content .atri-attachment-link .atri-attachment-icon {
|
|
129
|
+
width: 1em;
|
|
130
|
+
height: 1em;
|
|
131
|
+
background-color: currentColor;
|
|
132
|
+
}
|
|
133
|
+
.atri-editor-content .atri-attachment-link[data-atri-upload-status=uploading] {
|
|
134
|
+
opacity: 0.55;
|
|
135
|
+
}
|
|
136
|
+
.atri-editor-content .atri-attachment-link[data-atri-upload-status=error] {
|
|
137
|
+
color: var(--atri-color-error);
|
|
138
|
+
outline: 1px solid var(--atri-color-error);
|
|
139
|
+
}
|
|
140
|
+
.atri-editor-content .atri-attachment-link.ProseMirror-selectednode {
|
|
141
|
+
outline: 2px solid var(--atri-color-primary);
|
|
142
|
+
outline-offset: 1px;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@keyframes atri-upload-indeterminate {
|
|
146
|
+
from {
|
|
147
|
+
transform: translateX(-100%);
|
|
148
|
+
}
|
|
149
|
+
to {
|
|
150
|
+
transform: translateX(250%);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
.atri-media-panel {
|
|
154
|
+
position: fixed;
|
|
155
|
+
z-index: 1000;
|
|
156
|
+
display: flex;
|
|
157
|
+
flex-direction: column;
|
|
158
|
+
gap: 8px;
|
|
159
|
+
min-width: 260px;
|
|
160
|
+
padding: 12px;
|
|
161
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
162
|
+
font-size: 14px;
|
|
163
|
+
color: var(--atri-text-color);
|
|
164
|
+
background-color: var(--atri-bg-color);
|
|
165
|
+
border: 1px solid var(--atri-border-color);
|
|
166
|
+
border-radius: 8px;
|
|
167
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
|
|
168
|
+
box-sizing: border-box;
|
|
169
|
+
}
|
|
170
|
+
.atri-media-panel *,
|
|
171
|
+
.atri-media-panel *::before,
|
|
172
|
+
.atri-media-panel *::after {
|
|
173
|
+
box-sizing: border-box;
|
|
174
|
+
}
|
|
175
|
+
.atri-media-panel input {
|
|
176
|
+
width: 100%;
|
|
177
|
+
padding: 4px 8px;
|
|
178
|
+
font-family: inherit;
|
|
179
|
+
font-size: inherit;
|
|
180
|
+
color: var(--atri-text-color);
|
|
181
|
+
background-color: var(--atri-bg-color);
|
|
182
|
+
border: 1px solid var(--atri-border-color);
|
|
183
|
+
border-radius: 4px;
|
|
184
|
+
transition: all 0.2s ease;
|
|
185
|
+
}
|
|
186
|
+
.atri-media-panel input::placeholder {
|
|
187
|
+
color: var(--atri-text-color-disabled);
|
|
188
|
+
}
|
|
189
|
+
.atri-media-panel input:focus {
|
|
190
|
+
outline: none;
|
|
191
|
+
border-color: var(--atri-border-color-hover);
|
|
192
|
+
}
|
|
193
|
+
.atri-media-panel .atri-media-panel-file {
|
|
194
|
+
display: none;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.atri-media-panel-drop {
|
|
198
|
+
display: flex;
|
|
199
|
+
align-items: center;
|
|
200
|
+
justify-content: center;
|
|
201
|
+
gap: 4px;
|
|
202
|
+
padding: 12px;
|
|
203
|
+
color: var(--atri-text-color-secondary);
|
|
204
|
+
text-align: center;
|
|
205
|
+
border: 1px dashed var(--atri-border-color);
|
|
206
|
+
border-radius: 4px;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.atri-media-panel-browse,
|
|
210
|
+
.atri-media-panel-insert {
|
|
211
|
+
padding: 4px 12px;
|
|
212
|
+
font-family: inherit;
|
|
213
|
+
font-size: 12px;
|
|
214
|
+
border: 1px solid var(--atri-border-color);
|
|
215
|
+
border-radius: 4px;
|
|
216
|
+
background-color: var(--atri-bg-color-secondary);
|
|
217
|
+
color: var(--atri-text-color);
|
|
218
|
+
cursor: pointer;
|
|
219
|
+
transition: all 0.2s ease;
|
|
220
|
+
}
|
|
221
|
+
.atri-media-panel-browse:hover,
|
|
222
|
+
.atri-media-panel-insert:hover {
|
|
223
|
+
background-color: var(--atri-bg-color-hover);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.atri-media-panel-insert {
|
|
227
|
+
border-color: var(--atri-color-primary);
|
|
228
|
+
background-color: var(--atri-color-primary);
|
|
229
|
+
color: var(--atri-bg-color);
|
|
230
|
+
}
|
|
231
|
+
.atri-media-panel-insert:hover {
|
|
232
|
+
background-color: var(--atri-color-primary-hover);
|
|
233
|
+
border-color: var(--atri-color-primary-hover);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.atri-editor .atri-media-status {
|
|
237
|
+
position: absolute;
|
|
238
|
+
right: 12px;
|
|
239
|
+
bottom: 12px;
|
|
240
|
+
z-index: 1000;
|
|
241
|
+
display: flex;
|
|
242
|
+
align-items: center;
|
|
243
|
+
gap: 8px;
|
|
244
|
+
padding: 4px 8px;
|
|
245
|
+
font-size: 12px;
|
|
246
|
+
background-color: var(--atri-bg-color);
|
|
247
|
+
border: 1px solid var(--atri-color-primary);
|
|
248
|
+
border-radius: 4px;
|
|
249
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
|
|
250
|
+
}
|
|
251
|
+
.atri-editor .atri-media-status[hidden] {
|
|
252
|
+
display: none;
|
|
253
|
+
}
|
|
254
|
+
.atri-editor .atri-media-status[data-atri-media-status=error] {
|
|
255
|
+
border-color: var(--atri-color-error);
|
|
256
|
+
}
|
|
257
|
+
.atri-editor .atri-media-status[data-atri-media-status=error] .atri-media-status-text {
|
|
258
|
+
color: var(--atri-color-error);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.atri-media-status-text {
|
|
262
|
+
display: inline-flex;
|
|
263
|
+
gap: 12px;
|
|
264
|
+
color: var(--atri-color-primary);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.atri-media-status-retry {
|
|
268
|
+
padding: 0 8px;
|
|
269
|
+
font-family: inherit;
|
|
270
|
+
font-size: inherit;
|
|
271
|
+
border: 1px solid var(--atri-color-error);
|
|
272
|
+
border-radius: 4px;
|
|
273
|
+
background-color: var(--atri-bg-color);
|
|
274
|
+
color: var(--atri-color-error);
|
|
275
|
+
cursor: pointer;
|
|
276
|
+
transition: all 0.2s ease;
|
|
277
|
+
}
|
|
278
|
+
.atri-media-status-retry:hover {
|
|
279
|
+
background-color: var(--atri-color-error);
|
|
280
|
+
color: var(--atri-bg-color);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
:root {
|
|
284
|
+
--atri-color-primary: #1890ff;
|
|
285
|
+
--atri-color-primary-hover: #40a9ff;
|
|
286
|
+
--atri-color-primary-active: #096dd9;
|
|
287
|
+
--atri-color-success: #52c41a;
|
|
288
|
+
--atri-color-warning: #faad14;
|
|
289
|
+
--atri-color-error: #ff4d4f;
|
|
290
|
+
--atri-bg-color: #ffffff;
|
|
291
|
+
--atri-bg-color-secondary: #f5f5f5;
|
|
292
|
+
--atri-bg-color-hover: #e8e8e8;
|
|
293
|
+
--atri-text-color: #333333;
|
|
294
|
+
--atri-text-color-secondary: #666666;
|
|
295
|
+
--atri-text-color-disabled: #999999;
|
|
296
|
+
--atri-border-color: #d9d9d9;
|
|
297
|
+
--atri-border-color-hover: #40a9ff;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.atri-theme-dark {
|
|
301
|
+
--atri-bg-color: #1f1f1f;
|
|
302
|
+
--atri-bg-color-secondary: #2d2d2d;
|
|
303
|
+
--atri-bg-color-hover: #3d3d3d;
|
|
304
|
+
--atri-text-color: #e8e8e8;
|
|
305
|
+
--atri-text-color-secondary: #a8a8a8;
|
|
306
|
+
--atri-text-color-disabled: #666666;
|
|
307
|
+
--atri-border-color: #434343;
|
|
308
|
+
--atri-border-color-hover: #1890ff;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.atri-editor {
|
|
312
|
+
position: relative;
|
|
313
|
+
width: 100%;
|
|
314
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
315
|
+
font-size: 14px;
|
|
316
|
+
line-height: 1.6;
|
|
317
|
+
color: var(--atri-text-color);
|
|
318
|
+
background-color: var(--atri-bg-color);
|
|
319
|
+
border: 1px solid var(--atri-border-color);
|
|
320
|
+
border-radius: 4px;
|
|
321
|
+
box-sizing: border-box;
|
|
322
|
+
}
|
|
323
|
+
.atri-editor *,
|
|
324
|
+
.atri-editor *::before,
|
|
325
|
+
.atri-editor *::after {
|
|
326
|
+
box-sizing: border-box;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.atri-editor-toolbar {
|
|
330
|
+
display: flex;
|
|
331
|
+
flex-wrap: wrap;
|
|
332
|
+
align-items: center;
|
|
333
|
+
gap: 2px;
|
|
334
|
+
padding: 4px 8px;
|
|
335
|
+
border-bottom: 1px solid var(--atri-border-color);
|
|
336
|
+
background-color: var(--atri-bg-color-secondary);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.atri-editor-toolbar-btn {
|
|
340
|
+
display: flex;
|
|
341
|
+
align-items: center;
|
|
342
|
+
justify-content: center;
|
|
343
|
+
width: 32px;
|
|
344
|
+
height: 32px;
|
|
345
|
+
padding: 0;
|
|
346
|
+
border: none;
|
|
347
|
+
border-radius: 4px;
|
|
348
|
+
background: transparent;
|
|
349
|
+
color: var(--atri-text-color);
|
|
350
|
+
cursor: pointer;
|
|
351
|
+
transition: all 0.2s ease;
|
|
352
|
+
}
|
|
353
|
+
.atri-editor-toolbar-btn:hover {
|
|
354
|
+
background-color: var(--atri-bg-color-hover);
|
|
355
|
+
}
|
|
356
|
+
.atri-editor-toolbar-btn.active {
|
|
357
|
+
background-color: var(--atri-color-primary);
|
|
358
|
+
color: white;
|
|
359
|
+
}
|
|
360
|
+
.atri-editor-toolbar-btn:disabled {
|
|
361
|
+
opacity: 0.4;
|
|
362
|
+
cursor: not-allowed;
|
|
363
|
+
}
|
|
364
|
+
.atri-editor-toolbar-btn svg {
|
|
365
|
+
width: 18px;
|
|
366
|
+
height: 18px;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.atri-editor-toolbar-separator {
|
|
370
|
+
width: 1px;
|
|
371
|
+
height: 20px;
|
|
372
|
+
background-color: var(--atri-border-color);
|
|
373
|
+
margin: 0 4px;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
.atri-editor-bubble-toolbar {
|
|
377
|
+
position: absolute;
|
|
378
|
+
display: flex;
|
|
379
|
+
align-items: center;
|
|
380
|
+
gap: 2px;
|
|
381
|
+
padding: 2px 4px;
|
|
382
|
+
border: 1px solid var(--atri-border-color);
|
|
383
|
+
border-radius: 8px;
|
|
384
|
+
background-color: var(--atri-bg-color);
|
|
385
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
386
|
+
z-index: 1000;
|
|
387
|
+
}
|
|
388
|
+
.atri-editor-bubble-toolbar .atri-editor-bubble-group {
|
|
389
|
+
display: none;
|
|
390
|
+
align-items: center;
|
|
391
|
+
gap: 2px;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.atri-editor-bubble-toolbar[data-atri-bubble-mode=text] .atri-editor-bubble-group[data-atri-bubble-group=text],
|
|
395
|
+
.atri-editor-bubble-toolbar[data-atri-bubble-mode=node] .atri-editor-bubble-group[data-atri-bubble-group=node] {
|
|
396
|
+
display: flex;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
.atri-editor-bubble-toolbar[data-atri-bubble-node=image] [data-toolbar-item=attachmentDisplay] {
|
|
400
|
+
display: none;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
.atri-editor-content-wrapper {
|
|
404
|
+
position: relative;
|
|
405
|
+
min-height: 200px;
|
|
406
|
+
padding: 12px;
|
|
407
|
+
overflow-y: auto;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
.atri-editor-content {
|
|
411
|
+
outline: none;
|
|
412
|
+
min-height: 150px;
|
|
413
|
+
}
|
|
414
|
+
.atri-editor-content:focus {
|
|
415
|
+
outline: none;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
.atri-editor-content > .is-editor-empty:not([data-placeholder=""])::before {
|
|
419
|
+
content: attr(data-placeholder);
|
|
420
|
+
float: left;
|
|
421
|
+
color: var(--atri-text-color-disabled);
|
|
422
|
+
pointer-events: none;
|
|
423
|
+
height: 0;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
.atri-editor-content h1 {
|
|
427
|
+
font-size: 2em;
|
|
428
|
+
font-weight: 600;
|
|
429
|
+
margin: 0.67em 0;
|
|
430
|
+
}
|
|
431
|
+
.atri-editor-content h2 {
|
|
432
|
+
font-size: 1.5em;
|
|
433
|
+
font-weight: 600;
|
|
434
|
+
margin: 0.75em 0;
|
|
435
|
+
}
|
|
436
|
+
.atri-editor-content h3 {
|
|
437
|
+
font-size: 1.25em;
|
|
438
|
+
font-weight: 600;
|
|
439
|
+
margin: 0.83em 0;
|
|
440
|
+
}
|
|
441
|
+
.atri-editor-content h4 {
|
|
442
|
+
font-size: 1em;
|
|
443
|
+
font-weight: 600;
|
|
444
|
+
margin: 1em 0;
|
|
445
|
+
}
|
|
446
|
+
.atri-editor-content p {
|
|
447
|
+
margin: 0.5em 0;
|
|
448
|
+
}
|
|
449
|
+
.atri-editor-content ul,
|
|
450
|
+
.atri-editor-content ol {
|
|
451
|
+
padding-left: 1.5em;
|
|
452
|
+
margin: 0.5em 0;
|
|
453
|
+
}
|
|
454
|
+
.atri-editor-content li {
|
|
455
|
+
margin: 0.25em 0;
|
|
456
|
+
}
|
|
457
|
+
.atri-editor-content blockquote {
|
|
458
|
+
border-left: 4px solid var(--atri-border-color);
|
|
459
|
+
padding-left: 1em;
|
|
460
|
+
margin: 0.5em 0;
|
|
461
|
+
color: var(--atri-text-color-secondary);
|
|
462
|
+
}
|
|
463
|
+
.atri-editor-content code {
|
|
464
|
+
background-color: var(--atri-bg-color-secondary);
|
|
465
|
+
border-radius: 3px;
|
|
466
|
+
padding: 0.2em 0.4em;
|
|
467
|
+
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
|
|
468
|
+
font-size: 0.9em;
|
|
469
|
+
}
|
|
470
|
+
.atri-editor-content pre {
|
|
471
|
+
background-color: var(--atri-bg-color-secondary);
|
|
472
|
+
border-radius: 4px;
|
|
473
|
+
padding: 1em;
|
|
474
|
+
overflow-x: auto;
|
|
475
|
+
margin: 0.5em 0;
|
|
476
|
+
}
|
|
477
|
+
.atri-editor-content pre code {
|
|
478
|
+
background: none;
|
|
479
|
+
padding: 0;
|
|
480
|
+
}
|
|
481
|
+
.atri-editor-content a {
|
|
482
|
+
color: var(--atri-color-primary);
|
|
483
|
+
text-decoration: none;
|
|
484
|
+
}
|
|
485
|
+
.atri-editor-content a:hover {
|
|
486
|
+
text-decoration: underline;
|
|
487
|
+
}
|
|
488
|
+
.atri-editor-content img {
|
|
489
|
+
max-width: 100%;
|
|
490
|
+
height: auto;
|
|
491
|
+
}
|
|
492
|
+
.atri-editor-content table {
|
|
493
|
+
border-collapse: collapse;
|
|
494
|
+
width: 100%;
|
|
495
|
+
margin: 0.5em 0;
|
|
496
|
+
}
|
|
497
|
+
.atri-editor-content table td,
|
|
498
|
+
.atri-editor-content table th {
|
|
499
|
+
border: 1px solid var(--atri-border-color);
|
|
500
|
+
padding: 8px 12px;
|
|
501
|
+
text-align: left;
|
|
502
|
+
}
|
|
503
|
+
.atri-editor-content table th {
|
|
504
|
+
background-color: var(--atri-bg-color-secondary);
|
|
505
|
+
font-weight: 600;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
.atri-editor-content ul[data-type=taskList] {
|
|
509
|
+
list-style: none;
|
|
510
|
+
padding-left: 0;
|
|
511
|
+
}
|
|
512
|
+
.atri-editor-content ul[data-type=taskList] li {
|
|
513
|
+
display: flex;
|
|
514
|
+
align-items: flex-start;
|
|
515
|
+
}
|
|
516
|
+
.atri-editor-content ul[data-type=taskList] li label {
|
|
517
|
+
margin-right: 8px;
|
|
518
|
+
}
|
|
519
|
+
.atri-editor-content ul[data-type=taskList] li label input[type=checkbox] {
|
|
520
|
+
margin-top: 0.25em;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.atri-editor-content ::selection {
|
|
524
|
+
background-color: rgba(24, 144, 255, 0.2);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
.atri-ai-command-menu {
|
|
528
|
+
position: fixed;
|
|
529
|
+
z-index: 1000;
|
|
530
|
+
background-color: var(--atri-bg-color);
|
|
531
|
+
border: 1px solid var(--atri-border-color);
|
|
532
|
+
border-radius: 8px;
|
|
533
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
534
|
+
padding: 4px;
|
|
535
|
+
min-width: 200px;
|
|
536
|
+
max-height: 300px;
|
|
537
|
+
overflow-y: auto;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.atri-ai-command-menu-item {
|
|
541
|
+
display: flex;
|
|
542
|
+
align-items: center;
|
|
543
|
+
padding: 8px 12px;
|
|
544
|
+
border-radius: 4px;
|
|
545
|
+
cursor: pointer;
|
|
546
|
+
transition: all 0.2s ease;
|
|
547
|
+
}
|
|
548
|
+
.atri-ai-command-menu-item:hover, .atri-ai-command-menu-item.active {
|
|
549
|
+
background-color: var(--atri-bg-color-hover);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.atri-ai-command-menu-icon {
|
|
553
|
+
display: flex;
|
|
554
|
+
align-items: center;
|
|
555
|
+
justify-content: center;
|
|
556
|
+
width: 24px;
|
|
557
|
+
height: 24px;
|
|
558
|
+
margin-right: 8px;
|
|
559
|
+
color: var(--atri-text-color-secondary);
|
|
560
|
+
}
|
|
561
|
+
.atri-ai-command-menu-icon svg {
|
|
562
|
+
width: 16px;
|
|
563
|
+
height: 16px;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
.atri-ai-command-menu-name {
|
|
567
|
+
flex: 1;
|
|
568
|
+
font-size: 14px;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
@media (max-width: 768px) {
|
|
572
|
+
.atri-editor {
|
|
573
|
+
border-radius: 0;
|
|
574
|
+
}
|
|
575
|
+
.atri-editor-content-wrapper {
|
|
576
|
+
padding: 8px;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI 功能定义
|
|
3
|
+
*/
|
|
4
|
+
export interface AtriAIFunction {
|
|
5
|
+
/** 功能唯一标识 */
|
|
6
|
+
id: string;
|
|
7
|
+
/** 显示名称 */
|
|
8
|
+
name: string;
|
|
9
|
+
/** hover 提示描述 */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** 图标:SVG 标记字符串,按原样插入,需来自可信配置 */
|
|
12
|
+
icon?: string;
|
|
13
|
+
/** 预设 Prompt 模板,支持 {selection} {cursor} {document} 及随 scope 解析的 {content} */
|
|
14
|
+
prompt?: string;
|
|
15
|
+
/** 作用域:决定 {content} 取选区、光标前文还是全文;省略时 {content} 为「选区,否则光标前文」 */
|
|
16
|
+
scope?: 'selection' | 'cursor' | 'document';
|
|
17
|
+
/** 输出模式 */
|
|
18
|
+
outputMode?: 'replace' | 'insert' | 'append';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* AI 请求上下文
|
|
22
|
+
*/
|
|
23
|
+
export interface AIRequestContext {
|
|
24
|
+
/** 触发的功能 ID */
|
|
25
|
+
functionId: string;
|
|
26
|
+
/** 本次功能的作用域(决定 prompt 中 {content} 的取值) */
|
|
27
|
+
scope?: AtriAIFunction['scope'];
|
|
28
|
+
/** 当前选区文本 */
|
|
29
|
+
selection: string;
|
|
30
|
+
/** 光标前文本 */
|
|
31
|
+
cursorContext: string;
|
|
32
|
+
/** 完整文档内容(纯文本) */
|
|
33
|
+
document: string;
|
|
34
|
+
/** 预设 prompt */
|
|
35
|
+
prompt?: string;
|
|
36
|
+
/** 自定义扩展参数 */
|
|
37
|
+
extra?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* AI 响应结构
|
|
41
|
+
*/
|
|
42
|
+
export interface AIResponse {
|
|
43
|
+
/** 输出内容 */
|
|
44
|
+
content: string;
|
|
45
|
+
/** 内容类型 */
|
|
46
|
+
contentType?: 'html' | 'text' | 'markdown';
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* AI 拦截器
|
|
50
|
+
*/
|
|
51
|
+
export interface AtriAIInterceptors {
|
|
52
|
+
/** 请求前拦截,返回 false 取消请求 */
|
|
53
|
+
beforePost?: (context: AIRequestContext) => AIRequestContext | false;
|
|
54
|
+
/** 请求后拦截,可修改原始响应 */
|
|
55
|
+
afterPost?: (response: AIResponse, context: AIRequestContext) => AIResponse;
|
|
56
|
+
/** 渲染前拦截(在 Markdown 转换之前执行) */
|
|
57
|
+
beforeRender?: (content: string, context: AIRequestContext) => string;
|
|
58
|
+
/** 渲染后回调 */
|
|
59
|
+
afterRender?: (content: string, context: AIRequestContext) => void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* AI 配置
|
|
63
|
+
*/
|
|
64
|
+
export interface AtriAIConfig {
|
|
65
|
+
/** AI 功能列表 */
|
|
66
|
+
functions: AtriAIFunction[];
|
|
67
|
+
/** 请求端点,开发者完全控制网络请求 */
|
|
68
|
+
requestEndpoint: (context: AIRequestContext) => Promise<AIResponse>;
|
|
69
|
+
/** 拦截器链 */
|
|
70
|
+
interceptors?: AtriAIInterceptors;
|
|
71
|
+
/** 自动将 AI 返回的 Markdown 转换为 HTML(默认 true) */
|
|
72
|
+
autoTranslateMarkdownToHTML?: boolean;
|
|
73
|
+
/** 全局错误处理 */
|
|
74
|
+
onError?: (error: Error, context: AIRequestContext) => void;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=ai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../src/types/ai.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,aAAa;IACb,EAAE,EAAE,MAAM,CAAC;IACX,WAAW;IACX,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC;IAC5C,WAAW;IACX,UAAU,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,eAAe;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAChC,aAAa;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,WAAW;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW;IACX,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,0BAA0B;IAC1B,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,gBAAgB,GAAG,KAAK,CAAC;IACrE,oBAAoB;IACpB,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,KAAK,UAAU,CAAC;IAC5E,+BAA+B;IAC/B,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,KAAK,MAAM,CAAC;IACtE,YAAY;IACZ,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;CACpE;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,cAAc;IACd,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,uBAAuB;IACvB,eAAe,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACpE,WAAW;IACX,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,4CAA4C;IAC5C,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,aAAa;IACb,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC7D"}
|