@formicoidea/labre-core 0.26.1 → 0.29.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.
Files changed (68) hide show
  1. package/dist/_pkgs/affine-block-database/data-source.d.ts +28 -40
  2. package/dist/_pkgs/affine-block-database/data-source.js +116 -178
  3. package/dist/_pkgs/affine-block-database/database-block.d.ts +10 -3
  4. package/dist/_pkgs/affine-block-database/database-block.js +110 -70
  5. package/dist/_pkgs/affine-block-database/external-data-source.d.ts +69 -0
  6. package/dist/_pkgs/affine-block-database/external-data-source.js +144 -0
  7. package/dist/_pkgs/affine-block-database/index.d.ts +1 -0
  8. package/dist/_pkgs/affine-block-database/index.js +1 -0
  9. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-linked-doc-block.js +6 -7
  10. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/components/embed-synced-doc-card.js +5 -5
  11. package/dist/_pkgs/affine-block-root/configs/toolbar.d.ts +1 -1
  12. package/dist/_pkgs/affine-block-root/edgeless/configs/toolbar/misc.d.ts +18 -0
  13. package/dist/_pkgs/affine-block-root/edgeless/configs/toolbar/more.d.ts +18 -0
  14. package/dist/_pkgs/affine-block-root/edgeless/configs/toolbar/more.js +104 -2
  15. package/dist/_pkgs/affine-block-root/index.d.ts +1 -0
  16. package/dist/_pkgs/affine-block-root/index.js +1 -0
  17. package/dist/_pkgs/affine-block-root/keyboard/keyboard-manager.js +3 -21
  18. package/dist/_pkgs/affine-block-root/keyboard/shortcuts.d.ts +8 -0
  19. package/dist/_pkgs/affine-block-root/keyboard/shortcuts.js +48 -0
  20. package/dist/_pkgs/affine-block-root/view.js +6 -1
  21. package/dist/_pkgs/affine-gfx-link/effects.js +2 -2
  22. package/dist/_pkgs/affine-gfx-link/toolbar/undo-dense-menu.d.ts +3 -0
  23. package/dist/_pkgs/affine-gfx-link/toolbar/undo-dense-menu.js +12 -0
  24. package/dist/_pkgs/affine-gfx-link/toolbar/undo-tool-button.d.ts +18 -0
  25. package/dist/_pkgs/affine-gfx-link/toolbar/undo-tool-button.js +41 -0
  26. package/dist/_pkgs/affine-gfx-link/undo-tool.d.ts +6 -0
  27. package/dist/_pkgs/affine-gfx-link/undo-tool.js +17 -0
  28. package/dist/_pkgs/affine-gfx-link/view.js +4 -2
  29. package/dist/_pkgs/affine-gfx-mindmap/toolbar/mindmap-tool-button.js +13 -2
  30. package/dist/_pkgs/affine-gfx-mindmap/toolbar/senior-tool.d.ts +12 -2
  31. package/dist/_pkgs/affine-gfx-mindmap/toolbar/senior-tool.js +62 -11
  32. package/dist/_pkgs/affine-gfx-mindmap/view.d.ts +13 -2
  33. package/dist/_pkgs/affine-gfx-mindmap/view.js +24 -5
  34. package/dist/_pkgs/affine-shared/services/index.d.ts +2 -0
  35. package/dist/_pkgs/affine-shared/services/index.js +2 -0
  36. package/dist/_pkgs/affine-shared/services/keymap-override-service.d.ts +15 -0
  37. package/dist/_pkgs/affine-shared/services/keymap-override-service.js +26 -0
  38. package/dist/_pkgs/affine-shared/services/linked-doc-content-service.d.ts +42 -0
  39. package/dist/_pkgs/affine-shared/services/linked-doc-content-service.js +47 -0
  40. package/dist/_pkgs/affine-widget-edgeless-selected-rect/edgeless-element-link.d.ts +29 -0
  41. package/dist/_pkgs/affine-widget-edgeless-selected-rect/edgeless-element-link.js +233 -0
  42. package/dist/_pkgs/affine-widget-edgeless-selected-rect/effects.js +2 -0
  43. package/dist/_pkgs/affine-widget-edgeless-selected-rect/spec.d.ts +1 -0
  44. package/dist/_pkgs/affine-widget-edgeless-selected-rect/spec.js +2 -0
  45. package/dist/_pkgs/affine-widget-edgeless-selected-rect/view.js +2 -1
  46. package/dist/_pkgs/data-view/core/data-source/base.d.ts +6 -0
  47. package/dist/_pkgs/data-view/core/data-source/base.js +6 -0
  48. package/dist/_pkgs/std/extension/index.d.ts +1 -0
  49. package/dist/_pkgs/std/extension/index.js +1 -0
  50. package/dist/_pkgs/std/extension/shortcut.d.ts +69 -0
  51. package/dist/_pkgs/std/extension/shortcut.js +106 -0
  52. package/dist/_pkgs/std/gfx/model/surface/element-model.d.ts +7 -0
  53. package/dist/_pkgs/std/gfx/model/surface/element-model.js +24 -1
  54. package/dist/_pkgs/std/identifier.d.ts +7 -0
  55. package/dist/_pkgs/std/identifier.js +6 -0
  56. package/dist/_pkgs/std/inline/components/v-element.js +5 -2
  57. package/dist/extensions/view.js +5 -2
  58. package/dist/flags.d.ts +1 -1
  59. package/dist/flags.js +4 -1
  60. package/dist/shortcuts.d.ts +24 -0
  61. package/dist/shortcuts.js +39 -0
  62. package/package.json +5 -1
  63. package/dist/_pkgs/affine-gfx-link/link-tool.d.ts +0 -1
  64. package/dist/_pkgs/affine-gfx-link/link-tool.js +0 -11
  65. package/dist/_pkgs/affine-gfx-link/toolbar/link-dense-menu.d.ts +0 -2
  66. package/dist/_pkgs/affine-gfx-link/toolbar/link-dense-menu.js +0 -26
  67. package/dist/_pkgs/affine-gfx-link/toolbar/link-tool-button.d.ts +0 -10
  68. package/dist/_pkgs/affine-gfx-link/toolbar/link-tool-button.js +0 -84
@@ -100,6 +100,13 @@ export declare abstract class GfxPrimitiveElementModel<Props extends BaseElement
100
100
  accessor externalXYWH: SerializedXYWH | undefined;
101
101
  accessor hidden: boolean;
102
102
  accessor index: string;
103
+ /**
104
+ * Minimal link target attached to the element. At most one is set.
105
+ * Opaque to the framework; an affine widget shows a hover arrow that
106
+ * opens the doc ({@link linkedDocId}) or the URL ({@link externalLink}).
107
+ */
108
+ accessor externalLink: string | undefined;
109
+ accessor linkedDocId: string | undefined;
103
110
  accessor lockedBySelf: boolean | undefined;
104
111
  accessor opacity: number;
105
112
  accessor responseExtension: [number, number];
@@ -55,6 +55,12 @@ let GfxPrimitiveElementModel = (() => {
55
55
  let _index_decorators;
56
56
  let _index_initializers = [];
57
57
  let _index_extraInitializers = [];
58
+ let _externalLink_decorators;
59
+ let _externalLink_initializers = [];
60
+ let _externalLink_extraInitializers = [];
61
+ let _linkedDocId_decorators;
62
+ let _linkedDocId_initializers = [];
63
+ let _linkedDocId_extraInitializers = [];
58
64
  let _lockedBySelf_decorators;
59
65
  let _lockedBySelf_initializers = [];
60
66
  let _lockedBySelf_extraInitializers = [];
@@ -76,6 +82,8 @@ let GfxPrimitiveElementModel = (() => {
76
82
  }), local()];
77
83
  _hidden_decorators = [field(false)];
78
84
  _index_decorators = [field()];
85
+ _externalLink_decorators = [field()];
86
+ _linkedDocId_decorators = [field()];
79
87
  _lockedBySelf_decorators = [field()];
80
88
  _opacity_decorators = [local()];
81
89
  _responseExtension_decorators = [local()];
@@ -84,6 +92,8 @@ let GfxPrimitiveElementModel = (() => {
84
92
  __esDecorate(this, null, _externalXYWH_decorators, { kind: "accessor", name: "externalXYWH", static: false, private: false, access: { has: obj => "externalXYWH" in obj, get: obj => obj.externalXYWH, set: (obj, value) => { obj.externalXYWH = value; } }, metadata: _metadata }, _externalXYWH_initializers, _externalXYWH_extraInitializers);
85
93
  __esDecorate(this, null, _hidden_decorators, { kind: "accessor", name: "hidden", static: false, private: false, access: { has: obj => "hidden" in obj, get: obj => obj.hidden, set: (obj, value) => { obj.hidden = value; } }, metadata: _metadata }, _hidden_initializers, _hidden_extraInitializers);
86
94
  __esDecorate(this, null, _index_decorators, { kind: "accessor", name: "index", static: false, private: false, access: { has: obj => "index" in obj, get: obj => obj.index, set: (obj, value) => { obj.index = value; } }, metadata: _metadata }, _index_initializers, _index_extraInitializers);
95
+ __esDecorate(this, null, _externalLink_decorators, { kind: "accessor", name: "externalLink", static: false, private: false, access: { has: obj => "externalLink" in obj, get: obj => obj.externalLink, set: (obj, value) => { obj.externalLink = value; } }, metadata: _metadata }, _externalLink_initializers, _externalLink_extraInitializers);
96
+ __esDecorate(this, null, _linkedDocId_decorators, { kind: "accessor", name: "linkedDocId", static: false, private: false, access: { has: obj => "linkedDocId" in obj, get: obj => obj.linkedDocId, set: (obj, value) => { obj.linkedDocId = value; } }, metadata: _metadata }, _linkedDocId_initializers, _linkedDocId_extraInitializers);
87
97
  __esDecorate(this, null, _lockedBySelf_decorators, { kind: "accessor", name: "lockedBySelf", static: false, private: false, access: { has: obj => "lockedBySelf" in obj, get: obj => obj.lockedBySelf, set: (obj, value) => { obj.lockedBySelf = value; } }, metadata: _metadata }, _lockedBySelf_initializers, _lockedBySelf_extraInitializers);
88
98
  __esDecorate(this, null, _opacity_decorators, { kind: "accessor", name: "opacity", static: false, private: false, access: { has: obj => "opacity" in obj, get: obj => obj.opacity, set: (obj, value) => { obj.opacity = value; } }, metadata: _metadata }, _opacity_initializers, _opacity_extraInitializers);
89
99
  __esDecorate(this, null, _responseExtension_decorators, { kind: "accessor", name: "responseExtension", static: false, private: false, access: { has: obj => "responseExtension" in obj, get: obj => obj.responseExtension, set: (obj, value) => { obj.responseExtension = value; } }, metadata: _metadata }, _responseExtension_initializers, _responseExtension_extraInitializers);
@@ -162,7 +172,9 @@ let GfxPrimitiveElementModel = (() => {
162
172
  this.#externalXYWH_accessor_storage = (__runInitializers(this, _display_extraInitializers), __runInitializers(this, _externalXYWH_initializers, undefined));
163
173
  this.#hidden_accessor_storage = (__runInitializers(this, _externalXYWH_extraInitializers), __runInitializers(this, _hidden_initializers, false));
164
174
  this.#index_accessor_storage = (__runInitializers(this, _hidden_extraInitializers), __runInitializers(this, _index_initializers, void 0));
165
- this.#lockedBySelf_accessor_storage = (__runInitializers(this, _index_extraInitializers), __runInitializers(this, _lockedBySelf_initializers, false));
175
+ this.#externalLink_accessor_storage = (__runInitializers(this, _index_extraInitializers), __runInitializers(this, _externalLink_initializers, undefined));
176
+ this.#linkedDocId_accessor_storage = (__runInitializers(this, _externalLink_extraInitializers), __runInitializers(this, _linkedDocId_initializers, undefined));
177
+ this.#lockedBySelf_accessor_storage = (__runInitializers(this, _linkedDocId_extraInitializers), __runInitializers(this, _lockedBySelf_initializers, false));
166
178
  this.#opacity_accessor_storage = (__runInitializers(this, _lockedBySelf_extraInitializers), __runInitializers(this, _opacity_initializers, 1));
167
179
  this.#responseExtension_accessor_storage = (__runInitializers(this, _opacity_extraInitializers), __runInitializers(this, _responseExtension_initializers, [0, 0]));
168
180
  this.#seed_accessor_storage = (__runInitializers(this, _responseExtension_extraInitializers), __runInitializers(this, _seed_initializers, void 0));
@@ -294,6 +306,17 @@ let GfxPrimitiveElementModel = (() => {
294
306
  #index_accessor_storage;
295
307
  get index() { return this.#index_accessor_storage; }
296
308
  set index(value) { this.#index_accessor_storage = value; }
309
+ #externalLink_accessor_storage;
310
+ /**
311
+ * Minimal link target attached to the element. At most one is set.
312
+ * Opaque to the framework; an affine widget shows a hover arrow that
313
+ * opens the doc ({@link linkedDocId}) or the URL ({@link externalLink}).
314
+ */
315
+ get externalLink() { return this.#externalLink_accessor_storage; }
316
+ set externalLink(value) { this.#externalLink_accessor_storage = value; }
317
+ #linkedDocId_accessor_storage;
318
+ get linkedDocId() { return this.#linkedDocId_accessor_storage; }
319
+ set linkedDocId(value) { this.#linkedDocId_accessor_storage = value; }
297
320
  #lockedBySelf_accessor_storage;
298
321
  get lockedBySelf() { return this.#lockedBySelf_accessor_storage; }
299
322
  set lockedBySelf(value) { this.#lockedBySelf_accessor_storage = value; }
@@ -1,6 +1,7 @@
1
1
  import type { Command } from './command/index.js';
2
2
  import type { EventOptions, UIEventHandler } from './event/index.js';
3
3
  import type { BlockService, LifeCycleWatcher } from './extension/index.js';
4
+ import type { ShortcutConflictReporter, ShortcutDescriptor, ShortcutOverrides } from './extension/shortcut.js';
4
5
  import type { BlockStdScope } from './scope/index.js';
5
6
  import type { BlockViewType } from './spec/type.js';
6
7
  export declare const BlockServiceIdentifier: import("../global/di/types.js").ServiceIdentifier<BlockService> & (<U extends BlockService = BlockService>(variant: import("../global/di/types.js").ServiceVariant) => import("../global/di/types.js").ServiceIdentifier<U>);
@@ -27,3 +28,9 @@ export declare const KeymapIdentifier: import("../global/di/types.js").ServiceId
27
28
  getter: (std: BlockStdScope) => Record<string, UIEventHandler>;
28
29
  options?: EventOptions;
29
30
  }>(variant: import("../global/di/types.js").ServiceVariant) => import("../global/di/types.js").ServiceIdentifier<U>);
31
+ /** Multi-instance: one registered {@link ShortcutDescriptor} per impl. */
32
+ export declare const ShortcutIdentifier: import("../global/di/types.js").ServiceIdentifier<ShortcutDescriptor> & (<U extends ShortcutDescriptor = ShortcutDescriptor>(variant: import("../global/di/types.js").ServiceVariant) => import("../global/di/types.js").ServiceIdentifier<U>);
33
+ /** Host-injected rebinding table (see `KeymapOverrideExtension`). */
34
+ export declare const ShortcutOverrideIdentifier: import("../global/di/types.js").ServiceIdentifier<ShortcutOverrides> & (<U extends ShortcutOverrides = ShortcutOverrides>(variant: import("../global/di/types.js").ServiceVariant) => import("../global/di/types.js").ServiceIdentifier<U>);
35
+ /** Host-injected sink for reported combo conflicts. */
36
+ export declare const ShortcutConflictReporterIdentifier: import("../global/di/types.js").ServiceIdentifier<ShortcutConflictReporter> & (<U extends ShortcutConflictReporter = ShortcutConflictReporter>(variant: import("../global/di/types.js").ServiceVariant) => import("../global/di/types.js").ServiceIdentifier<U>);
@@ -8,3 +8,9 @@ export const WidgetViewIdentifier = createIdentifier('WidgetView');
8
8
  export const LifeCycleWatcherIdentifier = createIdentifier('LifeCycleWatcher');
9
9
  export const StdIdentifier = createIdentifier('Std');
10
10
  export const KeymapIdentifier = createIdentifier('Keymap');
11
+ /** Multi-instance: one registered {@link ShortcutDescriptor} per impl. */
12
+ export const ShortcutIdentifier = createIdentifier('Shortcut');
13
+ /** Host-injected rebinding table (see `KeymapOverrideExtension`). */
14
+ export const ShortcutOverrideIdentifier = createIdentifier('ShortcutOverride');
15
+ /** Host-injected sink for reported combo conflicts. */
16
+ export const ShortcutConflictReporterIdentifier = createIdentifier('ShortcutConflictReporter');
@@ -90,9 +90,12 @@ let VElement = (() => {
90
90
  }
91
91
  async getUpdateComplete() {
92
92
  const result = await super.getUpdateComplete();
93
+ // The inner span (and its child) may not be in the DOM yet when this is
94
+ // awaited mid mount/unmount — guard instead of throwing on `null`.
93
95
  const span = this.querySelector('[data-v-element="true"]');
94
- const el = span.firstElementChild;
95
- await el.updateComplete;
96
+ const el = span?.firstElementChild;
97
+ if (el)
98
+ await el.updateComplete;
96
99
  const vTexts = Array.from(this.querySelectorAll('v-text'));
97
100
  await Promise.all(vTexts.map(vText => vText.updateComplete));
98
101
  return result;
@@ -27,7 +27,7 @@ import { BrushViewExtension } from '../_pkgs/affine-gfx-brush/view.js';
27
27
  import { ConnectorViewExtension } from '../_pkgs/affine-gfx-connector/view.js';
28
28
  import { GroupViewExtension } from '../_pkgs/affine-gfx-group/view.js';
29
29
  import { LinkViewExtension as GfxLinkViewExtension } from '../_pkgs/affine-gfx-link/view.js';
30
- import { MindmapRenderViewExtension, MindmapToolViewExtension, OtherToolViewExtension, } from '../_pkgs/affine-gfx-mindmap/view.js';
30
+ import { MediaToolViewExtension, MindmapRenderViewExtension, MindmapToolViewExtension, TextToolViewExtension, } from '../_pkgs/affine-gfx-mindmap/view.js';
31
31
  import { NoteViewExtension as GfxNoteViewExtension } from '../_pkgs/affine-gfx-note/view.js';
32
32
  import { PointerViewExtension } from '../_pkgs/affine-gfx-pointer/view.js';
33
33
  import { ShapeViewExtension } from '../_pkgs/affine-gfx-shape/view.js';
@@ -69,11 +69,14 @@ export function getInternalViewExtensions(flags) {
69
69
  PointerViewExtension,
70
70
  GfxNoteViewExtension,
71
71
  ...(on('brush') ? [BrushViewExtension] : []),
72
+ // Standalone text / add-file senior buttons, placed right after pen/eraser
73
+ // (registration order = senior-row order for the default order group).
74
+ ...(on('edgeless-text') ? [TextToolViewExtension] : []),
75
+ ...(on('edgeless-media') ? [MediaToolViewExtension] : []),
72
76
  ShapeViewExtension,
73
77
  // Mindmap rendering is always on; the flags gate only the senior buttons.
74
78
  MindmapRenderViewExtension,
75
79
  ...(on('mindmap') ? [MindmapToolViewExtension] : []),
76
- ...(on('other') ? [OtherToolViewExtension] : []),
77
80
  ConnectorViewExtension,
78
81
  GroupViewExtension,
79
82
  TextViewExtension,
package/dist/flags.d.ts CHANGED
@@ -23,7 +23,7 @@
23
23
  * - `latex` controls both the latex block and inline latex.
24
24
  * - `frame` also controls the frame panel fragment.
25
25
  */
26
- export declare const OPTIONAL_BLOCKS: readonly ["attachment", "bookmark", "callout", "code", "data-view", "database", "divider", "edgeless-text", "embed", "embed-doc", "frame", "image", "latex", "list", "surface-ref", "table", "brush", "mindmap", "other", "template", "link"];
26
+ export declare const OPTIONAL_BLOCKS: readonly ["attachment", "bookmark", "callout", "code", "data-view", "database", "divider", "edgeless-text", "embed", "embed-doc", "frame", "image", "latex", "list", "surface-ref", "table", "brush", "mindmap", "edgeless-text", "edgeless-media", "template", "link"];
27
27
  export type OptionalBlock = (typeof OPTIONAL_BLOCKS)[number];
28
28
  /** Map of optional block -> enabled. Missing keys default to enabled. */
29
29
  export type BlockFlags = Partial<Record<OptionalBlock, boolean>>;
package/dist/flags.js CHANGED
@@ -43,7 +43,10 @@ export const OPTIONAL_BLOCKS = [
43
43
  // gfx modules
44
44
  'brush',
45
45
  'mindmap',
46
- 'other',
46
+ // Standalone text / add-file tools, promoted out of the former "Others"
47
+ // senior submenu (each individually toggleable).
48
+ 'edgeless-text',
49
+ 'edgeless-media',
47
50
  'template',
48
51
  'link',
49
52
  ];
@@ -0,0 +1,24 @@
1
+ import type { ShortcutDescriptor } from './_pkgs/std/index.js';
2
+ import { type BlockFlags, type OptionalBlock } from './flags.js';
3
+ /**
4
+ * Manifest view of a shortcut: the metadata a host "Shortcuts" settings panel
5
+ * needs, without the runtime `handler`.
6
+ */
7
+ export type ShortcutManifestEntry = Omit<ShortcutDescriptor, 'handler'>;
8
+ interface FrameworkShortcutGroup {
9
+ owner: OptionalBlock;
10
+ shortcuts: ShortcutDescriptor[];
11
+ }
12
+ /**
13
+ * Pure aggregator (exported for testing): core shortcuts plus the shortcuts of
14
+ * every framework group whose flag is enabled.
15
+ */
16
+ export declare function buildShortcutManifest(core: ShortcutDescriptor[], groups: FrameworkShortcutGroup[], flags?: BlockFlags): ShortcutManifestEntry[];
17
+ /**
18
+ * The enumerable shortcut manifest for a given flag set: core shortcuts plus
19
+ * the shortcuts contributed by the currently-enabled frameworks. Enumerable
20
+ * without an editor instance (for a settings panel). Mirrors the flag gating of
21
+ * `getInternalViewExtensions`.
22
+ */
23
+ export declare function getShortcutManifest(flags?: BlockFlags): ShortcutManifestEntry[];
24
+ export {};
@@ -0,0 +1,39 @@
1
+ import { coreShortcuts } from './_pkgs/affine-block-root/index.js';
2
+ import { isBlockEnabled } from './flags.js';
3
+ /**
4
+ * Per-framework shortcut contributions. A framework that adds shortcuts lists
5
+ * them here (manifest) AND registers `ShortcutExtension(...)` in its view
6
+ * (runtime binding); both are gated by its flag. No framework ships shortcuts
7
+ * yet — the seam is ready and the manifest currently returns core only.
8
+ */
9
+ const FRAMEWORK_SHORTCUT_GROUPS = [];
10
+ const toEntry = (d) => ({
11
+ id: d.id,
12
+ labelKey: d.labelKey,
13
+ defaultKeys: d.defaultKeys,
14
+ scope: d.scope,
15
+ owner: d.owner,
16
+ when: d.when,
17
+ });
18
+ /**
19
+ * Pure aggregator (exported for testing): core shortcuts plus the shortcuts of
20
+ * every framework group whose flag is enabled.
21
+ */
22
+ export function buildShortcutManifest(core, groups, flags) {
23
+ const entries = core.map(toEntry);
24
+ for (const { owner, shortcuts } of groups) {
25
+ if (isBlockEnabled(flags, owner)) {
26
+ entries.push(...shortcuts.map(toEntry));
27
+ }
28
+ }
29
+ return entries;
30
+ }
31
+ /**
32
+ * The enumerable shortcut manifest for a given flag set: core shortcuts plus
33
+ * the shortcuts contributed by the currently-enabled frameworks. Enumerable
34
+ * without an editor instance (for a settings panel). Mirrors the flag gating of
35
+ * `getInternalViewExtensions`.
36
+ */
37
+ export function getShortcutManifest(flags) {
38
+ return buildShortcutManifest(coreShortcuts, FRAMEWORK_SHORTCUT_GROUPS, flags);
39
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formicoidea/labre-core",
3
3
  "description": "Labre editor — the full BlockSuite-derived editor as one package.",
4
- "version": "0.26.1",
4
+ "version": "0.29.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "author": "lajola",
@@ -810,6 +810,10 @@
810
810
  "types": "./dist/flags.d.ts",
811
811
  "import": "./dist/flags.js"
812
812
  },
813
+ "./shortcuts": {
814
+ "types": "./dist/shortcuts.d.ts",
815
+ "import": "./dist/shortcuts.js"
816
+ },
813
817
  "./model": {
814
818
  "types": "./dist/model/index.d.ts",
815
819
  "import": "./dist/model/index.js"
@@ -1 +0,0 @@
1
- export declare const linkQuickTool: import("../store/index.js").ExtensionType;
@@ -1,11 +0,0 @@
1
- import { QuickToolExtension } from '../affine-widget-edgeless-toolbar/index.js';
2
- import { html } from 'lit';
3
- import { buildLinkDenseMenu } from './toolbar/link-dense-menu';
4
- export const linkQuickTool = QuickToolExtension('link', ({ block, gfx }) => {
5
- return {
6
- content: html `<edgeless-link-tool-button
7
- .edgeless=${block}
8
- ></edgeless-link-tool-button>`,
9
- menu: buildLinkDenseMenu(block, gfx),
10
- };
11
- });
@@ -1,2 +0,0 @@
1
- import type { DenseMenuBuilder } from '../../affine-widget-edgeless-toolbar/index.js';
2
- export declare const buildLinkDenseMenu: DenseMenuBuilder;
@@ -1,26 +0,0 @@
1
- import { insertLinkByQuickSearchCommand } from '../../affine-block-bookmark/index.js';
2
- import { menu } from '../../affine-components/context-menu/index.js';
3
- import { LinkIcon } from '../../affine-components/icons/index.js';
4
- import { TelemetryProvider } from '../../affine-shared/services/index.js';
5
- export const buildLinkDenseMenu = edgeless => menu.action({
6
- name: 'Link',
7
- prefix: LinkIcon,
8
- select: () => {
9
- const [_, { insertedLinkType }] = edgeless.std.command.exec(insertLinkByQuickSearchCommand);
10
- insertedLinkType
11
- ?.then(type => {
12
- const flavour = type?.flavour;
13
- if (!flavour)
14
- return;
15
- edgeless.std
16
- .getOptional(TelemetryProvider)
17
- ?.track('CanvasElementAdded', {
18
- control: 'toolbar:general',
19
- page: 'whiteboard editor',
20
- module: 'toolbar',
21
- type: flavour.split(':')[1],
22
- });
23
- })
24
- .catch(console.error);
25
- },
26
- });
@@ -1,10 +0,0 @@
1
- import { DefaultTool } from '../../affine-block-surface/index.js';
2
- import { LitElement } from 'lit';
3
- declare const EdgelessLinkToolButton_base: typeof LitElement & import("../../global/utils/types.js").Constructor<import("../../affine-widget-edgeless-toolbar/index.js").QuickToolMixinClass>;
4
- export declare class EdgelessLinkToolButton extends EdgelessLinkToolButton_base {
5
- static styles: import("lit").CSSResult;
6
- type: typeof DefaultTool;
7
- private _onClick;
8
- render(): import("lit-html").TemplateResult<1>;
9
- }
10
- export {};
@@ -1,84 +0,0 @@
1
- import { insertLinkByQuickSearchCommand } from '../../affine-block-bookmark/index.js';
2
- import { insertEmbedCard } from '../../affine-block-embed/index.js';
3
- import { DefaultTool } from '../../affine-block-surface/index.js';
4
- import { toggleEmbedCardCreateModal } from '../../affine-components/embed-card-modal/index.js';
5
- import { LinkIcon } from '../../affine-components/icons/index.js';
6
- import { TelemetryProvider } from '../../affine-shared/services/index.js';
7
- import { QuickToolMixin } from '../../affine-widget-edgeless-toolbar/index.js';
8
- import { GfxControllerIdentifier } from '../../std/gfx/index.js';
9
- import { css, html, LitElement } from 'lit';
10
- export class EdgelessLinkToolButton extends QuickToolMixin(LitElement) {
11
- constructor() {
12
- super(...arguments);
13
- this.type = DefaultTool;
14
- }
15
- static { this.styles = css `
16
- .link-icon,
17
- .link-icon > svg {
18
- width: 24px;
19
- height: 24px;
20
- }
21
- `; }
22
- _onClick() {
23
- const [success, { insertedLinkType }] = this.edgeless.std.command.exec(insertLinkByQuickSearchCommand);
24
- if (!success) {
25
- // fallback to create a bookmark block with input modal
26
- toggleEmbedCardCreateModal(this.edgeless.host, 'Links', 'The added link will be displayed as a card view.', {
27
- mode: 'edgeless',
28
- onSave: url => {
29
- insertEmbedCard(this.edgeless.std, {
30
- flavour: 'affine:bookmark',
31
- targetStyle: 'vertical',
32
- props: { url },
33
- });
34
- },
35
- }, ({ mode }) => {
36
- if (mode === 'edgeless') {
37
- const gfx = this.edgeless.std.get(GfxControllerIdentifier);
38
- gfx.tool.setTool(DefaultTool);
39
- }
40
- }).catch(console.error);
41
- return;
42
- }
43
- insertedLinkType
44
- ?.then(type => {
45
- const flavour = type?.flavour;
46
- if (!flavour)
47
- return;
48
- this.edgeless.std
49
- .getOptional(TelemetryProvider)
50
- ?.track('CanvasElementAdded', {
51
- control: 'toolbar:general',
52
- page: 'whiteboard editor',
53
- module: 'toolbar',
54
- segment: 'toolbar',
55
- type: flavour.split(':')[1],
56
- });
57
- this.edgeless.std
58
- .getOptional(TelemetryProvider)
59
- ?.track('LinkedDocCreated', {
60
- control: 'links',
61
- page: 'whiteboard editor',
62
- module: 'edgeless toolbar',
63
- segment: 'whiteboard',
64
- type: flavour.split(':')[1],
65
- other: 'existing doc',
66
- });
67
- })
68
- .catch(console.error);
69
- }
70
- render() {
71
- return html `<edgeless-tool-icon-button
72
- .iconContainerPadding="${6}"
73
- .tooltip="${html `<affine-tooltip-content-with-shortcut
74
- data-tip="${'Link'}"
75
- data-shortcut="${'@'}"
76
- ></affine-tooltip-content-with-shortcut>`}"
77
- .tooltipOffset=${17}
78
- class="edgeless-link-tool-button"
79
- @click=${this._onClick}
80
- >
81
- <span class="link-icon">${LinkIcon}</span>
82
- </edgeless-tool-icon-button>`;
83
- }
84
- }