removed syntax highlighting in editor. will revist later
This commit is contained in:
parent
050dfb0b66
commit
eae80b0014
4 changed files with 10 additions and 13 deletions
|
@ -1,21 +1,18 @@
|
||||||
import Book from '../../data/Book';
|
import Book from '../../data/Book';
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
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 moment = require('moment');
|
||||||
const book = new Book();
|
const book = new Book();
|
||||||
const uuidv4 = require('uuid/v4');
|
const uuidv4 = require('uuid/v4');
|
||||||
const settings = require('../../../site/settings.json');
|
const settings = require('../../../site/settings.json');
|
||||||
hljs.registerLanguage('markdown', hljs_md);
|
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// POSTS
|
// POSTS
|
||||||
//--------------------------
|
//--------------------------
|
||||||
router.get('/list/:filter?/:page?', function(req, res) {
|
router.get('/list/:filter?/:page?', function (req, res) {
|
||||||
var pageNum = req.params.page;
|
var pageNum = req.params.page;
|
||||||
var filter = req.params.filter;
|
var filter = req.params.filter;
|
||||||
if (pageNum == '' || pageNum == null) pageNum = 1;
|
if (pageNum == '' || pageNum == null) pageNum = 1;
|
||||||
if (filter == '' || filter == null) filter = "all";
|
if (filter == '' || filter == null) filter = 'all';
|
||||||
if (req.session.user) {
|
if (req.session.user) {
|
||||||
book.getPage()
|
book.getPage()
|
||||||
.then(pages => {
|
.then(pages => {
|
||||||
|
@ -92,7 +89,7 @@ router.get('/list/:filter?/:page?', function(req, res) {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// BLOG POST ADD DISPLAY
|
// BLOG POST ADD DISPLAY
|
||||||
//--------------------------
|
//--------------------------
|
||||||
router.get('/add/new', function(req, res) {
|
router.get('/add/new', function (req, res) {
|
||||||
if (req.session.user) {
|
if (req.session.user) {
|
||||||
res.render('page-edit', {
|
res.render('page-edit', {
|
||||||
id: settings.library_stats.current_index,
|
id: settings.library_stats.current_index,
|
||||||
|
@ -113,12 +110,11 @@ router.get('/add/new', function(req, res) {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// BLOG POST EDIT DISPLAY
|
// BLOG POST EDIT DISPLAY
|
||||||
//--------------------------
|
//--------------------------
|
||||||
router.get('/edit/:id', function(req, res) {
|
router.get('/edit/:id', function (req, res) {
|
||||||
var id = req.params.id;
|
var id = req.params.id;
|
||||||
if (req.session.user) {
|
if (req.session.user) {
|
||||||
book.getPage(id)
|
book.getPage(id)
|
||||||
.then(page => {
|
.then(page => {
|
||||||
let pretty = hljs.highlight('markdown', page.content).value;
|
|
||||||
res.render('page-edit', {
|
res.render('page-edit', {
|
||||||
id: page.metadata.id,
|
id: page.metadata.id,
|
||||||
uuid: page.metadata.uuid,
|
uuid: page.metadata.uuid,
|
||||||
|
@ -127,7 +123,7 @@ router.get('/edit/:id', function(req, res) {
|
||||||
page: page.metadata,
|
page: page.metadata,
|
||||||
date: moment(page.metadata.created).format('YYYY MMM DD'),
|
date: moment(page.metadata.created).format('YYYY MMM DD'),
|
||||||
rawDate: page.metadata.created,
|
rawDate: page.metadata.created,
|
||||||
colored: pretty,
|
content: page.content,
|
||||||
feature: page.metadata.feature,
|
feature: page.metadata.feature,
|
||||||
status: [
|
status: [
|
||||||
String(page.metadata.menu),
|
String(page.metadata.menu),
|
||||||
|
|
|
@ -48,7 +48,7 @@ block main-content
|
||||||
#edit-post
|
#edit-post
|
||||||
#edit-post-wrapper
|
#edit-post-wrapper
|
||||||
pre
|
pre
|
||||||
code#edit-post-text(contenteditable="true") !{colored}
|
code#edit-post-text(contenteditable="true") !{content}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ export default class PostActions {
|
||||||
let txt = document.createElement('textarea');
|
let txt = document.createElement('textarea');
|
||||||
txt.innerHTML = document.getElementById('edit-post-text').innerHTML;
|
txt.innerHTML = document.getElementById('edit-post-text').innerHTML;
|
||||||
let html = txt.value;
|
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
|
html = html.replace(/<\/?br[^>]*>/g, '\n'); //convert back to encoded line break for storage
|
||||||
pageInfo.append(
|
pageInfo.append(
|
||||||
'id',
|
'id',
|
||||||
|
|
|
@ -14,7 +14,7 @@ class TextEditor extends EventEmitter {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
constructor(textEditor, scrollLimit) {
|
constructor(textEditor, scrollLimit) {
|
||||||
super();
|
super();
|
||||||
hljs.initHighlightingOnLoad();
|
//hljs.initHighlightingOnLoad();
|
||||||
this.textEditor = textEditor;
|
this.textEditor = textEditor;
|
||||||
this.fixLimit = scrollLimit;
|
this.fixLimit = scrollLimit;
|
||||||
this.caretPos = null;
|
this.caretPos = null;
|
||||||
|
@ -53,7 +53,8 @@ class TextEditor extends EventEmitter {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
refresh() {
|
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>');
|
spiffed = spiffed.replace(new RegExp('\r?\n', 'g'), '<br>');
|
||||||
var temp = document.createElement('div');
|
var temp = document.createElement('div');
|
||||||
temp.innerText = spiffed;
|
temp.innerText = spiffed;
|
||||||
|
|
Loading…
Reference in a new issue