@flogeez/angular-tiptap-editor 3.1.5 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/esm2022/lib/components/bubble-menus/base/ate-base-bubble-menu.mjs +1 -1
- package/esm2022/lib/components/bubble-menus/base/ate-base-sub-bubble-menu.mjs +1 -1
- package/esm2022/lib/components/bubble-menus/link/ate-link-bubble-menu.component.mjs +1 -1
- package/esm2022/lib/components/editor/angular-tiptap-editor.component.mjs +40 -3
- package/esm2022/lib/components/slash-commands/ate-slash-commands.component.mjs +1 -1
- package/esm2022/lib/models/ate-editor-ref.mjs +319 -0
- package/esm2022/lib/services/ate-editor-commands.service.mjs +4 -1
- package/esm2022/lib/services/ate-editor-registry.service.mjs +94 -0
- package/esm2022/lib/services/ate-image.service.mjs +4 -1
- package/esm2022/lib/utils/ate-markdown.utils.mjs +2 -4
- package/esm2022/public-api.mjs +3 -1
- package/fesm2022/flogeez-angular-tiptap-editor.mjs +456 -6
- package/fesm2022/flogeez-angular-tiptap-editor.mjs.map +1 -1
- package/lib/components/editor/angular-tiptap-editor.component.d.ts +11 -2
- package/lib/models/ate-editor-ref.d.ts +73 -0
- package/lib/services/ate-editor-commands.service.d.ts +2 -1
- package/lib/services/ate-editor-registry.service.d.ts +36 -0
- package/lib/services/ate-image.service.d.ts +1 -0
- package/package.json +1 -1
- package/public-api.d.ts +2 -0
|
@@ -1660,6 +1660,9 @@ class AteImageService {
|
|
|
1660
1660
|
this.forceEditorUpdate();
|
|
1661
1661
|
// Final insertion
|
|
1662
1662
|
insertionStrategy(editor, result);
|
|
1663
|
+
if (this.onImageUploadedCallback) {
|
|
1664
|
+
this.onImageUploadedCallback(result);
|
|
1665
|
+
}
|
|
1663
1666
|
this.resetUploadState();
|
|
1664
1667
|
}
|
|
1665
1668
|
catch (error) {
|
|
@@ -2219,9 +2222,7 @@ function convertNode(node, ctx) {
|
|
|
2219
2222
|
if (tag === "pre") {
|
|
2220
2223
|
// Extract language from code class e.g. "language-typescript"
|
|
2221
2224
|
const codeEl = el.querySelector("code");
|
|
2222
|
-
const lang = codeEl
|
|
2223
|
-
? (codeEl.className.match(/language-(\S+)/) || [])[1] || ""
|
|
2224
|
-
: "";
|
|
2225
|
+
const lang = codeEl ? (codeEl.className.match(/language-(\S+)/) || [])[1] || "" : "";
|
|
2225
2226
|
const code = codeEl ? codeEl.textContent || "" : el.textContent || "";
|
|
2226
2227
|
return `\n\n\`\`\`${lang}\n${code}\n\`\`\`\n\n`;
|
|
2227
2228
|
}
|
|
@@ -2492,6 +2493,9 @@ class AteEditorCommandsService {
|
|
|
2492
2493
|
setToolbarInteracting(value) {
|
|
2493
2494
|
this._isToolbarInteracting.set(value);
|
|
2494
2495
|
}
|
|
2496
|
+
set onImageUploaded(callback) {
|
|
2497
|
+
this.imageService.onImageUploadedCallback = callback || undefined;
|
|
2498
|
+
}
|
|
2495
2499
|
set uploadHandler(handler) {
|
|
2496
2500
|
this.imageService.uploadHandler = handler;
|
|
2497
2501
|
}
|
|
@@ -6360,6 +6364,416 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
6360
6364
|
`, styles: [".ate-edit-toggle-container{position:absolute;margin-top:16px;right:16px;z-index:50}\n"] }]
|
|
6361
6365
|
}] });
|
|
6362
6366
|
|
|
6367
|
+
/**
|
|
6368
|
+
* A wrapper class that holds a reference to a registered editor component.
|
|
6369
|
+
* It provides direct, type-safe facade methods to interact with the editor
|
|
6370
|
+
* and execute formatting/utility commands without needing to manage the raw
|
|
6371
|
+
* TipTap editor instance directly.
|
|
6372
|
+
*/
|
|
6373
|
+
class AteEditorRef {
|
|
6374
|
+
constructor(id, getEditorInstance, commandsService) {
|
|
6375
|
+
this.id = id;
|
|
6376
|
+
this.getEditorInstance = getEditorInstance;
|
|
6377
|
+
this.commandsService = commandsService;
|
|
6378
|
+
}
|
|
6379
|
+
/** Get the raw TipTap Editor instance. */
|
|
6380
|
+
get editor() {
|
|
6381
|
+
return this.getEditorInstance();
|
|
6382
|
+
}
|
|
6383
|
+
/** Get the current editor state snapshot. */
|
|
6384
|
+
get state() {
|
|
6385
|
+
return this.commandsService.editorState();
|
|
6386
|
+
}
|
|
6387
|
+
/** Get the reactive editor state as a Signal. */
|
|
6388
|
+
get stateSignal() {
|
|
6389
|
+
return this.commandsService.editorState;
|
|
6390
|
+
}
|
|
6391
|
+
/** Execute a generic command by name. */
|
|
6392
|
+
execute(command, ...args) {
|
|
6393
|
+
const editor = this.editor;
|
|
6394
|
+
if (editor) {
|
|
6395
|
+
this.commandsService.execute(editor, command, ...args);
|
|
6396
|
+
}
|
|
6397
|
+
}
|
|
6398
|
+
// ============================================
|
|
6399
|
+
// Facade Formatting Commands
|
|
6400
|
+
// ============================================
|
|
6401
|
+
toggleBold() {
|
|
6402
|
+
const editor = this.editor;
|
|
6403
|
+
if (editor) {
|
|
6404
|
+
this.commandsService.toggleBold(editor);
|
|
6405
|
+
}
|
|
6406
|
+
}
|
|
6407
|
+
toggleItalic() {
|
|
6408
|
+
const editor = this.editor;
|
|
6409
|
+
if (editor) {
|
|
6410
|
+
this.commandsService.toggleItalic(editor);
|
|
6411
|
+
}
|
|
6412
|
+
}
|
|
6413
|
+
toggleStrike() {
|
|
6414
|
+
const editor = this.editor;
|
|
6415
|
+
if (editor) {
|
|
6416
|
+
this.commandsService.toggleStrike(editor);
|
|
6417
|
+
}
|
|
6418
|
+
}
|
|
6419
|
+
toggleCode() {
|
|
6420
|
+
const editor = this.editor;
|
|
6421
|
+
if (editor) {
|
|
6422
|
+
this.commandsService.toggleCode(editor);
|
|
6423
|
+
}
|
|
6424
|
+
}
|
|
6425
|
+
toggleCodeBlock() {
|
|
6426
|
+
const editor = this.editor;
|
|
6427
|
+
if (editor) {
|
|
6428
|
+
this.commandsService.toggleCodeBlock(editor);
|
|
6429
|
+
}
|
|
6430
|
+
}
|
|
6431
|
+
toggleUnderline() {
|
|
6432
|
+
const editor = this.editor;
|
|
6433
|
+
if (editor) {
|
|
6434
|
+
this.commandsService.toggleUnderline(editor);
|
|
6435
|
+
}
|
|
6436
|
+
}
|
|
6437
|
+
toggleSuperscript() {
|
|
6438
|
+
const editor = this.editor;
|
|
6439
|
+
if (editor) {
|
|
6440
|
+
this.commandsService.toggleSuperscript(editor);
|
|
6441
|
+
}
|
|
6442
|
+
}
|
|
6443
|
+
toggleSubscript() {
|
|
6444
|
+
const editor = this.editor;
|
|
6445
|
+
if (editor) {
|
|
6446
|
+
this.commandsService.toggleSubscript(editor);
|
|
6447
|
+
}
|
|
6448
|
+
}
|
|
6449
|
+
toggleHeading(level) {
|
|
6450
|
+
const editor = this.editor;
|
|
6451
|
+
if (editor) {
|
|
6452
|
+
this.commandsService.toggleHeading(editor, level);
|
|
6453
|
+
}
|
|
6454
|
+
}
|
|
6455
|
+
toggleBulletList() {
|
|
6456
|
+
const editor = this.editor;
|
|
6457
|
+
if (editor) {
|
|
6458
|
+
this.commandsService.toggleBulletList(editor);
|
|
6459
|
+
}
|
|
6460
|
+
}
|
|
6461
|
+
toggleOrderedList() {
|
|
6462
|
+
const editor = this.editor;
|
|
6463
|
+
if (editor) {
|
|
6464
|
+
this.commandsService.toggleOrderedList(editor);
|
|
6465
|
+
}
|
|
6466
|
+
}
|
|
6467
|
+
toggleBlockquote() {
|
|
6468
|
+
const editor = this.editor;
|
|
6469
|
+
if (editor) {
|
|
6470
|
+
this.commandsService.toggleBlockquote(editor);
|
|
6471
|
+
}
|
|
6472
|
+
}
|
|
6473
|
+
setTextAlign(alignment) {
|
|
6474
|
+
const editor = this.editor;
|
|
6475
|
+
if (editor) {
|
|
6476
|
+
this.commandsService.setTextAlign(editor, alignment);
|
|
6477
|
+
}
|
|
6478
|
+
}
|
|
6479
|
+
insertHorizontalRule() {
|
|
6480
|
+
const editor = this.editor;
|
|
6481
|
+
if (editor) {
|
|
6482
|
+
this.commandsService.insertHorizontalRule(editor);
|
|
6483
|
+
}
|
|
6484
|
+
}
|
|
6485
|
+
insertImage(options) {
|
|
6486
|
+
const editor = this.editor;
|
|
6487
|
+
if (editor) {
|
|
6488
|
+
this.commandsService.insertImage(editor, options);
|
|
6489
|
+
}
|
|
6490
|
+
}
|
|
6491
|
+
uploadImage(file, options) {
|
|
6492
|
+
const editor = this.editor;
|
|
6493
|
+
if (editor) {
|
|
6494
|
+
this.commandsService.uploadImage(editor, file, options);
|
|
6495
|
+
}
|
|
6496
|
+
}
|
|
6497
|
+
toggleHighlight(color) {
|
|
6498
|
+
const editor = this.editor;
|
|
6499
|
+
if (editor) {
|
|
6500
|
+
this.commandsService.toggleHighlight(editor, color);
|
|
6501
|
+
}
|
|
6502
|
+
}
|
|
6503
|
+
undo() {
|
|
6504
|
+
const editor = this.editor;
|
|
6505
|
+
if (editor) {
|
|
6506
|
+
this.commandsService.undo(editor);
|
|
6507
|
+
}
|
|
6508
|
+
}
|
|
6509
|
+
redo() {
|
|
6510
|
+
const editor = this.editor;
|
|
6511
|
+
if (editor) {
|
|
6512
|
+
this.commandsService.redo(editor);
|
|
6513
|
+
}
|
|
6514
|
+
}
|
|
6515
|
+
// ============================================
|
|
6516
|
+
// Table Commands
|
|
6517
|
+
// ============================================
|
|
6518
|
+
insertTable(rows, cols) {
|
|
6519
|
+
const editor = this.editor;
|
|
6520
|
+
if (editor) {
|
|
6521
|
+
this.commandsService.insertTable(editor, rows, cols);
|
|
6522
|
+
}
|
|
6523
|
+
}
|
|
6524
|
+
addColumnBefore() {
|
|
6525
|
+
const editor = this.editor;
|
|
6526
|
+
if (editor) {
|
|
6527
|
+
this.commandsService.addColumnBefore(editor);
|
|
6528
|
+
}
|
|
6529
|
+
}
|
|
6530
|
+
addColumnAfter() {
|
|
6531
|
+
const editor = this.editor;
|
|
6532
|
+
if (editor) {
|
|
6533
|
+
this.commandsService.addColumnAfter(editor);
|
|
6534
|
+
}
|
|
6535
|
+
}
|
|
6536
|
+
deleteColumn() {
|
|
6537
|
+
const editor = this.editor;
|
|
6538
|
+
if (editor) {
|
|
6539
|
+
this.commandsService.deleteColumn(editor);
|
|
6540
|
+
}
|
|
6541
|
+
}
|
|
6542
|
+
addRowBefore() {
|
|
6543
|
+
const editor = this.editor;
|
|
6544
|
+
if (editor) {
|
|
6545
|
+
this.commandsService.addRowBefore(editor);
|
|
6546
|
+
}
|
|
6547
|
+
}
|
|
6548
|
+
addRowAfter() {
|
|
6549
|
+
const editor = this.editor;
|
|
6550
|
+
if (editor) {
|
|
6551
|
+
this.commandsService.addRowAfter(editor);
|
|
6552
|
+
}
|
|
6553
|
+
}
|
|
6554
|
+
deleteRow() {
|
|
6555
|
+
const editor = this.editor;
|
|
6556
|
+
if (editor) {
|
|
6557
|
+
this.commandsService.deleteRow(editor);
|
|
6558
|
+
}
|
|
6559
|
+
}
|
|
6560
|
+
deleteTable() {
|
|
6561
|
+
const editor = this.editor;
|
|
6562
|
+
if (editor) {
|
|
6563
|
+
this.commandsService.deleteTable(editor);
|
|
6564
|
+
}
|
|
6565
|
+
}
|
|
6566
|
+
mergeCells() {
|
|
6567
|
+
const editor = this.editor;
|
|
6568
|
+
if (editor) {
|
|
6569
|
+
this.commandsService.mergeCells(editor);
|
|
6570
|
+
}
|
|
6571
|
+
}
|
|
6572
|
+
splitCell() {
|
|
6573
|
+
const editor = this.editor;
|
|
6574
|
+
if (editor) {
|
|
6575
|
+
this.commandsService.splitCell(editor);
|
|
6576
|
+
}
|
|
6577
|
+
}
|
|
6578
|
+
toggleHeaderColumn() {
|
|
6579
|
+
const editor = this.editor;
|
|
6580
|
+
if (editor) {
|
|
6581
|
+
this.commandsService.toggleHeaderColumn(editor);
|
|
6582
|
+
}
|
|
6583
|
+
}
|
|
6584
|
+
toggleHeaderRow() {
|
|
6585
|
+
const editor = this.editor;
|
|
6586
|
+
if (editor) {
|
|
6587
|
+
this.commandsService.toggleHeaderRow(editor);
|
|
6588
|
+
}
|
|
6589
|
+
}
|
|
6590
|
+
// ============================================
|
|
6591
|
+
// Color Picker & Link Commands
|
|
6592
|
+
// ============================================
|
|
6593
|
+
applyColor(color, selectionOnly, closeMenu) {
|
|
6594
|
+
const editor = this.editor;
|
|
6595
|
+
if (editor) {
|
|
6596
|
+
this.commandsService.execute(editor, "applyColor", color, selectionOnly, closeMenu);
|
|
6597
|
+
}
|
|
6598
|
+
}
|
|
6599
|
+
applyHighlight(color, selectionOnly, closeMenu) {
|
|
6600
|
+
const editor = this.editor;
|
|
6601
|
+
if (editor) {
|
|
6602
|
+
this.commandsService.execute(editor, "applyHighlight", color, selectionOnly, closeMenu);
|
|
6603
|
+
}
|
|
6604
|
+
}
|
|
6605
|
+
unsetColor(selectionOnly) {
|
|
6606
|
+
const editor = this.editor;
|
|
6607
|
+
if (editor) {
|
|
6608
|
+
this.commandsService.execute(editor, "unsetColor", selectionOnly);
|
|
6609
|
+
}
|
|
6610
|
+
}
|
|
6611
|
+
unsetHighlight(selectionOnly) {
|
|
6612
|
+
const editor = this.editor;
|
|
6613
|
+
if (editor) {
|
|
6614
|
+
this.commandsService.execute(editor, "unsetHighlight", selectionOnly);
|
|
6615
|
+
}
|
|
6616
|
+
}
|
|
6617
|
+
toggleLink(event) {
|
|
6618
|
+
const editor = this.editor;
|
|
6619
|
+
if (editor) {
|
|
6620
|
+
this.commandsService.execute(editor, "toggleLink", event);
|
|
6621
|
+
}
|
|
6622
|
+
}
|
|
6623
|
+
unsetLink() {
|
|
6624
|
+
const editor = this.editor;
|
|
6625
|
+
if (editor) {
|
|
6626
|
+
this.commandsService.execute(editor, "unsetLink");
|
|
6627
|
+
}
|
|
6628
|
+
}
|
|
6629
|
+
toggleColorPicker(mode, event) {
|
|
6630
|
+
const editor = this.editor;
|
|
6631
|
+
if (editor) {
|
|
6632
|
+
this.commandsService.execute(editor, "toggleColorPicker", mode, event);
|
|
6633
|
+
}
|
|
6634
|
+
}
|
|
6635
|
+
// ============================================
|
|
6636
|
+
// General Controls & Content
|
|
6637
|
+
// ============================================
|
|
6638
|
+
clearContent() {
|
|
6639
|
+
const editor = this.editor;
|
|
6640
|
+
if (editor) {
|
|
6641
|
+
this.commandsService.clearContent(editor);
|
|
6642
|
+
}
|
|
6643
|
+
}
|
|
6644
|
+
setContent(content, emitUpdate = true) {
|
|
6645
|
+
const editor = this.editor;
|
|
6646
|
+
if (editor) {
|
|
6647
|
+
this.commandsService.setContent(editor, content, emitUpdate);
|
|
6648
|
+
}
|
|
6649
|
+
}
|
|
6650
|
+
getContent(format) {
|
|
6651
|
+
const editor = this.editor;
|
|
6652
|
+
return editor ? this.commandsService.getContent(editor, format) : "";
|
|
6653
|
+
}
|
|
6654
|
+
getHTML() {
|
|
6655
|
+
const editor = this.editor;
|
|
6656
|
+
return editor ? editor.getHTML() : "";
|
|
6657
|
+
}
|
|
6658
|
+
getJSON() {
|
|
6659
|
+
const editor = this.editor;
|
|
6660
|
+
return editor ? editor.getJSON() : undefined;
|
|
6661
|
+
}
|
|
6662
|
+
getText() {
|
|
6663
|
+
const editor = this.editor;
|
|
6664
|
+
return editor ? editor.getText() : "";
|
|
6665
|
+
}
|
|
6666
|
+
async exportAs(format, method, options) {
|
|
6667
|
+
const editor = this.editor;
|
|
6668
|
+
if (editor) {
|
|
6669
|
+
await this.commandsService.exportAs(editor, format, method, options);
|
|
6670
|
+
}
|
|
6671
|
+
}
|
|
6672
|
+
focus() {
|
|
6673
|
+
const editor = this.editor;
|
|
6674
|
+
if (editor) {
|
|
6675
|
+
this.commandsService.focus(editor);
|
|
6676
|
+
}
|
|
6677
|
+
}
|
|
6678
|
+
blur() {
|
|
6679
|
+
const editor = this.editor;
|
|
6680
|
+
if (editor) {
|
|
6681
|
+
this.commandsService.blur(editor);
|
|
6682
|
+
}
|
|
6683
|
+
}
|
|
6684
|
+
}
|
|
6685
|
+
|
|
6686
|
+
/**
|
|
6687
|
+
* A root-level registry service to register, unregister, and manage active editor instances.
|
|
6688
|
+
* This service is provided in 'root' and can be injected anywhere in the application.
|
|
6689
|
+
*/
|
|
6690
|
+
class AteEditorRegistry {
|
|
6691
|
+
constructor() {
|
|
6692
|
+
// Map of registered editors
|
|
6693
|
+
this._editors = signal(new Map());
|
|
6694
|
+
this.editors = this._editors.asReadonly();
|
|
6695
|
+
// Active (last focused or last registered) editor ID
|
|
6696
|
+
this._activeEditorId = signal(null);
|
|
6697
|
+
this.activeEditorId = this._activeEditorId.asReadonly();
|
|
6698
|
+
// List of all active editor IDs reactively
|
|
6699
|
+
this.editorIds = computed(() => Array.from(this._editors().keys()));
|
|
6700
|
+
// Active AteEditorRef reactively
|
|
6701
|
+
this.activeEditor = computed(() => {
|
|
6702
|
+
const activeId = this._activeEditorId();
|
|
6703
|
+
if (!activeId) {
|
|
6704
|
+
return null;
|
|
6705
|
+
}
|
|
6706
|
+
return this._editors().get(activeId) || null;
|
|
6707
|
+
});
|
|
6708
|
+
}
|
|
6709
|
+
static { this.counter = 0; }
|
|
6710
|
+
/**
|
|
6711
|
+
* Register an editor instance.
|
|
6712
|
+
* Returns the final registered ID.
|
|
6713
|
+
*/
|
|
6714
|
+
register(id, getEditor, commandsService) {
|
|
6715
|
+
const finalId = id || `ate-editor-${++AteEditorRegistry.counter}`;
|
|
6716
|
+
const editorRef = new AteEditorRef(finalId, getEditor, commandsService);
|
|
6717
|
+
this._editors.update(map => {
|
|
6718
|
+
const newMap = new Map(map);
|
|
6719
|
+
newMap.set(finalId, editorRef);
|
|
6720
|
+
return newMap;
|
|
6721
|
+
});
|
|
6722
|
+
// If there is no active editor, make this one active
|
|
6723
|
+
if (!this._activeEditorId()) {
|
|
6724
|
+
this._activeEditorId.set(finalId);
|
|
6725
|
+
}
|
|
6726
|
+
return finalId;
|
|
6727
|
+
}
|
|
6728
|
+
/**
|
|
6729
|
+
* Unregister an editor instance by ID.
|
|
6730
|
+
*/
|
|
6731
|
+
unregister(id) {
|
|
6732
|
+
this._editors.update(map => {
|
|
6733
|
+
const newMap = new Map(map);
|
|
6734
|
+
newMap.delete(id);
|
|
6735
|
+
return newMap;
|
|
6736
|
+
});
|
|
6737
|
+
// If the active editor is the one being unregistered, find a fallback
|
|
6738
|
+
if (this._activeEditorId() === id) {
|
|
6739
|
+
const remainingIds = this.editorIds();
|
|
6740
|
+
if (remainingIds.length > 0) {
|
|
6741
|
+
// Set active to the last registered one remaining
|
|
6742
|
+
this._activeEditorId.set(remainingIds[remainingIds.length - 1]);
|
|
6743
|
+
}
|
|
6744
|
+
else {
|
|
6745
|
+
this._activeEditorId.set(null);
|
|
6746
|
+
}
|
|
6747
|
+
}
|
|
6748
|
+
}
|
|
6749
|
+
/**
|
|
6750
|
+
* Mark an editor as active (usually on focus).
|
|
6751
|
+
*/
|
|
6752
|
+
setActive(id) {
|
|
6753
|
+
if (this._editors().has(id)) {
|
|
6754
|
+
this._activeEditorId.set(id);
|
|
6755
|
+
}
|
|
6756
|
+
}
|
|
6757
|
+
/**
|
|
6758
|
+
* Retrieve an editor reference by ID, or the active editor if ID is not specified.
|
|
6759
|
+
*/
|
|
6760
|
+
get(id) {
|
|
6761
|
+
if (id) {
|
|
6762
|
+
return this._editors().get(id);
|
|
6763
|
+
}
|
|
6764
|
+
const activeId = this._activeEditorId();
|
|
6765
|
+
return activeId ? this._editors().get(activeId) : undefined;
|
|
6766
|
+
}
|
|
6767
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AteEditorRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
6768
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AteEditorRegistry, providedIn: "root" }); }
|
|
6769
|
+
}
|
|
6770
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AteEditorRegistry, decorators: [{
|
|
6771
|
+
type: Injectable,
|
|
6772
|
+
args: [{
|
|
6773
|
+
providedIn: "root",
|
|
6774
|
+
}]
|
|
6775
|
+
}] });
|
|
6776
|
+
|
|
6363
6777
|
/**
|
|
6364
6778
|
* Noop Value Accessor Directive
|
|
6365
6779
|
* @link https://medium.com/netanelbasal/forwarding-form-controls-to-custom-control-components-in-angular-701e8406cc55
|
|
@@ -7351,6 +7765,11 @@ class AngularTiptapEditorComponent {
|
|
|
7351
7765
|
* ```
|
|
7352
7766
|
*/
|
|
7353
7767
|
this.imageUploadHandler = input(undefined);
|
|
7768
|
+
/**
|
|
7769
|
+
* Optional unique identifier for the editor instance in the registry.
|
|
7770
|
+
* If not specified, a unique ID is automatically generated.
|
|
7771
|
+
*/
|
|
7772
|
+
this.editorId = input(undefined);
|
|
7354
7773
|
// Nouveaux outputs
|
|
7355
7774
|
this.contentChange = output();
|
|
7356
7775
|
this.editorCreated = output();
|
|
@@ -7358,6 +7777,7 @@ class AngularTiptapEditorComponent {
|
|
|
7358
7777
|
this.editorFocus = output();
|
|
7359
7778
|
this.editorBlur = output();
|
|
7360
7779
|
this.editableChange = output();
|
|
7780
|
+
this.imageUploaded = output();
|
|
7361
7781
|
// ViewChild with signal
|
|
7362
7782
|
this.editorElement = viewChild.required("editorElement");
|
|
7363
7783
|
// Private signals for internal state
|
|
@@ -7543,6 +7963,9 @@ class AngularTiptapEditorComponent {
|
|
|
7543
7963
|
this.editorCommandsService = inject(AteEditorCommandsService);
|
|
7544
7964
|
// Access editor state via service
|
|
7545
7965
|
this.editorState = this.editorCommandsService.editorState;
|
|
7966
|
+
this.editorRegistry = inject(AteEditorRegistry);
|
|
7967
|
+
this._registeredId = signal(null);
|
|
7968
|
+
this.registeredId = this._registeredId.asReadonly();
|
|
7546
7969
|
this.injector = inject(Injector);
|
|
7547
7970
|
this.globalConfig = inject(ATE_GLOBAL_CONFIG, { optional: true });
|
|
7548
7971
|
/**
|
|
@@ -7639,6 +8062,9 @@ class AngularTiptapEditorComponent {
|
|
|
7639
8062
|
}
|
|
7640
8063
|
});
|
|
7641
8064
|
}, { allowSignalWrites: true });
|
|
8065
|
+
this.editorCommandsService.onImageUploaded = result => {
|
|
8066
|
+
this.imageUploaded.emit(result);
|
|
8067
|
+
};
|
|
7642
8068
|
}
|
|
7643
8069
|
ngAfterViewInit() {
|
|
7644
8070
|
// La vue est déjà complètement initialisée dans ngAfterViewInit
|
|
@@ -7653,6 +8079,11 @@ class AngularTiptapEditorComponent {
|
|
|
7653
8079
|
currentEditor.destroy();
|
|
7654
8080
|
}
|
|
7655
8081
|
this._editorFullyInitialized.set(false);
|
|
8082
|
+
// Unregister from the global registry
|
|
8083
|
+
const id = this.registeredId();
|
|
8084
|
+
if (id) {
|
|
8085
|
+
this.editorRegistry.unregister(id);
|
|
8086
|
+
}
|
|
7656
8087
|
}
|
|
7657
8088
|
initEditor() {
|
|
7658
8089
|
const extensions = [
|
|
@@ -7825,6 +8256,10 @@ class AngularTiptapEditorComponent {
|
|
|
7825
8256
|
}, 100);
|
|
7826
8257
|
},
|
|
7827
8258
|
onFocus: ({ editor, event }) => {
|
|
8259
|
+
const id = this.registeredId();
|
|
8260
|
+
if (id) {
|
|
8261
|
+
this.editorRegistry.setActive(id);
|
|
8262
|
+
}
|
|
7828
8263
|
this.editorFocus.emit({ editor, event });
|
|
7829
8264
|
},
|
|
7830
8265
|
onBlur: ({ editor, event }) => {
|
|
@@ -7837,6 +8272,9 @@ class AngularTiptapEditorComponent {
|
|
|
7837
8272
|
});
|
|
7838
8273
|
// Stocker la référence de l'éditeur immédiatement
|
|
7839
8274
|
this._editor.set(newEditor);
|
|
8275
|
+
// Register editor in the global registry
|
|
8276
|
+
const registeredId = this.editorRegistry.register(this.editorId(), () => this.editor(), this.editorCommandsService);
|
|
8277
|
+
this._registeredId.set(registeredId);
|
|
7840
8278
|
}
|
|
7841
8279
|
toggleEditMode(event) {
|
|
7842
8280
|
event.preventDefault();
|
|
@@ -7963,7 +8401,13 @@ class AngularTiptapEditorComponent {
|
|
|
7963
8401
|
}
|
|
7964
8402
|
}
|
|
7965
8403
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AngularTiptapEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
7966
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: AngularTiptapEditorComponent, isStandalone: true, selector: "angular-tiptap-editor", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null }, fillContainer: { classPropertyName: "fillContainer", publicName: "fillContainer", isSignal: true, isRequired: false, transformFunction: null }, showToolbar: { classPropertyName: "showToolbar", publicName: "showToolbar", isSignal: true, isRequired: false, transformFunction: null }, showFooter: { classPropertyName: "showFooter", publicName: "showFooter", isSignal: true, isRequired: false, transformFunction: null }, showCharacterCount: { classPropertyName: "showCharacterCount", publicName: "showCharacterCount", isSignal: true, isRequired: false, transformFunction: null }, showWordCount: { classPropertyName: "showWordCount", publicName: "showWordCount", isSignal: true, isRequired: false, transformFunction: null }, maxCharacters: { classPropertyName: "maxCharacters", publicName: "maxCharacters", isSignal: true, isRequired: false, transformFunction: null }, enableOfficePaste: { classPropertyName: "enableOfficePaste", publicName: "enableOfficePaste", isSignal: true, isRequired: false, transformFunction: null }, enableSlashCommands: { classPropertyName: "enableSlashCommands", publicName: "enableSlashCommands", isSignal: true, isRequired: false, transformFunction: null }, slashCommands: { classPropertyName: "slashCommands", publicName: "slashCommands", isSignal: true, isRequired: false, transformFunction: null }, customSlashCommands: { classPropertyName: "customSlashCommands", publicName: "customSlashCommands", isSignal: true, isRequired: false, transformFunction: null }, blockControls: { classPropertyName: "blockControls", publicName: "blockControls", isSignal: true, isRequired: false, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, seamless: { classPropertyName: "seamless", publicName: "seamless", isSignal: true, isRequired: false, transformFunction: null }, floatingToolbar: { classPropertyName: "floatingToolbar", publicName: "floatingToolbar", isSignal: true, isRequired: false, transformFunction: null }, showEditToggle: { classPropertyName: "showEditToggle", publicName: "showEditToggle", isSignal: true, isRequired: false, transformFunction: null }, spellcheck: { classPropertyName: "spellcheck", publicName: "spellcheck", isSignal: true, isRequired: false, transformFunction: null }, tiptapExtensions: { classPropertyName: "tiptapExtensions", publicName: "tiptapExtensions", isSignal: true, isRequired: false, transformFunction: null }, tiptapOptions: { classPropertyName: "tiptapOptions", publicName: "tiptapOptions", isSignal: true, isRequired: false, transformFunction: null }, showBubbleMenu: { classPropertyName: "showBubbleMenu", publicName: "showBubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, bubbleMenu: { classPropertyName: "bubbleMenu", publicName: "bubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, showImageBubbleMenu: { classPropertyName: "showImageBubbleMenu", publicName: "showImageBubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, imageBubbleMenu: { classPropertyName: "imageBubbleMenu", publicName: "imageBubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, toolbar: { classPropertyName: "toolbar", publicName: "toolbar", isSignal: true, isRequired: false, transformFunction: null }, showTableBubbleMenu: { classPropertyName: "showTableBubbleMenu", publicName: "showTableBubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, tableBubbleMenu: { classPropertyName: "tableBubbleMenu", publicName: "tableBubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, showCellBubbleMenu: { classPropertyName: "showCellBubbleMenu", publicName: "showCellBubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, cellBubbleMenu: { classPropertyName: "cellBubbleMenu", publicName: "cellBubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, stateCalculators: { classPropertyName: "stateCalculators", publicName: "stateCalculators", isSignal: true, isRequired: false, transformFunction: null }, imageUpload: { classPropertyName: "imageUpload", publicName: "imageUpload", isSignal: true, isRequired: false, transformFunction: null }, imageUploadHandler: { classPropertyName: "imageUploadHandler", publicName: "imageUploadHandler", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { contentChange: "contentChange", editorCreated: "editorCreated", editorUpdate: "editorUpdate", editorFocus: "editorFocus", editorBlur: "editorBlur", editableChange: "editableChange" }, host: { properties: { "class.fill-container": "finalFillContainer()", "class.floating-toolbar": "finalFloatingToolbar()", "class.is-readonly": "!finalEditable() && !mergedDisabled()", "class.is-disabled": "mergedDisabled()", "style.--ate-border-width": "finalSeamless() || mergedDisabled() ? '0' : null", "style.--ate-background": "finalSeamless() ? 'transparent' : (mergedDisabled() ? 'var(--ate-surface-tertiary)' : null)", "style.--ate-toolbar-border-color": "finalSeamless() ? 'transparent' : null", "style.--ate-counter-background": "finalSeamless() ? 'transparent' : null", "style.--ate-counter-border-color": "finalSeamless() ? 'transparent' : null", "class.dark": "config().theme === 'dark'", "class.ate-blocks-inside": "finalBlockControls() === 'inside'", "class.ate-blocks-outside": "finalBlockControls() === 'outside'", "attr.data-theme": "config().theme" } }, providers: [
|
|
8404
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: AngularTiptapEditorComponent, isStandalone: true, selector: "angular-tiptap-editor", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null }, fillContainer: { classPropertyName: "fillContainer", publicName: "fillContainer", isSignal: true, isRequired: false, transformFunction: null }, showToolbar: { classPropertyName: "showToolbar", publicName: "showToolbar", isSignal: true, isRequired: false, transformFunction: null }, showFooter: { classPropertyName: "showFooter", publicName: "showFooter", isSignal: true, isRequired: false, transformFunction: null }, showCharacterCount: { classPropertyName: "showCharacterCount", publicName: "showCharacterCount", isSignal: true, isRequired: false, transformFunction: null }, showWordCount: { classPropertyName: "showWordCount", publicName: "showWordCount", isSignal: true, isRequired: false, transformFunction: null }, maxCharacters: { classPropertyName: "maxCharacters", publicName: "maxCharacters", isSignal: true, isRequired: false, transformFunction: null }, enableOfficePaste: { classPropertyName: "enableOfficePaste", publicName: "enableOfficePaste", isSignal: true, isRequired: false, transformFunction: null }, enableSlashCommands: { classPropertyName: "enableSlashCommands", publicName: "enableSlashCommands", isSignal: true, isRequired: false, transformFunction: null }, slashCommands: { classPropertyName: "slashCommands", publicName: "slashCommands", isSignal: true, isRequired: false, transformFunction: null }, customSlashCommands: { classPropertyName: "customSlashCommands", publicName: "customSlashCommands", isSignal: true, isRequired: false, transformFunction: null }, blockControls: { classPropertyName: "blockControls", publicName: "blockControls", isSignal: true, isRequired: false, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, seamless: { classPropertyName: "seamless", publicName: "seamless", isSignal: true, isRequired: false, transformFunction: null }, floatingToolbar: { classPropertyName: "floatingToolbar", publicName: "floatingToolbar", isSignal: true, isRequired: false, transformFunction: null }, showEditToggle: { classPropertyName: "showEditToggle", publicName: "showEditToggle", isSignal: true, isRequired: false, transformFunction: null }, spellcheck: { classPropertyName: "spellcheck", publicName: "spellcheck", isSignal: true, isRequired: false, transformFunction: null }, tiptapExtensions: { classPropertyName: "tiptapExtensions", publicName: "tiptapExtensions", isSignal: true, isRequired: false, transformFunction: null }, tiptapOptions: { classPropertyName: "tiptapOptions", publicName: "tiptapOptions", isSignal: true, isRequired: false, transformFunction: null }, showBubbleMenu: { classPropertyName: "showBubbleMenu", publicName: "showBubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, bubbleMenu: { classPropertyName: "bubbleMenu", publicName: "bubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, showImageBubbleMenu: { classPropertyName: "showImageBubbleMenu", publicName: "showImageBubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, imageBubbleMenu: { classPropertyName: "imageBubbleMenu", publicName: "imageBubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, toolbar: { classPropertyName: "toolbar", publicName: "toolbar", isSignal: true, isRequired: false, transformFunction: null }, showTableBubbleMenu: { classPropertyName: "showTableBubbleMenu", publicName: "showTableBubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, tableBubbleMenu: { classPropertyName: "tableBubbleMenu", publicName: "tableBubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, showCellBubbleMenu: { classPropertyName: "showCellBubbleMenu", publicName: "showCellBubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, cellBubbleMenu: { classPropertyName: "cellBubbleMenu", publicName: "cellBubbleMenu", isSignal: true, isRequired: false, transformFunction: null }, stateCalculators: { classPropertyName: "stateCalculators", publicName: "stateCalculators", isSignal: true, isRequired: false, transformFunction: null }, imageUpload: { classPropertyName: "imageUpload", publicName: "imageUpload", isSignal: true, isRequired: false, transformFunction: null }, imageUploadHandler: { classPropertyName: "imageUploadHandler", publicName: "imageUploadHandler", isSignal: true, isRequired: false, transformFunction: null }, editorId: { classPropertyName: "editorId", publicName: "editorId", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { contentChange: "contentChange", editorCreated: "editorCreated", editorUpdate: "editorUpdate", editorFocus: "editorFocus", editorBlur: "editorBlur", editableChange: "editableChange", imageUploaded: "imageUploaded" }, host: { properties: { "class.fill-container": "finalFillContainer()", "class.floating-toolbar": "finalFloatingToolbar()", "class.is-readonly": "!finalEditable() && !mergedDisabled()", "class.is-disabled": "mergedDisabled()", "style.--ate-border-width": "finalSeamless() || mergedDisabled() ? '0' : null", "style.--ate-background": "finalSeamless() ? 'transparent' : (mergedDisabled() ? 'var(--ate-surface-tertiary)' : null)", "style.--ate-toolbar-border-color": "finalSeamless() ? 'transparent' : null", "style.--ate-counter-background": "finalSeamless() ? 'transparent' : null", "style.--ate-counter-border-color": "finalSeamless() ? 'transparent' : null", "class.dark": "config().theme === 'dark'", "class.ate-blocks-inside": "finalBlockControls() === 'inside'", "class.ate-blocks-outside": "finalBlockControls() === 'outside'", "attr.data-theme": "config().theme" } }, providers: [
|
|
8405
|
+
AteEditorCommandsService,
|
|
8406
|
+
AteImageService,
|
|
8407
|
+
AteColorPickerService,
|
|
8408
|
+
AteLinkService,
|
|
8409
|
+
AteExportService,
|
|
8410
|
+
], viewQueries: [{ propertyName: "editorElement", first: true, predicate: ["editorElement"], descendants: true, isSignal: true }], hostDirectives: [{ directive: AteNoopValueAccessorDirective }], ngImport: i0, template: `
|
|
7967
8411
|
<div class="ate-editor">
|
|
7968
8412
|
<!-- Toolbar -->
|
|
7969
8413
|
@if (finalEditable() && !mergedDisabled() && finalShowToolbar() && editor()) {
|
|
@@ -8118,7 +8562,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
8118
8562
|
AteColorBubbleMenuComponent,
|
|
8119
8563
|
AteEditToggleComponent,
|
|
8120
8564
|
AteBlockControlsComponent,
|
|
8121
|
-
], providers: [
|
|
8565
|
+
], providers: [
|
|
8566
|
+
AteEditorCommandsService,
|
|
8567
|
+
AteImageService,
|
|
8568
|
+
AteColorPickerService,
|
|
8569
|
+
AteLinkService,
|
|
8570
|
+
AteExportService,
|
|
8571
|
+
], template: `
|
|
8122
8572
|
<div class="ate-editor">
|
|
8123
8573
|
<!-- Toolbar -->
|
|
8124
8574
|
@if (finalEditable() && !mergedDisabled() && finalShowToolbar() && editor()) {
|
|
@@ -8326,5 +8776,5 @@ const ATE_TOOLBAR_KEYS = [
|
|
|
8326
8776
|
* Generated bundle index. Do not edit.
|
|
8327
8777
|
*/
|
|
8328
8778
|
|
|
8329
|
-
export { ATE_BUBBLE_MENU_KEYS, ATE_CELL_BUBBLE_MENU_KEYS, ATE_DEFAULT_BUBBLE_MENU_CONFIG, ATE_DEFAULT_CELL_MENU_CONFIG, ATE_DEFAULT_CONFIG, ATE_DEFAULT_IMAGE_BUBBLE_MENU_CONFIG, ATE_DEFAULT_IMAGE_UPLOAD_CONFIG, ATE_DEFAULT_SLASH_COMMANDS_CONFIG, ATE_DEFAULT_TABLE_MENU_CONFIG, ATE_DEFAULT_TOOLBAR_CONFIG, ATE_GLOBAL_CONFIG, ATE_IMAGE_BUBBLE_MENU_KEYS, ATE_INITIAL_EDITOR_STATE, ATE_SLASH_COMMAND_KEYS, ATE_TABLE_BUBBLE_MENU_KEYS, ATE_TOOLBAR_KEYS, AngularTiptapEditorComponent, AteAngularNodeView, AteColorPickerService, AteDiscoveryCalculator, AteEditorCommandsService, AteExportService, AteI18nService, AteImageCalculator, AteImageService, AteLinkService, AteMarksCalculator, AteNodeViewRenderer, AteNoopValueAccessorDirective, AteSelectionCalculator, AteStructureCalculator, AteTableCalculator, AteTooltipDirective, createAngularComponentExtension, createDefaultSlashCommands, filterSlashCommands, provideAteEditor, registerAngularComponent };
|
|
8779
|
+
export { ATE_BUBBLE_MENU_KEYS, ATE_CELL_BUBBLE_MENU_KEYS, ATE_DEFAULT_BUBBLE_MENU_CONFIG, ATE_DEFAULT_CELL_MENU_CONFIG, ATE_DEFAULT_CONFIG, ATE_DEFAULT_IMAGE_BUBBLE_MENU_CONFIG, ATE_DEFAULT_IMAGE_UPLOAD_CONFIG, ATE_DEFAULT_SLASH_COMMANDS_CONFIG, ATE_DEFAULT_TABLE_MENU_CONFIG, ATE_DEFAULT_TOOLBAR_CONFIG, ATE_GLOBAL_CONFIG, ATE_IMAGE_BUBBLE_MENU_KEYS, ATE_INITIAL_EDITOR_STATE, ATE_SLASH_COMMAND_KEYS, ATE_TABLE_BUBBLE_MENU_KEYS, ATE_TOOLBAR_KEYS, AngularTiptapEditorComponent, AteAngularNodeView, AteColorPickerService, AteDiscoveryCalculator, AteEditorCommandsService, AteEditorRef, AteEditorRegistry, AteExportService, AteI18nService, AteImageCalculator, AteImageService, AteLinkService, AteMarksCalculator, AteNodeViewRenderer, AteNoopValueAccessorDirective, AteSelectionCalculator, AteStructureCalculator, AteTableCalculator, AteTooltipDirective, createAngularComponentExtension, createDefaultSlashCommands, filterSlashCommands, provideAteEditor, registerAngularComponent };
|
|
8330
8780
|
//# sourceMappingURL=flogeez-angular-tiptap-editor.mjs.map
|