xt-plugin-editor 0.0.0-stage → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,13 @@
1
- # Temporary Holding Version
1
+ ![ng-xtend logo](https://dont-code.net/assets/images/logos/logo-xtend-angular-red-small.png)
2
+
3
+ # Plugin xt-editor
4
+
5
+ This plugin is part of the [ng-xtend framework](https://github.com/dont-code/ng-xtend/blob/main/README.md)
6
+
7
+ It enable [xt-components](https://github.com/dont-code/ng-xtend/tree/main/libs/xt-components) to
8
+
9
+ - Display and edit rich text notes
10
+ ![Rich Text Editor](https://dont-code.net/assets/images/screenshots/plugin-default-primitive.png)
11
+
12
+ With it you are sure you can display / edit any type within any xt-components application like [xt-host](https://github.com/dont-code/ng-xtend/tree/main/libs/xt-host).
2
13
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
@@ -0,0 +1,770 @@
1
+ import * as i0 from '@angular/core';
2
+ import { SecurityContext, Pipe, input, inject, viewChild, signal, effect, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import { XtSimpleComponent, XtResolverService, updateFormGroupWithValue, XtRenderComponent } from 'xt-components';
4
+ import * as i1$1 from '@angular/forms';
5
+ import { FormGroup, ReactiveFormsModule, FormsModule } from '@angular/forms';
6
+ import { NodeSelection, EditorState } from 'prosemirror-state';
7
+ import { EditorView } from 'prosemirror-view';
8
+ import { schema, defaultMarkdownSerializer, defaultMarkdownParser } from 'prosemirror-markdown';
9
+ import { MenuItem, icons, wrapItem, blockTypeItem, Dropdown, DropdownSubmenu, joinUpItem, liftItem, selectParentNodeItem, undoItem, redoItem, menuBar } from 'prosemirror-menu';
10
+ import { joinUp, joinDown, lift, selectParentNode, toggleMark, wrapIn, chainCommands, exitCode, setBlockType, baseKeymap } from 'prosemirror-commands';
11
+ import { wrapInList, splitListItem, liftListItem, sinkListItem } from 'prosemirror-schema-list';
12
+ import { undo, redo, history } from 'prosemirror-history';
13
+ import { undoInputRule, wrappingInputRule, textblockTypeInputRule, smartQuotes, ellipsis, emDash, inputRules } from 'prosemirror-inputrules';
14
+ import { keymap } from 'prosemirror-keymap';
15
+ import { dropCursor } from 'prosemirror-dropcursor';
16
+ import { gapCursor } from 'prosemirror-gapcursor';
17
+ import { marked } from 'marked';
18
+ import * as i1 from '@angular/platform-browser';
19
+ import { Tooltip } from 'primeng/tooltip';
20
+ import { Dialog } from 'primeng/dialog';
21
+ import { ButtonDirective } from 'primeng/button';
22
+
23
+ /// Given a blockquote node type, returns an input rule that turns `"> "`
24
+ /// at the start of a textblock into a blockquote.
25
+ const prefix = "ProseMirror-prompt";
26
+ const mac = typeof navigator != "undefined" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform) : false;
27
+ /// Inspect the given schema looking for marks and nodes from the
28
+ /// basic schema, and if found, add key bindings related to them.
29
+ /// This will add:
30
+ ///
31
+ /// * **Mod-b** for toggling [strong](#schema-basic.StrongMark)
32
+ /// * **Mod-i** for toggling [emphasis](#schema-basic.EmMark)
33
+ /// * **Mod-`** for toggling [code font](#schema-basic.CodeMark)
34
+ /// * **Ctrl-Shift-0** for making the current textblock a paragraph
35
+ /// * **Ctrl-Shift-1** to **Ctrl-Shift-Digit6** for making the current
36
+ /// textblock a heading of the corresponding level
37
+ /// * **Ctrl-Shift-Backslash** to make the current textblock a code block
38
+ /// * **Ctrl-Shift-8** to wrap the selection in an ordered list
39
+ /// * **Ctrl-Shift-9** to wrap the selection in a bullet list
40
+ /// * **Ctrl->** to wrap the selection in a block quote
41
+ /// * **Enter** to split a non-empty textblock in a list item while at
42
+ /// the same time splitting the list item
43
+ /// * **Mod-Enter** to insert a hard break
44
+ /// * **Mod-_** to insert a horizontal rule
45
+ /// * **Backspace** to undo an input rule
46
+ /// * **Alt-ArrowUp** to `joinUp`
47
+ /// * **Alt-ArrowDown** to `joinDown`
48
+ /// * **Mod-BracketLeft** to `lift`
49
+ /// * **Escape** to `selectParentNode`
50
+ ///
51
+ /// You can suppress or map these bindings by passing a `mapKeys`
52
+ /// argument, which maps key names (say `"Mod-B"` to either `false`, to
53
+ /// remove the binding, or a new key name string.
54
+ function buildKeymap(schema, mapKeys) {
55
+ let keys = {}, type;
56
+ function bind(key, cmd) {
57
+ if (mapKeys) {
58
+ let mapped = mapKeys[key];
59
+ if (mapped === false)
60
+ return;
61
+ if (mapped)
62
+ key = mapped;
63
+ }
64
+ keys[key] = cmd;
65
+ }
66
+ bind("Mod-z", undo);
67
+ bind("Shift-Mod-z", redo);
68
+ bind("Backspace", undoInputRule);
69
+ if (!mac)
70
+ bind("Mod-y", redo);
71
+ bind("Alt-ArrowUp", joinUp);
72
+ bind("Alt-ArrowDown", joinDown);
73
+ bind("Mod-BracketLeft", lift);
74
+ bind("Escape", selectParentNode);
75
+ if (type = schema.marks["strong"]) {
76
+ bind("Mod-b", toggleMark(type));
77
+ bind("Mod-B", toggleMark(type));
78
+ }
79
+ if (type = schema.marks["em"]) {
80
+ bind("Mod-i", toggleMark(type));
81
+ bind("Mod-I", toggleMark(type));
82
+ }
83
+ if (type = schema.marks["code"])
84
+ bind("Mod-`", toggleMark(type));
85
+ if (type = schema.nodes["bullet_list"])
86
+ bind("Shift-Ctrl-8", wrapInList(type));
87
+ if (type = schema.nodes["ordered_list"])
88
+ bind("Shift-Ctrl-9", wrapInList(type));
89
+ if (type = schema.nodes["blockquote"])
90
+ bind("Ctrl->", wrapIn(type));
91
+ if (type = schema.nodes["hard_break"]) {
92
+ let br = type, cmd = chainCommands(exitCode, (state, dispatch) => {
93
+ if (dispatch)
94
+ dispatch(state.tr.replaceSelectionWith(br.create()).scrollIntoView());
95
+ return true;
96
+ });
97
+ bind("Mod-Enter", cmd);
98
+ bind("Shift-Enter", cmd);
99
+ if (mac)
100
+ bind("Ctrl-Enter", cmd);
101
+ }
102
+ if (type = schema.nodes["list_item"]) {
103
+ bind("Enter", splitListItem(type));
104
+ bind("Mod-[", liftListItem(type));
105
+ bind("Mod-]", sinkListItem(type));
106
+ }
107
+ if (type = schema.nodes["paragraph"])
108
+ bind("Shift-Ctrl-0", setBlockType(type));
109
+ if (type = schema.nodes["code_block"])
110
+ bind("Shift-Ctrl-\\", setBlockType(type));
111
+ if (type = schema.nodes["heading"])
112
+ for (let i = 1; i <= 6; i++)
113
+ bind("Shift-Ctrl-" + i, setBlockType(type, { level: i }));
114
+ if (type = schema.nodes["horizontal_rule"]) {
115
+ let hr = type;
116
+ bind("Mod-_", (state, dispatch) => {
117
+ if (dispatch)
118
+ dispatch(state.tr.replaceSelectionWith(hr.create()).scrollIntoView());
119
+ return true;
120
+ });
121
+ }
122
+ return keys;
123
+ }
124
+ function openPrompt(options) {
125
+ let wrapper = document.body.appendChild(document.createElement("div"));
126
+ wrapper.className = prefix;
127
+ let mouseOutside = (e) => { if (!wrapper.contains(e.target))
128
+ close(); };
129
+ setTimeout(() => window.addEventListener("mousedown", mouseOutside), 50);
130
+ let close = () => {
131
+ window.removeEventListener("mousedown", mouseOutside);
132
+ if (wrapper.parentNode)
133
+ wrapper.parentNode.removeChild(wrapper);
134
+ };
135
+ let domFields = [];
136
+ for (let name in options.fields)
137
+ domFields.push(options.fields[name].render());
138
+ let submitButton = document.createElement("button");
139
+ submitButton.type = "submit";
140
+ submitButton.className = prefix + "-submit";
141
+ submitButton.textContent = "OK";
142
+ let cancelButton = document.createElement("button");
143
+ cancelButton.type = "button";
144
+ cancelButton.className = prefix + "-cancel";
145
+ cancelButton.textContent = "Cancel";
146
+ cancelButton.addEventListener("click", close);
147
+ let form = wrapper.appendChild(document.createElement("form"));
148
+ if (options.title)
149
+ form.appendChild(document.createElement("h5")).textContent = options.title;
150
+ domFields.forEach(field => {
151
+ form.appendChild(document.createElement("div")).appendChild(field);
152
+ });
153
+ let buttons = form.appendChild(document.createElement("div"));
154
+ buttons.className = prefix + "-buttons";
155
+ buttons.appendChild(submitButton);
156
+ buttons.appendChild(document.createTextNode(" "));
157
+ buttons.appendChild(cancelButton);
158
+ let box = wrapper.getBoundingClientRect();
159
+ wrapper.style.top = ((window.innerHeight - box.height) / 2) + "px";
160
+ wrapper.style.left = ((window.innerWidth - box.width) / 2) + "px";
161
+ let submit = () => {
162
+ let params = getValues(options.fields, domFields);
163
+ if (params) {
164
+ close();
165
+ options.callback(params);
166
+ }
167
+ };
168
+ form.addEventListener("submit", e => {
169
+ e.preventDefault();
170
+ submit();
171
+ });
172
+ form.addEventListener("keydown", e => {
173
+ if (e.keyCode == 27) {
174
+ e.preventDefault();
175
+ close();
176
+ }
177
+ else if (e.keyCode == 13 && !(e.ctrlKey || e.metaKey || e.shiftKey)) {
178
+ e.preventDefault();
179
+ submit();
180
+ }
181
+ else if (e.keyCode == 9) {
182
+ window.setTimeout(() => {
183
+ if (!wrapper.contains(document.activeElement))
184
+ close();
185
+ }, 500);
186
+ }
187
+ });
188
+ let input = form.elements[0];
189
+ if (input)
190
+ input.focus();
191
+ }
192
+ function getValues(fields, domFields) {
193
+ let result = Object.create(null), i = 0;
194
+ for (let name in fields) {
195
+ let field = fields[name], dom = domFields[i++];
196
+ let value = field.read(dom), bad = field.validate(value);
197
+ if (bad) {
198
+ reportInvalid(dom, bad);
199
+ return null;
200
+ }
201
+ result[name] = field.clean(value);
202
+ }
203
+ return result;
204
+ }
205
+ function reportInvalid(dom, message) {
206
+ // FIXME this is awful and needs a lot more work
207
+ let parent = dom.parentNode;
208
+ let msg = parent.appendChild(document.createElement("div"));
209
+ msg.style.left = (dom.offsetLeft + dom.offsetWidth + 2) + "px";
210
+ msg.style.top = (dom.offsetTop - 5) + "px";
211
+ msg.className = "ProseMirror-invalid";
212
+ msg.textContent = message;
213
+ setTimeout(() => parent.removeChild(msg), 1500);
214
+ }
215
+ /// The type of field that `openPrompt` expects to be passed to it.
216
+ class Field {
217
+ /// Create a field with the given options. Options support by all
218
+ /// field types are:
219
+ constructor(
220
+ /// @internal
221
+ options) {
222
+ this.options = options;
223
+ }
224
+ /// Read the field's value from its DOM node.
225
+ read(dom) { return dom.value; }
226
+ /// A field-type-specific validation function.
227
+ validateType(value) { return null; }
228
+ /// @internal
229
+ validate(value) {
230
+ if (!value && this.options.required)
231
+ return "Required field";
232
+ return this.validateType(value) || (this.options.validate ? this.options.validate(value) : null);
233
+ }
234
+ clean(value) {
235
+ return this.options.clean ? this.options.clean(value) : value;
236
+ }
237
+ }
238
+ /// A field class for single-line text fields.
239
+ class TextField extends Field {
240
+ render() {
241
+ let input = document.createElement("input");
242
+ input.type = "text";
243
+ input.placeholder = this.options.label;
244
+ input.value = this.options.value || "";
245
+ input.autocomplete = "off";
246
+ return input;
247
+ }
248
+ }
249
+ /// A field class for dropdown fields based on a plain `<select>`
250
+ /// tag. Expects an option `options`, which should be an array of
251
+ /// `{value: string, label: string}` objects, or a function taking a
252
+ /// `ProseMirror` instance and returning such an array.
253
+ class SelectField extends Field {
254
+ render() {
255
+ let select = document.createElement("select");
256
+ this.options.options.forEach(o => {
257
+ let opt = select.appendChild(document.createElement("option"));
258
+ opt.value = o.value;
259
+ opt.selected = o.value == this.options.value;
260
+ opt.label = o.label;
261
+ });
262
+ return select;
263
+ }
264
+ }
265
+ // Helpers to create specific types of items
266
+ function canInsert(state, nodeType) {
267
+ let $from = state.selection.$from;
268
+ for (let d = $from.depth; d >= 0; d--) {
269
+ let index = $from.index(d);
270
+ if ($from.node(d).canReplaceWith(index, index, nodeType))
271
+ return true;
272
+ }
273
+ return false;
274
+ }
275
+ function insertImageItem(nodeType) {
276
+ return new MenuItem({
277
+ title: "Insert image",
278
+ label: "Image",
279
+ enable(state) { return canInsert(state, nodeType); },
280
+ run(state, _, view) {
281
+ let { from, to } = state.selection, attrs = null;
282
+ if (state.selection instanceof NodeSelection && state.selection.node.type == nodeType)
283
+ attrs = state.selection.node.attrs;
284
+ openPrompt({
285
+ title: "Insert image",
286
+ fields: {
287
+ src: new TextField({ label: "Location", required: true, value: attrs && attrs["src"] }),
288
+ title: new TextField({ label: "Title", value: attrs && attrs["title"] }),
289
+ alt: new TextField({ label: "Description",
290
+ value: attrs ? attrs["alt"] : state.doc.textBetween(from, to, " ") })
291
+ },
292
+ callback(attrs) {
293
+ view.dispatch(view.state.tr.replaceSelectionWith(nodeType.createAndFill(attrs)));
294
+ view.focus();
295
+ }
296
+ });
297
+ }
298
+ });
299
+ }
300
+ function cmdItem(cmd, options) {
301
+ let passedOptions = {
302
+ label: options.title,
303
+ run: cmd
304
+ };
305
+ for (let prop in options)
306
+ passedOptions[prop] = options[prop];
307
+ if (!options.enable && !options.select)
308
+ passedOptions[options.enable ? "enable" : "select"] = state => cmd(state);
309
+ return new MenuItem(passedOptions);
310
+ }
311
+ function markActive(state, type) {
312
+ let { from, $from, to, empty } = state.selection;
313
+ if (empty)
314
+ return !!type.isInSet(state.storedMarks || $from.marks());
315
+ else
316
+ return state.doc.rangeHasMark(from, to, type);
317
+ }
318
+ function markItem(markType, options) {
319
+ let passedOptions = {
320
+ active(state) { return markActive(state, markType); }
321
+ };
322
+ for (let prop in options)
323
+ passedOptions[prop] = options[prop];
324
+ return cmdItem(toggleMark(markType), passedOptions);
325
+ }
326
+ function linkItem(markType) {
327
+ return new MenuItem({
328
+ title: "Add or remove link",
329
+ icon: icons["link"],
330
+ active(state) { return markActive(state, markType); },
331
+ enable(state) { return !state.selection.empty; },
332
+ run(state, dispatch, view) {
333
+ if (markActive(state, markType)) {
334
+ toggleMark(markType)(state, dispatch);
335
+ return true;
336
+ }
337
+ openPrompt({
338
+ title: "Create a link",
339
+ fields: {
340
+ href: new TextField({
341
+ label: "Link target",
342
+ required: true
343
+ }),
344
+ title: new TextField({ label: "Title" })
345
+ },
346
+ callback(attrs) {
347
+ toggleMark(markType, attrs)(view.state, view.dispatch);
348
+ view.focus();
349
+ }
350
+ });
351
+ return true;
352
+ }
353
+ });
354
+ }
355
+ function wrapListItem(nodeType, options) {
356
+ return cmdItem(wrapInList(nodeType, options.attrs), options);
357
+ }
358
+ /// Given a schema, look for default mark and node types in it and
359
+ /// return an object with relevant menu items relating to those marks.
360
+ function buildMenuItems(schema, override) {
361
+ let r = {};
362
+ let mark;
363
+ override = override || {};
364
+ if (mark = schema.marks["strong"])
365
+ r.toggleStrong = override["strong"] || markItem(mark, { title: "Toggle strong style", icon: icons["strong"] });
366
+ if (mark = schema.marks["em"])
367
+ r.toggleEm = override["em"] || markItem(mark, { title: "Toggle emphasis", icon: icons["em"] });
368
+ if (mark = schema.marks["code"])
369
+ r.toggleCode = override["code"] || markItem(mark, { title: "Toggle code font", icon: icons["code"] });
370
+ if (mark = schema.marks["link"])
371
+ r.toggleLink = override["link"] || linkItem(mark);
372
+ let node;
373
+ if (node = schema.nodes["image"])
374
+ r.insertImage = override["image"] || insertImageItem(node);
375
+ if (node = schema.nodes["bullet_list"])
376
+ r.wrapBulletList = override["bullet_list"] || wrapListItem(node, {
377
+ title: "Wrap in bullet list",
378
+ icon: icons["bulletList"]
379
+ });
380
+ if (node = schema.nodes["ordered_list"])
381
+ r.wrapOrderedList = override["ordered_list"] || wrapListItem(node, {
382
+ title: "Wrap in ordered list",
383
+ icon: icons["orderedList"]
384
+ });
385
+ if (node = schema.nodes["blockquote"])
386
+ r.wrapBlockQuote = override["blockquote"] || wrapItem(node, {
387
+ title: "Wrap in block quote",
388
+ icon: icons["blockquote"]
389
+ });
390
+ if (node = schema.nodes["paragraph"])
391
+ r.makeParagraph = override["paragraph"] || blockTypeItem(node, {
392
+ title: "Change to paragraph",
393
+ label: "Plain"
394
+ });
395
+ if (node = schema.nodes["code_block"])
396
+ r.makeCodeBlock = override["code_block"] || blockTypeItem(node, {
397
+ title: "Change to code block",
398
+ label: "Code"
399
+ });
400
+ if (node = schema.nodes["heading"])
401
+ for (let i = 1; i <= 10; i++)
402
+ r["makeHead" + i] = override["makeHead" + i] || blockTypeItem(node, {
403
+ title: "Change to heading " + i,
404
+ label: "Level " + i,
405
+ attrs: { level: i }
406
+ });
407
+ if (node = schema.nodes["horizontal_rule"]) {
408
+ let hr = node;
409
+ r.insertHorizontalRule = override["horizontal_rule"] || new MenuItem({
410
+ title: "Insert horizontal rule",
411
+ label: "Horizontal rule",
412
+ enable(state) { return canInsert(state, hr); },
413
+ run(state, dispatch) { dispatch(state.tr.replaceSelectionWith(hr.create())); }
414
+ });
415
+ }
416
+ let cut = (arr) => arr.filter(x => x);
417
+ r.insertMenu = new Dropdown(cut([r.insertImage, r.insertHorizontalRule]), { label: "Insert" });
418
+ r.typeMenu = new Dropdown(cut([r.makeParagraph, r.makeCodeBlock, r.makeHead1 && new DropdownSubmenu(cut([
419
+ r.makeHead1, r.makeHead2, r.makeHead3, r.makeHead4, r.makeHead5, r.makeHead6
420
+ ]), { label: "Heading" })]), { label: "Type..." });
421
+ r.inlineMenu = [cut([r.toggleStrong, r.toggleEm, r.toggleCode, r.toggleLink])];
422
+ r.blockMenu = [cut([r.wrapBulletList, r.wrapOrderedList, r.wrapBlockQuote, joinUpItem,
423
+ liftItem, selectParentNodeItem])];
424
+ r.fullMenu = r.inlineMenu.concat([[r.insertMenu, r.typeMenu]], [[undoItem, redoItem]], r.blockMenu);
425
+ return r;
426
+ }
427
+ function blockQuoteRule(nodeType) {
428
+ return wrappingInputRule(/^\s*>\s$/, nodeType);
429
+ }
430
+ /// Given a list node type, returns an input rule that turns a number
431
+ /// followed by a dot at the start of a textblock into an ordered list.
432
+ function orderedListRule(nodeType) {
433
+ return wrappingInputRule(/^(\d+)\.\s$/, nodeType, match => ({ order: +match[1] }), (match, node) => node.childCount + node.attrs["order"] == +match[1]);
434
+ }
435
+ /// Given a list node type, returns an input rule that turns a bullet
436
+ /// (dash, plush, or asterisk) at the start of a textblock into a
437
+ /// bullet list.
438
+ function bulletListRule(nodeType) {
439
+ return wrappingInputRule(/^\s*([-+*])\s$/, nodeType);
440
+ }
441
+ /// Given a code block node type, returns an input rule that turns a
442
+ /// textblock starting with three backticks into a code block.
443
+ function codeBlockRule(nodeType) {
444
+ return textblockTypeInputRule(/^```$/, nodeType);
445
+ }
446
+ /// Given a node type and a maximum level, creates an input rule that
447
+ /// turns up to that number of `#` characters followed by a space at
448
+ /// the start of a textblock into a heading whose level corresponds to
449
+ /// the number of `#` signs.
450
+ function headingRule(nodeType, maxLevel) {
451
+ return textblockTypeInputRule(new RegExp("^(#{1," + maxLevel + "})\\s$"), nodeType, match => ({ level: match[1].length }));
452
+ }
453
+ /// A set of input rules for creating the basic block quotes, lists,
454
+ /// code blocks, and heading.
455
+ function buildInputRules(schema) {
456
+ let rules = smartQuotes.concat(ellipsis, emDash), type;
457
+ if (type = schema.nodes["blockquote"])
458
+ rules.push(blockQuoteRule(type));
459
+ if (type = schema.nodes["ordered_list"])
460
+ rules.push(orderedListRule(type));
461
+ if (type = schema.nodes["bullet_list"])
462
+ rules.push(bulletListRule(type));
463
+ if (type = schema.nodes["code_block"])
464
+ rules.push(codeBlockRule(type));
465
+ if (type = schema.nodes["heading"])
466
+ rules.push(headingRule(type, 6));
467
+ return inputRules({ rules });
468
+ }
469
+ /// Create an array of plugins pre-configured for the given schema.
470
+ /// The resulting array will include the following plugins:
471
+ ///
472
+ /// * Input rules for smart quotes and creating the block types in the
473
+ /// schema using markdown conventions (say `"> "` to create a
474
+ /// blockquote)
475
+ ///
476
+ /// * A keymap that defines keys to create and manipulate the nodes in the
477
+ /// schema
478
+ ///
479
+ /// * A keymap binding the default keys provided by the
480
+ /// prosemirror-commands module
481
+ ///
482
+ /// * The undo history plugin
483
+ ///
484
+ /// * The drop cursor plugin
485
+ ///
486
+ /// * The gap cursor plugin
487
+ ///
488
+ /// * A custom plugin that adds a `menuContent` prop for the
489
+ /// prosemirror-menu wrapper, and a CSS class that enables the
490
+ /// additional styling defined in `style/style.css` in this package
491
+ ///
492
+ /// Probably only useful for quickly setting up a passable
493
+ /// editor—you'll need more control over your settings in most
494
+ /// real-world situations.
495
+ function basicSetup(options) {
496
+ let plugins = [
497
+ buildInputRules(options.schema),
498
+ keymap(buildKeymap(options.schema, options.mapKeys)),
499
+ keymap(baseKeymap),
500
+ dropCursor(),
501
+ gapCursor()
502
+ ];
503
+ if (options.menuBar !== false)
504
+ plugins.push(menuBar({ floating: options.floatingMenu !== false,
505
+ content: buildMenuItems(options.schema, options.menuContent).fullMenu }));
506
+ if (options.history !== false)
507
+ plugins.push(history());
508
+ return plugins; /*.concat(new Plugin({
509
+ props: {
510
+ attributes: {class: "ProseMirror-example-setup-style"}
511
+ }
512
+ }))*/
513
+ }
514
+
515
+ class MarkdownPipe {
516
+ constructor(sanitizer) {
517
+ this.sanitizer = sanitizer;
518
+ }
519
+ transform(value, ...args) {
520
+ if (typeof value === 'string') {
521
+ const html = marked.parse(value.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, ""), {
522
+ async: false
523
+ });
524
+ return this.sanitizer.sanitize(SecurityContext.HTML, html);
525
+ }
526
+ return null;
527
+ }
528
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: MarkdownPipe, deps: [{ token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe }); }
529
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.7", ngImport: i0, type: MarkdownPipe, isStandalone: true, name: "markdown" }); }
530
+ }
531
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: MarkdownPipe, decorators: [{
532
+ type: Pipe,
533
+ args: [{
534
+ name: 'markdown',
535
+ }]
536
+ }], ctorParameters: () => [{ type: i1.DomSanitizer }] });
537
+
538
+ class InlineMarkdownPipe {
539
+ transform(value, ...args) {
540
+ if (typeof value === 'string') {
541
+ let text = value;
542
+ if (text.length > 100)
543
+ text = text.substring(0, 100); // For inline text, we don't want all the text, just the start
544
+ text = text.replace(/!\[[^\]]*\]\([^)]*\)/g, ''); // images
545
+ text = text.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1'); // links -> visible text
546
+ text = text.replace(/^#{1,6}\s*/gm, ''); // headers
547
+ text = text.replace(/^\s*[-*+]\s+/gm, ''); // bullet lists
548
+ text = text.replace(/^\s*\d+[.)]\s+/gm, ''); // numbered lists
549
+ text = text.replace(/^\s*[-*]\s+/gm, ''); // bullets that were bold markers
550
+ text = text.replace(/\*\*([^*]*)\*\*/g, '$1'); // bold
551
+ text = text.replace(/\*([^*]*)\*/g, '$1'); // italic *
552
+ text = text.replace(/(?<!\w)_([^_\n]+)_(?!\w)/g, '$1'); // italic _text_
553
+ text = text.replace(/\s*\n\s*/g, ' '); // newlines -> spaces
554
+ text = text.replace(/\s{2,}/g, ' ').trim(); // collapse
555
+ if (text.length > 57) {
556
+ return text.substring(0, 57) + '...';
557
+ }
558
+ return text;
559
+ }
560
+ return null;
561
+ }
562
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: InlineMarkdownPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
563
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.7", ngImport: i0, type: InlineMarkdownPipe, isStandalone: true, name: "inlineMarkdown" }); }
564
+ }
565
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: InlineMarkdownPipe, decorators: [{
566
+ type: Pipe,
567
+ args: [{
568
+ name: 'inlineMarkdown',
569
+ }]
570
+ }] });
571
+
572
+ class EditorComponent extends XtSimpleComponent {
573
+ constructor() {
574
+ super();
575
+ this.context = input.required(...(ngDevMode ? [{ debugName: "context" }] : /* istanbul ignore next */ []));
576
+ this.resolver = inject(XtResolverService);
577
+ this.editor = viewChild('editor', ...(ngDevMode ? [{ debugName: "editor" }] : /* istanbul ignore next */ []));
578
+ this.sampleJson = { "type": "doc", "content": [{ "type": "heading", "attrs": { "level": 1 }, "content": [{ "type": "text", "text": "Example Text" }] }, { "type": "paragraph", "content": [{ "type": "text", "text": "s it working ?" }] }] };
579
+ this.emptyJson = { "type": "doc", "content": [{ "type": "paragraph" }] };
580
+ // Mix the nodes from prosemirror-schema-list into the basic schema to create a schema with list support.
581
+ /** mySchema: Schema = new Schema({
582
+ nodes: addListNodes(schema.spec.nodes, "paragraph block*", "block"),
583
+ marks: schema.spec.marks
584
+ });*/
585
+ // Creates the markdown schema
586
+ this.mySchema = schema;
587
+ this.view = null;
588
+ /**
589
+ * Enable dialog box for image or link editing
590
+ * @protected
591
+ */
592
+ this.displayAttrDialog = signal(false, ...(ngDevMode ? [{ debugName: "displayAttrDialog" }] : /* istanbul ignore next */ []));
593
+ this.editAttrForm = new FormGroup({});
594
+ this.editAttrNodeType = this.mySchema['image'];
595
+ this.editAttrValueType = "editorImageType";
596
+ const imageType = this.resolver.typeResolver.findType('image');
597
+ const linkType = this.resolver.typeResolver.findType('link');
598
+ // Register the type with the image type if supported
599
+ this.resolver.registerTypes({
600
+ editorImageType: {
601
+ children: {
602
+ src: (imageType == null) ? "string" : "image",
603
+ title: "string",
604
+ alt: "string"
605
+ }
606
+ },
607
+ editorLinkType: {
608
+ children: {
609
+ href: (linkType == null) ? "string" : "link",
610
+ title: "string"
611
+ }
612
+ }
613
+ });
614
+ updateFormGroupWithValue(this.editAttrForm, {}, 'editorImageType', this.resolver.typeResolver);
615
+ // Setup the editor once the divs are available
616
+ effect(() => {
617
+ const editor = this.editor();
618
+ if ((editor != null) && (this.view == null)) {
619
+ const value = this.context().formControlValue();
620
+ const doc = this.toProseMirrorDoc(value);
621
+ this.view = new EditorView(editor.nativeElement, {
622
+ state: EditorState.create({
623
+ doc: doc,
624
+ plugins: basicSetup({ schema: this.mySchema, menuContent: {
625
+ image: this.imageMenu(this.mySchema.nodes['image'], this),
626
+ link: this.linkMenu(this.mySchema.marks['link'], this)
627
+ } })
628
+ }),
629
+ dispatchTransaction: this.handleTransactions.bind(this)
630
+ });
631
+ }
632
+ });
633
+ }
634
+ ngAfterViewInit() {
635
+ /* this.editor.valueChanges.pipe(takeUntil(this.unsubscribe)).subscribe((jsonDoc) => {
636
+ this.handleChange(jsonDoc);
637
+ });*/
638
+ }
639
+ imageMenu(imageNodeType, that) {
640
+ return new MenuItem({
641
+ title: "Insert image",
642
+ label: "Image",
643
+ enable(state) {
644
+ return canInsert(state, imageNodeType);
645
+ },
646
+ run(state, _, view) {
647
+ let { from, to } = state.selection, attrs = {};
648
+ if (state.selection instanceof NodeSelection && state.selection.node.type == imageNodeType)
649
+ attrs = state.selection.node.attrs || {};
650
+ if (attrs.alt == null)
651
+ attrs.alt = state.doc.textBetween(from, to, " ");
652
+ that.editAttrValueType = "editorImageType";
653
+ updateFormGroupWithValue(that.editAttrForm, attrs, that.editAttrValueType, that.resolver.typeResolver);
654
+ that.editAttrNodeType = imageNodeType;
655
+ that.displayAttrDialog.set(true);
656
+ }
657
+ });
658
+ }
659
+ updateAttrsFromForm() {
660
+ if (this.view != null) {
661
+ if (this.editAttrValueType == "editorImageType") {
662
+ this.view.dispatch(this.view.state.tr.replaceSelectionWith((this.mySchema.nodes['image']).createAndFill(this.editAttrForm.value)));
663
+ }
664
+ else if (this.editAttrValueType == "editorLinkType") {
665
+ toggleMark(this.editAttrNodeType, this.editAttrForm.value)(this.view.state, this.view.dispatch);
666
+ }
667
+ this.view.focus();
668
+ }
669
+ this.displayAttrDialog.set(false);
670
+ }
671
+ linkMenu(linkMarkType, that) {
672
+ return new MenuItem({
673
+ title: "Add or Remove link",
674
+ icon: icons["link"],
675
+ active(state) { return markActive(state, linkMarkType); },
676
+ enable(state) { return !state.selection.empty; },
677
+ run(state, _, view) {
678
+ let { from, to } = state.selection, attrs = {};
679
+ if (markActive(state, linkMarkType)) {
680
+ toggleMark(linkMarkType)(state, view.dispatch);
681
+ return true;
682
+ }
683
+ that.editAttrValueType = "editorLinkType";
684
+ updateFormGroupWithValue(that.editAttrForm, attrs, that.editAttrValueType, that.resolver.typeResolver);
685
+ that.editAttrNodeType = linkMarkType;
686
+ that.displayAttrDialog.set(true);
687
+ return true;
688
+ }
689
+ });
690
+ }
691
+ handleTransactions(tr) {
692
+ if (this.view != null) {
693
+ const state = this.view.state.apply(tr);
694
+ this.view.updateState(state);
695
+ if (tr.docChanged) {
696
+ const markdown = defaultMarkdownSerializer.serialize(state.doc);
697
+ this.context().setFormValue(markdown, true);
698
+ }
699
+ }
700
+ else {
701
+ console.error("Editor: View transaction received while no view defined.", tr.doc.toJSON());
702
+ }
703
+ }
704
+ toProseMirrorDoc(value) {
705
+ if (value == null) {
706
+ return this.mySchema.nodeFromJSON(this.emptyJson);
707
+ }
708
+ if (typeof value === 'string') {
709
+ // This is a markdown text,
710
+ return defaultMarkdownParser.parse(value);
711
+ }
712
+ return this.mySchema.nodeFromJSON(value);
713
+ }
714
+ textJson(text) {
715
+ return { "type": "doc", "content": [{ "type": "paragraph", "content": [{ "type": "text", "text": text }] }] };
716
+ }
717
+ ;
718
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: EditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
719
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.7", type: EditorComponent, isStandalone: true, selector: "xt-editor-editor", inputs: { context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: true, transformFunction: null } }, viewQueries: [{ propertyName: "editor", first: true, predicate: ["editor"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "@if (isInForm() ) {\n <div class=\"editorContainer\">\n <div #editor [formGroup]=\"formGroup()\">\n </div>\n </div>\n <p-dialog [visible]=\"displayAttrDialog()\" [modal]=\"true\" header=\"Edit\">\n <form [formGroup]=\"editAttrForm\">\n <xt-render [valueType]=\"editAttrValueType\" [formGroup]=\"editAttrForm\" displayMode=\"FULL_EDITABLE\" ></xt-render>\n </form>\n <ng-template #footer>\n <button type=\"button\" pButton severity=\"secondary\" variant=\"outlined\" (click)=\"displayAttrDialog.set(false)\">Cancel</button>\n <button type=\"button\" pButton (click)=\"updateAttrsFromForm()\">Save</button>\n </ng-template>\n </p-dialog>\n} @else {\n @let toDisplay=displayValue();\n @if (toDisplay!=null) {\n @if (context().displayMode=='FULL_VIEW') {\n <div class=\"displayForm\" [innerHTML]=\"displayValue() | markdown\">\n </div>\n } @else {\n <span [pTooltip]=\"fullText\">{{ toDisplay | inlineMarkdown}}</span>\n <ng-template #fullText>\n <div class=\"toolTip\" [innerHTML]=\"displayValue() | markdown\">\n </div>\n </ng-template>\n }\n }\n}\n", styles: [".editorContainer{width:60em;border:white solid thin;padding:5px}.toolTip{white-space:normal}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "showOnEllipsis", "pTooltip", "tooltipDisabled", "tooltipOptions", "appendTo", "ptTooltip", "pTooltipPT", "pTooltipUnstyled"] }, { kind: "component", type: Dialog, selector: "p-dialog", inputs: ["hostName", "header", "draggable", "resizable", "contentStyle", "contentStyleClass", "modal", "closeOnEscape", "dismissableMask", "rtl", "closable", "breakpoints", "styleClass", "maskStyleClass", "maskStyle", "showHeader", "blockScroll", "autoZIndex", "baseZIndex", "minX", "minY", "focusOnShow", "maximizable", "keepInViewport", "focusTrap", "transitionOptions", "maskMotionOptions", "motionOptions", "closeIcon", "closeAriaLabel", "closeTabindex", "minimizeIcon", "maximizeIcon", "closeButtonProps", "maximizeButtonProps", "visible", "style", "position", "role", "appendTo", "content", "contentTemplate", "footerTemplate", "closeIconTemplate", "maximizeIconTemplate", "minimizeIconTemplate", "headlessTemplate"], outputs: ["onShow", "onHide", "visibleChange", "onResizeInit", "onResizeEnd", "onDragEnd", "onMaximize"] }, { kind: "component", type: XtRenderComponent, selector: "xt-render", inputs: ["componentType", "displayMode", "valueType", "value", "formGroup", "subName", "inputs", "models"], outputs: ["valueChange", "outputs"] }, { kind: "directive", type: ButtonDirective, selector: "[pButton]", inputs: ["ptButtonDirective", "pButtonPT", "pButtonUnstyled", "hostName", "text", "plain", "raised", "size", "outlined", "rounded", "iconPos", "loadingIcon", "fluid", "label", "icon", "loading", "buttonProps", "severity"] }, { kind: "pipe", type: MarkdownPipe, name: "markdown" }, { kind: "pipe", type: InlineMarkdownPipe, name: "inlineMarkdown" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
720
+ }
721
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: EditorComponent, decorators: [{
722
+ type: Component,
723
+ args: [{ selector: 'xt-editor-editor', imports: [
724
+ ReactiveFormsModule,
725
+ FormsModule,
726
+ MarkdownPipe, InlineMarkdownPipe, Tooltip, Dialog,
727
+ XtRenderComponent, ButtonDirective
728
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (isInForm() ) {\n <div class=\"editorContainer\">\n <div #editor [formGroup]=\"formGroup()\">\n </div>\n </div>\n <p-dialog [visible]=\"displayAttrDialog()\" [modal]=\"true\" header=\"Edit\">\n <form [formGroup]=\"editAttrForm\">\n <xt-render [valueType]=\"editAttrValueType\" [formGroup]=\"editAttrForm\" displayMode=\"FULL_EDITABLE\" ></xt-render>\n </form>\n <ng-template #footer>\n <button type=\"button\" pButton severity=\"secondary\" variant=\"outlined\" (click)=\"displayAttrDialog.set(false)\">Cancel</button>\n <button type=\"button\" pButton (click)=\"updateAttrsFromForm()\">Save</button>\n </ng-template>\n </p-dialog>\n} @else {\n @let toDisplay=displayValue();\n @if (toDisplay!=null) {\n @if (context().displayMode=='FULL_VIEW') {\n <div class=\"displayForm\" [innerHTML]=\"displayValue() | markdown\">\n </div>\n } @else {\n <span [pTooltip]=\"fullText\">{{ toDisplay | inlineMarkdown}}</span>\n <ng-template #fullText>\n <div class=\"toolTip\" [innerHTML]=\"displayValue() | markdown\">\n </div>\n </ng-template>\n }\n }\n}\n", styles: [".editorContainer{width:60em;border:white solid thin;padding:5px}.toolTip{white-space:normal}\n"] }]
729
+ }], ctorParameters: () => [], propDecorators: { context: [{ type: i0.Input, args: [{ isSignal: true, alias: "context", required: true }] }], editor: [{ type: i0.ViewChild, args: ['editor', { isSignal: true }] }] } });
730
+
731
+ function registerEditorPlugin(resolverService) {
732
+ const pluginName = "Plugin Editor";
733
+ console.info('Registering ' + pluginName);
734
+ resolverService.registerPlugin({
735
+ name: pluginName,
736
+ uriLogo: 'pluginicon.png',
737
+ cssUrls: [
738
+ 'prosemirror-view/style/prosemirror.css',
739
+ 'prosemirror-menu/style/menu.css',
740
+ 'prosemirror-gapcursor/style/gapcursor.css'
741
+ ],
742
+ components: [
743
+ {
744
+ componentName: 'Editor',
745
+ componentClass: EditorComponent,
746
+ typesHandled: ['markdown', 'rich-text', 'description'],
747
+ }
748
+ ],
749
+ types: {
750
+ 'markdown': 'string',
751
+ 'rich-text': 'string',
752
+ 'description': 'string'
753
+ }
754
+ });
755
+ return pluginName;
756
+ }
757
+ function registerPlugin(resolverService) {
758
+ return registerEditorPlugin(resolverService);
759
+ }
760
+
761
+ /*
762
+ * Public API Surface of web plugin
763
+ */
764
+
765
+ /**
766
+ * Generated bundle index. Do not edit.
767
+ */
768
+
769
+ export { EditorComponent, MarkdownPipe, registerEditorPlugin, registerPlugin };
770
+ //# sourceMappingURL=xt-plugin-editor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xt-plugin-editor.mjs","sources":["../../../projects/editor/src/lib/prose-mirror/basic-setup.ts","../../../projects/editor/src/lib/markdown/markdown-pipe.ts","../../../projects/editor/src/lib/markdown/inline-markdown-pipe.ts","../../../projects/editor/src/lib/editor/editor.component.ts","../../../projects/editor/src/lib/editor/editor.component.html","../../../projects/editor/src/lib/register.ts","../../../projects/editor/src/public-api.ts","../../../projects/editor/src/xt-plugin-editor.ts"],"sourcesContent":["\n\n\n/// Given a blockquote node type, returns an input rule that turns `\"> \"`\n/// at the start of a textblock into a blockquote.\n\nimport {\n wrapItem, blockTypeItem, Dropdown, DropdownSubmenu, joinUpItem, liftItem,\n selectParentNodeItem, undoItem, redoItem, icons, MenuItem, MenuElement, MenuItemSpec, menuBar\n} from 'prosemirror-menu';\nimport {NodeSelection, EditorState, Command} from \"prosemirror-state\"\nimport {Schema, NodeType, MarkType} from \"prosemirror-model\"\n\nimport {Attrs} from \"prosemirror-model\"\n\nconst prefix = \"ProseMirror-prompt\"\n\nimport {\n wrapIn, setBlockType, chainCommands, toggleMark, exitCode,\n joinUp, joinDown, lift, selectParentNode, baseKeymap\n} from 'prosemirror-commands';\nimport {wrapInList, splitListItem, liftListItem, sinkListItem} from \"prosemirror-schema-list\"\nimport { undo, redo, history } from 'prosemirror-history';\nimport {\n ellipsis, emDash,\n inputRules,\n smartQuotes,\n textblockTypeInputRule,\n undoInputRule,\n wrappingInputRule\n} from 'prosemirror-inputrules';\nimport { keymap } from 'prosemirror-keymap';\nimport { dropCursor } from 'prosemirror-dropcursor';\nimport { gapCursor } from 'prosemirror-gapcursor';\n\nconst mac = typeof navigator != \"undefined\" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform) : false\n\n/// Inspect the given schema looking for marks and nodes from the\n/// basic schema, and if found, add key bindings related to them.\n/// This will add:\n///\n/// * **Mod-b** for toggling [strong](#schema-basic.StrongMark)\n/// * **Mod-i** for toggling [emphasis](#schema-basic.EmMark)\n/// * **Mod-`** for toggling [code font](#schema-basic.CodeMark)\n/// * **Ctrl-Shift-0** for making the current textblock a paragraph\n/// * **Ctrl-Shift-1** to **Ctrl-Shift-Digit6** for making the current\n/// textblock a heading of the corresponding level\n/// * **Ctrl-Shift-Backslash** to make the current textblock a code block\n/// * **Ctrl-Shift-8** to wrap the selection in an ordered list\n/// * **Ctrl-Shift-9** to wrap the selection in a bullet list\n/// * **Ctrl->** to wrap the selection in a block quote\n/// * **Enter** to split a non-empty textblock in a list item while at\n/// the same time splitting the list item\n/// * **Mod-Enter** to insert a hard break\n/// * **Mod-_** to insert a horizontal rule\n/// * **Backspace** to undo an input rule\n/// * **Alt-ArrowUp** to `joinUp`\n/// * **Alt-ArrowDown** to `joinDown`\n/// * **Mod-BracketLeft** to `lift`\n/// * **Escape** to `selectParentNode`\n///\n/// You can suppress or map these bindings by passing a `mapKeys`\n/// argument, which maps key names (say `\"Mod-B\"` to either `false`, to\n/// remove the binding, or a new key name string.\nexport function buildKeymap(schema: Schema, mapKeys?: {[key: string]: false | string}) {\n let keys: {[key: string]: Command} = {}, type\n function bind(key: string, cmd: Command) {\n if (mapKeys) {\n let mapped = mapKeys[key]\n if (mapped === false) return\n if (mapped) key = mapped\n }\n keys[key] = cmd\n }\n\n bind(\"Mod-z\", undo)\n bind(\"Shift-Mod-z\", redo)\n bind(\"Backspace\", undoInputRule)\n if (!mac) bind(\"Mod-y\", redo)\n\n bind(\"Alt-ArrowUp\", joinUp)\n bind(\"Alt-ArrowDown\", joinDown)\n bind(\"Mod-BracketLeft\", lift)\n bind(\"Escape\", selectParentNode)\n\n if (type = schema.marks[\"strong\"]) {\n bind(\"Mod-b\", toggleMark(type))\n bind(\"Mod-B\", toggleMark(type))\n }\n if (type = schema.marks[\"em\"]) {\n bind(\"Mod-i\", toggleMark(type))\n bind(\"Mod-I\", toggleMark(type))\n }\n if (type = schema.marks[\"code\"])\n bind(\"Mod-`\", toggleMark(type))\n\n if (type = schema.nodes[\"bullet_list\"])\n bind(\"Shift-Ctrl-8\", wrapInList(type))\n if (type = schema.nodes[\"ordered_list\"])\n bind(\"Shift-Ctrl-9\", wrapInList(type))\n if (type = schema.nodes[\"blockquote\"])\n bind(\"Ctrl->\", wrapIn(type))\n if (type = schema.nodes[\"hard_break\"]) {\n let br = type as any, cmd = chainCommands(exitCode, (state, dispatch) => {\n if (dispatch) dispatch(state.tr.replaceSelectionWith(br.create()).scrollIntoView())\n return true\n })\n bind(\"Mod-Enter\", cmd)\n bind(\"Shift-Enter\", cmd)\n if (mac) bind(\"Ctrl-Enter\", cmd)\n }\n if (type = schema.nodes[\"list_item\"]) {\n bind(\"Enter\", splitListItem(type))\n bind(\"Mod-[\", liftListItem(type))\n bind(\"Mod-]\", sinkListItem(type))\n }\n if (type = schema.nodes[\"paragraph\"])\n bind(\"Shift-Ctrl-0\", setBlockType(type))\n if (type = schema.nodes[\"code_block\"])\n bind(\"Shift-Ctrl-\\\\\", setBlockType(type))\n if (type = schema.nodes[\"heading\"])\n for (let i = 1; i <= 6; i++) bind(\"Shift-Ctrl-\" + i, setBlockType(type, {level: i}))\n if (type = schema.nodes[\"horizontal_rule\"]) {\n let hr = type as any\n bind(\"Mod-_\", (state, dispatch) => {\n if (dispatch) dispatch(state.tr.replaceSelectionWith(hr.create()).scrollIntoView())\n return true\n })\n }\n\n return keys\n}\n\n\nexport function openPrompt(options: {\n title: string,\n fields: {[name: string]: Field},\n callback: (attrs: Attrs) => void\n}) {\n let wrapper = document.body.appendChild(document.createElement(\"div\"))\n wrapper.className = prefix\n\n let mouseOutside = (e: MouseEvent) => { if (!wrapper.contains(e.target as HTMLElement)) close() }\n setTimeout(() => window.addEventListener(\"mousedown\", mouseOutside), 50)\n let close = () => {\n window.removeEventListener(\"mousedown\", mouseOutside)\n if (wrapper.parentNode) wrapper.parentNode.removeChild(wrapper)\n }\n\n let domFields: HTMLElement[] = []\n for (let name in options.fields) domFields.push(options.fields[name].render())\n\n let submitButton = document.createElement(\"button\")\n submitButton.type = \"submit\"\n submitButton.className = prefix + \"-submit\"\n submitButton.textContent = \"OK\"\n let cancelButton = document.createElement(\"button\")\n cancelButton.type = \"button\"\n cancelButton.className = prefix + \"-cancel\"\n cancelButton.textContent = \"Cancel\"\n cancelButton.addEventListener(\"click\", close)\n\n let form = wrapper.appendChild(document.createElement(\"form\"))\n if (options.title) form.appendChild(document.createElement(\"h5\")).textContent = options.title\n domFields.forEach(field => {\n form.appendChild(document.createElement(\"div\")).appendChild(field)\n })\n let buttons = form.appendChild(document.createElement(\"div\"))\n buttons.className = prefix + \"-buttons\"\n buttons.appendChild(submitButton)\n buttons.appendChild(document.createTextNode(\" \"))\n buttons.appendChild(cancelButton)\n\n let box = wrapper.getBoundingClientRect()\n wrapper.style.top = ((window.innerHeight - box.height) / 2) + \"px\"\n wrapper.style.left = ((window.innerWidth - box.width) / 2) + \"px\"\n\n let submit = () => {\n let params = getValues(options.fields, domFields)\n if (params) {\n close()\n options.callback(params)\n }\n }\n\n form.addEventListener(\"submit\", e => {\n e.preventDefault()\n submit()\n })\n\n form.addEventListener(\"keydown\", e => {\n if (e.keyCode == 27) {\n e.preventDefault()\n close()\n } else if (e.keyCode == 13 && !(e.ctrlKey || e.metaKey || e.shiftKey)) {\n e.preventDefault()\n submit()\n } else if (e.keyCode == 9) {\n window.setTimeout(() => {\n if (!wrapper.contains(document.activeElement)) close()\n }, 500)\n }\n })\n\n let input = form.elements[0] as HTMLElement\n if (input) input.focus()\n}\n\nfunction getValues(fields: {[name: string]: Field}, domFields: readonly HTMLElement[]) {\n let result = Object.create(null), i = 0\n for (let name in fields) {\n let field = fields[name], dom = domFields[i++]\n let value = field.read(dom), bad = field.validate(value)\n if (bad) {\n reportInvalid(dom, bad)\n return null\n }\n result[name] = field.clean(value)\n }\n return result\n}\n\nfunction reportInvalid(dom: HTMLElement, message: string) {\n // FIXME this is awful and needs a lot more work\n let parent = dom.parentNode!\n let msg = parent.appendChild(document.createElement(\"div\"))\n msg.style.left = (dom.offsetLeft + dom.offsetWidth + 2) + \"px\"\n msg.style.top = (dom.offsetTop - 5) + \"px\"\n msg.className = \"ProseMirror-invalid\"\n msg.textContent = message\n setTimeout(() => parent.removeChild(msg), 1500)\n}\n\n/// The type of field that `openPrompt` expects to be passed to it.\nexport abstract class Field {\n /// Create a field with the given options. Options support by all\n /// field types are:\n constructor(\n /// @internal\n readonly options: {\n /// The starting value for the field.\n value?: any\n\n /// The label for the field.\n label: string\n\n /// Whether the field is required.\n required?: boolean\n\n /// A function to validate the given value. Should return an\n /// error message if it is not valid.\n validate?: (value: any) => string | null\n\n /// A cleanup function for field values.\n clean?: (value: any) => any\n }\n ) {}\n\n /// Render the field to the DOM. Should be implemented by all subclasses.\n abstract render(): HTMLElement\n\n /// Read the field's value from its DOM node.\n read(dom: HTMLElement) { return (dom as any).value }\n\n /// A field-type-specific validation function.\n validateType(value: any): string | null { return null }\n\n /// @internal\n validate(value: any): string | null {\n if (!value && this.options.required)\n return \"Required field\"\n return this.validateType(value) || (this.options.validate ? this.options.validate(value) : null)\n }\n\n clean(value: any): any {\n return this.options.clean ? this.options.clean(value) : value\n }\n}\n\n/// A field class for single-line text fields.\nexport class TextField extends Field {\n render() {\n let input = document.createElement(\"input\")\n input.type = \"text\"\n input.placeholder = this.options.label\n input.value = this.options.value || \"\"\n input.autocomplete = \"off\"\n return input\n }\n}\n\n\n/// A field class for dropdown fields based on a plain `<select>`\n/// tag. Expects an option `options`, which should be an array of\n/// `{value: string, label: string}` objects, or a function taking a\n/// `ProseMirror` instance and returning such an array.\nexport class SelectField extends Field {\n render() {\n let select = document.createElement(\"select\")\n ;((this.options as any).options as {value: string, label: string}[]).forEach(o => {\n let opt = select.appendChild(document.createElement(\"option\"))\n opt.value = o.value\n opt.selected = o.value == this.options.value\n opt.label = o.label\n })\n return select\n }\n}\n\n// Helpers to create specific types of items\n\nexport function canInsert(state: EditorState, nodeType: NodeType) {\n let $from = state.selection.$from\n for (let d = $from.depth; d >= 0; d--) {\n let index = $from.index(d)\n if ($from.node(d).canReplaceWith(index, index, nodeType)) return true\n }\n return false\n}\n\nfunction insertImageItem(nodeType: NodeType) {\n return new MenuItem({\n title: \"Insert image\",\n label: \"Image\",\n enable(state) { return canInsert(state, nodeType) },\n run(state, _, view) {\n let {from, to} = state.selection, attrs = null\n if (state.selection instanceof NodeSelection && state.selection.node.type == nodeType)\n attrs = state.selection.node.attrs\n openPrompt({\n title: \"Insert image\",\n fields: {\n src: new TextField({label: \"Location\", required: true, value: attrs && attrs[\"src\"]}),\n title: new TextField({label: \"Title\", value: attrs && attrs[\"title\"]}),\n alt: new TextField({label: \"Description\",\n value: attrs ? attrs[\"alt\"] : state.doc.textBetween(from, to, \" \")})\n },\n callback(attrs) {\n view.dispatch(view.state.tr.replaceSelectionWith(nodeType.createAndFill(attrs)!))\n view.focus()\n }\n })\n }\n })\n}\n\nfunction cmdItem(cmd: Command, options: Partial<MenuItemSpec>) {\n let passedOptions: MenuItemSpec = {\n label: options.title as string | undefined,\n run: cmd\n }\n for (let prop in options) (passedOptions as any)[prop] = (options as any)[prop]\n if (!options.enable && !options.select)\n passedOptions[options.enable ? \"enable\" : \"select\"] = state => cmd(state)\n\n return new MenuItem(passedOptions)\n}\n\nexport function markActive(state: EditorState, type: MarkType) {\n let {from, $from, to, empty} = state.selection\n if (empty) return !!type.isInSet(state.storedMarks || $from.marks())\n else return state.doc.rangeHasMark(from, to, type)\n}\n\nfunction markItem(markType: MarkType, options: Partial<MenuItemSpec>) {\n let passedOptions: Partial<MenuItemSpec> = {\n active(state) { return markActive(state, markType) }\n }\n for (let prop in options) (passedOptions as any)[prop] = (options as any)[prop]\n return cmdItem(toggleMark(markType), passedOptions)\n}\n\nfunction linkItem(markType: MarkType) {\n return new MenuItem({\n title: \"Add or remove link\",\n icon: icons[\"link\"],\n active(state) { return markActive(state, markType) },\n enable(state) { return !state.selection.empty },\n run(state, dispatch, view) {\n if (markActive(state, markType)) {\n toggleMark(markType)(state, dispatch)\n return true\n }\n openPrompt({\n title: \"Create a link\",\n fields: {\n href: new TextField({\n label: \"Link target\",\n required: true\n }),\n title: new TextField({label: \"Title\"})\n },\n callback(attrs) {\n toggleMark(markType, attrs)(view.state, view.dispatch)\n view.focus()\n }\n })\n return true\n }\n })\n}\n\nfunction wrapListItem(nodeType: NodeType, options: Partial<MenuItemSpec>) {\n return cmdItem(wrapInList(nodeType, (options as any).attrs), options)\n}\n\ntype MenuItemResult = {\n /// A menu item to toggle the [strong mark](#schema-basic.StrongMark).\n toggleStrong?: MenuElement\n\n /// A menu item to toggle the [emphasis mark](#schema-basic.EmMark).\n toggleEm?: MenuElement\n\n /// A menu item to toggle the [code font mark](#schema-basic.CodeMark).\n toggleCode?: MenuElement\n\n /// A menu item to toggle the [link mark](#schema-basic.LinkMark).\n toggleLink?: MenuElement\n\n /// A menu item to insert an [image](#schema-basic.Image).\n insertImage?: MenuElement\n\n /// A menu item to wrap the selection in a [bullet list](#schema-list.BulletList).\n wrapBulletList?: MenuElement\n\n /// A menu item to wrap the selection in an [ordered list](#schema-list.OrderedList).\n wrapOrderedList?: MenuElement\n\n /// A menu item to wrap the selection in a [block quote](#schema-basic.BlockQuote).\n wrapBlockQuote?: MenuElement\n\n /// A menu item to set the current textblock to be a normal\n /// [paragraph](#schema-basic.Paragraph).\n makeParagraph?: MenuElement\n\n /// A menu item to set the current textblock to be a\n /// [code block](#schema-basic.CodeBlock).\n makeCodeBlock?: MenuElement\n\n /// Menu items to set the current textblock to be a\n /// [heading](#schema-basic.Heading) of level _N_.\n makeHead1?: MenuElement\n makeHead2?: MenuElement\n makeHead3?: MenuElement\n makeHead4?: MenuElement\n makeHead5?: MenuElement\n makeHead6?: MenuElement\n\n /// A menu item to insert a horizontal rule.\n insertHorizontalRule?: MenuElement\n\n /// A dropdown containing the `insertImage` and\n /// `insertHorizontalRule` items.\n insertMenu: Dropdown\n\n /// A dropdown containing the items for making the current\n /// textblock a paragraph, code block, or heading.\n typeMenu: Dropdown\n\n /// Array of block-related menu items.\n blockMenu: MenuElement[][]\n\n /// Inline-markup related menu items.\n inlineMenu: MenuElement[][]\n\n /// An array of arrays of menu elements for use as the full menu\n /// for, for example the [menu\n /// bar](https://code.haverbeke.berlin/prosemirror/prosemirror-menu).\n fullMenu: MenuElement[][]\n}\n\n/// Given a schema, look for default mark and node types in it and\n/// return an object with relevant menu items relating to those marks.\nexport function buildMenuItems(schema: Schema, override?:{[itemName:string]:MenuElement}): MenuItemResult {\n let r: MenuItemResult = {} as any\n let mark: MarkType | undefined;\n override=override||{};\n if (mark = schema.marks[\"strong\"])\n r.toggleStrong = override[\"strong\"]||markItem(mark, {title: \"Toggle strong style\", icon: icons[\"strong\"]})\n if (mark = schema.marks[\"em\"])\n r.toggleEm = override[\"em\"]|| markItem(mark, {title: \"Toggle emphasis\", icon: icons[\"em\"]})\n if (mark = schema.marks[\"code\"])\n r.toggleCode = override[\"code\"]||markItem(mark, {title: \"Toggle code font\", icon: icons[\"code\"]})\n if (mark = schema.marks[\"link\"])\n r.toggleLink = override[\"link\"]||linkItem(mark)\n\n let node: NodeType | undefined\n if (node = schema.nodes[\"image\"])\n r.insertImage = override[\"image\"]||insertImageItem(node)\n if (node = schema.nodes[\"bullet_list\"])\n r.wrapBulletList = override[\"bullet_list\"]||wrapListItem(node, {\n title: \"Wrap in bullet list\",\n icon: icons[\"bulletList\"]\n })\n if (node = schema.nodes[\"ordered_list\"])\n r.wrapOrderedList = override[\"ordered_list\"]||wrapListItem(node, {\n title: \"Wrap in ordered list\",\n icon: icons[\"orderedList\"]\n })\n if (node = schema.nodes[\"blockquote\"])\n r.wrapBlockQuote = override[\"blockquote\"]||wrapItem(node, {\n title: \"Wrap in block quote\",\n icon: icons[\"blockquote\"]\n })\n if (node = schema.nodes[\"paragraph\"])\n r.makeParagraph = override[\"paragraph\"]||blockTypeItem(node, {\n title: \"Change to paragraph\",\n label: \"Plain\"\n })\n if (node = schema.nodes[\"code_block\"])\n r.makeCodeBlock = override[\"code_block\"]||blockTypeItem(node, {\n title: \"Change to code block\",\n label: \"Code\"\n })\n if (node = schema.nodes[\"heading\"])\n for (let i = 1; i <= 10; i++)\n (r as any)[\"makeHead\" + i] = override[\"makeHead\"+i]||blockTypeItem(node, {\n title: \"Change to heading \" + i,\n label: \"Level \" + i,\n attrs: {level: i}\n })\n if (node = schema.nodes[\"horizontal_rule\"]) {\n let hr = node\n r.insertHorizontalRule = override[\"horizontal_rule\"]||new MenuItem({\n title: \"Insert horizontal rule\",\n label: \"Horizontal rule\",\n enable(state) { return canInsert(state, hr) },\n run(state, dispatch) { dispatch(state.tr.replaceSelectionWith(hr.create())) }\n })\n }\n\n let cut = <T>(arr: T[]) => arr.filter(x => x) as NonNullable<T>[]\n r.insertMenu = new Dropdown(cut([r.insertImage, r.insertHorizontalRule]), {label: \"Insert\"})\n r.typeMenu = new Dropdown(cut([r.makeParagraph, r.makeCodeBlock, r.makeHead1 && new DropdownSubmenu(cut([\n r.makeHead1, r.makeHead2, r.makeHead3, r.makeHead4, r.makeHead5, r.makeHead6\n ]), {label: \"Heading\"})]), {label: \"Type...\"})\n\n r.inlineMenu = [cut([r.toggleStrong, r.toggleEm, r.toggleCode, r.toggleLink])]\n r.blockMenu = [cut([r.wrapBulletList, r.wrapOrderedList, r.wrapBlockQuote, joinUpItem,\n liftItem, selectParentNodeItem])]\n r.fullMenu = r.inlineMenu.concat([[r.insertMenu, r.typeMenu]], [[undoItem, redoItem]], r.blockMenu)\n\n return r\n}\n\nexport function blockQuoteRule(nodeType: NodeType) {\n return wrappingInputRule(/^\\s*>\\s$/, nodeType)\n}\n\n/// Given a list node type, returns an input rule that turns a number\n/// followed by a dot at the start of a textblock into an ordered list.\nexport function orderedListRule(nodeType: NodeType) {\n return wrappingInputRule(/^(\\d+)\\.\\s$/, nodeType, match => ({order: +match[1]}),\n (match, node) => node.childCount + node.attrs[\"order\"] == +match[1])\n}\n\n/// Given a list node type, returns an input rule that turns a bullet\n/// (dash, plush, or asterisk) at the start of a textblock into a\n/// bullet list.\nexport function bulletListRule(nodeType: NodeType) {\n return wrappingInputRule(/^\\s*([-+*])\\s$/, nodeType)\n}\n\n/// Given a code block node type, returns an input rule that turns a\n/// textblock starting with three backticks into a code block.\nexport function codeBlockRule(nodeType: NodeType) {\n return textblockTypeInputRule(/^```$/, nodeType)\n}\n\n/// Given a node type and a maximum level, creates an input rule that\n/// turns up to that number of `#` characters followed by a space at\n/// the start of a textblock into a heading whose level corresponds to\n/// the number of `#` signs.\nexport function headingRule(nodeType: NodeType, maxLevel: number) {\n return textblockTypeInputRule(new RegExp(\"^(#{1,\" + maxLevel + \"})\\\\s$\"),\n nodeType, match => ({level: match[1].length}))\n}\n\n/// A set of input rules for creating the basic block quotes, lists,\n/// code blocks, and heading.\nexport function buildInputRules(schema: Schema) {\n let rules = smartQuotes.concat(ellipsis, emDash), type\n if (type = schema.nodes[\"blockquote\"]) rules.push(blockQuoteRule(type))\n if (type = schema.nodes[\"ordered_list\"]) rules.push(orderedListRule(type))\n if (type = schema.nodes[\"bullet_list\"]) rules.push(bulletListRule(type))\n if (type = schema.nodes[\"code_block\"]) rules.push(codeBlockRule(type))\n if (type = schema.nodes[\"heading\"]) rules.push(headingRule(type, 6))\n return inputRules({rules})\n}\n\n/// Create an array of plugins pre-configured for the given schema.\n/// The resulting array will include the following plugins:\n///\n/// * Input rules for smart quotes and creating the block types in the\n/// schema using markdown conventions (say `\"> \"` to create a\n/// blockquote)\n///\n/// * A keymap that defines keys to create and manipulate the nodes in the\n/// schema\n///\n/// * A keymap binding the default keys provided by the\n/// prosemirror-commands module\n///\n/// * The undo history plugin\n///\n/// * The drop cursor plugin\n///\n/// * The gap cursor plugin\n///\n/// * A custom plugin that adds a `menuContent` prop for the\n/// prosemirror-menu wrapper, and a CSS class that enables the\n/// additional styling defined in `style/style.css` in this package\n///\n/// Probably only useful for quickly setting up a passable\n/// editor—you'll need more control over your settings in most\n/// real-world situations.\nexport function basicSetup(options: {\n /// The schema to generate key bindings and menu items for.\n schema: Schema\n\n /// Can be used to [adjust](#example-setup.buildKeymap) the key bindings created.\n mapKeys?: {[key: string]: string | false}\n\n /// Set to false to disable the menu bar.\n menuBar?: boolean\n\n /// Set to false to disable the history plugin.\n history?: boolean\n\n /// Set to false to make the menu bar non-floating.\n floatingMenu?: boolean\n\n /// Can be used to override any menu content.\n menuContent?: { [itemName:string]:MenuElement }\n}) {\n let plugins = [\n buildInputRules(options.schema),\n keymap(buildKeymap(options.schema, options.mapKeys)),\n keymap(baseKeymap),\n dropCursor(),\n gapCursor()\n ]\n if (options.menuBar !== false)\n plugins.push(menuBar({floating: options.floatingMenu !== false,\n content: buildMenuItems(options.schema, options.menuContent).fullMenu}))\n if (options.history !== false)\n plugins.push(history())\n\n return plugins;/*.concat(new Plugin({\n props: {\n attributes: {class: \"ProseMirror-example-setup-style\"}\n }\n }))*/\n}\n\n","import { Pipe, PipeTransform, SecurityContext } from '@angular/core';\nimport { marked } from 'marked';\nimport { DomSanitizer } from '@angular/platform-browser';\n\n@Pipe({\n name: 'markdown',\n})\nexport class MarkdownPipe implements PipeTransform {\n constructor(protected sanitizer: DomSanitizer) {\n }\n transform(value: unknown, ...args: unknown[]): unknown {\n if( typeof value === 'string' ) {\n const html= marked.parse(value.replace(/^[\\u200B\\u200C\\u200D\\u200E\\u200F\\uFEFF]/,\"\"),\n {\n async:false\n });\n return this.sanitizer.sanitize(SecurityContext.HTML, html);\n }\n return null;\n }\n}\n","import { Pipe, PipeTransform } from '@angular/core';\n\n@Pipe({\n name: 'inlineMarkdown',\n})\nexport class InlineMarkdownPipe implements PipeTransform {\n transform(value: unknown, ...args: unknown[]): unknown {\n if( typeof value === 'string' ) {\n let text = value as string;\n if (text.length>100)\n text=text.substring(0,100); // For inline text, we don't want all the text, just the start\n text = text.replace(/!\\[[^\\]]*\\]\\([^)]*\\)/g, ''); // images\n text = text.replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1');// links -> visible text\n text = text.replace(/^#{1,6}\\s*/gm, ''); // headers\n text = text.replace(/^\\s*[-*+]\\s+/gm, ''); // bullet lists\n text = text.replace(/^\\s*\\d+[.)]\\s+/gm, ''); // numbered lists\n text = text.replace(/^\\s*[-*]\\s+/gm, ''); // bullets that were bold markers\n text = text.replace(/\\*\\*([^*]*)\\*\\*/g, '$1'); // bold\n text = text.replace(/\\*([^*]*)\\*/g, '$1'); // italic *\n text = text.replace(/(?<!\\w)_([^_\\n]+)_(?!\\w)/g, '$1'); // italic _text_\n text = text.replace(/\\s*\\n\\s*/g, ' '); // newlines -> spaces\n text = text.replace(/\\s{2,}/g, ' ').trim(); // collapse\n if (text.length>57) {\n return text.substring(0,57)+'...';\n }\n return text;\n }\n return null;\n }\n}\n","import {\n AfterViewInit,\n ChangeDetectionStrategy,\n Component,\n effect,\n ElementRef, inject,\n input,\n signal,\n viewChild\n} from '@angular/core';\nimport { updateFormGroupWithValue, XtContext, XtRenderComponent, XtResolverService, XtSimpleComponent } from 'xt-components';\nimport { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';\nimport { EditorState, NodeSelection, Transaction } from 'prosemirror-state';\nimport { EditorView } from 'prosemirror-view';\nimport { MarkType, Node, NodeType, Schema } from 'prosemirror-model';\nimport { defaultMarkdownParser, defaultMarkdownSerializer, schema } from 'prosemirror-markdown';\nimport { basicSetup, canInsert, markActive, openPrompt, TextField } from '../prose-mirror/basic-setup';\nimport { MarkdownPipe } from '../markdown/markdown-pipe';\nimport { InlineMarkdownPipe } from '../markdown/inline-markdown-pipe';\nimport { Tooltip } from 'primeng/tooltip';\nimport { Dialog } from 'primeng/dialog';\nimport { icons, MenuElement, MenuItem } from 'prosemirror-menu';\nimport { type } from '@ngrx/signals';\nimport { ButtonDirective } from 'primeng/button';\nimport { toggleMark } from 'prosemirror-commands';\n\n@Component({\n selector: 'xt-editor-editor',\n imports: [\n ReactiveFormsModule,\n FormsModule,\n MarkdownPipe, InlineMarkdownPipe, Tooltip, Dialog,\n XtRenderComponent, ButtonDirective\n ],\n templateUrl: './editor.component.html',\n styleUrl: './editor.component.css',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class EditorComponent extends XtSimpleComponent<any> implements AfterViewInit{\n override context = input.required<XtContext<any>>();\n\n protected resolver = inject(XtResolverService);\n\n protected editor = viewChild<ElementRef<HTMLDivElement>>('editor');\n\n protected sampleJson={ \"type\": \"doc\", \"content\": [ { \"type\": \"heading\", \"attrs\": { \"level\": 1 }, \"content\": [ { \"type\": \"text\", \"text\": \"Example Text\" } ] }, { \"type\": \"paragraph\", \"content\": [ { \"type\": \"text\", \"text\": \"s it working ?\" } ] } ] };\n protected emptyJson={ \"type\": \"doc\", \"content\": [ { \"type\": \"paragraph\"} ] };\n// Mix the nodes from prosemirror-schema-list into the basic schema to create a schema with list support.\n /** mySchema: Schema = new Schema({\n nodes: addListNodes(schema.spec.nodes, \"paragraph block*\", \"block\"),\n marks: schema.spec.marks\n });*/\n // Creates the markdown schema\n mySchema = schema;\n\n protected view: EditorView|null=null;\n\n /**\n * Enable dialog box for image or link editing\n * @protected\n */\n protected displayAttrDialog = signal<boolean>(false);\n protected editAttrForm = new FormGroup({});\n protected editAttrNodeType:NodeType|MarkType=(this.mySchema as any)['image'];\n protected editAttrValueType: string = \"editorImageType\";\n\n constructor() {\n super();\n const imageType=this.resolver.typeResolver.findType('image');\n const linkType=this.resolver.typeResolver.findType('link');\n // Register the type with the image type if supported\n this.resolver.registerTypes({\n editorImageType: {\n children: {\n src: (imageType==null)?\"string\":\"image\",\n title: \"string\",\n alt: \"string\"\n }\n },\n editorLinkType: {\n children: {\n href: (linkType==null)?\"string\":\"link\",\n title: \"string\"\n }\n }\n });\n\n updateFormGroupWithValue (this.editAttrForm, {}, 'editorImageType', this.resolver.typeResolver);\n\n // Setup the editor once the divs are available\n effect(() => {\n const editor=this.editor();\n if( (editor!=null) && (this.view==null)) {\n const value=this.context().formControlValue();\n\n const doc = this.toProseMirrorDoc (value);\n this.view = new EditorView(editor.nativeElement, {\n state: EditorState.create({\n doc: doc,\n plugins: basicSetup({schema: this.mySchema, menuContent: {\n image: this.imageMenu(this.mySchema.nodes['image'], this),\n link: this.linkMenu (this.mySchema.marks['link'], this)\n }})\n }),\n dispatchTransaction: this.handleTransactions.bind(this)\n })\n }\n\n })\n }\n\n ngAfterViewInit() {\n /* this.editor.valueChanges.pipe(takeUntil(this.unsubscribe)).subscribe((jsonDoc) => {\n this.handleChange(jsonDoc);\n });*/\n }\n\n protected imageMenu(imageNodeType:NodeType, that: EditorComponent):MenuElement {\n return new MenuItem({\n title: \"Insert image\",\n label: \"Image\",\n enable(state) {\n return canInsert(state, imageNodeType)\n },\n run(state, _, view) {\n let { from, to } = state.selection, attrs: {src?:string, title?:string, alt?:string} = { };\n if (state.selection instanceof NodeSelection && state.selection.node.type == imageNodeType)\n attrs = state.selection.node.attrs||{};\n if (attrs.alt==null)\n attrs.alt= state.doc.textBetween(from, to, \" \");\n that.editAttrValueType=\"editorImageType\";\n updateFormGroupWithValue(that.editAttrForm, attrs, that.editAttrValueType, that.resolver.typeResolver);\n that.editAttrNodeType=imageNodeType;\n that.displayAttrDialog.set(true);\n }\n });\n }\n\n protected updateAttrsFromForm() {\n if (this.view != null) {\n if (this.editAttrValueType == \"editorImageType\"){\n this.view.dispatch(this.view.state.tr.replaceSelectionWith((this.mySchema.nodes['image']).createAndFill(this.editAttrForm.value)!))\n } else if (this.editAttrValueType == \"editorLinkType\"){\n toggleMark(this.editAttrNodeType as MarkType, this.editAttrForm.value)(this.view.state, this.view.dispatch)\n }\n this.view.focus()\n }\n this.displayAttrDialog.set(false);\n }\n\n protected linkMenu(linkMarkType:MarkType, that: EditorComponent):MenuElement {\n return new MenuItem({\n title: \"Add or Remove link\",\n icon: icons[\"link\"],\n active(state) { return markActive(state, linkMarkType) },\n enable(state) { return !state.selection.empty },\n run(state, _, view) {\n let { from, to } = state.selection, attrs: {href?:string, title?:string} = { };\n if (markActive(state, linkMarkType)) {\n toggleMark(linkMarkType)(state, view.dispatch)\n return true\n }\n that.editAttrValueType=\"editorLinkType\";\n updateFormGroupWithValue(that.editAttrForm, attrs, that.editAttrValueType, that.resolver.typeResolver);\n that.editAttrNodeType=linkMarkType;\n that.displayAttrDialog.set(true);\n return true;\n }\n });\n }\n\n protected handleTransactions(tr: Transaction): void {\n if (this.view!=null) {\n const state = this.view.state.apply(tr);\n this.view.updateState(state);\n\n if (tr.docChanged) {\n const markdown = defaultMarkdownSerializer.serialize(state.doc);\n this.context().setFormValue(markdown, true);\n }\n } else {\n console.error(\"Editor: View transaction received while no view defined.\",tr.doc.toJSON());\n }\n }\n\n\n private toProseMirrorDoc(value: any): Node {\n if (value == null) {\n return this.mySchema.nodeFromJSON ( this.emptyJson);\n }\n if (typeof value === 'string') {\n // This is a markdown text,\n return defaultMarkdownParser.parse(value);\n }\n return this.mySchema.nodeFromJSON (value);\n }\n\n protected textJson (text:string){\n return { \"type\": \"doc\", \"content\": [ { \"type\": \"paragraph\", \"content\": [ { \"type\": \"text\", \"text\": text } ] } ] }\n };\n\n}\n","@if (isInForm() ) {\n <div class=\"editorContainer\">\n <div #editor [formGroup]=\"formGroup()\">\n </div>\n </div>\n <p-dialog [visible]=\"displayAttrDialog()\" [modal]=\"true\" header=\"Edit\">\n <form [formGroup]=\"editAttrForm\">\n <xt-render [valueType]=\"editAttrValueType\" [formGroup]=\"editAttrForm\" displayMode=\"FULL_EDITABLE\" ></xt-render>\n </form>\n <ng-template #footer>\n <button type=\"button\" pButton severity=\"secondary\" variant=\"outlined\" (click)=\"displayAttrDialog.set(false)\">Cancel</button>\n <button type=\"button\" pButton (click)=\"updateAttrsFromForm()\">Save</button>\n </ng-template>\n </p-dialog>\n} @else {\n @let toDisplay=displayValue();\n @if (toDisplay!=null) {\n @if (context().displayMode=='FULL_VIEW') {\n <div class=\"displayForm\" [innerHTML]=\"displayValue() | markdown\">\n </div>\n } @else {\n <span [pTooltip]=\"fullText\">{{ toDisplay | inlineMarkdown}}</span>\n <ng-template #fullText>\n <div class=\"toolTip\" [innerHTML]=\"displayValue() | markdown\">\n </div>\n </ng-template>\n }\n }\n}\n","import { XtResolverService } from 'xt-components';\nimport { EditorComponent } from './editor/editor.component';\n\nexport function registerEditorPlugin (resolverService:XtResolverService):string {\n const pluginName = \"Plugin Editor\";\n console.info ('Registering ' +pluginName);\n resolverService.registerPlugin ({\n name:pluginName,\n uriLogo:'pluginicon.png',\n cssUrls: [\n 'prosemirror-view/style/prosemirror.css',\n 'prosemirror-menu/style/menu.css',\n 'prosemirror-gapcursor/style/gapcursor.css'\n ],\n components: [\n {\n componentName:'Editor',\n componentClass:EditorComponent,\n typesHandled: ['markdown','rich-text','description'],\n }\n ],\n types: {\n 'markdown':'string',\n 'rich-text':'string',\n 'description':'string'\n }\n });\n return pluginName;\n}\n\nexport function registerPlugin (resolverService:XtResolverService):string {\n return registerEditorPlugin(resolverService);\n}\n","/*\n * Public API Surface of web plugin\n */\n\nexport * from './lib/editor/editor.component';\nexport * from './lib/register';\nexport * from './lib/markdown/markdown-pipe'\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAGA;AACA;AAWA,MAAM,MAAM,GAAG,oBAAoB;AAoBnC,MAAM,GAAG,GAAG,OAAO,SAAS,IAAI,WAAW,GAAG,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,KAAK;AAEnG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACM,SAAU,WAAW,CAAC,MAAc,EAAE,OAAyC,EAAA;AACnF,IAAA,IAAI,IAAI,GAA6B,EAAE,EAAE,IAAI;AAC7C,IAAA,SAAS,IAAI,CAAC,GAAW,EAAE,GAAY,EAAA;QACrC,IAAI,OAAO,EAAE;AACX,YAAA,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;YACzB,IAAI,MAAM,KAAK,KAAK;gBAAE;AACtB,YAAA,IAAI,MAAM;gBAAE,GAAG,GAAG,MAAM;QAC1B;AACA,QAAA,IAAI,CAAC,GAAG,C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AE,eAAiC,EAAA;AAC/D,IAAA,OAAO,oBAAoB,CAAC,eAAe,CAAC;AAC9C;;AChCA;;AAEG;;ACFH;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,55 @@
1
1
  {
2
2
  "name": "xt-plugin-editor",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.3.0",
4
+ "repository": {
5
+ "url": "https://github.com/dont-code/ng-xtend.git"
6
+ },
7
+ "peerDependencies": {
8
+ "@angular/animations": "^21.0.0",
9
+ "@angular/common": "^21.0.0",
10
+ "@angular/compiler": "^21.0.0",
11
+ "@angular/core": "^21.0.0",
12
+ "@angular/forms": "^21.0.0",
13
+ "@angular/platform-browser": "^21.0.0",
14
+ "@angular/platform-browser-dynamic": "^21.0.0",
15
+ "@angular/router": "^21.0.0",
16
+ "xt-components": "^1.0.0",
17
+ "rxjs": "^7.8.2",
18
+ "primeng": "^21.0.0",
19
+ "primeicons": "^7.0.0",
20
+ "prosemirror-model": "^1.25.11",
21
+ "prosemirror-transform": "^1.12.0",
22
+ "prosemirror-state": "^1.4.4",
23
+ "prosemirror-view": "^1.42.2",
24
+ "prosemirror-keymap": "^1.2.3",
25
+ "prosemirror-commands": "^1.0.0",
26
+ "prosemirror-schema-basic": "^1.2.4",
27
+ "prosemirror-markdown": "^1.13.5",
28
+ "prosemirror-schema-list": "^1.5.1",
29
+ "prosemirror-menu": "^1.3.2",
30
+ "prosemirror-history": "^1.5.0",
31
+ "prosemirror-inputrules": "^1.5.1",
32
+ "prosemirror-dropcursor": "^1.8.3",
33
+ "prosemirror-gapcursor": "^1.4.1",
34
+ "prosemirror-history-v2": "^1.1.3",
35
+ "markdown-it": "^15.0.2",
36
+ "crelt": "~1.0.7",
37
+ "marked": "~18.0.13"
38
+ },
39
+ "dependencies": {
40
+ "tslib": "^2.8.1"
41
+ },
42
+ "sideEffects": false,
43
+ "module": "fesm2022/xt-plugin-editor.mjs",
44
+ "typings": "types/xt-plugin-editor.d.ts",
45
+ "exports": {
46
+ "./package.json": {
47
+ "default": "./package.json"
48
+ },
49
+ ".": {
50
+ "types": "./types/xt-plugin-editor.d.ts",
51
+ "default": "./fesm2022/xt-plugin-editor.mjs"
52
+ }
53
+ },
54
+ "type": "module"
6
55
  }
@@ -0,0 +1,87 @@
1
+ import * as i0 from '@angular/core';
2
+ import { AfterViewInit, ElementRef, PipeTransform } from '@angular/core';
3
+ import { XtSimpleComponent, XtContext, XtResolverService } from 'xt-components';
4
+ import { FormGroup } from '@angular/forms';
5
+ import { Transaction } from 'prosemirror-state';
6
+ import { EditorView } from 'prosemirror-view';
7
+ import { Schema, NodeType, MarkType } from 'prosemirror-model';
8
+ import { MenuElement } from 'prosemirror-menu';
9
+ import { DomSanitizer } from '@angular/platform-browser';
10
+
11
+ declare class EditorComponent extends XtSimpleComponent<any> implements AfterViewInit {
12
+ context: i0.InputSignal<XtContext<any>>;
13
+ protected resolver: XtResolverService;
14
+ protected editor: i0.Signal<ElementRef<HTMLDivElement> | undefined>;
15
+ protected sampleJson: {
16
+ type: string;
17
+ content: ({
18
+ type: string;
19
+ attrs: {
20
+ level: number;
21
+ };
22
+ content: {
23
+ type: string;
24
+ text: string;
25
+ }[];
26
+ } | {
27
+ type: string;
28
+ content: {
29
+ type: string;
30
+ text: string;
31
+ }[];
32
+ attrs?: undefined;
33
+ })[];
34
+ };
35
+ protected emptyJson: {
36
+ type: string;
37
+ content: {
38
+ type: string;
39
+ }[];
40
+ };
41
+ /** mySchema: Schema = new Schema({
42
+ nodes: addListNodes(schema.spec.nodes, "paragraph block*", "block"),
43
+ marks: schema.spec.marks
44
+ });*/
45
+ mySchema: Schema<"bullet_list" | "ordered_list" | "blockquote" | "hard_break" | "list_item" | "paragraph" | "code_block" | "heading" | "horizontal_rule" | "text" | "image" | "doc", "strong" | "em" | "code" | "link">;
46
+ protected view: EditorView | null;
47
+ /**
48
+ * Enable dialog box for image or link editing
49
+ * @protected
50
+ */
51
+ protected displayAttrDialog: i0.WritableSignal<boolean>;
52
+ protected editAttrForm: FormGroup<{}>;
53
+ protected editAttrNodeType: NodeType | MarkType;
54
+ protected editAttrValueType: string;
55
+ constructor();
56
+ ngAfterViewInit(): void;
57
+ protected imageMenu(imageNodeType: NodeType, that: EditorComponent): MenuElement;
58
+ protected updateAttrsFromForm(): void;
59
+ protected linkMenu(linkMarkType: MarkType, that: EditorComponent): MenuElement;
60
+ protected handleTransactions(tr: Transaction): void;
61
+ private toProseMirrorDoc;
62
+ protected textJson(text: string): {
63
+ type: string;
64
+ content: {
65
+ type: string;
66
+ content: {
67
+ type: string;
68
+ text: string;
69
+ }[];
70
+ }[];
71
+ };
72
+ static ɵfac: i0.ɵɵFactoryDeclaration<EditorComponent, never>;
73
+ static ɵcmp: i0.ɵɵComponentDeclaration<EditorComponent, "xt-editor-editor", never, { "context": { "alias": "context"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
74
+ }
75
+
76
+ declare function registerEditorPlugin(resolverService: XtResolverService): string;
77
+ declare function registerPlugin(resolverService: XtResolverService): string;
78
+
79
+ declare class MarkdownPipe implements PipeTransform {
80
+ protected sanitizer: DomSanitizer;
81
+ constructor(sanitizer: DomSanitizer);
82
+ transform(value: unknown, ...args: unknown[]): unknown;
83
+ static ɵfac: i0.ɵɵFactoryDeclaration<MarkdownPipe, never>;
84
+ static ɵpipe: i0.ɵɵPipeDeclaration<MarkdownPipe, "markdown", true>;
85
+ }
86
+
87
+ export { EditorComponent, MarkdownPipe, registerEditorPlugin, registerPlugin };