Skip to content

Commit 5a292ee

Browse files
committed
Fix dynamic language loading
Fixes #214
1 parent 7071f00 commit 5a292ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+265
-389
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"name": "alloy-editor",
33
"version": "0.2.8",
44
"description": "Alloy Editor, a modern WYSIWYG editor, build on top of CKEditor",
5-
"dependencies": {},
6-
"devDependencies": {
5+
"dependencies": {
76
"bourbon": "https://github.com/thoughtbot/bourbon/tarball/master",
87
"chai": "^2.3.0",
98
"del": "^1.2.0",
@@ -64,4 +63,4 @@
6463
"url": "https://github.com/liferay/alloy-editor/issues"
6564
},
6665
"homepage": "http://alloyeditor.com"
67-
}
66+
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@ module.exports = [
1515
'ui/react/src/selections/selection-position.js',
1616
'ui/react/src/selections/selection-test.js',
1717
'ui/react/src/selections/selections.js',
18-
'ui/react/src/adapter/alloy-editor.js'
18+
'ui/react/src/adapter/alloy-editor.js',
19+
'ui/react/src/components/base/*.js*',
20+
'ui/react/src/components/buttons/*.js*',
21+
'ui/react/src/components/toolbars/*.js*',
22+
'ui/react/src/components/main.js*'
1923
];

src/ui/react/_ui.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/ui/react/gulp-tasks/build.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
var gulp = require('gulp');
44

55
var argv = require('yargs').argv;
6+
var react = require('gulp-react');
67
var concat = require('gulp-concat');
78
var del = require('del');
89
var fs = require('fs');
910
var path = require('path');
10-
var react = require('gulp-react');
1111
var rename = require('gulp-rename');
1212
var replace = require('gulp-replace');
1313
var runSequence = require('run-sequence');
@@ -24,8 +24,7 @@ var apiFolder = path.join(rootDir, 'api');
2424
var distFolder = path.join(rootDir, 'dist');
2525
var editorDistFolder = path.join(distFolder, 'alloy-editor-' + pkg.version, 'alloy-editor');
2626

27-
var coreFiles = require('../_core.js');
28-
var uiFiles = require('../_ui.js');
27+
var srcFiles = require('../_src.js');
2928

3029
function errorHandler(error) {
3130
console.log(error.toString());
@@ -127,8 +126,7 @@ gulp.task('build-demo', function() {
127126
gulp.task('build-js', function(callback) {
128127
runSequence([
129128
'copy-ckeditor',
130-
'create-alloy-editor-core',
131-
'create-alloy-editor-core-ui'
129+
'create-alloy-editor-core'
132130
], 'wrap-alloy-editor', callback);
133131
});
134132

@@ -211,19 +209,12 @@ gulp.task('create-alloy-editor-no-react-min', function() {
211209
});
212210

213211
gulp.task('create-alloy-editor-core', function() {
214-
return gulp.src(coreFiles, {cwd : rootDir + '/src'})
212+
return gulp.src(srcFiles, {cwd : rootDir + '/src'})
215213
.pipe(react()).on('error', errorHandler)
216214
.pipe(concat('alloy-editor-core.js'))
217215
.pipe(gulp.dest(editorDistFolder));
218216
});
219217

220-
gulp.task('create-alloy-editor-core-ui', function() {
221-
return gulp.src(uiFiles, {cwd : rootDir + '/src'})
222-
.pipe(react()).on('error', errorHandler)
223-
.pipe(concat('alloy-editor-core-ui.js'))
224-
.pipe(gulp.dest(editorDistFolder));
225-
});
226-
227218
gulp.task('create-zip', function() {
228219
return gulp.src(path.join(distFolder, '/**'))
229220
.pipe(zip('alloy-editor-' + pkg.version + '.zip'))

src/ui/react/gulp-tasks/test.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict';
22

33
var argv = require('yargs').argv;
4+
var react = require('gulp-react');
45
var gulp = require('gulp');
56
var karma = require('karma').server;
67
var mkdirp = require('mkdirp');
78
var path = require('path');
8-
var react = require('gulp-react');
99
var runSequence = require('run-sequence');
1010

1111
var rootDir = path.join(__dirname, '..', '..', '..', '..');
@@ -15,14 +15,13 @@ var pkg = require(path.join(rootDir, 'package.json'));
1515
var distFolder = path.join(rootDir, 'dist');
1616
var editorDistFolder = path.join(distFolder, 'alloy-editor-' + pkg.version, 'alloy-editor');
1717

18-
var coreFiles = require('../_core.js');
18+
var srcFiles = require('../_src.js');
1919
var languageFiles = require('../_languages.js');
20-
var uiFiles = require('../_ui.js');
2120

2221
gulp.task('prepare-files', function(done) {
2322
runSequence(
2423
'clean-dist', 'create-output-dir', [
25-
'build-css', 'copy-ckeditor', 'copy-core-files', 'copy-ui-files', 'copy-language-files', 'copy-react'
24+
'build-css', 'copy-ckeditor', 'copy-core-files', 'copy-language-files', 'copy-react'
2625
], done);
2726
});
2827

@@ -31,7 +30,7 @@ gulp.task('create-output-dir', function(callback) {
3130
});
3231

3332
gulp.task('copy-core-files', function() {
34-
return gulp.src(coreFiles, {cwd: 'src', base: 'src'})
33+
return gulp.src(srcFiles, {cwd: 'src', base: 'src'})
3534
.pipe(react())
3635
.pipe(gulp.dest(path.join(editorDistFolder, 'test')));
3736
});
@@ -41,12 +40,6 @@ gulp.task('copy-language-files', function() {
4140
.pipe(gulp.dest(path.join(editorDistFolder, 'test')));
4241
});
4342

44-
gulp.task('copy-ui-files', function() {
45-
return gulp.src(uiFiles, {cwd: 'src', base: 'src'})
46-
.pipe(react())
47-
.pipe(gulp.dest(path.join(editorDistFolder, 'test')));
48-
});
49-
5043
gulp.task('copy-react', function() {
5144
return gulp.src(path.join(reactDir, 'vendor', 'react-with-addons.js'))
5245
.pipe(gulp.dest(editorDistFolder));

src/ui/react/gulp-tasks/wrap.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,11 @@ var distFolder = path.join(rootDir, 'dist');
1515
var pkg = require(path.join(rootDir, 'package.json'));
1616
var editorDistFolder = path.join(distFolder, 'alloy-editor-' + pkg.version, 'alloy-editor');
1717

18-
gulp.task('join-core-ui', function() {
19-
return gulp.src(path.join(reactDir, 'template/alloy-editor.template'))
18+
gulp.task('wrap-alloy-editor', function () {
19+
return gulp.src(path.join(reactDir, 'template/alloy-editor.template'))
2020
.pipe(template({
21-
core: fs.readFileSync(path.join(editorDistFolder, 'alloy-editor-core.js')),
22-
ui: fs.readFileSync(path.join(editorDistFolder, 'alloy-editor-core-ui.js'))
21+
core: fs.readFileSync(path.join(editorDistFolder, 'alloy-editor-core.js'))
2322
}))
2423
.pipe(rename('alloy-editor-core.js'))
2524
.pipe(gulp.dest(editorDistFolder));
26-
});
27-
28-
gulp.task('clean-ui', function(done) {
29-
del(path.join(editorDistFolder, 'alloy-editor-core-ui.js'), done);
30-
});
31-
32-
gulp.task('wrap-alloy-editor', ['join-core-ui', 'clean-ui']);
25+
});

src/ui/react/karma.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ var alloyEditorDir = 'dist/alloy-editor-*/alloy-editor/';
77
var argv = require('yargs').argv;
88
var path = require('path');
99

10-
var coreFiles = require('./_core.js');
11-
var uiFiles = require('./_ui.js');
10+
var srcFiles = require('./_src.js');
1211

1312
var preprocessors = {
1413
'**/*.jsx': ['react-jsx'],
@@ -77,7 +76,7 @@ var filesToLoad = [
7776
'src/ui/react/test/fixtures/**/*'
7877
];
7978

80-
coreFiles.forEach(function(file) {
79+
srcFiles.forEach(function(file) {
8180
filesToLoad.push({
8281
pattern: path.join(alloyEditorDir, 'test', file),
8382
included: true,
@@ -86,21 +85,13 @@ coreFiles.forEach(function(file) {
8685
});
8786

8887
filesToLoad.push({
89-
pattern: path.join(alloyEditorDir, 'test/ui/react/lang/en.js'),
88+
pattern: 'src/ui/react/test/*.js*',
9089
included: true,
9190
watched: false
9291
});
9392

94-
uiFiles.forEach(function(file) {
95-
filesToLoad.push({
96-
pattern: path.join(alloyEditorDir, 'test', file),
97-
included: true,
98-
watched: false
99-
});
100-
});
101-
10293
filesToLoad.push({
103-
pattern: 'src/ui/react/test/*.js*',
94+
pattern: path.join(alloyEditorDir, 'test/ui/react/lang/en.js'),
10495
included: true,
10596
watched: false
10697
});

src/ui/react/src/adapter/alloy-editor.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
AlloyEditor.OOP.extend(Core, AlloyEditor.Base, {
1616
/**
1717
* Initializer lifecycle implementation for the AlloyEditor class. Creates a CKEditor
18-
* instace, passing it the provided configuration attributes.
18+
* instance, passing it the provided configuration attributes.
1919
*
2020
* @protected
2121
* @method initializer
@@ -76,6 +76,13 @@
7676
return this._editor;
7777
},
7878

79+
/**
80+
* Detects and load the corresponding language file
81+
* if AlloyEditor language strings are not already present.
82+
*
83+
* @protected
84+
* @method _loadLanguageFile
85+
*/
7986
_loadLanguageFile: function() {
8087
var onLanguageFileLoad = function() {
8188
CKEDITOR.fire('resourcesLoaded');

src/ui/react/src/components/base/widget-focus-manager.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565

6666
/**
6767
* Lifecycle. Invoked immediately after the component's updates are flushed to the DOM.
68-
*
6968
* Refreshes the descendants list.
7069
*
7170
* @method componentDidUpdate

src/ui/react/src/components/buttons/button-bold.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
getDefaultProps: function() {
6060
return {
6161
command: 'bold',
62-
label: AlloyEditor.Strings.bold,
6362
style: {
6463
element: 'strong'
6564
}
@@ -76,7 +75,7 @@
7675
var cssClass = 'alloy-editor-button ' + this.getStateClasses();
7776

7877
return (
79-
<button aria-label={this.props.label} aria-pressed={cssClass.indexOf('pressed') !== -1} className={cssClass} data-type="button-bold" onClick={this.execCommand} tabIndex={this.props.tabIndex} title={this.props.label}>
78+
<button aria-label={AlloyEditor.Strings.bold} aria-pressed={cssClass.indexOf('pressed') !== -1} className={cssClass} data-type="button-bold" onClick={this.execCommand} tabIndex={this.props.tabIndex} title={AlloyEditor.Strings.bold}>
8079
<span className="alloy-editor-icon-bold"></span>
8180
</button>
8281
);

0 commit comments

Comments
 (0)