@lblod/ember-rdfa-editor-lblod-plugins 8.2.0 → 8.2.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.
- package/CHANGELOG.md +8 -1
- package/README.md +6 -3
- package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.ts +36 -4
- package/addon/plugins/table-of-contents-plugin/index.ts +1 -2
- package/components/table-of-contents-plugin/ember-nodes/table-of-contents.d.ts +2 -0
- package/package.json +2 -2
- package/plugins/table-of-contents-plugin/index.d.ts +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [8.2.1] - 2023-06-28
|
|
11
|
+
### Fixed
|
|
12
|
+
- GN-4200: Fixed bug with TOC scroll in GN and RB
|
|
13
|
+
### Dependencies
|
|
14
|
+
- Bump `date-fns` from 2.29.3 to 2.30.0
|
|
15
|
+
|
|
10
16
|
## [8.2.0] - 2023-06-26
|
|
11
17
|
### Added
|
|
12
18
|
- Add a toggle to show the number as words in a number variable
|
|
@@ -509,7 +515,7 @@ add onclick handler to pencil icon in variable plugin
|
|
|
509
515
|
|
|
510
516
|
# Changelog
|
|
511
517
|
|
|
512
|
-
[unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.
|
|
518
|
+
[unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.1...HEAD
|
|
513
519
|
[8.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.0.0...v8.0.1
|
|
514
520
|
[8.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.1.0...v8.0.0
|
|
515
521
|
[7.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.0.0...v7.1.0
|
|
@@ -525,5 +531,6 @@ add onclick handler to pencil icon in variable plugin
|
|
|
525
531
|
[3.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.2...v3.0.0
|
|
526
532
|
[2.1.2]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.1...v2.1.2
|
|
527
533
|
[2.1.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.0...v2.1.1
|
|
534
|
+
[8.2.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.0...v8.2.1
|
|
528
535
|
[8.2.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.1.0...v8.2.0
|
|
529
536
|
[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
|
|
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
|
-
|
|
437
|
-
],
|
|
437
|
+
'structure_header|article_header',
|
|
438
|
+
],
|
|
439
|
+
scrollContainer: () =>
|
|
440
|
+
document.getElementsByClassName('say-container__main')[0],
|
|
438
441
|
},
|
|
439
442
|
```
|
|
440
443
|
|
|
@@ -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
|
-
|
|
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
|
|
95
|
-
|
|
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 +
|
|
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
|
}
|
|
@@ -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.
|
|
3
|
+
"version": "8.2.1",
|
|
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.
|
|
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",
|