UNPKG

jodit

Version:

Jodit is an awesome and useful wysiwyg editor with filebrowser

37 lines (36 loc) 1.33 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 { Dom } from "../../../core/dom/dom.js"; /** * Checks whether the insertion of an element at the current location is allowed, * if it is not allowed, it deletes an empty block element or moves the cursor after it * @internal */ export function checkBlockNesting(jodit, node) { var _a, _b; if (Dom.isFragment(node)) { node = node.firstChild; } if (jodit.o.dtd.checkBlockNesting && Dom.isBlock(node)) { let parent = null; let current = (_b = (_a = jodit.s.current()) === null || _a === void 0 ? void 0 : _a.parentElement) !== null && _b !== void 0 ? _b : null; while (current && current !== jodit.editor) { if (Dom.isBlock(current)) { if (jodit.o.dtd.blockLimits[current.nodeName.toLowerCase()]) { break; } parent = current; } current = current.parentElement; } if (parent) { jodit.s.setCursorAfter(parent); if (Dom.isEmpty(parent)) { Dom.safeRemove(parent); } } } }