@exmg/exm-markdown-editor 0.0.2-alpha.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.
@@ -0,0 +1,491 @@
1
+ import { css } from 'lit';
2
+ export const style = css `
3
+ .CodeMirror {
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-list-color: var(--exm-markdown-editor-code-list-color, rgb(25, 165, 28));
9
+ --editor-selected-code-color: var(--exm-markdown-editor-selected-code-color, rgb(140, 140, 140));
10
+ color: var(--editor-code-color, var(--md-sys-color-on-surface, black));
11
+ direction: ltr;
12
+ }
13
+
14
+ .CodeMirror-lines {
15
+ padding: 0;
16
+ }
17
+
18
+ .CodeMirror pre {
19
+ padding: 0 1rem;
20
+ }
21
+
22
+ .CodeMirror-scrollbar-filler,
23
+ .CodeMirror-gutter-filler {
24
+ background-color: #fff;
25
+ }
26
+
27
+ .CodeMirror-gutters {
28
+ border-right: 1px solid #ddd;
29
+ background-color: #f7f7f7;
30
+ white-space: nowrap;
31
+ }
32
+
33
+ .CodeMirror-linenumber {
34
+ padding: 0 3px 0 5px;
35
+ min-width: 20px;
36
+ text-align: right;
37
+ color: #999;
38
+ white-space: nowrap;
39
+ }
40
+
41
+ .CodeMirror-guttermarker {
42
+ color: #000;
43
+ }
44
+
45
+ .CodeMirror-guttermarker-subtle {
46
+ color: #999;
47
+ }
48
+
49
+ .CodeMirror-cursor {
50
+ border-left: 1px solid var(--editor-code-cursor-color, var(--md-sys-color-on-surface, black));
51
+ }
52
+
53
+ .CodeMirror div.CodeMirror-secondarycursor {
54
+ border-left: 1px solid silver;
55
+ }
56
+
57
+ .cm-fat-cursor .CodeMirror-cursor {
58
+ width: auto;
59
+ border: 0 !important;
60
+ background: #7e7;
61
+ }
62
+
63
+ .cm-fat-cursor div.CodeMirror-cursors {
64
+ z-index: 1;
65
+ }
66
+
67
+ .cm-fat-cursor-mark {
68
+ background-color: rgba(20, 255, 20, 0.5);
69
+ -webkit-animation: blink 1.06s steps(1) infinite;
70
+ -moz-animation: blink 1.06s steps(1) infinite;
71
+ animation: blink 1.06s steps(1) infinite;
72
+ }
73
+
74
+ .cm-animate-fat-cursor {
75
+ width: auto;
76
+ border: 0;
77
+ -webkit-animation: blink 1.06s steps(1) infinite;
78
+ -moz-animation: blink 1.06s steps(1) infinite;
79
+ animation: blink 1.06s steps(1) infinite;
80
+ background-color: #7e7;
81
+ }
82
+
83
+ @-moz-keyframes blink {
84
+ 50% {
85
+ background-color: rgba(0, 0, 0, 0);
86
+ }
87
+ }
88
+
89
+ @-webkit-keyframes blink {
90
+ 50% {
91
+ background-color: rgba(0, 0, 0, 0);
92
+ }
93
+ }
94
+
95
+ @keyframes blink {
96
+ 50% {
97
+ background-color: rgba(0, 0, 0, 0);
98
+ }
99
+ }
100
+
101
+ .cm-tab {
102
+ display: inline-block;
103
+ text-decoration: inherit;
104
+ }
105
+
106
+ .CodeMirror-rulers {
107
+ position: absolute;
108
+ left: 0;
109
+ right: 0;
110
+ top: -50px;
111
+ bottom: -20px;
112
+ overflow: hidden;
113
+ }
114
+
115
+ .CodeMirror-ruler {
116
+ border-left: 1px solid #ccc;
117
+ top: 0;
118
+ bottom: 0;
119
+ position: absolute;
120
+ }
121
+
122
+ .cm-s-default .cm-header {
123
+ color: var(--editor-code-header-color);
124
+ }
125
+
126
+ .cm-s-default .cm-quote {
127
+ color: var(--editor-code-quote-color);
128
+ }
129
+
130
+ .cm-negative {
131
+ color: #d44;
132
+ }
133
+
134
+ .cm-positive {
135
+ color: #292;
136
+ }
137
+
138
+ .cm-header,
139
+ .cm-strong {
140
+ font-weight: bold;
141
+ }
142
+
143
+ .cm-em {
144
+ font-style: italic;
145
+ }
146
+
147
+ .cm-link {
148
+ text-decoration: underline;
149
+ }
150
+
151
+ .cm-strikethrough {
152
+ text-decoration: line-through;
153
+ }
154
+
155
+ .cm-s-default .cm-keyword {
156
+ color: #708;
157
+ }
158
+
159
+ .cm-s-default .cm-atom {
160
+ color: #219;
161
+ }
162
+
163
+ .cm-s-default .cm-number {
164
+ color: var(--editor-code-list-color);
165
+ }
166
+
167
+ .cm-s-default .cm-def {
168
+ color: blue;
169
+ }
170
+
171
+ .cm-s-default .cm-variable-2 {
172
+ color: var(--editor-code-list-color);
173
+ }
174
+
175
+ .cm-s-default .cm-variable-3,
176
+ .cm-s-default .cm-type {
177
+ color: var(--editor-code-list-color);
178
+ }
179
+
180
+ .cm-s-default .cm-comment {
181
+ color: #a50;
182
+ }
183
+
184
+ .cm-s-default .cm-string {
185
+ color: #a11;
186
+ }
187
+
188
+ .cm-s-default .cm-string-2 {
189
+ color: var(--editor-code-inline-code-color, #f50);
190
+ }
191
+
192
+ .cm-s-default .cm-meta {
193
+ color: #555;
194
+ }
195
+
196
+ .cm-s-default .cm-qualifier {
197
+ color: #555;
198
+ }
199
+
200
+ .cm-s-default .cm-builtin {
201
+ color: #30a;
202
+ }
203
+
204
+ .cm-s-default .cm-bracket {
205
+ color: #997;
206
+ }
207
+
208
+ .cm-s-default .cm-tag {
209
+ color: #170;
210
+ }
211
+
212
+ .cm-s-default .cm-attribute {
213
+ color: #00c;
214
+ }
215
+
216
+ .cm-s-default .cm-hr {
217
+ color: #999;
218
+ }
219
+
220
+ .cm-s-default .cm-link {
221
+ color: #00c;
222
+ }
223
+
224
+ .cm-s-default .cm-error {
225
+ color: red;
226
+ }
227
+
228
+ .cm-invalidchar {
229
+ color: red;
230
+ }
231
+
232
+ .CodeMirror-composing {
233
+ border-bottom: 2px solid;
234
+ }
235
+
236
+ div.CodeMirror span.CodeMirror-matchingbracket {
237
+ color: #0b0;
238
+ }
239
+
240
+ div.CodeMirror span.CodeMirror-nonmatchingbracket {
241
+ color: #a22;
242
+ }
243
+
244
+ .CodeMirror-matchingtag {
245
+ background: rgba(255, 150, 0, 0.3);
246
+ }
247
+
248
+ .CodeMirror-activeline-background {
249
+ background: #e8f2ff;
250
+ }
251
+
252
+ .CodeMirror {
253
+ position: relative;
254
+ overflow: hidden;
255
+ }
256
+
257
+ .CodeMirror-scroll {
258
+ overflow: scroll !important;
259
+ margin-bottom: -30px;
260
+ margin-right: -30px;
261
+ padding-bottom: 30px;
262
+ height: 100%;
263
+ outline: none;
264
+ position: relative;
265
+ box-sizing: border-box;
266
+ }
267
+
268
+ .CodeMirror-sizer {
269
+ position: relative;
270
+ border-right: 30px solid rgba(0, 0, 0, 0);
271
+ }
272
+
273
+ .CodeMirror-vscrollbar,
274
+ .CodeMirror-hscrollbar,
275
+ .CodeMirror-scrollbar-filler,
276
+ .CodeMirror-gutter-filler {
277
+ position: absolute;
278
+ z-index: 6;
279
+ display: none;
280
+ }
281
+
282
+ .CodeMirror-vscrollbar {
283
+ right: 0;
284
+ top: 0;
285
+ overflow-x: hidden;
286
+ overflow-y: scroll;
287
+ }
288
+
289
+ .CodeMirror-hscrollbar {
290
+ bottom: 0;
291
+ left: 0;
292
+ overflow-y: hidden;
293
+ overflow-x: scroll;
294
+ }
295
+
296
+ .CodeMirror-scrollbar-filler {
297
+ right: 0;
298
+ bottom: 0;
299
+ }
300
+
301
+ .CodeMirror-gutter-filler {
302
+ left: 0;
303
+ bottom: 0;
304
+ }
305
+
306
+ .CodeMirror-gutters {
307
+ position: absolute;
308
+ left: 0;
309
+ top: 0;
310
+ min-height: 100%;
311
+ z-index: 3;
312
+ }
313
+
314
+ .CodeMirror-gutter {
315
+ white-space: normal;
316
+ height: 100%;
317
+ display: inline-block;
318
+ vertical-align: top;
319
+ margin-bottom: -30px;
320
+ }
321
+
322
+ .CodeMirror-gutter-wrapper {
323
+ position: absolute;
324
+ z-index: 4;
325
+ background: none !important;
326
+ border: none !important;
327
+ }
328
+
329
+ .CodeMirror-gutter-background {
330
+ position: absolute;
331
+ top: 0;
332
+ bottom: 0;
333
+ z-index: 4;
334
+ }
335
+
336
+ .CodeMirror-gutter-elt {
337
+ position: absolute;
338
+ cursor: default;
339
+ z-index: 4;
340
+ }
341
+
342
+ .CodeMirror-gutter-wrapper ::selection {
343
+ background-color: rgba(0, 0, 0, 0);
344
+ }
345
+
346
+ .CodeMirror-gutter-wrapper ::-moz-selection {
347
+ background-color: rgba(0, 0, 0, 0);
348
+ }
349
+
350
+ .CodeMirror-lines {
351
+ cursor: text;
352
+ min-height: 1px;
353
+ }
354
+
355
+ .CodeMirror pre {
356
+ -moz-border-radius: 0;
357
+ -webkit-border-radius: 0;
358
+ border-radius: 0;
359
+ border-width: 0;
360
+ background: rgba(0, 0, 0, 0);
361
+ font-family: inherit;
362
+ font-size: inherit;
363
+ margin: 0;
364
+ white-space: pre;
365
+ word-wrap: normal;
366
+ line-height: inherit;
367
+ color: inherit;
368
+ z-index: 2;
369
+ position: relative;
370
+ overflow: visible;
371
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
372
+ -webkit-font-variant-ligatures: contextual;
373
+ font-variant-ligatures: contextual;
374
+ }
375
+
376
+ .CodeMirror-wrap pre {
377
+ word-wrap: break-word;
378
+ white-space: pre-wrap;
379
+ word-break: normal;
380
+ }
381
+
382
+ .CodeMirror-linebackground {
383
+ position: absolute;
384
+ left: 0;
385
+ right: 0;
386
+ top: 0;
387
+ bottom: 0;
388
+ z-index: 0;
389
+ }
390
+
391
+ .CodeMirror-linewidget {
392
+ position: relative;
393
+ z-index: 2;
394
+ padding: 0.1px;
395
+ }
396
+
397
+ .CodeMirror-rtl pre {
398
+ direction: rtl;
399
+ }
400
+
401
+ .CodeMirror-code {
402
+ outline: none;
403
+ }
404
+
405
+ .CodeMirror-sizer,
406
+ .CodeMirror-gutter,
407
+ .CodeMirror-gutters,
408
+ .CodeMirror-linenumber {
409
+ -moz-box-sizing: content-box;
410
+ box-sizing: content-box;
411
+ }
412
+
413
+ .CodeMirror-measure {
414
+ position: absolute;
415
+ width: 100%;
416
+ height: 0;
417
+ overflow: hidden;
418
+ visibility: hidden;
419
+ }
420
+
421
+ .CodeMirror-cursor {
422
+ position: absolute;
423
+ pointer-events: none;
424
+ }
425
+
426
+ .CodeMirror-measure pre {
427
+ position: static;
428
+ }
429
+
430
+ div.CodeMirror-cursors {
431
+ visibility: hidden;
432
+ position: relative;
433
+ z-index: 3;
434
+ }
435
+
436
+ div.CodeMirror-dragcursors {
437
+ visibility: visible;
438
+ }
439
+
440
+ .CodeMirror-focused div.CodeMirror-cursors {
441
+ visibility: visible;
442
+ }
443
+
444
+ .CodeMirror-selected {
445
+ background: #d9d9d9;
446
+ }
447
+
448
+ .CodeMirror-focused .CodeMirror-selected {
449
+ background: var(--editor-selected-code-color);
450
+ }
451
+
452
+ .CodeMirror-crosshair {
453
+ cursor: crosshair;
454
+ }
455
+
456
+ .CodeMirror-line::selection,
457
+ .CodeMirror-line > span::selection,
458
+ .CodeMirror-line > span > span::selection {
459
+ background: #d7d4f0;
460
+ }
461
+
462
+ .CodeMirror-line::-moz-selection,
463
+ .CodeMirror-line > span::-moz-selection,
464
+ .CodeMirror-line > span > span::-moz-selection {
465
+ background: #d7d4f0;
466
+ }
467
+
468
+ .cm-searching {
469
+ background-color: #ffa;
470
+ background-color: rgba(255, 255, 0, 0.4);
471
+ }
472
+
473
+ .cm-force-border {
474
+ padding-right: 0.1px;
475
+ }
476
+
477
+ @media print {
478
+ .CodeMirror div.CodeMirror-cursors {
479
+ visibility: hidden;
480
+ }
481
+ }
482
+
483
+ .cm-tab-wrap-hack:after {
484
+ content: '';
485
+ }
486
+
487
+ span.CodeMirror-selectedtext {
488
+ background: none;
489
+ }
490
+ `;
491
+ //# sourceMappingURL=exm-markdown-codemirror-css.js.map
@@ -0,0 +1 @@
1
+ export declare const style: import("lit").CSSResult;
@@ -0,0 +1,143 @@
1
+ import { css } from 'lit';
2
+ export const style = css `
3
+ :host {
4
+ display: block;
5
+ overflow: hidden;
6
+ --editor-border-color: var(--exm-markdown-editor-border-color, var(--md-sys-color-on-surface-variant));
7
+ --editor-border-color-focus: var(--exm-markdown-editor-border-color-focus, var(--md-sys-color-primary));
8
+ --editor-background-color: var(--exm-markdown-editor-background-color, var(--md-sys-color-surface-container-high));
9
+ --editor-code-background-color: var(
10
+ --exm-markdown-editor-code-background-color,
11
+ var(--md-sys-color-surface-container-high)
12
+ );
13
+ --editor-background-focus-color: var(
14
+ --exm-markdown-editor-background-focus-color,
15
+ var(--md-sys-color-surface-container-high)
16
+ );
17
+ --editor-code-background-focus-color: var(
18
+ --exm-markdown-editor-code-background-focus-color,
19
+ var(--md-sys-color-surface-container-highest)
20
+ );
21
+ --editor-label-focus-color: var(--exm-markdown-editor-label-focus-color, var(--md-sys-color-primary));
22
+ --editor-label-color: var(--exm-markdown-editor-label-color, var(--md-sys-color-on-surface));
23
+ }
24
+
25
+ .container {
26
+ display: grid;
27
+ position: relative;
28
+ grid-template-columns: 100%;
29
+ grid-template-rows: 0px 56px 1fr;
30
+ transition: grid-template-rows 0.2s ease;
31
+ border-top-right-radius: 4px;
32
+ background-color: var(--editor-code-background-color, var(--md-sys-color-surface-container-high));
33
+ border-top-left-radius: 4px;
34
+ }
35
+
36
+ .container[label] {
37
+ grid-template-rows: 2rem 56px 1fr;
38
+ }
39
+
40
+ .container:hover {
41
+ background-color: var(--editor-code-background-focus-color, var(--md-sys-color-surface-container-highest));
42
+ }
43
+
44
+ .container::after {
45
+ content: ' ';
46
+ display: block;
47
+ position: absolute;
48
+ bottom: 0;
49
+ width: 100%;
50
+ height: 3px;
51
+ background: var(--editor-border-color-focus, var(--md-sys-color-primary));
52
+ }
53
+
54
+ .container[preview] {
55
+ background-color: var(--editor-background-color, var(--md-sys-color-surface-container-high));
56
+ grid-template-rows: 0px 0.3rem 1fr;
57
+ }
58
+
59
+ .container[preview][label] {
60
+ grid-template-rows: 2rem 0.3rem 1fr;
61
+ }
62
+
63
+ .container[preview]:hover {
64
+ background-color: var(--editor-code-background-focus-color, var(--md-sys-color-surface-container-highest));
65
+ cursor: text;
66
+ }
67
+
68
+ .container[preview]::after {
69
+ height: 1px;
70
+ background: var(--editor-border-color, var(--md-sys-color-on-surface-variant));
71
+ }
72
+
73
+ label[for='markdowdEditorContainer'] {
74
+ grid-row-start: 1;
75
+ padding: 0.5rem 0 0 1rem;
76
+ font-size: 0.7rem;
77
+ color: var(--editor-label-focus-color, var(--md-sys-color-primary));
78
+ transition: all 200ms ease;
79
+ transform: scale(1) translateY(0px);
80
+ }
81
+
82
+ label[for='markdowdEditorContainer'][preview] {
83
+ color: var(--editor-label-color, var(--md-sys-color-on-surface));
84
+ padding-bottom: 1rem;
85
+ transform: translateY(8px);
86
+ font-size: 1rem;
87
+ }
88
+
89
+ exm-markdown-editor-toolbar {
90
+ grid-row-start: 1;
91
+ visibility: visible;
92
+ transition:
93
+ visibility 0s,
94
+ opacity 0.5s linear;
95
+ opacity: 1;
96
+ }
97
+
98
+ exm-markdown-editor-toolbar[preview] {
99
+ visibility: hidden;
100
+ opacity: 0;
101
+ }
102
+
103
+ exm-markdown-editor-toolbar[label] {
104
+ grid-row-start: 2;
105
+ }
106
+
107
+ #preview {
108
+ display: none;
109
+ grid-row-start: 3;
110
+ overflow: scroll;
111
+ }
112
+
113
+ #preview[preview] {
114
+ display: block;
115
+ }
116
+
117
+ #editor {
118
+ display: block;
119
+ grid-row-start: 3;
120
+ }
121
+
122
+ #editor[preview] {
123
+ display: none;
124
+ }
125
+
126
+ slot[name='preview'] {
127
+ display: none;
128
+ grid-row-start: 3;
129
+ }
130
+
131
+ slot[name='preview'][preview] {
132
+ display: block;
133
+ }
134
+
135
+ ::slotted([slot='preview']) {
136
+ overflow: scroll;
137
+ }
138
+
139
+ .preview-content {
140
+ padding: 0 1rem;
141
+ }
142
+ `;
143
+ //# sourceMappingURL=exm-markdown-editor-css.js.map
@@ -0,0 +1 @@
1
+ export declare const style: import("lit").CSSResult;
@@ -0,0 +1,20 @@
1
+ import { css } from 'lit';
2
+ export const style = css `
3
+ :host {
4
+ display: block;
5
+ }
6
+
7
+ .toolbar-container {
8
+ padding: 0.5rem 1rem;
9
+ display: flex;
10
+ }
11
+
12
+ md-icon-button:not(:first) {
13
+ margin: 0 0.3rem;
14
+ }
15
+
16
+ md-icon-button:first {
17
+ margin: 0 0;
18
+ }
19
+ `;
20
+ //# sourceMappingURL=exm-markdown-editor-toolbar-css.js.map
@@ -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/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,4 @@
1
+ import { EditorConfiguration } from 'codemirror';
2
+ import { MarkedOptions } from 'marked';
3
+ export declare const defaultConfiguration: EditorConfiguration;
4
+ export declare const markedConfiguration: MarkedOptions;
@@ -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
+ }