Собрал статические файлы

This commit is contained in:
NikDizell 2026-03-04 02:27:43 +03:00
parent d07e70def4
commit 283208857e
87 changed files with 2739 additions and 199 deletions

View File

@ -0,0 +1,238 @@
import ClassicEditor from './src/ckeditor';
import './src/override-django.css';
window.ClassicEditor = ClassicEditor;
window.ckeditorRegisterCallback = registerCallback;
window.ckeditorUnregisterCallback = unregisterCallback;
window.editors = {};
let editors = {};
let callbacks = {};
function getCookie(name) {
let cookieValue = null;
if (document.cookie && document.cookie !== '') {
let cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
let cookie = cookies[i].trim();
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
function getCSRFToken(cookieName) {
let token = getCookie(cookieName);
if (!token) {
token = document.querySelector('input[name=csrfmiddlewaretoken]')?.value;
}
return token;
}
/**
* Checks whether the element or its children match the query and returns
* an array with the matches.
*
* @param {!HTMLElement} element
* @param {!string} query
*
* @returns {array.<HTMLElement>}
*/
function resolveElementArray(element, query) {
return element.matches(query) ? [element] : [...element.querySelectorAll(query)];
}
/**
* This function initializes the CKEditor inputs within an optional element and
* assigns properties necessary for the correct operation
*
* @param {HTMLElement} [element=document.body] - The element to search for elements
*
* @returns {void}
*/
function createEditors(element = document.body) {
const allEditors = resolveElementArray(element, '.django_ckeditor_5');
allEditors.forEach(editorEl => {
if (
editorEl.id.indexOf('__prefix__') !== -1 ||
editorEl.getAttribute('data-processed') === '1'
) {
return;
}
const script_id = `${editorEl.id}_script`;
// remove next sibling if it is an empty text node
if (editorEl.nextSibling.nodeType == Node.TEXT_NODE && editorEl.nextSibling.textContent.trim() === '') {
editorEl.nextSibling.remove();
}
const upload_url = element.querySelector(
`#${script_id}-ck-editor-5-upload-url`
).getAttribute('data-upload-url');
const upload_file_types = JSON.parse(element.querySelector(
`#${script_id}-ck-editor-5-upload-url`
).getAttribute('data-upload-file-types'));
const csrf_cookie_name = element.querySelector(
`#${script_id}-ck-editor-5-upload-url`
).getAttribute('data-csrf_cookie_name');
const labelElement = element.querySelector(`[for$="${editorEl.id}"]`);
if (labelElement) {
labelElement.style.float = 'none';
}
const config = JSON.parse(
element.querySelector(`#${script_id}-span`).textContent,
(key, value) => {
var match = value.toString().match(new RegExp('^/(.*?)/([gimy]*)$'));
if (match) {
var regex = new RegExp(match[1], match[2]);
return regex;
}
if (typeof value === 'string' && value.startsWith('callback:')) {
var callbackName = value.substring(9);
var callback = window[callbackName];
if (typeof callback === 'function') {
return callback;
}
}
return value;
}
);
config.simpleUpload = {
'uploadUrl': upload_url,
'headers': {
'X-CSRFToken': getCSRFToken(csrf_cookie_name),
},
};
config.fileUploader = {
'fileTypes': upload_file_types
};
config.licenseKey = 'GPL';
// Configure autosave if enabled
if (config.autosave) {
config.autosave.save = function(editor) {
return new Promise((resolve, reject) => {
const textarea = document.querySelector(`#${editorEl.id}`);
const data = editor.getData();
textarea.value = data;
// If save URL is provided, send to server
if (config.autosave.saveUrl) {
fetch(config.autosave.saveUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': getCSRFToken(csrf_cookie_name),
},
body: JSON.stringify({
id: editorEl.id,
content: data
})
})
.then(response => response.json())
.then(result => resolve(result))
.catch(error => reject(error));
} else {
// Just update textarea
resolve();
}
});
};
}
ClassicEditor.create(
editorEl,
config
).then(editor => {
const textarea = document.querySelector(`#${editorEl.id}`);
editor.model.document.on('change:data', () => {
textarea.value = editor.getData();
});
if (editor.plugins.has('WordCount')) {
const wordCountPlugin = editor.plugins.get('WordCount');
const wordCountWrapper = element.querySelector(`#${script_id}-word-count`);
wordCountWrapper.innerHTML = '';
wordCountWrapper.appendChild(wordCountPlugin.wordCountContainer);
}
if (editorEl.hasAttribute('disabled')) {
editor.enableReadOnlyMode('django-ckeditor-5');
}
editors[editorEl.id] = editor;
if (callbacks[editorEl.id]) {
callbacks[editorEl.id](editor);
}
}).catch(error => {
console.error((error));
});
editorEl.setAttribute('data-processed', '1');
});
window.editors = editors;
}
/**
* This function filters the list of mutations only by added elements, thus
* eliminates the occurrence of text nodes and tags where it does not make sense
* to try to use with `QuerySelectorAll()` and `matches()` functions.
*
* @param {MutationRecord} recordList - It is the object inside the array
* passed to the callback of a MutationObserver.
*
* @returns {Array} Array containing filtered nodes.
*/
function getAddedNodes(recordList) {
return recordList
.flatMap(({ addedNodes }) => Array.from(addedNodes))
.filter(node => node.nodeType === 1);
}
/**
* Register a callback for when an editor with `id` is created.
*
* @param {!string} id - the id of the ckeditor element.
* @callback callback - the callback function to be invoked.
*/
function registerCallback(id, callback) {
callbacks[id] = callback;
}
/**
* Unregister a previously registered callback.
*
* @param {!string} id - the id of the ckeditor element.
*/
function unregisterCallback(id) {
callbacks[id] = null;
}
document.addEventListener("DOMContentLoaded", () => {
createEditors();
if (typeof django === "object" && django.jQuery) {
django.jQuery(document).on("formset:added", () => {createEditors();});
}
const observer = new MutationObserver((mutations) => {
let addedNodes = getAddedNodes(mutations);
addedNodes.forEach(node => {
// Initializes editors
createEditors(node);
});
});
// Configure MutationObserver options
const observerOptions = {
childList: true,
subtree: true,
};
// Selects the parent element where the events occur
const mainContent = document.body;
// Starts to observe the selected father element with the configured options
observer.observe(mainContent, observerOptions);
});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,20 @@
/* istanbul ignore else -- @preserve */
/* istanbul ignore else: This is always true because otherwise it would not register a reducer callback. -- @preserve */
/* istanbul ignore file -- @preserve */
/* istanbul ignore if -- @preserve */
/* istanbul ignore if: paranoid check -- @preserve */
/* istanbul ignore next -- @preserve */
/* istanbul ignore next: paranoid check -- @preserve */
/* istanbul ignore next: static function definition -- @preserve */
/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/

File diff suppressed because one or more lines are too long

114
static/django_ckeditor_5/dist/styles.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

116
static/django_ckeditor_5/src/ckeditor.js vendored Normal file
View File

@ -0,0 +1,116 @@
import { ClassicEditor as ClassicEditorBase } from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
import { Essentials } from '@ckeditor/ckeditor5-essentials/src/essentials';
import { CKFinderUploadAdapter } from '@ckeditor/ckeditor5-adapter-ckfinder/src/uploadadapter';
import { Autoformat } from '@ckeditor/ckeditor5-autoformat/src/autoformat';
import { Bold } from '@ckeditor/ckeditor5-basic-styles/src/bold';
import { Italic } from '@ckeditor/ckeditor5-basic-styles/src/italic';
import { Underline } from '@ckeditor/ckeditor5-basic-styles/src/underline';
import { Strikethrough } from '@ckeditor/ckeditor5-basic-styles/src/strikethrough';
import { Code } from '@ckeditor/ckeditor5-basic-styles/src/code';
import { Subscript } from '@ckeditor/ckeditor5-basic-styles/src/subscript';
import { Superscript } from '@ckeditor/ckeditor5-basic-styles/src/superscript';
import { BlockQuote } from '@ckeditor/ckeditor5-block-quote/src/blockquote';
import { Heading } from '@ckeditor/ckeditor5-heading/src/heading';
import { Image } from '@ckeditor/ckeditor5-image/src/image';
import { ImageCaption } from '@ckeditor/ckeditor5-image/src/imagecaption';
import { ImageStyle } from '@ckeditor/ckeditor5-image/src/imagestyle';
import { ImageToolbar } from '@ckeditor/ckeditor5-image/src/imagetoolbar';
import { Link } from '@ckeditor/ckeditor5-link/src/link';
import { List } from '@ckeditor/ckeditor5-list/src/list';
import { Paragraph } from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import { ImageResize } from '@ckeditor/ckeditor5-image/src/imageresize';
import { SimpleUploadAdapter } from '@ckeditor/ckeditor5-upload/src/adapters/simpleuploadadapter';
import { Alignment } from '@ckeditor/ckeditor5-alignment/src/alignment';
import { Autosave } from '@ckeditor/ckeditor5-autosave/src/autosave';
import { PasteFromOffice } from '@ckeditor/ckeditor5-paste-from-office/src/pastefromoffice';
import { Font } from '@ckeditor/ckeditor5-font/src/font';
import { MediaEmbed } from '@ckeditor/ckeditor5-media-embed/src/mediaembed';
import { RemoveFormat } from '@ckeditor/ckeditor5-remove-format/src/removeformat';
import { Table } from '@ckeditor/ckeditor5-table/src/table';
import { TableToolbar } from '@ckeditor/ckeditor5-table/src/tabletoolbar';
import { TableProperties } from '@ckeditor/ckeditor5-table/src/tableproperties';
import { TableCellProperties } from '@ckeditor/ckeditor5-table/src/tablecellproperties';
import { Indent } from '@ckeditor/ckeditor5-indent/src/indent';
import { IndentBlock } from '@ckeditor/ckeditor5-indent/src/indentblock';
import { Highlight } from '@ckeditor/ckeditor5-highlight/src/highlight';
import { TodoList } from '@ckeditor/ckeditor5-list/src/todolist';
import { CodeBlock } from '@ckeditor/ckeditor5-code-block/src/codeblock';
import { ListProperties } from '@ckeditor/ckeditor5-list/src/listproperties';
import { SourceEditing } from '@ckeditor/ckeditor5-source-editing/src/sourceediting';
import { GeneralHtmlSupport } from '@ckeditor/ckeditor5-html-support/src/generalhtmlsupport';
import { ImageInsert } from '@ckeditor/ckeditor5-image/src/imageinsert';
import { TableCaption } from '@ckeditor/ckeditor5-table';
import { WordCount } from '@ckeditor/ckeditor5-word-count/src/wordcount';
import { Mention } from '@ckeditor/ckeditor5-mention/src/mention';
import { Markdown } from '@ckeditor/ckeditor5-markdown-gfm/src/markdown';
import { PageBreak } from '@ckeditor/ckeditor5-page-break/src/pagebreak';
import { Style } from '@ckeditor/ckeditor5-style';
import { HorizontalLine } from '@ckeditor/ckeditor5-horizontal-line';
import {LinkImage} from "@ckeditor/ckeditor5-link";
import {HtmlEmbed} from "@ckeditor/ckeditor5-html-embed";
import { FullPage } from '@ckeditor/ckeditor5-html-support';
import { SpecialCharacters } from '@ckeditor/ckeditor5-special-characters';
import { SpecialCharactersEssentials } from '@ckeditor/ckeditor5-special-characters';
import { ShowBlocks } from '@ckeditor/ckeditor5-show-blocks';
import { SelectAll } from '@ckeditor/ckeditor5-select-all';
import { FindAndReplace } from '@ckeditor/ckeditor5-find-and-replace';
export default class ClassicEditor extends ClassicEditorBase {
}
ClassicEditor.builtinPlugins = [
Essentials,
CKFinderUploadAdapter,
CodeBlock,
Autoformat,
Bold,
Italic,
Underline,
Strikethrough,
Code,
Subscript,
Superscript,
BlockQuote,
Heading,
Image,
ImageCaption,
ImageStyle,
ImageToolbar,
ImageResize,
Link,
List,
Paragraph,
Alignment,
Autosave,
Font,
PasteFromOffice,
SimpleUploadAdapter,
MediaEmbed,
RemoveFormat,
Table, TableToolbar,
TableCaption,
TableProperties,
TableCellProperties,
Indent,
IndentBlock,
Highlight,
TodoList,
ListProperties,
SourceEditing,
GeneralHtmlSupport,
ImageInsert,
WordCount,
Mention,
Markdown,
PageBreak,
Style,
HorizontalLine,
LinkImage,
HtmlEmbed,
FullPage,
SpecialCharacters,
SpecialCharactersEssentials,
ShowBlocks,
SelectAll,
FindAndReplace
];

View File

@ -0,0 +1,47 @@
/** Todo list **/
.ck .todo-list input {
padding: 0;
}
.ck .todo-list__checkmark:after {
height: 6px !important;
}
.ck .todo-list__checkmark {
padding: 0;
}
.ck.ck-content.ck-editor__editable {
min-height: 300px;
}
.ck h2 {
color: inherit;
background: inherit;
}
form .aligned .ck ul li {
list-style: inherit;
}
form .aligned .ck ul {
margin-left: 1.5em;
padding-left: inherit;
}
.ck-word-count{
display: flex;
margin-top: 10px;
}
.ck-word-count__words{
margin-right: 10px;
}
.ck.ck-editor {
position: relative;
width: 100%;
}
.ck-editor-container{
width: 100%;
}

1
static/programmer/css/1c-dark.min.css vendored Normal file
View File

@ -0,0 +1 @@
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#abb2bf;background:#282c34}.hljs-comment,.hljs-quote{color:#5c6370;font-style:italic}.hljs-doctag,.hljs-formula,.hljs-keyword{color:#c678dd}.hljs-deletion,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-subst{color:#e06c75}.hljs-literal{color:#56b6c2}.hljs-addition,.hljs-attribute,.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#98c379}.hljs-attr,.hljs-number,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-pseudo,.hljs-template-variable,.hljs-type,.hljs-variable{color:#d19a66}.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-symbol,.hljs-title{color:#61aeee}.hljs-built_in,.hljs-class .hljs-title,.hljs-title.class_{color:#e6c07b}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}

View File

@ -0,0 +1,9 @@
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
Theme: 1c-light
Description: Style IDE 1C:Enterprise 8
Author: (c) Barilko Vitaliy <barilkovetal@gmail.com>
Maintainer: @Diversus23
Website: https://softonit.ru/
License: see project LICENSE
Touched: 2023
*/.hljs{color:#00f;background:#fff}.hljs-comment{color:green}.hljs-tag{color:#444a}.hljs-tag .hljs-attr,.hljs-tag .hljs-name{color:#444}.hljs-attribute,.hljs-doctag,.hljs-function,.hljs-keyword,.hljs-name,.hljs-punctuation,.hljs-selector-tag{color:red}.hljs-params,.hljs-type{color:#00f}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-symbol,.hljs-template-tag{color:#000}.hljs-section,.hljs-title{color:#00f}.hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-template-variable,.hljs-variable{color:#ab5656}.hljs-literal{color:red}.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code{color:#00f}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#963200}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}

View File

@ -0,0 +1,9 @@
/*!
Theme: Default
Description: Original highlight.js style
Author: (c) Ivan Sagalaev <maniac@softwaremaniacs.org>
Maintainer: @highlightjs/core-team
Website: https://highlightjs.org/
License: see project LICENSE
Touched: 2021
*/pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#f3f3f3;color:#444}.hljs-comment{color:#697070}.hljs-punctuation,.hljs-tag{color:#444a}.hljs-tag .hljs-attr,.hljs-tag .hljs-name{color:#444}.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag{font-weight:700}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type{color:#800}.hljs-section,.hljs-title{color:#800;font-weight:700}.hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#ab5656}.hljs-literal{color:#695}.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta .hljs-string{color:#38a}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

1244
static/programmer/js/highlight.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
document.addEventListener('DOMContentLoaded', function() {
const themeToggle = document.getElementById('theme-toggle');
const mobileThemeToggle = document.getElementById('mobile-theme-toggle');
const themeCSS = document.getElementById('theme-css');
const themeCSS1C = document.getElementById('theme-css-1c');
// Проверяем сохраненную тему в localStorage
const savedTheme = localStorage.getItem('theme');
@ -41,14 +41,20 @@ document.addEventListener('DOMContentLoaded', function() {
}
function switchToLightTheme() {
themeCSS.href = themeCSS.href.replace('styles_dark.css', 'styles_w.css');
document.body.classList.remove('theme-dark');
if (themeCSS1C) {
themeCSS1C.href = themeCSS1C.href.replace('1c-dark.min.css', '1c-light.min.css');
}
if (themeToggle) themeToggle.checked = true;
if (mobileThemeToggle) mobileThemeToggle.checked = true;
localStorage.setItem('theme', 'light');
}
function switchToDarkTheme() {
themeCSS.href = themeCSS.href.replace('styles_w.css', 'styles_dark.css');
document.body.classList.add('theme-dark');
if (themeCSS1C) {
themeCSS1C.href = themeCSS1C.href.replace('1c-light.min.css', '1c-dark.min.css');
}
if (themeToggle) themeToggle.checked = false;
if (mobileThemeToggle) mobileThemeToggle.checked = false;
localStorage.setItem('theme', 'dark');
@ -63,6 +69,6 @@ document.addEventListener('DOMContentLoaded', function() {
themeCSS.onerror = function() {
console.error('Ошибка загрузки CSS файла темы');
// Восстанавливаем светлую тему по умолчанию при ошибке
themeCSS.href = themeCSS.href.replace('styles_dark.css', 'styles_w.css');
themeCSS1C.href = themeCSS1C.href.replace('1c-light.min.css', '1c-dark.min.css');
};
});