|
|
|
@ -13,6 +13,7 @@ import 'jquery-contextmenu';
|
|
|
|
|
import getCaretCoordinates from './caret-position'
|
|
|
|
|
import moment from 'moment'
|
|
|
|
|
import mermaid from 'mermaid'
|
|
|
|
|
import { parseDOTNetwork, Network } from "vis-network/peer";
|
|
|
|
|
import PrismJS from 'prismjs'
|
|
|
|
|
import 'prismjs/plugins/filter-highlight-all/prism-filter-highlight-all'
|
|
|
|
|
import 'prismjs/components/prism-php'
|
|
|
|
@ -21,12 +22,17 @@ import 'prismjs/components/prism-perl'
|
|
|
|
|
import 'prismjs/components/prism-css'
|
|
|
|
|
import 'prismjs/components/prism-markup-templating'
|
|
|
|
|
import 'prismjs/components/prism-jq'
|
|
|
|
|
import './styles.scss';
|
|
|
|
|
import '../node_modules/jquery-contextmenu/dist/jquery.contextMenu.css';
|
|
|
|
|
|
|
|
|
|
import './styles.scss'
|
|
|
|
|
import '../node_modules/jquery-contextmenu/dist/jquery.contextMenu.css'
|
|
|
|
|
import 'vis-network/styles/vis-network.css'
|
|
|
|
|
|
|
|
|
|
moment.locale('nl')
|
|
|
|
|
mermaid.initialize({startOnLoad: true})
|
|
|
|
|
|
|
|
|
|
PrismJS.plugins.filterHighlightAll.reject.addSelector('.language-mermaid')
|
|
|
|
|
PrismJS.plugins.filterHighlightAll.reject.addSelector('.language-dot')
|
|
|
|
|
|
|
|
|
|
function isMultiline(input) {
|
|
|
|
|
return input.value.startsWith("```", 0)
|
|
|
|
|
}
|
|
|
|
@ -83,20 +89,20 @@ function addIndicator(editor, indicator) {
|
|
|
|
|
let holder = document.getElementById('editor');
|
|
|
|
|
|
|
|
|
|
function showSearchResults(searchTool, query, input, value, resultType) {
|
|
|
|
|
showSearchResultsExtended('#link-complete', 'link-template', searchTool, query, input, value, resultType, {belowCursor: true})
|
|
|
|
|
showSearchResultsExtended('#link-complete', 'link-template', searchTool, query, input, value, resultType, {showOnlyResults:true, belowCursor: true})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showSearchResultsExtended(element, template, searchTool, query, input, value, resultType, options) {
|
|
|
|
|
const $lc = $(element)
|
|
|
|
|
let results = searchTool(query)
|
|
|
|
|
|
|
|
|
|
if (query.length === 0 || !results.length) {
|
|
|
|
|
let opt = options || {};
|
|
|
|
|
|
|
|
|
|
if (opt.showOnlyResults && (query.length === 0 || !results.length)) {
|
|
|
|
|
$lc.fadeOut()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let opt = options || {};
|
|
|
|
|
|
|
|
|
|
$lc.data('result-type', resultType)
|
|
|
|
|
|
|
|
|
|
if (opt.belowCursor) {
|
|
|
|
@ -180,6 +186,24 @@ $(document).on('popup:selected', '#autocomplete', function (event, linkName, res
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function renderGraphs() {
|
|
|
|
|
$('code.language-dot').each(function (i, code) {
|
|
|
|
|
if (!code.innerText) {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let data = parseDOTNetwork(code.innerText)
|
|
|
|
|
let network = new Network(code, data, {
|
|
|
|
|
layout: {
|
|
|
|
|
randomSeed: 1239043
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
$(code).on('click', function () {
|
|
|
|
|
return false
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (holder) {
|
|
|
|
|
const MD = new MarkdownIt({
|
|
|
|
|
linkify: true,
|
|
|
|
@ -200,9 +224,9 @@ if (holder) {
|
|
|
|
|
})).use(MarkdownItMark)
|
|
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
|
transform(text, callback) {
|
|
|
|
|
transform(text, element) {
|
|
|
|
|
let converted = (text.startsWith("```", 0)) ? MD.render(text) : MD.renderInline(text)
|
|
|
|
|
return callback(converted)
|
|
|
|
|
element.html(converted)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -221,6 +245,12 @@ if (holder) {
|
|
|
|
|
).save()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
editor.on('rendered', function () {
|
|
|
|
|
PrismJS.highlightAll()
|
|
|
|
|
mermaid.init()
|
|
|
|
|
renderGraphs();
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
createPageSearch().then(function ({titleSearch, commandSearch, commands}) {
|
|
|
|
|
editor.on('start-editing', function (input) {
|
|
|
|
|
const $lc = $('#link-complete');
|
|
|
|
@ -370,9 +400,9 @@ if (holder) {
|
|
|
|
|
editor.on('stop-editing', function (input) {
|
|
|
|
|
$(input).parents('.list-item').removeClass('active');
|
|
|
|
|
$('#link-complete').off()
|
|
|
|
|
PrismJS.plugins.filterHighlightAll.reject.addSelector('.language-mermaid')
|
|
|
|
|
PrismJS.highlightAll()
|
|
|
|
|
mermaid.init()
|
|
|
|
|
renderGraphs();
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
$.contextMenu({
|
|
|
|
|