@sarunint/angular-simplemde
Version:
An Angular component for SimpleMDE
195 lines (185 loc) • 5.63 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('simplemde')) :
typeof define === 'function' && define.amd ? define('@sarunint/angular-simplemde', ['exports', '@angular/common', '@angular/core', '@angular/forms', 'simplemde'], factory) :
(factory((global.sarunint = global.sarunint || {}, global.sarunint['angular-simplemde'] = {}),global.ng.common,global.ng.core,global.ng.forms,global.SimpleMDE));
}(this, (function (exports,common,core,forms,SimpleMDE) { 'use strict';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var SIMPLEMDE_DEFAULT_OPTIONS = new core.InjectionToken('SimpleMDEDefaultOptions');
var __assign = (undefined && undefined.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var SimpleMDEComponent = /** @class */ (function () {
function SimpleMDEComponent(default_options) {
this.default_options = default_options;
}
/**
* @return {?}
*/
SimpleMDEComponent.prototype.ngAfterViewInit = /**
* @return {?}
*/
function () {
var _this = this;
this.simplemde = new SimpleMDE(__assign({}, this.default_options, this.options, { element: this.textarea.nativeElement }));
if (this.temp) {
this.simplemde.value(this.temp);
}
this.simplemde.codemirror.on('change', function () {
_this.onChange(_this.simplemde.value());
});
this.simplemde.codemirror.on('blur', function () {
_this.onTouched();
});
};
/**
* @return {?}
*/
SimpleMDEComponent.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
delete this.simplemde;
};
/**
* @param {?} value
* @return {?}
*/
SimpleMDEComponent.prototype.onChange = /**
* @param {?} value
* @return {?}
*/
function (value) {
if (this._onChange) {
this._onChange(value);
}
};
/**
* @return {?}
*/
SimpleMDEComponent.prototype.onTouched = /**
* @return {?}
*/
function () {
if (this._onTouched) {
this._onTouched();
}
};
/**
* @param {?} value
* @return {?}
*/
SimpleMDEComponent.prototype.writeValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
if (this.simplemde) {
this.simplemde.value(value);
}
else {
this.temp = value;
}
};
/**
* @param {?} fn
* @return {?}
*/
SimpleMDEComponent.prototype.registerOnChange = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
this._onChange = fn;
};
/**
* @param {?} fn
* @return {?}
*/
SimpleMDEComponent.prototype.registerOnTouched = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
this._onTouched = fn;
};
SimpleMDEComponent.decorators = [
{ type: core.Component, args: [{
selector: 'simplemde',
template: "<textarea #simplemde></textarea>",
providers: [
{
provide: forms.NG_VALUE_ACCESSOR,
useExisting: core.forwardRef(function () { return SimpleMDEComponent; }),
multi: true
}
]
},] },
];
/** @nocollapse */
SimpleMDEComponent.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: core.Inject, args: [SIMPLEMDE_DEFAULT_OPTIONS,] },] },
]; };
SimpleMDEComponent.propDecorators = {
"textarea": [{ type: core.ViewChild, args: ['simplemde',] },],
"options": [{ type: core.Input },],
};
return SimpleMDEComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ɵ0 = {};
var SimpleMDEModule = /** @class */ (function () {
function SimpleMDEModule() {
}
SimpleMDEModule.decorators = [
{ type: core.NgModule, args: [{
declarations: [SimpleMDEComponent],
exports: [SimpleMDEComponent],
imports: [common.CommonModule],
providers: [
{
provide: SIMPLEMDE_DEFAULT_OPTIONS,
useValue: ɵ0
}
]
},] },
];
/** @nocollapse */
SimpleMDEModule.ctorParameters = function () { return []; };
return SimpleMDEModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* Generated bundle index. Do not edit.
*/
exports.SimpleMDEModule = SimpleMDEModule;
exports.SimpleMDEComponent = SimpleMDEComponent;
exports.SIMPLEMDE_DEFAULT_OPTIONS = SIMPLEMDE_DEFAULT_OPTIONS;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=angular_simplemde.umd.js.map