@jupytergis/schema 0.11.1 → 0.12.1

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.
@@ -45,6 +45,22 @@ export type IJGISLayerItem = string | IJGISLayerGroup;
45
45
  */
46
46
  export type IJGISLayerTree = IJGISLayerItem[];
47
47
  export type WhetherPresentationModeIsActive = boolean;
48
+ /**
49
+ * The title of the story map
50
+ */
51
+ export type Title = string;
52
+ /**
53
+ * The type of story map
54
+ */
55
+ export type StoryType = "guided" | "unguided";
56
+ /**
57
+ * The background color of the story map
58
+ */
59
+ export type PresentationBackgroundColor = string;
60
+ /**
61
+ * The text color of the story map
62
+ */
63
+ export type PresentationTextColor = string;
48
64
 
49
65
  export interface IJGISContent {
50
66
  schemaVersion?: string;
@@ -52,6 +68,7 @@ export interface IJGISContent {
52
68
  sources: IJGISSources;
53
69
  layerTree?: IJGISLayerTree;
54
70
  options?: IJGISOptions;
71
+ stories?: IJGISStoryMap;
55
72
  metadata?: {
56
73
  /**
57
74
  * This interface was referenced by `undefined`'s JSON-Schema definition
@@ -149,16 +166,13 @@ export interface IJGISOptions {
149
166
  * via the `definition` "jGISStoryMap".
150
167
  */
151
168
  export interface IJGISStoryMap {
152
- /**
153
- * The title of the story map
154
- */
155
- title?: string;
156
- /**
157
- * The type of story map
158
- */
159
- storyType?: "guided" | "unguided";
169
+ title?: Title;
170
+ storyType?: StoryType;
160
171
  /**
161
172
  * Array of story segments for the story map
162
173
  */
163
174
  storySegments?: string[];
175
+ presentationBgColor?: PresentationBackgroundColor;
176
+ presentaionTextColor?: PresentationTextColor;
177
+ [k: string]: any;
164
178
  }
@@ -229,13 +229,18 @@ export interface IJupyterGISModel extends DocumentRegistry.IModel {
229
229
  triggerLayerUpdate(layerId: string, layer: IJGISLayer): void;
230
230
  disposed: ISignal<any, void>;
231
231
  getSelectedStory(): {
232
- storySegmentId: string;
232
+ storyId: string;
233
233
  story: IJGISStoryMap | undefined;
234
234
  };
235
235
  addStorySegment(): {
236
236
  storySegmentId: string;
237
- storyMapId: string;
237
+ storyId: string;
238
238
  } | null;
239
+ segmentAdded: ISignal<IJupyterGISModel, {
240
+ storySegmentId: string;
241
+ storyId: string;
242
+ }>;
243
+ isSpectaMode(): boolean;
239
244
  }
240
245
  export interface IUserData {
241
246
  userId: number;
@@ -341,4 +346,5 @@ export interface IJupyterGISSettings {
341
346
  annotationsDisabled?: boolean;
342
347
  identifyDisabled?: boolean;
343
348
  storyMapsDisabled: boolean;
349
+ zoomButtonsEnabled?: boolean;
344
350
  }
package/lib/model.d.ts CHANGED
@@ -157,12 +157,19 @@ export declare class JupyterGISModel implements IJupyterGISModel {
157
157
  itemId: string;
158
158
  } | null>;
159
159
  getClientId(): number;
160
+ /**
161
+ * Check if the application is running in Specta mode.
162
+ * Specta mode is enabled when the URL contains 'specta' AND the model has stories.
163
+ *
164
+ * @returns True if running in Specta mode
165
+ */
166
+ isSpectaMode(): boolean;
160
167
  /**
161
168
  * Placeholder in case we eventually want to support multiple stories
162
169
  * @returns First/only story
163
170
  */
164
171
  getSelectedStory(): {
165
- storySegmentId: string;
172
+ storyId: string;
166
173
  story: IJGISStoryMap | undefined;
167
174
  };
168
175
  /**
@@ -171,8 +178,12 @@ export declare class JupyterGISModel implements IJupyterGISModel {
171
178
  */
172
179
  addStorySegment(): {
173
180
  storySegmentId: string;
174
- storyMapId: string;
181
+ storyId: string;
175
182
  } | null;
183
+ get segmentAdded(): ISignal<this, {
184
+ storySegmentId: string;
185
+ storyId: string;
186
+ }>;
176
187
  /**
177
188
  * Add an item in the layer tree.
178
189
  *
@@ -236,6 +247,7 @@ export declare class JupyterGISModel implements IJupyterGISModel {
236
247
  private _sharedMetadataChanged;
237
248
  private _zoomToPositionSignal;
238
249
  private _addFeatureAsMsSignal;
250
+ private _segmentAdded;
239
251
  private _updateLayerSignal;
240
252
  private _isTemporalControllerActive;
241
253
  private _editing;
package/lib/model.js CHANGED
@@ -15,6 +15,7 @@ const DEFAULT_SETTINGS = {
15
15
  annotationsDisabled: false,
16
16
  identifyDisabled: false,
17
17
  storyMapsDisabled: false,
18
+ zoomButtonsEnabled: false,
18
19
  };
19
20
  export class JupyterGISModel {
20
21
  constructor(options) {
@@ -56,6 +57,7 @@ export class JupyterGISModel {
56
57
  this._sharedMetadataChanged = new Signal(this);
57
58
  this._zoomToPositionSignal = new Signal(this);
58
59
  this._addFeatureAsMsSignal = new Signal(this);
60
+ this._segmentAdded = new Signal(this);
59
61
  this._updateLayerSignal = new Signal(this);
60
62
  this._isTemporalControllerActive = false;
61
63
  this._editing = null;
@@ -261,11 +263,12 @@ export class JupyterGISModel {
261
263
  console.warn(errorMsg);
262
264
  }
263
265
  this.sharedModel.transact(() => {
264
- var _a, _b, _c, _d, _e;
266
+ var _a, _b, _c, _d, _e, _f;
265
267
  this.sharedModel.sources = (_a = jsonData.sources) !== null && _a !== void 0 ? _a : {};
266
268
  this.sharedModel.layers = (_b = jsonData.layers) !== null && _b !== void 0 ? _b : {};
267
269
  this.sharedModel.layerTree = (_c = jsonData.layerTree) !== null && _c !== void 0 ? _c : [];
268
- this.sharedModel.options = (_d = jsonData.options) !== null && _d !== void 0 ? _d : {
270
+ this.sharedModel.stories = (_d = jsonData.stories) !== null && _d !== void 0 ? _d : {};
271
+ this.sharedModel.options = (_e = jsonData.options) !== null && _e !== void 0 ? _e : {
269
272
  latitude: 0,
270
273
  longitude: 0,
271
274
  zoom: 0,
@@ -273,7 +276,7 @@ export class JupyterGISModel {
273
276
  pitch: 0,
274
277
  projection: 'EPSG:3857',
275
278
  };
276
- this.sharedModel.metadata = (_e = jsonData.metadata) !== null && _e !== void 0 ? _e : {};
279
+ this.sharedModel.metadata = (_f = jsonData.metadata) !== null && _f !== void 0 ? _f : {};
277
280
  });
278
281
  this.dirty = true;
279
282
  }
@@ -485,6 +488,19 @@ export class JupyterGISModel {
485
488
  getClientId() {
486
489
  return this.sharedModel.awareness.clientID;
487
490
  }
491
+ /**
492
+ * Check if the application is running in Specta mode.
493
+ * Specta mode is enabled when the URL contains 'specta' AND the model has stories.
494
+ *
495
+ * @returns True if running in Specta mode
496
+ */
497
+ isSpectaMode() {
498
+ var _a;
499
+ const hasStories = Object.keys(this.sharedModel.stories).length > 0;
500
+ const isSpecta = !!document.querySelector('meta[name="specta-config"]');
501
+ const guidedMode = ((_a = this.getSelectedStory().story) === null || _a === void 0 ? void 0 : _a.storyType) === 'guided';
502
+ return isSpecta && hasStories && guidedMode;
503
+ }
488
504
  /**
489
505
  * Placeholder in case we eventually want to support multiple stories
490
506
  * @returns First/only story
@@ -493,7 +509,7 @@ export class JupyterGISModel {
493
509
  const stories = this.sharedModel.stories;
494
510
  const storyId = Object.keys(stories)[0];
495
511
  return {
496
- storySegmentId: storyId,
512
+ storyId: storyId,
497
513
  story: this.sharedModel.getStoryMap(storyId),
498
514
  };
499
515
  }
@@ -504,11 +520,11 @@ export class JupyterGISModel {
504
520
  addStorySegment() {
505
521
  var _a;
506
522
  const { zoom, extent } = this.getOptions();
523
+ const { storyId } = this.getSelectedStory();
507
524
  if (!zoom || !extent) {
508
525
  console.warn('No extent or zoom found');
509
526
  return null;
510
527
  }
511
- const storyMapId = UUID.uuid4();
512
528
  const newStorySegmentId = UUID.uuid4();
513
529
  const layerParams = {
514
530
  extent,
@@ -522,27 +538,38 @@ export class JupyterGISModel {
522
538
  parameters: layerParams,
523
539
  };
524
540
  this.addLayer(newStorySegmentId, layerModel);
525
- // check for stories
526
- const isStoriesExist = Object.keys(this.sharedModel.stories).length !== 0;
527
- // if not stories, then just add simple
528
- if (!isStoriesExist) {
541
+ // if story doesn't exist then add one
542
+ if (!storyId) {
543
+ const storyId = UUID.uuid4();
529
544
  const title = 'New Story';
530
545
  const storyType = 'guided';
531
546
  const storySegments = [newStorySegmentId];
532
547
  const storyMap = { title, storyType, storySegments };
533
- this.sharedModel.addStoryMap(storyMapId, storyMap);
548
+ this.sharedModel.addStoryMap(storyId, storyMap);
549
+ this._segmentAdded.emit({
550
+ storySegmentId: newStorySegmentId,
551
+ storyId,
552
+ });
553
+ return { storySegmentId: newStorySegmentId, storyId };
534
554
  }
535
555
  else {
536
- // else need to update stories
556
+ // else need to update story
537
557
  const { story } = this.getSelectedStory();
538
558
  if (!story) {
539
559
  console.warn('No story found, something went wrong');
540
560
  return null;
541
561
  }
542
562
  const newStory = Object.assign(Object.assign({}, story), { storySegments: [...((_a = story.storySegments) !== null && _a !== void 0 ? _a : []), newStorySegmentId] });
543
- this.sharedModel.updateStoryMap(storyMapId, newStory);
563
+ this.sharedModel.updateStoryMap(storyId, newStory);
564
+ this._segmentAdded.emit({
565
+ storySegmentId: newStorySegmentId,
566
+ storyId,
567
+ });
568
+ return { storySegmentId: newStorySegmentId, storyId };
544
569
  }
545
- return { storySegmentId: newStorySegmentId, storyMapId };
570
+ }
571
+ get segmentAdded() {
572
+ return this._segmentAdded;
546
573
  }
547
574
  /**
548
575
  * Add an item in the layer tree.
@@ -20,6 +20,9 @@
20
20
  "options": {
21
21
  "$ref": "#/definitions/jGISOptions"
22
22
  },
23
+ "stories": {
24
+ "$ref": "#/definitions/jGISStoryMap"
25
+ },
23
26
  "metadata": {
24
27
  "type": "object",
25
28
  "patternProperties": {
@@ -140,14 +143,16 @@
140
143
  "jGISStoryMap": {
141
144
  "title": "IJGISStoryMap",
142
145
  "type": "object",
143
- "additionalProperties": false,
146
+ "additionalProperties": true,
144
147
  "properties": {
145
148
  "title": {
146
149
  "type": "string",
150
+ "title": "Title",
147
151
  "description": "The title of the story map"
148
152
  },
149
153
  "storyType": {
150
154
  "type": "string",
155
+ "title": "Story Type",
151
156
  "enum": ["guided", "unguided"],
152
157
  "description": "The type of story map"
153
158
  },
@@ -158,6 +163,16 @@
158
163
  "items": {
159
164
  "type": "string"
160
165
  }
166
+ },
167
+ "presentationBgColor": {
168
+ "type": "string",
169
+ "title": "Presentation Background Color",
170
+ "description": "The background color of the story map"
171
+ },
172
+ "presentaionTextColor": {
173
+ "type": "string",
174
+ "title": "Presentation Text Color",
175
+ "description": "The text color of the story map"
161
176
  }
162
177
  }
163
178
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupytergis/schema",
3
- "version": "0.11.1",
3
+ "version": "0.12.1",
4
4
  "description": "A JupyterGIS schema package.",
5
5
  "keywords": [
6
6
  "jupytergis"