Skip to content

Commit dc2053a

Browse files
committed
Update tinymce demo
1 parent a75dcc9 commit dc2053a

File tree

6 files changed

+77
-24
lines changed

6 files changed

+77
-24
lines changed

angular.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,15 @@
6060
"tsConfig": "projects/demo-app/tsconfig.app.json",
6161
"assets": [
6262
"projects/demo-app/src/favicon.ico",
63-
"projects/demo-app/src/assets"
63+
"projects/demo-app/src/assets",
64+
{ "glob": "**/*", "input": "node_modules/tinymce", "output": "/tinymce/" }
6465
],
6566
"styles": [
6667
"projects/demo-app/src/styles.css"
6768
],
68-
"scripts": [],
69+
"scripts": [
70+
"node_modules/tinymce/tinymce.min.js"
71+
],
6972
"vendorChunk": true,
7073
"extractLicenses": false,
7174
"buildOptimizer": false,

package-lock.json

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
"@angular/platform-browser": "~12.0.2",
2020
"@angular/platform-browser-dynamic": "~12.0.2",
2121
"@angular/router": "~12.0.2",
22+
"@tinymce/tinymce-angular": "^4.2.3",
2223
"angular-in-memory-web-api": "^0.11.0",
2324
"codelyzer": "^6.0.0",
2425
"core-js": "^3.6.5",
2526
"rxjs": "~6.5.5",
2627
"rxjs-compat": "^6.5.5",
28+
"tinymce": "^5.8.1",
2729
"tslib": "^2.2.0",
2830
"zone.js": "~0.11.4"
2931
},

projects/demo-app-e2e/src/app.e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('angular-mentions app', function() {
3434
it('test mentions iframe', () => {
3535
page.navigateTo();
3636
expect(page.getHeadingText()).toEqual('Angular Mentions');
37-
let el = element.all(by.id('tmce_ifr'));
37+
let el = element.all(by.css('editor iframe'));
3838
// iframe testing workaround - sendKeys is not working unless menu is opened first
3939
// this wasn't needed in previous versions of angular/protractor
4040
// el.click();

projects/demo-app/src/app/app.module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { BrowserModule } from '@angular/platform-browser';
22
import { HttpClientModule } from '@angular/common/http';
33
import { NgModule } from '@angular/core';
44

5+
import { EditorModule } from '@tinymce/tinymce-angular';
6+
57
// Imports for loading & configuring the in-memory web api
68
import { InMemoryWebApiModule } from 'angular-in-memory-web-api';
79
import { InMemoryDataService } from './demo-async/in-memory-data.service';
@@ -19,6 +21,7 @@ import { TestPositionComponent } from './test-position/test-position.component';
1921
@NgModule({
2022
imports: [
2123
BrowserModule,
24+
EditorModule,
2225
HttpClientModule,
2326
InMemoryWebApiModule.forRoot(InMemoryDataService, { delay: 500 }),
2427
MentionModule

projects/demo-app/src/app/demo-tinymce/demo-tinymce.component.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import { Component, ElementRef, NgZone, Input, ViewChild } from '@angular/core';
1+
import { Component, NgZone, Input, ViewChild } from '@angular/core';
22

33
import { MentionDirective } from 'angular-mentions';
44
import { COMMON_NAMES } from '../common-names';
55

6-
declare var tinymce: any;
7-
86
/**
97
* Angular 2 Mentions.
108
* https://github.com/dmacfarlane/angular-mentions
@@ -19,29 +17,31 @@ declare var tinymce: any;
1917
<div>
2018
<textarea class="hidden" cols="60" rows="4" id="tmce">{{htmlContent}}</textarea>
2119
</div>
22-
</div>`
20+
</div>
21+
<editor [init]="CONFIG"></editor>
22+
`
2323
})
2424
export class DemoTinymceComponent {
2525
@Input() htmlContent:string;
2626
@ViewChild(MentionDirective, { static: true }) mention: MentionDirective;
2727
public items:string[] = COMMON_NAMES;
28-
constructor(private _elementRef: ElementRef, private _zone: NgZone) {}
29-
ngAfterViewInit() {
30-
tinymce.init({
31-
mode: 'exact',
32-
height: 100,
33-
theme: 'modern',
34-
plugins: [
35-
'advlist autolink lists link image charmap print preview anchor',
36-
'searchreplace visualblocks code fullscreen',
37-
'insertdatetime media table contextmenu paste code'
38-
],
39-
toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
40-
elements: "tmce",
41-
setup: this.tinySetup.bind(this)
42-
}
43-
);
44-
}
28+
public CONFIG = {
29+
base_url: '/tinymce',
30+
suffix: '.min',
31+
height: 200,
32+
menubar: false,
33+
plugins: [
34+
'advlist autolink lists link image charmap print preview anchor',
35+
'searchreplace visualblocks code fullscreen',
36+
'insertdatetime media table paste code help wordcount'
37+
],
38+
toolbar:
39+
'undo redo | formatselect | bold italic backcolor | \
40+
alignleft aligncenter alignright alignjustify | \
41+
bullist numlist outdent indent | removeformat | help',
42+
setup: this.tinySetup.bind(this)
43+
};
44+
constructor(private _zone: NgZone) {}
4545
tinySetup(ed) {
4646
ed.on('init', (args) => {
4747
this.mention.setIframe(ed.iframeElement);

0 commit comments

Comments
 (0)