Themeneditor vorerst fertig
This commit is contained in:
@@ -19,9 +19,9 @@ $defaultValues['article'] = "";
|
||||
|
||||
$errors = array();
|
||||
|
||||
if (isset($_GET['subjectId']) && isset($_GET['topicId'])) {
|
||||
if (isset($allSubjects[$_GET['subjectId']]->getTopics()[$_GET['topicId']])) {
|
||||
$editingTopic = $allSubjects[$_GET['subjectId']]->getTopics()[$_GET['topicId']];
|
||||
if (isset($_GET['subject']) && isset($_GET['topic'])) {
|
||||
if (isset($allSubjects[$_GET['subject']]->getTopics()[$_GET['topic']])) {
|
||||
$editingTopic = $allSubjects[$_GET['subject']]->getTopics()[$_GET['topic']];
|
||||
|
||||
$defaultValues['displayName'] = $editingTopic->getDisplayName();
|
||||
$defaultValues['id'] = $editingTopic->getId();
|
||||
@@ -29,7 +29,7 @@ if (isset($_GET['subjectId']) && isset($_GET['topicId'])) {
|
||||
$defaultValues['description'] = $editingTopic->getDescription();
|
||||
$defaultValues['icon'] = $editingTopic->getIcon();
|
||||
$defaultValues['relatedTopics'] = implode(", ", $editingTopic->getRelatedTopics());
|
||||
$defaultValues['article'] = str_replace("$$", "<br>$$<br>", $editingTopic->getFinishedArticle());
|
||||
$defaultValues['article'] = $editingTopic->getFinishedArticle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,11 +106,11 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.js"></script>
|
||||
<script src="assets/js/quill_mod.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.18/dist/katex.min.css" integrity="sha384-veTAhWILPOotXm+kbR5uY7dRamYLJf58I7P+hJhjeuc7hsMAkJHTsPahAl0hBST0" crossorigin="anonymous">
|
||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.18/dist/katex.min.js" integrity="sha384-v6mkHYHfY/4BWq54f7lQAdtIsoZZIByznQ3ZqN38OL4KCsrxo31SLlPiak7cj/Mg" crossorigin="anonymous"></script>
|
||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.18/dist/contrib/auto-render.min.js" integrity="sha384-hCXGrW6PitJEwbkoStFjeJxv+fSOOQKOPbJxSfM6G5sWZjAyWhXiTIIAmQqnlLlh" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/katex.min.css" integrity="sha384-7lU0muIg/i1plk7MgygDUp3/bNRA65orrBub4/OSWHECgwEsY83HaS1x3bljA/XV" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/katex.min.js" integrity="sha384-RdymN7NRJ+XoyeRY4185zXaxq9QWOOx3O7beyyrRK4KQZrPlCDQQpCu95FoCGPAE" crossorigin="anonymous"></script>
|
||||
<script src="assets/js/katex_autorender_mod.js"></script>
|
||||
</head>
|
||||
|
||||
<body class="min-h-screen bg-gray-50">
|
||||
@@ -188,7 +188,12 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
</div>
|
||||
|
||||
<div id="quillEditor" style="height: 400px;" class="bg-white border rounded-lg">
|
||||
<?php echo $defaultValues['article']; ?>
|
||||
<?php
|
||||
$article = $defaultValues['article'];
|
||||
|
||||
echo $article;
|
||||
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -214,16 +219,24 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
</form>
|
||||
|
||||
<script>
|
||||
const Inline = Quill.import('blots/inline');
|
||||
const Block = Quill.import('blots/block');
|
||||
const Embed = Quill.import('blots/embed');
|
||||
|
||||
class FormulaBlot extends Embed {
|
||||
static blotName = 'formula';
|
||||
static tagName = 'math';
|
||||
function renderFormulas() {
|
||||
renderMathInElement(document.body, {
|
||||
delimiters: [
|
||||
{left: "$$", right: "$$", display: true},
|
||||
{left: "\\(", right: "\\)", display: false},
|
||||
{left: "\\begin{equation}", right: "\\end{equation}", display: true},
|
||||
{left: "\\begin{array}", right: "\\end{array}", display: true},
|
||||
{left: "\\begin{align}", right: "\\end{align}", display: true},
|
||||
{left: "\\begin{alignat}", right: "\\end{alignat}", display: true},
|
||||
{left: "\\begin{gather}", right: "\\end{gather}", display: true},
|
||||
{left: "\\begin{CD}", right: "\\end{CD}", display: true},
|
||||
{left: "\\[", right: "\\]", display: true}
|
||||
],
|
||||
throwOnError : false
|
||||
});
|
||||
}
|
||||
|
||||
//Quill.register(FormulaBlot);
|
||||
renderFormulas();
|
||||
|
||||
const quill = new Quill('#quillEditor', {
|
||||
modules: {
|
||||
@@ -242,11 +255,10 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
const html = quill.getSemanticHTML().replace(/ /g, " ");
|
||||
document.getElementById('contentPreview').innerHTML = html;
|
||||
document.getElementById('article-upload-field').value = html;
|
||||
|
||||
renderFormulas();
|
||||
});
|
||||
quill.emitter.emit('text-change');
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user