Skip to content

Commit

Permalink
build: fix package.json, close #8
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Apr 9, 2018
1 parent 2721079 commit cea0b32
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 21 deletions.
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}))
Expand Down Expand Up @@ -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`
Expand Down
23 changes: 22 additions & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
29 changes: 12 additions & 17 deletions lib/src/tinymce.component.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -12,23 +9,25 @@ declare const tinymce: any;
@Component({
// tslint:disable-next-line:component-selector
selector: 'tinymce',
template: `<textarea id="{{id}}" class="tinymce-selector"></textarea>
template: `
<textarea id="{{id}}" class="tinymce-selector"></textarea>
<div class="loading" *ngIf="load">
<ng-container *ngIf="_loading; else _loadingTpl">{{_loading}}</ng-container>
</div>`,
</div>
`,
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;
Expand All @@ -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
) {}

Expand Down Expand Up @@ -103,14 +101,6 @@ export class TinymceComponent implements OnInit, AfterViewInit, OnChanges, OnDes

ngOnInit() {
this.inited = true;
this.route$ = <any>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 {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit cea0b32

Please sign in to comment.