@limetech/lime-elements 37.44.2 → 37.45.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +131 -11
  3. package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js.map +1 -1
  4. package/dist/cjs/limel-snackbar.cjs.entry.js +5 -5
  5. package/dist/cjs/limel-snackbar.cjs.entry.js.map +1 -1
  6. package/dist/cjs/limel-text-editor.cjs.entry.js.map +1 -1
  7. package/dist/collection/components/snackbar/snackbar.css +39 -354
  8. package/dist/collection/components/snackbar/snackbar.js +4 -4
  9. package/dist/collection/components/snackbar/snackbar.js.map +1 -1
  10. package/dist/collection/components/text-editor/prosemirror-adapter/menu/menu-commands.js +81 -10
  11. package/dist/collection/components/text-editor/prosemirror-adapter/menu/menu-commands.js.map +1 -1
  12. package/dist/collection/components/text-editor/prosemirror-adapter/menu/menu-items.js +27 -0
  13. package/dist/collection/components/text-editor/prosemirror-adapter/menu/menu-items.js.map +1 -1
  14. package/dist/collection/components/text-editor/prosemirror-adapter/menu/menu-schema-extender.js +12 -0
  15. package/dist/collection/components/text-editor/prosemirror-adapter/menu/menu-schema-extender.js.map +1 -0
  16. package/dist/collection/components/text-editor/prosemirror-adapter/menu/types.js +3 -0
  17. package/dist/collection/components/text-editor/prosemirror-adapter/menu/types.js.map +1 -1
  18. package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.js +4 -1
  19. package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.js.map +1 -1
  20. package/dist/collection/components/text-editor/text-editor.js +1 -1
  21. package/dist/collection/components/text-editor/text-editor.js.map +1 -1
  22. package/dist/collection/components/text-editor/utils/markdown-converter.js +8 -2
  23. package/dist/collection/components/text-editor/utils/markdown-converter.js.map +1 -1
  24. package/dist/collection/util/get-attributes.js +27 -0
  25. package/dist/collection/util/get-attributes.js.map +1 -0
  26. package/dist/esm/limel-prosemirror-adapter.entry.js +131 -11
  27. package/dist/esm/limel-prosemirror-adapter.entry.js.map +1 -1
  28. package/dist/esm/limel-snackbar.entry.js +5 -5
  29. package/dist/esm/limel-snackbar.entry.js.map +1 -1
  30. package/dist/esm/limel-text-editor.entry.js.map +1 -1
  31. package/dist/lime-elements/lime-elements.esm.js +1 -1
  32. package/dist/lime-elements/{p-50a34fa3.entry.js → p-1ffe31d4.entry.js} +2 -2
  33. package/dist/lime-elements/p-1ffe31d4.entry.js.map +1 -0
  34. package/dist/lime-elements/p-5cfed8a8.entry.js +90 -0
  35. package/dist/lime-elements/{p-25d2faff.entry.js.map → p-5cfed8a8.entry.js.map} +1 -1
  36. package/dist/lime-elements/p-c5f96fcd.entry.js.map +1 -1
  37. package/dist/types/components/text-editor/prosemirror-adapter/menu/menu-commands.d.ts +9 -6
  38. package/dist/types/components/text-editor/prosemirror-adapter/menu/menu-items.d.ts +3 -0
  39. package/dist/types/components/text-editor/prosemirror-adapter/menu/menu-schema-extender.d.ts +3 -0
  40. package/dist/types/util/get-attributes.d.ts +15 -0
  41. package/package.json +1 -1
  42. package/dist/lime-elements/p-25d2faff.entry.js +0 -90
  43. package/dist/lime-elements/p-50a34fa3.entry.js.map +0 -1
@@ -1,114 +1,24 @@
1
- /*
2
- * This file is imported into every component!
3
- *
4
- * Nothing in this file may output any CSS
5
- * without being explicitly called by outside code.
6
- */
7
- /*
8
- * This file is imported into every component that uses MDC!
9
- *
10
- * Anything in this file that generates CSS output on its own,
11
- * without being explicitly used, will output that CSS in every
12
- * single component, increasing the size of the production build.
13
- * Avoid that unless there's very good reason for it!
14
- */
15
- /*
16
- * This file is imported into every component that uses MDC!
17
- *
18
- * Anything in this file that generates CSS output on its own,
19
- * without being explicitly used, will output that CSS in every
20
- * single component, increasing the size of the production build.
21
- * Avoid that unless there's very good reason for it!
1
+ /**
2
+ * @prop --snackbar-top: Snackbar has `position: fixed;` and uses `--snackbar-top`, which defaults to `auto` for its `top` property. See the examples in the documentations for further info.
3
+ * @prop --snackbar-right: Snackbar has `position: fixed;` and uses `--snackbar-right`, which defaults to `0` for its `right` property. See the examples in the documentations for further info.
4
+ * @prop --snackbar-bottom: Snackbar has `position: fixed;` and uses `--snackbar-bottom`, which defaults to `0` for its `bottom` property. See the examples in the documentations for further info.
5
+ * @prop --snackbar-left: Snackbar has `position: fixed;` and uses `--snackbar-left`, which defaults to `0` for its `left` property. See the examples in the documentations for further info.
22
6
  */
23
- :host {
24
- --mdc-theme-primary: var(
25
- --lime-primary-color,
26
- rgb(var(--color-teal-default))
27
- );
28
- --mdc-theme-secondary: var(
29
- --lime-secondary-color,
30
- rgb(var(--contrast-1100))
31
- );
32
- --mdc-theme-on-primary: var(
33
- --lime-on-primary-color,
34
- rgb(var(--contrast-100))
35
- );
36
- --mdc-theme-on-secondary: var(
37
- --lime-on-secondary-color,
38
- rgb(var(--contrast-100))
39
- );
40
- --mdc-theme-text-disabled-on-background: var(
41
- --lime-text-disabled-on-background-color,
42
- rgba(var(--contrast-1700), 0.38)
43
- );
44
- --mdc-theme-text-primary-on-background: var(
45
- --lime-text-primary-on-background-color,
46
- rgba(var(--contrast-1700), 0.87)
47
- );
48
- --mdc-theme-text-secondary-on-background: var(
49
- --lime-text-secondary-on-background-color,
50
- rgba(var(--contrast-1700), 0.54)
51
- );
52
- --mdc-theme-error: var(
53
- --lime-error-background-color,
54
- rgb(var(--color-red-dark))
55
- );
56
- --lime-error-text-color: rgb(var(--color-red-darker));
57
- --mdc-theme-surface: var(
58
- --lime-surface-background-color,
59
- rgb(var(--contrast-100))
60
- );
61
- --mdc-theme-on-surface: var(
62
- --lime-on-surface-color,
63
- rgb(var(--contrast-1500))
64
- );
7
+ * {
8
+ box-sizing: border-box;
65
9
  }
66
10
 
67
11
  .mdc-snackbar {
68
- z-index: 8;
69
- margin: 8px;
12
+ top: var(--snackbar-top, auto);
13
+ right: var(--snackbar-right, 0);
14
+ bottom: var(--snackbar-bottom, 0);
15
+ left: var(--snackbar-left, 0);
70
16
  display: none;
71
17
  position: fixed;
72
- right: 0;
73
- bottom: 0;
74
- left: 0;
18
+ z-index: 8;
19
+ padding: 0.75rem;
75
20
  align-items: center;
76
21
  justify-content: center;
77
- box-sizing: border-box;
78
- pointer-events: none;
79
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
80
- }
81
-
82
- .mdc-snackbar__surface {
83
- background-color: #333333;
84
- }
85
-
86
- .mdc-snackbar__label {
87
- color: rgba(255, 255, 255, 0.87);
88
- }
89
-
90
- .mdc-snackbar__surface {
91
- min-width: 344px;
92
- }
93
- @media (max-width: 480px), (max-width: 344px) {
94
- .mdc-snackbar__surface {
95
- min-width: 100%;
96
- }
97
- }
98
-
99
- .mdc-snackbar__surface {
100
- max-width: 672px;
101
- }
102
-
103
- .mdc-snackbar__surface {
104
- /* @alternate */
105
- box-shadow: 0px 3px 5px -1px rgba(0, 0, 0, 0.2), 0px 6px 10px 0px rgba(0, 0, 0, 0.14), 0px 1px 18px 0px rgba(0, 0, 0, 0.12);
106
- }
107
-
108
- .mdc-snackbar__surface {
109
- border-radius: 4px;
110
- /* @alternate */
111
- border-radius: var(--mdc-shape-small, 4px);
112
22
  }
113
23
 
114
24
  .mdc-snackbar--opening,
@@ -121,298 +31,73 @@
121
31
  .mdc-snackbar--open .mdc-snackbar__actions {
122
32
  visibility: visible;
123
33
  }
124
-
125
- .mdc-snackbar--leading {
126
- justify-content: flex-start;
127
- }
128
-
129
- .mdc-snackbar--stacked .mdc-snackbar__label {
130
- /* @noflip */ /*rtl:ignore*/
131
- padding-left: 16px;
132
- /* @noflip */ /*rtl:ignore*/
133
- padding-right: 8px;
134
- padding-bottom: 12px;
135
- }
136
- [dir=rtl] .mdc-snackbar--stacked .mdc-snackbar__label, .mdc-snackbar--stacked .mdc-snackbar__label[dir=rtl] {
137
- /*rtl:begin:ignore*/
138
- /* @noflip */ /*rtl:ignore*/
139
- padding-left: 8px;
140
- /* @noflip */ /*rtl:ignore*/
141
- padding-right: 16px;
142
- /*rtl:end:ignore*/
143
- }
144
-
145
- .mdc-snackbar--stacked .mdc-snackbar__surface {
146
- flex-direction: column;
147
- align-items: flex-start;
148
- }
149
- .mdc-snackbar--stacked .mdc-snackbar__actions {
150
- align-self: flex-end;
151
- margin-bottom: 8px;
34
+ .mdc-snackbar--open .mdc-snackbar__surface {
35
+ transform: scale(1);
36
+ opacity: 1;
152
37
  }
153
38
 
154
39
  .mdc-snackbar__surface {
155
- /* @noflip */ /*rtl:ignore*/
156
- padding-left: 0;
157
- /* @noflip */ /*rtl:ignore*/
158
- padding-right: 8px;
40
+ transition: opacity 0.2s cubic-bezier(0, 0, 0.2, 1), transform 0.2s cubic-bezier(0, 0, 0.2, 1);
41
+ padding: 0.5rem;
159
42
  display: flex;
160
43
  align-items: center;
161
44
  justify-content: flex-start;
162
- box-sizing: border-box;
45
+ gap: 0.25rem;
46
+ min-height: 3.25rem;
47
+ min-width: unset;
48
+ max-width: 42rem;
163
49
  transform: scale(0.8);
164
50
  opacity: 0;
165
- }
166
- .mdc-snackbar__surface::before {
167
- position: absolute;
168
- box-sizing: border-box;
169
- width: 100%;
170
- height: 100%;
171
- top: 0;
172
- left: 0;
173
- border: 1px solid transparent;
174
- border-radius: inherit;
175
- content: "";
176
- pointer-events: none;
177
- }
178
- [dir=rtl] .mdc-snackbar__surface, .mdc-snackbar__surface[dir=rtl] {
179
- /*rtl:begin:ignore*/
180
- /* @noflip */ /*rtl:ignore*/
181
- padding-left: 8px;
182
- /* @noflip */ /*rtl:ignore*/
183
- padding-right: 0;
184
- /*rtl:end:ignore*/
185
- }
186
-
187
- .mdc-snackbar--open .mdc-snackbar__surface {
188
- transform: scale(1);
189
- opacity: 1;
190
- pointer-events: auto;
191
- transition: opacity 150ms 0ms cubic-bezier(0, 0, 0.2, 1), transform 150ms 0ms cubic-bezier(0, 0, 0.2, 1);
192
- }
193
- .mdc-snackbar--closing .mdc-snackbar__surface {
194
- transform: scale(1);
195
- transition: opacity 75ms 0ms cubic-bezier(0.4, 0, 1, 1);
51
+ border-radius: 0.75rem;
52
+ background-color: rgb(var(--contrast-1400));
53
+ box-shadow: var(--shadow-depth-8), var(--shadow-depth-16);
196
54
  }
197
55
 
198
56
  .mdc-snackbar__label {
199
- -moz-osx-font-smoothing: grayscale;
57
+ visibility: hidden;
58
+ color: rgb(var(--contrast-100));
200
59
  -webkit-font-smoothing: antialiased;
201
- font-family: inherit;
202
- /* @alternate */
203
- font-family: var(--mdc-typography-body2-font-family, var(--mdc-typography-font-family, inherit));
204
60
  font-size: 0.8125rem;
205
- /* @alternate */
206
- font-size: var(--mdc-typography-body2-font-size, 0.8125rem);
207
- line-height: 1.625rem;
208
- /* @alternate */
209
- line-height: var(--mdc-typography-body2-line-height, 1.625rem);
210
61
  font-weight: 400;
211
- /* @alternate */
212
- font-weight: var(--mdc-typography-body2-font-weight, 400);
213
- letter-spacing: 0.0178571429em;
214
- /* @alternate */
215
- letter-spacing: var(--mdc-typography-body2-letter-spacing, 0.0178571429em);
216
- text-decoration: inherit;
217
- /* @alternate */
218
- text-decoration: var(--mdc-typography-body2-text-decoration, inherit);
219
- text-transform: inherit;
220
- /* @alternate */
221
- text-transform: var(--mdc-typography-body2-text-transform, inherit);
222
- /* @noflip */ /*rtl:ignore*/
223
- padding-left: 16px;
224
- /* @noflip */ /*rtl:ignore*/
225
- padding-right: 8px;
62
+ padding: 0 0.25rem;
226
63
  width: 100%;
227
64
  flex-grow: 1;
228
- box-sizing: border-box;
229
- margin: 0;
230
- visibility: hidden;
231
- padding-top: 14px;
232
- padding-bottom: 14px;
233
- }
234
- [dir=rtl] .mdc-snackbar__label, .mdc-snackbar__label[dir=rtl] {
235
- /*rtl:begin:ignore*/
236
- /* @noflip */ /*rtl:ignore*/
237
- padding-left: 8px;
238
- /* @noflip */ /*rtl:ignore*/
239
- padding-right: 16px;
240
- /*rtl:end:ignore*/
241
- }
242
-
243
- .mdc-snackbar__label::before {
244
- display: inline;
245
- content: attr(data-mdc-snackbar-label-text);
246
65
  }
247
66
 
248
67
  .mdc-snackbar__actions {
68
+ visibility: hidden;
249
69
  display: flex;
250
70
  flex-shrink: 0;
251
71
  align-items: center;
252
72
  box-sizing: border-box;
253
- visibility: hidden;
254
- }
255
-
256
- .mdc-snackbar__action:not(:disabled) {
257
- color: #bb86fc;
258
- }
259
- .mdc-snackbar__action::before, .mdc-snackbar__action::after {
260
- background-color: #bb86fc;
261
- /* @alternate */
262
- background-color: var(--mdc-ripple-color, #bb86fc);
263
- }
264
- .mdc-snackbar__action:hover::before, .mdc-snackbar__action.mdc-ripple-surface--hover::before {
265
- opacity: 0.08;
266
- /* @alternate */
267
- opacity: var(--mdc-ripple-hover-opacity, 0.08);
268
- }
269
- .mdc-snackbar__action.mdc-ripple-upgraded--background-focused::before, .mdc-snackbar__action:not(.mdc-ripple-upgraded):focus::before {
270
- transition-duration: 75ms;
271
- opacity: 0.24;
272
- /* @alternate */
273
- opacity: var(--mdc-ripple-focus-opacity, 0.24);
274
- }
275
- .mdc-snackbar__action:not(.mdc-ripple-upgraded)::after {
276
- transition: opacity 150ms linear;
277
- }
278
- .mdc-snackbar__action:not(.mdc-ripple-upgraded):active::after {
279
- transition-duration: 75ms;
280
- opacity: 0.24;
281
- /* @alternate */
282
- opacity: var(--mdc-ripple-press-opacity, 0.24);
283
- }
284
- .mdc-snackbar__action.mdc-ripple-upgraded {
285
- --mdc-ripple-fg-opacity: var(--mdc-ripple-press-opacity, 0.24);
286
- }
287
-
288
- .mdc-snackbar__dismiss {
289
- color: rgba(255, 255, 255, 0.87);
290
- }
291
- .mdc-snackbar__dismiss .mdc-icon-button__ripple::before, .mdc-snackbar__dismiss .mdc-icon-button__ripple::after {
292
- background-color: rgba(255, 255, 255, 0.87);
293
- /* @alternate */
294
- background-color: var(--mdc-ripple-color, rgba(255, 255, 255, 0.87));
295
- }
296
- .mdc-snackbar__dismiss:hover .mdc-icon-button__ripple::before, .mdc-snackbar__dismiss.mdc-ripple-surface--hover .mdc-icon-button__ripple::before {
297
- opacity: 0.08;
298
- /* @alternate */
299
- opacity: var(--mdc-ripple-hover-opacity, 0.08);
300
- }
301
- .mdc-snackbar__dismiss.mdc-ripple-upgraded--background-focused .mdc-icon-button__ripple::before, .mdc-snackbar__dismiss:not(.mdc-ripple-upgraded):focus .mdc-icon-button__ripple::before {
302
- transition-duration: 75ms;
303
- opacity: 0.24;
304
- /* @alternate */
305
- opacity: var(--mdc-ripple-focus-opacity, 0.24);
306
- }
307
- .mdc-snackbar__dismiss:not(.mdc-ripple-upgraded) .mdc-icon-button__ripple::after {
308
- transition: opacity 150ms linear;
309
- }
310
- .mdc-snackbar__dismiss:not(.mdc-ripple-upgraded):active .mdc-icon-button__ripple::after {
311
- transition-duration: 75ms;
312
- opacity: 0.24;
313
- /* @alternate */
314
- opacity: var(--mdc-ripple-press-opacity, 0.24);
315
- }
316
- .mdc-snackbar__dismiss.mdc-ripple-upgraded {
317
- --mdc-ripple-fg-opacity: var(--mdc-ripple-press-opacity, 0.24);
318
- }
319
-
320
- .mdc-snackbar__dismiss.mdc-snackbar__dismiss {
321
- width: 36px;
322
- height: 36px;
323
- padding: 6px;
324
- font-size: 18px;
325
- }
326
- .mdc-snackbar__dismiss.mdc-snackbar__dismiss.mdc-icon-button--reduced-size {
327
- width: 36px;
328
- height: 36px;
329
- padding: 6px;
330
- }
331
- .mdc-snackbar__dismiss.mdc-snackbar__dismiss.mdc-icon-button--reduced-size.mdc-icon-button--touch {
332
- margin-top: 0px;
333
- margin-bottom: 0px;
334
- margin-right: 0px;
335
- margin-left: 0px;
336
- }
337
- .mdc-snackbar__dismiss.mdc-snackbar__dismiss .mdc-icon-button__touch {
338
- position: absolute;
339
- top: 50%;
340
- height: 36px;
341
- /* @noflip */ /*rtl:ignore*/
342
- left: 50%;
343
- width: 36px;
344
- transform: translate(-50%, -50%);
345
- }
346
-
347
- .mdc-snackbar__action + .mdc-snackbar__dismiss {
348
- /* @noflip */ /*rtl:ignore*/
349
- margin-left: 8px;
350
- /* @noflip */ /*rtl:ignore*/
351
- margin-right: 0;
352
- }
353
- [dir=rtl] .mdc-snackbar__action + .mdc-snackbar__dismiss, .mdc-snackbar__action + .mdc-snackbar__dismiss[dir=rtl] {
354
- /*rtl:begin:ignore*/
355
- /* @noflip */ /*rtl:ignore*/
356
- margin-left: 0;
357
- /* @noflip */ /*rtl:ignore*/
358
- margin-right: 8px;
359
- /*rtl:end:ignore*/
360
- }
361
-
362
- /**
363
- * @prop --snackbar-top: Snackbar has `position: fixed;` and uses `--snackbar-top`, which defaults to `auto` for its `top` property. See the examples in the documentations for further info.
364
- * @prop --snackbar-right: Snackbar has `position: fixed;` and uses `--snackbar-right`, which defaults to `0` for its `right` property. See the examples in the documentations for further info.
365
- * @prop --snackbar-bottom: Snackbar has `position: fixed;` and uses `--snackbar-bottom`, which defaults to `0` for its `bottom` property. See the examples in the documentations for further info.
366
- * @prop --snackbar-left: Snackbar has `position: fixed;` and uses `--snackbar-left`, which defaults to `0` for its `left` property. See the examples in the documentations for further info.
367
- */
368
- .mdc-snackbar {
369
- top: var(--snackbar-top, auto);
370
- right: var(--snackbar-right, 0);
371
- bottom: var(--snackbar-bottom, 0);
372
- left: var(--snackbar-left, 0);
373
- }
374
-
375
- .mdc-snackbar__surface {
376
- min-width: unset;
377
- max-width: 42rem;
378
- background-color: rgb(var(--contrast-1400));
379
- box-shadow: var(--shadow-depth-8), var(--shadow-depth-16);
380
- gap: 0.75rem;
381
- }
382
-
383
- .mdc-snackbar__label {
384
- font-family: inherit;
385
- }
386
-
387
- .mdc-snackbar__label {
388
- color: rgb(var(--contrast-100));
389
- }
390
-
391
- .mdc-snackbar__actions {
392
73
  gap: 0.5rem;
393
74
  }
394
75
 
76
+ .dismiss,
395
77
  .mdc-snackbar__actions {
396
78
  --lime-elevated-surface-background-color: rgb(
397
79
  var(--contrast-1300)
398
80
  );
399
81
  }
400
- .mdc-snackbar__actions limel-icon-button.mdc-snackbar__dismiss {
401
- transform: scale(0.8);
402
- margin: 0;
403
- padding: 0;
404
- }
405
82
 
406
83
  .dismiss {
407
84
  --mdc-theme-on-surface: rgb(var(--contrast-100));
408
85
  --icon-background-color: var(--lime-elevated-surface-background-color);
409
86
  --fill-color: var(--mdc-theme-primary);
410
87
  --track-color: rgb(var(--contrast-800), 0.2);
411
- position: relative;
88
+ position: absolute;
89
+ top: -0.9rem;
90
+ left: -0.9rem;
91
+ transform: scale(0.8);
412
92
  display: flex;
413
93
  align-items: center;
414
94
  justify-content: center;
415
95
  }
96
+ .dismiss limel-icon-button.mdc-snackbar__dismiss {
97
+ transform: scale(0.8);
98
+ margin: 0;
99
+ padding: 0;
100
+ }
416
101
  .dismiss svg {
417
102
  position: absolute;
418
103
  transform: rotate(90deg);
@@ -73,7 +73,7 @@ export class Snackbar {
73
73
  ${this.multiline ? 'mdc-snackbar--stacked' : ''}
74
74
  `, style: {
75
75
  '--snackbar-timeout': `${this.timeout}ms`,
76
- } }, h("div", { class: "mdc-snackbar__surface", role: "status", "aria-relevant": "additions" }, h("div", { class: "mdc-snackbar__label", "aria-atomic": "false" }), this.renderActions(this.actionText, this.dismissible))));
76
+ } }, h("div", { class: "mdc-snackbar__surface", role: "status", "aria-relevant": "additions" }, h("div", { class: "mdc-snackbar__label", "aria-atomic": "false" }), this.renderActions(this.actionText), this.renderDismissButton(this.dismissible))));
77
77
  }
78
78
  handleMdcClosing(event) {
79
79
  if (event.detail.reason === 'action') {
@@ -83,11 +83,11 @@ export class Snackbar {
83
83
  this.hide.emit();
84
84
  }
85
85
  }
86
- renderActions(actionText, dismissible) {
87
- if (!actionText && !dismissible) {
86
+ renderActions(actionText) {
87
+ if (!actionText) {
88
88
  return;
89
89
  }
90
- return (h("div", { class: "mdc-snackbar__actions", "aria-atomic": "true" }, this.renderActionButton(actionText), this.renderDismissButton(dismissible)));
90
+ return (h("div", { class: "mdc-snackbar__actions", "aria-atomic": "true" }, this.renderActionButton(actionText)));
91
91
  }
92
92
  renderActionButton(actionText) {
93
93
  if (!actionText) {
@@ -1 +1 @@
1
- {"version":3,"file":"snackbar.js","sourceRoot":"","sources":["../../../src/components/snackbar/snackbar.tsx"],"names":[],"mappings":"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","sourcesContent":["import { Languages } from '../date-picker/date.types';\nimport { MDCSnackbar, MDCSnackbarCloseEvent } from '@material/snackbar';\nimport {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Method,\n Prop,\n} from '@stencil/core';\nimport translate from '../../global/translations';\n\n/**\n * A Snackbar –also known as \"Toast\"– is used to inform the end user\n * about an action or a process in the system.\n * The information could vary from announcing that a process has just started,\n * is taking place now, has ended, or has been interrupted or canceled.\n *\n * The information that you provide using a snackbar should be:\n * - temporary\n * - contextual\n * - short\n * - and most importantly, ignorable.\n *\n * It means if the user misses the information, it shouldn't be a big deal.\n *\n * :::note\n * If the information you want to display has a higher importance or priority,\n * and you need to make sure that the user takes an action to dismiss it,\n * consider using the [Banner](/#/component/limel-banner/) component instead.\n * For more complex interactions and for delivering more detailed information,\n * [Dialog](/#/component/limel-dialog/) is a better choice.\n * :::\n *\n * @exampleComponent limel-example-snackbar\n * @exampleComponent limel-example-snackbar-dismissible\n * @exampleComponent limel-example-snackbar-with-action\n * @exampleComponent limel-example-snackbar-with-changing-messages\n * @exampleComponent limel-example-snackbar-positioning\n */\n\n@Component({\n tag: 'limel-snackbar',\n shadow: true,\n styleUrl: 'snackbar.scss',\n})\nexport class Snackbar {\n /**\n * The text message to display.\n */\n @Prop()\n public message: string;\n\n /**\n * The amount of time in milliseconds to show the snackbar.\n */\n @Prop()\n // eslint-disable-next-line no-magic-numbers\n public timeout?: number = 5000;\n\n /**\n * The text to display for the action button.\n */\n @Prop()\n public actionText: string;\n\n /**\n * When `true` displays a dismiss button on the snackbar,\n * allowing users to close it.\n */\n @Prop()\n public dismissible: boolean = true;\n\n /**\n * Whether to show the snackbar with space for multiple lines of text\n */\n @Prop()\n public multiline: boolean;\n\n /**\n * Defines the language for translations.\n */\n @Prop()\n public language: Languages = 'en';\n\n @Element()\n private host: HTMLLimelSnackbarElement;\n\n /**\n * Emitted when the action button is pressed\n */\n @Event()\n private action: EventEmitter<void>;\n\n /**\n * Emitted when the snackbar hides itself\n */\n @Event()\n private hide: EventEmitter<void>;\n\n private mdcSnackbar: MDCSnackbar;\n\n constructor() {\n this.handleMdcClosing = this.handleMdcClosing.bind(this);\n }\n\n public connectedCallback() {\n this.initialize();\n }\n\n public componentDidLoad() {\n this.initialize();\n }\n\n private initialize() {\n const element = this.host.shadowRoot.querySelector('.mdc-snackbar');\n if (!element) {\n return;\n }\n\n this.mdcSnackbar = new MDCSnackbar(element);\n\n this.mdcSnackbar.listen('MDCSnackbar:closing', this.handleMdcClosing);\n }\n\n public disconnectedCallback() {\n this.mdcSnackbar.unlisten('MDCSnackbar:closing', this.handleMdcClosing);\n this.mdcSnackbar.destroy();\n }\n\n /**\n * Show the snackbar\n */\n @Method()\n public async show() {\n if (this.timeout) {\n this.mdcSnackbar.timeoutMs = this.timeout;\n }\n\n this.mdcSnackbar.labelText = this.message;\n\n this.mdcSnackbar.open();\n }\n\n public render() {\n return (\n <aside\n class={`\n mdc-snackbar\n ${this.multiline ? 'mdc-snackbar--stacked' : ''}\n `}\n style={{\n '--snackbar-timeout': `${this.timeout}ms`,\n }}\n >\n <div\n class=\"mdc-snackbar__surface\"\n role=\"status\"\n aria-relevant=\"additions\"\n >\n <div class=\"mdc-snackbar__label\" aria-atomic=\"false\"></div>\n {this.renderActions(this.actionText, this.dismissible)}\n </div>\n </aside>\n );\n }\n\n private handleMdcClosing(event: MDCSnackbarCloseEvent) {\n if (event.detail.reason === 'action') {\n this.action.emit();\n } else {\n this.hide.emit();\n }\n }\n\n private renderActions(actionText: string, dismissible: boolean) {\n if (!actionText && !dismissible) {\n return;\n }\n\n return (\n <div class=\"mdc-snackbar__actions\" aria-atomic=\"true\">\n {this.renderActionButton(actionText)}\n {this.renderDismissButton(dismissible)}\n </div>\n );\n }\n\n private renderActionButton(actionText: string) {\n if (!actionText) {\n return;\n }\n\n return (\n <limel-button\n class=\"mdc-button mdc-snackbar__action\"\n label={actionText}\n />\n );\n }\n\n private renderDismissButton(dismissible: boolean) {\n if (!dismissible) {\n return;\n }\n\n const label = translate.get('snackbar.dismiss', this.language);\n\n return (\n <div class=\"dismiss\">\n {this.renderTimeoutVisualization()}\n <limel-icon-button\n class=\"mdc-icon-button mdc-snackbar__dismiss\"\n icon=\"multiply\"\n label={label}\n />\n </div>\n );\n }\n\n private renderTimeoutVisualization() {\n return (\n <svg width=\"36\" height=\"36\" viewBox=\"0 0 36 36\">\n <circle r=\"18\" cx=\"18\" cy=\"18\" fill=\"var(--track-color)\" />\n <path\n class=\"track\"\n d=\"M 18,18 m -16,0 a 16,16 0 1,0 32,0 a 16,16 0 1,0 -32,0\"\n stroke=\"var(--fill-color)\"\n />\n </svg>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"snackbar.js","sourceRoot":"","sources":["../../../src/components/snackbar/snackbar.tsx"],"names":[],"mappings":"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","sourcesContent":["import { Languages } from '../date-picker/date.types';\nimport { MDCSnackbar, MDCSnackbarCloseEvent } from '@material/snackbar';\nimport {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Method,\n Prop,\n} from '@stencil/core';\nimport translate from '../../global/translations';\n\n/**\n * A Snackbar –also known as \"Toast\"– is used to inform the end user\n * about an action or a process in the system.\n * The information could vary from announcing that a process has just started,\n * is taking place now, has ended, or has been interrupted or canceled.\n *\n * The information that you provide using a snackbar should be:\n * - temporary\n * - contextual\n * - short\n * - and most importantly, ignorable.\n *\n * It means if the user misses the information, it shouldn't be a big deal.\n *\n * :::note\n * If the information you want to display has a higher importance or priority,\n * and you need to make sure that the user takes an action to dismiss it,\n * consider using the [Banner](/#/component/limel-banner/) component instead.\n * For more complex interactions and for delivering more detailed information,\n * [Dialog](/#/component/limel-dialog/) is a better choice.\n * :::\n *\n * @exampleComponent limel-example-snackbar\n * @exampleComponent limel-example-snackbar-dismissible\n * @exampleComponent limel-example-snackbar-with-action\n * @exampleComponent limel-example-snackbar-with-changing-messages\n * @exampleComponent limel-example-snackbar-positioning\n */\n\n@Component({\n tag: 'limel-snackbar',\n shadow: true,\n styleUrl: 'snackbar.scss',\n})\nexport class Snackbar {\n /**\n * The text message to display.\n */\n @Prop()\n public message: string;\n\n /**\n * The amount of time in milliseconds to show the snackbar.\n */\n @Prop()\n // eslint-disable-next-line no-magic-numbers\n public timeout?: number = 5000;\n\n /**\n * The text to display for the action button.\n */\n @Prop()\n public actionText: string;\n\n /**\n * When `true` displays a dismiss button on the snackbar,\n * allowing users to close it.\n */\n @Prop()\n public dismissible: boolean = true;\n\n /**\n * Whether to show the snackbar with space for multiple lines of text\n */\n @Prop()\n public multiline: boolean;\n\n /**\n * Defines the language for translations.\n */\n @Prop()\n public language: Languages = 'en';\n\n @Element()\n private host: HTMLLimelSnackbarElement;\n\n /**\n * Emitted when the action button is pressed\n */\n @Event()\n private action: EventEmitter<void>;\n\n /**\n * Emitted when the snackbar hides itself\n */\n @Event()\n private hide: EventEmitter<void>;\n\n private mdcSnackbar: MDCSnackbar;\n\n constructor() {\n this.handleMdcClosing = this.handleMdcClosing.bind(this);\n }\n\n public connectedCallback() {\n this.initialize();\n }\n\n public componentDidLoad() {\n this.initialize();\n }\n\n private initialize() {\n const element = this.host.shadowRoot.querySelector('.mdc-snackbar');\n if (!element) {\n return;\n }\n\n this.mdcSnackbar = new MDCSnackbar(element);\n\n this.mdcSnackbar.listen('MDCSnackbar:closing', this.handleMdcClosing);\n }\n\n public disconnectedCallback() {\n this.mdcSnackbar.unlisten('MDCSnackbar:closing', this.handleMdcClosing);\n this.mdcSnackbar.destroy();\n }\n\n /**\n * Show the snackbar\n */\n @Method()\n public async show() {\n if (this.timeout) {\n this.mdcSnackbar.timeoutMs = this.timeout;\n }\n\n this.mdcSnackbar.labelText = this.message;\n\n this.mdcSnackbar.open();\n }\n\n public render() {\n return (\n <aside\n class={`\n mdc-snackbar\n ${this.multiline ? 'mdc-snackbar--stacked' : ''}\n `}\n style={{\n '--snackbar-timeout': `${this.timeout}ms`,\n }}\n >\n <div\n class=\"mdc-snackbar__surface\"\n role=\"status\"\n aria-relevant=\"additions\"\n >\n <div class=\"mdc-snackbar__label\" aria-atomic=\"false\"></div>\n {this.renderActions(this.actionText)}\n {this.renderDismissButton(this.dismissible)}\n </div>\n </aside>\n );\n }\n\n private handleMdcClosing(event: MDCSnackbarCloseEvent) {\n if (event.detail.reason === 'action') {\n this.action.emit();\n } else {\n this.hide.emit();\n }\n }\n\n private renderActions(actionText: string) {\n if (!actionText) {\n return;\n }\n\n return (\n <div class=\"mdc-snackbar__actions\" aria-atomic=\"true\">\n {this.renderActionButton(actionText)}\n </div>\n );\n }\n\n private renderActionButton(actionText: string) {\n if (!actionText) {\n return;\n }\n\n return (\n <limel-button\n class=\"mdc-button mdc-snackbar__action\"\n label={actionText}\n />\n );\n }\n\n private renderDismissButton(dismissible: boolean) {\n if (!dismissible) {\n return;\n }\n\n const label = translate.get('snackbar.dismiss', this.language);\n\n return (\n <div class=\"dismiss\">\n {this.renderTimeoutVisualization()}\n <limel-icon-button\n class=\"mdc-icon-button mdc-snackbar__dismiss\"\n icon=\"multiply\"\n label={label}\n />\n </div>\n );\n }\n\n private renderTimeoutVisualization() {\n return (\n <svg width=\"36\" height=\"36\" viewBox=\"0 0 36 36\">\n <circle r=\"18\" cx=\"18\" cy=\"18\" fill=\"var(--track-color)\" />\n <path\n class=\"track\"\n d=\"M 18,18 m -16,0 a 16,16 0 1,0 32,0 a 16,16 0 1,0 -32,0\"\n stroke=\"var(--fill-color)\"\n />\n </svg>\n );\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import { toggleMark, setBlockType, wrapIn } from 'prosemirror-commands';
2
- import { wrapInList } from 'prosemirror-schema-list';
2
+ import { findWrapping, liftTarget } from 'prosemirror-transform';
3
+ import { TextSelection } from 'prosemirror-state';
3
4
  import { EditorMenuTypes, LevelMapping } from './types';
4
5
  const setActiveMethodForMark = (command, markType) => {
5
6
  command.active = (state) => {
@@ -17,7 +18,7 @@ const setActiveMethodForNode = (command, nodeType, level) => {
17
18
  const { $from } = state.selection;
18
19
  const node = $from.node($from.depth);
19
20
  if (node && node.type.name === nodeType.name) {
20
- if (nodeType.name === 'heading') {
21
+ if (nodeType.name === LevelMapping.Heading && level) {
21
22
  return node.attrs.level === level;
22
23
  }
23
24
  return true;
@@ -62,14 +63,44 @@ const getAttributes = (markName, url) => {
62
63
  const isExternalLink = (url) => {
63
64
  return !url.startsWith(window.location.origin);
64
65
  };
66
+ const toggleBlockType = (schema, type, attrs = {}, wrap = false) => {
67
+ const blockType = schema.nodes[type];
68
+ const paragraphType = schema.nodes.paragraph;
69
+ return (state, dispatch) => {
70
+ const { $from, to } = state.selection;
71
+ if (state.selection instanceof TextSelection &&
72
+ $from.sameParent($from.doc.resolve(to))) {
73
+ if ($from.parent.type === blockType) {
74
+ if (dispatch) {
75
+ dispatch(state.tr.setBlockType($from.pos, to, paragraphType));
76
+ }
77
+ return true;
78
+ }
79
+ else {
80
+ if (wrap) {
81
+ return wrapIn(blockType, attrs)(state, dispatch);
82
+ }
83
+ else {
84
+ return setBlockType(blockType, attrs)(state, dispatch);
85
+ }
86
+ }
87
+ }
88
+ return false;
89
+ };
90
+ };
65
91
  const createSetNodeTypeCommand = (schema, nodeType, level) => {
66
92
  const type = schema.nodes[nodeType];
67
93
  if (!type) {
68
94
  throw new Error(`Node type "${nodeType}" not found in schema`);
69
95
  }
70
96
  let command;
71
- if (nodeType === 'heading' && level) {
72
- command = setBlockType(type, { level: level });
97
+ if (nodeType === LevelMapping.Heading && level) {
98
+ command = toggleBlockType(schema, LevelMapping.Heading, {
99
+ level: level,
100
+ });
101
+ }
102
+ else if (nodeType === EditorMenuTypes.CodeBlock) {
103
+ command = toggleBlockType(schema, EditorMenuTypes.CodeBlock);
73
104
  }
74
105
  else {
75
106
  command = setBlockType(type);
@@ -82,16 +113,50 @@ const createWrapInCommand = (schema, nodeType) => {
82
113
  if (!type) {
83
114
  throw new Error(`Node type "${nodeType}" not found in schema`);
84
115
  }
85
- const command = wrapIn(type);
116
+ let command;
117
+ if (nodeType === EditorMenuTypes.Blockquote) {
118
+ command = toggleBlockType(schema, EditorMenuTypes.Blockquote, {}, true);
119
+ }
120
+ else {
121
+ command = wrapIn(type);
122
+ }
86
123
  setActiveMethodForWrap(command, type);
87
124
  return command;
88
125
  };
126
+ const toggleList = (listType) => {
127
+ return (state, dispatch) => {
128
+ const { $from, $to } = state.selection;
129
+ const range = $from.blockRange($to);
130
+ if (!range) {
131
+ return false;
132
+ }
133
+ const wrapping = range && findWrapping(range, listType);
134
+ if (wrapping) {
135
+ // Wrap the selection in a list
136
+ if (dispatch) {
137
+ dispatch(state.tr.wrap(range, wrapping).scrollIntoView());
138
+ }
139
+ return true;
140
+ }
141
+ else {
142
+ // Check if we are in a list item and lift out of the list
143
+ const liftRange = range && liftTarget(range);
144
+ if (liftRange !== null) {
145
+ if (dispatch) {
146
+ dispatch(state.tr.lift(range, liftRange).scrollIntoView());
147
+ }
148
+ return true;
149
+ }
150
+ return false;
151
+ }
152
+ };
153
+ };
89
154
  const createListCommand = (schema, listType) => {
90
155
  const type = schema.nodes[listType];
91
156
  if (!type) {
92
157
  throw new Error(`List type "${listType}" not found in schema`);
93
158
  }
94
- const command = wrapInList(type);
159
+ const command = toggleList(type);
95
160
  setActiveMethodForWrap(command, type);
96
161
  return command;
97
162
  };
@@ -99,15 +164,18 @@ const commandMapping = {
99
164
  strong: createToggleMarkCommand,
100
165
  em: createToggleMarkCommand,
101
166
  underline: createToggleMarkCommand,
167
+ strikethrough: createToggleMarkCommand,
168
+ code: createToggleMarkCommand,
169
+ link: createToggleMarkCommand,
102
170
  headerlevel1: (schema) => createSetNodeTypeCommand(schema, LevelMapping.Heading, LevelMapping.one),
103
171
  headerlevel2: (schema) => createSetNodeTypeCommand(schema, LevelMapping.Heading, LevelMapping.two),
104
172
  headerlevel3: (schema) => createSetNodeTypeCommand(schema, LevelMapping.Heading, LevelMapping.three),
105
- blockquote: createWrapInCommand,
173
+ blockquote: (schema) => createWrapInCommand(schema, EditorMenuTypes.Blockquote),
106
174
  /* eslint-disable camelcase */
107
- ordered_list: createListCommand,
108
- bullet_list: createListCommand,
175
+ code_block: (schema) => createSetNodeTypeCommand(schema, EditorMenuTypes.CodeBlock),
176
+ ordered_list: (schema) => createListCommand(schema, EditorMenuTypes.OrderedList),
177
+ bullet_list: (schema) => createListCommand(schema, EditorMenuTypes.BulletList),
109
178
  /* eslint-enable camelcase */
110
- link: createToggleMarkCommand,
111
179
  };
112
180
  export class MenuCommandFactory {
113
181
  constructor(schema) {
@@ -127,6 +195,9 @@ export class MenuCommandFactory {
127
195
  'Mod-Shift-1': this.getCommand(EditorMenuTypes.HeaderLevel1),
128
196
  'Mod-Shift-2': this.getCommand(EditorMenuTypes.HeaderLevel2),
129
197
  'Mod-Shift-3': this.getCommand(EditorMenuTypes.HeaderLevel3),
198
+ 'Mod-Shift-X': this.getCommand(EditorMenuTypes.Strikethrough),
199
+ 'Mod-`': this.getCommand(EditorMenuTypes.Code),
200
+ 'Mod-Shift-C': this.getCommand(EditorMenuTypes.CodeBlock),
130
201
  };
131
202
  }
132
203
  }