@fileverse-dev/ddoc 3.0.79 → 3.0.80-tab-v2-2

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.
@@ -4,18 +4,42 @@ export interface Tab {
4
4
  name: string;
5
5
  emoji: string | null;
6
6
  }
7
+ export interface TabsYdocNodes {
8
+ order: Y.Array<string>;
9
+ nameById: Y.Map<string>;
10
+ emojiById: Y.Map<string | null>;
11
+ tabState: Y.Map<unknown>;
12
+ deletedById: Y.Map<boolean>;
13
+ }
14
+ export interface SyncedTabsYdocNodes extends TabsYdocNodes {
15
+ didWrite: boolean;
16
+ }
17
+ interface TabSyncOptions {
18
+ createDefaultTabIfMissing?: boolean;
19
+ }
7
20
  export declare const DEFAULT_TAB_ID = "default";
8
21
  export declare const DEFAULT_TAB_NAME = "Tab 1";
9
- export declare function deriveTabsFromEncodedState(yjsEncodedState: string, doc: Y.Doc, options?: {
10
- createDefaultTabIfMissing?: boolean;
11
- }): {
22
+ export declare const LEGACY_ROOT_KEY = "ddocTabs";
23
+ export declare const ORDER_ROOT_KEY = "tabs_order";
24
+ export declare const NAME_ROOT_KEY = "tabs_name_registry";
25
+ export declare const EMOJI_ROOT_KEY = "tabs_emoji_registry";
26
+ export declare const STATE_ROOT_KEY = "tabs_state";
27
+ export declare const DELETED_ROOT_KEY = "tabs_delete_registry";
28
+ export declare const ACTIVE_TAB_STATE_KEY = "activeTabId";
29
+ export declare function syncTabState(doc: Y.Doc, options?: TabSyncOptions): boolean;
30
+ export declare function deriveTabsFromEncodedState(yjsEncodedState: string | string[] | null | undefined, doc: Y.Doc, options?: TabSyncOptions): {
12
31
  tabList: Tab[];
13
32
  activeTabId: string;
33
+ didWrite: boolean;
14
34
  };
15
- export declare function getTabsYdocNodes(doc: Y.Doc): {
16
- root: Y.Map<unknown>;
17
- order: Y.Array<string>;
18
- tabs: Y.Map<Y.Map<string | null>>;
19
- activeTab: Y.Text;
20
- };
35
+ export declare function getTabsYdocNodes(doc: Y.Doc): TabsYdocNodes;
36
+ export declare function syncTabStateAndGetNodes(doc: Y.Doc, options?: TabSyncOptions): SyncedTabsYdocNodes;
37
+ export declare function mergeTabAwareYjsUpdates(encodedUpdates: string[], options?: TabSyncOptions): string;
38
+ export declare function getActiveTabIdFromNodes(tabNodes: Pick<TabsYdocNodes, 'tabState'>): string | null;
39
+ export declare function getTabMetadata(tabNodes: Pick<TabsYdocNodes, 'nameById' | 'emojiById'>, tabId: string): {
40
+ name: string;
41
+ emoji: string | null;
42
+ } | null;
43
+ export declare function getTabListFromNodes(tabNodes: Pick<TabsYdocNodes, 'order' | 'nameById' | 'emojiById'>): Tab[];
21
44
  export declare function cloneFragmentContent(fragment: Y.XmlFragment): (Y.XmlElement | Y.XmlText)[];
45
+ export {};
@@ -2,8 +2,12 @@ import { Extension } from '@tiptap/core';
2
2
 
3
3
  /**
4
4
  * TypographyPersistence consolidates fontFamily and fontSize persistence logic
5
- * into a single extension with 3 plugins, replacing the 6 individual plugins
6
- * that were split across FontFamilyPersistence and FontSize.
5
+ * into a single extension with 2 plugins.
6
+ *
7
+ * Node-attr syncing (storedMarks → paragraph attrs) is handled directly by the
8
+ * setFontFamily/unsetFontFamily/setFontSize/unsetFontSize commands rather than
9
+ * via an appendTransaction plugin, because appendTransaction's setNodeMarkup
10
+ * clears storedMarks and drops other textStyle attrs like color.
7
11
  *
8
12
  * Plugins:
9
13
  * 1. typographyInheritance — when a new paragraph is inserted next to a styled
@@ -12,11 +16,5 @@ import { Extension } from '@tiptap/core';
12
16
  * at creation time, but should not be overridden when the user clears them).
13
17
  * 2. typographyStoredMarks — when selection moves into an empty styled
14
18
  * paragraph, restore storedMarks for both fontFamily and fontSize at once.
15
- * 3. typographySyncNodeAttr — when storedMarks change on an empty paragraph,
16
- * update both node attributes in one setNodeMarkup call.
17
- * Clearing only happens when the textStyle mark itself explicitly has a null
18
- * value for the property — NOT when non-textStyle marks (bold, italic, etc.)
19
- * are stored, which was previously causing font attrs to be wiped on
20
- * bold/italic toggle.
21
19
  */
22
20
  export declare const TypographyPersistence: Extension<any, any>;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fileverse-dev/ddoc",
3
3
  "private": false,
4
4
  "description": "DDoc",
5
- "version": "3.0.79",
5
+ "version": "3.0.80-tab-v2-2",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",
8
8
  "exports": {
@@ -152,4 +152,4 @@
152
152
  "typescript": "^5.2.2",
153
153
  "vite": "^5.0.0"
154
154
  }
155
- }
155
+ }