@ferrlabs/ui-ng 1.51.0 → 1.52.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -90,7 +90,11 @@ pnpm add marked marked-highlight prismjs
90
90
  ```
91
91
 
92
92
  ```ts
93
- import { CodeComponent, MarkdownComponent } from '@ferrlabs/ui-ng/markdown';
93
+ import {
94
+ CodeComponent,
95
+ MarkdownComponent,
96
+ MarkdownEditorComponent,
97
+ } from '@ferrlabs/ui-ng/markdown';
94
98
  ```
95
99
 
96
100
  ```html
@@ -103,6 +107,14 @@ import { CodeComponent, MarkdownComponent } from '@ferrlabs/ui-ng/markdown';
103
107
  highlights fenced code, and passes the result through Angular's `[innerHTML]`
104
108
  sanitizer, so scripts and event handlers in the source are stripped. Links get
105
109
  `rel="noopener noreferrer"`.
110
+ - `flr-markdown-editor`: `ControlValueAccessor` (`ngModel` / reactive forms) with a
111
+ markdown string value. Inputs `placeholder`, `rows` (default 8), `minHeight`, `labels` (partial
112
+ `MarkdownEditorLabels` merged over the English defaults: toolbar buttons with their
113
+ shortcut hints, tab names, `editorMode`, `formatting`, `nothingToPreview`) and
114
+ `aria-label`; disabled comes from the form control. Write / Preview tabs, a
115
+ formatting toolbar (bold, italic, strikethrough, heading cycling H1 to H3, inline
116
+ code, code block, link, bullet, numbered and task lists, quote) and Ctrl/Cmd+B,
117
+ I, K shortcuts. Preview renders through `flr-markdown`.
106
118
  - Languages: javascript, typescript, json, bash, rust, python, yaml, toml, sql,
107
119
  diff, markdown, css, markup (html/xml), go, docker. Common aliases (`ts`, `sh`,
108
120
  `yml`, `rs`, `html`, ...) resolve.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from "@angular/core";
2
- import { ChangeDetectionStrategy, Component, ViewEncapsulation, computed, inject, input, signal } from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, ViewEncapsulation, computed, forwardRef, inject, input, signal, viewChild } from "@angular/core";
3
3
  import { DOCUMENT } from "@angular/common";
4
4
  import Prism from "prismjs";
5
5
  import "prismjs/components/prism-clike";
@@ -20,6 +20,8 @@ import "prismjs/components/prism-go";
20
20
  import "prismjs/components/prism-docker";
21
21
  import { Marked } from "marked";
22
22
  import { markedHighlight } from "marked-highlight";
23
+ import { NG_VALUE_ACCESSOR } from "@angular/forms";
24
+ import { ButtonComponent, TabComponent, TabsComponent } from "@ferrlabs/ui-ng";
23
25
  const ENTITIES = {
24
26
  "&": "&",
25
27
  "<": "&lt;",
@@ -252,6 +254,563 @@ i0.ɵɵngDeclareClassMetadata({
252
254
  }]
253
255
  }] }
254
256
  });
255
- export { CodeComponent, MarkdownComponent };
257
+ const LIST_MARKER = /^(?:- \[[ xX]\] |- |\d+\. )/;
258
+ const NO_MARKER = /^(?!)/;
259
+ const BULLET = {
260
+ make: () => "- ",
261
+ match: /^- /,
262
+ replaces: LIST_MARKER
263
+ };
264
+ const NUMBERED = {
265
+ make: (i) => `${i + 1}. `,
266
+ match: /^\d+\. /,
267
+ replaces: LIST_MARKER
268
+ };
269
+ const TASK = {
270
+ make: () => "- [ ] ",
271
+ match: /^- \[[ xX]\] /,
272
+ replaces: LIST_MARKER
273
+ };
274
+ const QUOTE = {
275
+ make: () => "> ",
276
+ match: /^> ?/,
277
+ replaces: NO_MARKER
278
+ };
279
+ const HEADING = /^(#{1,6}) /;
280
+ const MAX_HEADING_LEVEL = 3;
281
+ function runLength(text, char, from, step) {
282
+ let count = 0;
283
+ for (let i = from; i >= 0 && i < text.length && text[i] === char; i += step) count++;
284
+ return count;
285
+ }
286
+ function isRepeated(marker) {
287
+ return marker.length > 0 && [...marker].every((c) => c === marker[0]);
288
+ }
289
+ function splice(value, from, to, text) {
290
+ return value.slice(0, from) + text + value.slice(to);
291
+ }
292
+ function toggleRun({ value, start, end }, char, size) {
293
+ const runStart = start - runLength(value, char, start - 1, -1);
294
+ const runEnd = end + runLength(value, char, end, 1);
295
+ const length = runEnd - runStart;
296
+ const next = Math.floor((length - 1) / (2 * size)) % 2 === 0 ? length + 2 * size : length - 2 * size;
297
+ return {
298
+ value: splice(value, runStart, runEnd, char.repeat(next)),
299
+ start: runStart,
300
+ end: runStart + next
301
+ };
302
+ }
303
+ function toggleRepeated(state, marker) {
304
+ const { value, start, end } = state;
305
+ const char = marker[0];
306
+ const size = marker.length;
307
+ const selected = value.slice(start, end);
308
+ const leading = runLength(selected, char, 0, 1);
309
+ if (leading === selected.length) return toggleRun(state, char, size);
310
+ const coreStart = start + leading;
311
+ const coreEnd = end - runLength(selected, char, selected.length - 1, -1);
312
+ const left = runLength(value, char, coreStart - 1, -1);
313
+ const right = runLength(value, char, coreEnd, 1);
314
+ const core = value.slice(coreStart, coreEnd);
315
+ if (Math.floor(Math.min(left, right) / size) % 2 === 1) return {
316
+ value: splice(value, coreStart - size, coreEnd + size, core),
317
+ start: coreStart - size,
318
+ end: coreEnd - size
319
+ };
320
+ return {
321
+ value: splice(value, coreStart, coreEnd, marker + core + marker),
322
+ start: coreStart + size,
323
+ end: coreEnd + size
324
+ };
325
+ }
326
+ function isWrapped(value, start, end, before, after) {
327
+ if (start < before.length || end + after.length > value.length) return false;
328
+ return value.slice(start - before.length, start) === before && value.slice(end, end + after.length) === after;
329
+ }
330
+ function toggleWrap(state, before, after = before, placeholder = "text") {
331
+ const { value, start, end } = state;
332
+ const selected = value.slice(start, end);
333
+ if (before === after && isRepeated(before)) {
334
+ if (selected) return toggleRepeated(state, before);
335
+ return toggleRepeated({
336
+ value: splice(value, start, end, placeholder),
337
+ start,
338
+ end: start + placeholder.length
339
+ }, before);
340
+ }
341
+ if (isWrapped(value, start, end, before, after)) return {
342
+ value: splice(value, start - before.length, end + after.length, selected),
343
+ start: start - before.length,
344
+ end: end - before.length
345
+ };
346
+ if (selected.length >= before.length + after.length && selected.startsWith(before) && selected.endsWith(after)) {
347
+ const inner = selected.slice(before.length, selected.length - after.length);
348
+ return {
349
+ value: splice(value, start, end, inner),
350
+ start,
351
+ end: start + inner.length
352
+ };
353
+ }
354
+ const text = selected || placeholder;
355
+ return {
356
+ value: splice(value, start, end, before + text + after),
357
+ start: start + before.length,
358
+ end: start + before.length + text.length
359
+ };
360
+ }
361
+ function lineRange({ value, start, end }) {
362
+ const from = start === 0 ? 0 : value.lastIndexOf("\n", start - 1) + 1;
363
+ const stop = end > start && value[end - 1] === "\n" ? end - 1 : end;
364
+ const next = value.indexOf("\n", stop);
365
+ const to = next === -1 ? value.length : next;
366
+ return {
367
+ from,
368
+ to,
369
+ lines: value.slice(from, to).split("\n")
370
+ };
371
+ }
372
+ function replaceLines(state, range, lines) {
373
+ const joined = lines.join("\n");
374
+ if (joined === state.value.slice(range.from, range.to)) return state;
375
+ return {
376
+ value: state.value.slice(0, range.from) + joined + state.value.slice(range.to),
377
+ start: range.from,
378
+ end: range.from + joined.length
379
+ };
380
+ }
381
+ function toggleLinePrefix(state, prefix) {
382
+ const range = lineRange(state);
383
+ const content = range.lines.filter((line) => line.trim() !== "");
384
+ const allPrefixed = content.length > 0 && content.every((line) => prefix.match.test(line));
385
+ let index = 0;
386
+ return replaceLines(state, range, range.lines.map((line) => {
387
+ if (line.trim() === "" && range.lines.length > 1) return line;
388
+ if (allPrefixed) return line.replace(prefix.match, "");
389
+ return prefix.make(index++) + line.replace(prefix.replaces, "");
390
+ }));
391
+ }
392
+ function cycleHeading(state) {
393
+ const range = lineRange(state);
394
+ const hasContent = range.lines.some((line) => line.trim() !== "");
395
+ const isTouched = (line, index) => hasContent ? line.trim() !== "" : index === 0;
396
+ const touched = range.lines.filter(isTouched);
397
+ const remainders = touched.map((line) => line.replace(HEADING, ""));
398
+ const reference = touched[0] ?? range.lines[0];
399
+ const current = HEADING.exec(reference)?.[1].length ?? 0;
400
+ const keepsHeading = remainders.some((text) => HEADING.test(text)) || hasContent && range.lines.length > 1 && remainders.some((text) => text.trim() === "");
401
+ const next = current === MAX_HEADING_LEVEL && !keepsHeading ? 0 : current >= MAX_HEADING_LEVEL ? 1 : current + 1;
402
+ const marker = next === 0 ? "" : `${"#".repeat(next)} `;
403
+ return replaceLines(state, range, range.lines.map((line, i) => isTouched(line, i) ? marker + line.replace(HEADING, "") : line));
404
+ }
405
+ function insertBlock({ value, start, end }, marker, placeholder = "code") {
406
+ const selected = value.slice(start, end) || placeholder;
407
+ const longest = Math.max(0, ...(selected.match(/`+/g) ?? []).map((run) => run.length));
408
+ const fence = marker.length > longest ? marker : marker[0].repeat(longest + 1);
409
+ const lead = start > 0 && value[start - 1] !== "\n" ? "\n" : "";
410
+ const trail = end < value.length && value[end] !== "\n" ? "\n" : "";
411
+ const open = `${lead}${fence}\n`;
412
+ const block = `${open}${selected}\n${fence}${trail}`;
413
+ return {
414
+ value: value.slice(0, start) + block + value.slice(end),
415
+ start: start + open.length,
416
+ end: start + open.length + selected.length
417
+ };
418
+ }
419
+ function insertLink({ value, start, end }, url = "https://") {
420
+ const label = (value.slice(start, end) || "text").replace(/\s*\n\s*/g, " ").replace(/[\\[\]]/g, "\\$&");
421
+ const link = `[${label}](${url})`;
422
+ const urlStart = start + label.length + 3;
423
+ return {
424
+ value: value.slice(0, start) + link + value.slice(end),
425
+ start: urlStart,
426
+ end: urlStart + url.length
427
+ };
428
+ }
429
+ function diffReplacement(before, after) {
430
+ const limit = Math.min(before.length, after.length);
431
+ let prefix = 0;
432
+ while (prefix < limit && before[prefix] === after[prefix]) prefix++;
433
+ let suffix = 0;
434
+ while (suffix < limit - prefix && before[before.length - 1 - suffix] === after[after.length - 1 - suffix]) suffix++;
435
+ return {
436
+ from: prefix,
437
+ to: before.length - suffix,
438
+ text: after.slice(prefix, after.length - suffix)
439
+ };
440
+ }
441
+ const DEFAULT_LABELS = {
442
+ editor: "Markdown editor",
443
+ editorMode: "Editor mode",
444
+ formatting: "Formatting",
445
+ write: "Write",
446
+ preview: "Preview",
447
+ nothingToPreview: "Nothing to preview",
448
+ bold: "Bold (Ctrl/Cmd+B)",
449
+ italic: "Italic (Ctrl/Cmd+I)",
450
+ strike: "Strikethrough",
451
+ heading: "Heading (cycles H1 to H3)",
452
+ code: "Inline code",
453
+ codeBlock: "Code block",
454
+ link: "Link (Ctrl/Cmd+K)",
455
+ bullet: "Bulleted list",
456
+ numbered: "Numbered list",
457
+ task: "Task list",
458
+ quote: "Quote"
459
+ };
460
+ const ACTIONS = [
461
+ {
462
+ id: "bold",
463
+ glyph: "B",
464
+ label: "bold",
465
+ style: "font-weight: 700",
466
+ apply: (s) => toggleWrap(s, "**")
467
+ },
468
+ {
469
+ id: "italic",
470
+ glyph: "I",
471
+ label: "italic",
472
+ style: "font-style: italic",
473
+ apply: (s) => toggleWrap(s, "*")
474
+ },
475
+ {
476
+ id: "strike",
477
+ glyph: "S",
478
+ label: "strike",
479
+ style: "text-decoration: line-through",
480
+ apply: (s) => toggleWrap(s, "~~")
481
+ },
482
+ {
483
+ id: "heading",
484
+ glyph: "H",
485
+ label: "heading",
486
+ apply: cycleHeading
487
+ },
488
+ {
489
+ id: "code",
490
+ glyph: "</>",
491
+ label: "code",
492
+ apply: (s) => toggleWrap(s, "`")
493
+ },
494
+ {
495
+ id: "code-block",
496
+ glyph: "{ }",
497
+ label: "codeBlock",
498
+ apply: (s) => insertBlock(s, "```")
499
+ },
500
+ {
501
+ id: "link",
502
+ glyph: "[↗]",
503
+ label: "link",
504
+ apply: (s) => insertLink(s)
505
+ },
506
+ {
507
+ id: "bullet",
508
+ glyph: "•",
509
+ label: "bullet",
510
+ apply: (s) => toggleLinePrefix(s, BULLET)
511
+ },
512
+ {
513
+ id: "numbered",
514
+ glyph: "1.",
515
+ label: "numbered",
516
+ apply: (s) => toggleLinePrefix(s, NUMBERED)
517
+ },
518
+ {
519
+ id: "task",
520
+ glyph: "[ ]",
521
+ label: "task",
522
+ apply: (s) => toggleLinePrefix(s, TASK)
523
+ },
524
+ {
525
+ id: "quote",
526
+ glyph: "\"",
527
+ label: "quote",
528
+ apply: (s) => toggleLinePrefix(s, QUOTE)
529
+ }
530
+ ];
531
+ const SHORTCUTS = {
532
+ b: "bold",
533
+ i: "italic",
534
+ k: "link"
535
+ };
536
+ let sequence = 0;
537
+ var MarkdownEditorComponent = class MarkdownEditorComponent {
538
+ constructor() {
539
+ this.placeholder = input(null, ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
540
+ this.rows = input(8, ...ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []);
541
+ this.minHeight = input(null, ...ngDevMode ? [{ debugName: "minHeight" }] : /* istanbul ignore next */ []);
542
+ this.labels = input({}, ...ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []);
543
+ this.ariaLabel = input(null, {
544
+ ...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
545
+ alias: "aria-label"
546
+ });
547
+ this.resolvedLabels = computed(() => ({
548
+ ...DEFAULT_LABELS,
549
+ ...this.labels()
550
+ }), ...ngDevMode ? [{ debugName: "resolvedLabels" }] : /* istanbul ignore next */ []);
551
+ this.actions = ACTIONS;
552
+ this.value = signal("", ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
553
+ this.written = signal("", ...ngDevMode ? [{ debugName: "written" }] : /* istanbul ignore next */ []);
554
+ this.disabled = signal(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
555
+ this.mode = signal("write", ...ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []);
556
+ this.uid = ++sequence;
557
+ this.writeId = `flr-md-editor-write-${this.uid}`;
558
+ this.previewId = `flr-md-editor-preview-${this.uid}`;
559
+ this.previewing = computed(() => this.mode() === "preview", ...ngDevMode ? [{ debugName: "previewing" }] : /* istanbul ignore next */ []);
560
+ this.textarea = viewChild("textarea", ...ngDevMode ? [{ debugName: "textarea" }] : /* istanbul ignore next */ []);
561
+ this.document = inject(DOCUMENT);
562
+ this.onChange = () => {};
563
+ this.onTouched = () => {};
564
+ }
565
+ writeValue(value) {
566
+ const text = value ?? "";
567
+ this.value.set(text);
568
+ this.written.set(text);
569
+ const element = this.textarea()?.nativeElement;
570
+ if (element) element.value = text;
571
+ }
572
+ registerOnChange(fn) {
573
+ this.onChange = fn;
574
+ }
575
+ registerOnTouched(fn) {
576
+ this.onTouched = fn;
577
+ }
578
+ setDisabledState(isDisabled) {
579
+ this.disabled.set(isDisabled);
580
+ }
581
+ handleInput(event) {
582
+ this.commit(event.target.value);
583
+ }
584
+ handleBlur() {
585
+ this.onTouched();
586
+ }
587
+ handleKeydown(event) {
588
+ if (!(event.ctrlKey || event.metaKey) || event.altKey || event.shiftKey) return;
589
+ const action = ACTIONS.find((a) => a.id === SHORTCUTS[event.key.toLowerCase()]);
590
+ if (!action) return;
591
+ event.preventDefault();
592
+ this.run(action);
593
+ }
594
+ run(action) {
595
+ const element = this.textarea()?.nativeElement;
596
+ if (!element) return;
597
+ const next = action.apply({
598
+ value: element.value,
599
+ start: element.selectionStart,
600
+ end: element.selectionEnd
601
+ });
602
+ element.focus();
603
+ if (next.value === element.value) {
604
+ element.setSelectionRange(next.start, next.end);
605
+ return;
606
+ }
607
+ const change = diffReplacement(element.value, next.value);
608
+ element.setSelectionRange(change.from, change.to);
609
+ if (!this.document.execCommand("insertText", false, change.text)) {
610
+ element.value = next.value;
611
+ this.commit(next.value);
612
+ }
613
+ element.setSelectionRange(next.start, next.end);
614
+ }
615
+ commit(value) {
616
+ this.value.set(value);
617
+ this.onChange(value);
618
+ }
619
+ static {
620
+ this.ɵfac = i0.ɵɵngDeclareFactory({
621
+ minVersion: "12.0.0",
622
+ version: "22.2.5",
623
+ ngImport: i0,
624
+ type: MarkdownEditorComponent,
625
+ deps: [],
626
+ target: i0.ɵɵFactoryTarget.Component
627
+ });
628
+ }
629
+ static {
630
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
631
+ minVersion: "17.0.0",
632
+ version: "22.2.5",
633
+ type: MarkdownEditorComponent,
634
+ isStandalone: true,
635
+ selector: "flr-markdown-editor",
636
+ inputs: {
637
+ placeholder: {
638
+ classPropertyName: "placeholder",
639
+ publicName: "placeholder",
640
+ isSignal: true,
641
+ isRequired: false,
642
+ transformFunction: null
643
+ },
644
+ rows: {
645
+ classPropertyName: "rows",
646
+ publicName: "rows",
647
+ isSignal: true,
648
+ isRequired: false,
649
+ transformFunction: null
650
+ },
651
+ minHeight: {
652
+ classPropertyName: "minHeight",
653
+ publicName: "minHeight",
654
+ isSignal: true,
655
+ isRequired: false,
656
+ transformFunction: null
657
+ },
658
+ labels: {
659
+ classPropertyName: "labels",
660
+ publicName: "labels",
661
+ isSignal: true,
662
+ isRequired: false,
663
+ transformFunction: null
664
+ },
665
+ ariaLabel: {
666
+ classPropertyName: "ariaLabel",
667
+ publicName: "aria-label",
668
+ isSignal: true,
669
+ isRequired: false,
670
+ transformFunction: null
671
+ }
672
+ },
673
+ host: { classAttribute: "flr-md-editor" },
674
+ providers: [{
675
+ provide: NG_VALUE_ACCESSOR,
676
+ useExisting: forwardRef(() => MarkdownEditorComponent),
677
+ multi: true
678
+ }],
679
+ viewQueries: [{
680
+ propertyName: "textarea",
681
+ first: true,
682
+ predicate: ["textarea"],
683
+ descendants: true,
684
+ isSignal: true
685
+ }],
686
+ ngImport: i0,
687
+ template: "<div class=\"flr-md-editor__frame\" [class.flr-md-editor__frame--disabled]=\"disabled()\">\n <div class=\"flr-md-editor__head\">\n <flr-tabs mode=\"panel\" [ariaLabel]=\"resolvedLabels().editorMode\">\n <flr-tab\n [label]=\"resolvedLabels().write\"\n [active]=\"!previewing()\"\n [panelId]=\"writeId\"\n (selected)=\"mode.set('write')\"\n />\n <flr-tab\n [label]=\"resolvedLabels().preview\"\n [active]=\"previewing()\"\n [panelId]=\"previewId\"\n (selected)=\"mode.set('preview')\"\n />\n </flr-tabs>\n <div\n class=\"flr-md-editor__toolbar\"\n role=\"group\"\n [attr.aria-label]=\"resolvedLabels().formatting\"\n [hidden]=\"previewing()\"\n >\n @for (action of actions; track action.id) {\n <flr-button\n variant=\"ghost\"\n size=\"sm\"\n [aria-label]=\"resolvedLabels()[action.label]\"\n [disabled]=\"disabled()\"\n (pressed)=\"run(action)\"\n >\n <span\n class=\"flr-md-editor__glyph\"\n aria-hidden=\"true\"\n [style]=\"action.style\"\n [attr.data-glyph]=\"action.glyph\"\n ></span>\n </flr-button>\n }\n </div>\n </div>\n\n <div\n [id]=\"writeId\"\n role=\"tabpanel\"\n [attr.aria-label]=\"resolvedLabels().write\"\n [hidden]=\"previewing()\"\n >\n <textarea\n #textarea\n class=\"flr-md-editor__input\"\n [rows]=\"rows()\"\n [style.min-height]=\"minHeight()\"\n [value]=\"written()\"\n [disabled]=\"disabled()\"\n [attr.placeholder]=\"placeholder()\"\n [attr.aria-label]=\"ariaLabel() ?? resolvedLabels().editor\"\n (input)=\"handleInput($event)\"\n (keydown)=\"handleKeydown($event)\"\n (blur)=\"handleBlur()\"\n ></textarea>\n </div>\n\n <div\n [id]=\"previewId\"\n role=\"tabpanel\"\n [attr.aria-label]=\"resolvedLabels().preview\"\n class=\"flr-md-editor__preview\"\n [style.min-height]=\"minHeight()\"\n [hidden]=\"!previewing()\"\n >\n @if (previewing()) {\n @if (value().trim()) {\n <flr-markdown [source]=\"value()\" />\n } @else {\n <p class=\"flr-md-editor__empty\">{{ resolvedLabels().nothingToPreview }}</p>\n }\n }\n </div>\n</div>\n",
688
+ styles: [":host{display:block}.flr-md-editor__frame{display:flex;flex-direction:column;border:1px solid var(--color-rule-strong, rgba(30, 41, 59, .28));border-radius:var(--radius-card, 8px);background:var(--color-card, #ffffff);overflow:hidden;transition:border-color .14s,box-shadow .14s}.flr-md-editor__frame:focus-within{border-color:var(--color-accent, var(--color-ink, #1e293b));box-shadow:0 0 0 3px color-mix(in oklab,var(--color-accent, var(--color-ink, #1e293b)) 30%,transparent)}.flr-md-editor__frame--disabled{background:var(--color-paper-2, #f1f5f9);cursor:not-allowed}.flr-md-editor__head{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:8px;padding:0 8px;background:var(--color-app-bg-2, #f1f5f9);border-bottom:1px solid var(--color-rule, rgba(30, 41, 59, .14))}.flr-md-editor__toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:4px;padding:6px 0}.flr-md-editor__toolbar[hidden]{display:none}.flr-md-editor__glyph{display:inline-block;min-width:1.25em;text-align:center}.flr-md-editor__glyph:before{content:attr(data-glyph)}.flr-md-editor__input{display:block;width:100%;box-sizing:border-box;padding:12px;border:0;outline:none;resize:vertical;background:transparent;color:var(--color-ink, #1e293b);font-family:var( --font-mono, \"DM Mono\", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace );font-size:14px;line-height:1.6}.flr-md-editor__input:disabled{cursor:not-allowed}.flr-md-editor__input::placeholder{color:var(--color-ink-3, #64748b)}.flr-md-editor__preview{box-sizing:border-box;padding:12px 16px}.flr-md-editor__preview[hidden]{display:none}.flr-md-editor__empty{margin:0;color:var(--color-ink-3, #64748b);font-size:14px}\n"],
689
+ dependencies: [
690
+ {
691
+ kind: "component",
692
+ type: ButtonComponent,
693
+ selector: "flr-button",
694
+ inputs: [
695
+ "variant",
696
+ "size",
697
+ "accent",
698
+ "loading",
699
+ "fullWidth",
700
+ "disabled",
701
+ "type",
702
+ "form",
703
+ "href",
704
+ "target",
705
+ "rel",
706
+ "aria-label"
707
+ ],
708
+ outputs: ["pressed"]
709
+ },
710
+ {
711
+ kind: "component",
712
+ type: TabsComponent,
713
+ selector: "flr-tabs",
714
+ inputs: ["mode", "ariaLabel"]
715
+ },
716
+ {
717
+ kind: "component",
718
+ type: TabComponent,
719
+ selector: "flr-tab",
720
+ inputs: [
721
+ "label",
722
+ "href",
723
+ "active",
724
+ "count",
725
+ "disabled",
726
+ "panelId"
727
+ ],
728
+ outputs: ["selected"]
729
+ },
730
+ {
731
+ kind: "component",
732
+ type: MarkdownComponent,
733
+ selector: "flr-markdown",
734
+ inputs: ["source"]
735
+ }
736
+ ],
737
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
738
+ });
739
+ }
740
+ };
741
+ i0.ɵɵngDeclareClassMetadata({
742
+ minVersion: "12.0.0",
743
+ version: "22.2.5",
744
+ ngImport: i0,
745
+ type: MarkdownEditorComponent,
746
+ decorators: [{
747
+ type: Component,
748
+ args: [{
749
+ selector: "flr-markdown-editor",
750
+ changeDetection: ChangeDetectionStrategy.OnPush,
751
+ imports: [
752
+ ButtonComponent,
753
+ TabsComponent,
754
+ TabComponent,
755
+ MarkdownComponent
756
+ ],
757
+ providers: [{
758
+ provide: NG_VALUE_ACCESSOR,
759
+ useExisting: forwardRef(() => MarkdownEditorComponent),
760
+ multi: true
761
+ }],
762
+ host: { class: "flr-md-editor" },
763
+ template: "<div class=\"flr-md-editor__frame\" [class.flr-md-editor__frame--disabled]=\"disabled()\">\n <div class=\"flr-md-editor__head\">\n <flr-tabs mode=\"panel\" [ariaLabel]=\"resolvedLabels().editorMode\">\n <flr-tab\n [label]=\"resolvedLabels().write\"\n [active]=\"!previewing()\"\n [panelId]=\"writeId\"\n (selected)=\"mode.set('write')\"\n />\n <flr-tab\n [label]=\"resolvedLabels().preview\"\n [active]=\"previewing()\"\n [panelId]=\"previewId\"\n (selected)=\"mode.set('preview')\"\n />\n </flr-tabs>\n <div\n class=\"flr-md-editor__toolbar\"\n role=\"group\"\n [attr.aria-label]=\"resolvedLabels().formatting\"\n [hidden]=\"previewing()\"\n >\n @for (action of actions; track action.id) {\n <flr-button\n variant=\"ghost\"\n size=\"sm\"\n [aria-label]=\"resolvedLabels()[action.label]\"\n [disabled]=\"disabled()\"\n (pressed)=\"run(action)\"\n >\n <span\n class=\"flr-md-editor__glyph\"\n aria-hidden=\"true\"\n [style]=\"action.style\"\n [attr.data-glyph]=\"action.glyph\"\n ></span>\n </flr-button>\n }\n </div>\n </div>\n\n <div\n [id]=\"writeId\"\n role=\"tabpanel\"\n [attr.aria-label]=\"resolvedLabels().write\"\n [hidden]=\"previewing()\"\n >\n <textarea\n #textarea\n class=\"flr-md-editor__input\"\n [rows]=\"rows()\"\n [style.min-height]=\"minHeight()\"\n [value]=\"written()\"\n [disabled]=\"disabled()\"\n [attr.placeholder]=\"placeholder()\"\n [attr.aria-label]=\"ariaLabel() ?? resolvedLabels().editor\"\n (input)=\"handleInput($event)\"\n (keydown)=\"handleKeydown($event)\"\n (blur)=\"handleBlur()\"\n ></textarea>\n </div>\n\n <div\n [id]=\"previewId\"\n role=\"tabpanel\"\n [attr.aria-label]=\"resolvedLabels().preview\"\n class=\"flr-md-editor__preview\"\n [style.min-height]=\"minHeight()\"\n [hidden]=\"!previewing()\"\n >\n @if (previewing()) {\n @if (value().trim()) {\n <flr-markdown [source]=\"value()\" />\n } @else {\n <p class=\"flr-md-editor__empty\">{{ resolvedLabels().nothingToPreview }}</p>\n }\n }\n </div>\n</div>\n",
764
+ styles: [":host{display:block}.flr-md-editor__frame{display:flex;flex-direction:column;border:1px solid var(--color-rule-strong, rgba(30, 41, 59, .28));border-radius:var(--radius-card, 8px);background:var(--color-card, #ffffff);overflow:hidden;transition:border-color .14s,box-shadow .14s}.flr-md-editor__frame:focus-within{border-color:var(--color-accent, var(--color-ink, #1e293b));box-shadow:0 0 0 3px color-mix(in oklab,var(--color-accent, var(--color-ink, #1e293b)) 30%,transparent)}.flr-md-editor__frame--disabled{background:var(--color-paper-2, #f1f5f9);cursor:not-allowed}.flr-md-editor__head{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:8px;padding:0 8px;background:var(--color-app-bg-2, #f1f5f9);border-bottom:1px solid var(--color-rule, rgba(30, 41, 59, .14))}.flr-md-editor__toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:4px;padding:6px 0}.flr-md-editor__toolbar[hidden]{display:none}.flr-md-editor__glyph{display:inline-block;min-width:1.25em;text-align:center}.flr-md-editor__glyph:before{content:attr(data-glyph)}.flr-md-editor__input{display:block;width:100%;box-sizing:border-box;padding:12px;border:0;outline:none;resize:vertical;background:transparent;color:var(--color-ink, #1e293b);font-family:var( --font-mono, \"DM Mono\", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace );font-size:14px;line-height:1.6}.flr-md-editor__input:disabled{cursor:not-allowed}.flr-md-editor__input::placeholder{color:var(--color-ink-3, #64748b)}.flr-md-editor__preview{box-sizing:border-box;padding:12px 16px}.flr-md-editor__preview[hidden]{display:none}.flr-md-editor__empty{margin:0;color:var(--color-ink-3, #64748b);font-size:14px}\n"]
765
+ }]
766
+ }],
767
+ propDecorators: {
768
+ placeholder: [{
769
+ type: i0.Input,
770
+ args: [{
771
+ isSignal: true,
772
+ alias: "placeholder",
773
+ required: false
774
+ }]
775
+ }],
776
+ rows: [{
777
+ type: i0.Input,
778
+ args: [{
779
+ isSignal: true,
780
+ alias: "rows",
781
+ required: false
782
+ }]
783
+ }],
784
+ minHeight: [{
785
+ type: i0.Input,
786
+ args: [{
787
+ isSignal: true,
788
+ alias: "minHeight",
789
+ required: false
790
+ }]
791
+ }],
792
+ labels: [{
793
+ type: i0.Input,
794
+ args: [{
795
+ isSignal: true,
796
+ alias: "labels",
797
+ required: false
798
+ }]
799
+ }],
800
+ ariaLabel: [{
801
+ type: i0.Input,
802
+ args: [{
803
+ isSignal: true,
804
+ alias: "aria-label",
805
+ required: false
806
+ }]
807
+ }],
808
+ textarea: [{
809
+ type: i0.ViewChild,
810
+ args: ["textarea", { isSignal: true }]
811
+ }]
812
+ }
813
+ });
814
+ export { CodeComponent, MarkdownComponent, MarkdownEditorComponent };
256
815
 
257
816
  //# sourceMappingURL=ferrlabs-ui-ng-markdown.mjs.map