@diagrammo/dgmo 0.5.2 → 0.5.4

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/src/sharing.ts CHANGED
@@ -10,6 +10,8 @@ export interface DiagramViewState {
10
10
  activeTagGroup?: string;
11
11
  collapsedGroups?: string[];
12
12
  swimlaneTagGroup?: string;
13
+ palette?: string;
14
+ theme?: 'light' | 'dark';
13
15
  }
14
16
 
15
17
  export interface DecodedDiagramUrl {
@@ -57,6 +59,14 @@ export function encodeDiagramUrl(
57
59
  hash += `&swim=${encodeURIComponent(options.viewState.swimlaneTagGroup)}`;
58
60
  }
59
61
 
62
+ if (options?.viewState?.palette && options.viewState.palette !== 'nord') {
63
+ hash += `&pal=${encodeURIComponent(options.viewState.palette)}`;
64
+ }
65
+
66
+ if (options?.viewState?.theme && options.viewState.theme !== 'dark') {
67
+ hash += `&th=${encodeURIComponent(options.viewState.theme)}`;
68
+ }
69
+
60
70
  // Encode in both query param AND hash fragment — some share mechanisms
61
71
  // strip one or the other (iOS share sheet strips #, AirDrop strips ?)
62
72
  return { url: `${baseUrl}?${hash}#${hash}` };
@@ -105,6 +115,8 @@ export function decodeDiagramUrl(hash: string): DecodedDiagramUrl {
105
115
  if (key === 'swim' && val) {
106
116
  viewState.swimlaneTagGroup = val;
107
117
  }
118
+ if (key === 'pal' && val) viewState.palette = val;
119
+ if (key === 'th' && (val === 'light' || val === 'dark')) viewState.theme = val;
108
120
  }
109
121
 
110
122
  // Strip 'dgmo=' prefix