forked from andyhot/ember-ckeditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
68 lines (56 loc) · 1.57 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
'use strict';
const Funnel = require('broccoli-funnel');
const UnwatchedDir = require('broccoli-source').UnwatchedDir;
const mergeTrees = require('broccoli-merge-trees');
const stew = require('broccoli-stew');
const path = require('path');
const map = stew.map;
module.exports = {
name: require('./package').name,
included: function(app) {
this._super.included(app);
let ckeditorPath = path.dirname(require.resolve('ckeditor'));
this.ckeditorNode = new UnwatchedDir(ckeditorPath);
app.import('vendor/ckeditor/ckeditor.js');
},
contentFor: function(type, config) {
if (type === 'head') {
return `<script>window.CKEDITOR_BASEPATH = '${config.rootURL}assets/ckeditor/';</script>`;
}
},
treeForPublic: function(_tree) {
let trees = [];
trees.push(
Funnel(this.ckeditorNode, {
srcDir: '/',
include: [
'config.js',
'styles.js',
'contents.css',
'skins/moono-lisa/**/*',
'lang/en.js',
'plugins/**/lang/en.js',
'plugins/**/styles/*.css',
'plugins/**/dialogs/*.{css,js}',
'plugins/**/skins/**/*.css',
'plugins/*/*.js',
],
destDir: '/assets/ckeditor'
})
);
return mergeTrees(trees);
},
treeForVendor(vendorTree) {
let trees = [];
if (vendorTree) {
trees.push(vendorTree);
}
trees.push(
Funnel(this.ckeditorNode, {
srcDir: '/',
include: ['ckeditor.js'],
destDir: 'ckeditor',
}))
return map(mergeTrees(trees), (content) => `${content}`)
}
};