mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-25 18:13:44 +03:00
feat: export angular module <not stable yet>
This commit is contained in:
parent
cb2de97945
commit
ef5101b1f2
15
build/join-module-css.js
Normal file
15
build/join-module-css.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
'use strict';
|
||||||
|
require('shelljs/global');
|
||||||
|
|
||||||
|
set('-e');
|
||||||
|
set('-v');
|
||||||
|
|
||||||
|
|
||||||
|
cat([
|
||||||
|
'lib/components/Redoc/redoc-initial-styles.css',
|
||||||
|
'node_modules/perfect-scrollbar/dist/css/perfect-scrollbar.css',
|
||||||
|
'node_modules/dropkickjs/build/css/dropkick.css',
|
||||||
|
'node_modules/prismjs/themes/prism-dark.css',
|
||||||
|
'node_modules/hint.css/hint.base.css'
|
||||||
|
]).to('dist/redoc.css')
|
|
@ -16,7 +16,6 @@ module.exports = webpackMerge(commonConfig({
|
||||||
devtool: '#inline-source-map',
|
devtool: '#inline-source-map',
|
||||||
entry: {
|
entry: {
|
||||||
'polyfills': './lib/polyfills.ts',
|
'polyfills': './lib/polyfills.ts',
|
||||||
'vendor': './lib/vendor.ts',
|
|
||||||
'redoc': './lib/index.ts',
|
'redoc': './lib/index.ts',
|
||||||
},
|
},
|
||||||
devServer: {
|
devServer: {
|
||||||
|
|
|
@ -21,7 +21,7 @@ const config = webpackMerge(commonConfig({
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
|
|
||||||
entry: {
|
entry: {
|
||||||
'redoc': IS_MODULE ? ['./lib/vendor.ts', './lib/redoc.module.ts'] : ['./lib/polyfills.ts', './lib/vendor.ts', './lib/index.ts']
|
'redoc': IS_MODULE ? ['./lib/redoc.module.ts'] : ['./lib/polyfills.ts', './lib/index.ts']
|
||||||
},
|
},
|
||||||
|
|
||||||
output: {
|
output: {
|
||||||
|
|
|
@ -283,7 +283,7 @@ footer {
|
||||||
|
|
||||||
&:before, &:after {
|
&:before, &:after {
|
||||||
letter-spacing: -0.2em;
|
letter-spacing: -0.2em;
|
||||||
content: "\00a0";
|
//content: "\00a0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,35 +28,3 @@ if (!IS_PRODUCTION) {
|
||||||
Error.stackTraceLimit = Infinity;
|
Error.stackTraceLimit = Infinity;
|
||||||
require('zone.js/dist/long-stack-trace-zone');
|
require('zone.js/dist/long-stack-trace-zone');
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Element {
|
|
||||||
scrollIntoViewIfNeeded(centerIfNeeded?: boolean): void;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!(<any>Element).prototype.scrollIntoViewIfNeeded) {
|
|
||||||
(<any>Element).prototype.scrollIntoViewIfNeeded = function (centerIfNeeded) {
|
|
||||||
centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded;
|
|
||||||
|
|
||||||
var parent = this.parentNode,
|
|
||||||
parentComputedStyle = window.getComputedStyle(parent, null),
|
|
||||||
parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width')),
|
|
||||||
parentBorderLeftWidth = parseInt(parentComputedStyle.getPropertyValue('border-left-width')),
|
|
||||||
overTop = this.offsetTop - parent.offsetTop < parent.scrollTop,
|
|
||||||
overBottom = (this.offsetTop - parent.offsetTop + this.clientHeight - parentBorderTopWidth) > (parent.scrollTop + parent.clientHeight),
|
|
||||||
overLeft = this.offsetLeft - parent.offsetLeft < parent.scrollLeft,
|
|
||||||
overRight = (this.offsetLeft - parent.offsetLeft + this.clientWidth - parentBorderLeftWidth) > (parent.scrollLeft + parent.clientWidth),
|
|
||||||
alignWithTop = overTop && !overBottom;
|
|
||||||
|
|
||||||
if ((overTop || overBottom) && centerIfNeeded) {
|
|
||||||
parent.scrollTop = this.offsetTop - parent.offsetTop - parent.clientHeight / 2 - parentBorderTopWidth + this.clientHeight / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((overLeft || overRight) && centerIfNeeded) {
|
|
||||||
parent.scrollLeft = this.offsetLeft - parent.offsetLeft - parent.clientWidth / 2 - parentBorderLeftWidth + this.clientWidth / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((overTop || overBottom || overLeft || overRight) && !centerIfNeeded) {
|
|
||||||
this.scrollIntoView(alignWithTop);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import './vendor';
|
||||||
|
|
||||||
import { NgModule, ErrorHandler, APP_ID } from '@angular/core';
|
import { NgModule, ErrorHandler, APP_ID } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,34 @@ import 'dropkickjs/build/css/dropkick.css';
|
||||||
import 'prismjs/themes/prism-dark.css';
|
import 'prismjs/themes/prism-dark.css';
|
||||||
import 'hint.css/hint.base.css';
|
import 'hint.css/hint.base.css';
|
||||||
|
|
||||||
if (!IS_PRODUCTION) {
|
interface Element {
|
||||||
require('@angular/platform-browser');
|
scrollIntoViewIfNeeded(centerIfNeeded?: boolean): void;
|
||||||
require('@angular/platform-browser-dynamic');
|
};
|
||||||
require('@angular/core');
|
|
||||||
require('@angular/common');
|
|
||||||
|
|
||||||
// RxJS
|
if (!(<any>Element).prototype.scrollIntoViewIfNeeded) {
|
||||||
require('rxjs/Rx');
|
(<any>Element).prototype.scrollIntoViewIfNeeded = function (centerIfNeeded) {
|
||||||
|
centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded;
|
||||||
|
|
||||||
|
var parent = this.parentNode,
|
||||||
|
parentComputedStyle = window.getComputedStyle(parent, null),
|
||||||
|
parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width')),
|
||||||
|
parentBorderLeftWidth = parseInt(parentComputedStyle.getPropertyValue('border-left-width')),
|
||||||
|
overTop = this.offsetTop - parent.offsetTop < parent.scrollTop,
|
||||||
|
overBottom = (this.offsetTop - parent.offsetTop + this.clientHeight - parentBorderTopWidth) > (parent.scrollTop + parent.clientHeight),
|
||||||
|
overLeft = this.offsetLeft - parent.offsetLeft < parent.scrollLeft,
|
||||||
|
overRight = (this.offsetLeft - parent.offsetLeft + this.clientWidth - parentBorderLeftWidth) > (parent.scrollLeft + parent.clientWidth),
|
||||||
|
alignWithTop = overTop && !overBottom;
|
||||||
|
|
||||||
|
if ((overTop || overBottom) && centerIfNeeded) {
|
||||||
|
parent.scrollTop = this.offsetTop - parent.offsetTop - parent.clientHeight / 2 - parentBorderTopWidth + this.clientHeight / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((overLeft || overRight) && centerIfNeeded) {
|
||||||
|
parent.scrollLeft = this.offsetLeft - parent.offsetLeft - parent.clientWidth / 2 - parentBorderLeftWidth + this.clientWidth / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((overTop || overBottom || overLeft || overRight) && !centerIfNeeded) {
|
||||||
|
this.scrollIntoView(alignWithTop);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,12 +31,13 @@
|
||||||
"clean": "rimraf dist .tmp compiled lib/**/*.css",
|
"clean": "rimraf dist .tmp compiled lib/**/*.css",
|
||||||
"ngc": "ngc -p tsconfig.json",
|
"ngc": "ngc -p tsconfig.json",
|
||||||
"inline": "ng2-inline -o .tmp -r --compress \"lib/**/*.ts\"",
|
"inline": "ng2-inline -o .tmp -r --compress \"lib/**/*.ts\"",
|
||||||
"build:aot": "npm run build:sass && npm run inline && ngc -p tsconfig.aot.json",
|
"build:module": "npm run build:sass && npm run inline && ngc -p tsconfig.aot.json && npm run module:css",
|
||||||
|
"module:css": "node build/join-module-css.js",
|
||||||
"webpack:prod": "webpack --config build/webpack.prod.js --profile --bail",
|
"webpack:prod": "webpack --config build/webpack.prod.js --profile --bail",
|
||||||
"build:sass": "node-sass -q -o lib lib",
|
"build:sass": "node-sass -q -o lib lib",
|
||||||
"build:prod": "npm run build:sass && npm run ngc && npm run webpack:prod",
|
"build:prod": "npm run build:sass && npm run ngc && npm run webpack:prod",
|
||||||
"build-dist": "npm run build:prod",
|
"build-dist": "npm run build:prod",
|
||||||
"build:all": "npm run clean && npm run build:prod && npm run build:aot",
|
"build:all": "npm run clean && npm run build:prod && npm run build:module",
|
||||||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
|
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
|
||||||
"stats": "webpack --config build/webpack.prod.js --json > stats.json"
|
"stats": "webpack --config build/webpack.prod.js --json > stats.json"
|
||||||
},
|
},
|
||||||
|
@ -141,7 +142,6 @@
|
||||||
"scrollparent": "^2.0.1",
|
"scrollparent": "^2.0.1",
|
||||||
"slugify": "^1.0.2",
|
"slugify": "^1.0.2",
|
||||||
"stream-http": "^2.6.1",
|
"stream-http": "^2.6.1",
|
||||||
"ts-helpers": "^1.1.1",
|
|
||||||
"zone.js": "^0.8.14"
|
"zone.js": "^0.8.14"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"noEmitHelpers": true,
|
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"strictNullChecks": false,
|
"strictNullChecks": false,
|
||||||
"typeRoots": [ "./node_modules/@types" ],
|
"typeRoots": [ "./node_modules/@types" ],
|
||||||
|
@ -24,7 +23,6 @@
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"custom.d.ts",
|
"custom.d.ts",
|
||||||
".tmp/lib/vendor.ts",
|
|
||||||
".tmp/lib/polyfills.ts",
|
".tmp/lib/polyfills.ts",
|
||||||
".tmp/lib/redoc.module.ts"
|
".tmp/lib/redoc.module.ts"
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user