ionic-mathlive
Version:
A Ionic-mathlive math.
104 lines (98 loc) • 4.87 kB
JavaScript
import { __decorate } from 'tslib';
import { EventEmitter, ViewChild, Input, Output, Component, forwardRef, NgModule } from '@angular/core';
import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
import { makeMathField } from 'mathlive';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';
var IonMathliveComponent = /** @class */ (function () {
// get accessor
function IonMathliveComponent() {
var _this = this;
this.disabled = false;
// tslint:disable-next-line:no-output-on-prefix
this.onValueChange = new EventEmitter();
this.onChange = function () { };
this.onTouched = function () { };
this.writeValue = function (mathfield) {
_this.answer = mathfield.$text();
_this.onValueChange.emit(_this.answer);
};
}
IonMathliveComponent_1 = IonMathliveComponent;
// tslint:disable-next-line:use-lifecycle-interface
IonMathliveComponent.prototype.ngAfterViewInit = function () {
makeMathField(this.mathfield.nativeElement, {
onContentDidChange: this.writeValue,
virtualKeyboardMode: 'onfocus',
virtualKeyboards: 'all',
});
};
IonMathliveComponent.prototype.ngOnInit = function () {
};
Object.defineProperty(IonMathliveComponent.prototype, "value", {
get: function () {
return this.answer;
},
set: function (val) {
this.answer = val;
this.onChange(val);
this.onTouched();
},
enumerable: true,
configurable: true
});
IonMathliveComponent.prototype.registerOnChange = function (fn) {
this.onChange = fn;
};
IonMathliveComponent.prototype.registerOnTouched = function (fn) {
this.onTouched = fn;
};
IonMathliveComponent.prototype.setDisabledState = function (disabled) {
this.disabled = disabled;
};
var IonMathliveComponent_1;
__decorate([
ViewChild('mathfield', { static: true })
], IonMathliveComponent.prototype, "mathfield", void 0);
__decorate([
Input('answer')
], IonMathliveComponent.prototype, "answer", void 0);
__decorate([
Input()
], IonMathliveComponent.prototype, "disabled", void 0);
__decorate([
Output()
], IonMathliveComponent.prototype, "onValueChange", void 0);
IonMathliveComponent = IonMathliveComponent_1 = __decorate([
Component({
// tslint:disable-next-line
selector: 'ionic-mathlive',
template: "<div id=\"mathfield\" class=\"mathfield\" #mathfield ngDefaultControl name=\"answer\" [(ngModel)]=\"answer\">\n\n</div >\n",
providers: [
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return IonMathliveComponent_1; }), multi: true }
],
styles: ["#ML__keyboard{position:absolute;left:0;padding-top:5px;width:100vw;z-index:3;transition:.28s cubic-bezier(0,0,.2,1);bottom:-267px;opacity:0;visibility:hidden;-webkit-backdrop-filter:grayscale(50%);backdrop-filter:grayscale(50%);background-color:rgba(209,213,217,.9);border:1px solid #ddd;font-family:-apple-system,BlinkMacSystemFont,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Droid Sans,Helvetica Neue,sans-serif;font-size:16px;font-weight:400;margin:0;text-shadow:none;box-sizing:border-box;touch-action:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer;box-shadow:0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23)}#ML__keyboard div.alternate-keys{-ms-flex-line-pack:center;-ms-flex-pack:center;-webkit-box-pack:center;-webkit-box-shadow:0 14px 28px rgba(0,0,0,.25),0 10px 10px rgba(0,0,0,.22);-webkit-transition:none;align-content:center;background-color:#fff;border-radius:6px;box-shadow:0 14px 28px rgba(0,0,0,.25),0 10px 10px rgba(0,0,0,.22);display:flex;flex-direction:row;justify-content:center;max-width:50vw;position:unset;text-align:center;transition:none;visibility:hidden;z-index:101}.mathfield{width:60vw;height:10vh;border:1px solid #ddd;padding:5px;margin:auto;border-radius:5px;background-color:#eee}"]
})
], IonMathliveComponent);
return IonMathliveComponent;
}());
var IonicMathliveModule = /** @class */ (function () {
function IonicMathliveModule() {
}
IonicMathliveModule = __decorate([
NgModule({
imports: [CommonModule, FormsModule, IonicModule],
exports: [IonMathliveComponent],
declarations: [IonMathliveComponent]
})
], IonicMathliveModule);
return IonicMathliveModule;
}());
/*
* Public API Surface of ionic-mathlive
*/
/**
* Generated bundle index. Do not edit.
*/
export { IonMathliveComponent, IonicMathliveModule };
//# sourceMappingURL=ionic-mathlive.js.map