@lblod/ember-rdfa-editor-lblod-plugins 8.2.0 → 8.2.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [8.2.2] - 2023-06-28
11
+
12
+ ### Fixed
13
+ - Fix code filtering of roadsign regulation plugin
14
+
15
+ ## [8.2.1] - 2023-06-28
16
+ ### Fixed
17
+ - GN-4200: Fixed bug with TOC scroll in GN and RB
18
+ ### Dependencies
19
+ - Bump `date-fns` from 2.29.3 to 2.30.0
20
+
10
21
  ## [8.2.0] - 2023-06-26
11
22
  ### Added
12
23
  - Add a toggle to show the number as words in a number variable
@@ -509,7 +520,7 @@ add onclick handler to pencil icon in variable plugin
509
520
 
510
521
  # Changelog
511
522
 
512
- [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.0...HEAD
523
+ [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.2...HEAD
513
524
  [8.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.0.0...v8.0.1
514
525
  [8.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.1.0...v8.0.0
515
526
  [7.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.0.0...v7.1.0
@@ -525,5 +536,7 @@ add onclick handler to pencil icon in variable plugin
525
536
  [3.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.2...v3.0.0
526
537
  [2.1.2]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.1...v2.1.2
527
538
  [2.1.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.0...v2.1.1
539
+ [8.2.2]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.1...v8.2.2
540
+ [8.2.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.0...v8.2.1
528
541
  [8.2.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.1.0...v8.2.0
529
542
  [8.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.0.1...v8.1.0
package/README.md CHANGED
@@ -427,14 +427,17 @@ In order to enable the plugin you need to add the table of contents button to th
427
427
  ```
428
428
  ### Configuring the plugin with a custom config
429
429
 
430
- You can configure the nodeview with the hiearchy of the nodes
430
+ You can configure the nodeview with the hierarchy of the nodes.
431
+ For very custom setups, the plugin might be unable to find your scrollContainer (htmlElement providing scroll to your document). You can pass the scrollContainer element via the `scrollContainer()` function in the plugin config options instead.
431
432
 
432
433
  ```js
433
434
  {
434
435
  nodeHierarchy: [
435
436
  'title|chapter|section|subsection|article',
436
- 'structure_header|article_header',
437
- ],
437
+ 'structure_header|article_header',
438
+ ],
439
+ scrollContainer: () =>
440
+ document.getElementsByClassName('say-container__main')[0],
438
441
  },
439
442
  ```
440
443
 
@@ -156,11 +156,17 @@ export default class RoadsignRegulationCard extends Component<Args> {
156
156
  closeModal() {
157
157
  this.args.closeModal();
158
158
  }
159
+
159
160
  @action
160
161
  searchCodes(term: string) {
161
162
  const category = this.categorySelected?.value;
162
163
  const type = this.typeSelected?.value;
163
- return this.roadsignRegistry.searchCode.perform(term, category, type);
164
+ return this.roadsignRegistry.searchCode.perform(
165
+ this.endpoint,
166
+ term,
167
+ category,
168
+ type
169
+ );
164
170
  }
165
171
 
166
172
  async fetchCodeCombinations() {
@@ -88,14 +88,28 @@ export default class TableOfContentsComponent extends Component<EmberNodeArgs> {
88
88
  selection.from
89
89
  );
90
90
  const config = this.config[0];
91
+ let scrollContainer: HTMLElement | undefined;
91
92
  if (config.scrollContainer) {
92
- const scrollContainer: HTMLElement = config.scrollContainer;
93
+ scrollContainer = config.scrollContainer();
94
+ } else {
95
+ scrollContainer = this.getScrollContainer();
96
+ }
97
+ if (scrollContainer) {
98
+ /*
99
+ coords.top = The distance from the top of the page to your element, this changes with the amount you
100
+ have scrolled so far
101
+ scrollContainerDistanceToTop = absolute y-coord of the start of the scroll container.
102
+ The difference between these two plus the alreadyScrolled distance is where we want to scroll
103
+ */
93
104
  const alreadyScrolled = scrollContainer.scrollTop;
94
- const MAGIC_NUMBER_TOPBAR_HEIGHT: number =
95
- config.scrollingPadding ?? 150;
105
+ const scrollContainerDistanceToTop =
106
+ scrollContainer.getBoundingClientRect().y;
107
+ const topPadding = 10; // We need top padding so the wanted position is not just on top of the page
96
108
  scrollContainer.scrollTo(
97
109
  0,
98
- coords.top + alreadyScrolled - MAGIC_NUMBER_TOPBAR_HEIGHT
110
+ coords.top +
111
+ alreadyScrolled -
112
+ (scrollContainerDistanceToTop + topPadding)
99
113
  );
100
114
  } else {
101
115
  tr.scrollIntoView();
@@ -105,4 +119,22 @@ export default class TableOfContentsComponent extends Component<EmberNodeArgs> {
105
119
  });
106
120
  this.controller.focus();
107
121
  }
122
+ getScrollContainer(): HTMLElement | undefined {
123
+ let currentElement = this.controller.mainEditorView.dom;
124
+ while (currentElement.parentElement) {
125
+ const parent = currentElement.parentElement;
126
+ if (this.isScrollable(parent)) {
127
+ return parent;
128
+ }
129
+ currentElement = parent;
130
+ }
131
+ return;
132
+ }
133
+ isScrollable(element: HTMLElement): boolean {
134
+ const hasScrollableContent = element.scrollHeight > element.clientHeight;
135
+ const overflowYStyle = window.getComputedStyle(element).overflowY;
136
+ const isOverflowHidden = overflowYStyle.indexOf('hidden') !== -1;
137
+
138
+ return hasScrollableContent && !isOverflowHidden;
139
+ }
108
140
  }
@@ -1,5 +1,4 @@
1
1
  export type TableOfContentsConfig = {
2
2
  nodeHierarchy: string[];
3
- scrollContainer?: HTMLElement;
4
- scrollingPadding?: number;
3
+ scrollContainer?: () => HTMLElement;
5
4
  }[];
@@ -18,5 +18,7 @@ export default class TableOfContentsComponent extends Component<EmberNodeArgs> {
18
18
  pos: number;
19
19
  }): OutlineEntry[];
20
20
  moveToPosition(pos: number): void;
21
+ getScrollContainer(): HTMLElement | undefined;
22
+ isScrollable(element: HTMLElement): boolean;
21
23
  }
22
24
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "8.2.0",
3
+ "version": "8.2.2",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -42,7 +42,7 @@
42
42
  "@types/rdfjs__parser-n3": "^2.0.1",
43
43
  "buffer": "^6.0.3",
44
44
  "codemirror": "^6.0.1",
45
- "date-fns": "^2.29.3",
45
+ "date-fns": "^2.30.0",
46
46
  "ember-auto-import": "^2.4.3",
47
47
  "ember-cli-babel": "^7.26.11",
48
48
  "ember-cli-htmlbars": "^6.1.1",
@@ -1,5 +1,4 @@
1
1
  export type TableOfContentsConfig = {
2
2
  nodeHierarchy: string[];
3
- scrollContainer?: HTMLElement;
4
- scrollingPadding?: number;
3
+ scrollContainer?: () => HTMLElement;
5
4
  }[];