mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 00:26:34 +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',
|
||||
entry: {
|
||||
'polyfills': './lib/polyfills.ts',
|
||||
'vendor': './lib/vendor.ts',
|
||||
'redoc': './lib/index.ts',
|
||||
},
|
||||
devServer: {
|
||||
|
|
|
@ -21,7 +21,7 @@ const config = webpackMerge(commonConfig({
|
|||
devtool: 'source-map',
|
||||
|
||||
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: {
|
||||
|
|
|
@ -283,7 +283,7 @@ footer {
|
|||
|
||||
&:before, &:after {
|
||||
letter-spacing: -0.2em;
|
||||
content: "\00a0";
|
||||
//content: "\00a0";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,35 +28,3 @@ if (!IS_PRODUCTION) {
|
|||
Error.stackTraceLimit = Infinity;
|
||||
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 { CommonModule } from '@angular/common';
|
||||
|
||||
|
|
|
@ -24,12 +24,34 @@ import 'dropkickjs/build/css/dropkick.css';
|
|||
import 'prismjs/themes/prism-dark.css';
|
||||
import 'hint.css/hint.base.css';
|
||||
|
||||
if (!IS_PRODUCTION) {
|
||||
require('@angular/platform-browser');
|
||||
require('@angular/platform-browser-dynamic');
|
||||
require('@angular/core');
|
||||
require('@angular/common');
|
||||
interface Element {
|
||||
scrollIntoViewIfNeeded(centerIfNeeded?: boolean): void;
|
||||
};
|
||||
|
||||
// RxJS
|
||||
require('rxjs/Rx');
|
||||
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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -31,12 +31,13 @@
|
|||
"clean": "rimraf dist .tmp compiled lib/**/*.css",
|
||||
"ngc": "ngc -p tsconfig.json",
|
||||
"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",
|
||||
"build:sass": "node-sass -q -o lib lib",
|
||||
"build:prod": "npm run build:sass && npm run ngc && npm run webpack: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",
|
||||
"stats": "webpack --config build/webpack.prod.js --json > stats.json"
|
||||
},
|
||||
|
@ -141,7 +142,6 @@
|
|||
"scrollparent": "^2.0.1",
|
||||
"slugify": "^1.0.2",
|
||||
"stream-http": "^2.6.1",
|
||||
"ts-helpers": "^1.1.1",
|
||||
"zone.js": "^0.8.14"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"sourceMap": true,
|
||||
"noEmitHelpers": true,
|
||||
"outDir": "./dist",
|
||||
"strictNullChecks": false,
|
||||
"typeRoots": [ "./node_modules/@types" ],
|
||||
|
@ -24,7 +23,6 @@
|
|||
},
|
||||
"files": [
|
||||
"custom.d.ts",
|
||||
".tmp/lib/vendor.ts",
|
||||
".tmp/lib/polyfills.ts",
|
||||
".tmp/lib/redoc.module.ts"
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue
Block a user