@phuong-tran-redoc/document-engine-angular 0.0.41 → 0.1.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
@@ -55,6 +55,43 @@ type SelectButton = {
55
55
  };
56
56
  type ToolbarButton = IconButton | SelectButton;
57
57
 
58
+ /**
59
+ * The result a consumer's media picker resolves to.
60
+ *
61
+ * Returned by the async `image.onPick` config hook. The shape is intentionally
62
+ * minimal and presentation-light: `id` is the opaque media reference (inserted as
63
+ * an `image-ref` node when that node is enabled), `url` is the resolved address
64
+ * (used for a plain image fallback), and `alt` is an optional text hint.
65
+ */
66
+ interface MediaResult {
67
+ /** Opaque media id — inserted as an `image-ref` node when available. */
68
+ id: string;
69
+ /** Resolved image URL — used for a plain `<img>` fallback. */
70
+ url: string;
71
+ /** Optional alternative text. */
72
+ alt?: string;
73
+ }
74
+ /**
75
+ * Async hook a consumer provides via `image.onPick` to supply images from its own
76
+ * media library. Resolving `null`/`undefined` (or rejecting) is treated as a
77
+ * cancel — the editor inserts nothing and stays usable.
78
+ */
79
+ type ImagePickHook = () => Promise<MediaResult | null | undefined>;
80
+
81
+ /**
82
+ * Image options plus the optional async `onPick` media-picker hook. When `onPick`
83
+ * is provided, the image insert view delegates selection to the consumer's picker
84
+ * instead of asking for a raw URL.
85
+ */
86
+ type ImageConfig = Partial<ImageOptions> & {
87
+ /**
88
+ * Async hook that supplies an image from the consumer's own media library.
89
+ * When set, the insert view calls it and inserts the result (an `image-ref`
90
+ * node when that node is enabled, else a plain image). Resolving nothing or
91
+ * rejecting is a no-op.
92
+ */
93
+ onPick?: ImagePickHook;
94
+ };
58
95
  /**
59
96
  * Định nghĩa cấu hình đầy đủ cho DocumentEngineKit (Factory của bạn).
60
97
  * Hầu hết các tùy chọn đều là:
@@ -164,10 +201,17 @@ interface DocumentEngineConfig {
164
201
  */
165
202
  blockquote: Partial<BlockquoteOptions> | boolean;
166
203
  /**
167
- * Cấu hình cho @tiptap/extension-image
204
+ * Options for @tiptap/extension-image. May include `onPick` to delegate image
205
+ * selection to the consumer's own media picker.
168
206
  * @default {}
169
207
  */
170
- image?: Partial<ImageOptions> | boolean;
208
+ image?: ImageConfig | boolean;
209
+ /**
210
+ * Enable the URL-free `image-ref` node (`<figure data-block="image-ref" data-image-id>`).
211
+ * Stores an opaque media id; the consumer resolves the real responsive image.
212
+ * @default false
213
+ */
214
+ imageRef?: boolean;
171
215
  /**
172
216
  * Cấu hình cho @tiptap/extension-table (StyledTableKit)
173
217
  * @default false
@@ -1366,9 +1410,13 @@ declare class ColorPickerViewComponent implements BubbleMenuViewContent<Record<s
1366
1410
  }
1367
1411
 
1368
1412
  /**
1369
- * Temporary image insert view for bubble menu
1370
- * Provides URL input for inserting images via link
1371
- * This is a temporary solution until full upload flow is implemented
1413
+ * Image insert view for the bubble menu.
1414
+ *
1415
+ * Two modes:
1416
+ * - When the editor's `image` config supplies an async `onPick` hook, the view
1417
+ * delegates selection to the consumer's media picker and inserts the result
1418
+ * (an `image-ref` node when that node is enabled, else a plain image).
1419
+ * - Otherwise it falls back to the built-in raw-URL input form.
1372
1420
  */
1373
1421
  declare class ImageInsertViewComponent implements BubbleMenuViewContent<Record<string, unknown>> {
1374
1422
  private fb;
@@ -1376,13 +1424,21 @@ declare class ImageInsertViewComponent implements BubbleMenuViewContent<Record<s
1376
1424
  editor?: Editor;
1377
1425
  close?: () => void;
1378
1426
  goBack?: (viewId?: string) => void;
1427
+ /** True while the consumer's `onPick` promise is in flight. */
1428
+ loading: boolean;
1379
1429
  imageForm: _angular_forms.FormGroup<{
1380
1430
  url: _angular_forms.FormControl<string | null>;
1381
1431
  alt: _angular_forms.FormControl<string | null>;
1382
1432
  }>;
1433
+ /** The consumer's media picker, read off the `image` extension options (if any). */
1434
+ private get onPick();
1435
+ /** Whether to show the picker mode (vs the raw-URL fallback form). */
1436
+ get hasPicker(): boolean;
1383
1437
  onActivate(): void;
1384
1438
  canInsert(): boolean;
1385
1439
  insertImage(): void;
1440
+ /** Delegate selection to the consumer's media picker, then insert the result. */
1441
+ pickImage(): Promise<void>;
1386
1442
  cancel(): void;
1387
1443
  static ɵfac: i0.ɵɵFactoryDeclaration<ImageInsertViewComponent, never>;
1388
1444
  static ɵcmp: i0.ɵɵComponentDeclaration<ImageInsertViewComponent, "document-engine-image-insert-view", never, {}, {}, never, never, true, never>;
@@ -1757,4 +1813,4 @@ declare class EditorBubbleMenuComponent implements OnInit, AfterViewInit, OnDest
1757
1813
  }
1758
1814
 
1759
1815
  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_CONTENT_WRAPPER_CLASS, 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 };
1760
- export type { BubbleMenuProps, BubbleMenuViewConfig, BubbleMenuViewContent, BubbleTarget, ButtonType, DocumentEngineConfig, DynamicFieldCategory, DynamicFieldItem, EditorBubbleMenuConfig, EditorHtmlPreprocessor, HeadingLevel, IconButton, OutsideHandler, SelectButton, SelectOption, TableCreateViewData, TemplateItem, ToolbarBubbleMenuConfig, ToolbarButton, ToolbarState };
1816
+ export type { BubbleMenuProps, BubbleMenuViewConfig, BubbleMenuViewContent, BubbleTarget, ButtonType, DocumentEngineConfig, DynamicFieldCategory, DynamicFieldItem, EditorBubbleMenuConfig, EditorHtmlPreprocessor, HeadingLevel, IconButton, ImageConfig, ImagePickHook, MediaResult, OutsideHandler, SelectButton, SelectOption, TableCreateViewData, TemplateItem, ToolbarBubbleMenuConfig, ToolbarButton, ToolbarState };
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@phuong-tran-redoc/document-engine-angular",
3
- "version": "0.0.41",
4
- "type": "commonjs",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
5
  "license": "MIT",
6
- "author": "Duc Phuong (Jack) <tdp99.business@gmail.com>",
6
+ "author": "Realestatedoc (Redoc)",
7
+ "contributors": [
8
+ "Duc Phuong (Jack) <tdp99.business@gmail.com>"
9
+ ],
7
10
  "description": "Angular wrapper for @phuong-tran-redoc/document-engine-core",
8
- "main": "./src/index.js",
9
- "types": "./src/index.d.ts",
10
11
  "keywords": [
11
12
  "angular",
12
13
  "document-engine",
@@ -17,7 +18,7 @@
17
18
  ],
18
19
  "repository": {
19
20
  "type": "git",
20
- "url": "https://github.com/phuong-tran-redoc/document-engine"
21
+ "url": "git+https://github.com/phuong-tran-redoc/document-engine.git"
21
22
  },
22
23
  "publishConfig": {
23
24
  "directory": "../../dist/libs/document-engine-angular",
@@ -26,41 +27,41 @@
26
27
  "dependencies": {
27
28
  "tslib": "^2.3.0",
28
29
  "@floating-ui/dom": "^1.7.4",
29
- "@phuong-tran-redoc/document-engine-core": "workspace:*"
30
+ "@phuong-tran-redoc/document-engine-core": "0.1.0"
30
31
  },
31
32
  "peerDependencies": {
32
33
  "rxjs": "^7.5.0",
33
34
  "lodash-es": "^4.17.10",
34
- "@angular/core": ">=14.0.0 <21.0.0",
35
- "@angular/common": ">=14.0.0 <21.0.0",
36
- "@angular/forms": ">=14.0.0 <21.0.0",
37
- "@angular/platform-browser": ">=14.0.0 <21.0.0",
38
- "@tiptap/core": "^3.10.5",
39
- "@tiptap/extension-blockquote": "^3.10.5",
40
- "@tiptap/extension-bold": "^3.10.5",
41
- "@tiptap/extension-bubble-menu": "^3.10.5",
42
- "@tiptap/extension-code": "^3.10.5",
43
- "@tiptap/extension-code-block": "^3.10.5",
44
- "@tiptap/extension-document": "^3.10.5",
45
- "@tiptap/extension-floating-menu": "^3.10.5",
46
- "@tiptap/extension-hard-break": "^3.10.5",
47
- "@tiptap/extension-heading": "^3.10.5",
48
- "@tiptap/extension-horizontal-rule": "^3.10.5",
49
- "@tiptap/extension-image": "^3.10.5",
50
- "@tiptap/extension-italic": "^3.10.5",
51
- "@tiptap/extension-link": "^3.10.5",
52
- "@tiptap/extension-list": "^3.10.5",
53
- "@tiptap/extension-paragraph": "^3.10.5",
54
- "@tiptap/extension-strike": "^3.10.5",
55
- "@tiptap/extension-subscript": "^3.10.5",
56
- "@tiptap/extension-superscript": "^3.10.5",
57
- "@tiptap/extension-table": "^3.10.5",
58
- "@tiptap/extension-text": "^3.10.5",
59
- "@tiptap/extension-text-align": "^3.10.5",
60
- "@tiptap/extension-text-style": "^3.10.5",
61
- "@tiptap/extension-underline": "^3.10.5",
62
- "@tiptap/extensions": "^3.10.5",
63
- "@tiptap/pm": "^3.10.5"
35
+ "@angular/core": ">=16.0.0 <22.0.0",
36
+ "@angular/common": ">=16.0.0 <22.0.0",
37
+ "@angular/forms": ">=16.0.0 <22.0.0",
38
+ "@angular/platform-browser": ">=16.0.0 <22.0.0",
39
+ "@tiptap/core": "^3.26.0",
40
+ "@tiptap/extension-blockquote": "^3.26.0",
41
+ "@tiptap/extension-bold": "^3.26.0",
42
+ "@tiptap/extension-bubble-menu": "^3.26.0",
43
+ "@tiptap/extension-code": "^3.26.0",
44
+ "@tiptap/extension-code-block": "^3.26.0",
45
+ "@tiptap/extension-document": "^3.26.0",
46
+ "@tiptap/extension-floating-menu": "^3.26.0",
47
+ "@tiptap/extension-hard-break": "^3.26.0",
48
+ "@tiptap/extension-heading": "^3.26.0",
49
+ "@tiptap/extension-horizontal-rule": "^3.26.0",
50
+ "@tiptap/extension-image": "^3.26.0",
51
+ "@tiptap/extension-italic": "^3.26.0",
52
+ "@tiptap/extension-link": "^3.26.0",
53
+ "@tiptap/extension-list": "^3.26.0",
54
+ "@tiptap/extension-paragraph": "^3.26.0",
55
+ "@tiptap/extension-strike": "^3.26.0",
56
+ "@tiptap/extension-subscript": "^3.26.0",
57
+ "@tiptap/extension-superscript": "^3.26.0",
58
+ "@tiptap/extension-table": "^3.26.0",
59
+ "@tiptap/extension-text": "^3.26.0",
60
+ "@tiptap/extension-text-align": "^3.26.0",
61
+ "@tiptap/extension-text-style": "^3.26.0",
62
+ "@tiptap/extension-underline": "^3.26.0",
63
+ "@tiptap/extensions": "^3.26.0",
64
+ "@tiptap/pm": "^3.26.0"
64
65
  },
65
66
  "exports": {
66
67
  "./styles": {
@@ -77,4 +78,4 @@
77
78
  "module": "fesm2022/phuong-tran-redoc-document-engine-angular.mjs",
78
79
  "typings": "index.d.ts",
79
80
  "sideEffects": false
80
- }
81
+ }