inital commit

This commit is contained in:
2026-01-01 15:25:19 +05:30
commit f0ae49465a
36361 changed files with 4894111 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module plugins/clean-html
*/
import type { IJodit, Nullable } from "../../../../types/index";
/**
* For collapsed selection move cursor outside or split inline block
* @private
*/
export declare function removeFormatForCollapsedSelection(jodit: IJodit, fake?: Node): Nullable<Text> | void;
/**
* Element has inline display mode
* @private
*/
export declare function isInlineBlock(node: Nullable<Node>): node is Node;

View File

@@ -0,0 +1,45 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
import { INSEPARABLE_TAGS } from "../../../../core/constants.js";
import { Dom } from "../../../../core/dom/dom.js";
/**
* For collapsed selection move cursor outside or split inline block
* @private
*/
export function removeFormatForCollapsedSelection(jodit, fake) {
const { s } = jodit;
let fakeNode = fake;
if (!fakeNode) {
fakeNode = jodit.createInside.fake();
const { range } = s;
Dom.safeInsertNode(range, fakeNode);
range.collapse();
}
const mainInline = Dom.furthest(fakeNode, isInlineBlock, jodit.editor);
if (mainInline) {
if (s.cursorOnTheLeft(mainInline)) {
Dom.before(mainInline, fakeNode);
}
else if (s.cursorOnTheRight(mainInline)) {
Dom.after(mainInline, fakeNode);
}
else {
const leftHand = s.splitSelection(mainInline);
leftHand && Dom.after(leftHand, fakeNode);
}
}
if (!fake) {
s.setCursorBefore(fakeNode);
Dom.safeRemove(fakeNode);
}
}
/**
* Element has inline display mode
* @private
*/
export function isInlineBlock(node) {
return Dom.isInlineBlock(node) && !Dom.isTag(node, INSEPARABLE_TAGS);
}

View File

@@ -0,0 +1,14 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module plugins/clean-html
*/
import type { IJodit } from "../../../../types/index";
/**
* Remove formatting for all selected elements
* @private
*/
export declare function removeFormatForSelection(jodit: IJodit): void;

View File

@@ -0,0 +1,53 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
import { Dom } from "../../../../core/dom/dom.js";
import { attr } from "../../../../core/helpers/utils/index.js";
import { isInlineBlock, removeFormatForCollapsedSelection } from "./remove-format-for-collapsed-selection.js";
/**
* Remove formatting for all selected elements
* @private
*/
export function removeFormatForSelection(jodit) {
const { s, editor, createInside } = jodit, { range } = s, left = range.cloneRange(), right = range.cloneRange(), fakeLeft = createInside.fake(), fakeRight = createInside.fake();
left.collapse(true);
right.collapse(false);
Dom.safeInsertNode(left, fakeLeft);
Dom.safeInsertNode(right, fakeRight);
range.setStartBefore(fakeLeft);
range.collapse(true);
s.selectRange(range);
removeFormatForCollapsedSelection(jodit, fakeLeft);
range.setEndAfter(fakeRight);
range.collapse(false);
s.selectRange(range);
removeFormatForCollapsedSelection(jodit, fakeRight);
const shouldUnwrap = [];
Dom.between(fakeLeft, fakeRight, node => {
if (isInlineBlock(node) && !Dom.isTag(node, 'a')) {
shouldUnwrap.push(node);
}
if (Dom.isElement(node) && attr(node, 'style')) {
attr(node, 'style', null);
}
});
shouldUnwrap.forEach(node => Dom.unwrap(node));
const clearParent = (node, left) => {
if (!Dom.findNotEmptySibling(node, left)) {
const pn = node.parentNode;
if (pn && pn !== editor && attr(pn, 'style')) {
attr(pn, 'style', null);
clearParent(pn, left);
return true;
}
}
};
clearParent(fakeLeft, true) && clearParent(fakeRight, false);
range.setStartAfter(fakeLeft);
range.setEndBefore(fakeRight);
s.selectRange(range);
Dom.safeRemove(fakeLeft);
Dom.safeRemove(fakeRight);
}