@acorex/cdk 22.4.45 → 22.4.47

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.
@@ -23,7 +23,7 @@ interface AXTextEditorRecentColor {
23
23
  color: string;
24
24
  kind: 'text' | 'background';
25
25
  }
26
- type AXTextEditorCommandType = 'undo' | 'redo' | 'bold' | 'italic' | 'underline' | 'strike' | 'heading' | 'paragraph' | 'align' | 'direction' | 'color' | 'highlight' | 'fontSize' | 'bulletList' | 'orderedList' | 'superscript' | 'subscript' | 'link' | 'unlink' | 'blockquote' | 'code' | 'codeBlock' | 'horizontalRule' | 'image' | 'video' | 'insertTable' | 'addColumnBefore' | 'addColumnAfter' | 'deleteColumn' | 'addRowBefore' | 'addRowAfter' | 'deleteRow' | 'toggleHeaderRow' | 'deleteTable';
26
+ type AXTextEditorCommandType = 'undo' | 'redo' | 'bold' | 'italic' | 'underline' | 'strike' | 'spoiler' | 'heading' | 'paragraph' | 'align' | 'direction' | 'color' | 'highlight' | 'fontSize' | 'bulletList' | 'orderedList' | 'superscript' | 'subscript' | 'link' | 'unlink' | 'blockquote' | 'code' | 'codeBlock' | 'horizontalRule' | 'image' | 'video' | 'insertTable' | 'addColumnBefore' | 'addColumnAfter' | 'deleteColumn' | 'addRowBefore' | 'addRowAfter' | 'deleteRow' | 'toggleHeaderRow' | 'deleteTable';
27
27
  interface AXTextEditorFeatures {
28
28
  table?: boolean;
29
29
  image?: boolean;
@@ -34,17 +34,75 @@ interface AXTextEditorFeatures {
34
34
  placeholder?: boolean;
35
35
  }
36
36
  declare const AX_DEFAULT_TEXT_EDITOR_FEATURES: AXTextEditorFeatures;
37
+ /** A person or record offered by the mention suggestion. */
38
+ interface AXTextEditorMentionItem {
39
+ id: string;
40
+ label: string;
41
+ /** HTTP(S), blob, data-image, or root-relative URL. */
42
+ avatar?: string;
43
+ /** Optional icon class used by a custom avatar template. */
44
+ icon?: string;
45
+ }
46
+ /** Draws a mention portrait into `host`. Return a function that removes that view. */
47
+ type AXTextEditorMentionAvatarRenderer = (host: HTMLElement, item: AXTextEditorMentionItem) => void | (() => void);
48
+ interface AXTextEditorMentionRect {
49
+ top: number;
50
+ left: number;
51
+ right: number;
52
+ bottom: number;
53
+ }
54
+ /** Active @-query. `null` means the picker is closed. */
55
+ interface AXTextEditorMentionSuggestion {
56
+ query: string;
57
+ items: readonly AXTextEditorMentionItem[];
58
+ index: number;
59
+ loading: boolean;
60
+ rect: AXTextEditorMentionRect | null;
61
+ }
62
+ /** Runtime source. `items` receives the text typed after the trigger and may resolve later. */
63
+ interface AXTextEditorMentionConfig {
64
+ /** Trigger character. Defaults to `@`. */
65
+ char?: string;
66
+ /** Maximum rows shown. Defaults to 8. */
67
+ limit?: number;
68
+ items: (query: string) => readonly AXTextEditorMentionItem[] | Promise<readonly AXTextEditorMentionItem[]>;
69
+ }
70
+ /**
71
+ * Value of the `mentions` input.
72
+ * An array is filtered locally by label and id. A function replaces that filter.
73
+ * An options object sets the trigger character and limit.
74
+ */
75
+ type AXTextEditorMentionInput = readonly AXTextEditorMentionItem[] | AXTextEditorMentionConfig['items'] | {
76
+ char?: string;
77
+ limit?: number;
78
+ items: readonly AXTextEditorMentionItem[] | AXTextEditorMentionConfig['items'];
79
+ };
80
+ interface AXTextEditorMentionActions {
81
+ apply(item: AXTextEditorMentionItem): void;
82
+ setIndex(index: number): void;
83
+ refresh(): void;
84
+ dismiss(): void;
85
+ }
86
+ /** Bridge between the mention plugin and the editor shell. */
87
+ interface AXTextEditorMentionController {
88
+ getSource(): AXTextEditorMentionConfig | null;
89
+ publish(suggestion: AXTextEditorMentionSuggestion | null): void;
90
+ bind(actions: AXTextEditorMentionActions): void;
91
+ renderMentionAvatar?(host: HTMLElement, item: AXTextEditorMentionItem): void | (() => void);
92
+ }
37
93
  interface AXTextEditorLoadExtensionsOptions {
38
94
  placeholder?: string | (() => string);
39
95
  features?: AXTextEditorFeatures;
40
96
  headingLevels?: AXTextEditorHeadingLevel[];
41
97
  extensions?: Extensions;
98
+ mentions?: AXTextEditorMentionController;
42
99
  }
43
100
  interface AXTextEditorState {
44
101
  bold: boolean;
45
102
  italic: boolean;
46
103
  underline: boolean;
47
104
  strike: boolean;
105
+ spoiler: boolean;
48
106
  code: boolean;
49
107
  codeBlock: boolean;
50
108
  headingLevel: AXTextEditorHeadingLevel | null;
@@ -73,6 +131,8 @@ interface AXTextEditorInitOptions {
73
131
  features?: AXTextEditorFeatures;
74
132
  headingLevels?: AXTextEditorHeadingLevel[];
75
133
  extensions?: Extensions;
134
+ /** Enter starts the next block without the inline marks active at the caret. */
135
+ exitMarksOnEnter?: boolean;
76
136
  editorProps?: _tiptap_core.EditorOptions['editorProps'];
77
137
  /** @deprecated Use `editable: false` instead. */
78
138
  readOnly?: boolean;
@@ -90,6 +150,9 @@ declare module '@tiptap/core' {
90
150
  subscript: {
91
151
  toggleSubscript: () => ReturnType;
92
152
  };
153
+ spoiler: {
154
+ toggleSpoiler: () => ReturnType;
155
+ };
93
156
  axTextEditorFontSize: {
94
157
  setFontSize: (size: string | null) => ReturnType;
95
158
  };
@@ -101,12 +164,17 @@ declare module '@tiptap/core' {
101
164
  }
102
165
  }
103
166
 
104
- declare class AXTextEditor {
167
+ declare class AXTextEditor implements AXTextEditorMentionController {
105
168
  readonly editor: _angular_core.WritableSignal<_tiptap_core.Editor>;
106
169
  readonly state: _angular_core.WritableSignal<AXTextEditorState>;
107
170
  readonly ready: _angular_core.WritableSignal<boolean>;
108
171
  readonly version: _angular_core.WritableSignal<number>;
172
+ readonly mentionSuggestion: _angular_core.WritableSignal<AXTextEditorMentionSuggestion>;
109
173
  private readonly platformId;
174
+ private readonly zone;
175
+ private mentionSource;
176
+ private mentionActions;
177
+ private mentionAvatarRenderer;
110
178
  private destroyed;
111
179
  private applyingContent;
112
180
  init(container: HTMLElement | string, options?: AXTextEditorInitOptions): Promise<void>;
@@ -132,6 +200,8 @@ declare class AXTextEditor {
132
200
  private commandsApi;
133
201
  private getCommandsApi;
134
202
  insertContent(value: AXTextEditorTiptapContent): boolean;
203
+ /** Inserts a `<br>` and keeps the inline marks that were active at the caret. */
204
+ insertHardBreak(): boolean;
135
205
  clearContent(): boolean;
136
206
  insertImage(src: string, alt?: string): void;
137
207
  insertVideo(src: string): void;
@@ -141,6 +211,17 @@ declare class AXTextEditor {
141
211
  toggleHeading(level: AXTextEditorHeadingLevel): void;
142
212
  setTextAlign(align: AXTextEditorTextAlign): void;
143
213
  setTextDirection(direction: AXTextEditorTextDirection): void;
214
+ /** Replaces the mention source. Pass `null` to close the picker and ignore `@`. */
215
+ setMentionSource(source: AXTextEditorMentionConfig | null): void;
216
+ selectMention(item: AXTextEditorMentionItem): void;
217
+ setMentionIndex(index: number): void;
218
+ dismissMention(): void;
219
+ /** Replaces the portrait drawn inside mention chips. Pass `null` for the built-in image. */
220
+ setMentionAvatarRenderer(renderer: AXTextEditorMentionAvatarRenderer | null): void;
221
+ renderMentionAvatar(host: HTMLElement, item: AXTextEditorMentionItem): void | (() => void);
222
+ getSource(): AXTextEditorMentionConfig | null;
223
+ publish(suggestion: AXTextEditorMentionSuggestion | null): void;
224
+ bind(actions: AXTextEditorMentionActions): void;
144
225
  private refreshState;
145
226
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXTextEditor, never>;
146
227
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<any>;
@@ -152,5 +233,18 @@ declare function runTextEditorCommand(editor: AXTextEditorTiptapEditor, command:
152
233
 
153
234
  declare function createTextEditorExtensions(placeholderOrOptions?: string | (() => string) | AXTextEditorLoadExtensionsOptions): Promise<_tiptap_core.AnyExtension[]>;
154
235
 
155
- export { AXTextEditor, AX_DEFAULT_TEXT_EDITOR_FEATURES, AX_EMPTY_TEXT_EDITOR_STATE, AX_TEXT_EDITOR_DEFAULT_BACKGROUND_COLORS, AX_TEXT_EDITOR_DEFAULT_TEXT_COLORS, AX_TEXT_EDITOR_FONT_SIZES, AX_TEXT_EDITOR_FONT_SIZE_TOKEN_VALUES, AX_TEXT_EDITOR_ZOOM_MAX, AX_TEXT_EDITOR_ZOOM_MIN, AX_TEXT_EDITOR_ZOOM_PRESETS, canRunTextEditorCommand, createTextEditorExtensions, isTextEditorCommandActive, runTextEditorCommand };
156
- export type { AXTextEditorCommandAttrs, AXTextEditorCommandType, AXTextEditorFeatures, AXTextEditorFontSize, AXTextEditorFontSizeToken, AXTextEditorHeadingLevel, AXTextEditorInitOptions, AXTextEditorLoadExtensionsOptions, AXTextEditorRecentColor, AXTextEditorState, AXTextEditorTextAlign, AXTextEditorTextDirection, AXTextEditorTiptapChain, AXTextEditorTiptapContent, AXTextEditorTiptapEditor, AXTextEditorTiptapJSON };
236
+ /** Text before the caret. `start` is the index of the trigger inside `text`. */
237
+ declare function findTextEditorMentionQuery(text: string, char?: string): {
238
+ start: number;
239
+ query: string;
240
+ } | null;
241
+ /** Local filter used when `mentions` is an array. */
242
+ declare function filterTextEditorMentionItems(items: readonly AXTextEditorMentionItem[], query: string, limit?: number): AXTextEditorMentionItem[];
243
+ /** Normalizes the `mentions` input into a suggestion source. `null` disables the picker. */
244
+ declare function resolveTextEditorMentions(source: AXTextEditorMentionInput | null | undefined): AXTextEditorMentionConfig | null;
245
+ /** Keeps only URLs that are safe to put in an `<img src>`. */
246
+ declare function textEditorMentionAvatar(value: string | null | undefined): string | null;
247
+ declare function mentionSuggestionsEqual(left: AXTextEditorMentionSuggestion | null, right: AXTextEditorMentionSuggestion | null): boolean;
248
+
249
+ export { AXTextEditor, AX_DEFAULT_TEXT_EDITOR_FEATURES, AX_EMPTY_TEXT_EDITOR_STATE, AX_TEXT_EDITOR_DEFAULT_BACKGROUND_COLORS, AX_TEXT_EDITOR_DEFAULT_TEXT_COLORS, AX_TEXT_EDITOR_FONT_SIZES, AX_TEXT_EDITOR_FONT_SIZE_TOKEN_VALUES, AX_TEXT_EDITOR_ZOOM_MAX, AX_TEXT_EDITOR_ZOOM_MIN, AX_TEXT_EDITOR_ZOOM_PRESETS, canRunTextEditorCommand, createTextEditorExtensions, filterTextEditorMentionItems, findTextEditorMentionQuery, isTextEditorCommandActive, mentionSuggestionsEqual, resolveTextEditorMentions, runTextEditorCommand, textEditorMentionAvatar };
250
+ export type { AXTextEditorCommandAttrs, AXTextEditorCommandType, AXTextEditorFeatures, AXTextEditorFontSize, AXTextEditorFontSizeToken, AXTextEditorHeadingLevel, AXTextEditorInitOptions, AXTextEditorLoadExtensionsOptions, AXTextEditorMentionActions, AXTextEditorMentionAvatarRenderer, AXTextEditorMentionConfig, AXTextEditorMentionController, AXTextEditorMentionInput, AXTextEditorMentionItem, AXTextEditorMentionRect, AXTextEditorMentionSuggestion, AXTextEditorRecentColor, AXTextEditorState, AXTextEditorTextAlign, AXTextEditorTextDirection, AXTextEditorTiptapChain, AXTextEditorTiptapContent, AXTextEditorTiptapEditor, AXTextEditorTiptapJSON };