@flogeez/angular-tiptap-editor 2.2.2 → 2.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/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import * as _flogeez_angular_tiptap_editor from '@flogeez/angular-tiptap-editor';
2
- import { Editor, Node, Mark, Extension, EditorOptions, JSONContent } from '@tiptap/core';
2
+ import { Editor, Node as Node$1, Mark, Extension, EditorOptions, JSONContent, NodeConfig } from '@tiptap/core';
3
3
  import * as _angular_core from '@angular/core';
4
- import { AfterViewInit, OnDestroy, ElementRef } from '@angular/core';
4
+ import { AfterViewInit, OnDestroy, ElementRef, Signal, Injector, Type } from '@angular/core';
5
5
  import { Observable } from 'rxjs';
6
6
  import { ControlValueAccessor } from '@angular/forms';
7
+ import { Node as Node$2 } from '@tiptap/pm/model';
8
+ import { Decoration, EditorView, NodeView } from '@tiptap/pm/view';
7
9
 
8
10
  type SupportedLocale = "en" | "fr" | (string & {});
9
11
  interface AteTranslations {
@@ -891,7 +893,7 @@ declare class AngularTiptapEditorComponent implements AfterViewInit, OnDestroy {
891
893
  floatingToolbar: _angular_core.InputSignal<boolean>;
892
894
  showEditToggle: _angular_core.InputSignal<boolean>;
893
895
  spellcheck: _angular_core.InputSignal<boolean>;
894
- tiptapExtensions: _angular_core.InputSignal<(Node<any, any> | Mark<any, any> | Extension<any, any>)[]>;
896
+ tiptapExtensions: _angular_core.InputSignal<(Node$1<any, any> | Mark<any, any> | Extension<any, any>)[]>;
895
897
  tiptapOptions: _angular_core.InputSignal<Partial<EditorOptions>>;
896
898
  showBubbleMenu: _angular_core.InputSignal<boolean>;
897
899
  bubbleMenu: _angular_core.InputSignal<Partial<AteBubbleMenuConfig>>;
@@ -1228,6 +1230,305 @@ declare const ATE_DEFAULT_IMAGE_BUBBLE_MENU_CONFIG: AteImageBubbleMenuConfig;
1228
1230
  declare const ATE_DEFAULT_TABLE_MENU_CONFIG: AteTableBubbleMenuConfig;
1229
1231
  declare const ATE_DEFAULT_CELL_MENU_CONFIG: AteCellBubbleMenuConfig;
1230
1232
 
1233
+ /**
1234
+ * Props that are injected into Angular NodeView components
1235
+ */
1236
+ interface AteAngularNodeViewProps {
1237
+ editor: Editor;
1238
+ node: Node$2;
1239
+ decorations: readonly Decoration[];
1240
+ selected: boolean;
1241
+ extension: unknown;
1242
+ getPos: () => number | undefined;
1243
+ updateAttributes: (attrs: Record<string, unknown>) => void;
1244
+ deleteNode: () => void;
1245
+ }
1246
+ /**
1247
+ * Base abstract class for Angular components used as TipTap NodeViews.
1248
+ *
1249
+ * Extend this class in your custom components to get access to the TipTap node properties.
1250
+ *
1251
+ * @example
1252
+ * ```typescript
1253
+ * @Component({
1254
+ * selector: 'app-counter',
1255
+ * template: `
1256
+ * <div>
1257
+ * <button (click)="increment()">Count: {{ node().attrs['count'] }}</button>
1258
+ * </div>
1259
+ * `
1260
+ * })
1261
+ * export class CounterComponent extends AteAngularNodeView {
1262
+ * increment() {
1263
+ * const count = this.node().attrs['count'] || 0;
1264
+ * this.updateAttributes({ count: count + 1 });
1265
+ * }
1266
+ * }
1267
+ * ```
1268
+ */
1269
+ declare abstract class AteAngularNodeView {
1270
+ /**
1271
+ * The TipTap editor instance
1272
+ */
1273
+ editor: Signal<Editor>;
1274
+ /**
1275
+ * The ProseMirror node
1276
+ */
1277
+ node: Signal<Node$2>;
1278
+ /**
1279
+ * Decorations applied to this node
1280
+ */
1281
+ decorations: Signal<readonly Decoration[]>;
1282
+ /**
1283
+ * Whether the node is currently selected
1284
+ */
1285
+ selected: Signal<boolean>;
1286
+ /**
1287
+ * The extension instance that created this node
1288
+ */
1289
+ extension: Signal<unknown>;
1290
+ /**
1291
+ * Function to get the current position of this node in the document
1292
+ */
1293
+ getPos: () => number | undefined;
1294
+ /**
1295
+ * Update the attributes of this node
1296
+ *
1297
+ * @param attrs - Partial attributes to update
1298
+ *
1299
+ * @example
1300
+ * ```typescript
1301
+ * this.updateAttributes({ count: 5, color: 'blue' });
1302
+ * ```
1303
+ */
1304
+ updateAttributes: (attrs: Record<string, unknown>) => void;
1305
+ /**
1306
+ * Delete this node from the document
1307
+ */
1308
+ deleteNode: () => void;
1309
+ /** @internal */
1310
+ private _writableSignals?;
1311
+ /**
1312
+ * Internal method to initialize the component with NodeView props.
1313
+ * This is called by the AngularNodeViewRenderer.
1314
+ *
1315
+ * @internal
1316
+ */
1317
+ _initNodeView(props: AteAngularNodeViewProps): void;
1318
+ /**
1319
+ * Internal method to update the component when the node changes.
1320
+ * This is called by the AngularNodeViewRenderer.
1321
+ *
1322
+ * @internal
1323
+ */
1324
+ _updateNodeView(node: Node$2, decorations: readonly Decoration[]): void;
1325
+ /**
1326
+ * Internal method to update the selection state.
1327
+ * This is called by the AngularNodeViewRenderer.
1328
+ *
1329
+ * @internal
1330
+ */
1331
+ _selectNodeView(): void;
1332
+ /**
1333
+ * Internal method to update the deselection state.
1334
+ * This is called by the AngularNodeViewRenderer.
1335
+ *
1336
+ * @internal
1337
+ */
1338
+ _deselectNodeView(): void;
1339
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AteAngularNodeView, never>;
1340
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<AteAngularNodeView, never, never, {}, {}, never, never, true, never>;
1341
+ }
1342
+
1343
+ /**
1344
+ * Common options for rendering any Angular component as a TipTap NodeView
1345
+ */
1346
+ interface AteComponentRenderOptions {
1347
+ /**
1348
+ * Angular injector to use for creating the component
1349
+ */
1350
+ injector: Injector;
1351
+ /**
1352
+ * Additional inputs to pass to the component
1353
+ */
1354
+ inputs?: Record<string, unknown>;
1355
+ /**
1356
+ * Custom wrapper element tag (default: 'div')
1357
+ */
1358
+ wrapperTag?: string;
1359
+ /**
1360
+ * CSS classes to add to the wrapper element
1361
+ */
1362
+ wrapperClass?: string;
1363
+ /**
1364
+ * Whether the node should be treated as an atom (not editable)
1365
+ * Default: true
1366
+ */
1367
+ atom?: boolean;
1368
+ /**
1369
+ * Enables editable content for <ng-content>.
1370
+ * If true, TipTap will treat the component's content as editable.
1371
+ * @default false
1372
+ */
1373
+ editableContent?: boolean;
1374
+ /**
1375
+ * Optional CSS selector to target an internal element of the component as the editable area.
1376
+ */
1377
+ contentSelector?: string;
1378
+ /**
1379
+ * Type of content allowed in the editable area.
1380
+ */
1381
+ contentMode?: "block" | "inline";
1382
+ /**
1383
+ * Whether to ignore mutations in the component's DOM.
1384
+ * If true, TipTap won't try to sync changes from the component's DOM back to the editor state.
1385
+ * @default true
1386
+ */
1387
+ ignoreMutation?: boolean | ((mutation: MutationRecord | {
1388
+ type: "selection";
1389
+ target: Node;
1390
+ }) => boolean);
1391
+ /**
1392
+ * Callback called when an Output event is emitted by the component.
1393
+ */
1394
+ onOutput?: (outputName: string, value: unknown) => void;
1395
+ /**
1396
+ * Callback called when the node is updated.
1397
+ */
1398
+ onUpdate?: (node: Node$2) => void;
1399
+ /**
1400
+ * Callback called when the component is destroyed.
1401
+ */
1402
+ onDestroy?: () => void;
1403
+ }
1404
+ /**
1405
+ * Unified configuration for registering ANY Angular component.
1406
+ */
1407
+ interface RegisterAngularComponentOptions<T = unknown> {
1408
+ /**
1409
+ * The Angular component to register
1410
+ */
1411
+ component: Type<T>;
1412
+ /**
1413
+ * Unique name for the TipTap node
1414
+ */
1415
+ name?: string;
1416
+ /**
1417
+ * Default inputs (for standard components)
1418
+ */
1419
+ defaultInputs?: Record<string, unknown>;
1420
+ /**
1421
+ * TipTap attributes (for TipTap-aware components)
1422
+ */
1423
+ attributes?: Record<string, {
1424
+ default?: unknown;
1425
+ parseHTML?: (element: HTMLElement) => unknown;
1426
+ renderHTML?: (attributes: Record<string, unknown>) => Record<string, unknown> | null;
1427
+ }>;
1428
+ /**
1429
+ * CSS selector for the editable area inside the component
1430
+ */
1431
+ contentSelector?: string;
1432
+ /**
1433
+ * Content mode for the editable area
1434
+ */
1435
+ contentMode?: "block" | "inline";
1436
+ /**
1437
+ * Enable editable content via <ng-content> or contentSelector
1438
+ * @default false
1439
+ */
1440
+ editableContent?: boolean;
1441
+ /**
1442
+ * Node group (block or inline)
1443
+ * @default 'block'
1444
+ */
1445
+ group?: "block" | "inline";
1446
+ /**
1447
+ * Is the node draggable?
1448
+ * @default true
1449
+ */
1450
+ draggable?: boolean;
1451
+ /**
1452
+ * Whether to ignore mutations in the component's DOM.
1453
+ * @default true
1454
+ */
1455
+ ignoreMutation?: boolean | ((mutation: MutationRecord | {
1456
+ type: "selection";
1457
+ target: Node;
1458
+ }) => boolean);
1459
+ /**
1460
+ * Custom HTML attributes for the wrapper
1461
+ */
1462
+ HTMLAttributes?: Record<string, unknown>;
1463
+ /**
1464
+ * Custom parseHTML rules
1465
+ */
1466
+ parseHTML?: NodeConfig["parseHTML"];
1467
+ /**
1468
+ * Custom renderHTML function
1469
+ */
1470
+ renderHTML?: NodeConfig["renderHTML"];
1471
+ /**
1472
+ * Callback called when an Output event is emitted by the component.
1473
+ */
1474
+ onOutput?: (outputName: string, value: unknown) => void;
1475
+ }
1476
+
1477
+ /**
1478
+ * Universal Renderer for Angular Components as TipTap NodeViews.
1479
+ *
1480
+ * Supports:
1481
+ * - TipTap-Aware components (extending AteAngularNodeView)
1482
+ * - Standard library components (automatic @Input() sync)
1483
+ * - Signal-based inputs and outputs (Angular 18+)
1484
+ * - Content projection (editableContent)
1485
+ * - Unified lifecycle and event management
1486
+ */
1487
+ declare function AteNodeViewRenderer<T>(component: Type<T>, options: AteComponentRenderOptions): (props: {
1488
+ node: Node$2;
1489
+ view: EditorView;
1490
+ getPos: () => number | undefined;
1491
+ decorations: readonly Decoration[];
1492
+ editor: Editor;
1493
+ extension: unknown;
1494
+ }) => NodeView;
1495
+
1496
+ /**
1497
+ * Factory to transform an Angular component into a TipTap Node extension.
1498
+ * Supports both "TipTap-Aware" and "Standard" modes.
1499
+ *
1500
+ * @internal
1501
+ */
1502
+ declare function createAngularComponentExtension<T = unknown>(injector: Injector, options: RegisterAngularComponentOptions<T>): Node$1;
1503
+
1504
+ /**
1505
+ * Registers ANY Angular component as a TipTap node extension.
1506
+ *
1507
+ * This function is the single public entry point for adding custom components.
1508
+ * It supports two distinct modes:
1509
+ *
1510
+ * 1. **TipTap-Aware Mode** (the component extends `AteAngularNodeView`):
1511
+ * Grants direct access to the TipTap API (`editor`, `node`, `updateAttributes`, etc.) within the component.
1512
+ *
1513
+ * 2. **Standard Mode** (library or legacy components):
1514
+ * Allows using any existing Angular component. Its `@Input()` properties are automatically
1515
+ * synchronized with TipTap node attributes.
1516
+ *
1517
+ * @param injector - The Angular Injector (obtained via `inject(Injector)`)
1518
+ * @param options - Configuration options for the component extension
1519
+ * @returns A TipTap Node extension ready to be used
1520
+ *
1521
+ * @example
1522
+ * ```typescript
1523
+ * registerAngularComponent(injector, {
1524
+ * component: MyComponent,
1525
+ * name: 'myComponent',
1526
+ * defaultInputs: { color: 'blue' }
1527
+ * });
1528
+ * ```
1529
+ */
1530
+ declare function registerAngularComponent<T = unknown>(injector: Injector, options: RegisterAngularComponentOptions<T>): Node$1;
1531
+
1231
1532
  /** @deprecated Renamed to `ATE_INITIAL_EDITOR_STATE`. This alias will be removed in v3.0.0. */
1232
1533
  declare const INITIAL_EDITOR_STATE: AteEditorStateSnapshot;
1233
1534
 
@@ -1259,5 +1560,5 @@ declare const DEFAULT_TABLE_MENU_CONFIG: Partial<Record<"addColumnBefore" | "add
1259
1560
  /** @deprecated Renamed to `ATE_DEFAULT_CELL_MENU_CONFIG`. This alias will be removed in v3.0.0. */
1260
1561
  declare const DEFAULT_CELL_MENU_CONFIG: Partial<Record<"mergeCells" | "splitCell", boolean>>;
1261
1562
 
1262
- export { ATE_BUBBLE_MENU_KEYS, ATE_CELL_BUBBLE_MENU_KEYS, ATE_DEFAULT_BUBBLE_MENU_CONFIG, ATE_DEFAULT_CELL_MENU_CONFIG, ATE_DEFAULT_IMAGE_BUBBLE_MENU_CONFIG, ATE_DEFAULT_SLASH_COMMANDS_CONFIG, ATE_DEFAULT_TABLE_MENU_CONFIG, ATE_DEFAULT_TOOLBAR_CONFIG, ATE_IMAGE_BUBBLE_MENU_KEYS, ATE_INITIAL_EDITOR_STATE, ATE_SLASH_COMMAND_KEYS, ATE_TABLE_BUBBLE_MENU_KEYS, ATE_TOOLBAR_KEYS, AngularTiptapEditorComponent, AteColorPickerService, AteDiscoveryCalculator, AteEditorCommandsService, AteI18nService, AteImageCalculator, AteImageService, AteLinkService, AteMarksCalculator, AteNoopValueAccessorDirective, AteSelectionCalculator, AteStructureCalculator, AteTableCalculator, AteColorPickerService as ColorPickerService, DEFAULT_BUBBLE_MENU_CONFIG, DEFAULT_CELL_MENU_CONFIG, DEFAULT_IMAGE_BUBBLE_MENU_CONFIG, DEFAULT_SLASH_COMMANDS_CONFIG, DEFAULT_TABLE_MENU_CONFIG, DEFAULT_TOOLBAR_CONFIG, DiscoveryCalculator, AteEditorCommandsService as EditorCommandsService, INITIAL_EDITOR_STATE, ImageCalculator, AteImageService as ImageService, AteLinkService as LinkService, MarksCalculator, SLASH_COMMAND_KEYS, SelectionCalculator, StructureCalculator, TableCalculator, AteI18nService as TiptapI18nService, createDefaultSlashCommands, filterSlashCommands };
1263
- export type { AteBubbleMenuConfig, AteBubbleMenuKey, AteCellBubbleMenuConfig, AteCellBubbleMenuKey, AteColorEditMode, AteColorPickerSelection, AteCustomBubbleMenuItem, AteCustomSlashCommands, AteCustomToolbarItem, AteEditorConfig, AteEditorStateSnapshot, AteImageBubbleMenuConfig, AteImageBubbleMenuKey, AteImageData, AteImageUploadConfig, AteImageUploadContext, AteImageUploadHandler, AteImageUploadHandlerResult, AteImageUploadOptions, AteImageUploadResult, AteResizeOptions, AteSlashCommandItem, AteSlashCommandKey, AteSlashCommandsConfig, AteStateCalculator, AteTableBubbleMenuConfig, AteTableBubbleMenuKey, AteToolbarConfig, AteToolbarKey, AteTranslations, AteBubbleMenuConfig as BubbleMenuConfig, AteCellBubbleMenuConfig as CellBubbleMenuConfig, AteCustomSlashCommands as CustomSlashCommands, AteEditorConfig as EditorConfig, AteEditorStateSnapshot as EditorStateSnapshot, AteImageBubbleMenuConfig as ImageBubbleMenuConfig, AteImageData as ImageData, AteImageUploadHandler as ImageUploadHandler, AteImageUploadOptions as ImageUploadOptions, AteImageUploadResult as ImageUploadResult, AteResizeOptions as ResizeOptions, AteSlashCommandItem as SlashCommandItem, AteSlashCommandKey as SlashCommandKey, AteSlashCommandsConfig as SlashCommandsConfig, SupportedLocale, AteTableBubbleMenuConfig as TableBubbleMenuConfig, AteToolbarConfig as ToolbarConfig };
1563
+ export { ATE_BUBBLE_MENU_KEYS, ATE_CELL_BUBBLE_MENU_KEYS, ATE_DEFAULT_BUBBLE_MENU_CONFIG, ATE_DEFAULT_CELL_MENU_CONFIG, ATE_DEFAULT_IMAGE_BUBBLE_MENU_CONFIG, ATE_DEFAULT_SLASH_COMMANDS_CONFIG, ATE_DEFAULT_TABLE_MENU_CONFIG, ATE_DEFAULT_TOOLBAR_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, AteI18nService, AteImageCalculator, AteImageService, AteLinkService, AteMarksCalculator, AteNodeViewRenderer, AteNoopValueAccessorDirective, AteSelectionCalculator, AteStructureCalculator, AteTableCalculator, AteColorPickerService as ColorPickerService, DEFAULT_BUBBLE_MENU_CONFIG, DEFAULT_CELL_MENU_CONFIG, DEFAULT_IMAGE_BUBBLE_MENU_CONFIG, DEFAULT_SLASH_COMMANDS_CONFIG, DEFAULT_TABLE_MENU_CONFIG, DEFAULT_TOOLBAR_CONFIG, DiscoveryCalculator, AteEditorCommandsService as EditorCommandsService, INITIAL_EDITOR_STATE, ImageCalculator, AteImageService as ImageService, AteLinkService as LinkService, MarksCalculator, SLASH_COMMAND_KEYS, SelectionCalculator, StructureCalculator, TableCalculator, AteI18nService as TiptapI18nService, createAngularComponentExtension, createDefaultSlashCommands, filterSlashCommands, registerAngularComponent };
1564
+ export type { AteAngularNodeViewProps, AteBubbleMenuConfig, AteBubbleMenuKey, AteCellBubbleMenuConfig, AteCellBubbleMenuKey, AteColorEditMode, AteColorPickerSelection, AteComponentRenderOptions, AteCustomBubbleMenuItem, AteCustomSlashCommands, AteCustomToolbarItem, AteEditorConfig, AteEditorStateSnapshot, AteImageBubbleMenuConfig, AteImageBubbleMenuKey, AteImageData, AteImageUploadConfig, AteImageUploadContext, AteImageUploadHandler, AteImageUploadHandlerResult, AteImageUploadOptions, AteImageUploadResult, AteResizeOptions, AteSlashCommandItem, AteSlashCommandKey, AteSlashCommandsConfig, AteStateCalculator, AteTableBubbleMenuConfig, AteTableBubbleMenuKey, AteToolbarConfig, AteToolbarKey, AteTranslations, AteBubbleMenuConfig as BubbleMenuConfig, AteCellBubbleMenuConfig as CellBubbleMenuConfig, AteCustomSlashCommands as CustomSlashCommands, AteEditorConfig as EditorConfig, AteEditorStateSnapshot as EditorStateSnapshot, AteImageBubbleMenuConfig as ImageBubbleMenuConfig, AteImageData as ImageData, AteImageUploadHandler as ImageUploadHandler, AteImageUploadOptions as ImageUploadOptions, AteImageUploadResult as ImageUploadResult, RegisterAngularComponentOptions, AteResizeOptions as ResizeOptions, AteSlashCommandItem as SlashCommandItem, AteSlashCommandKey as SlashCommandKey, AteSlashCommandsConfig as SlashCommandsConfig, SupportedLocale, AteTableBubbleMenuConfig as TableBubbleMenuConfig, AteToolbarConfig as ToolbarConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flogeez/angular-tiptap-editor",
3
- "version": "2.2.2",
3
+ "version": "2.3.0",
4
4
  "description": "A modern, customizable rich-text editor for Angular (18+), built with Tiptap and featuring complete internationalization support",
5
5
  "keywords": [
6
6
  "angular",