@jambotron/aria-markdown-editor 0.0.0-stage → 0.2.4
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 +100 -2
- package/fesm2022/jambotron-aria-markdown-editor.mjs +1122 -0
- package/fesm2022/jambotron-aria-markdown-editor.mjs.map +1 -0
- package/package.json +49 -3
- package/styles/aria-markdown-editor.scss +37 -0
- package/types/jambotron-aria-markdown-editor.d.ts +308 -0
|
@@ -0,0 +1,1122 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injectable, InjectionToken, PLATFORM_ID, ViewEncapsulation, afterNextRender, afterRenderEffect, computed, forwardRef, inject, input, model, signal, viewChild } from "@angular/core";
|
|
3
|
+
import { Marked } from "marked";
|
|
4
|
+
import { NgTemplateOutlet, isPlatformBrowser } from "@angular/common";
|
|
5
|
+
import { NG_VALUE_ACCESSOR } from "@angular/forms";
|
|
6
|
+
import { Tab, TabContent, TabList, TabPanel, Tabs } from "@angular/aria/tabs";
|
|
7
|
+
import { Toolbar, ToolbarWidget, ToolbarWidgetGroup } from "@angular/aria/toolbar";
|
|
8
|
+
import { JtIconComponent } from "@jambotron/aria-components";
|
|
9
|
+
const JT_MD_EDITOR_DEFAULT_LABELS = {
|
|
10
|
+
editor: "Markdown",
|
|
11
|
+
toolbar: "Formatting",
|
|
12
|
+
write: "Write",
|
|
13
|
+
preview: "Preview",
|
|
14
|
+
heading: "Heading",
|
|
15
|
+
bold: "Bold",
|
|
16
|
+
italic: "Italic",
|
|
17
|
+
strike: "Strikethrough",
|
|
18
|
+
code: "Code",
|
|
19
|
+
link: "Link",
|
|
20
|
+
quote: "Quote",
|
|
21
|
+
bullets: "Bulleted list",
|
|
22
|
+
numbers: "Numbered list",
|
|
23
|
+
tasks: "Task list",
|
|
24
|
+
codeBlock: "Code block",
|
|
25
|
+
table: "Table",
|
|
26
|
+
math: "Formula",
|
|
27
|
+
image: "Image",
|
|
28
|
+
rule: "Horizontal line",
|
|
29
|
+
sampleText: "text",
|
|
30
|
+
sampleUrl: "https://",
|
|
31
|
+
sampleImage: "image",
|
|
32
|
+
sampleCode: "code",
|
|
33
|
+
sampleFormula: "x^2",
|
|
34
|
+
sampleColumn: "Column",
|
|
35
|
+
uploading: "Uploading",
|
|
36
|
+
uploadFailed: "Upload failed",
|
|
37
|
+
emptyPreview: "Nothing to preview"
|
|
38
|
+
};
|
|
39
|
+
const JT_MD_EDITOR_LABELS = new InjectionToken("JT_MD_EDITOR_LABELS", {
|
|
40
|
+
providedIn: "root",
|
|
41
|
+
factory: () => () => JT_MD_EDITOR_DEFAULT_LABELS
|
|
42
|
+
});
|
|
43
|
+
function provideJtMdEditorLabels(labels) {
|
|
44
|
+
const read = typeof labels === "function" ? labels : () => labels;
|
|
45
|
+
return {
|
|
46
|
+
provide: JT_MD_EDITOR_LABELS,
|
|
47
|
+
useValue: () => ({
|
|
48
|
+
...JT_MD_EDITOR_DEFAULT_LABELS,
|
|
49
|
+
...read()
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const JT_MARKDOWN_CONFIG = new InjectionToken("JT_MARKDOWN_CONFIG", {
|
|
54
|
+
providedIn: "root",
|
|
55
|
+
factory: () => ({})
|
|
56
|
+
});
|
|
57
|
+
function provideJtMarkdown(config) {
|
|
58
|
+
return {
|
|
59
|
+
provide: JT_MARKDOWN_CONFIG,
|
|
60
|
+
useValue: config
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const MATH = "jt-math";
|
|
64
|
+
const DISPLAY = "jt-math--display";
|
|
65
|
+
function escapeHtml(text) {
|
|
66
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
67
|
+
}
|
|
68
|
+
const INLINE_RULE = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n$]))\1(?=[\s?!.,:?!。,:]|$)/;
|
|
69
|
+
const BLOCK_RULE = /^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;
|
|
70
|
+
function placeholder(token) {
|
|
71
|
+
const display = token["displayMode"] === true;
|
|
72
|
+
return `<span class="${MATH}${display ? " " + DISPLAY : ""}">${escapeHtml(String(token["text"] ?? ""))}</span>`;
|
|
73
|
+
}
|
|
74
|
+
function mathToken(type, match) {
|
|
75
|
+
return {
|
|
76
|
+
type,
|
|
77
|
+
raw: match[0],
|
|
78
|
+
text: match[2].trim(),
|
|
79
|
+
displayMode: match[1].length === 2
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function markdownMathExtension() {
|
|
83
|
+
return { extensions: [{
|
|
84
|
+
name: "inlineKatex",
|
|
85
|
+
level: "inline",
|
|
86
|
+
start(src) {
|
|
87
|
+
let rest = src;
|
|
88
|
+
let offset = 0;
|
|
89
|
+
while (rest) {
|
|
90
|
+
const index = rest.indexOf("$");
|
|
91
|
+
if (index === -1) return;
|
|
92
|
+
if ((index === 0 || rest.charAt(index - 1) === " ") && INLINE_RULE.test(rest.substring(index))) return offset + index;
|
|
93
|
+
const next = rest.substring(index + 1);
|
|
94
|
+
const skipped = next.length - next.replace(/^\$+/, "").length;
|
|
95
|
+
offset += index + 1 + skipped;
|
|
96
|
+
rest = next.substring(skipped);
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
tokenizer(src) {
|
|
100
|
+
const match = src.match(INLINE_RULE);
|
|
101
|
+
return match ? mathToken("inlineKatex", match) : void 0;
|
|
102
|
+
},
|
|
103
|
+
renderer: (token) => placeholder(token)
|
|
104
|
+
}, {
|
|
105
|
+
name: "blockKatex",
|
|
106
|
+
level: "block",
|
|
107
|
+
tokenizer(src) {
|
|
108
|
+
const match = src.match(BLOCK_RULE);
|
|
109
|
+
return match ? mathToken("blockKatex", match) : void 0;
|
|
110
|
+
},
|
|
111
|
+
renderer: (token) => `<p>${placeholder(token)}</p>\n`
|
|
112
|
+
}] };
|
|
113
|
+
}
|
|
114
|
+
async function renderMath(element, katex) {
|
|
115
|
+
const spans = Array.from(element.querySelectorAll(`span.${MATH}`));
|
|
116
|
+
if (spans.length === 0 || !katex) return;
|
|
117
|
+
const engine = await katex();
|
|
118
|
+
spans.forEach((span) => {
|
|
119
|
+
if (!span.isConnected || !span.classList.contains(MATH)) return;
|
|
120
|
+
const tex = span.textContent ?? "";
|
|
121
|
+
const displayMode = span.classList.contains(DISPLAY);
|
|
122
|
+
span.classList.remove(MATH);
|
|
123
|
+
span.classList.add("jt-math-rendered");
|
|
124
|
+
engine.render(tex, span, {
|
|
125
|
+
displayMode,
|
|
126
|
+
throwOnError: false
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function applyEdit(text, edit) {
|
|
131
|
+
return text.slice(0, edit.from) + edit.insert + text.slice(edit.to);
|
|
132
|
+
}
|
|
133
|
+
function toggleWrap(state, before, after = before, placeholder = "") {
|
|
134
|
+
const { text, start, end } = state;
|
|
135
|
+
const selected = text.slice(start, end);
|
|
136
|
+
if (text.slice(start - before.length, start) === before && text.slice(end, end + after.length) === after) return {
|
|
137
|
+
from: start - before.length,
|
|
138
|
+
to: end + after.length,
|
|
139
|
+
insert: selected,
|
|
140
|
+
selectionStart: start - before.length,
|
|
141
|
+
selectionEnd: end - before.length
|
|
142
|
+
};
|
|
143
|
+
if (selected.length >= before.length + after.length && selected.startsWith(before) && selected.endsWith(after)) {
|
|
144
|
+
const inner = selected.slice(before.length, selected.length - after.length);
|
|
145
|
+
return {
|
|
146
|
+
from: start,
|
|
147
|
+
to: end,
|
|
148
|
+
insert: inner,
|
|
149
|
+
selectionStart: start,
|
|
150
|
+
selectionEnd: start + inner.length
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const inner = selected || placeholder;
|
|
154
|
+
return {
|
|
155
|
+
from: start,
|
|
156
|
+
to: end,
|
|
157
|
+
insert: before + inner + after,
|
|
158
|
+
selectionStart: start + before.length,
|
|
159
|
+
selectionEnd: start + before.length + inner.length
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function lineRange(text, start, end) {
|
|
163
|
+
const from = text.lastIndexOf("\n", start - 1) + 1;
|
|
164
|
+
const last = end > start && text.charAt(end - 1) === "\n" ? end - 1 : end;
|
|
165
|
+
const next = text.indexOf("\n", last);
|
|
166
|
+
return {
|
|
167
|
+
from,
|
|
168
|
+
to: next === -1 ? text.length : next
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
const LINE_MARKERS = {
|
|
172
|
+
quote: /^(\s*)> ?/,
|
|
173
|
+
bullets: /^(\s*)[-*+] (?!\[[ xX]\] )/,
|
|
174
|
+
numbers: /^(\s*)\d+[.)] /,
|
|
175
|
+
tasks: /^(\s*)[-*+] \[[ xX]\] /
|
|
176
|
+
};
|
|
177
|
+
const ANY_MARKER = /^(\s*)(?:> ?|[-*+] \[[ xX]\] |[-*+] |\d+[.)] )/;
|
|
178
|
+
function marker(kind, index) {
|
|
179
|
+
switch (kind) {
|
|
180
|
+
case "quote": return "> ";
|
|
181
|
+
case "bullets": return "- ";
|
|
182
|
+
case "numbers": return `${index + 1}. `;
|
|
183
|
+
case "tasks": return "- [ ] ";
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function toggleLines(state, kind) {
|
|
187
|
+
const { from, to } = lineRange(state.text, state.start, state.end);
|
|
188
|
+
const lines = state.text.slice(from, to).split("\n");
|
|
189
|
+
const filled = lines.filter((line) => line.trim() !== "");
|
|
190
|
+
const remove = filled.length > 0 && filled.every((line) => LINE_MARKERS[kind].test(line));
|
|
191
|
+
let index = 0;
|
|
192
|
+
const insert = lines.map((line) => {
|
|
193
|
+
if (remove) return line.replace(LINE_MARKERS[kind], "$1");
|
|
194
|
+
if (line.trim() === "" && lines.length > 1) return line;
|
|
195
|
+
const match = line.match(ANY_MARKER);
|
|
196
|
+
const indent = match ? match[1] : line.match(/^\s*/)?.[0] ?? "";
|
|
197
|
+
const rest = match ? line.slice(match[0].length) : line.slice(indent.length);
|
|
198
|
+
return indent + marker(kind, index++) + rest;
|
|
199
|
+
}).join("\n");
|
|
200
|
+
if (lines.length === 1 && state.start === state.end) {
|
|
201
|
+
const shift = insert.length - lines[0].length;
|
|
202
|
+
const caret = Math.max(from, state.start + shift);
|
|
203
|
+
return {
|
|
204
|
+
from,
|
|
205
|
+
to,
|
|
206
|
+
insert,
|
|
207
|
+
selectionStart: caret,
|
|
208
|
+
selectionEnd: caret
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
from,
|
|
213
|
+
to,
|
|
214
|
+
insert,
|
|
215
|
+
selectionStart: from,
|
|
216
|
+
selectionEnd: from + insert.length
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function cycleHeading(state) {
|
|
220
|
+
const { from, to } = lineRange(state.text, state.start, state.start);
|
|
221
|
+
const line = state.text.slice(from, to);
|
|
222
|
+
const match = line.match(/^(#{1,6}) /);
|
|
223
|
+
const level = match ? match[1].length : 0;
|
|
224
|
+
const content = match ? line.slice(match[0].length) : line;
|
|
225
|
+
const prefix = level >= 3 ? "" : "#".repeat(level + 1) + " ";
|
|
226
|
+
const insert = prefix + content;
|
|
227
|
+
const caret = Math.max(from + prefix.length, state.start + insert.length - line.length);
|
|
228
|
+
return {
|
|
229
|
+
from,
|
|
230
|
+
to,
|
|
231
|
+
insert,
|
|
232
|
+
selectionStart: caret,
|
|
233
|
+
selectionEnd: caret
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
const URL_LIKE = /^(https?:\/\/|mailto:|\/)\S*$/;
|
|
237
|
+
function insertLink(state, sampleText, sampleUrl) {
|
|
238
|
+
const selected = state.text.slice(state.start, state.end);
|
|
239
|
+
if (URL_LIKE.test(selected)) {
|
|
240
|
+
const insert = `[${sampleText}](${selected})`;
|
|
241
|
+
return {
|
|
242
|
+
from: state.start,
|
|
243
|
+
to: state.end,
|
|
244
|
+
insert,
|
|
245
|
+
selectionStart: state.start + 1,
|
|
246
|
+
selectionEnd: state.start + 1 + sampleText.length
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
const label = selected || sampleText;
|
|
250
|
+
const insert = `[${label}](${sampleUrl})`;
|
|
251
|
+
const urlStart = state.start + label.length + 3;
|
|
252
|
+
return {
|
|
253
|
+
from: state.start,
|
|
254
|
+
to: state.end,
|
|
255
|
+
insert,
|
|
256
|
+
selectionStart: selected ? urlStart : state.start + 1,
|
|
257
|
+
selectionEnd: selected ? urlStart + sampleUrl.length : state.start + 1 + label.length
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function blockPadding(text, start, end) {
|
|
261
|
+
const head = text.slice(0, start);
|
|
262
|
+
const tail = text.slice(end);
|
|
263
|
+
return {
|
|
264
|
+
before: head === "" || head.endsWith("\n\n") ? "" : head.endsWith("\n") ? "\n" : "\n\n",
|
|
265
|
+
after: tail === "" || tail.startsWith("\n\n") ? "" : tail.startsWith("\n") ? "\n" : "\n\n"
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function insertBlock(state, block, select) {
|
|
269
|
+
const { before, after } = blockPadding(state.text, state.start, state.end);
|
|
270
|
+
const insert = before + block + after;
|
|
271
|
+
const base = state.start + before.length;
|
|
272
|
+
const selectionStart = select ? base + select.start : base + block.length;
|
|
273
|
+
const selectionEnd = select ? base + select.end : selectionStart;
|
|
274
|
+
return {
|
|
275
|
+
from: state.start,
|
|
276
|
+
to: state.end,
|
|
277
|
+
insert,
|
|
278
|
+
selectionStart,
|
|
279
|
+
selectionEnd
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function insertCodeBlock(state, placeholder) {
|
|
283
|
+
const code = state.text.slice(state.start, state.end).replace(/\n$/, "") || placeholder;
|
|
284
|
+
return insertBlock(state, "```\n" + code + "\n```", {
|
|
285
|
+
start: 4,
|
|
286
|
+
end: 4 + code.length
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
function insertMath(state, placeholder) {
|
|
290
|
+
const selected = state.text.slice(state.start, state.end);
|
|
291
|
+
if (selected.includes("\n")) {
|
|
292
|
+
const tex = selected.replace(/\n$/, "");
|
|
293
|
+
return insertBlock(state, "$$\n" + tex + "\n$$", {
|
|
294
|
+
start: 3,
|
|
295
|
+
end: 3 + tex.length
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return toggleWrap(state, "$", "$", placeholder);
|
|
299
|
+
}
|
|
300
|
+
function insertTable(state, column) {
|
|
301
|
+
return insertBlock(state, `${`| ${column} 1 | ${column} 2 |`}\n| --- | --- |\n| | |\n| | |`, {
|
|
302
|
+
start: 2,
|
|
303
|
+
end: 2 + column.length + 2
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
function insertRule(state) {
|
|
307
|
+
return insertBlock(state, "---");
|
|
308
|
+
}
|
|
309
|
+
function insertImage(state, url, alt) {
|
|
310
|
+
return insertBlock(state, ``, {
|
|
311
|
+
start: 2,
|
|
312
|
+
end: 2 + alt.length
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
function continueList(state) {
|
|
316
|
+
if (state.start !== state.end) return null;
|
|
317
|
+
const from = state.text.lastIndexOf("\n", state.start - 1) + 1;
|
|
318
|
+
const lineEnd = state.text.indexOf("\n", state.start);
|
|
319
|
+
const line = state.text.slice(from, lineEnd === -1 ? state.text.length : lineEnd);
|
|
320
|
+
const match = line.match(/^(\s*)(?:([-*+]) \[[ xX]\] |([-*+]) |(\d+)([.)]) |> ?)/);
|
|
321
|
+
if (!match || state.start - from < match[0].length) return null;
|
|
322
|
+
if (line.slice(match[0].length).trim() === "" && state.start === from + line.length) return {
|
|
323
|
+
from,
|
|
324
|
+
to: from + line.length,
|
|
325
|
+
insert: "",
|
|
326
|
+
selectionStart: from,
|
|
327
|
+
selectionEnd: from
|
|
328
|
+
};
|
|
329
|
+
const [, indent, taskBullet, bullet, number, delimiter] = match;
|
|
330
|
+
const next = taskBullet ? `${taskBullet} [ ] ` : bullet ? `${bullet} ` : number ? `${Number(number) + 1}${delimiter} ` : "> ";
|
|
331
|
+
const insert = "\n" + indent + next;
|
|
332
|
+
const caret = state.start + insert.length;
|
|
333
|
+
return {
|
|
334
|
+
from: state.start,
|
|
335
|
+
to: state.end,
|
|
336
|
+
insert,
|
|
337
|
+
selectionStart: caret,
|
|
338
|
+
selectionEnd: caret
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
function mergeTypedMarker(state, key) {
|
|
342
|
+
if (state.start !== state.end) return null;
|
|
343
|
+
const from = state.text.lastIndexOf("\n", state.start - 1) + 1;
|
|
344
|
+
const head = state.text.slice(from, state.start);
|
|
345
|
+
let match = null;
|
|
346
|
+
if (key === "." || key === ")") match = head.match(/^(\s*)\d+[.)] (\d{1,3})$/);
|
|
347
|
+
else if (key === " ") match = head.match(/^(\s*)[-*+] ([-*+])$/);
|
|
348
|
+
if (!match) return null;
|
|
349
|
+
const [, indent, typed] = match;
|
|
350
|
+
const insert = indent + typed + key;
|
|
351
|
+
const caret = from + insert.length;
|
|
352
|
+
return {
|
|
353
|
+
from,
|
|
354
|
+
to: state.start,
|
|
355
|
+
insert,
|
|
356
|
+
selectionStart: caret,
|
|
357
|
+
selectionEnd: caret
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
function taskExtension() {
|
|
361
|
+
return { renderer: { checkbox({ checked }) {
|
|
362
|
+
return `<span class="jt-md-task${checked ? " jt-md-task--done" : ""}" role="img" aria-label="${checked ? "[x]" : "[ ]"}">${checked ? "☑" : "☐"}</span> `;
|
|
363
|
+
} } };
|
|
364
|
+
}
|
|
365
|
+
var JtMarkdownRenderer = class JtMarkdownRenderer {
|
|
366
|
+
config = inject(JT_MARKDOWN_CONFIG);
|
|
367
|
+
marked = new Marked({
|
|
368
|
+
gfm: true,
|
|
369
|
+
breaks: this.config.breaks ?? false
|
|
370
|
+
}, taskExtension(), ...this.config.math === false ? [] : [markdownMathExtension()], ...this.config.extensions ?? []);
|
|
371
|
+
render(markdown) {
|
|
372
|
+
return this.marked.parse(markdown ?? "", { async: false });
|
|
373
|
+
}
|
|
374
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
375
|
+
minVersion: "12.0.0",
|
|
376
|
+
version: "22.3.0",
|
|
377
|
+
ngImport: i0,
|
|
378
|
+
type: JtMarkdownRenderer,
|
|
379
|
+
deps: [],
|
|
380
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
381
|
+
});
|
|
382
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
383
|
+
minVersion: "12.0.0",
|
|
384
|
+
version: "22.3.0",
|
|
385
|
+
ngImport: i0,
|
|
386
|
+
type: JtMarkdownRenderer,
|
|
387
|
+
providedIn: "root"
|
|
388
|
+
});
|
|
389
|
+
};
|
|
390
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
391
|
+
minVersion: "12.0.0",
|
|
392
|
+
version: "22.3.0",
|
|
393
|
+
ngImport: i0,
|
|
394
|
+
type: JtMarkdownRenderer,
|
|
395
|
+
decorators: [{
|
|
396
|
+
type: Injectable,
|
|
397
|
+
args: [{ providedIn: "root" }]
|
|
398
|
+
}]
|
|
399
|
+
});
|
|
400
|
+
var JtMdPreviewComponent = class JtMdPreviewComponent {
|
|
401
|
+
element = inject(ElementRef);
|
|
402
|
+
renderer = inject(JtMarkdownRenderer);
|
|
403
|
+
config = inject(JT_MARKDOWN_CONFIG);
|
|
404
|
+
browser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
405
|
+
markdown = input("", ...ngDevMode ? [{ debugName: "markdown" }] : /* istanbul ignore next */ []);
|
|
406
|
+
html = computed(() => this.renderer.render(this.markdown() ?? ""), ...ngDevMode ? [{ debugName: "html" }] : /* istanbul ignore next */ []);
|
|
407
|
+
constructor() {
|
|
408
|
+
afterRenderEffect(() => {
|
|
409
|
+
this.html();
|
|
410
|
+
if (this.browser) renderMath(this.element.nativeElement, this.config.katex);
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
414
|
+
minVersion: "12.0.0",
|
|
415
|
+
version: "22.3.0",
|
|
416
|
+
ngImport: i0,
|
|
417
|
+
type: JtMdPreviewComponent,
|
|
418
|
+
deps: [],
|
|
419
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
420
|
+
});
|
|
421
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
422
|
+
minVersion: "17.1.0",
|
|
423
|
+
version: "22.3.0",
|
|
424
|
+
type: JtMdPreviewComponent,
|
|
425
|
+
isStandalone: true,
|
|
426
|
+
selector: "jt-md-preview",
|
|
427
|
+
inputs: { markdown: {
|
|
428
|
+
classPropertyName: "markdown",
|
|
429
|
+
publicName: "markdown",
|
|
430
|
+
isSignal: true,
|
|
431
|
+
isRequired: false,
|
|
432
|
+
transformFunction: null
|
|
433
|
+
} },
|
|
434
|
+
host: {
|
|
435
|
+
properties: { "innerHTML": "html()" },
|
|
436
|
+
classAttribute: "jt-md-preview"
|
|
437
|
+
},
|
|
438
|
+
ngImport: i0,
|
|
439
|
+
template: "",
|
|
440
|
+
isInline: true,
|
|
441
|
+
styles: [".jt-md-preview{display:block;color:var(--jt-text, inherit);line-height:1.6;overflow-wrap:anywhere}.jt-md-preview>:first-child{margin-top:0}.jt-md-preview>:last-child{margin-bottom:0}.jt-md-preview h1,.jt-md-preview h2,.jt-md-preview h3,.jt-md-preview h4,.jt-md-preview h5,.jt-md-preview h6{margin:1.2em 0 .5em;line-height:1.25}.jt-md-preview h1{font-size:1.75em}.jt-md-preview h2{font-size:1.4em}.jt-md-preview h3{font-size:1.2em}.jt-md-preview p,.jt-md-preview ul,.jt-md-preview ol,.jt-md-preview blockquote,.jt-md-preview pre,.jt-md-preview table{margin:0 0 .9em}.jt-md-preview ul,.jt-md-preview ol{padding-left:1.6em}.jt-md-preview li:has(>.jt-md-task){list-style:none;margin-left:-1.3em}.jt-md-preview .jt-md-task--done{color:var(--jt-accent, currentColor)}.jt-md-preview a{color:var(--jt-accent-text, #0b6aa8)}.jt-md-preview blockquote{padding:.2em 1em;border-left:3px solid var(--jt-accent, #14c8e6);color:var(--jt-text-muted, inherit)}.jt-md-preview code{padding:.1em .35em;border-radius:var(--jt-radius-sm, 6px);background:var(--jt-md-code-bg, rgba(10, 16, 48, .07));font-family:var(--jt-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);font-size:.9em}.jt-md-preview pre{padding:var(--jt-space-3, 12px);border-radius:var(--jt-radius-md, 10px);background:var(--jt-md-code-bg, rgba(10, 16, 48, .07));overflow-x:auto}.jt-md-preview pre code{padding:0;background:none}.jt-md-preview table{border-collapse:collapse;display:block;max-width:100%;overflow-x:auto}.jt-md-preview th,.jt-md-preview td{padding:.35em .75em;border:1px solid var(--jt-divider, rgba(10, 16, 48, .12))}.jt-md-preview th{text-align:left}.jt-md-preview img{max-width:100%;height:auto}.jt-md-preview hr{border:0;border-top:1px solid var(--jt-divider, rgba(10, 16, 48, .12));margin:1.5em 0}.jt-md-preview .jt-math{font-family:var(--jt-font-mono, ui-monospace, monospace);font-size:.9em;color:var(--jt-text-muted, inherit)}.jt-md-preview .jt-math--display{display:block;text-align:center}\n"],
|
|
442
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
443
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
444
|
+
});
|
|
445
|
+
};
|
|
446
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
447
|
+
minVersion: "12.0.0",
|
|
448
|
+
version: "22.3.0",
|
|
449
|
+
ngImport: i0,
|
|
450
|
+
type: JtMdPreviewComponent,
|
|
451
|
+
decorators: [{
|
|
452
|
+
type: Component,
|
|
453
|
+
args: [{
|
|
454
|
+
selector: "jt-md-preview",
|
|
455
|
+
template: "",
|
|
456
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
457
|
+
encapsulation: ViewEncapsulation.None,
|
|
458
|
+
host: {
|
|
459
|
+
"class": "jt-md-preview",
|
|
460
|
+
"[innerHTML]": "html()"
|
|
461
|
+
},
|
|
462
|
+
styles: [".jt-md-preview{display:block;color:var(--jt-text, inherit);line-height:1.6;overflow-wrap:anywhere}.jt-md-preview>:first-child{margin-top:0}.jt-md-preview>:last-child{margin-bottom:0}.jt-md-preview h1,.jt-md-preview h2,.jt-md-preview h3,.jt-md-preview h4,.jt-md-preview h5,.jt-md-preview h6{margin:1.2em 0 .5em;line-height:1.25}.jt-md-preview h1{font-size:1.75em}.jt-md-preview h2{font-size:1.4em}.jt-md-preview h3{font-size:1.2em}.jt-md-preview p,.jt-md-preview ul,.jt-md-preview ol,.jt-md-preview blockquote,.jt-md-preview pre,.jt-md-preview table{margin:0 0 .9em}.jt-md-preview ul,.jt-md-preview ol{padding-left:1.6em}.jt-md-preview li:has(>.jt-md-task){list-style:none;margin-left:-1.3em}.jt-md-preview .jt-md-task--done{color:var(--jt-accent, currentColor)}.jt-md-preview a{color:var(--jt-accent-text, #0b6aa8)}.jt-md-preview blockquote{padding:.2em 1em;border-left:3px solid var(--jt-accent, #14c8e6);color:var(--jt-text-muted, inherit)}.jt-md-preview code{padding:.1em .35em;border-radius:var(--jt-radius-sm, 6px);background:var(--jt-md-code-bg, rgba(10, 16, 48, .07));font-family:var(--jt-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);font-size:.9em}.jt-md-preview pre{padding:var(--jt-space-3, 12px);border-radius:var(--jt-radius-md, 10px);background:var(--jt-md-code-bg, rgba(10, 16, 48, .07));overflow-x:auto}.jt-md-preview pre code{padding:0;background:none}.jt-md-preview table{border-collapse:collapse;display:block;max-width:100%;overflow-x:auto}.jt-md-preview th,.jt-md-preview td{padding:.35em .75em;border:1px solid var(--jt-divider, rgba(10, 16, 48, .12))}.jt-md-preview th{text-align:left}.jt-md-preview img{max-width:100%;height:auto}.jt-md-preview hr{border:0;border-top:1px solid var(--jt-divider, rgba(10, 16, 48, .12));margin:1.5em 0}.jt-md-preview .jt-math{font-family:var(--jt-font-mono, ui-monospace, monospace);font-size:.9em;color:var(--jt-text-muted, inherit)}.jt-md-preview .jt-math--display{display:block;text-align:center}\n"]
|
|
463
|
+
}]
|
|
464
|
+
}],
|
|
465
|
+
ctorParameters: () => [],
|
|
466
|
+
propDecorators: { markdown: [{
|
|
467
|
+
type: i0.Input,
|
|
468
|
+
args: [{
|
|
469
|
+
isSignal: true,
|
|
470
|
+
alias: "markdown",
|
|
471
|
+
required: false
|
|
472
|
+
}]
|
|
473
|
+
}] }
|
|
474
|
+
});
|
|
475
|
+
const JT_MD_DEFAULT_TOOLS = [
|
|
476
|
+
"heading",
|
|
477
|
+
"bold",
|
|
478
|
+
"italic",
|
|
479
|
+
"strike",
|
|
480
|
+
"|",
|
|
481
|
+
"link",
|
|
482
|
+
"image",
|
|
483
|
+
"code",
|
|
484
|
+
"codeBlock",
|
|
485
|
+
"|",
|
|
486
|
+
"quote",
|
|
487
|
+
"bullets",
|
|
488
|
+
"numbers",
|
|
489
|
+
"tasks",
|
|
490
|
+
"|",
|
|
491
|
+
"table",
|
|
492
|
+
"math",
|
|
493
|
+
"rule"
|
|
494
|
+
];
|
|
495
|
+
const HOTKEYS = {
|
|
496
|
+
b: "bold",
|
|
497
|
+
i: "italic",
|
|
498
|
+
k: "link",
|
|
499
|
+
e: "code"
|
|
500
|
+
};
|
|
501
|
+
const HOTKEY_HINT = {
|
|
502
|
+
bold: "B",
|
|
503
|
+
italic: "I",
|
|
504
|
+
link: "K",
|
|
505
|
+
code: "E"
|
|
506
|
+
};
|
|
507
|
+
const NARROW = 720;
|
|
508
|
+
const ICONS = {
|
|
509
|
+
heading: "title",
|
|
510
|
+
bold: "format_bold",
|
|
511
|
+
italic: "format_italic",
|
|
512
|
+
strike: "format_strikethrough",
|
|
513
|
+
code: "code",
|
|
514
|
+
link: "link",
|
|
515
|
+
quote: "format_quote",
|
|
516
|
+
bullets: "format_list_bulleted",
|
|
517
|
+
numbers: "format_list_numbered",
|
|
518
|
+
tasks: "checklist",
|
|
519
|
+
codeBlock: "code_blocks",
|
|
520
|
+
table: "table",
|
|
521
|
+
math: "functions",
|
|
522
|
+
image: "image",
|
|
523
|
+
rule: "horizontal_rule"
|
|
524
|
+
};
|
|
525
|
+
var JtMdEditorComponent = class JtMdEditorComponent {
|
|
526
|
+
host = inject(ElementRef);
|
|
527
|
+
readLabels = inject(JT_MD_EDITOR_LABELS);
|
|
528
|
+
destroyRef = inject(DestroyRef);
|
|
529
|
+
value = model("", ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
530
|
+
placeholder = input("", ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
|
|
531
|
+
disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
|
|
532
|
+
readonly = input(false, ...ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []);
|
|
533
|
+
label = input("", ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
|
|
534
|
+
tools = input(JT_MD_DEFAULT_TOOLS, ...ngDevMode ? [{ debugName: "tools" }] : /* istanbul ignore next */ []);
|
|
535
|
+
layout = input("auto", ...ngDevMode ? [{ debugName: "layout" }] : /* istanbul ignore next */ []);
|
|
536
|
+
uploadImage = input(null, ...ngDevMode ? [{ debugName: "uploadImage" }] : /* istanbul ignore next */ []);
|
|
537
|
+
pickImage = input(null, ...ngDevMode ? [{ debugName: "pickImage" }] : /* istanbul ignore next */ []);
|
|
538
|
+
labels = computed(() => this.readLabels(), ...ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []);
|
|
539
|
+
textarea = viewChild("textarea", ...ngDevMode ? [{ debugName: "textarea" }] : /* istanbul ignore next */ []);
|
|
540
|
+
fileInput = viewChild("file", ...ngDevMode ? [{ debugName: "fileInput" }] : /* istanbul ignore next */ []);
|
|
541
|
+
formDisabled = signal(false, ...ngDevMode ? [{ debugName: "formDisabled" }] : /* istanbul ignore next */ []);
|
|
542
|
+
isDisabled = computed(() => this.disabled() || this.formDisabled(), ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
|
|
543
|
+
locked = computed(() => this.isDisabled() || this.readonly(), ...ngDevMode ? [{ debugName: "locked" }] : /* istanbul ignore next */ []);
|
|
544
|
+
width = signal(Number.POSITIVE_INFINITY, ...ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []);
|
|
545
|
+
tabbed = computed(() => this.layout() === "tabs" || this.layout() === "auto" && this.width() < NARROW, ...ngDevMode ? [{ debugName: "tabbed" }] : /* istanbul ignore next */ []);
|
|
546
|
+
tab = signal("write", ...ngDevMode ? [{ debugName: "tab" }] : /* istanbul ignore next */ []);
|
|
547
|
+
dragging = signal(false, ...ngDevMode ? [{ debugName: "dragging" }] : /* istanbul ignore next */ []);
|
|
548
|
+
uploads = signal(0, ...ngDevMode ? [{ debugName: "uploads" }] : /* istanbul ignore next */ []);
|
|
549
|
+
error = signal("", ...ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []);
|
|
550
|
+
groups = computed(() => {
|
|
551
|
+
const groups = [[]];
|
|
552
|
+
for (const tool of this.tools()) if (tool === "|") groups.push([]);
|
|
553
|
+
else groups[groups.length - 1].push(tool);
|
|
554
|
+
return groups.filter((group) => group.length > 0);
|
|
555
|
+
}, ...ngDevMode ? [{ debugName: "groups" }] : /* istanbul ignore next */ []);
|
|
556
|
+
onChange = () => {};
|
|
557
|
+
onTouched = () => {};
|
|
558
|
+
constructor() {
|
|
559
|
+
afterNextRender(() => {
|
|
560
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
561
|
+
const observer = new ResizeObserver((entries) => this.width.set(entries[0].contentRect.width));
|
|
562
|
+
observer.observe(this.host.nativeElement);
|
|
563
|
+
this.destroyRef.onDestroy(() => observer.disconnect());
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
writeValue(value) {
|
|
567
|
+
this.value.set(value ?? "");
|
|
568
|
+
}
|
|
569
|
+
registerOnChange(fn) {
|
|
570
|
+
this.onChange = fn;
|
|
571
|
+
}
|
|
572
|
+
registerOnTouched(fn) {
|
|
573
|
+
this.onTouched = fn;
|
|
574
|
+
}
|
|
575
|
+
setDisabledState(disabled) {
|
|
576
|
+
this.formDisabled.set(disabled);
|
|
577
|
+
}
|
|
578
|
+
icon(tool) {
|
|
579
|
+
return ICONS[tool];
|
|
580
|
+
}
|
|
581
|
+
title(tool) {
|
|
582
|
+
const key = HOTKEY_HINT[tool];
|
|
583
|
+
const mac = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform ?? "");
|
|
584
|
+
return this.labels()[tool] + (key ? ` (${mac ? "⌘" : "Ctrl+"}${key})` : "");
|
|
585
|
+
}
|
|
586
|
+
onInput(event) {
|
|
587
|
+
this.commit(event.target.value);
|
|
588
|
+
}
|
|
589
|
+
onBlur() {
|
|
590
|
+
this.onTouched();
|
|
591
|
+
}
|
|
592
|
+
onKeydown(event) {
|
|
593
|
+
if (this.locked() || event.isComposing) return;
|
|
594
|
+
const mod = event.ctrlKey || event.metaKey;
|
|
595
|
+
if (mod && !event.altKey && !event.shiftKey) {
|
|
596
|
+
const tool = HOTKEYS[event.key.toLowerCase()];
|
|
597
|
+
if (tool) {
|
|
598
|
+
event.preventDefault();
|
|
599
|
+
this.run(tool);
|
|
600
|
+
}
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
if (event.key === "Enter" && !mod && !event.shiftKey && !event.altKey) {
|
|
604
|
+
const edit = continueList(this.state());
|
|
605
|
+
if (edit) {
|
|
606
|
+
event.preventDefault();
|
|
607
|
+
this.apply(edit);
|
|
608
|
+
}
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
if ((event.key === "." || event.key === ")" || event.key === " ") && !mod && !event.altKey) {
|
|
612
|
+
const edit = mergeTypedMarker(this.state(), event.key);
|
|
613
|
+
if (edit) {
|
|
614
|
+
event.preventDefault();
|
|
615
|
+
this.apply(edit);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
onScroll(event) {
|
|
620
|
+
if (this.tabbed()) return;
|
|
621
|
+
const source = event.target;
|
|
622
|
+
const preview = this.host.nativeElement.querySelector(".jt-md-editor__preview");
|
|
623
|
+
const range = source.scrollHeight - source.clientHeight;
|
|
624
|
+
if (!preview || range <= 0) return;
|
|
625
|
+
preview.scrollTop = source.scrollTop / range * (preview.scrollHeight - preview.clientHeight);
|
|
626
|
+
}
|
|
627
|
+
run(tool) {
|
|
628
|
+
if (this.locked()) return;
|
|
629
|
+
const labels = this.labels();
|
|
630
|
+
const state = this.state();
|
|
631
|
+
switch (tool) {
|
|
632
|
+
case "heading": return this.apply(cycleHeading(state));
|
|
633
|
+
case "bold": return this.apply(toggleWrap(state, "**", "**", labels.sampleText));
|
|
634
|
+
case "italic": return this.apply(toggleWrap(state, "_", "_", labels.sampleText));
|
|
635
|
+
case "strike": return this.apply(toggleWrap(state, "~~", "~~", labels.sampleText));
|
|
636
|
+
case "code": return this.apply(toggleWrap(state, "`", "`", labels.sampleCode));
|
|
637
|
+
case "link": return this.apply(insertLink(state, labels.sampleText, labels.sampleUrl));
|
|
638
|
+
case "quote":
|
|
639
|
+
case "bullets":
|
|
640
|
+
case "numbers":
|
|
641
|
+
case "tasks": return this.apply(toggleLines(state, tool));
|
|
642
|
+
case "codeBlock": return this.apply(insertCodeBlock(state, labels.sampleCode));
|
|
643
|
+
case "table": return this.apply(insertTable(state, labels.sampleColumn));
|
|
644
|
+
case "math": return this.apply(insertMath(state, labels.sampleFormula));
|
|
645
|
+
case "rule": return this.apply(insertRule(state));
|
|
646
|
+
case "image":
|
|
647
|
+
this.chooseImage();
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
async chooseImage() {
|
|
652
|
+
const pick = this.pickImage();
|
|
653
|
+
if (pick) {
|
|
654
|
+
const image = await pick();
|
|
655
|
+
if (image) this.apply(insertImage(this.state(), image.url, image.alt ?? this.labels().sampleImage));
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
if (this.uploadImage()) {
|
|
659
|
+
this.fileInput()?.nativeElement.click();
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
const alt = this.labels().sampleImage;
|
|
663
|
+
const url = this.labels().sampleUrl;
|
|
664
|
+
const edit = insertImage(this.state(), url, alt);
|
|
665
|
+
const urlStart = edit.selectionStart + alt.length + 2;
|
|
666
|
+
this.apply({
|
|
667
|
+
...edit,
|
|
668
|
+
selectionStart: urlStart,
|
|
669
|
+
selectionEnd: urlStart + url.length
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
onFileChosen(event) {
|
|
673
|
+
const input = event.target;
|
|
674
|
+
const files = Array.from(input.files ?? []);
|
|
675
|
+
input.value = "";
|
|
676
|
+
this.uploadFiles(files);
|
|
677
|
+
}
|
|
678
|
+
onPaste(event) {
|
|
679
|
+
const files = this.imageFiles(event.clipboardData);
|
|
680
|
+
if (files.length && this.uploadImage() && !this.locked()) {
|
|
681
|
+
event.preventDefault();
|
|
682
|
+
this.uploadFiles(files);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
onDragOver(event) {
|
|
686
|
+
if (this.uploadImage() && !this.locked() && Array.from(event.dataTransfer?.types ?? []).includes("Files")) {
|
|
687
|
+
event.preventDefault();
|
|
688
|
+
this.dragging.set(true);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
onDragLeave() {
|
|
692
|
+
this.dragging.set(false);
|
|
693
|
+
}
|
|
694
|
+
onDrop(event) {
|
|
695
|
+
this.dragging.set(false);
|
|
696
|
+
const files = this.imageFiles(event.dataTransfer);
|
|
697
|
+
if (files.length && this.uploadImage() && !this.locked()) {
|
|
698
|
+
event.preventDefault();
|
|
699
|
+
this.uploadFiles(files);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
imageFiles(data) {
|
|
703
|
+
return Array.from(data?.files ?? []).filter((file) => file.type.startsWith("image/"));
|
|
704
|
+
}
|
|
705
|
+
async uploadFiles(files) {
|
|
706
|
+
const upload = this.uploadImage();
|
|
707
|
+
if (!upload) return;
|
|
708
|
+
this.error.set("");
|
|
709
|
+
for (const file of files) {
|
|
710
|
+
const marker = `![${this.labels().uploading} ${file.name}…]()`;
|
|
711
|
+
this.apply(insertImage(this.state(), "", `${this.labels().uploading} ${file.name}…`));
|
|
712
|
+
this.uploads.update((count) => count + 1);
|
|
713
|
+
try {
|
|
714
|
+
const result = await upload(file);
|
|
715
|
+
const image = typeof result === "string" ? { url: result } : result;
|
|
716
|
+
this.replaceMarker(marker, `![${image.alt ?? file.name.replace(/\.[^.]+$/, "")}](${image.url})`);
|
|
717
|
+
} catch {
|
|
718
|
+
this.replaceMarker(marker, "");
|
|
719
|
+
this.error.set(`${this.labels().uploadFailed}: ${file.name}`);
|
|
720
|
+
} finally {
|
|
721
|
+
this.uploads.update((count) => count - 1);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
replaceMarker(marker, insert) {
|
|
726
|
+
const text = this.value();
|
|
727
|
+
const from = text.indexOf(marker);
|
|
728
|
+
if (from === -1) return;
|
|
729
|
+
const to = from + marker.length;
|
|
730
|
+
const element = this.textarea()?.nativeElement;
|
|
731
|
+
const caret = element ? element.selectionStart : text.length;
|
|
732
|
+
const shift = insert.length - marker.length;
|
|
733
|
+
const next = caret >= to ? caret + shift : caret > from ? from + insert.length : caret;
|
|
734
|
+
this.apply({
|
|
735
|
+
from,
|
|
736
|
+
to,
|
|
737
|
+
insert,
|
|
738
|
+
selectionStart: next,
|
|
739
|
+
selectionEnd: next
|
|
740
|
+
}, false);
|
|
741
|
+
}
|
|
742
|
+
state() {
|
|
743
|
+
const element = this.textarea()?.nativeElement;
|
|
744
|
+
const text = this.value();
|
|
745
|
+
if (!element) return {
|
|
746
|
+
text,
|
|
747
|
+
start: text.length,
|
|
748
|
+
end: text.length
|
|
749
|
+
};
|
|
750
|
+
return {
|
|
751
|
+
text,
|
|
752
|
+
start: element.selectionStart,
|
|
753
|
+
end: element.selectionEnd
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
apply(edit, focus = true) {
|
|
757
|
+
const expected = applyEdit(this.value(), edit);
|
|
758
|
+
const element = this.textarea()?.nativeElement;
|
|
759
|
+
if (!element) {
|
|
760
|
+
this.commit(expected);
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
if (focus) element.focus();
|
|
764
|
+
element.setSelectionRange(edit.from, edit.to);
|
|
765
|
+
let done = false;
|
|
766
|
+
if (focus && typeof document !== "undefined" && typeof document.execCommand === "function") try {
|
|
767
|
+
done = edit.insert === "" && edit.from === edit.to ? true : document.execCommand(edit.insert === "" ? "delete" : "insertText", false, edit.insert);
|
|
768
|
+
} catch {
|
|
769
|
+
done = false;
|
|
770
|
+
}
|
|
771
|
+
if (!done || element.value !== expected) element.value = expected;
|
|
772
|
+
element.setSelectionRange(edit.selectionStart, edit.selectionEnd);
|
|
773
|
+
this.commit(expected);
|
|
774
|
+
}
|
|
775
|
+
commit(text) {
|
|
776
|
+
if (text === this.value()) return;
|
|
777
|
+
this.value.set(text);
|
|
778
|
+
this.onChange(text);
|
|
779
|
+
}
|
|
780
|
+
focus() {
|
|
781
|
+
this.textarea()?.nativeElement.focus();
|
|
782
|
+
}
|
|
783
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
784
|
+
minVersion: "12.0.0",
|
|
785
|
+
version: "22.3.0",
|
|
786
|
+
ngImport: i0,
|
|
787
|
+
type: JtMdEditorComponent,
|
|
788
|
+
deps: [],
|
|
789
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
790
|
+
});
|
|
791
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
792
|
+
minVersion: "17.0.0",
|
|
793
|
+
version: "22.3.0",
|
|
794
|
+
type: JtMdEditorComponent,
|
|
795
|
+
isStandalone: true,
|
|
796
|
+
selector: "jt-md-editor",
|
|
797
|
+
inputs: {
|
|
798
|
+
value: {
|
|
799
|
+
classPropertyName: "value",
|
|
800
|
+
publicName: "value",
|
|
801
|
+
isSignal: true,
|
|
802
|
+
isRequired: false,
|
|
803
|
+
transformFunction: null
|
|
804
|
+
},
|
|
805
|
+
placeholder: {
|
|
806
|
+
classPropertyName: "placeholder",
|
|
807
|
+
publicName: "placeholder",
|
|
808
|
+
isSignal: true,
|
|
809
|
+
isRequired: false,
|
|
810
|
+
transformFunction: null
|
|
811
|
+
},
|
|
812
|
+
disabled: {
|
|
813
|
+
classPropertyName: "disabled",
|
|
814
|
+
publicName: "disabled",
|
|
815
|
+
isSignal: true,
|
|
816
|
+
isRequired: false,
|
|
817
|
+
transformFunction: null
|
|
818
|
+
},
|
|
819
|
+
readonly: {
|
|
820
|
+
classPropertyName: "readonly",
|
|
821
|
+
publicName: "readonly",
|
|
822
|
+
isSignal: true,
|
|
823
|
+
isRequired: false,
|
|
824
|
+
transformFunction: null
|
|
825
|
+
},
|
|
826
|
+
label: {
|
|
827
|
+
classPropertyName: "label",
|
|
828
|
+
publicName: "label",
|
|
829
|
+
isSignal: true,
|
|
830
|
+
isRequired: false,
|
|
831
|
+
transformFunction: null
|
|
832
|
+
},
|
|
833
|
+
tools: {
|
|
834
|
+
classPropertyName: "tools",
|
|
835
|
+
publicName: "tools",
|
|
836
|
+
isSignal: true,
|
|
837
|
+
isRequired: false,
|
|
838
|
+
transformFunction: null
|
|
839
|
+
},
|
|
840
|
+
layout: {
|
|
841
|
+
classPropertyName: "layout",
|
|
842
|
+
publicName: "layout",
|
|
843
|
+
isSignal: true,
|
|
844
|
+
isRequired: false,
|
|
845
|
+
transformFunction: null
|
|
846
|
+
},
|
|
847
|
+
uploadImage: {
|
|
848
|
+
classPropertyName: "uploadImage",
|
|
849
|
+
publicName: "uploadImage",
|
|
850
|
+
isSignal: true,
|
|
851
|
+
isRequired: false,
|
|
852
|
+
transformFunction: null
|
|
853
|
+
},
|
|
854
|
+
pickImage: {
|
|
855
|
+
classPropertyName: "pickImage",
|
|
856
|
+
publicName: "pickImage",
|
|
857
|
+
isSignal: true,
|
|
858
|
+
isRequired: false,
|
|
859
|
+
transformFunction: null
|
|
860
|
+
}
|
|
861
|
+
},
|
|
862
|
+
outputs: { value: "valueChange" },
|
|
863
|
+
host: {
|
|
864
|
+
properties: {
|
|
865
|
+
"class.jt-md-editor--tabs": "tabbed()",
|
|
866
|
+
"class.jt-md-editor--disabled": "isDisabled()",
|
|
867
|
+
"class.jt-md-editor--dragging": "dragging()"
|
|
868
|
+
},
|
|
869
|
+
classAttribute: "jt-md-editor"
|
|
870
|
+
},
|
|
871
|
+
providers: [{
|
|
872
|
+
provide: NG_VALUE_ACCESSOR,
|
|
873
|
+
useExisting: forwardRef(() => JtMdEditorComponent),
|
|
874
|
+
multi: true
|
|
875
|
+
}],
|
|
876
|
+
viewQueries: [{
|
|
877
|
+
propertyName: "textarea",
|
|
878
|
+
first: true,
|
|
879
|
+
predicate: ["textarea"],
|
|
880
|
+
descendants: true,
|
|
881
|
+
isSignal: true
|
|
882
|
+
}, {
|
|
883
|
+
propertyName: "fileInput",
|
|
884
|
+
first: true,
|
|
885
|
+
predicate: ["file"],
|
|
886
|
+
descendants: true,
|
|
887
|
+
isSignal: true
|
|
888
|
+
}],
|
|
889
|
+
ngImport: i0,
|
|
890
|
+
template: "@if (tabbed()) {\n <div ngTabs class=\"jt-md-editor__tabs\">\n <ul ngTabList class=\"jt-md-editor__tablist\" [(selectedTab)]=\"tab\">\n <li ngTab class=\"jt-md-editor__tab\" value=\"write\">{{ labels().write }}</li>\n <li ngTab class=\"jt-md-editor__tab\" value=\"preview\">{{ labels().preview }}</li>\n </ul>\n <div ngTabPanel class=\"jt-md-editor__panel\" value=\"write\">\n <ng-template ngTabContent>\n <ng-container [ngTemplateOutlet]=\"source\" />\n </ng-template>\n </div>\n <div ngTabPanel class=\"jt-md-editor__panel\" value=\"preview\">\n <ng-template ngTabContent>\n <ng-container [ngTemplateOutlet]=\"preview\" />\n </ng-template>\n </div>\n </div>\n} @else {\n <div class=\"jt-md-editor__split\">\n <ng-container [ngTemplateOutlet]=\"source\" />\n <ng-container [ngTemplateOutlet]=\"preview\" />\n </div>\n}\n\n<ng-template #source>\n <div class=\"jt-md-editor__source\">\n @if (!readonly()) {\n <div ngToolbar class=\"jt-md-editor__toolbar\" [wrap]=\"true\" [disabled]=\"isDisabled()\" [attr.aria-label]=\"labels().toolbar\">\n @for (group of groups(); track $index) {\n <div ngToolbarWidgetGroup class=\"jt-md-editor__group\" role=\"group\">\n @for (tool of group; track tool) {\n <button ngToolbarWidget type=\"button\" class=\"jt-md-editor__button\" [attr.data-tool]=\"tool\"\n [attr.aria-label]=\"labels()[tool]\" [title]=\"title(tool)\"\n (mousedown)=\"$event.preventDefault()\" (click)=\"run(tool)\">\n <jt-icon [name]=\"icon(tool)\" [size]=\"18\" />\n </button>\n }\n </div>\n }\n @if (uploads()) {\n <span class=\"jt-md-editor__status\" role=\"status\">{{ labels().uploading }}…</span>\n }\n </div>\n }\n <textarea #textarea class=\"jt-md-editor__textarea\" spellcheck=\"true\"\n [value]=\"value()\" [placeholder]=\"placeholder()\" [disabled]=\"isDisabled()\" [readOnly]=\"readonly()\"\n [attr.aria-label]=\"label() || labels().editor\"\n (input)=\"onInput($event)\" (scroll)=\"onScroll($event)\" (blur)=\"onBlur()\" (keydown)=\"onKeydown($event)\" (paste)=\"onPaste($event)\"\n (dragover)=\"onDragOver($event)\" (dragleave)=\"onDragLeave()\" (drop)=\"onDrop($event)\"></textarea>\n @if (error()) {\n <p class=\"jt-md-editor__error\" role=\"alert\">{{ error() }}</p>\n }\n @if (uploadImage()) {\n <input #file type=\"file\" accept=\"image/*\" multiple hidden (change)=\"onFileChosen($event)\">\n }\n </div>\n</ng-template>\n\n<ng-template #preview>\n @if (value().trim()) {\n <jt-md-preview class=\"jt-md-editor__preview\" [markdown]=\"value()\" />\n } @else {\n <p class=\"jt-md-editor__preview jt-md-editor__preview--empty\">{{ labels().emptyPreview }}</p>\n }\n</ng-template>\n",
|
|
891
|
+
styles: [":host{display:block;min-width:0;color:var(--jt-text, inherit);--_height: var(--jt-md-editor-height, 420px)}.jt-md-editor__split{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:var(--jt-space-3, 12px);height:var(--_height)}.jt-md-editor__source{display:flex;flex-direction:column;min-height:0;border:1px solid var(--jt-field-border, rgba(10, 16, 48, .28));border-radius:var(--jt-radius-md, 10px);background:var(--jt-field-bg, rgba(255, 255, 255, .55));overflow:hidden;transition:border-color var(--jt-duration-fast, .12s) var(--jt-easing, ease),box-shadow var(--jt-duration-fast, .12s) var(--jt-easing, ease)}.jt-md-editor__source:focus-within{border-color:var(--jt-accent, #14c8e6);box-shadow:var(--jt-focus-ring, 0 0 0 3px rgba(20, 200, 230, .45))}:host(.jt-md-editor--dragging) .jt-md-editor__source{border-style:dashed;border-color:var(--jt-accent, #14c8e6)}.jt-md-editor__toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:var(--jt-space-1, 4px);padding:var(--jt-space-1, 4px);border-bottom:1px solid var(--jt-divider, rgba(10, 16, 48, .12))}.jt-md-editor__group{display:flex;gap:2px}.jt-md-editor__group+.jt-md-editor__group{padding-left:var(--jt-space-1, 4px);border-left:1px solid var(--jt-divider, rgba(10, 16, 48, .12))}.jt-md-editor__button{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;padding:0;border:0;border-radius:var(--jt-radius-sm, 6px);background:none;color:var(--jt-text-muted, inherit);cursor:pointer}.jt-md-editor__button:hover:not([aria-disabled=true]){background:var(--jt-md-hover-bg, rgba(20, 200, 230, .12));color:var(--jt-text, inherit)}.jt-md-editor__button:focus-visible{outline:none;box-shadow:var(--jt-focus-ring, 0 0 0 3px rgba(20, 200, 230, .45))}.jt-md-editor__button[aria-disabled=true]{color:var(--jt-text-disabled, rgba(20, 26, 51, .45));cursor:default}.jt-md-editor__status{margin-left:auto;padding:0 var(--jt-space-2, 8px);color:var(--jt-text-muted, inherit);font-size:.85em}.jt-md-editor__textarea{flex:1;min-height:0;width:100%;box-sizing:border-box;padding:var(--jt-space-3, 12px);border:0;outline:none;resize:none;background:transparent;color:inherit;font-family:var(--jt-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);font-size:.92em;line-height:1.55;tab-size:2}.jt-md-editor__textarea:disabled{color:var(--jt-text-disabled, rgba(20, 26, 51, .45))}.jt-md-editor__error{margin:0;padding:var(--jt-space-1, 4px) var(--jt-space-3, 12px);color:var(--jt-danger-text, #8a1414);font-size:.85em}.jt-md-editor__preview{display:block;min-height:0;margin:0;padding:var(--jt-space-3, 12px);border:1px solid var(--jt-divider, rgba(10, 16, 48, .12));border-radius:var(--jt-radius-md, 10px);overflow:auto}.jt-md-editor__preview--empty{color:var(--jt-text-muted, inherit);font-style:italic}.jt-md-editor__tablist{display:flex;gap:var(--jt-space-1, 4px);margin:0 0 var(--jt-space-2, 8px);padding:0;list-style:none;border-bottom:1px solid var(--jt-divider, rgba(10, 16, 48, .12))}.jt-md-editor__tab{padding:var(--jt-space-2, 8px) var(--jt-space-3, 12px);border-bottom:2px solid transparent;color:var(--jt-text-muted, inherit);cursor:pointer}.jt-md-editor__tab[aria-selected=true]{border-bottom-color:var(--jt-accent, #14c8e6);color:var(--jt-text, inherit)}.jt-md-editor__tab:focus-visible{outline:none;box-shadow:var(--jt-focus-ring, 0 0 0 3px rgba(20, 200, 230, .45))}.jt-md-editor__panel{height:var(--_height)}.jt-md-editor__panel[inert]{display:none}.jt-md-editor__panel>.jt-md-editor__source,.jt-md-editor__panel>.jt-md-editor__preview{height:100%;box-sizing:border-box}@media(prefers-reduced-motion:reduce){.jt-md-editor__source{transition:none}}\n"],
|
|
892
|
+
dependencies: [
|
|
893
|
+
{
|
|
894
|
+
kind: "directive",
|
|
895
|
+
type: NgTemplateOutlet,
|
|
896
|
+
selector: "[ngTemplateOutlet]",
|
|
897
|
+
inputs: [
|
|
898
|
+
"ngTemplateOutletContext",
|
|
899
|
+
"ngTemplateOutlet",
|
|
900
|
+
"ngTemplateOutletInjector"
|
|
901
|
+
]
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
kind: "directive",
|
|
905
|
+
type: Tabs,
|
|
906
|
+
selector: "[ngTabs]",
|
|
907
|
+
exportAs: ["ngTabs"]
|
|
908
|
+
},
|
|
909
|
+
{
|
|
910
|
+
kind: "directive",
|
|
911
|
+
type: TabList,
|
|
912
|
+
selector: "[ngTabList]",
|
|
913
|
+
inputs: [
|
|
914
|
+
"orientation",
|
|
915
|
+
"wrap",
|
|
916
|
+
"softDisabled",
|
|
917
|
+
"focusMode",
|
|
918
|
+
"selectionMode",
|
|
919
|
+
"selectedTab",
|
|
920
|
+
"disabled"
|
|
921
|
+
],
|
|
922
|
+
outputs: ["selectedTabChange"],
|
|
923
|
+
exportAs: ["ngTabList"]
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
kind: "directive",
|
|
927
|
+
type: Tab,
|
|
928
|
+
selector: "[ngTab]",
|
|
929
|
+
inputs: [
|
|
930
|
+
"id",
|
|
931
|
+
"disabled",
|
|
932
|
+
"value"
|
|
933
|
+
],
|
|
934
|
+
exportAs: ["ngTab"]
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
kind: "directive",
|
|
938
|
+
type: TabPanel,
|
|
939
|
+
selector: "[ngTabPanel]",
|
|
940
|
+
inputs: ["id", "value"],
|
|
941
|
+
exportAs: ["ngTabPanel"]
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
kind: "directive",
|
|
945
|
+
type: TabContent,
|
|
946
|
+
selector: "ng-template[ngTabContent]",
|
|
947
|
+
exportAs: ["ngTabContent"]
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
kind: "directive",
|
|
951
|
+
type: Toolbar,
|
|
952
|
+
selector: "[ngToolbar]",
|
|
953
|
+
inputs: [
|
|
954
|
+
"orientation",
|
|
955
|
+
"softDisabled",
|
|
956
|
+
"disabled",
|
|
957
|
+
"wrap"
|
|
958
|
+
],
|
|
959
|
+
exportAs: ["ngToolbar"]
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
kind: "directive",
|
|
963
|
+
type: ToolbarWidget,
|
|
964
|
+
selector: "[ngToolbarWidget]",
|
|
965
|
+
inputs: ["id", "disabled"],
|
|
966
|
+
exportAs: ["ngToolbarWidget"]
|
|
967
|
+
},
|
|
968
|
+
{
|
|
969
|
+
kind: "directive",
|
|
970
|
+
type: ToolbarWidgetGroup,
|
|
971
|
+
selector: "[ngToolbarWidgetGroup]",
|
|
972
|
+
inputs: ["disabled"],
|
|
973
|
+
exportAs: ["ngToolbarWidgetGroup"]
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
kind: "component",
|
|
977
|
+
type: JtMdPreviewComponent,
|
|
978
|
+
selector: "jt-md-preview",
|
|
979
|
+
inputs: ["markdown"]
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
kind: "component",
|
|
983
|
+
type: JtIconComponent,
|
|
984
|
+
selector: "jt-icon",
|
|
985
|
+
inputs: [
|
|
986
|
+
"name",
|
|
987
|
+
"label",
|
|
988
|
+
"size"
|
|
989
|
+
]
|
|
990
|
+
}
|
|
991
|
+
],
|
|
992
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
993
|
+
});
|
|
994
|
+
};
|
|
995
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
996
|
+
minVersion: "12.0.0",
|
|
997
|
+
version: "22.3.0",
|
|
998
|
+
ngImport: i0,
|
|
999
|
+
type: JtMdEditorComponent,
|
|
1000
|
+
decorators: [{
|
|
1001
|
+
type: Component,
|
|
1002
|
+
args: [{
|
|
1003
|
+
selector: "jt-md-editor",
|
|
1004
|
+
imports: [
|
|
1005
|
+
NgTemplateOutlet,
|
|
1006
|
+
Tabs,
|
|
1007
|
+
TabList,
|
|
1008
|
+
Tab,
|
|
1009
|
+
TabPanel,
|
|
1010
|
+
TabContent,
|
|
1011
|
+
Toolbar,
|
|
1012
|
+
ToolbarWidget,
|
|
1013
|
+
ToolbarWidgetGroup,
|
|
1014
|
+
JtMdPreviewComponent,
|
|
1015
|
+
JtIconComponent
|
|
1016
|
+
],
|
|
1017
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1018
|
+
providers: [{
|
|
1019
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1020
|
+
useExisting: forwardRef(() => JtMdEditorComponent),
|
|
1021
|
+
multi: true
|
|
1022
|
+
}],
|
|
1023
|
+
host: {
|
|
1024
|
+
"class": "jt-md-editor",
|
|
1025
|
+
"[class.jt-md-editor--tabs]": "tabbed()",
|
|
1026
|
+
"[class.jt-md-editor--disabled]": "isDisabled()",
|
|
1027
|
+
"[class.jt-md-editor--dragging]": "dragging()"
|
|
1028
|
+
},
|
|
1029
|
+
template: "@if (tabbed()) {\n <div ngTabs class=\"jt-md-editor__tabs\">\n <ul ngTabList class=\"jt-md-editor__tablist\" [(selectedTab)]=\"tab\">\n <li ngTab class=\"jt-md-editor__tab\" value=\"write\">{{ labels().write }}</li>\n <li ngTab class=\"jt-md-editor__tab\" value=\"preview\">{{ labels().preview }}</li>\n </ul>\n <div ngTabPanel class=\"jt-md-editor__panel\" value=\"write\">\n <ng-template ngTabContent>\n <ng-container [ngTemplateOutlet]=\"source\" />\n </ng-template>\n </div>\n <div ngTabPanel class=\"jt-md-editor__panel\" value=\"preview\">\n <ng-template ngTabContent>\n <ng-container [ngTemplateOutlet]=\"preview\" />\n </ng-template>\n </div>\n </div>\n} @else {\n <div class=\"jt-md-editor__split\">\n <ng-container [ngTemplateOutlet]=\"source\" />\n <ng-container [ngTemplateOutlet]=\"preview\" />\n </div>\n}\n\n<ng-template #source>\n <div class=\"jt-md-editor__source\">\n @if (!readonly()) {\n <div ngToolbar class=\"jt-md-editor__toolbar\" [wrap]=\"true\" [disabled]=\"isDisabled()\" [attr.aria-label]=\"labels().toolbar\">\n @for (group of groups(); track $index) {\n <div ngToolbarWidgetGroup class=\"jt-md-editor__group\" role=\"group\">\n @for (tool of group; track tool) {\n <button ngToolbarWidget type=\"button\" class=\"jt-md-editor__button\" [attr.data-tool]=\"tool\"\n [attr.aria-label]=\"labels()[tool]\" [title]=\"title(tool)\"\n (mousedown)=\"$event.preventDefault()\" (click)=\"run(tool)\">\n <jt-icon [name]=\"icon(tool)\" [size]=\"18\" />\n </button>\n }\n </div>\n }\n @if (uploads()) {\n <span class=\"jt-md-editor__status\" role=\"status\">{{ labels().uploading }}…</span>\n }\n </div>\n }\n <textarea #textarea class=\"jt-md-editor__textarea\" spellcheck=\"true\"\n [value]=\"value()\" [placeholder]=\"placeholder()\" [disabled]=\"isDisabled()\" [readOnly]=\"readonly()\"\n [attr.aria-label]=\"label() || labels().editor\"\n (input)=\"onInput($event)\" (scroll)=\"onScroll($event)\" (blur)=\"onBlur()\" (keydown)=\"onKeydown($event)\" (paste)=\"onPaste($event)\"\n (dragover)=\"onDragOver($event)\" (dragleave)=\"onDragLeave()\" (drop)=\"onDrop($event)\"></textarea>\n @if (error()) {\n <p class=\"jt-md-editor__error\" role=\"alert\">{{ error() }}</p>\n }\n @if (uploadImage()) {\n <input #file type=\"file\" accept=\"image/*\" multiple hidden (change)=\"onFileChosen($event)\">\n }\n </div>\n</ng-template>\n\n<ng-template #preview>\n @if (value().trim()) {\n <jt-md-preview class=\"jt-md-editor__preview\" [markdown]=\"value()\" />\n } @else {\n <p class=\"jt-md-editor__preview jt-md-editor__preview--empty\">{{ labels().emptyPreview }}</p>\n }\n</ng-template>\n",
|
|
1030
|
+
styles: [":host{display:block;min-width:0;color:var(--jt-text, inherit);--_height: var(--jt-md-editor-height, 420px)}.jt-md-editor__split{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:var(--jt-space-3, 12px);height:var(--_height)}.jt-md-editor__source{display:flex;flex-direction:column;min-height:0;border:1px solid var(--jt-field-border, rgba(10, 16, 48, .28));border-radius:var(--jt-radius-md, 10px);background:var(--jt-field-bg, rgba(255, 255, 255, .55));overflow:hidden;transition:border-color var(--jt-duration-fast, .12s) var(--jt-easing, ease),box-shadow var(--jt-duration-fast, .12s) var(--jt-easing, ease)}.jt-md-editor__source:focus-within{border-color:var(--jt-accent, #14c8e6);box-shadow:var(--jt-focus-ring, 0 0 0 3px rgba(20, 200, 230, .45))}:host(.jt-md-editor--dragging) .jt-md-editor__source{border-style:dashed;border-color:var(--jt-accent, #14c8e6)}.jt-md-editor__toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:var(--jt-space-1, 4px);padding:var(--jt-space-1, 4px);border-bottom:1px solid var(--jt-divider, rgba(10, 16, 48, .12))}.jt-md-editor__group{display:flex;gap:2px}.jt-md-editor__group+.jt-md-editor__group{padding-left:var(--jt-space-1, 4px);border-left:1px solid var(--jt-divider, rgba(10, 16, 48, .12))}.jt-md-editor__button{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;padding:0;border:0;border-radius:var(--jt-radius-sm, 6px);background:none;color:var(--jt-text-muted, inherit);cursor:pointer}.jt-md-editor__button:hover:not([aria-disabled=true]){background:var(--jt-md-hover-bg, rgba(20, 200, 230, .12));color:var(--jt-text, inherit)}.jt-md-editor__button:focus-visible{outline:none;box-shadow:var(--jt-focus-ring, 0 0 0 3px rgba(20, 200, 230, .45))}.jt-md-editor__button[aria-disabled=true]{color:var(--jt-text-disabled, rgba(20, 26, 51, .45));cursor:default}.jt-md-editor__status{margin-left:auto;padding:0 var(--jt-space-2, 8px);color:var(--jt-text-muted, inherit);font-size:.85em}.jt-md-editor__textarea{flex:1;min-height:0;width:100%;box-sizing:border-box;padding:var(--jt-space-3, 12px);border:0;outline:none;resize:none;background:transparent;color:inherit;font-family:var(--jt-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);font-size:.92em;line-height:1.55;tab-size:2}.jt-md-editor__textarea:disabled{color:var(--jt-text-disabled, rgba(20, 26, 51, .45))}.jt-md-editor__error{margin:0;padding:var(--jt-space-1, 4px) var(--jt-space-3, 12px);color:var(--jt-danger-text, #8a1414);font-size:.85em}.jt-md-editor__preview{display:block;min-height:0;margin:0;padding:var(--jt-space-3, 12px);border:1px solid var(--jt-divider, rgba(10, 16, 48, .12));border-radius:var(--jt-radius-md, 10px);overflow:auto}.jt-md-editor__preview--empty{color:var(--jt-text-muted, inherit);font-style:italic}.jt-md-editor__tablist{display:flex;gap:var(--jt-space-1, 4px);margin:0 0 var(--jt-space-2, 8px);padding:0;list-style:none;border-bottom:1px solid var(--jt-divider, rgba(10, 16, 48, .12))}.jt-md-editor__tab{padding:var(--jt-space-2, 8px) var(--jt-space-3, 12px);border-bottom:2px solid transparent;color:var(--jt-text-muted, inherit);cursor:pointer}.jt-md-editor__tab[aria-selected=true]{border-bottom-color:var(--jt-accent, #14c8e6);color:var(--jt-text, inherit)}.jt-md-editor__tab:focus-visible{outline:none;box-shadow:var(--jt-focus-ring, 0 0 0 3px rgba(20, 200, 230, .45))}.jt-md-editor__panel{height:var(--_height)}.jt-md-editor__panel[inert]{display:none}.jt-md-editor__panel>.jt-md-editor__source,.jt-md-editor__panel>.jt-md-editor__preview{height:100%;box-sizing:border-box}@media(prefers-reduced-motion:reduce){.jt-md-editor__source{transition:none}}\n"]
|
|
1031
|
+
}]
|
|
1032
|
+
}],
|
|
1033
|
+
ctorParameters: () => [],
|
|
1034
|
+
propDecorators: {
|
|
1035
|
+
value: [{
|
|
1036
|
+
type: i0.Input,
|
|
1037
|
+
args: [{
|
|
1038
|
+
isSignal: true,
|
|
1039
|
+
alias: "value",
|
|
1040
|
+
required: false
|
|
1041
|
+
}]
|
|
1042
|
+
}, {
|
|
1043
|
+
type: i0.Output,
|
|
1044
|
+
args: ["valueChange"]
|
|
1045
|
+
}],
|
|
1046
|
+
placeholder: [{
|
|
1047
|
+
type: i0.Input,
|
|
1048
|
+
args: [{
|
|
1049
|
+
isSignal: true,
|
|
1050
|
+
alias: "placeholder",
|
|
1051
|
+
required: false
|
|
1052
|
+
}]
|
|
1053
|
+
}],
|
|
1054
|
+
disabled: [{
|
|
1055
|
+
type: i0.Input,
|
|
1056
|
+
args: [{
|
|
1057
|
+
isSignal: true,
|
|
1058
|
+
alias: "disabled",
|
|
1059
|
+
required: false
|
|
1060
|
+
}]
|
|
1061
|
+
}],
|
|
1062
|
+
readonly: [{
|
|
1063
|
+
type: i0.Input,
|
|
1064
|
+
args: [{
|
|
1065
|
+
isSignal: true,
|
|
1066
|
+
alias: "readonly",
|
|
1067
|
+
required: false
|
|
1068
|
+
}]
|
|
1069
|
+
}],
|
|
1070
|
+
label: [{
|
|
1071
|
+
type: i0.Input,
|
|
1072
|
+
args: [{
|
|
1073
|
+
isSignal: true,
|
|
1074
|
+
alias: "label",
|
|
1075
|
+
required: false
|
|
1076
|
+
}]
|
|
1077
|
+
}],
|
|
1078
|
+
tools: [{
|
|
1079
|
+
type: i0.Input,
|
|
1080
|
+
args: [{
|
|
1081
|
+
isSignal: true,
|
|
1082
|
+
alias: "tools",
|
|
1083
|
+
required: false
|
|
1084
|
+
}]
|
|
1085
|
+
}],
|
|
1086
|
+
layout: [{
|
|
1087
|
+
type: i0.Input,
|
|
1088
|
+
args: [{
|
|
1089
|
+
isSignal: true,
|
|
1090
|
+
alias: "layout",
|
|
1091
|
+
required: false
|
|
1092
|
+
}]
|
|
1093
|
+
}],
|
|
1094
|
+
uploadImage: [{
|
|
1095
|
+
type: i0.Input,
|
|
1096
|
+
args: [{
|
|
1097
|
+
isSignal: true,
|
|
1098
|
+
alias: "uploadImage",
|
|
1099
|
+
required: false
|
|
1100
|
+
}]
|
|
1101
|
+
}],
|
|
1102
|
+
pickImage: [{
|
|
1103
|
+
type: i0.Input,
|
|
1104
|
+
args: [{
|
|
1105
|
+
isSignal: true,
|
|
1106
|
+
alias: "pickImage",
|
|
1107
|
+
required: false
|
|
1108
|
+
}]
|
|
1109
|
+
}],
|
|
1110
|
+
textarea: [{
|
|
1111
|
+
type: i0.ViewChild,
|
|
1112
|
+
args: ["textarea", { isSignal: true }]
|
|
1113
|
+
}],
|
|
1114
|
+
fileInput: [{
|
|
1115
|
+
type: i0.ViewChild,
|
|
1116
|
+
args: ["file", { isSignal: true }]
|
|
1117
|
+
}]
|
|
1118
|
+
}
|
|
1119
|
+
});
|
|
1120
|
+
export { JT_MARKDOWN_CONFIG, JT_MD_DEFAULT_TOOLS, JT_MD_EDITOR_DEFAULT_LABELS, JT_MD_EDITOR_LABELS, JtMarkdownRenderer, JtMdEditorComponent, JtMdPreviewComponent, applyEdit, continueList, cycleHeading, insertBlock, insertCodeBlock, insertImage, insertLink, insertMath, insertRule, insertTable, markdownMathExtension, mergeTypedMarker, provideJtMarkdown, provideJtMdEditorLabels, renderMath, toggleLines, toggleWrap };
|
|
1121
|
+
|
|
1122
|
+
//# sourceMappingURL=jambotron-aria-markdown-editor.mjs.map
|