@mescius/inputman.comment.angular
Version:
このパッケージには、Angular用の[InputManJS](https://developer.mescius.jp/inputmanjs)コンポーネントが含まれます。
341 lines (335 loc) • 14.9 kB
JavaScript
import * as i0 from '@angular/core';
import { EventEmitter, Component, Input, Output, NgModule } from '@angular/core';
import * as GC from '@mescius/inputman.comment';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
const IMCommentCtrl = "__imcomment";
function Property(setter, getter, isPramArr, supportWithinConfig, order) {
var saveToTargetProDic = function (target, propertyName) {
var methods = {
setter: setter,
getter: getter,
isPramArr: isPramArr,
supportWithinConfig: (typeof supportWithinConfig === "boolean") ? supportWithinConfig : true,
order: (typeof order === "number") ? order : -1
};
if (!target.propDic) {
target.propDic = {};
}
target.propDic[propertyName] = methods;
};
return saveToTargetProDic;
}
const isEmpty = function (value) {
return value === undefined || value === null || value === "";
};
const getMethodPrefix = function (type) {
if (type === MethodType.getter) {
return "get";
}
else if (type === MethodType.setter) {
return "set";
}
return '';
};
var MethodType;
(function (MethodType) {
MethodType[MethodType["getter"] = 0] = "getter";
MethodType[MethodType["setter"] = 1] = "setter";
})(MethodType || (MethodType = {}));
class GcCommentComponent {
constructor(ref) {
this.editorCreated = new EventEmitter();
this.preprocessError = new EventEmitter();
this.beforeExecuteCommand = new EventEmitter();
this.afterExecuteCommand = new EventEmitter();
this.beforeFirstLoad = new EventEmitter();
this.afterFirstLoad = new EventEmitter();
this.onInitialized = new EventEmitter();
this._container = ref.nativeElement;
}
ngOnChanges(changes) {
if (!this._imGcComment) {
return;
}
Object.keys(changes).forEach((key) => {
let currentValue = changes[key].currentValue;
this.setValueToIMControl(key, currentValue);
});
}
setValueToIMControl(key, value) {
if (value === undefined) {
return;
}
if (this.isSetAccessor(key)) {
this._imGcComment[key] = value;
return;
}
let setter = this.tryGetPropertyOperator(key, MethodType.setter);
if (this.hasRealMethod(setter)) {
if (this.propDic &&
this.propDic[key] &&
this.propDic[key].isPramArr === true) {
this._imGcComment[setter].apply(this._imGcComment, value);
}
else {
this._imGcComment[setter](value);
}
}
}
hasRealMethod(methodName) {
return (this._imGcComment &&
typeof this._imGcComment[methodName] === "function");
}
isSetAccessor(key) {
let descriptor = Object.getOwnPropertyDescriptor(this._imGcComment.constructor.prototype, key);
if (descriptor && descriptor.set) {
return true;
}
return false;
}
tryGetPropertyOperator(propertyName, methodType) {
let method = "";
if (this.propDic && this.propDic[propertyName]) {
method =
methodType === MethodType.getter
? this.propDic[propertyName].getter
: this.propDic[propertyName].setter;
if (!isEmpty(method)) {
return method;
}
}
return (getMethodPrefix(methodType) +
propertyName[0].toUpperCase() +
propertyName.slice(1));
}
ngAfterContentInit() {
this.initGcComment();
this.bindEvent();
if (this.propDic) {
var unSupportWithinConfigProps = Object.keys(this.propDic).filter((p) => this.propDic[p] &&
this.propDic[p].supportWithinConfig === false);
unSupportWithinConfigProps.sort((p1, p2) => {
return this.propDic[p1].order - this.propDic[p2].order;
});
unSupportWithinConfigProps.forEach((p) => {
this.setValueToIMControl(p, this[p]);
});
}
this._container[IMCommentCtrl] = this._imGcComment;
}
bindEvent() {
if (!this._imGcComment) {
return;
}
this._imGcComment.addEventListener(GC.InputMan.GcCommentEvent.EditorCreated, (e) => {
this.editorCreated.emit(e);
});
this._imGcComment.addEventListener(GC.InputMan.GcCommentEvent.PreprocessError, (e) => {
this.preprocessError.emit(e);
});
this._imGcComment.addEventListener(GC.InputMan.GcCommentEvent.BeforeExecuteCommand, (e) => {
this.beforeExecuteCommand.emit(e);
});
this._imGcComment.addEventListener(GC.InputMan.GcCommentEvent.AfterExecuteCommand, (e) => {
this.afterExecuteCommand.emit(e);
});
this._imGcComment.addEventListener(GC.InputMan.GcCommentEvent.BeforeFirstLoad, () => {
this.beforeFirstLoad.emit();
});
this._imGcComment.addEventListener(GC.InputMan.GcCommentEvent.AfterFirstLoad, () => {
this.afterFirstLoad.emit();
});
}
ngOnDestroy() {
if (this._container != null) {
this._container.remove();
this._imGcComment?.destroy?.();
this._imGcComment = null;
}
}
initGcComment() {
let element = document.createElement('div');
this.createTemplate(element);
this._imGcComment = new GC.InputMan.GcComment(element, this);
if (Array.isArray(this.comments)) {
this._imGcComment.comments = this.comments;
}
if (this.stickedComment) {
this._imGcComment.stickedComment = this.stickedComment;
}
this._imGcComment.addEventListener(GC.InputMan.GcCommentEvent.CreateEditor, this.createEditor);
this.onInitialized.emit(this._imGcComment);
}
createTemplate(element) {
this._container.innerHTML = "";
this._container.appendChild(element);
}
getNestedIMControl() {
return this._imGcComment;
}
}
GcCommentComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: GcCommentComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
GcCommentComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: GcCommentComponent, selector: "gc-comment", inputs: { userInfo: "userInfo", candidateReactionList: "candidateReactionList", candidateReactionListColumns: "candidateReactionListColumns", postTimeFormatter: "postTimeFormatter", updateTimeFormatter: "updateTimeFormatter", showIcon: "showIcon", addCommentEditorPosition: "addCommentEditorPosition", commentMode: "commentMode", header: "header", footer: "footer", headerFooterItems: "headerFooterItems", commentAction: "commentAction", commentInfoAction: "commentInfoAction", commentActionItem: "commentActionItem", commentInfoActionItem: "commentInfoActionItem", commentActionButtonType: "commentActionButtonType", pageSize: "pageSize", loadOnDemand: "loadOnDemand", allowAnonymous: "allowAnonymous", anonymousUserInfo: "anonymousUserInfo", warningMessage: "warningMessage", watermark: "watermark", commentFormatter: "commentFormatter", editorConfig: "editorConfig", avatarType: "avatarType", loadUsersInfoHandler: "loadUsersInfoHandler", loadComments: "loadComments", addNewCommentTo: "addNewCommentTo", keepDraft: "keepDraft", dataSource: "dataSource", loadCommentCount: "loadCommentCount", commentCountFormatter: "commentCountFormatter", loadReactionCount: "loadReactionCount", reactionCountFormatter: "reactionCountFormatter", sortInfo: "sortInfo", createEditor: "createEditor", loadRepliesOnDemand: "loadRepliesOnDemand", replyLevel: "replyLevel", collapseRepliesMode: "collapseRepliesMode", showCurrentUserName: "showCurrentUserName", contextToolbar: "contextToolbar", contextToolbarItem: "contextToolbarItem", loadCommentReplies: "loadCommentReplies", comments: "comments", stickedComment: "stickedComment", copiedLinkDisplayTextFormatter: "copiedLinkDisplayTextFormatter", copiedLinkFormatter: "copiedLinkFormatter", copiedLinkSearchParams: "copiedLinkSearchParams", pastedLinkType: "pastedLinkType", showLinkTypeContextToolbar: "showLinkTypeContextToolbar", loadCommentByLink: "loadCommentByLink", openLinkMode: "openLinkMode", loadStickedComment: "loadStickedComment", showZeroReaction: "showZeroReaction", showOpenReactionListButton: "showOpenReactionListButton" }, outputs: { editorCreated: "editorCreated", preprocessError: "preprocessError", beforeExecuteCommand: "beforeExecuteCommand", afterExecuteCommand: "afterExecuteCommand", beforeFirstLoad: "beforeFirstLoad", afterFirstLoad: "afterFirstLoad", onInitialized: "onInitialized" }, usesOnChanges: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: GcCommentComponent, decorators: [{
type: Component,
args: [{
selector: "gc-comment",
template: `<ng-content></ng-content>`,
}]
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { userInfo: [{
type: Input
}], candidateReactionList: [{
type: Input
}], candidateReactionListColumns: [{
type: Input
}], postTimeFormatter: [{
type: Input
}], updateTimeFormatter: [{
type: Input
}], showIcon: [{
type: Input
}], addCommentEditorPosition: [{
type: Input
}], commentMode: [{
type: Input
}], header: [{
type: Input
}], footer: [{
type: Input
}], headerFooterItems: [{
type: Input
}], commentAction: [{
type: Input
}], commentInfoAction: [{
type: Input
}], commentActionItem: [{
type: Input
}], commentInfoActionItem: [{
type: Input
}], commentActionButtonType: [{
type: Input
}], pageSize: [{
type: Input
}], loadOnDemand: [{
type: Input
}], allowAnonymous: [{
type: Input
}], anonymousUserInfo: [{
type: Input
}], warningMessage: [{
type: Input
}], watermark: [{
type: Input
}], commentFormatter: [{
type: Input
}], editorConfig: [{
type: Input
}], avatarType: [{
type: Input
}], loadUsersInfoHandler: [{
type: Input
}], loadComments: [{
type: Input
}], addNewCommentTo: [{
type: Input
}], keepDraft: [{
type: Input
}], dataSource: [{
type: Input
}], loadCommentCount: [{
type: Input
}], commentCountFormatter: [{
type: Input
}], loadReactionCount: [{
type: Input
}], reactionCountFormatter: [{
type: Input
}], sortInfo: [{
type: Input
}], createEditor: [{
type: Input
}], loadRepliesOnDemand: [{
type: Input
}], replyLevel: [{
type: Input
}], collapseRepliesMode: [{
type: Input
}], showCurrentUserName: [{
type: Input
}], contextToolbar: [{
type: Input
}], contextToolbarItem: [{
type: Input
}], loadCommentReplies: [{
type: Input
}], comments: [{
type: Input
}], stickedComment: [{
type: Input
}], copiedLinkDisplayTextFormatter: [{
type: Input
}], copiedLinkFormatter: [{
type: Input
}], copiedLinkSearchParams: [{
type: Input
}], pastedLinkType: [{
type: Input
}], showLinkTypeContextToolbar: [{
type: Input
}], loadCommentByLink: [{
type: Input
}], openLinkMode: [{
type: Input
}], loadStickedComment: [{
type: Input
}], showZeroReaction: [{
type: Input
}], showOpenReactionListButton: [{
type: Input
}], editorCreated: [{
type: Output
}], preprocessError: [{
type: Output
}], beforeExecuteCommand: [{
type: Output
}], afterExecuteCommand: [{
type: Output
}], beforeFirstLoad: [{
type: Output
}], afterFirstLoad: [{
type: Output
}], onInitialized: [{
type: Output
}] } });
/*Import from angular */
/**
* Declare & add export modules
*/
class InputManModule {
}
InputManModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: InputManModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
InputManModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: InputManModule, declarations: [GcCommentComponent], imports: [CommonModule,
FormsModule], exports: [GcCommentComponent] });
InputManModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: InputManModule, imports: [CommonModule,
FormsModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: InputManModule, decorators: [{
type: NgModule,
args: [{
imports: [
CommonModule,
FormsModule
],
declarations: [
GcCommentComponent,
],
exports: [
GcCommentComponent
]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { GcCommentComponent, InputManModule };
//# sourceMappingURL=mescius-inputman.comment.angular.mjs.map