UNPKG

jodit

Version:

Jodit is an awesome and useful wysiwyg editor with filebrowser

46 lines (45 loc) 1.77 kB
/*! * Jodit Editor (https://xdsoft.net/jodit/) * Released under MIT see LICENSE.txt in the project root for license information. * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net */ import { getComponentClass } from "../../core/decorators/component/component.js"; import { isFunction } from "../../core/helpers/checker/is-function.js"; import { isJoditObject } from "../../core/helpers/checker/is-jodit-object.js"; /** * Collection factory */ export function makeCollection(jodit, parentElement) { const ToolbarCollection = getComponentClass('ToolbarCollection'); const ToolbarEditorCollection = getComponentClass('ToolbarEditorCollection'); const collection = isJoditObject(jodit) ? new ToolbarEditorCollection(jodit) : new ToolbarCollection(jodit); if (jodit.o.textIcons) { collection.container.classList.add('jodit_text_icons'); } if (parentElement) { collection.parentElement = parentElement; } if (jodit.o.toolbarButtonSize) { collection.buttonSize = jodit.o.toolbarButtonSize; } return collection; } /** * Button factory */ export function makeButton(jodit, control, target = null) { if (isFunction(control.getContent)) { const ToolbarContent = getComponentClass('ToolbarContent'); return new ToolbarContent(jodit, control, target); } const ToolbarButton = getComponentClass('ToolbarButton'); const button = new ToolbarButton(jodit, control, target); button.state.tabIndex = jodit.o.allowTabNavigation ? 0 : -1; return button; } export function makeSelect(view, control, target = null) { const ToolbarSelect = getComponentClass('ToolbarSelect'); return new ToolbarSelect(view, control, target); }