Add realtime editing and usage
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Peter Stuifzand 2020-06-08 23:11:42 +02:00
parent e69ad351ad
commit 354c6ea294
4 changed files with 74 additions and 5 deletions

View File

@ -4365,6 +4365,26 @@
"uc.micro": "^1.0.5" "uc.micro": "^1.0.5"
} }
}, },
"markdown-it-mark": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/markdown-it-mark/-/markdown-it-mark-3.0.0.tgz",
"integrity": "sha512-HqMWeKfMMOu4zBO0emmxsoMWmbf2cPKZY1wP6FsTbKmicFfp5y4L3KXAsNeO1rM6NTJVOrNlLKMPjWzriBGspw=="
},
"markdown-it-regexp": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/markdown-it-regexp/-/markdown-it-regexp-0.4.0.tgz",
"integrity": "sha1-1k1xPuzsVc5M/esyF1DswJniwtw="
},
"markdown-it-wikilinks": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/markdown-it-wikilinks/-/markdown-it-wikilinks-1.0.1.tgz",
"integrity": "sha1-+14MCiF5l7CJuMLcIvXFcuZKrXQ=",
"requires": {
"extend": "^3.0.0",
"markdown-it-regexp": "^0.4.0",
"sanitize-filename": "^1.6.1"
}
},
"math-random": { "math-random": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.4.tgz", "resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.4.tgz",
@ -6666,6 +6686,14 @@
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
}, },
"sanitize-filename": {
"version": "1.6.3",
"resolved": "https://registry.npmjs.org/sanitize-filename/-/sanitize-filename-1.6.3.tgz",
"integrity": "sha512-y/52Mcy7aw3gRm7IrcGDFx/bCk4AhRh2eI9luHOQM86nZsqwiRkkq2GekHXBBD+SmPidc8i2PqtYZl+pWJ8Oeg==",
"requires": {
"truncate-utf8-bytes": "^1.0.0"
}
},
"sass-graph": { "sass-graph": {
"version": "2.2.5", "version": "2.2.5",
"resolved": "https://registry.npmjs.org/sass-graph/-/sass-graph-2.2.5.tgz", "resolved": "https://registry.npmjs.org/sass-graph/-/sass-graph-2.2.5.tgz",
@ -7868,6 +7896,14 @@
"glob": "^7.1.2" "glob": "^7.1.2"
} }
}, },
"truncate-utf8-bytes": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz",
"integrity": "sha1-QFkjkJWS1W94pYGENLC3hInKXys=",
"requires": {
"utf8-byte-length": "^1.0.1"
}
},
"tslib": { "tslib": {
"version": "1.13.0", "version": "1.13.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
@ -8079,6 +8115,11 @@
"integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==",
"dev": true "dev": true
}, },
"utf8-byte-length": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/utf8-byte-length/-/utf8-byte-length-1.0.4.tgz",
"integrity": "sha1-9F8VDExm7uloGGUFq5P8u4rWv2E="
},
"util": { "util": {
"version": "0.11.1", "version": "0.11.1",
"resolved": "https://registry.npmjs.org/util/-/util-0.11.1.tgz", "resolved": "https://registry.npmjs.org/util/-/util-0.11.1.tgz",
@ -8564,9 +8605,9 @@
} }
}, },
"wiki-list-editor": { "wiki-list-editor": {
"version": "0.7.1", "version": "0.7.2",
"resolved": "https://registry.npmjs.org/wiki-list-editor/-/wiki-list-editor-0.7.1.tgz", "resolved": "https://registry.npmjs.org/wiki-list-editor/-/wiki-list-editor-0.7.2.tgz",
"integrity": "sha512-rctnDnVH2buNz6OeK2qm0V7BrOmNmWOoB5gX5VsAgPrLwtss637+BRYGcZDHp8d6vvGwwAZBuYDanXgfExVtAw==", "integrity": "sha512-Rw5Cn+BztW+q/JRhOKjOSwZ4Wyx/Llv/8YuxYRDkMPV/buCUethIAYeywoStaoSxkXft3ONHcXq8Hgu9AFwtjw==",
"requires": { "requires": {
"dragula": "^3.7.2", "dragula": "^3.7.2",
"he": "^1.2.0", "he": "^1.2.0",

View File

@ -19,12 +19,14 @@
"jquery-contextmenu": "^2.9.2", "jquery-contextmenu": "^2.9.2",
"lunr": "^2.3.8", "lunr": "^2.3.8",
"markdown-it": "^11.0.0", "markdown-it": "^11.0.0",
"markdown-it-mark": "^3.0.0",
"markdown-it-wikilinks": "^1.0.1",
"moment": "^2.26.0", "moment": "^2.26.0",
"mustache": "^4.0.1", "mustache": "^4.0.1",
"node-sass": "^4.14.1", "node-sass": "^4.14.1",
"sass-loader": "^7.3.1", "sass-loader": "^7.3.1",
"style-loader": "^1.0.0", "style-loader": "^1.0.0",
"wiki-list-editor": "^0.7.1" "wiki-list-editor": "^0.7.2"
}, },
"scripts": { "scripts": {
"test": "node_modules/.bin/mocha -r esm", "test": "node_modules/.bin/mocha -r esm",

View File

@ -1,4 +1,7 @@
import listEditor from 'wiki-list-editor'; import listEditor from 'wiki-list-editor';
import MarkdownIt from 'markdown-it';
import MarkdownItWikilinks from 'markdown-it-wikilinks';
import MarkdownItMark from 'markdown-it-mark';
import axios from 'axios'; import axios from 'axios';
import qs from 'querystring' import qs from 'querystring'
import $ from 'jquery'; import $ from 'jquery';
@ -161,7 +164,21 @@ $(document).on('popup:selected', '#autocomplete', function (event, linkName, res
}) })
if (holder) { if (holder) {
let editor = listEditor(holder, JSON.parse(holder.dataset.input)); console.log(holder.dataset)
const MD = new MarkdownIt()
MD.use(MarkdownItWikilinks({
baseURL: holder.dataset.baseUrl,
uriSuffix: '',
relativeBaseURL: '/edit/'
})).use(MarkdownItMark)
const options = {
transform(text, callback) {
let converted = MD.renderInline(text)
return callback(converted)
}
}
let editor = listEditor(holder, JSON.parse(holder.dataset.input), options);
editor.on('change', function () { editor.on('change', function () {
let element = document.getElementById('editor'); let element = document.getElementById('editor');

View File

@ -12,6 +12,15 @@ body {
font-family: 'Inter', sans-serif; font-family: 'Inter', sans-serif;
} }
.content a::before {
content: "[[";
color: #ccc;
}
.content a::after {
content: "]]";
color: #ccc;
}
@supports (font-variation-settings: normal) { @supports (font-variation-settings: normal) {
html { html {
font-family: 'Inter var', sans-serif; font-family: 'Inter var', sans-serif;