@exmg/exm-markdown-editor 1.0.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 +25 -0
- package/index.d.ts +6 -0
- package/index.js +6 -0
- package/package.json +56 -0
- package/src/actions.d.ts +6 -0
- package/src/actions.js +227 -0
- package/src/exm-markdown-editor-base.d.ts +81 -0
- package/src/exm-markdown-editor-base.js +252 -0
- package/src/exm-markdown-editor-toolbar-base.d.ts +12 -0
- package/src/exm-markdown-editor-toolbar-base.js +52 -0
- package/src/exm-markdown-editor-toolbar.d.ts +9 -0
- package/src/exm-markdown-editor-toolbar.js +12 -0
- package/src/exm-markdown-editor.d.ts +76 -0
- package/src/exm-markdown-editor.js +83 -0
- package/src/icons.d.ts +6 -0
- package/src/icons.js +28 -0
- package/src/styles/exm-markdown-codemirror-css.d.ts +2 -0
- package/src/styles/exm-markdown-codemirror-css.js +4 -0
- package/src/styles/exm-markdown-codemirror.scss +443 -0
- package/src/styles/exm-markdown-editor-css.d.ts +2 -0
- package/src/styles/exm-markdown-editor-css.js +4 -0
- package/src/styles/exm-markdown-editor-toolbar-css.d.ts +2 -0
- package/src/styles/exm-markdown-editor-toolbar-css.js +4 -0
- package/src/styles/exm-markdown-editor-toolbar.scss +17 -0
- package/src/styles/exm-markdown-editor.scss +122 -0
- package/src/types.d.ts +13 -0
- package/src/types.js +2 -0
- package/src/utils/configurations.d.ts +4 -0
- package/src/utils/configurations.js +14 -0
- package/src/validator/exm-markdown-editor-validator.d.ts +23 -0
- package/src/validator/exm-markdown-editor-validator.js +35 -0
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
/* BASICS */
|
|
2
|
+
.CodeMirror {
|
|
3
|
+
/* Variables to use internaly */
|
|
4
|
+
--editor-code-color: var(--exm-markdown-editor-code-color, var(--md-sys-color-on-surface));
|
|
5
|
+
--editor-code-cursor-color: var(--exm-markdown-editor-code-cursor-color, var(--md-sys-color-on-surface));
|
|
6
|
+
--editor-code-header-color: var(--exm-markdown-editor-code-header-color, #4a8fc0);
|
|
7
|
+
--editor-code-inline-code-color: var(--exm-markdown-editor-code-inline-code-color, #ea881f);
|
|
8
|
+
// --editor-code-background-color: var(--exm-markdown-editor-code-background-color, var(--md-sys-color-surface));
|
|
9
|
+
--editor-code-list-color: var(--exm-markdown-editor-code-list-color, rgb(25, 165, 28));
|
|
10
|
+
--editor-selected-code-color: var(--exm-markdown-editor-selected-code-color, rgb(140, 140, 140));
|
|
11
|
+
/* Set height, width, borders, and global font properties here */
|
|
12
|
+
color: var(--editor-code-color, var(--md-sys-color-on-surface, black));
|
|
13
|
+
direction: ltr;
|
|
14
|
+
}
|
|
15
|
+
/* PADDING */
|
|
16
|
+
.CodeMirror-lines {
|
|
17
|
+
padding: 0; /* Vertical padding around content */
|
|
18
|
+
}
|
|
19
|
+
.CodeMirror pre {
|
|
20
|
+
padding: 0 1rem; /* Horizontal padding of content */
|
|
21
|
+
}
|
|
22
|
+
.CodeMirror-scrollbar-filler,
|
|
23
|
+
.CodeMirror-gutter-filler {
|
|
24
|
+
background-color: white; /* The little square between H and V scrollbars */
|
|
25
|
+
}
|
|
26
|
+
/* GUTTER */
|
|
27
|
+
.CodeMirror-gutters {
|
|
28
|
+
border-right: 1px solid #ddd;
|
|
29
|
+
background-color: #f7f7f7;
|
|
30
|
+
white-space: nowrap;
|
|
31
|
+
}
|
|
32
|
+
.CodeMirror-linenumber {
|
|
33
|
+
padding: 0 3px 0 5px;
|
|
34
|
+
min-width: 20px;
|
|
35
|
+
text-align: right;
|
|
36
|
+
color: #999;
|
|
37
|
+
white-space: nowrap;
|
|
38
|
+
}
|
|
39
|
+
.CodeMirror-guttermarker {
|
|
40
|
+
color: black;
|
|
41
|
+
}
|
|
42
|
+
.CodeMirror-guttermarker-subtle {
|
|
43
|
+
color: #999;
|
|
44
|
+
}
|
|
45
|
+
/* CURSOR */
|
|
46
|
+
.CodeMirror-cursor {
|
|
47
|
+
border-left: 1px solid var(--editor-code-cursor-color, var(--md-sys-color-on-surface, black));
|
|
48
|
+
}
|
|
49
|
+
/* Shown when moving in bi-directional text */
|
|
50
|
+
.CodeMirror div.CodeMirror-secondarycursor {
|
|
51
|
+
border-left: 1px solid silver;
|
|
52
|
+
}
|
|
53
|
+
.cm-fat-cursor .CodeMirror-cursor {
|
|
54
|
+
width: auto;
|
|
55
|
+
border: 0 !important;
|
|
56
|
+
background: #7e7;
|
|
57
|
+
}
|
|
58
|
+
.cm-fat-cursor div.CodeMirror-cursors {
|
|
59
|
+
z-index: 1;
|
|
60
|
+
}
|
|
61
|
+
.cm-fat-cursor-mark {
|
|
62
|
+
background-color: rgba(20, 255, 20, 0.5);
|
|
63
|
+
-webkit-animation: blink 1.06s steps(1) infinite;
|
|
64
|
+
-moz-animation: blink 1.06s steps(1) infinite;
|
|
65
|
+
animation: blink 1.06s steps(1) infinite;
|
|
66
|
+
}
|
|
67
|
+
.cm-animate-fat-cursor {
|
|
68
|
+
width: auto;
|
|
69
|
+
border: 0;
|
|
70
|
+
-webkit-animation: blink 1.06s steps(1) infinite;
|
|
71
|
+
-moz-animation: blink 1.06s steps(1) infinite;
|
|
72
|
+
animation: blink 1.06s steps(1) infinite;
|
|
73
|
+
background-color: #7e7;
|
|
74
|
+
}
|
|
75
|
+
@-moz-keyframes blink {
|
|
76
|
+
0% {
|
|
77
|
+
}
|
|
78
|
+
50% {
|
|
79
|
+
background-color: transparent;
|
|
80
|
+
}
|
|
81
|
+
100% {
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
@-webkit-keyframes blink {
|
|
85
|
+
0% {
|
|
86
|
+
}
|
|
87
|
+
50% {
|
|
88
|
+
background-color: transparent;
|
|
89
|
+
}
|
|
90
|
+
100% {
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
@keyframes blink {
|
|
94
|
+
0% {
|
|
95
|
+
}
|
|
96
|
+
50% {
|
|
97
|
+
background-color: transparent;
|
|
98
|
+
}
|
|
99
|
+
100% {
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/* Can style cursor different in overwrite (non-insert) mode */
|
|
103
|
+
.CodeMirror-overwrite .CodeMirror-cursor {
|
|
104
|
+
}
|
|
105
|
+
.cm-tab {
|
|
106
|
+
display: inline-block;
|
|
107
|
+
text-decoration: inherit;
|
|
108
|
+
}
|
|
109
|
+
.CodeMirror-rulers {
|
|
110
|
+
position: absolute;
|
|
111
|
+
left: 0;
|
|
112
|
+
right: 0;
|
|
113
|
+
top: -50px;
|
|
114
|
+
bottom: -20px;
|
|
115
|
+
overflow: hidden;
|
|
116
|
+
}
|
|
117
|
+
.CodeMirror-ruler {
|
|
118
|
+
border-left: 1px solid #ccc;
|
|
119
|
+
top: 0;
|
|
120
|
+
bottom: 0;
|
|
121
|
+
position: absolute;
|
|
122
|
+
}
|
|
123
|
+
/* DEFAULT THEME */
|
|
124
|
+
.cm-s-default .cm-header {
|
|
125
|
+
color: var(--editor-code-header-color);
|
|
126
|
+
}
|
|
127
|
+
.cm-s-default .cm-quote {
|
|
128
|
+
color: var(--editor-code-quote-color);
|
|
129
|
+
}
|
|
130
|
+
.cm-negative {
|
|
131
|
+
color: #d44;
|
|
132
|
+
}
|
|
133
|
+
.cm-positive {
|
|
134
|
+
color: #292;
|
|
135
|
+
}
|
|
136
|
+
.cm-header,
|
|
137
|
+
.cm-strong {
|
|
138
|
+
font-weight: bold;
|
|
139
|
+
}
|
|
140
|
+
.cm-em {
|
|
141
|
+
font-style: italic;
|
|
142
|
+
}
|
|
143
|
+
.cm-link {
|
|
144
|
+
text-decoration: underline;
|
|
145
|
+
}
|
|
146
|
+
.cm-strikethrough {
|
|
147
|
+
text-decoration: line-through;
|
|
148
|
+
}
|
|
149
|
+
.cm-s-default .cm-keyword {
|
|
150
|
+
color: #708;
|
|
151
|
+
}
|
|
152
|
+
.cm-s-default .cm-atom {
|
|
153
|
+
color: #219;
|
|
154
|
+
}
|
|
155
|
+
.cm-s-default .cm-number {
|
|
156
|
+
color: var(--editor-code-list-color);
|
|
157
|
+
}
|
|
158
|
+
.cm-s-default .cm-def {
|
|
159
|
+
color: #00f;
|
|
160
|
+
}
|
|
161
|
+
.cm-s-default .cm-variable,
|
|
162
|
+
.cm-s-default .cm-punctuation,
|
|
163
|
+
.cm-s-default .cm-property,
|
|
164
|
+
.cm-s-default .cm-operator {
|
|
165
|
+
}
|
|
166
|
+
.cm-s-default .cm-variable-2 {
|
|
167
|
+
color: var(--editor-code-list-color);
|
|
168
|
+
}
|
|
169
|
+
.cm-s-default .cm-variable-3,
|
|
170
|
+
.cm-s-default .cm-type {
|
|
171
|
+
color: var(--editor-code-list-color);
|
|
172
|
+
}
|
|
173
|
+
.cm-s-default .cm-comment {
|
|
174
|
+
color: #a50;
|
|
175
|
+
}
|
|
176
|
+
.cm-s-default .cm-string {
|
|
177
|
+
color: #a11;
|
|
178
|
+
}
|
|
179
|
+
.cm-s-default .cm-string-2 {
|
|
180
|
+
color: var(--editor-code-inline-code-color, #f50);
|
|
181
|
+
}
|
|
182
|
+
.cm-s-default .cm-meta {
|
|
183
|
+
color: #555;
|
|
184
|
+
}
|
|
185
|
+
.cm-s-default .cm-qualifier {
|
|
186
|
+
color: #555;
|
|
187
|
+
}
|
|
188
|
+
.cm-s-default .cm-builtin {
|
|
189
|
+
color: #30a;
|
|
190
|
+
}
|
|
191
|
+
.cm-s-default .cm-bracket {
|
|
192
|
+
color: #997;
|
|
193
|
+
}
|
|
194
|
+
.cm-s-default .cm-tag {
|
|
195
|
+
color: #170;
|
|
196
|
+
}
|
|
197
|
+
.cm-s-default .cm-attribute {
|
|
198
|
+
color: #00c;
|
|
199
|
+
}
|
|
200
|
+
.cm-s-default .cm-hr {
|
|
201
|
+
color: #999;
|
|
202
|
+
}
|
|
203
|
+
.cm-s-default .cm-link {
|
|
204
|
+
color: #00c;
|
|
205
|
+
}
|
|
206
|
+
.cm-s-default .cm-error {
|
|
207
|
+
color: #f00;
|
|
208
|
+
}
|
|
209
|
+
.cm-invalidchar {
|
|
210
|
+
color: #f00;
|
|
211
|
+
}
|
|
212
|
+
.CodeMirror-composing {
|
|
213
|
+
border-bottom: 2px solid;
|
|
214
|
+
}
|
|
215
|
+
/* Default styles for common addons */
|
|
216
|
+
div.CodeMirror span.CodeMirror-matchingbracket {
|
|
217
|
+
color: #0b0;
|
|
218
|
+
}
|
|
219
|
+
div.CodeMirror span.CodeMirror-nonmatchingbracket {
|
|
220
|
+
color: #a22;
|
|
221
|
+
}
|
|
222
|
+
.CodeMirror-matchingtag {
|
|
223
|
+
background: rgba(255, 150, 0, 0.3);
|
|
224
|
+
}
|
|
225
|
+
.CodeMirror-activeline-background {
|
|
226
|
+
background: #e8f2ff;
|
|
227
|
+
}
|
|
228
|
+
/* STOP */
|
|
229
|
+
/* The rest of this file contains styles related to the mechanics of
|
|
230
|
+
the editor. You probably shouldn't touch them. */
|
|
231
|
+
.CodeMirror {
|
|
232
|
+
position: relative;
|
|
233
|
+
overflow: hidden;
|
|
234
|
+
}
|
|
235
|
+
.CodeMirror-scroll {
|
|
236
|
+
overflow: scroll !important; /* Things will break if this is overridden */
|
|
237
|
+
/* 30px is the magic margin used to hide the element's real scrollbars */
|
|
238
|
+
/* See overflow: hidden in .CodeMirror */
|
|
239
|
+
margin-bottom: -30px;
|
|
240
|
+
margin-right: -30px;
|
|
241
|
+
padding-bottom: 30px;
|
|
242
|
+
height: 100%;
|
|
243
|
+
outline: none; /* Prevent dragging from highlighting the element */
|
|
244
|
+
position: relative;
|
|
245
|
+
box-sizing: border-box;
|
|
246
|
+
}
|
|
247
|
+
.CodeMirror-sizer {
|
|
248
|
+
position: relative;
|
|
249
|
+
border-right: 30px solid transparent;
|
|
250
|
+
}
|
|
251
|
+
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
|
252
|
+
before actual scrolling happens, thus preventing shaking and
|
|
253
|
+
flickering artifacts. */
|
|
254
|
+
.CodeMirror-vscrollbar,
|
|
255
|
+
.CodeMirror-hscrollbar,
|
|
256
|
+
.CodeMirror-scrollbar-filler,
|
|
257
|
+
.CodeMirror-gutter-filler {
|
|
258
|
+
position: absolute;
|
|
259
|
+
z-index: 6;
|
|
260
|
+
display: none;
|
|
261
|
+
}
|
|
262
|
+
.CodeMirror-vscrollbar {
|
|
263
|
+
right: 0;
|
|
264
|
+
top: 0;
|
|
265
|
+
overflow-x: hidden;
|
|
266
|
+
overflow-y: scroll;
|
|
267
|
+
}
|
|
268
|
+
.CodeMirror-hscrollbar {
|
|
269
|
+
bottom: 0;
|
|
270
|
+
left: 0;
|
|
271
|
+
overflow-y: hidden;
|
|
272
|
+
overflow-x: scroll;
|
|
273
|
+
}
|
|
274
|
+
.CodeMirror-scrollbar-filler {
|
|
275
|
+
right: 0;
|
|
276
|
+
bottom: 0;
|
|
277
|
+
}
|
|
278
|
+
.CodeMirror-gutter-filler {
|
|
279
|
+
left: 0;
|
|
280
|
+
bottom: 0;
|
|
281
|
+
}
|
|
282
|
+
.CodeMirror-gutters {
|
|
283
|
+
position: absolute;
|
|
284
|
+
left: 0;
|
|
285
|
+
top: 0;
|
|
286
|
+
min-height: 100%;
|
|
287
|
+
z-index: 3;
|
|
288
|
+
}
|
|
289
|
+
.CodeMirror-gutter {
|
|
290
|
+
white-space: normal;
|
|
291
|
+
height: 100%;
|
|
292
|
+
display: inline-block;
|
|
293
|
+
vertical-align: top;
|
|
294
|
+
margin-bottom: -30px;
|
|
295
|
+
}
|
|
296
|
+
.CodeMirror-gutter-wrapper {
|
|
297
|
+
position: absolute;
|
|
298
|
+
z-index: 4;
|
|
299
|
+
background: none !important;
|
|
300
|
+
border: none !important;
|
|
301
|
+
}
|
|
302
|
+
.CodeMirror-gutter-background {
|
|
303
|
+
position: absolute;
|
|
304
|
+
top: 0;
|
|
305
|
+
bottom: 0;
|
|
306
|
+
z-index: 4;
|
|
307
|
+
}
|
|
308
|
+
.CodeMirror-gutter-elt {
|
|
309
|
+
position: absolute;
|
|
310
|
+
cursor: default;
|
|
311
|
+
z-index: 4;
|
|
312
|
+
}
|
|
313
|
+
.CodeMirror-gutter-wrapper ::selection {
|
|
314
|
+
background-color: transparent;
|
|
315
|
+
}
|
|
316
|
+
.CodeMirror-gutter-wrapper ::-moz-selection {
|
|
317
|
+
background-color: transparent;
|
|
318
|
+
}
|
|
319
|
+
.CodeMirror-lines {
|
|
320
|
+
cursor: text;
|
|
321
|
+
min-height: 1px; /* prevents collapsing before first draw */
|
|
322
|
+
}
|
|
323
|
+
.CodeMirror pre {
|
|
324
|
+
/* Reset some styles that the rest of the page might have set */
|
|
325
|
+
-moz-border-radius: 0;
|
|
326
|
+
-webkit-border-radius: 0;
|
|
327
|
+
border-radius: 0;
|
|
328
|
+
border-width: 0;
|
|
329
|
+
background: transparent;
|
|
330
|
+
font-family: inherit;
|
|
331
|
+
font-size: inherit;
|
|
332
|
+
margin: 0;
|
|
333
|
+
white-space: pre;
|
|
334
|
+
word-wrap: normal;
|
|
335
|
+
line-height: inherit;
|
|
336
|
+
color: inherit;
|
|
337
|
+
z-index: 2;
|
|
338
|
+
position: relative;
|
|
339
|
+
overflow: visible;
|
|
340
|
+
-webkit-tap-highlight-color: transparent;
|
|
341
|
+
-webkit-font-variant-ligatures: contextual;
|
|
342
|
+
font-variant-ligatures: contextual;
|
|
343
|
+
}
|
|
344
|
+
.CodeMirror-wrap pre {
|
|
345
|
+
word-wrap: break-word;
|
|
346
|
+
white-space: pre-wrap;
|
|
347
|
+
word-break: normal;
|
|
348
|
+
}
|
|
349
|
+
.CodeMirror-linebackground {
|
|
350
|
+
position: absolute;
|
|
351
|
+
left: 0;
|
|
352
|
+
right: 0;
|
|
353
|
+
top: 0;
|
|
354
|
+
bottom: 0;
|
|
355
|
+
z-index: 0;
|
|
356
|
+
}
|
|
357
|
+
.CodeMirror-linewidget {
|
|
358
|
+
position: relative;
|
|
359
|
+
z-index: 2;
|
|
360
|
+
padding: 0.1px; /* Force widget margins to stay inside of the container */
|
|
361
|
+
}
|
|
362
|
+
.CodeMirror-rtl pre {
|
|
363
|
+
direction: rtl;
|
|
364
|
+
}
|
|
365
|
+
.CodeMirror-code {
|
|
366
|
+
outline: none;
|
|
367
|
+
}
|
|
368
|
+
/* Force content-box sizing for the elements where we expect it */
|
|
369
|
+
/* .CodeMirror-scroll, */
|
|
370
|
+
.CodeMirror-sizer,
|
|
371
|
+
.CodeMirror-gutter,
|
|
372
|
+
.CodeMirror-gutters,
|
|
373
|
+
.CodeMirror-linenumber {
|
|
374
|
+
-moz-box-sizing: content-box;
|
|
375
|
+
box-sizing: content-box;
|
|
376
|
+
}
|
|
377
|
+
.CodeMirror-measure {
|
|
378
|
+
position: absolute;
|
|
379
|
+
width: 100%;
|
|
380
|
+
height: 0;
|
|
381
|
+
overflow: hidden;
|
|
382
|
+
visibility: hidden;
|
|
383
|
+
}
|
|
384
|
+
.CodeMirror-cursor {
|
|
385
|
+
position: absolute;
|
|
386
|
+
pointer-events: none;
|
|
387
|
+
}
|
|
388
|
+
.CodeMirror-measure pre {
|
|
389
|
+
position: static;
|
|
390
|
+
}
|
|
391
|
+
div.CodeMirror-cursors {
|
|
392
|
+
visibility: hidden;
|
|
393
|
+
position: relative;
|
|
394
|
+
z-index: 3;
|
|
395
|
+
}
|
|
396
|
+
div.CodeMirror-dragcursors {
|
|
397
|
+
visibility: visible;
|
|
398
|
+
}
|
|
399
|
+
.CodeMirror-focused div.CodeMirror-cursors {
|
|
400
|
+
visibility: visible;
|
|
401
|
+
}
|
|
402
|
+
.CodeMirror-selected {
|
|
403
|
+
background: #d9d9d9;
|
|
404
|
+
}
|
|
405
|
+
.CodeMirror-focused .CodeMirror-selected {
|
|
406
|
+
background: var(--editor-selected-code-color);
|
|
407
|
+
}
|
|
408
|
+
.CodeMirror-crosshair {
|
|
409
|
+
cursor: crosshair;
|
|
410
|
+
}
|
|
411
|
+
.CodeMirror-line::selection,
|
|
412
|
+
.CodeMirror-line > span::selection,
|
|
413
|
+
.CodeMirror-line > span > span::selection {
|
|
414
|
+
background: #d7d4f0;
|
|
415
|
+
}
|
|
416
|
+
.CodeMirror-line::-moz-selection,
|
|
417
|
+
.CodeMirror-line > span::-moz-selection,
|
|
418
|
+
.CodeMirror-line > span > span::-moz-selection {
|
|
419
|
+
background: #d7d4f0;
|
|
420
|
+
}
|
|
421
|
+
.cm-searching {
|
|
422
|
+
background-color: #ffa;
|
|
423
|
+
background-color: rgba(255, 255, 0, 0.4);
|
|
424
|
+
}
|
|
425
|
+
/* Used to force a border model for a node */
|
|
426
|
+
.cm-force-border {
|
|
427
|
+
padding-right: 0.1px;
|
|
428
|
+
}
|
|
429
|
+
@media print {
|
|
430
|
+
/* Hide the cursor when printing */
|
|
431
|
+
.CodeMirror div.CodeMirror-cursors {
|
|
432
|
+
visibility: hidden;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
/* See issue #2901 */
|
|
436
|
+
.cm-tab-wrap-hack:after {
|
|
437
|
+
content: '';
|
|
438
|
+
}
|
|
439
|
+
/* Help users use markselection to safely style text background */
|
|
440
|
+
span.CodeMirror-selectedtext {
|
|
441
|
+
background: none;
|
|
442
|
+
}
|
|
443
|
+
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const style = css `:host{display:block;overflow:hidden;--editor-border-color: var(--exm-markdown-editor-border-color, var(--md-sys-color-on-surface-variant));--editor-border-color-focus: var(--exm-markdown-editor-border-color-focus, var(--md-sys-color-primary));--editor-background-color: var(--exm-markdown-editor-background-color, var(--md-sys-color-surface-container-high));--editor-code-background-color: var(--exm-markdown-editor-code-background-color, var(--md-sys-color-surface-container-high));--editor-background-focus-color: var(--exm-markdown-editor-background-focus-color, var(--md-sys-color-surface-container-high));--editor-code-background-focus-color: var(--exm-markdown-editor-code-background-focus-color, var(--md-sys-color-surface-container-highest));--editor-label-focus-color: var(--exm-markdown-editor-label-focus-color, var(--md-sys-color-primary));--editor-label-color: var(--exm-markdown-editor-label-color, var(--md-sys-color-on-surface))}.container{display:grid;position:relative;grid-template-columns:100%;grid-template-rows:0px 56px 1fr;transition:grid-template-rows .2s ease;border-top-right-radius:4px;background-color:var(--editor-code-background-color, var(--md-sys-color-surface-container-high));border-top-left-radius:4px}.container[label]{grid-template-rows:2rem 56px 1fr}.container:hover{background-color:var(--editor-code-background-focus-color, var(--md-sys-color-surface-container-highest))}.container::after{content:" ";display:block;position:absolute;bottom:0;width:100%;height:3px;background:var(--editor-border-color-focus, var(--md-sys-color-primary))}.container[preview]{background-color:var(--editor-background-color, var(--md-sys-color-surface-container-high));grid-template-rows:0px .3rem 1fr}.container[preview][label]{grid-template-rows:2rem .3rem 1fr}.container[preview]:hover{background-color:var(--editor-code-background-focus-color, var(--md-sys-color-surface-container-highest));cursor:text}.container[preview]::after{height:1px;background:var(--editor-border-color, var(--md-sys-color-on-surface-variant))}label[for=markdowdEditorContainer]{grid-row-start:1;padding:.5rem 0 0 1rem;font-size:.7rem;color:var(--editor-label-focus-color, var(--md-sys-color-primary));transition:all 200ms ease;transform:scale(1) translateY(0px)}label[for=markdowdEditorContainer][preview]{color:var(--editor-label-color, var(--md-sys-color-on-surface));padding-bottom:1rem;transform:translateY(8px);font-size:1rem}exm-markdown-editor-toolbar{grid-row-start:1;visibility:visible;transition:visibility 0s,opacity .5s linear;opacity:1}exm-markdown-editor-toolbar[preview]{visibility:hidden;opacity:0}exm-markdown-editor-toolbar[label]{grid-row-start:2}#preview{display:none;grid-row-start:3;overflow:scroll}#preview[preview]{display:block}#editor{display:block;grid-row-start:3}#editor[preview]{display:none}slot[name=preview]{display:none;grid-row-start:3}slot[name=preview][preview]{display:block}::slotted([slot=preview]){overflow:scroll}.preview-content{padding:0 1rem}`;
|
|
3
|
+
export default style;
|
|
4
|
+
//# sourceMappingURL=exm-markdown-editor-css.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const style = css `:host{display:block}.toolbar-container{padding:.5rem 1rem;display:flex}md-icon-button:not(:first){margin:0 .3rem}md-icon-button:first{margin:0 0}`;
|
|
3
|
+
export default style;
|
|
4
|
+
//# sourceMappingURL=exm-markdown-editor-toolbar-css.js.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/* NEW STYLES */
|
|
2
|
+
/** Editor **/
|
|
3
|
+
|
|
4
|
+
:host {
|
|
5
|
+
display: block;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
--editor-border-color: var(--exm-markdown-editor-border-color, var(--md-sys-color-on-surface-variant));
|
|
8
|
+
--editor-border-color-focus: var(--exm-markdown-editor-border-color-focus, var(--md-sys-color-primary));
|
|
9
|
+
--editor-background-color: var(--exm-markdown-editor-background-color, var(--md-sys-color-surface-container-high));
|
|
10
|
+
--editor-code-background-color: var(--exm-markdown-editor-code-background-color, var(--md-sys-color-surface-container-high));
|
|
11
|
+
--editor-background-focus-color: var(--exm-markdown-editor-background-focus-color, var(--md-sys-color-surface-container-high));
|
|
12
|
+
--editor-code-background-focus-color: var(--exm-markdown-editor-code-background-focus-color, var(--md-sys-color-surface-container-highest));
|
|
13
|
+
--editor-label-focus-color: var(--exm-markdown-editor-label-focus-color, var(--md-sys-color-primary));
|
|
14
|
+
--editor-label-color: var(--exm-markdown-editor-label-color, var(--md-sys-color-on-surface));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.container {
|
|
18
|
+
display: grid;
|
|
19
|
+
position: relative;
|
|
20
|
+
grid-template-columns: 100%;
|
|
21
|
+
grid-template-rows: 0px 56px 1fr;
|
|
22
|
+
transition: grid-template-rows .2s ease;
|
|
23
|
+
|
|
24
|
+
border-top-right-radius: 4px;
|
|
25
|
+
background-color: var(--editor-code-background-color, var(--md-sys-color-surface-container-high));
|
|
26
|
+
border-top-left-radius: 4px;
|
|
27
|
+
|
|
28
|
+
&[label] {
|
|
29
|
+
grid-template-rows: 2rem 56px 1fr;
|
|
30
|
+
}
|
|
31
|
+
&:hover {
|
|
32
|
+
background-color: var(--editor-code-background-focus-color, var(--md-sys-color-surface-container-highest));
|
|
33
|
+
}
|
|
34
|
+
&::after {
|
|
35
|
+
content: ' ';
|
|
36
|
+
display: block;
|
|
37
|
+
position: absolute;
|
|
38
|
+
bottom:0;
|
|
39
|
+
width: 100%;
|
|
40
|
+
height: 3px;
|
|
41
|
+
background: var(--editor-border-color-focus, var(--md-sys-color-primary));
|
|
42
|
+
}
|
|
43
|
+
&[preview] {
|
|
44
|
+
background-color: var(--editor-background-color, var(--md-sys-color-surface-container-high));
|
|
45
|
+
grid-template-rows: 0px .3rem 1fr;
|
|
46
|
+
&[label] {
|
|
47
|
+
grid-template-rows: 2rem .3rem 1fr;
|
|
48
|
+
}
|
|
49
|
+
&:hover {
|
|
50
|
+
background-color: var(--editor-code-background-focus-color, var(--md-sys-color-surface-container-highest));
|
|
51
|
+
cursor: text;
|
|
52
|
+
}
|
|
53
|
+
&::after {
|
|
54
|
+
height: 1px;
|
|
55
|
+
background: var(--editor-border-color, var(--md-sys-color-on-surface-variant));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
label[for='markdowdEditorContainer'] {
|
|
61
|
+
grid-row-start: 1;
|
|
62
|
+
padding: 0.5rem 0 0 1rem;
|
|
63
|
+
font-size: .7rem;
|
|
64
|
+
color: var(--editor-label-focus-color, var(--md-sys-color-primary));
|
|
65
|
+
transition: all 200ms ease;
|
|
66
|
+
transform: scale(1) translateY(0px);
|
|
67
|
+
&[preview] {
|
|
68
|
+
color: var(--editor-label-color, var(--md-sys-color-on-surface));
|
|
69
|
+
padding-bottom: 1rem;
|
|
70
|
+
transform:translateY(8px);
|
|
71
|
+
font-size: 1rem;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
exm-markdown-editor-toolbar {
|
|
76
|
+
grid-row-start: 1;
|
|
77
|
+
visibility: visible;
|
|
78
|
+
transition: visibility 0s, opacity 0.5s linear;
|
|
79
|
+
opacity: 1;
|
|
80
|
+
&[preview] {
|
|
81
|
+
visibility: hidden;
|
|
82
|
+
opacity: 0;
|
|
83
|
+
}
|
|
84
|
+
&[label] {
|
|
85
|
+
grid-row-start:2;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
#preview {
|
|
90
|
+
display: none;
|
|
91
|
+
grid-row-start: 3;
|
|
92
|
+
overflow: scroll;
|
|
93
|
+
&[preview] {
|
|
94
|
+
display: block;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#editor {
|
|
99
|
+
display: block;
|
|
100
|
+
grid-row-start: 3;
|
|
101
|
+
&[preview] {
|
|
102
|
+
display: none;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
slot[name='preview'] {
|
|
107
|
+
display: none;
|
|
108
|
+
grid-row-start: 3;
|
|
109
|
+
&[preview] {
|
|
110
|
+
display: block;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
::slotted([slot='preview']) {
|
|
115
|
+
overflow: scroll;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* Html rendering CSS */
|
|
119
|
+
|
|
120
|
+
.preview-content {
|
|
121
|
+
padding: 0 1rem;
|
|
122
|
+
}
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HTMLTemplateResult } from 'lit';
|
|
2
|
+
/** Toolbar Types */
|
|
3
|
+
export type ToolbarItem = {
|
|
4
|
+
name: string;
|
|
5
|
+
icon: string;
|
|
6
|
+
};
|
|
7
|
+
export type ToolbarIcons = {
|
|
8
|
+
[k: string]: HTMLTemplateResult;
|
|
9
|
+
};
|
|
10
|
+
/** Editor Types */
|
|
11
|
+
export type MarkdownActions = {
|
|
12
|
+
[key: string]: Function;
|
|
13
|
+
};
|
package/src/types.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const defaultConfiguration = {
|
|
2
|
+
mode: 'markdown',
|
|
3
|
+
tabSize: 2,
|
|
4
|
+
indentUnit: 2,
|
|
5
|
+
indentWithTabs: true,
|
|
6
|
+
lineNumbers: false,
|
|
7
|
+
autofocus: false,
|
|
8
|
+
lineWrapping: true,
|
|
9
|
+
};
|
|
10
|
+
export const markedConfiguration = {
|
|
11
|
+
breaks: false,
|
|
12
|
+
pedantic: false,
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=configurations.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Validator } from '@material/web/labs/behaviors/validators/validator.js';
|
|
7
|
+
export interface MarkdownEditorState {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the checkbox is required.
|
|
10
|
+
*/
|
|
11
|
+
readonly required: boolean;
|
|
12
|
+
readonly value: string;
|
|
13
|
+
readonly internalElement?: HTMLInputElement;
|
|
14
|
+
}
|
|
15
|
+
export declare class MardownEditorValidator extends Validator<MarkdownEditorState> {
|
|
16
|
+
private inputElement?;
|
|
17
|
+
protected computeValidity(state: MarkdownEditorState): {
|
|
18
|
+
validity: ValidityState;
|
|
19
|
+
validationMessage: string;
|
|
20
|
+
};
|
|
21
|
+
protected equals(prevState: MarkdownEditorState, state: MarkdownEditorState): boolean;
|
|
22
|
+
protected copy(state: MarkdownEditorState): MarkdownEditorState;
|
|
23
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Validator } from '@material/web/labs/behaviors/validators/validator.js';
|
|
7
|
+
export class MardownEditorValidator extends Validator {
|
|
8
|
+
computeValidity(state) {
|
|
9
|
+
var _a;
|
|
10
|
+
if (!this.inputElement) {
|
|
11
|
+
this.inputElement = state.internalElement;
|
|
12
|
+
}
|
|
13
|
+
if (!this.inputElement) {
|
|
14
|
+
// Lazily create the input element if not existing
|
|
15
|
+
this.inputElement = document.createElement('input');
|
|
16
|
+
this.inputElement.type = 'text';
|
|
17
|
+
}
|
|
18
|
+
// Set values to the input element
|
|
19
|
+
this.inputElement.value = (_a = state.value) !== null && _a !== void 0 ? _a : '';
|
|
20
|
+
this.inputElement.required = state.required;
|
|
21
|
+
return {
|
|
22
|
+
validity: this.inputElement.validity,
|
|
23
|
+
validationMessage: this.inputElement.validationMessage,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
equals(prevState, state) {
|
|
27
|
+
return prevState.value === state.value && prevState.required === state.required;
|
|
28
|
+
}
|
|
29
|
+
copy(state) {
|
|
30
|
+
return {
|
|
31
|
+
...state,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=exm-markdown-editor-validator.js.map
|