@mohamedatia/fly-design-system 2.15.1 → 2.15.3

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.
@@ -14,6 +14,8 @@ import { Markdown } from '@tiptap/markdown';
14
14
  import TaskList from '@tiptap/extension-task-list';
15
15
  import TaskItem from '@tiptap/extension-task-item';
16
16
  import { TiptapEditorDirective } from 'ngx-tiptap';
17
+ import { Link } from '@tiptap/extension-link';
18
+ import { registerCustomProtocol } from 'linkifyjs';
17
19
  import { switchMap, debounceTime, distinctUntilChanged, filter } from 'rxjs/operators';
18
20
  import Cropper from 'cropperjs';
19
21
 
@@ -2438,6 +2440,87 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImpor
2438
2440
  args: ['document:keydown.escape']
2439
2441
  }] } });
2440
2442
 
2443
+ /**
2444
+ * Centralised registration + a non-resetting Link extension for the platform's
2445
+ * ``flyos:`` entity deep-link scheme.
2446
+ *
2447
+ * WHY THIS EXISTS — Tiptap's stock ``@tiptap/extension-link`` couples two
2448
+ * concerns onto its ``protocols`` option:
2449
+ * 1. ``isAllowedUri`` allow-listing — read directly from ``options.protocols``
2450
+ * so a ``flyos:`` href survives instead of being blanked to ``href=""``.
2451
+ * 2. linkify autolink scheme registration — done by calling linkify's global
2452
+ * ``registerCustomProtocol`` inside the mark's ``onCreate``, and undone by
2453
+ * ``reset()`` inside ``onDestroy``.
2454
+ *
2455
+ * linkify is a process-wide singleton that only accepts scheme registration
2456
+ * *before* its first tokenisation. So with stock Link the SECOND editor to mount
2457
+ * after linkify has initialised re-calls ``registerCustomProtocol`` and linkify
2458
+ * logs:
2459
+ * ``linkifyjs: already initialized - will not register custom scheme "flyos" …``
2460
+ * and worse, every editor's ``onDestroy`` ``reset()`` wipes the scheme registry
2461
+ * for all other live editors.
2462
+ *
2463
+ * {@link FlyosLink} keeps concern (1) — ``protocols`` stays set, so hrefs and
2464
+ * ``getMarkdown()`` round-trips survive — but drops the per-editor register
2465
+ * /reset of (2). Registration is hoisted to a single {@link registerFlyosProtocol}
2466
+ * call made once, before any editor, so the scheme is registered exactly once
2467
+ * and never torn down.
2468
+ *
2469
+ * See ``skills/cross-app-deep-linking.md``.
2470
+ */
2471
+ /** The platform entity deep-link URI scheme (``flyos:<appId>.<entity>/<id>``). */
2472
+ const FLYOS_PROTOCOL = 'flyos';
2473
+ let registered = false;
2474
+ /**
2475
+ * Register the ``flyos`` scheme with linkify exactly once. MUST run before any
2476
+ * Tiptap editor tokenises (i.e. at app bootstrap) because linkify rejects — and
2477
+ * warns about — scheme registration after its singleton initialises.
2478
+ *
2479
+ * Idempotent: repeat calls are no-ops, so it is safe to also call defensively
2480
+ * from an editor's constructor for consumers that don't own a shared bootstrap
2481
+ * (e.g. a federated remote that mounts {@link FlyMarkdownEditorComponent}
2482
+ * standalone).
2483
+ */
2484
+ function registerFlyosProtocol() {
2485
+ if (registered)
2486
+ return;
2487
+ registered = true;
2488
+ registerCustomProtocol(FLYOS_PROTOCOL);
2489
+ }
2490
+ /**
2491
+ * Drop-in replacement for ``@tiptap/extension-link``'s ``Link`` that keeps the
2492
+ * ``flyos`` href allow-list but does NOT register the scheme per-editor or
2493
+ * ``reset()`` linkify on teardown — see the module header for the full
2494
+ * rationale. Defaults ``openOnClick`` off because ``flyos:`` is non-routable in
2495
+ * a browser; surfaces that can launch in-shell wire their own
2496
+ * ``editorProps.handleClick`` (see ``flyosEditorHandleClick``).
2497
+ *
2498
+ * Keeps the mark name ``link`` so StarterKit's link commands (``setLink`` /
2499
+ * ``toggleLink`` / ``isActive('link')``) and markdown serialisation keep
2500
+ * working — pair it with ``StarterKit.configure({ link: false })``.
2501
+ */
2502
+ const FlyosLink = Link.extend({
2503
+ addOptions() {
2504
+ // `parent` (the base Link's addOptions) is always defined for Link.extend;
2505
+ // the cast restores the required LinkOptions fields the optional `?.` drops.
2506
+ return {
2507
+ ...this.parent?.(),
2508
+ openOnClick: false,
2509
+ protocols: [FLYOS_PROTOCOL],
2510
+ };
2511
+ },
2512
+ // Scheme registration is centralised in registerFlyosProtocol(); skipping the
2513
+ // stock per-editor registerCustomProtocol() is what silences linkify's
2514
+ // "already initialized" warning on the 2nd+ concurrent editor.
2515
+ // eslint-disable-next-line @typescript-eslint/no-empty-function -- intentional no-op override
2516
+ onCreate() { },
2517
+ // Stock Link calls linkify reset() here, which would un-register `flyos`
2518
+ // (and every other custom scheme) for every other live editor. Registration
2519
+ // is process-wide and owned by registerFlyosProtocol() — never torn down.
2520
+ // eslint-disable-next-line @typescript-eslint/no-empty-function -- intentional no-op override
2521
+ onDestroy() { },
2522
+ });
2523
+
2441
2524
  const ENTITY_LINK_LAUNCHER = new InjectionToken('ENTITY_LINK_LAUNCHER');
2442
2525
  const MARKDOWN_TOOLBAR_PRESETS = {
2443
2526
  full: [
@@ -2528,14 +2611,19 @@ class FlyMarkdownEditorComponent {
2528
2611
  }, ...(ngDevMode ? [{ debugName: "toolbarItems" }] : /* istanbul ignore next */ []));
2529
2612
  editor;
2530
2613
  constructor() {
2614
+ // Register the `flyos` scheme once, before this editor tokenises. Idempotent
2615
+ // — covered by the shell bootstrap in the desktop host, but called here too
2616
+ // so a standalone consumer (e.g. a federated remote) is self-sufficient.
2617
+ registerFlyosProtocol();
2531
2618
  this.editor = new Editor({
2532
2619
  extensions: [
2533
- StarterKit.configure({
2534
- // Whitelist the platform deep-link scheme so Tiptap keeps the href
2535
- // instead of blanking it; openOnClick false because flyos: is
2536
- // non-routable handleClick launches in-shell below.
2537
- link: { openOnClick: false, protocols: ['flyos'] },
2538
- }),
2620
+ // FlyosLink replaces StarterKit's bundled link: it keeps the `flyos:`
2621
+ // href whitelist (so the href isn't blanked) but skips the per-editor
2622
+ // linkify register/reset that triggers the "already initialized" warning
2623
+ // across concurrent editors. openOnClick false because flyos: is
2624
+ // non-routable handleClick launches in-shell below.
2625
+ StarterKit.configure({ link: false }),
2626
+ FlyosLink,
2539
2627
  Markdown,
2540
2628
  TaskList,
2541
2629
  TaskItem.configure({ nested: true }),
@@ -6544,5 +6632,5 @@ const AUDIENCE_ERROR_CODES = {
6544
6632
  * Generated bundle index. Do not edit.
6545
6633
  */
6546
6634
 
6547
- export { AGENT_DRAG_MIME, AGENT_PAYLOAD_VERSION, APP_LOOKUP, AUDIENCE_ERROR_CODES, AUDIENCE_LIMITS, AUDIENCE_PRESETS, AUDIENCE_TERM_KINDS, AgentActionBus, AgentActionUnsupportedDispatchError, AgentCommandRegistry, AgentDropRegistry, AgentFlightAnimator, AgentLookupRegistry, AgentPayloadOversizeError, AudienceBuilderComponent, AuthService, ContextMenuComponent, DEFAULT_AGENT_PAYLOAD_LIMITS, DEFAULT_FLY_THEME_MODE, DS_BASELINE_LOCALES, DialogResult, ENTITY_LINK_LAUNCHER, EntityLookupComponent, FLYOS_LAUNCH_EVENT, FLYOS_REMOTE_ROUTE_EVENT, FLY_LOCALE_CATALOG, FLY_REMOTE_BASE_PATH, FLY_REMOTE_CONTEXT_EVENT, FLY_REMOTE_CONTEXT_STORE_KEY, FLY_REMOTE_ROUTES, FLY_THEME_MODE_IDS, FLY_WINDOW_HELP_HINT_EVENT, FlyAgentDraggableDirective, FlyBlockUiComponent, FlyFileUploadComponent, FlyImageUploadComponent, FlyMarkdownEditorComponent, FlyRemoteContextService, FlyRemoteRouter, FlyRemoteRouterOutletComponent, FlySecureSrcDirective, FlyThemeService, FlyWindowHelpService, FlyosPendingLaunchesGlobalKey, FlyosShellOwnsHistoryGlobalKey, I18nService, LAUNCH_CONTEXT, MARKDOWN_TOOLBAR_PRESETS, MessageBoxButtons, MessageBoxComponent, MessageBoxIcon, MessageBoxService, MockAuthService, RTL_LOCALE_SET, SHARE_ORG_CHART_SYSTEM_KEY_APPS, SHARE_ORG_CHART_SYSTEM_KEY_DEFAULT, SHARE_PANEL_DEFAULT_FILE_LEVELS, SUPPORTED_AGENT_PAYLOAD_VERSIONS, SharePanelComponent, SourceAppResolver, StandaloneWindowManagerService, TranslatePipe, WINDOW_DATA, WINDOW_HELP_HINT, WindowManagerService, findLocaleByDialect, findLocaleByPrefix, isRtlLocale, isRtlLocaleEntry, loadRemoteStyles, matchFlyRoutePattern, normalizeFlyTheme, trimAgentPayload, trimAgentString, unloadRemoteStyles, utf8ByteLength, validateAgentPayload };
6635
+ export { AGENT_DRAG_MIME, AGENT_PAYLOAD_VERSION, APP_LOOKUP, AUDIENCE_ERROR_CODES, AUDIENCE_LIMITS, AUDIENCE_PRESETS, AUDIENCE_TERM_KINDS, AgentActionBus, AgentActionUnsupportedDispatchError, AgentCommandRegistry, AgentDropRegistry, AgentFlightAnimator, AgentLookupRegistry, AgentPayloadOversizeError, AudienceBuilderComponent, AuthService, ContextMenuComponent, DEFAULT_AGENT_PAYLOAD_LIMITS, DEFAULT_FLY_THEME_MODE, DS_BASELINE_LOCALES, DialogResult, ENTITY_LINK_LAUNCHER, EntityLookupComponent, FLYOS_LAUNCH_EVENT, FLYOS_PROTOCOL, FLYOS_REMOTE_ROUTE_EVENT, FLY_LOCALE_CATALOG, FLY_REMOTE_BASE_PATH, FLY_REMOTE_CONTEXT_EVENT, FLY_REMOTE_CONTEXT_STORE_KEY, FLY_REMOTE_ROUTES, FLY_THEME_MODE_IDS, FLY_WINDOW_HELP_HINT_EVENT, FlyAgentDraggableDirective, FlyBlockUiComponent, FlyFileUploadComponent, FlyImageUploadComponent, FlyMarkdownEditorComponent, FlyRemoteContextService, FlyRemoteRouter, FlyRemoteRouterOutletComponent, FlySecureSrcDirective, FlyThemeService, FlyWindowHelpService, FlyosLink, FlyosPendingLaunchesGlobalKey, FlyosShellOwnsHistoryGlobalKey, I18nService, LAUNCH_CONTEXT, MARKDOWN_TOOLBAR_PRESETS, MessageBoxButtons, MessageBoxComponent, MessageBoxIcon, MessageBoxService, MockAuthService, RTL_LOCALE_SET, SHARE_ORG_CHART_SYSTEM_KEY_APPS, SHARE_ORG_CHART_SYSTEM_KEY_DEFAULT, SHARE_PANEL_DEFAULT_FILE_LEVELS, SUPPORTED_AGENT_PAYLOAD_VERSIONS, SharePanelComponent, SourceAppResolver, StandaloneWindowManagerService, TranslatePipe, WINDOW_DATA, WINDOW_HELP_HINT, WindowManagerService, findLocaleByDialect, findLocaleByPrefix, isRtlLocale, isRtlLocaleEntry, loadRemoteStyles, matchFlyRoutePattern, normalizeFlyTheme, registerFlyosProtocol, trimAgentPayload, trimAgentString, unloadRemoteStyles, utf8ByteLength, validateAgentPayload };
6548
6636
  //# sourceMappingURL=mohamedatia-fly-design-system.mjs.map