@phuong-tran-redoc/document-engine-angular 0.0.27 → 0.0.28

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.
@@ -6102,10 +6102,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImpo
6102
6102
  args: ['attr.data-drag-handle']
6103
6103
  }] } });
6104
6104
 
6105
+ /**
6106
+ * Injection token for HTML preprocessor function.
6107
+ * Use this token to provide a custom function that processes HTML content
6108
+ * before it's set into the TipTap editor.
6109
+ *
6110
+ * This is optional - if not provided, the editor will use the HTML content as-is.
6111
+ *
6112
+ * @example
6113
+ * ```typescript
6114
+ * // In your component or module providers
6115
+ * {
6116
+ * provide: EDITOR_HTML_PREPROCESSOR,
6117
+ * useValue: (html: string) => {
6118
+ * // Your custom preprocessing logic
6119
+ * return html.replace(/old/g, 'new');
6120
+ * }
6121
+ * }
6122
+ * ```
6123
+ */
6124
+ const EDITOR_HTML_PREPROCESSOR = new InjectionToken('EDITOR_HTML_PREPROCESSOR');
6125
+
6105
6126
  class TiptapEditorDirective {
6106
6127
  elRef = inject(ElementRef);
6107
6128
  renderer = inject(Renderer2);
6108
6129
  changeDetectorRef = inject(ChangeDetectorRef);
6130
+ htmlPreprocessor = inject(EDITOR_HTML_PREPROCESSOR, { optional: true });
6109
6131
  _editor;
6110
6132
  initialEditableState;
6111
6133
  set editor(editor) {
@@ -6132,7 +6154,12 @@ class TiptapEditorDirective {
6132
6154
  // Writes a new value to the element.
6133
6155
  // This methods is called when programmatic changes from model to view are requested.
6134
6156
  writeValue(value) {
6135
- this.editor.chain().setContent(value, { emitUpdate: false }).run();
6157
+ // Apply preprocessor if value is a string (HTML) and preprocessor is available
6158
+ let processedValue = value;
6159
+ if (typeof value === 'string' && this.htmlPreprocessor) {
6160
+ processedValue = this.htmlPreprocessor(value);
6161
+ }
6162
+ this.editor.chain().setContent(processedValue, { emitUpdate: false }).run();
6136
6163
  }
6137
6164
  // Registers a callback function that is called when the control's value changes in the UI.
6138
6165
  registerOnChange(fn) {
@@ -6179,7 +6206,9 @@ class TiptapEditorDirective {
6179
6206
  editor.setOptions({ element: this.elRef.nativeElement });
6180
6207
  // update content to the editor
6181
6208
  if (innerHTML) {
6182
- editor.chain().setContent(innerHTML, { emitUpdate: false }).run();
6209
+ // Apply preprocessor to initial content if available
6210
+ const processedContent = this.htmlPreprocessor ? this.htmlPreprocessor(innerHTML) : innerHTML;
6211
+ editor.chain().setContent(processedContent, { emitUpdate: false }).run();
6183
6212
  }
6184
6213
  // register blur handler to update `touched` property
6185
6214
  editor.on('blur', () => {
@@ -6281,5 +6310,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImpo
6281
6310
  * Generated bundle index. Do not edit.
6282
6311
  */
6283
6312
 
6284
- export { ARCHIVE, ARROW_DROP_DOWN, AngularRenderer, ButtonDirective, CHECK, CLEAR_ALL, CLOSE, CODE, CharacterCountComponent, CheckboxComponent, ColorPickerComponent, ColorPickerViewComponent, DEFAULT, DEFAULT_TOOLBAR_STATE, DESCRIPTION, DYNAMIC_FORM, DocumentEditorComponent, DocumentEditorModule, DocumentEngineKit, DynamicFieldsViewComponent, EDIT, EditorBubbleMenuComponent, EditorCapabilities, ErrorMessageComponent, EventManager, FORMAT_ALIGN_CENTER, FORMAT_ALIGN_JUSTIFY, FORMAT_ALIGN_LEFT, FORMAT_ALIGN_RIGHT, FORMAT_BOLD, FORMAT_CLEAR, FORMAT_COLOR_FILL, FORMAT_COLOR_TEXT, FORMAT_INDENT_DECREASE, FORMAT_INDENT_INCREASE, FORMAT_ITALIC, FORMAT_LINE_SPACING, FORMAT_LIST_BULLETED, FORMAT_LIST_NUMBERED, FORMAT_QUOTE, FORMAT_SIZE, FORMAT_STRIKETHROUGH, FORMAT_UNDERLINE, FocusTrapService, FooterComponent, INSERT_PAGE_BREAK, IconComponent, IconRegistryService, ImageInsertViewComponent, InputDirective, LINK, LINK_OFF, LabelDirective, LinkEditViewComponent, LinkMainViewComponent, LinkPropertiesViewComponent, MARKDOWN, MATCH_CASE, PHOTO, PRINT, PopoverDirective, REDO, RESTRICT_EDIT, SEARCH, SEARCH_OFF, SETTINGS, SPECIAL_CHARACTER, SUBSCRIPT, SUPERSCRIPT, SelectComponent, SelectLabelDirective, SelectOptionDirective, SpecialCharactersViewComponent, TABLE_CELL_PROPERTY, TABLE_COLUMN, TABLE_MERGE_CELL, TABLE_PROPERTY, TABLE_ROW, TABLE_ROWS, TableCellStyleViewComponent, TableCreateViewComponent, TableMainViewComponent, TableStyleViewComponent, TemplateViewComponent, TiptapBubbleMenuDirective, TiptapDraggableDirective, TiptapEditorDirective, TiptapFloatingMenuDirective, ToggleGroupComponent, ToggleOptionDirective, ToolbarBubbleMenuComponent, ToolbarComponent, ToolbarService, UNDO, VERTICAL_ALIGN_BOTTOM, VERTICAL_ALIGN_CENTER, VERTICAL_ALIGN_TOP, buildToolbarState, selectionChangeHandler, shouldShowFnFactory, urlValidator };
6313
+ export { ARCHIVE, ARROW_DROP_DOWN, AngularRenderer, ButtonDirective, CHECK, CLEAR_ALL, CLOSE, CODE, CharacterCountComponent, CheckboxComponent, ColorPickerComponent, ColorPickerViewComponent, DEFAULT, DEFAULT_TOOLBAR_STATE, DESCRIPTION, DYNAMIC_FORM, DocumentEditorComponent, DocumentEditorModule, DocumentEngineKit, DynamicFieldsViewComponent, EDIT, EDITOR_HTML_PREPROCESSOR, EditorBubbleMenuComponent, EditorCapabilities, ErrorMessageComponent, EventManager, FORMAT_ALIGN_CENTER, FORMAT_ALIGN_JUSTIFY, FORMAT_ALIGN_LEFT, FORMAT_ALIGN_RIGHT, FORMAT_BOLD, FORMAT_CLEAR, FORMAT_COLOR_FILL, FORMAT_COLOR_TEXT, FORMAT_INDENT_DECREASE, FORMAT_INDENT_INCREASE, FORMAT_ITALIC, FORMAT_LINE_SPACING, FORMAT_LIST_BULLETED, FORMAT_LIST_NUMBERED, FORMAT_QUOTE, FORMAT_SIZE, FORMAT_STRIKETHROUGH, FORMAT_UNDERLINE, FocusTrapService, FooterComponent, INSERT_PAGE_BREAK, IconComponent, IconRegistryService, ImageInsertViewComponent, InputDirective, LINK, LINK_OFF, LabelDirective, LinkEditViewComponent, LinkMainViewComponent, LinkPropertiesViewComponent, MARKDOWN, MATCH_CASE, PHOTO, PRINT, PopoverDirective, REDO, RESTRICT_EDIT, SEARCH, SEARCH_OFF, SETTINGS, SPECIAL_CHARACTER, SUBSCRIPT, SUPERSCRIPT, SelectComponent, SelectLabelDirective, SelectOptionDirective, SpecialCharactersViewComponent, TABLE_CELL_PROPERTY, TABLE_COLUMN, TABLE_MERGE_CELL, TABLE_PROPERTY, TABLE_ROW, TABLE_ROWS, TableCellStyleViewComponent, TableCreateViewComponent, TableMainViewComponent, TableStyleViewComponent, TemplateViewComponent, TiptapBubbleMenuDirective, TiptapDraggableDirective, TiptapEditorDirective, TiptapFloatingMenuDirective, ToggleGroupComponent, ToggleOptionDirective, ToolbarBubbleMenuComponent, ToolbarComponent, ToolbarService, UNDO, VERTICAL_ALIGN_BOTTOM, VERTICAL_ALIGN_CENTER, VERTICAL_ALIGN_TOP, buildToolbarState, selectionChangeHandler, shouldShowFnFactory, urlValidator };
6285
6314
  //# sourceMappingURL=phuong-tran-redoc-document-engine-angular.mjs.map