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,13 @@
/*!
* 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/print
*/
import type { IJodit } from "../../../types/index";
/**
* @private
*/
export declare function generateCriticalCSS(jodit: IJodit): string;

View File

@@ -0,0 +1,102 @@
/*!
* 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 { toArray } from "../../../core/helpers/array/to-array.js";
/**
* @private
*/
export function generateCriticalCSS(jodit) {
const getMatchedCSSRules = (el, css = el.ownerDocument.styleSheets) => {
const rules = toArray(css)
.map(s => {
try {
return toArray(s.cssRules);
}
catch (_a) { }
return [];
})
.flat();
return rules.filter((r) => {
try {
return Boolean(r && el.matches(r.selectorText));
}
catch (_a) { }
return false;
});
};
class CSSCriticalPath {
constructor(w, d, opts) {
this.css = {};
const opt = opts || {};
const pushCSS = (r) => {
const selectorText = r.selectorText
.split(',')
.map(a => a.trim())
.sort()
.join(',');
if (Boolean(this.css[selectorText]) === false) {
this.css[selectorText] = {};
}
const styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for (let i = 0; i < styles.length; i++) {
if (!styles[i]) {
continue;
}
const pair = styles[i].split(':');
pair[0] = pair[0].trim();
pair[1] = pair[1].trim();
this.css[selectorText][pair[0]] = pair[1].replace(/var\(([^)]+)\)/g, (varValue, key) => {
const [name, def] = key.split(',');
return (jodit.ew
.getComputedStyle(jodit.editor)
.getPropertyValue(name.trim()) ||
def ||
varValue).trim();
});
}
};
const parseTree = () => {
// Get a list of all the elements in the view.
const height = w.innerHeight;
const walker = d.createTreeWalker(jodit.editor, NodeFilter.SHOW_ELEMENT, () => NodeFilter.FILTER_ACCEPT);
while (walker.nextNode()) {
const node = walker.currentNode;
const rect = node.getBoundingClientRect();
if (rect.top < height || opt.scanFullPage) {
const rules = getMatchedCSSRules(node);
if (rules) {
for (let r = 0; r < rules.length; r++) {
pushCSS(rules[r]);
}
}
}
}
};
parseTree();
}
generateCSS() {
let finalCSS = '';
for (const k in this.css) {
if (/:not\(/.test(k)) {
continue;
}
finalCSS += k + ' { ';
for (const j in this.css[k]) {
finalCSS += j + ': ' + this.css[k][j] + '; ';
}
finalCSS += '}\n';
}
return finalCSS;
}
}
try {
const cp = new CSSCriticalPath(jodit.ew, jodit.ed, {
scanFullPage: true
});
return cp.generateCSS();
}
catch (_a) { }
return '';
}

12
node_modules/jodit/esm/plugins/print/print.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
/*!
* 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
*/
/**
* [[include:plugins/print/README.md]]
* @packageDocumentation
* @module plugins/print
*/
import type { IJodit } from "../../types/index";
export declare function print(editor: IJodit): void;

69
node_modules/jodit/esm/plugins/print/print.js generated vendored Normal file
View File

@@ -0,0 +1,69 @@
/*!
* 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 * as consts from "../../core/constants.js";
import { Dom } from "../../core/dom/index.js";
import { getContainer, pluginSystem } from "../../core/global.js";
import { defaultLanguage } from "../../core/helpers/utils/default-language.js";
import { previewBox } from "../../core/helpers/utils/print.js";
import { Icon } from "../../core/ui/icon.js";
import { Config } from "../../config.js";
import { generateCriticalCSS } from "./lib/generate-critical-css.js";
import printIcon from "./print.svg.js";
Icon.set('print', printIcon);
Config.prototype.controls.print = {
exec: (editor) => {
const iframe = editor.create.element('iframe');
Object.assign(iframe.style, {
position: 'fixed',
right: 0,
bottom: 0,
width: 0,
height: 0,
border: 0
});
getContainer(editor, Config).appendChild(iframe);
const afterFinishPrint = () => {
editor.e.off(editor.ow, 'mousemove', afterFinishPrint);
Dom.safeRemove(iframe);
};
const myWindow = iframe.contentWindow;
if (myWindow) {
editor.e
.on(myWindow, 'onbeforeunload onafterprint', afterFinishPrint)
.on(editor.ow, 'mousemove', afterFinishPrint);
if (editor.o.iframe) {
editor.e.fire('generateDocumentStructure.iframe', myWindow.document, editor);
myWindow.document.body.innerHTML = editor.value;
}
else {
myWindow.document.write('<!doctype html><html lang="' +
defaultLanguage(editor.o.language) +
'"><head><title></title></head><style>' +
generateCriticalCSS(editor) +
'</style><body></body></html>');
myWindow.document.close();
previewBox(editor, undefined, 'px', myWindow.document.body);
}
const style = myWindow.document.createElement('style');
style.innerHTML = `@media print {
body {
-webkit-print-color-adjust: exact;
}
}`;
myWindow.document.head.appendChild(style);
myWindow.focus();
myWindow.print();
}
},
mode: consts.MODE_SOURCE + consts.MODE_WYSIWYG,
tooltip: 'Print'
};
export function print(editor) {
editor.registerButton({
name: 'print'
});
}
pluginSystem.add('print', print);

1
node_modules/jodit/esm/plugins/print/print.svg.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export default "<svg xmlns='http://www.w3.org/2000/svg' viewBox=\"0 0 1792 1792\"> <path d=\"M448 1536h896v-256h-896v256zm0-640h896v-384h-160q-40 0-68-28t-28-68v-160h-640v640zm1152 64q0-26-19-45t-45-19-45 19-19 45 19 45 45 19 45-19 19-45zm128 0v416q0 13-9.5 22.5t-22.5 9.5h-224v160q0 40-28 68t-68 28h-960q-40 0-68-28t-28-68v-160h-224q-13 0-22.5-9.5t-9.5-22.5v-416q0-79 56.5-135.5t135.5-56.5h64v-544q0-40 28-68t68-28h672q40 0 88 20t76 48l152 152q28 28 48 76t20 88v256h64q79 0 135.5 56.5t56.5 135.5z\"/> </svg> ";