From cea0b320a7d541dfaf735a778c4fef2d8e565cdf Mon Sep 17 00:00:00 2001 From: cipchk Date: Mon, 9 Apr 2018 20:53:29 +0800 Subject: [PATCH] build: fix package.json, close #8 --- gulpfile.js | 4 ++-- lib/package.json | 23 ++++++++++++++++++++++- lib/src/tinymce.component.ts | 29 ++++++++++++----------------- package.json | 2 +- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index ac32b72..b90994e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,7 +20,7 @@ gulp.task('bundle', bundleUmd); gulp.task('bump', bumpVersions); function bumpVersions() { - gulp.src([ './package.json'], {base: './'}) + gulp.src([ './package.json', './lib/package.json' ], {base: './'}) .pipe(bump({ version: VERSION })) @@ -53,7 +53,7 @@ function copyResources() { `./LICENSE`, `./README.md`, `./rollup.config.js`, - `./package.json`, + `${paths.build}/package.json`, `${paths.build}/**/*.html`, `${paths.build}/**/*.css`, `${paths.build}/**/*.less` diff --git a/lib/package.json b/lib/package.json index 05cc8a2..e747b30 100644 --- a/lib/package.json +++ b/lib/package.json @@ -1,3 +1,24 @@ { - "name": "ngx-tinymce" + "name": "ngx-tinymce", + "version": "1.0.2", + "license": "MIT", + "description": "Angular for tinymce", + "main": "./bundles/ngx-tinymce.umd.js", + "author": "cipchk", + "homepage": "https://cipchk.github.io/ngx-tinymce/", + "bugs": { + "url": "https://github.com/cipchk/ngx-tinymce/issues" + }, + "keywords": [ + "angular tinymce", + "ngx-tinymce", + "ng-tinymce", + "ng tinymce", + "tinymce" + ], + "peerDependencies": { + "@angular/core": "^5.0.0", + "@angular/common": "^5.0.0", + "@angular/forms": "^5.0.0" + } } diff --git a/lib/src/tinymce.component.ts b/lib/src/tinymce.component.ts index bea17a6..064293c 100644 --- a/lib/src/tinymce.component.ts +++ b/lib/src/tinymce.component.ts @@ -1,8 +1,5 @@ import { Component, forwardRef, OnChanges, OnDestroy, Input, OnInit, AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, TemplateRef, Output, EventEmitter, SimpleChanges, Optional } from '@angular/core'; import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms'; -import { Router, ActivationEnd } from '@angular/router'; -import { Subscription } from 'rxjs/Subscription'; -import { debounceTime, filter } from 'rxjs/operators'; import { ScriptService } from './script.service'; import { TinymceOptions } from './tinymce.options'; @@ -12,23 +9,25 @@ declare const tinymce: any; @Component({ // tslint:disable-next-line:component-selector selector: 'tinymce', - template: ` + template: ` +
{{_loading}} -
`, + + `, styles: [ `:host .tinymce-selector{display:none}` ], providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => TinymceComponent), multi: true }], - changeDetection: ChangeDetectionStrategy.OnPush + changeDetection: ChangeDetectionStrategy.OnPush, + preserveWhitespaces: false }) export class TinymceComponent implements OnInit, AfterViewInit, OnChanges, OnDestroy, ControlValueAccessor { private instance: any; private value: string; private inited = false; - private route$: Subscription; load = true; id = `_tinymce-${Math.random().toString(36).substring(2)}`; onChange: any = Function.prototype; @@ -49,7 +48,6 @@ export class TinymceComponent implements OnInit, AfterViewInit, OnChanges, OnDes constructor( private defConfig: TinymceOptions, private ss: ScriptService, - @Optional() private router: Router, private cd: ChangeDetectorRef ) {} @@ -103,14 +101,6 @@ export class TinymceComponent implements OnInit, AfterViewInit, OnChanges, OnDes ngOnInit() { this.inited = true; - this.route$ = this.router.events.pipe( - filter(e => e instanceof ActivationEnd), - debounceTime(100), - filter(e => !!document.querySelector('#' + this.id)) - ).subscribe(res => { - this.destroy(); - this.init(); - }); } ngAfterViewInit(): void { @@ -136,7 +126,12 @@ export class TinymceComponent implements OnInit, AfterViewInit, OnChanges, OnDes ngOnDestroy(): void { this.destroy(); - if (this.route$) this.route$.unsubscribe(); + } + + // reuse-tab: http://ng-alain.com/components/reuse-tab#%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F + _onReuseInit() { + this.destroy(); + this.init(); } writeValue(value: string): void { diff --git a/package.json b/package.json index 6fa7c01..7d0c02b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-tinymce", - "version": "1.0.1", + "version": "1.0.2", "license": "MIT", "description": "Angular for tinymce", "main": "./bundles/ngx-tinymce.umd.js",