@aquera/nile-elements 1.8.5 → 1.8.7
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 +8 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +915 -321
- package/dist/nile-markdown/index.cjs.js +2 -0
- package/dist/nile-markdown/index.cjs.js.map +1 -0
- package/dist/nile-markdown/index.esm.js +1 -0
- package/dist/nile-markdown/nile-markdown.cjs.js +30 -0
- package/dist/nile-markdown/nile-markdown.cjs.js.map +1 -0
- package/dist/nile-markdown/nile-markdown.css.cjs.js +2 -0
- package/dist/nile-markdown/nile-markdown.css.cjs.js.map +1 -0
- package/dist/nile-markdown/nile-markdown.css.esm.js +152 -0
- package/dist/nile-markdown/nile-markdown.esm.js +3 -0
- package/dist/nile-markdown-editor/index.cjs.js +2 -0
- package/dist/nile-markdown-editor/index.cjs.js.map +1 -0
- package/dist/nile-markdown-editor/index.esm.js +1 -0
- package/dist/nile-markdown-editor/nile-markdown-editor.cjs.js +2 -0
- package/dist/nile-markdown-editor/nile-markdown-editor.cjs.js.map +1 -0
- package/dist/nile-markdown-editor/nile-markdown-editor.css.cjs.js +2 -0
- package/dist/nile-markdown-editor/nile-markdown-editor.css.cjs.js.map +1 -0
- package/dist/nile-markdown-editor/nile-markdown-editor.css.esm.js +255 -0
- package/dist/nile-markdown-editor/nile-markdown-editor.esm.js +143 -0
- package/dist/nile-option/nile-option.cjs.js +1 -1
- package/dist/nile-option/nile-option.cjs.js.map +1 -1
- package/dist/nile-option/nile-option.css.cjs.js +1 -1
- package/dist/nile-option/nile-option.css.cjs.js.map +1 -1
- package/dist/nile-option/nile-option.css.esm.js +22 -1
- package/dist/nile-option/nile-option.esm.js +12 -2
- package/dist/nile-select/nile-select.cjs.js +1 -1
- package/dist/nile-select/nile-select.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.css.cjs.js +1 -1
- package/dist/nile-select/nile-select.css.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.css.esm.js +16 -7
- package/dist/nile-select/nile-select.esm.js +2 -2
- package/dist/nile-select/virtual-scroll-helper.cjs.js +1 -1
- package/dist/nile-select/virtual-scroll-helper.cjs.js.map +1 -1
- package/dist/nile-select/virtual-scroll-helper.esm.js +2 -0
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js +3 -3
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js.map +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.esm.js +4 -3
- package/dist/nile-virtual-select/nile-virtual-select.esm.js +4 -4
- package/dist/nile-virtual-select/renderer.cjs.js +1 -1
- package/dist/nile-virtual-select/renderer.cjs.js.map +1 -1
- package/dist/nile-virtual-select/renderer.esm.js +14 -12
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-markdown/index.d.ts +1 -0
- package/dist/src/nile-markdown/index.js +2 -0
- package/dist/src/nile-markdown/index.js.map +1 -0
- package/dist/src/nile-markdown/nile-markdown.css.d.ts +10 -0
- package/dist/src/nile-markdown/nile-markdown.css.js +163 -0
- package/dist/src/nile-markdown/nile-markdown.css.js.map +1 -0
- package/dist/src/nile-markdown/nile-markdown.d.ts +91 -0
- package/dist/src/nile-markdown/nile-markdown.js +167 -0
- package/dist/src/nile-markdown/nile-markdown.js.map +1 -0
- package/dist/src/nile-markdown/nile-markdown.test.d.ts +1 -0
- package/dist/src/nile-markdown/nile-markdown.test.js +192 -0
- package/dist/src/nile-markdown/nile-markdown.test.js.map +1 -0
- package/dist/src/nile-markdown-editor/index.d.ts +1 -0
- package/dist/src/nile-markdown-editor/index.js +2 -0
- package/dist/src/nile-markdown-editor/index.js.map +1 -0
- package/dist/src/nile-markdown-editor/nile-markdown-editor.css.d.ts +10 -0
- package/dist/src/nile-markdown-editor/nile-markdown-editor.css.js +266 -0
- package/dist/src/nile-markdown-editor/nile-markdown-editor.css.js.map +1 -0
- package/dist/src/nile-markdown-editor/nile-markdown-editor.d.ts +121 -0
- package/dist/src/nile-markdown-editor/nile-markdown-editor.js +615 -0
- package/dist/src/nile-markdown-editor/nile-markdown-editor.js.map +1 -0
- package/dist/src/nile-markdown-editor/nile-markdown-editor.test.d.ts +1 -0
- package/dist/src/nile-markdown-editor/nile-markdown-editor.test.js +268 -0
- package/dist/src/nile-markdown-editor/nile-markdown-editor.test.js.map +1 -0
- package/dist/src/nile-option/nile-option.css.js +22 -1
- package/dist/src/nile-option/nile-option.css.js.map +1 -1
- package/dist/src/nile-option/nile-option.d.ts +3 -0
- package/dist/src/nile-option/nile-option.js +21 -0
- package/dist/src/nile-option/nile-option.js.map +1 -1
- package/dist/src/nile-select/nile-select.css.js +16 -7
- package/dist/src/nile-select/nile-select.css.js.map +1 -1
- package/dist/src/nile-select/nile-select.d.ts +7 -0
- package/dist/src/nile-select/nile-select.js +35 -0
- package/dist/src/nile-select/nile-select.js.map +1 -1
- package/dist/src/nile-select/virtual-scroll-helper.js +2 -0
- package/dist/src/nile-select/virtual-scroll-helper.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js +4 -3
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.d.ts +4 -0
- package/dist/src/nile-virtual-select/nile-virtual-select.js +11 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.js.map +1 -1
- package/dist/src/nile-virtual-select/renderer.d.ts +2 -2
- package/dist/src/nile-virtual-select/renderer.js +6 -4
- package/dist/src/nile-virtual-select/renderer.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/src/index.ts +3 -1
- package/src/nile-markdown/index.ts +1 -0
- package/src/nile-markdown/nile-markdown.css.ts +164 -0
- package/src/nile-markdown/nile-markdown.test.ts +252 -0
- package/src/nile-markdown/nile-markdown.ts +179 -0
- package/src/nile-markdown-editor/index.ts +1 -0
- package/src/nile-markdown-editor/nile-markdown-editor.css.ts +267 -0
- package/src/nile-markdown-editor/nile-markdown-editor.test.ts +402 -0
- package/src/nile-markdown-editor/nile-markdown-editor.ts +710 -0
- package/src/nile-option/nile-option.css.ts +22 -1
- package/src/nile-option/nile-option.ts +18 -0
- package/src/nile-select/nile-select.css.ts +16 -7
- package/src/nile-select/nile-select.ts +32 -0
- package/src/nile-select/virtual-scroll-helper.ts +2 -0
- package/src/nile-virtual-select/nile-virtual-select.css.ts +4 -3
- package/src/nile-virtual-select/nile-virtual-select.ts +9 -1
- package/src/nile-virtual-select/renderer.ts +9 -3
- package/vscode-html-custom-data.json +115 -3
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Aquera Inc 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { css } from 'lit';
|
|
8
|
+
/**
|
|
9
|
+
* Markdown editor CSS
|
|
10
|
+
*/
|
|
11
|
+
export const styles = css `
|
|
12
|
+
:host {
|
|
13
|
+
position: relative;
|
|
14
|
+
display: block;
|
|
15
|
+
font-family: inherit;
|
|
16
|
+
-webkit-font-smoothing: var(--nile-webkit-font-smoothing, var(--ng-webkit-font-smoothing));
|
|
17
|
+
-moz-osx-font-smoothing: var( --nile-moz-osx-font-smoothing,var(--ng-moz-osx-font-smoothing));
|
|
18
|
+
text-rendering: var(--nile-text-rendering, var(--ng-text-rendering));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.editor {
|
|
22
|
+
width: 100%;
|
|
23
|
+
border: 1px solid var(--nile-colors-neutral-400, var(--ng-colors-border-neutral));
|
|
24
|
+
border-radius: var(--nile-radius-radius-xl, var(--ng-radius-md));
|
|
25
|
+
background: var(--nile-colors-white-base, var(--ng-colors-bg-primary));
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.editor--disabled {
|
|
32
|
+
border-color: var(--nile-colors-neutral-500, var(--ng-colors-border-disabled));
|
|
33
|
+
background: var(--nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle));
|
|
34
|
+
cursor: not-allowed;
|
|
35
|
+
pointer-events: none;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.header {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: space-between;
|
|
42
|
+
gap: 6px;
|
|
43
|
+
flex-wrap: wrap;
|
|
44
|
+
padding: 8px;
|
|
45
|
+
border-bottom: 1px solid var(--nile-colors-neutral-400, var(--ng-colors-border-neutral));
|
|
46
|
+
background: var(--nile-colors-neutral-100, var(--ng-colors-bg-secondary));
|
|
47
|
+
border-radius: 8px 8px 0 0;
|
|
48
|
+
width: 100%;
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.editor--disabled .header {
|
|
53
|
+
border-color: var(--nile-colors-neutral-500, var(--ng-colors-border-disabled));
|
|
54
|
+
background: var(--nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.tabs {
|
|
58
|
+
display: flex;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Slimmer segmented control inside the editor header. */
|
|
62
|
+
.tabs nile-button-toggle::part(base) {
|
|
63
|
+
height: 28px;
|
|
64
|
+
padding: var(--nile-spacing-xxs, var(--ng-spacing-xs))
|
|
65
|
+
var(--nile-spacing-md, var(--ng-spacing-md));
|
|
66
|
+
font-size: var(--nile-type-scale-2, var(--ng-font-size-text-sm));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.tab__content {
|
|
70
|
+
display: inline-flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
gap: var(--nile-spacing-xs, var(--ng-spacing-xs));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
.toolbar {
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
flex-wrap: wrap;
|
|
81
|
+
gap: 6px;
|
|
82
|
+
min-width: 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.toolbar__button {
|
|
86
|
+
display: inline-flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
justify-content: center;
|
|
89
|
+
width: 32px;
|
|
90
|
+
height: 32px;
|
|
91
|
+
padding: 0px 6px;
|
|
92
|
+
box-sizing: border-box;
|
|
93
|
+
border: none;
|
|
94
|
+
background: transparent;
|
|
95
|
+
border-radius: var(--nile-radius-radius-lg, var(--ng-radius-md));
|
|
96
|
+
cursor: pointer;
|
|
97
|
+
color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900));
|
|
98
|
+
font-family: inherit;
|
|
99
|
+
font-size: var(--nile-type-scale-3, var(--ng-font-size-text-md));
|
|
100
|
+
transition: background 0.15s ease;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.toolbar__button:hover {
|
|
104
|
+
background: var(--nile-colors-dark-100, var(--ng-colors-bg-primary-hover));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.toolbar__menu {
|
|
108
|
+
display: inline-flex;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.toolbar__menu .toolbar__button {
|
|
112
|
+
width: auto;
|
|
113
|
+
gap: 2px;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.toolbar__button nile-icon {
|
|
117
|
+
pointer-events: none;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.toolbar__divider {
|
|
121
|
+
margin: 0 4px;
|
|
122
|
+
display: inline-block;
|
|
123
|
+
height: 24px;
|
|
124
|
+
width: 1px;
|
|
125
|
+
background: var(--nile-colors-neutral-400, var(--ng-colors-border-neutral));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.toolbar__glyph--heading {
|
|
129
|
+
font-weight: bold;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.toolbar__glyph--strikethrough {
|
|
133
|
+
text-decoration: line-through;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.toolbar__glyph--code {
|
|
137
|
+
font-family: var(--nile-font-family-mono, monospace);
|
|
138
|
+
font-size: var(--nile-type-scale-1, var(--ng-font-size-text-xs));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.body {
|
|
142
|
+
display: flex;
|
|
143
|
+
align-items: stretch;
|
|
144
|
+
overflow: hidden;
|
|
145
|
+
min-height: 160px;
|
|
146
|
+
border-radius: 0 0 var(--nile-radius-radius-xl, var(--ng-radius-md))
|
|
147
|
+
var(--nile-radius-radius-xl, var(--ng-radius-md));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.pane {
|
|
151
|
+
flex: 1 1 0;
|
|
152
|
+
min-width: 0;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* Draggable divider between the write and preview panes in split mode. */
|
|
156
|
+
.gutter {
|
|
157
|
+
flex: 0 0 auto;
|
|
158
|
+
position: relative;
|
|
159
|
+
width: 1px;
|
|
160
|
+
align-self: stretch;
|
|
161
|
+
background: var(--nile-colors-neutral-400, var(--ng-colors-border-neutral));
|
|
162
|
+
cursor: col-resize;
|
|
163
|
+
touch-action: none;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* Widen the hit area without shifting the 1px visual line. */
|
|
167
|
+
.gutter::before {
|
|
168
|
+
content: '';
|
|
169
|
+
position: absolute;
|
|
170
|
+
inset: 0 -4px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.gutter:hover,
|
|
174
|
+
.body--dragging .gutter {
|
|
175
|
+
background: var(--nile-colors-primary-500, var(--ng-colors-border-brand));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/* Keep the drag smooth: no text selection or pointer capture by the panes. */
|
|
179
|
+
.body--dragging {
|
|
180
|
+
cursor: col-resize;
|
|
181
|
+
user-select: none;
|
|
182
|
+
-webkit-user-select: none;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.body--dragging .pane {
|
|
186
|
+
pointer-events: none;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.pane--write {
|
|
190
|
+
display: flex;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
textarea {
|
|
194
|
+
flex: 1;
|
|
195
|
+
/* The body owns the resize/height now; the textarea fills it and scrolls
|
|
196
|
+
its own overflow. min-height:0 lets it shrink when the body shrinks. */
|
|
197
|
+
min-height: 0;
|
|
198
|
+
width: 100%;
|
|
199
|
+
padding: 12px;
|
|
200
|
+
border: none;
|
|
201
|
+
outline: none;
|
|
202
|
+
resize: none;
|
|
203
|
+
box-sizing: border-box;
|
|
204
|
+
tab-size: 4;
|
|
205
|
+
-moz-tab-size: 4;
|
|
206
|
+
word-break: break-word;
|
|
207
|
+
font-family: inherit;
|
|
208
|
+
font-size: inherit;
|
|
209
|
+
line-height: inherit;
|
|
210
|
+
color: inherit;
|
|
211
|
+
background: var(--nile-colors-white-base, var(--ng-colors-bg-primary));
|
|
212
|
+
border-radius: 0 0 var(--nile-radius-radius-xl, var(--ng-radius-md))
|
|
213
|
+
var(--nile-radius-radius-xl, var(--ng-radius-md));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
textarea::placeholder {
|
|
217
|
+
color: var(--nile-colors-neutral-500, var(--ng-colors-text-secondary));
|
|
218
|
+
font-family: var(--nile-font-family-sans-serif, var(--ng-font-family-body));
|
|
219
|
+
opacity: 0.7;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.editor--disabled textarea {
|
|
223
|
+
background: var(
|
|
224
|
+
--nile-colors-dark-200,
|
|
225
|
+
var(--ng-colors-bg-disabled-subtle)
|
|
226
|
+
);
|
|
227
|
+
color: var(--nile-colors-dark-500, var(--ng-colors-text-disabled));
|
|
228
|
+
pointer-events: none;
|
|
229
|
+
user-select: none;
|
|
230
|
+
-webkit-user-select: none;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.pane--preview {
|
|
234
|
+
min-height: 0;
|
|
235
|
+
padding: 12px;
|
|
236
|
+
overflow: auto;
|
|
237
|
+
box-sizing: border-box;
|
|
238
|
+
word-wrap: break-word;
|
|
239
|
+
background: var(--nile-colors-white-base, var(--ng-colors-bg-primary));
|
|
240
|
+
border-radius: 0 0 var(--nile-radius-radius-xl, var(--ng-radius-md))
|
|
241
|
+
var(--nile-radius-radius-xl, var(--ng-radius-md));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.editor--disabled .pane--preview {
|
|
245
|
+
background: var(
|
|
246
|
+
--nile-colors-dark-200,
|
|
247
|
+
var(--ng-colors-bg-disabled-subtle)
|
|
248
|
+
);
|
|
249
|
+
color: var(--nile-colors-dark-500, var(--ng-colors-text-disabled));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.editor--split .pane--preview {
|
|
253
|
+
border-radius: 0 0 var(--nile-radius-radius-xl, var(--ng-radius-md)) 0;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.editor--split textarea {
|
|
257
|
+
border-radius: 0 0 0 var(--nile-radius-radius-xl, var(--ng-radius-md));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.preview-empty {
|
|
261
|
+
color: var(--nile-colors-neutral-500, var(--ng-colors-text-secondary));
|
|
262
|
+
font-size: var(--nile-type-scale-2, var(--ng-font-size-text-sm));
|
|
263
|
+
opacity: 0.7;
|
|
264
|
+
}
|
|
265
|
+
`;
|
|
266
|
+
//# sourceMappingURL=nile-markdown-editor.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nile-markdown-editor.css.js","sourceRoot":"","sources":["../../../src/nile-markdown-editor/nile-markdown-editor.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8PxB,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { css } from 'lit';\n\n/**\n * Markdown editor CSS\n */\nexport const styles = css`\n :host {\n position: relative;\n display: block;\n font-family: inherit;\n -webkit-font-smoothing: var(--nile-webkit-font-smoothing, var(--ng-webkit-font-smoothing));\n -moz-osx-font-smoothing: var( --nile-moz-osx-font-smoothing,var(--ng-moz-osx-font-smoothing));\n text-rendering: var(--nile-text-rendering, var(--ng-text-rendering));\n }\n\n .editor {\n width: 100%;\n border: 1px solid var(--nile-colors-neutral-400, var(--ng-colors-border-neutral));\n border-radius: var(--nile-radius-radius-xl, var(--ng-radius-md));\n background: var(--nile-colors-white-base, var(--ng-colors-bg-primary));\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n }\n\n .editor--disabled {\n border-color: var(--nile-colors-neutral-500, var(--ng-colors-border-disabled));\n background: var(--nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle));\n cursor: not-allowed;\n pointer-events: none;\n }\n\n .header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 6px;\n flex-wrap: wrap;\n padding: 8px;\n border-bottom: 1px solid var(--nile-colors-neutral-400, var(--ng-colors-border-neutral));\n background: var(--nile-colors-neutral-100, var(--ng-colors-bg-secondary));\n border-radius: 8px 8px 0 0;\n width: 100%;\n box-sizing: border-box;\n }\n\n .editor--disabled .header {\n border-color: var(--nile-colors-neutral-500, var(--ng-colors-border-disabled));\n background: var(--nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle));\n }\n\n .tabs {\n display: flex;\n }\n\n /* Slimmer segmented control inside the editor header. */\n .tabs nile-button-toggle::part(base) {\n height: 28px;\n padding: var(--nile-spacing-xxs, var(--ng-spacing-xs))\n var(--nile-spacing-md, var(--ng-spacing-md));\n font-size: var(--nile-type-scale-2, var(--ng-font-size-text-sm));\n }\n\n .tab__content {\n display: inline-flex;\n align-items: center;\n gap: var(--nile-spacing-xs, var(--ng-spacing-xs));\n }\n\n \n\n .toolbar {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 6px;\n min-width: 0;\n }\n\n .toolbar__button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n padding: 0px 6px;\n box-sizing: border-box;\n border: none;\n background: transparent;\n border-radius: var(--nile-radius-radius-lg, var(--ng-radius-md));\n cursor: pointer;\n color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900));\n font-family: inherit;\n font-size: var(--nile-type-scale-3, var(--ng-font-size-text-md));\n transition: background 0.15s ease;\n }\n\n .toolbar__button:hover {\n background: var(--nile-colors-dark-100, var(--ng-colors-bg-primary-hover));\n }\n\n .toolbar__menu {\n display: inline-flex;\n }\n\n .toolbar__menu .toolbar__button {\n width: auto;\n gap: 2px;\n }\n\n .toolbar__button nile-icon {\n pointer-events: none;\n }\n\n .toolbar__divider {\n margin: 0 4px;\n display: inline-block;\n height: 24px;\n width: 1px;\n background: var(--nile-colors-neutral-400, var(--ng-colors-border-neutral));\n }\n\n .toolbar__glyph--heading {\n font-weight: bold;\n }\n\n .toolbar__glyph--strikethrough {\n text-decoration: line-through;\n }\n\n .toolbar__glyph--code {\n font-family: var(--nile-font-family-mono, monospace);\n font-size: var(--nile-type-scale-1, var(--ng-font-size-text-xs));\n }\n\n .body {\n display: flex;\n align-items: stretch;\n overflow: hidden;\n min-height: 160px;\n border-radius: 0 0 var(--nile-radius-radius-xl, var(--ng-radius-md))\n var(--nile-radius-radius-xl, var(--ng-radius-md));\n }\n\n .pane {\n flex: 1 1 0;\n min-width: 0;\n }\n\n /* Draggable divider between the write and preview panes in split mode. */\n .gutter {\n flex: 0 0 auto;\n position: relative;\n width: 1px;\n align-self: stretch;\n background: var(--nile-colors-neutral-400, var(--ng-colors-border-neutral));\n cursor: col-resize;\n touch-action: none;\n }\n\n /* Widen the hit area without shifting the 1px visual line. */\n .gutter::before {\n content: '';\n position: absolute;\n inset: 0 -4px;\n }\n\n .gutter:hover,\n .body--dragging .gutter {\n background: var(--nile-colors-primary-500, var(--ng-colors-border-brand));\n }\n\n /* Keep the drag smooth: no text selection or pointer capture by the panes. */\n .body--dragging {\n cursor: col-resize;\n user-select: none;\n -webkit-user-select: none;\n }\n\n .body--dragging .pane {\n pointer-events: none;\n }\n\n .pane--write {\n display: flex;\n }\n\n textarea {\n flex: 1;\n /* The body owns the resize/height now; the textarea fills it and scrolls\n its own overflow. min-height:0 lets it shrink when the body shrinks. */\n min-height: 0;\n width: 100%;\n padding: 12px;\n border: none;\n outline: none;\n resize: none;\n box-sizing: border-box;\n tab-size: 4;\n -moz-tab-size: 4;\n word-break: break-word;\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n color: inherit;\n background: var(--nile-colors-white-base, var(--ng-colors-bg-primary));\n border-radius: 0 0 var(--nile-radius-radius-xl, var(--ng-radius-md))\n var(--nile-radius-radius-xl, var(--ng-radius-md));\n }\n\n textarea::placeholder {\n color: var(--nile-colors-neutral-500, var(--ng-colors-text-secondary));\n font-family: var(--nile-font-family-sans-serif, var(--ng-font-family-body));\n opacity: 0.7;\n }\n\n .editor--disabled textarea {\n background: var(\n --nile-colors-dark-200,\n var(--ng-colors-bg-disabled-subtle)\n );\n color: var(--nile-colors-dark-500, var(--ng-colors-text-disabled));\n pointer-events: none;\n user-select: none;\n -webkit-user-select: none;\n }\n\n .pane--preview {\n min-height: 0;\n padding: 12px;\n overflow: auto;\n box-sizing: border-box;\n word-wrap: break-word;\n background: var(--nile-colors-white-base, var(--ng-colors-bg-primary));\n border-radius: 0 0 var(--nile-radius-radius-xl, var(--ng-radius-md))\n var(--nile-radius-radius-xl, var(--ng-radius-md));\n }\n\n .editor--disabled .pane--preview {\n background: var(\n --nile-colors-dark-200,\n var(--ng-colors-bg-disabled-subtle)\n );\n color: var(--nile-colors-dark-500, var(--ng-colors-text-disabled));\n }\n\n .editor--split .pane--preview {\n border-radius: 0 0 var(--nile-radius-radius-xl, var(--ng-radius-md)) 0;\n }\n\n .editor--split textarea {\n border-radius: 0 0 0 var(--nile-radius-radius-xl, var(--ng-radius-md));\n }\n\n .preview-empty {\n color: var(--nile-colors-neutral-500, var(--ng-colors-text-secondary));\n font-size: var(--nile-type-scale-2, var(--ng-font-size-text-sm));\n opacity: 0.7;\n }\n`;\n"]}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Aquera Inc 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import NileElement from '../internal/nile-element';
|
|
8
|
+
import '../nile-markdown/nile-markdown';
|
|
9
|
+
import '../nile-icon';
|
|
10
|
+
import '../nile-button-toggle-group/nile-button-toggle-group';
|
|
11
|
+
import '../nile-button-toggle/nile-button-toggle';
|
|
12
|
+
import '../nile-dropdown/nile-dropdown';
|
|
13
|
+
import '../nile-menu/nile-menu';
|
|
14
|
+
import '../nile-menu-item/nile-menu-item';
|
|
15
|
+
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
16
|
+
export type MarkdownEditorMode = 'write' | 'preview' | 'split';
|
|
17
|
+
/**
|
|
18
|
+
* Nile markdown editor component.
|
|
19
|
+
*
|
|
20
|
+
* @tag nile-markdown-editor
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* @summary A GitHub-style markdown editor with a formatting toolbar and a
|
|
24
|
+
* live preview rendered by `nile-markdown`.
|
|
25
|
+
* @status experimental
|
|
26
|
+
*
|
|
27
|
+
* @dependency nile-markdown
|
|
28
|
+
* @dependency nile-icon
|
|
29
|
+
* @dependency nile-glyph
|
|
30
|
+
* @dependency nile-button-toggle-group
|
|
31
|
+
* @dependency nile-button-toggle
|
|
32
|
+
*
|
|
33
|
+
* @attr {string} tools - JSON-array allowlist of toolbar tools to show, e.g.
|
|
34
|
+
* `tools='["bold","italic","link"]'`. Valid names: heading, bold, italic,
|
|
35
|
+
* strikethrough, quote, code, ul, ol, link. Empty shows all.
|
|
36
|
+
*
|
|
37
|
+
* @event nile-input - Emitted with `{ value }` on every keystroke or toolbar action.
|
|
38
|
+
* @event nile-change - Emitted with `{ value }` when the editor loses focus after an edit.
|
|
39
|
+
* @event nile-mode-change - Emitted with `{ mode }` when the write/preview/split mode changes.
|
|
40
|
+
*
|
|
41
|
+
* @csspart base - The component's base wrapper.
|
|
42
|
+
* @csspart header - The header containing the tabs and toolbar.
|
|
43
|
+
* @csspart toolbar - The formatting toolbar.
|
|
44
|
+
* @csspart textarea - The markdown source textarea.
|
|
45
|
+
* @csspart preview - The rendered preview pane.
|
|
46
|
+
*/
|
|
47
|
+
export declare class NileMarkdownEditor extends NileElement {
|
|
48
|
+
static styles: CSSResultGroup;
|
|
49
|
+
/** The markdown source. */
|
|
50
|
+
value: string;
|
|
51
|
+
/** Placeholder shown when the editor is empty. */
|
|
52
|
+
placeholder: string;
|
|
53
|
+
/** Disables the editor. */
|
|
54
|
+
disabled: boolean;
|
|
55
|
+
/** Makes the source read-only while still allowing mode switching. */
|
|
56
|
+
readonly: boolean;
|
|
57
|
+
/** Number of visible text rows in write mode. */
|
|
58
|
+
rows: number;
|
|
59
|
+
/** Active view: `write`, `preview`, or `split`. */
|
|
60
|
+
mode: MarkdownEditorMode;
|
|
61
|
+
/** Hides the formatting toolbar. */
|
|
62
|
+
hideToolbar: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Allowlist of toolbar tool names to show. Accepts a JSON array via the
|
|
65
|
+
* `tools` attribute (e.g. `tools='["bold","italic","link"]'`), a
|
|
66
|
+
* comma-separated string, or an array when set as a property. When empty
|
|
67
|
+
* (default) every tool is shown. Valid names: `heading`, `bold`, `italic`,
|
|
68
|
+
* `strikethrough`, `quote`, `code`, `ul`, `ol`, `link`.
|
|
69
|
+
*/
|
|
70
|
+
tools: string[];
|
|
71
|
+
/** Parsed allowlist, or `null` when no allowlist is set (show everything). */
|
|
72
|
+
private get allowedTools();
|
|
73
|
+
/** Toolbar groups after applying the allowlist; empty groups are dropped. */
|
|
74
|
+
private get visibleGroups();
|
|
75
|
+
private textarea?;
|
|
76
|
+
private bodyEl?;
|
|
77
|
+
/**
|
|
78
|
+
* Fraction of the body width given to the write pane in split mode
|
|
79
|
+
* (the rest goes to the preview). Clamped to a sensible range while
|
|
80
|
+
* dragging the splitter.
|
|
81
|
+
*/
|
|
82
|
+
private splitRatio;
|
|
83
|
+
/** Whether the split divider is currently being dragged. */
|
|
84
|
+
private splitDragging;
|
|
85
|
+
/** Begins a pointer-driven resize of the split divider. */
|
|
86
|
+
private startSplitDrag;
|
|
87
|
+
/** Resets the splitter to a 50/50 layout (double-click affordance). */
|
|
88
|
+
private resetSplit;
|
|
89
|
+
/** Moves focus to the textarea. */
|
|
90
|
+
focus(options?: FocusOptions): void;
|
|
91
|
+
blur(): void;
|
|
92
|
+
private setMode;
|
|
93
|
+
private handleInput;
|
|
94
|
+
private handleChange;
|
|
95
|
+
private handleKeydown;
|
|
96
|
+
/** Replaces the current selection and restores focus/selection. */
|
|
97
|
+
private replaceSelection;
|
|
98
|
+
/** Wraps (or unwraps) the selection with prefix/suffix delimiters. */
|
|
99
|
+
private applyWrap;
|
|
100
|
+
/** Toggles a markdown prefix on every line in the selection. */
|
|
101
|
+
private applyLinePrefix;
|
|
102
|
+
/** Inserts a `[text](url)` link, selecting the URL for quick editing. */
|
|
103
|
+
private insertLink;
|
|
104
|
+
private runAction;
|
|
105
|
+
/** Applies a heading-style line prefix chosen from a dropdown menu. */
|
|
106
|
+
private runMenuItem;
|
|
107
|
+
/** Renders the glyph/icon shown inside a toolbar control. */
|
|
108
|
+
private renderActionContent;
|
|
109
|
+
/** A standard click-to-apply toolbar button. */
|
|
110
|
+
private renderActionButton;
|
|
111
|
+
/** A toolbar control that opens a dropdown of line-prefix choices. */
|
|
112
|
+
private renderMenuAction;
|
|
113
|
+
private renderToolbar;
|
|
114
|
+
render(): TemplateResult;
|
|
115
|
+
}
|
|
116
|
+
export default NileMarkdownEditor;
|
|
117
|
+
declare global {
|
|
118
|
+
interface HTMLElementTagNameMap {
|
|
119
|
+
'nile-markdown-editor': NileMarkdownEditor;
|
|
120
|
+
}
|
|
121
|
+
}
|