umberto 3.0.0 → 3.2.0

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +1591 -0
  2. package/README.md +6 -6
  3. package/package.json +4 -34
  4. package/src/api-builder/classes/doc-data-factory.js +107 -34
  5. package/src/data-converter/converters/typedoc/abstractparser.js +11 -0
  6. package/src/data-converter/converters/typedoc/computedpropertyparser.js +30 -0
  7. package/src/data-converter/converters/typedoc/moduleparser.js +2 -1
  8. package/src/data-converter/converters/typedoc/typedocconverter.js +89 -27
  9. package/src/data-converter/converters/typedoc2umberto.js +2 -0
  10. package/src/hexo-manager.js +10 -1
  11. package/themes/umberto/layout/_api-docs/_mixin/_method.pug +2 -1
  12. package/themes/umberto/layout/_api-docs/_mixin/_params.pug +10 -1
  13. package/themes/umberto/layout/_api-docs/_mixin/type-parameter.pug +1 -1
  14. package/themes/umberto/layout/_api-docs/_partial/api-subheader.pug +3 -0
  15. package/themes/umberto/layout/_api-docs/_partial/type-parameters.pug +1 -1
  16. package/themes/umberto/layout/_api-docs/api-base.pug +0 -2
  17. package/themes/umberto/layout/_mixin/nav-tree-level.pug +1 -1
  18. package/themes/umberto/layout/_partial/nav-tree.pug +1 -1
  19. package/themes/umberto/src/css/_api-subheader.scss +2 -0
  20. package/themes/umberto/src/css/_badge.scss +1 -0
  21. package/themes/umberto/src/css/_tree.scss +9 -0
  22. package/themes/umberto/src/js/_apitree.js +12 -20
  23. package/themes/umberto/src/js/_sidenavigation.js +45 -4
  24. package/themes/umberto/src/js/app.js +3 -3
  25. package/.editorconfig +0 -12
  26. package/.eslintrc.js +0 -41
  27. package/scripts-dev/postinstall.js +0 -18
  28. package/themes/umberto/layout/_api-docs/_partial/types.pug +0 -5
@@ -7,6 +7,8 @@
7
7
  }
8
8
 
9
9
  .api-subheader {
10
+ display: flex;
11
+
10
12
  &.hidden-loading {
11
13
  display: none;
12
14
  }
@@ -29,6 +29,7 @@
29
29
  font-size: u-font-size( -1 );
30
30
  padding: u-spacing( -3 ) u-spacing( -2 ) u-spacing( -3 );
31
31
  border: 1px solid u-color( 'text' );
32
+ margin-right: 1rem;
32
33
 
33
34
  &.badge--has-invert {
34
35
  padding-right: 0;
@@ -24,6 +24,15 @@ See: `_api-tree.scss` and `_guide-sdk-tree.scss`. */
24
24
 
25
25
  list-style: none;
26
26
 
27
+ &.guide-tree {
28
+ opacity: 0; //prevents flickering when applying categories fold state
29
+ }
30
+
31
+ &.state-applied {
32
+ opacity: 1;
33
+ transition: opacity 0.05s
34
+ }
35
+
27
36
  li {
28
37
  position: relative;
29
38
  cursor: pointer;
@@ -42,31 +42,23 @@ export function scrollApiTree() {
42
42
  const treeHeight = tree.height();
43
43
  const storageKey = 'side-nav-scroll-top';
44
44
  const sideNavScrollTop = Number( window.localStorage.getItem( storageKey ) );
45
- const treeItemClass = 'tree__item__wrapper';
46
45
  const activeTreeItemClass = 'tree__item__wrapper--active';
47
46
  const activeTreeItem = $( `div.side-navigation .${ activeTreeItemClass }` );
48
- const treeWrappers = $( `div.side-navigation [class*="${ treeItemClass }"]` );
49
- const activeTreeItemIndex = treeWrappers.index( activeTreeItem );
50
- let activeTreeItemTop = 25; // 25 is for top padding of side nav.
47
+ let activeTreeItemTop = 0;
51
48
  const bound = 50; // Offset from top and bottom of side nav.
52
49
 
53
- // Sum nav tree items heights.
54
- treeWrappers.each( function( index ) {
55
- if ( activeTreeItemIndex === -1 || index === activeTreeItemIndex ) {
56
- return false;
57
- }
58
-
59
- activeTreeItemTop += $( this ).height();
60
- } );
50
+ if ( activeTreeItem.length ) {
51
+ activeTreeItemTop = activeTreeItem[ 0 ].offsetParent ? activeTreeItem[ 0 ].offsetParent.offsetTop : 0;
61
52
 
62
- if (
63
- sideNavScrollTop !== null &&
64
- activeTreeItemTop > sideNavScrollTop + bound &&
65
- activeTreeItemTop < sideNavScrollTop + treeHeight - bound
66
- ) {
67
- tree.scrollTop( sideNavScrollTop );
68
- } else {
69
- tree.scrollTop( Math.max( 0, activeTreeItemTop - treeHeight / 2 ) );
53
+ if (
54
+ sideNavScrollTop !== null &&
55
+ activeTreeItemTop > sideNavScrollTop + bound &&
56
+ activeTreeItemTop < sideNavScrollTop + treeHeight - bound
57
+ ) {
58
+ tree.scrollTop( sideNavScrollTop );
59
+ } else {
60
+ activeTreeItem[ 0 ].scrollIntoView( { block: 'center' } );
61
+ }
70
62
  }
71
63
 
72
64
  tree.scroll( throttle( () => {
@@ -5,14 +5,55 @@
5
5
 
6
6
  export default function sideNavigation() {
7
7
  const folderButtons = Array.from( document.querySelectorAll( '.tree:not(.api-tree) .tree__item--folder' ) );
8
- if ( !folderButtons.length ) {
9
- return;
8
+ const guideTreeElement = document.getElementById( 'guidetree' );
9
+ const foldedClassName = 'tree__item-nested-list--hidden';
10
+ const activeClassName = '.tree__item__wrapper--active';
11
+ const localStorageKey = 'foldersState';
12
+
13
+ let foldersState = JSON.parse( window.localStorage.getItem( localStorageKey ) );
14
+ if ( foldersState === null ) {
15
+ foldersState = {};
10
16
  }
11
17
 
12
18
  folderButtons.forEach( btn => {
19
+ const element = btn.parentNode.nextElementSibling; // Get <ul> element
20
+ const id = element.getAttribute( 'data-id' );
21
+
22
+ applyFolderState( element, foldersState[ id ] );
23
+ checkForActiveChildren( element, id );
24
+
13
25
  btn.addEventListener( 'click', function() {
14
- // Get <ul> and control it.
15
- btn.parentNode.nextElementSibling.classList.toggle( 'tree__item-nested-list--hidden' );
26
+ element.classList.toggle( foldedClassName );
27
+ saveFolderState( id, isFolded( element ) );
16
28
  } );
17
29
  } );
30
+
31
+ if ( guideTreeElement ) {
32
+ guideTreeElement.classList.add( 'state-applied' );
33
+ }
34
+
35
+ function applyFolderState( element, folded ) {
36
+ if ( folded === false ) {
37
+ element.classList.remove( foldedClassName );
38
+ }
39
+ if ( folded === true ) {
40
+ element.classList.add( foldedClassName );
41
+ }
42
+ }
43
+
44
+ function saveFolderState( id, state ) {
45
+ foldersState[ id ] = state;
46
+ window.localStorage.setItem( localStorageKey, JSON.stringify( foldersState ) );
47
+ }
48
+
49
+ function checkForActiveChildren( element, id ) {
50
+ if ( element.querySelectorAll( activeClassName ).length > 0 ) {
51
+ element.classList.remove( foldedClassName );
52
+ saveFolderState( id, isFolded( element ) );
53
+ }
54
+ }
55
+
56
+ function isFolded( element ) {
57
+ return element.classList.contains( foldedClassName );
58
+ }
18
59
  }
@@ -44,19 +44,19 @@ window.umberto = {
44
44
  $( document ).ready( () => {
45
45
  pageNavigation(); // pageNavigation - needs to be run before filtering initialization.
46
46
  copyMobileApiNavigation(); // copy API Tree into mobile navigation
47
+ sideNavigation();
48
+ expandApiTree();
49
+ scrollApiTree();
47
50
  enableFiltering();
48
51
  setupPrism();
49
- expandApiTree();
50
52
  enableCollapsables();
51
53
  hideTogglers();
52
54
  enableAnchors();
53
55
  enableDropdowns();
54
56
  trackArticlePosition();
55
- scrollApiTree();
56
57
  setUpFuse();
57
58
  activateDevNames();
58
59
  attachPermalinkListener();
59
- sideNavigation();
60
60
  rwdButton();
61
61
  imageModal(); // lightbox for { @img } elements
62
62
  // `sampleCode()` must be called after the `setupPrism()` function.
package/.editorconfig DELETED
@@ -1,12 +0,0 @@
1
- # Configurations to normalize the IDE behavior.
2
- # http://editorconfig.org/
3
-
4
- root = true
5
-
6
- [*]
7
- indent_style = tab
8
- tab_width = 4
9
- charset = utf-8
10
- end_of_line = lf
11
- trim_trailing_whitespace = true
12
- insert_final_newline = true
package/.eslintrc.js DELETED
@@ -1,41 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2017-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md.
4
- */
5
-
6
- 'use strict';
7
-
8
- module.exports = {
9
- extends: 'ckeditor5',
10
- rules: {
11
- 'ckeditor5-rules/license-header': [ 'error', { headerLines: [
12
- '/**',
13
- ' * @license Copyright (c) 2017-2023, CKSource Holding sp. z o.o. All rights reserved.',
14
- ' * For licensing, see LICENSE.md.',
15
- ' */'
16
- ] } ]
17
- },
18
- env: {
19
- node: true
20
- },
21
- ignorePatterns: [
22
- 'source/**/*.js',
23
- 'temp/**/*.js',
24
- 'themes/umberto/source/**/*.js',
25
- 'tests/src/data-converter/converters/typedoc/fixtures'
26
- ],
27
- overrides: [
28
- {
29
- files: [ 'scripts/**/*.js' ],
30
- globals: {
31
- hexo: true
32
- }
33
- },
34
- {
35
- files: [ 'themes/**/*.js' ],
36
- env: {
37
- browser: true
38
- }
39
- }
40
- ]
41
- };
@@ -1,18 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2017-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md.
4
- */
5
-
6
- 'use strict';
7
-
8
- /* eslint-env node */
9
-
10
- const path = require( 'path' );
11
- const fs = require( 'fs' );
12
- const ROOT_DIRECTORY = path.join( __dirname, '..' );
13
-
14
- // When installing a repository as a dependency, the `.git` directory does not exist.
15
- // In such a case, husky should not attach its hooks as npm treats it as a package, not a git repository.
16
- if ( fs.existsSync( path.join( ROOT_DIRECTORY, '.git' ) ) ) {
17
- require( 'husky' ).install();
18
- }
@@ -1,5 +0,0 @@
1
- include ../_mixin/_type
2
-
3
- div(class="types hidden-loading")
4
- if isNonEmptyArray( data.types )
5
- +type( data.types )