removed syntax highlighting in editor. will revist later

This commit is contained in:
Ro 2020-05-20 21:44:19 -07:00
parent 050dfb0b66
commit eae80b0014
4 changed files with 10 additions and 13 deletions

View file

@ -1,21 +1,18 @@
import Book from '../../data/Book';
const express = require('express');
const router = express.Router();
const hljs = require('highlight.js/lib/highlight');
const hljs_md = require('highlight.js/lib/languages/markdown');
const moment = require('moment');
const book = new Book();
const uuidv4 = require('uuid/v4');
const settings = require('../../../site/settings.json');
hljs.registerLanguage('markdown', hljs_md);
//--------------------------
// POSTS
//--------------------------
router.get('/list/:filter?/:page?', function(req, res) {
router.get('/list/:filter?/:page?', function (req, res) {
var pageNum = req.params.page;
var filter = req.params.filter;
if (pageNum == '' || pageNum == null) pageNum = 1;
if (filter == '' || filter == null) filter = "all";
if (filter == '' || filter == null) filter = 'all';
if (req.session.user) {
book.getPage()
.then(pages => {
@ -92,7 +89,7 @@ router.get('/list/:filter?/:page?', function(req, res) {
//--------------------------
// BLOG POST ADD DISPLAY
//--------------------------
router.get('/add/new', function(req, res) {
router.get('/add/new', function (req, res) {
if (req.session.user) {
res.render('page-edit', {
id: settings.library_stats.current_index,
@ -113,12 +110,11 @@ router.get('/add/new', function(req, res) {
//--------------------------
// BLOG POST EDIT DISPLAY
//--------------------------
router.get('/edit/:id', function(req, res) {
router.get('/edit/:id', function (req, res) {
var id = req.params.id;
if (req.session.user) {
book.getPage(id)
.then(page => {
let pretty = hljs.highlight('markdown', page.content).value;
res.render('page-edit', {
id: page.metadata.id,
uuid: page.metadata.uuid,
@ -127,7 +123,7 @@ router.get('/edit/:id', function(req, res) {
page: page.metadata,
date: moment(page.metadata.created).format('YYYY MMM DD'),
rawDate: page.metadata.created,
colored: pretty,
content: page.content,
feature: page.metadata.feature,
status: [
String(page.metadata.menu),

View file

@ -48,7 +48,7 @@ block main-content
#edit-post
#edit-post-wrapper
pre
code#edit-post-text(contenteditable="true") !{colored}
code#edit-post-text(contenteditable="true") !{content}

View file

@ -16,7 +16,7 @@ export default class PostActions {
let txt = document.createElement('textarea');
txt.innerHTML = document.getElementById('edit-post-text').innerHTML;
let html = txt.value;
html = html.replace(/<\/?span[^>]*>/g, ''); //removes highightjs styling
//html = html.replace(/<\/?span[^>]*>/g, ''); //removes highightjs styling
html = html.replace(/<\/?br[^>]*>/g, '\n'); //convert back to encoded line break for storage
pageInfo.append(
'id',

View file

@ -14,7 +14,7 @@ class TextEditor extends EventEmitter {
//--------------------------
constructor(textEditor, scrollLimit) {
super();
hljs.initHighlightingOnLoad();
//hljs.initHighlightingOnLoad();
this.textEditor = textEditor;
this.fixLimit = scrollLimit;
this.caretPos = null;
@ -53,7 +53,8 @@ class TextEditor extends EventEmitter {
});
}
refresh() {
var spiffed = hljs.highlight('markdown', this.textEditor.innerText).value;
//var spiffed = hljs.highlight('markdown', this.textEditor.innerText).value;
var spiffed = this.textEditor.innerText;
spiffed = spiffed.replace(new RegExp('\r?\n', 'g'), '<br>');
var temp = document.createElement('div');
temp.innerText = spiffed;