Skip to content

Done froala/aurelia-froala-editor#1606 #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 58 additions & 53 deletions dist/amd/froala-editor.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
define(['exports', 'aurelia-framework', 'aurelia-binding', './froala-editor-config', 'froala-editor/js/froala_editor.pkgd.min.js'], function (exports, _aureliaFramework, _aureliaBinding, _froalaEditorConfig, _froala_editorPkgdMin) {
define(['exports', 'aurelia-framework', 'aurelia-binding', './froala-editor-config', 'froala-editor'], function (exports, _aureliaFramework, _aureliaBinding, _froalaEditorConfig, _froalaEditor) {
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FroalaEditor1 = undefined;

var _froala_editorPkgdMin2 = _interopRequireDefault(_froala_editorPkgdMin);
var _froalaEditor2 = _interopRequireDefault(_froalaEditor);

function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
Expand Down Expand Up @@ -63,12 +63,10 @@ define(['exports', 'aurelia-framework', 'aurelia-binding', './froala-editor-conf
throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.');
}

var _dec, _dec2, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3;
var _dec, _dec2, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;

var FroalaEditor1 = exports.FroalaEditor1 = (_dec = (0, _aureliaFramework.customElement)('froala-editor'), _dec2 = (0, _aureliaFramework.inject)(Element, _froalaEditorConfig.Config, _aureliaBinding.ObserverLocator), _dec(_class = _dec2(_class = (_class2 = function () {
function FroalaEditor1(element, config, observerLocator) {
var _this = this;

_classCallCheck(this, FroalaEditor1);

_initDefineProp(this, 'value', _descriptor, this);
Expand All @@ -77,69 +75,73 @@ define(['exports', 'aurelia-framework', 'aurelia-binding', './froala-editor-conf

_initDefineProp(this, 'eventHandlers', _descriptor3, this);

this.element = element;
_initDefineProp(this, 'editor', _descriptor4, this);

this.element = element;
this.config = config.options();

this.subscriptions = [observerLocator.getObserver(this, 'value').subscribe(function (newValue, oldValue) {
if (_this.instance && _this.instance.html.get() != newValue) {
_this.instance.html(newValue);
}
})];
this.observerLocator = observerLocator;
}

FroalaEditor1.prototype.tearUp = function tearUp() {
var _this2 = this;
FroalaEditor1.prototype.bind = function bind(bindingContext, overrideContext) {
this.parent = bindingContext;
};

if (this.config.iframe) {
this.instance = this.element.getElementsByTagName('textarea')[0];
} else {
this.instance = this.element.getElementsByTagName('div')[0];
}
FroalaEditor1.prototype.attached = function attached() {
var _this = this;

var editorSelector = this.config.iframe ? 'textarea' : 'div';
var editor = this;

if (this.instance['data-froala.editor']) {
if (this.editor != null) {
return;
}

this.instance.innerHTML = this.value;

if (this.eventHandlers && this.eventHandlers.length != 0) {
var _loop = function _loop(eventHandlerName) {
var handler = _this2.eventHandlers[eventHandlerName];
_this2.instance.addEventListener('' + eventHandlerName, function () {
var p = arguments;
return handler.apply(this, p);
});
};
this.subscriptions = [this.observerLocator.getObserver(this, 'value').subscribe(function (newValue, oldValue) {
if (_this.editor && _this.editor.html.get() != newValue) {
_this.editor.html.set(newValue);
}
})];

for (var eventHandlerName in this.eventHandlers) {
_loop(eventHandlerName);
this.config.events = {
contentChanged: function contentChanged(e) {
return editor.value = this.html.get();
},
blur: function blur(e) {
return editor.value = this.html.get();
}
};

this.editor = new _froalaEditor2.default(this.element, Object.assign({}, this.config), function () {
_this.editor.html.set(_this.value);

if (_this.eventHandlers && _this.eventHandlers.length != 0) {
var _loop = function _loop(eventHandlerName) {
var handler = _this.eventHandlers[eventHandlerName];
if (eventHandlerName === 'initialized') {
handler.apply(_this.parent);
} else {
_this.editor.events.on('' + eventHandlerName, function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

return handler.apply(_this.parent, args);
});
}
};

for (var eventHandlerName in _this.eventHandlers) {
_loop(eventHandlerName);
}
}
}
this.instance.addEventListener('contentChanged', function (e, editor) {
return _this2.value = editor.html.get();
});
this.instance.addEventListener('blur', function (e, editor) {
return _this2.value = editor.html.get();
});

this.instance = new _froala_editorPkgdMin2.default(this.element, Object.assign({}, this.config));
};

FroalaEditor1.prototype.tearDown = function tearDown() {
if (this.instance && this.instance['data-froala.editor']) {
this.instance.destroy();
}

this.instance = null;
};

FroalaEditor1.prototype.attached = function attached() {
this.tearUp();
};

FroalaEditor1.prototype.detached = function detached() {
this.tearDown();
if (this.editor != null) {
this.editor.destroy();
this.editor = null;
}
};

return FroalaEditor1;
Expand All @@ -156,5 +158,8 @@ define(['exports', 'aurelia-framework', 'aurelia-binding', './froala-editor-conf
initializer: function initializer() {
return {};
}
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'editor', [_aureliaFramework.bindable], {
enumerable: true,
initializer: null
})), _class2)) || _class) || _class);
});
111 changes: 58 additions & 53 deletions dist/commonjs/froala-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
});
exports.FroalaEditor1 = undefined;

var _dec, _dec2, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3;
var _dec, _dec2, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;

var _aureliaFramework = require('aurelia-framework');

var _aureliaBinding = require('aurelia-binding');

var _froalaEditorConfig = require('./froala-editor-config');

var _froala_editorPkgdMin = require('froala-editor/js/froala_editor.pkgd.min.js');
var _froalaEditor = require('froala-editor');

var _froala_editorPkgdMin2 = _interopRequireDefault(_froala_editorPkgdMin);
var _froalaEditor2 = _interopRequireDefault(_froalaEditor);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

Expand Down Expand Up @@ -66,8 +66,6 @@ function _initializerWarningHelper(descriptor, context) {

var FroalaEditor1 = exports.FroalaEditor1 = (_dec = (0, _aureliaFramework.customElement)('froala-editor'), _dec2 = (0, _aureliaFramework.inject)(Element, _froalaEditorConfig.Config, _aureliaBinding.ObserverLocator), _dec(_class = _dec2(_class = (_class2 = function () {
function FroalaEditor1(element, config, observerLocator) {
var _this = this;

_classCallCheck(this, FroalaEditor1);

_initDefineProp(this, 'value', _descriptor, this);
Expand All @@ -76,69 +74,73 @@ var FroalaEditor1 = exports.FroalaEditor1 = (_dec = (0, _aureliaFramework.custom

_initDefineProp(this, 'eventHandlers', _descriptor3, this);

this.element = element;
_initDefineProp(this, 'editor', _descriptor4, this);

this.element = element;
this.config = config.options();

this.subscriptions = [observerLocator.getObserver(this, 'value').subscribe(function (newValue, oldValue) {
if (_this.instance && _this.instance.html.get() != newValue) {
_this.instance.html(newValue);
}
})];
this.observerLocator = observerLocator;
}

FroalaEditor1.prototype.tearUp = function tearUp() {
var _this2 = this;
FroalaEditor1.prototype.bind = function bind(bindingContext, overrideContext) {
this.parent = bindingContext;
};

if (this.config.iframe) {
this.instance = this.element.getElementsByTagName('textarea')[0];
} else {
this.instance = this.element.getElementsByTagName('div')[0];
}
FroalaEditor1.prototype.attached = function attached() {
var _this = this;

var editorSelector = this.config.iframe ? 'textarea' : 'div';
var editor = this;

if (this.instance['data-froala.editor']) {
if (this.editor != null) {
return;
}

this.instance.innerHTML = this.value;

if (this.eventHandlers && this.eventHandlers.length != 0) {
var _loop = function _loop(eventHandlerName) {
var handler = _this2.eventHandlers[eventHandlerName];
_this2.instance.addEventListener('' + eventHandlerName, function () {
var p = arguments;
return handler.apply(this, p);
});
};
this.subscriptions = [this.observerLocator.getObserver(this, 'value').subscribe(function (newValue, oldValue) {
if (_this.editor && _this.editor.html.get() != newValue) {
_this.editor.html.set(newValue);
}
})];

for (var eventHandlerName in this.eventHandlers) {
_loop(eventHandlerName);
this.config.events = {
contentChanged: function contentChanged(e) {
return editor.value = this.html.get();
},
blur: function blur(e) {
return editor.value = this.html.get();
}
};

this.editor = new _froalaEditor2.default(this.element, Object.assign({}, this.config), function () {
_this.editor.html.set(_this.value);

if (_this.eventHandlers && _this.eventHandlers.length != 0) {
var _loop = function _loop(eventHandlerName) {
var handler = _this.eventHandlers[eventHandlerName];
if (eventHandlerName === 'initialized') {
handler.apply(_this.parent);
} else {
_this.editor.events.on('' + eventHandlerName, function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

return handler.apply(_this.parent, args);
});
}
};

for (var eventHandlerName in _this.eventHandlers) {
_loop(eventHandlerName);
}
}
}
this.instance.addEventListener('contentChanged', function (e, editor) {
return _this2.value = editor.html.get();
});
this.instance.addEventListener('blur', function (e, editor) {
return _this2.value = editor.html.get();
});

this.instance = new _froala_editorPkgdMin2.default(this.element, Object.assign({}, this.config));
};

FroalaEditor1.prototype.tearDown = function tearDown() {
if (this.instance && this.instance['data-froala.editor']) {
this.instance.destroy();
}

this.instance = null;
};

FroalaEditor1.prototype.attached = function attached() {
this.tearUp();
};

FroalaEditor1.prototype.detached = function detached() {
this.tearDown();
if (this.editor != null) {
this.editor.destroy();
this.editor = null;
}
};

return FroalaEditor1;
Expand All @@ -155,4 +157,7 @@ var FroalaEditor1 = exports.FroalaEditor1 = (_dec = (0, _aureliaFramework.custom
initializer: function initializer() {
return {};
}
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'editor', [_aureliaFramework.bindable], {
enumerable: true,
initializer: null
})), _class2)) || _class) || _class);
Loading