mirror of
https://github.com/typemill/typemill.git
synced 2025-08-04 05:07:44 +02:00
Version 1.2.8 Fix Editor
This commit is contained in:
2
cache/lastCache.txt
vendored
2
cache/lastCache.txt
vendored
@@ -1 +1 @@
|
||||
1543940450
|
||||
1544124516
|
@@ -668,8 +668,11 @@ class ContentApiController extends ContentController
|
||||
$blockArray = $parsedown->text($blockMarkdown);
|
||||
}
|
||||
|
||||
# needed for ToC links
|
||||
$relurl = '/tm/content/' . $this->settings['editor'] . '/' . $this->item->urlRel;
|
||||
|
||||
/* parse markdown-content-array to content-string */
|
||||
$blockHTML = $parsedown->markup($blockArray);
|
||||
$blockHTML = $parsedown->markup($blockArray, $relurl);
|
||||
|
||||
return $response->withJson(array('content' => $blockHTML, 'markdown' => $blockMarkdown, 'blockId' => $blockId, 'id' => $id, 'errors' => false));
|
||||
}
|
||||
|
@@ -127,14 +127,17 @@ class ContentBackendController extends ContentController
|
||||
# turn markdown into an array of markdown-blocks
|
||||
$content = $parsedown->markdownToArrayBlocks($content);
|
||||
}
|
||||
|
||||
|
||||
# needed for ToC links
|
||||
$relurl = '/tm/content/' . $this->settings['editor'] . '/' . $this->item->urlRel;
|
||||
|
||||
foreach($content as $key => $block)
|
||||
{
|
||||
/* parse markdown-file to content-array */
|
||||
$contentArray = $parsedown->text($block);
|
||||
|
||||
/* parse markdown-content-array to content-string */
|
||||
$content[$key] = $parsedown->markup($contentArray);
|
||||
$content[$key] = $parsedown->markup($contentArray, $relurl);
|
||||
}
|
||||
|
||||
# extract title and delete from content array, array will start at 1 after that.
|
||||
|
@@ -132,9 +132,9 @@ class PageController extends Controller
|
||||
|
||||
/* get the first image from content array */
|
||||
$firstImage = $this->getFirstImage($contentArray);
|
||||
|
||||
|
||||
/* parse markdown-content-array to content-string */
|
||||
$contentHTML = $parsedown->markup($contentArray);
|
||||
$contentHTML = $parsedown->markup($contentArray, $item->urlRel);
|
||||
$contentHTML = $this->c->dispatcher->dispatch('onHtmlLoaded', new OnHtmlLoaded($contentHTML))->getData();
|
||||
|
||||
/* extract the h1 headline*/
|
||||
|
@@ -25,7 +25,7 @@ class ParsedownExtension extends \ParsedownExtra
|
||||
return $Elements;
|
||||
}
|
||||
|
||||
function markup($Elements)
|
||||
function markup($Elements, $relurl)
|
||||
{
|
||||
# convert to markup
|
||||
$markup = $this->elements($Elements);
|
||||
@@ -39,7 +39,7 @@ class ParsedownExtension extends \ParsedownExtra
|
||||
# create table of contents
|
||||
if(isset($this->DefinitionData['TableOfContents']))
|
||||
{
|
||||
$TOC = $this->buildTOC($this->headlines);
|
||||
$TOC = $this->buildTOC($this->headlines, $relurl);
|
||||
|
||||
$markup = preg_replace('%(<p[^>]*>\[TOC\]</p>)%i', $TOC, $markup);
|
||||
}
|
||||
@@ -108,9 +108,8 @@ class ParsedownExtension extends \ParsedownExtra
|
||||
|
||||
# build the markup for table of contents
|
||||
|
||||
protected function buildTOC($headlines)
|
||||
protected function buildTOC($headlines, $relurl)
|
||||
{
|
||||
|
||||
$markup = '<ul class="TOC">';
|
||||
|
||||
foreach($headlines as $key => $headline)
|
||||
@@ -124,7 +123,7 @@ class ParsedownExtension extends \ParsedownExtra
|
||||
$markup .= '<ul>';
|
||||
}
|
||||
|
||||
$markup .= '<li class="' . $headline['name'] . '"><a href="#' . $headline['attribute'] . '">' . $headline['text'] . '</a>';
|
||||
$markup .= '<li class="' . $headline['name'] . '"><a href="' . $relurl . '#' . $headline['attribute'] . '">' . $headline['text'] . '</a>';
|
||||
|
||||
if($thisLevel == $nextLevel)
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@ const eventBus = new Vue();
|
||||
|
||||
const contentComponent = Vue.component('content-block', {
|
||||
props: ['body'],
|
||||
template: '<div ref="bloxcomponent" class="blox-editor"><div :class="{ editactive: edit }"><div @keyup.enter="submitBlock" @click="getData"><div class="component" ref="component"><transition name="fade-editor"><component :disabled="disabled" :compmarkdown="compmarkdown" @updatedMarkdown="compmarkdown = $event" :is="componentType"></component></transition><div class="blox-buttons" v-if="edit"><button class="edit" :disabled="disabled" @click.prevent="saveBlock">save</button><button class="cancel" :disabled="disabled" @click.prevent="switchToPreviewMode">cancel</button></div></div><div :class="preview" ref="preview"><slot></slot></div></div><div class="sideaction" v-if="body"><button class="delete" :disabled="disabled" title="delete content-block" @click.prevent="deleteBlock($event)"><i class="icon-cancel"></i></button></div></div></div>',
|
||||
template: '<div ref="bloxcomponent" class="blox-editor"><div :class="{ editactive: edit }"><div @keyup.enter="submitBlock" @click="getData"><div class="component" ref="component"><transition name="fade-editor"><component :disabled="disabled" :compmarkdown="compmarkdown" @updatedMarkdown="updateMarkdown" :is="componentType"></component></transition><div class="blox-buttons" v-if="edit"><button class="edit" :disabled="disabled" @click.prevent="saveBlock">save</button><button class="cancel" :disabled="disabled" @click.prevent="switchToPreviewMode">cancel</button></div></div><div :class="preview" ref="preview"><slot></slot></div></div><div class="sideaction" v-if="body"><button class="delete" :disabled="disabled" title="delete content-block" @click.prevent="deleteBlock($event)"><i class="icon-cancel"></i></button></div></div></div>',
|
||||
data: function () {
|
||||
return {
|
||||
preview: 'visible',
|
||||
@@ -17,8 +17,16 @@ const contentComponent = Vue.component('content-block', {
|
||||
eventBus.$on('closeComponents', this.closeComponents);
|
||||
},
|
||||
methods: {
|
||||
updateMarkdown: function($event)
|
||||
{
|
||||
this.compmarkdown = $event;
|
||||
this.$nextTick(function () {
|
||||
this.$refs.preview.style.minHeight = this.$refs.component.offsetHeight + 'px';
|
||||
});
|
||||
},
|
||||
switchToEditMode: function()
|
||||
{
|
||||
if(this.edit){ return; }
|
||||
eventBus.$emit('closeComponents');
|
||||
self = this;
|
||||
self.$root.$data.freeze = true; /* freeze the data */
|
||||
@@ -90,7 +98,9 @@ const contentComponent = Vue.component('content-block', {
|
||||
}
|
||||
},
|
||||
saveBlock: function()
|
||||
{
|
||||
{
|
||||
console.log(this.compmarkdown);
|
||||
|
||||
if(this.compmarkdown == undefined || this.compmarkdown.replace(/(\r\n|\n|\r|\s)/gm,"") == '')
|
||||
{
|
||||
this.switchToPreviewMode();
|
||||
|
Reference in New Issue
Block a user