Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public componentDidMount(): void {
const { readonly, activateRoosterOnMount, activateInViewMode } = this.props;
if (!readonly && activateRoosterOnMount) {
if (activateInViewMode) {
this._editor = new Editor(this._contentDiv, this._editorOptions);
this._updateContentToViewState(true /* isInitializing */);
} else {
this._trySwithToEditMode();
}
} else if (!this._hasPlaceholder) {
this._refreshPlaceholder();
}
}
let plugins: EditorPlugin[] = [new HyperLink(), new Paste(), new ContentEdit()];
if (additionalPlugins) {
plugins = plugins.concat(additionalPlugins);
}
let options: EditorOptions = {
plugins: plugins,
initialContent: initialContent,
defaultFormat: {
fontFamily: 'Calibri,Arial,Helvetica,sans-serif',
fontSize: '11pt',
textColor: '#000000',
},
};
return new Editor(contentDiv, options);
}
if (readonly) {
return false;
}
if (this.mode === LeanRoosterModes.Edit) {
if (alwaysForceUpdateForEditMode) {
this.forceUpdate();
}
return false;
}
if (onBeforeModeChange(LeanRoosterModes.Edit)) {
return;
}
const isInitializing = !this._editor;
if (isInitializing) {
this._editor = new Editor(this._contentDiv, this._editorOptions);
}
this._mode = LeanRoosterModes.Edit;
this._updateContentToViewState(isInitializing);
this.forceUpdate();
onAfterModeChange(LeanRoosterModes.Edit);
return true;
}
componentDidMount() {
this.editor = new Editor(this.contentDiv, this.getEditorOptions());
this.updateViewStateWhenUnmount = true;
this.updateContentToViewState(true /*isInitializing*/);
}
: null,
customReplace: pluginList.customReplace ? new CustomReplacePlugin() : null,
};
let plugins = [
...Object.keys(editorInstanceToggleablePlugins).map(
k => (editorInstanceToggleablePlugins as any)[k]
),
...this.props.plugins,
];
let defaultFormat = { ...this.state.defaultFormat };
let options: EditorOptions = {
plugins: plugins,
defaultFormat: defaultFormat,
undo: this.props.undo,
};
this.editor = new RoosterJsEditor(this.contentDiv, options);
}
}
const textColor = (document.getElementById('textColorDefaultFormat') as HTMLInputElement).value;
if (textColor) {
defaultFormat.textColor = textColor;
}
const fontFamily = (document.getElementById('fontNameDefaultFormat') as HTMLInputElement).value;
if (fontFamily) {
defaultFormat.fontFamily = fontFamily;
}
let editorOptions: EditorOptions = {
plugins: plugins,
defaultFormat: defaultFormat
};
setCurrentEditor(
new Editor(document.getElementById('editor') as HTMLDivElement, editorOptions)
);
updateSampleCode(plugins, defaultFormat, featuresChanged && features);
}