kyle-editor 1.0.0 → 1.0.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 +0 -57
- package/dist/keditor.cjs +2 -1
- package/dist/keditor.es.js +2 -1
- package/dist/keditor.umd.js +2 -1
- package/package.json +2 -4
- package/docs/api.md +0 -223
- package/docs/index.md +0 -8
- package/docs/integration.md +0 -296
- package/docs/npm-publish.md +0 -412
- package/docs/upload-adapter.md +0 -186
- package/src/core/commands.js +0 -311
- package/src/core/editor.js +0 -795
- package/src/core/format.js +0 -64
- package/src/core/history.js +0 -92
- package/src/core/icons.js +0 -49
- package/src/core/paste.js +0 -140
- package/src/core/sanitize.js +0 -182
- package/src/core/selection.js +0 -129
- package/src/core/toolbar.js +0 -465
- package/src/core/utils.js +0 -95
- package/src/index.js +0 -33
- package/src/media/media.js +0 -331
- package/src/ui/bubble.js +0 -270
- package/src/ui/popover.js +0 -507
- package/src/ui/preview.js +0 -59
- package/src/ui/source.js +0 -97
- package/src/ui/styles.js +0 -447
- package/src/ui/toast.js +0 -56
- package/src/upload/adapters.js +0 -206
- package/src/upload/chunk-uploader.js +0 -193
- package/src/upload/fingerprint.js +0 -38
- package/src/vue/index.js +0 -104
package/src/ui/styles.js
DELETED
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
/** 编辑器样式:随 JS 注入,单文件 <script> 引入即可拥有完整外观 */
|
|
2
|
-
|
|
3
|
-
export const CSS = `
|
|
4
|
-
.ke, .ke * { box-sizing: border-box; }
|
|
5
|
-
.ke {
|
|
6
|
-
--ke-primary: #07c160;
|
|
7
|
-
--ke-primary-weak: #eafaf1;
|
|
8
|
-
--ke-text: #3f3f3f;
|
|
9
|
-
--ke-muted: #8a8f99;
|
|
10
|
-
--ke-line: #e6e8eb;
|
|
11
|
-
--ke-line-weak: #f0f1f3;
|
|
12
|
-
--ke-bg: #f6f7f9;
|
|
13
|
-
--ke-radius: 10px;
|
|
14
|
-
--ke-paper: 677px;
|
|
15
|
-
--ke-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
|
|
16
|
-
font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
|
17
|
-
color: var(--ke-text);
|
|
18
|
-
background: var(--ke-bg);
|
|
19
|
-
position: relative;
|
|
20
|
-
border: 1px solid var(--ke-line);
|
|
21
|
-
border-radius: var(--ke-radius);
|
|
22
|
-
overflow: hidden;
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-direction: column;
|
|
25
|
-
font-size: 14px;
|
|
26
|
-
-webkit-font-smoothing: antialiased;
|
|
27
|
-
}
|
|
28
|
-
.ke[hidden] { display: none; }
|
|
29
|
-
.ke-is-fullscreen { position: fixed; inset: 0; z-index: 9998; border-radius: 0; }
|
|
30
|
-
|
|
31
|
-
/* ---------------- Toolbar ---------------- */
|
|
32
|
-
.ke-tb {
|
|
33
|
-
position: sticky; top: 0; z-index: 5;
|
|
34
|
-
display: flex; align-items: center; gap: 2px; flex-wrap: nowrap;
|
|
35
|
-
padding: 6px 10px 5px;
|
|
36
|
-
background: #fff;
|
|
37
|
-
border-bottom: 1px solid var(--ke-line);
|
|
38
|
-
overflow-x: auto;
|
|
39
|
-
overflow-y: hidden;
|
|
40
|
-
overscroll-behavior-x: contain;
|
|
41
|
-
-webkit-overflow-scrolling: touch;
|
|
42
|
-
/* 滚动条常显:静止时也能一眼看出「还有更多工具」 */
|
|
43
|
-
scrollbar-width: thin;
|
|
44
|
-
scrollbar-color: rgba(16, 24, 40, .28) rgba(16, 24, 40, .05);
|
|
45
|
-
}
|
|
46
|
-
.ke-tb::-webkit-scrollbar { height: 7px; }
|
|
47
|
-
.ke-tb::-webkit-scrollbar-track { background: rgba(16, 24, 40, .06); border-radius: 4px; }
|
|
48
|
-
.ke-tb::-webkit-scrollbar-thumb { background: rgba(16, 24, 40, .34); border-radius: 4px; }
|
|
49
|
-
.ke-tb:hover::-webkit-scrollbar-thumb { background: rgba(16, 24, 40, .48); }
|
|
50
|
-
.ke-tb::-webkit-scrollbar-thumb:active { background: var(--ke-primary); }
|
|
51
|
-
.ke-tb-group { display: flex; align-items: center; gap: 2px; flex: none; }
|
|
52
|
-
.ke-tb-sep { width: 1px; height: 18px; background: var(--ke-line); margin: 0 6px; flex: none; }
|
|
53
|
-
.ke-tb-tail {
|
|
54
|
-
position: sticky; right: 0; margin-left: auto; display: flex; align-items: center; gap: 4px;
|
|
55
|
-
flex: none; padding: 0 2px 0 12px; background: #fff;
|
|
56
|
-
box-shadow: none; transition: box-shadow .2s;
|
|
57
|
-
}
|
|
58
|
-
/* 仅当右侧仍有被尾部遮住的工具时才显示,让阴影成为「可继续滑动」的信号 */
|
|
59
|
-
.ke.ke-tb-can-r .ke-tb-tail { box-shadow: -16px 0 14px -10px rgba(16, 24, 40, .55); }
|
|
60
|
-
/* 尾部左缘渐隐:明确表达「还有工具滑到这块底下」 */
|
|
61
|
-
.ke-tb-tail::before {
|
|
62
|
-
content: ''; position: absolute; top: 0; bottom: 0; right: 100%; width: 30px;
|
|
63
|
-
background: linear-gradient(to left, rgba(255, 255, 255, .99) 18%, rgba(255, 255, 255, 0));
|
|
64
|
-
opacity: 0; transition: opacity .2s; pointer-events: none;
|
|
65
|
-
}
|
|
66
|
-
.ke.ke-tb-can-r .ke-tb-tail::before { opacity: 1; }
|
|
67
|
-
/* 遮住工具栏右侧 padding 区域,避免滚动内容从尾部后面露出 */
|
|
68
|
-
.ke-tb-tail::after { content: ''; position: absolute; top: 0; bottom: 0; right: -16px; width: 18px; background: #fff; }
|
|
69
|
-
|
|
70
|
-
/* ------- 可滑动提示:左侧渐隐 + 拖拽手势 + 首次引导气泡 ------- */
|
|
71
|
-
/* 高度避开底部 7px 滚动条,否则会把滚动条左端涂白 */
|
|
72
|
-
.ke-tb-fades { position: absolute; left: 0; right: 0; top: 0; height: calc(var(--ke-tb-h, 44px) - 8px); z-index: 6; pointer-events: none; overflow: hidden; }
|
|
73
|
-
.ke-tb-fade { position: absolute; top: 0; bottom: 0; width: 34px; opacity: 0; transition: opacity .2s; }
|
|
74
|
-
.ke-tb-fade-l { left: 0; background: linear-gradient(to right, rgba(255, 255, 255, .99) 26%, rgba(255, 255, 255, 0)); }
|
|
75
|
-
.ke.ke-tb-can-l .ke-tb-fade-l { opacity: 1; }
|
|
76
|
-
@media (hover: hover) and (pointer: fine) {
|
|
77
|
-
.ke.ke-tb-scrollable .ke-tb { cursor: grab; }
|
|
78
|
-
.ke.ke-tb-dragging .ke-tb, .ke.ke-tb-dragging .ke-tb .ke-btn { cursor: grabbing; }
|
|
79
|
-
}
|
|
80
|
-
.ke.ke-tb-dragging { user-select: none; -webkit-user-select: none; }
|
|
81
|
-
.ke-tb-hint {
|
|
82
|
-
position: absolute; left: 50%; top: calc(var(--ke-tb-h, 44px) + 9px); z-index: 7;
|
|
83
|
-
transform: translateX(-50%);
|
|
84
|
-
display: inline-flex; align-items: center; gap: 7px;
|
|
85
|
-
padding: 7px 13px; border-radius: 999px;
|
|
86
|
-
background: rgba(31, 35, 41, .94); color: #fff;
|
|
87
|
-
font-size: 12.5px; line-height: 1; white-space: nowrap; letter-spacing: .2px;
|
|
88
|
-
box-shadow: 0 6px 20px rgba(16, 24, 40, .26);
|
|
89
|
-
pointer-events: none;
|
|
90
|
-
animation: ke-hint-in .3s cubic-bezier(.22, 1, .36, 1) both;
|
|
91
|
-
}
|
|
92
|
-
.ke-tb-hint::before {
|
|
93
|
-
content: ''; position: absolute; top: -5px; left: 50%; margin-left: -5px;
|
|
94
|
-
border: 5px solid transparent; border-top: 0; border-bottom-color: rgba(31, 35, 41, .94);
|
|
95
|
-
}
|
|
96
|
-
.ke-tb-hint-ico { display: flex; color: #7ee2a8; animation: ke-hint-slide 1.15s ease-in-out infinite; }
|
|
97
|
-
.ke-tb-hint-ico svg { width: 15px; height: 15px; display: block; }
|
|
98
|
-
.ke-tb-hint.ke-is-out { animation: ke-hint-out .24s ease-in both; }
|
|
99
|
-
@keyframes ke-hint-in {
|
|
100
|
-
from { opacity: 0; transform: translateX(-50%) translateY(-8px) scale(.96); }
|
|
101
|
-
to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
|
|
102
|
-
}
|
|
103
|
-
@keyframes ke-hint-out {
|
|
104
|
-
to { opacity: 0; transform: translateX(-50%) translateY(-8px) scale(.96); }
|
|
105
|
-
}
|
|
106
|
-
@keyframes ke-hint-slide {
|
|
107
|
-
0%, 100% { transform: translateX(-2.5px); }
|
|
108
|
-
50% { transform: translateX(2.5px); }
|
|
109
|
-
}
|
|
110
|
-
.ke-btn {
|
|
111
|
-
position: relative; flex: none;
|
|
112
|
-
height: 30px; min-width: 30px; padding: 0 6px;
|
|
113
|
-
display: inline-flex; align-items: center; justify-content: center; gap: 4px;
|
|
114
|
-
border: 0; border-radius: 6px; background: transparent; color: #4b5158;
|
|
115
|
-
cursor: pointer; font-size: 13px; line-height: 1; transition: background .15s, color .15s;
|
|
116
|
-
}
|
|
117
|
-
.ke-btn:hover { background: #f2f3f5; color: #1f2329; }
|
|
118
|
-
.ke-btn:active { background: #e9eaec; }
|
|
119
|
-
.ke-btn.ke-is-active { background: var(--ke-primary-weak); color: var(--ke-primary); }
|
|
120
|
-
.ke-btn.ke-is-open { background: #eef0f2; color: #1f2329; }
|
|
121
|
-
.ke-btn-label { padding: 0 6px 0 8px; gap: 2px; min-width: 56px; justify-content: flex-start; }
|
|
122
|
-
.ke-btn-text { font-size: 12.5px; letter-spacing: .2px; }
|
|
123
|
-
.ke-btn:disabled { opacity: .38; cursor: not-allowed; }
|
|
124
|
-
.ke-btn:focus-visible { outline: 2px solid var(--ke-primary); outline-offset: 1px; }
|
|
125
|
-
.ke-ico { width: 17px; height: 17px; display: block; }
|
|
126
|
-
.ke-glyph { font-size: 14px; font-weight: 600; }
|
|
127
|
-
.ke-glyph-i { font-style: italic; font-family: Georgia, 'Times New Roman', serif; }
|
|
128
|
-
.ke-glyph-u { text-decoration: underline; }
|
|
129
|
-
.ke-glyph-s { text-decoration: line-through; }
|
|
130
|
-
.ke-glyph-h { font-weight: 700; font-size: 13px; }
|
|
131
|
-
.ke-dot { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 3px; border-radius: 2px; background: var(--ke-fore, #1f2329); }
|
|
132
|
-
.ke-dot-bg { left: 3px; right: 3px; bottom: 2.5px; height: 4px; border-radius: 2px; background: var(--ke-back, #f6c344); }
|
|
133
|
-
.ke-glyph-a { font-size: 15px; font-weight: 700; letter-spacing: 0; line-height: 1; margin-bottom: 3px; }
|
|
134
|
-
.ke-glyph-hl { position: relative; margin-bottom: 0; padding: 0 3px; }
|
|
135
|
-
.ke-glyph-hl::before { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 11px; border-radius: 2px; background: var(--ke-back, #f6c344); }
|
|
136
|
-
.ke-glyph-hl > span { position: relative; z-index: 1; }
|
|
137
|
-
.ke-btn[data-k-pop] .ke-caret { width: 11px; height: 11px; opacity: .5; margin-left: -1px; }
|
|
138
|
-
.ke-select {
|
|
139
|
-
height: 30px; border: 1px solid transparent; border-radius: 6px; background: transparent;
|
|
140
|
-
color: #4b5158; font-size: 13px; padding: 0 4px; cursor: pointer; max-width: 92px;
|
|
141
|
-
}
|
|
142
|
-
.ke-select:hover { background: #f2f3f5; }
|
|
143
|
-
.ke-select:focus { outline: none; border-color: var(--ke-primary); }
|
|
144
|
-
|
|
145
|
-
/* ---------------- Popover ---------------- */
|
|
146
|
-
.ke-pop {
|
|
147
|
-
position: absolute; z-index: 40; min-width: 236px; padding: 0;
|
|
148
|
-
background: #fff; border: 1px solid rgba(31, 35, 41, .07); border-radius: 12px;
|
|
149
|
-
box-shadow: 0 2px 4px rgba(16, 24, 40, .04), 0 12px 32px rgba(16, 24, 40, .14);
|
|
150
|
-
font-size: 13px; color: var(--ke-text); overflow: hidden;
|
|
151
|
-
}
|
|
152
|
-
.ke-pop[hidden] { display: none; }
|
|
153
|
-
.ke-pop-in { animation: ke-pop-in .16s cubic-bezier(.22, 1, .36, 1); }
|
|
154
|
-
@keyframes ke-pop-in { from { opacity: 0; transform: translateY(-6px) scale(.985); } }
|
|
155
|
-
.ke-panel { padding: 12px 14px 14px; }
|
|
156
|
-
.ke-panel-wide { min-width: 268px; }
|
|
157
|
-
.ke-panel-head { display: flex; align-items: center; gap: 8px; margin: -12px -14px 12px; padding: 10px 14px; background: #f8f9fb; border-bottom: 1px solid var(--ke-line-weak); }
|
|
158
|
-
.ke-panel-title { font-size: 13px; font-weight: 600; color: #1f2329; }
|
|
159
|
-
.ke-panel-note { margin-left: auto; font-size: 12px; color: var(--ke-muted); }
|
|
160
|
-
.ke-panel-reset { margin-left: auto; height: 22px; padding: 0 8px; border: 1px solid var(--ke-line); border-radius: 11px; background: #fff; color: #6b7280; font-size: 12px; cursor: pointer; }
|
|
161
|
-
.ke-panel-reset:hover { border-color: var(--ke-primary); color: var(--ke-primary); }
|
|
162
|
-
.ke-panel-sect { margin: 10px 0 6px; font-size: 11px; color: #a2a8b3; letter-spacing: .3px; }
|
|
163
|
-
.ke-panel-sect:first-of-type { margin-top: 0; }
|
|
164
|
-
.ke-panel-divider { height: 1px; background: var(--ke-line-weak); margin: 12px -14px 10px; }
|
|
165
|
-
.ke-panel-hint { font-size: 11.5px; color: #a2a8b3; line-height: 1.5; }
|
|
166
|
-
.ke-panel-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
|
|
167
|
-
|
|
168
|
-
.ke-sw-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
|
|
169
|
-
.ke-sw {
|
|
170
|
-
position: relative; width: 100%; aspect-ratio: 1 / 1; min-width: 22px; padding: 0;
|
|
171
|
-
border: 1px solid rgba(0, 0, 0, .07); border-radius: 6px; cursor: pointer;
|
|
172
|
-
transition: transform .12s ease, box-shadow .12s ease;
|
|
173
|
-
}
|
|
174
|
-
.ke-sw:hover { transform: translateY(-1px) scale(1.08); box-shadow: 0 2px 6px rgba(16, 24, 40, .18); z-index: 1; }
|
|
175
|
-
.ke-sw.ke-is-active { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--ke-primary); }
|
|
176
|
-
.ke-sw-check { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
|
|
177
|
-
.ke-sw-check .ke-ico { width: 13px; height: 13px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
|
|
178
|
-
.ke-sw-picker { width: 30px; height: 30px; padding: 0; border: 1px solid var(--ke-line); border-radius: 7px; background: #fff; cursor: pointer; flex: none; }
|
|
179
|
-
.ke-sw-picker::-webkit-color-swatch-wrapper { padding: 3px; }
|
|
180
|
-
.ke-sw-picker::-webkit-color-swatch { border: 0; border-radius: 4px; }
|
|
181
|
-
.ke-sw-hex { flex: 1; font-family: 'SFMono-Regular', Consolas, Menlo, monospace; text-transform: uppercase; }
|
|
182
|
-
|
|
183
|
-
.ke-hd-row {
|
|
184
|
-
display: flex; flex-direction: column; align-items: stretch; gap: 2px; width: 100%;
|
|
185
|
-
padding: 8px 10px; margin-bottom: 4px; border: 1px solid transparent; border-radius: 8px;
|
|
186
|
-
background: #fff; cursor: pointer; text-align: left; transition: background .14s, border-color .14s;
|
|
187
|
-
}
|
|
188
|
-
.ke-hd-row:last-child { margin-bottom: 0; }
|
|
189
|
-
.ke-hd-row:hover { background: #f7f8fa; }
|
|
190
|
-
.ke-hd-row.ke-is-active { border-color: var(--ke-primary); background: var(--ke-primary-weak); }
|
|
191
|
-
.ke-hd-sample { display: block; color: #1f2329; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.35; }
|
|
192
|
-
.ke-hd-meta { display: flex; align-items: baseline; gap: 6px; font-size: 11.5px; color: #a2a8b3; }
|
|
193
|
-
.ke-hd-label { color: #6b7280; }
|
|
194
|
-
.ke-hd-row .s-body { font-size: 15px; }
|
|
195
|
-
.ke-hd-row .s-h1 { font-size: 21px; font-weight: 700; }
|
|
196
|
-
.ke-hd-row .s-h2 { font-size: 18px; font-weight: 700; }
|
|
197
|
-
.ke-hd-row .s-h3 { font-size: 16px; font-weight: 600; }
|
|
198
|
-
|
|
199
|
-
.ke-size-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
|
|
200
|
-
.ke-size-cell { height: 32px; border: 1px solid var(--ke-line); border-radius: 7px; background: #fff; color: #4b5158; cursor: pointer; }
|
|
201
|
-
.ke-size-cell:hover { border-color: var(--ke-primary); color: var(--ke-primary); background: var(--ke-primary-weak); }
|
|
202
|
-
.ke-size-cell.ke-is-active { border-color: var(--ke-primary); background: var(--ke-primary); color: #fff; }
|
|
203
|
-
|
|
204
|
-
.ke-tabs { display: flex; gap: 4px; margin: -12px -14px 12px; padding: 0 14px; background: #f8f9fb; border-bottom: 1px solid var(--ke-line-weak); }
|
|
205
|
-
.ke-tab { height: 34px; padding: 0 4px; margin-right: 10px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #6b7280; font-size: 13px; cursor: pointer; }
|
|
206
|
-
.ke-tab:hover { color: #1f2329; }
|
|
207
|
-
.ke-tab.ke-is-active { color: var(--ke-primary); border-bottom-color: var(--ke-primary); font-weight: 600; }
|
|
208
|
-
.ke-tab-body[hidden] { display: none; }
|
|
209
|
-
.ke-drop {
|
|
210
|
-
display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
|
|
211
|
-
padding: 20px 14px; border: 1.5px dashed #d6dade; border-radius: 10px; background: #fbfcfd;
|
|
212
|
-
color: var(--ke-muted); cursor: pointer; text-align: center; transition: border-color .14s, background .14s;
|
|
213
|
-
}
|
|
214
|
-
.ke-drop:hover, .ke-drop.ke-is-over { border-color: var(--ke-primary); background: var(--ke-primary-weak); }
|
|
215
|
-
.ke-drop-ico .ke-ico { width: 24px; height: 24px; color: var(--ke-primary); }
|
|
216
|
-
.ke-drop-title { font-size: 13px; color: #4b5158; }
|
|
217
|
-
.ke-drop-sub { font-size: 11.5px; color: #a2a8b3; }
|
|
218
|
-
.ke-field { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
|
|
219
|
-
.ke-field-label { flex: none; width: 34px; font-size: 12px; color: var(--ke-muted); }
|
|
220
|
-
.ke-check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #4b5158; margin-bottom: 4px; }
|
|
221
|
-
.ke-link-status { min-height: 18px; font-size: 11.5px; color: #a2a8b3; }
|
|
222
|
-
.ke-link-status.ke-is-checking { color: #2f6fed; }
|
|
223
|
-
.ke-link-status.ke-is-ok { color: var(--ke-primary); }
|
|
224
|
-
.ke-link-status.ke-is-bad { color: #ed8936; }
|
|
225
|
-
|
|
226
|
-
.ke-input, .ke-textarea {
|
|
227
|
-
width: 100%; height: 32px; padding: 0 10px; border: 1px solid var(--ke-line); border-radius: 7px;
|
|
228
|
-
font-size: 13px; color: var(--ke-text); background: #fff; transition: border-color .14s, box-shadow .14s;
|
|
229
|
-
}
|
|
230
|
-
.ke-input:focus, .ke-textarea:focus { outline: none; border-color: var(--ke-primary); box-shadow: 0 0 0 3px rgba(7, 193, 96, .12); }
|
|
231
|
-
.ke-input.ke-is-invalid { border-color: #e53e3e; box-shadow: 0 0 0 3px rgba(229, 62, 62, .12); }
|
|
232
|
-
.ke-textarea { height: auto; padding: 8px 10px; resize: vertical; font-family: inherit; line-height: 1.6; }
|
|
233
|
-
.ke-btn-primary { height: 32px; padding: 0 16px; border-radius: 7px; background: var(--ke-primary); color: #fff; font-size: 13px; border: 0; cursor: pointer; flex: none; }
|
|
234
|
-
.ke-btn-primary:hover { background: #06b35a; }
|
|
235
|
-
.ke-btn-primary:disabled { opacity: .45; cursor: progress; }
|
|
236
|
-
.ke-btn-ghost { height: 32px; padding: 0 14px; border-radius: 7px; background: #fff; border: 1px solid var(--ke-line); color: #4b5158; font-size: 13px; cursor: pointer; flex: none; }
|
|
237
|
-
.ke-btn-ghost:hover { border-color: #cfd3d8; color: #1f2329; }
|
|
238
|
-
.ke-table-grid { display: grid; gap: 3px; }
|
|
239
|
-
.ke-table-cell { width: 18px; height: 18px; border: 1px solid #d6dade; border-radius: 3px; transition: background .1s; }
|
|
240
|
-
.ke-table-cell.ke-is-on { background: var(--ke-primary-weak); border-color: var(--ke-primary); }
|
|
241
|
-
|
|
242
|
-
/* ---------------- Paper / Content ---------------- */
|
|
243
|
-
.ke-main { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
|
|
244
|
-
.ke-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 18px 28px; background: var(--ke-bg); scrollbar-width: thin; }
|
|
245
|
-
.ke-paper {
|
|
246
|
-
width: min(100%, calc(var(--ke-paper) + 64px)); margin: 0 auto; background: #fff;
|
|
247
|
-
border-radius: 8px; box-shadow: var(--ke-shadow); padding: 32px;
|
|
248
|
-
min-height: var(--ke-min-height, 320px);
|
|
249
|
-
}
|
|
250
|
-
.ke-content { outline: none; font-size: 17px; line-height: 1.75; color: var(--ke-text); word-break: break-word; }
|
|
251
|
-
.ke-content:empty::before,
|
|
252
|
-
.ke-content[data-placeholder].ke-is-empty::before {
|
|
253
|
-
content: attr(data-placeholder); color: #b8bec7; pointer-events: none;
|
|
254
|
-
}
|
|
255
|
-
.ke-content > *:first-child { margin-top: 0; }
|
|
256
|
-
.ke-content p { margin: 0 0 16px; }
|
|
257
|
-
.ke-content h1, .ke-content h2, .ke-content h3, .ke-content h4, .ke-content h5, .ke-content h6 {
|
|
258
|
-
margin: 24px 0 12px; font-weight: 600; line-height: 1.4; color: #1f2329;
|
|
259
|
-
}
|
|
260
|
-
.ke-content h1 { font-size: 22px; } .ke-content h2 { font-size: 20px; } .ke-content h3 { font-size: 18px; }
|
|
261
|
-
.ke-content h4, .ke-content h5, .ke-content h6 { font-size: 17px; }
|
|
262
|
-
.ke-content ul, .ke-content ol { margin: 0 0 16px; padding-left: 26px; }
|
|
263
|
-
.ke-content li { margin: 4px 0; }
|
|
264
|
-
.ke-content blockquote {
|
|
265
|
-
margin: 0 0 16px; padding: 2px 16px; border-left: 3px solid var(--ke-primary);
|
|
266
|
-
background: #f8f9fa; color: #6b7280; border-radius: 0 4px 4px 0;
|
|
267
|
-
}
|
|
268
|
-
.ke-content a { color: #576b95; text-decoration: none; border-bottom: 1px solid rgba(87,107,149,.35); }
|
|
269
|
-
.ke-content hr { border: 0; border-top: 1px solid var(--ke-line); margin: 24px 0; }
|
|
270
|
-
.ke-content code { background: #f2f3f5; border-radius: 4px; padding: 2px 6px; font-size: 14px; font-family: 'SFMono-Regular', Consolas, Menlo, monospace; color: #c7254e; }
|
|
271
|
-
.ke-content pre {
|
|
272
|
-
background: #282c34; color: #e6e6e6; padding: 14px 16px; border-radius: 8px; overflow-x: auto;
|
|
273
|
-
font-size: 13px; line-height: 1.7; margin: 0 0 16px; font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
|
|
274
|
-
}
|
|
275
|
-
.ke-content pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
|
|
276
|
-
.ke-content img, .ke-content video { max-width: 100%; height: auto; display: block; }
|
|
277
|
-
.ke-content figure { margin: 0 0 16px; }
|
|
278
|
-
.ke-content figcaption { font-size: 13px; color: var(--ke-muted); text-align: center; margin-top: 6px; }
|
|
279
|
-
.ke-content table { border-collapse: collapse; width: 100%; margin: 0 0 16px; font-size: 15px; }
|
|
280
|
-
.ke-content th, .ke-content td { border: 1px solid #dfe2e6; padding: 8px 10px; min-width: 40px; }
|
|
281
|
-
.ke-content th { background: #f6f7f9; font-weight: 600; }
|
|
282
|
-
.ke-content section { margin: 0 0 16px; }
|
|
283
|
-
.ke-content .ke-is-selected-media { outline: 2px solid var(--ke-primary); outline-offset: 2px; border-radius: 4px; }
|
|
284
|
-
|
|
285
|
-
/* 上传中的媒体占位 */
|
|
286
|
-
.ke-media-box { position: relative; margin: 0 0 16px; }
|
|
287
|
-
.ke-media-holder {
|
|
288
|
-
border: 1px dashed #cdd3da; border-radius: 8px; background: #fafbfc; color: var(--ke-muted);
|
|
289
|
-
display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
|
|
290
|
-
min-height: 120px; padding: 16px; font-size: 13px; text-align: center;
|
|
291
|
-
}
|
|
292
|
-
.ke-media-holder img { max-width: 100%; max-height: 260px; border-radius: 6px; opacity: .9; }
|
|
293
|
-
.ke-media-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
294
|
-
.ke-progress { width: 100%; height: 6px; border-radius: 3px; background: #eceef1; overflow: hidden; }
|
|
295
|
-
.ke-progress i { display: block; height: 100%; width: 0; background: var(--ke-primary); border-radius: 3px; transition: width .2s ease; }
|
|
296
|
-
.ke-media-meta { display: flex; align-items: center; gap: 10px; width: 100%; }
|
|
297
|
-
.ke-media-pct { color: var(--ke-primary); font-weight: 600; min-width: 40px; text-align: right; }
|
|
298
|
-
.ke-media-error { color: #e53e3e; }
|
|
299
|
-
.ke-media-retry { border: 1px solid var(--ke-line); background: #fff; border-radius: 6px; padding: 4px 12px; cursor: pointer; font-size: 12px; color: #4b5158; }
|
|
300
|
-
.ke-media-retry:hover { border-color: var(--ke-primary); color: var(--ke-primary); }
|
|
301
|
-
.ke-media-cancel { border: 0; background: transparent; color: var(--ke-muted); cursor: pointer; font-size: 12px; }
|
|
302
|
-
.ke-spinner { width: 18px; height: 18px; border: 2px solid #dfe3e8; border-top-color: var(--ke-primary); border-radius: 50%; animation: ke-spin .8s linear infinite; }
|
|
303
|
-
@keyframes ke-spin { to { transform: rotate(360deg); } }
|
|
304
|
-
|
|
305
|
-
/* 视频卡片 */
|
|
306
|
-
.ke-video-card {
|
|
307
|
-
position: relative; border: 1px solid var(--ke-line); border-radius: 10px; background: #0f1115;
|
|
308
|
-
color: #e6e8eb; padding: 12px 14px; margin: 0 0 16px; display: flex; align-items: center; gap: 12px;
|
|
309
|
-
}
|
|
310
|
-
.ke-video-card video { width: 100%; border-radius: 6px; display: block; }
|
|
311
|
-
.ke-video-card .ke-video-body { flex: 1; min-width: 0; }
|
|
312
|
-
.ke-video-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
|
|
313
|
-
.ke-video-size { color: var(--ke-muted); font-size: 12px; }
|
|
314
|
-
.ke-video-remove { border: 0; background: transparent; color: #9aa2ad; cursor: pointer; padding: 4px; border-radius: 6px; }
|
|
315
|
-
.ke-video-remove:hover { color: #e53e3e; background: rgba(255,255,255,.06); }
|
|
316
|
-
.ke-inline-video video { border-radius: 8px; }
|
|
317
|
-
|
|
318
|
-
/* ---------------- Status bar ---------------- */
|
|
319
|
-
.ke-status {
|
|
320
|
-
display: flex; align-items: center; gap: 12px; padding: 6px 12px;
|
|
321
|
-
background: #fff; border-top: 1px solid var(--ke-line); font-size: 12px; color: var(--ke-muted);
|
|
322
|
-
}
|
|
323
|
-
.ke-status b { color: var(--ke-primary); font-weight: 600; }
|
|
324
|
-
.ke-status-hint { margin-left: 8px; }
|
|
325
|
-
.ke-status-tail { margin-left: auto; display: flex; align-items: center; gap: 4px; }
|
|
326
|
-
.ke-chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 12px; background: #f2f3f5; color: #4b5158; font-size: 12px; }
|
|
327
|
-
.ke-chip[hidden] { display: none; }
|
|
328
|
-
.ke-chip.ke-is-busy { background: var(--ke-primary-weak); color: var(--ke-primary); }
|
|
329
|
-
|
|
330
|
-
/* ---------------- Source mode ---------------- */
|
|
331
|
-
.ke-source { display: flex; flex-direction: column; flex: 1; min-height: 0; background: #1b1f27; }
|
|
332
|
-
.ke-source[hidden] { display: none; }
|
|
333
|
-
.ke-source-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #232833; color: #aeb6c2; font-size: 12px; }
|
|
334
|
-
.ke-source-title { font-weight: 600; color: #dfe4ea; }
|
|
335
|
-
.ke-source-bar .ke-btn { color: #aeb6c2; }
|
|
336
|
-
.ke-source-bar .ke-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
|
|
337
|
-
.ke-source-tail { margin-left: auto; display: flex; gap: 8px; align-items: center; }
|
|
338
|
-
.ke-source-code {
|
|
339
|
-
flex: 1; min-height: 240px; margin: 0; padding: 16px 18px; overflow: auto;
|
|
340
|
-
color: #e6edf3; background: #1b1f27; font-size: 12.5px; line-height: 1.7; tab-size: 2;
|
|
341
|
-
font-family: 'SFMono-Regular', Consolas, Menlo, Monaco, monospace; white-space: pre-wrap;
|
|
342
|
-
word-break: break-all; outline: none; caret-color: #4ade80;
|
|
343
|
-
}
|
|
344
|
-
.ke-source-code[data-k-tag] { }
|
|
345
|
-
.ke-source-tip { color: #7d8794; }
|
|
346
|
-
.ke-source-actions button { height: 28px; padding: 0 12px; border-radius: 6px; border: 1px solid #39424f; background: transparent; color: #cfd6de; font-size: 12px; cursor: pointer; }
|
|
347
|
-
.ke-source-actions button:hover { border-color: var(--ke-primary); color: #fff; }
|
|
348
|
-
.ke-source-actions .ke-apply { background: var(--ke-primary); border-color: var(--ke-primary); color: #fff; }
|
|
349
|
-
|
|
350
|
-
/* ---------------- Bubble (图片/视频工具条) ---------------- */
|
|
351
|
-
.ke-bubble {
|
|
352
|
-
position: absolute; z-index: 30; display: flex; align-items: center; gap: 2px; padding: 4px;
|
|
353
|
-
background: rgba(28, 32, 38, .94); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.22);
|
|
354
|
-
color: #fff; transform: translate(-50%, -100%); white-space: nowrap;
|
|
355
|
-
}
|
|
356
|
-
.ke-bubble.ke-is-below { transform: translate(-50%, 0); }
|
|
357
|
-
.ke-bubble[hidden] { display: none; }
|
|
358
|
-
.ke-bubble button { height: 28px; min-width: 28px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: #e6e8eb; cursor: pointer; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
|
|
359
|
-
.ke-bubble button:hover { background: rgba(255,255,255,.14); }
|
|
360
|
-
.ke-bubble button.ke-is-active { background: var(--ke-primary); color: #fff; }
|
|
361
|
-
.ke-bubble .ke-sep { width: 1px; height: 16px; background: rgba(255,255,255,.18); margin: 0 3px; }
|
|
362
|
-
|
|
363
|
-
/* ---------------- 图片缩放把手(鼠标拖动调大小) ---------------- */
|
|
364
|
-
.ke-img-resize {
|
|
365
|
-
position: absolute; z-index: 31; width: 18px; height: 18px; border-radius: 5px;
|
|
366
|
-
background: #fff; border: 2px solid var(--ke-primary); color: var(--ke-primary);
|
|
367
|
-
cursor: nwse-resize; box-shadow: 0 1px 5px rgba(0,0,0,.25);
|
|
368
|
-
display: flex; align-items: center; justify-content: center;
|
|
369
|
-
touch-action: none; transition: transform .12s ease, background .12s ease, color .12s ease;
|
|
370
|
-
}
|
|
371
|
-
.ke-img-resize svg { width: 10px; height: 10px; display: block; }
|
|
372
|
-
.ke-img-resize:hover { transform: scale(1.12); background: var(--ke-primary); color: #fff; }
|
|
373
|
-
.ke-img-resize[hidden] { display: none; }
|
|
374
|
-
.ke-img-resize-tip {
|
|
375
|
-
position: absolute; z-index: 32; transform: translate(-50%, -100%);
|
|
376
|
-
background: rgba(28,32,38,.9); color: #fff; font-size: 12px; line-height: 1;
|
|
377
|
-
padding: 5px 8px; border-radius: 6px; pointer-events: none; white-space: nowrap;
|
|
378
|
-
}
|
|
379
|
-
.ke-img-resize-tip[hidden] { display: none; }
|
|
380
|
-
|
|
381
|
-
/* ---------------- Drop zone / Toast / Lightbox ---------------- */
|
|
382
|
-
.ke-dropzone {
|
|
383
|
-
position: absolute; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center;
|
|
384
|
-
background: rgba(7, 193, 96, .08); backdrop-filter: blur(1px); border: 2px dashed var(--ke-primary);
|
|
385
|
-
border-radius: var(--ke-radius); color: var(--ke-primary); font-size: 15px; font-weight: 600; pointer-events: none;
|
|
386
|
-
}
|
|
387
|
-
.ke-is-dragover .ke-dropzone { display: flex; }
|
|
388
|
-
.ke-toasts { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 10000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
|
|
389
|
-
.ke-toast {
|
|
390
|
-
padding: 8px 16px; border-radius: 8px; background: rgba(28,32,38,.92); color: #fff; font-size: 13px;
|
|
391
|
-
box-shadow: 0 6px 20px rgba(0,0,0,.18); animation: ke-in .18s ease;
|
|
392
|
-
}
|
|
393
|
-
.ke-toast.ke-is-error { background: rgba(229, 62, 62, .95); }
|
|
394
|
-
.ke-toast.ke-is-warn { background: rgba(237, 137, 27, .95); }
|
|
395
|
-
@keyframes ke-in { from { opacity: 0; transform: translateY(-6px); } }
|
|
396
|
-
.ke-lightbox {
|
|
397
|
-
position: fixed; inset: 0; z-index: 10001; background: rgba(0,0,0,.86); display: flex;
|
|
398
|
-
align-items: center; justify-content: center; cursor: zoom-out; animation: ke-in .18s ease;
|
|
399
|
-
}
|
|
400
|
-
.ke-lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 4px; }
|
|
401
|
-
.ke-lightbox-close { position: absolute; top: 18px; right: 22px; color: #fff; background: transparent; border: 0; cursor: pointer; }
|
|
402
|
-
|
|
403
|
-
/* ---------------- Preview overlay ---------------- */
|
|
404
|
-
.ke-preview { position: absolute; inset: 0; z-index: 25; background: #f2f3f5; display: flex; flex-direction: column; }
|
|
405
|
-
.ke-preview[hidden] { display: none; }
|
|
406
|
-
.ke-preview-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--ke-line); font-size: 12px; color: var(--ke-muted); }
|
|
407
|
-
.ke-preview-body { flex: 1; overflow: auto; padding: 20px; }
|
|
408
|
-
.ke-preview-frame { margin: 0 auto; background: #fff; border-radius: 10px; box-shadow: var(--ke-shadow); padding: 22px 20px; transition: width .2s ease; }
|
|
409
|
-
.ke-preview-frame .ke-content { font-size: 17px; line-height: 1.75; color: var(--ke-text); }
|
|
410
|
-
.ke-preview-frame { min-height: 120px; }
|
|
411
|
-
|
|
412
|
-
/* ---------------- ReadOnly / disabled ---------------- */
|
|
413
|
-
.ke-is-readonly .ke-tb .ke-btn, .ke-is-readonly .ke-tb .ke-select { pointer-events: none; opacity: .45; }
|
|
414
|
-
.ke-is-readonly .ke-content { cursor: default; }
|
|
415
|
-
/* 源码模式下正文类按钮置灰,仅保留源码/预览/全屏 */
|
|
416
|
-
.ke-is-source .ke-tb .ke-btn:not([data-k-item="source"]):not([data-k-item="preview"]):not([data-k-item="fullscreen"]),
|
|
417
|
-
.ke-is-source .ke-tb .ke-btn-label { pointer-events: none; opacity: .35; }
|
|
418
|
-
.ke-is-source .ke-tb .ke-tb-sep { opacity: .4; }
|
|
419
|
-
.ke-btn[data-k-item="source"].ke-is-active { background: var(--ke-primary); color: #fff; }
|
|
420
|
-
.ke-btn[data-k-item="source"].ke-is-active:hover { background: #06b35a; }
|
|
421
|
-
|
|
422
|
-
/* ---------------- Mobile ---------------- */
|
|
423
|
-
@media (max-width: 640px) {
|
|
424
|
-
.ke-tb { padding: 4px 6px; gap: 0; }
|
|
425
|
-
.ke-btn, .ke-select { height: 28px; min-width: 28px; }
|
|
426
|
-
.ke-tb-sep { margin: 0 2px; }
|
|
427
|
-
.ke-scroll { padding: 12px 8px 18px; }
|
|
428
|
-
.ke-paper { padding: 16px 14px; border-radius: 6px; }
|
|
429
|
-
.ke-content { font-size: 16px; }
|
|
430
|
-
.ke-status { padding: 5px 8px; gap: 6px; }
|
|
431
|
-
.ke-status-hint { display: none; }
|
|
432
|
-
}
|
|
433
|
-
@media (prefers-reduced-motion: reduce) {
|
|
434
|
-
.ke * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
|
|
435
|
-
}
|
|
436
|
-
`
|
|
437
|
-
|
|
438
|
-
let injected = false
|
|
439
|
-
|
|
440
|
-
export function injectStyle() {
|
|
441
|
-
if (injected || typeof document === 'undefined') return
|
|
442
|
-
const style = document.createElement('style')
|
|
443
|
-
style.setAttribute('data-keditor-style', '')
|
|
444
|
-
style.textContent = CSS
|
|
445
|
-
document.head.appendChild(style)
|
|
446
|
-
injected = true
|
|
447
|
-
}
|
package/src/ui/toast.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/** 轻量 toast + 图片查看器(挂在 body 上,跟随编辑器实例销毁) */
|
|
2
|
-
import { h } from '../core/utils.js'
|
|
3
|
-
|
|
4
|
-
export class Toast {
|
|
5
|
-
constructor(owner = null) {
|
|
6
|
-
this.owner = owner
|
|
7
|
-
this.el = null
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
show(message, type = '', duration = 2600) {
|
|
11
|
-
if (typeof document === 'undefined') return
|
|
12
|
-
if (!this.el) {
|
|
13
|
-
this.el = h('div.ke-toasts')
|
|
14
|
-
document.body.appendChild(this.el)
|
|
15
|
-
}
|
|
16
|
-
const item = h(`span.ke-toast${type ? `.ke-is-${type}` : ''}`, { text: message })
|
|
17
|
-
this.el.appendChild(item)
|
|
18
|
-
setTimeout(() => {
|
|
19
|
-
item.style.opacity = '0'
|
|
20
|
-
item.style.transition = 'opacity .2s'
|
|
21
|
-
setTimeout(() => item.remove(), 220)
|
|
22
|
-
}, duration)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
error(msg) {
|
|
26
|
-
this.show(msg, 'error', 3600)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
warn(msg) {
|
|
30
|
-
this.show(msg, 'warn', 3000)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
ok(msg) {
|
|
34
|
-
this.show(msg, 'ok', 2200)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
destroy() {
|
|
38
|
-
if (this.el && !this.el.childElementCount) this.el.remove()
|
|
39
|
-
this.el = null
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function lightbox(src, ownerDocument = document) {
|
|
44
|
-
const box = h('div.ke-lightbox', { tabindex: '-1' }, [h('img', { src, alt: '' })])
|
|
45
|
-
const close = () => {
|
|
46
|
-
box.remove()
|
|
47
|
-
document.removeEventListener('keydown', onKey)
|
|
48
|
-
}
|
|
49
|
-
const onKey = (event) => {
|
|
50
|
-
if (event.key === 'Escape') close()
|
|
51
|
-
}
|
|
52
|
-
box.addEventListener('click', close)
|
|
53
|
-
document.addEventListener('keydown', onKey)
|
|
54
|
-
ownerDocument.body.appendChild(box)
|
|
55
|
-
return close
|
|
56
|
-
}
|