mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-29 06:15:29 -04:00
Linter: Fix all lint errors
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
b0a45bdf9c
commit
136d895d15
51 changed files with 2245 additions and 1539 deletions
|
@ -262,8 +262,8 @@ function updateItemFromNow () {
|
|||
}
|
||||
}
|
||||
|
||||
var clearHistory = false
|
||||
var deleteId = null
|
||||
let clearHistory = false
|
||||
let deleteId = null
|
||||
|
||||
function deleteHistory () {
|
||||
checkIfAuth(() => {
|
||||
|
@ -431,9 +431,9 @@ $('.search').keyup(() => {
|
|||
|
||||
// focus user field after opening login modal
|
||||
$('.signin-modal').on('shown.bs.modal', function () {
|
||||
let fieldLDAP = $('input[name=username]')
|
||||
let fieldEmail = $('input[name=email]')
|
||||
let fieldOpenID = $('input[name=openid_identifier]')
|
||||
const fieldLDAP = $('input[name=username]')
|
||||
const fieldEmail = $('input[name=email]')
|
||||
const fieldOpenID = $('input[name=openid_identifier]')
|
||||
if (fieldLDAP.length === 1) {
|
||||
fieldLDAP.focus()
|
||||
} else if (fieldEmail.length === 1) {
|
||||
|
|
|
@ -29,7 +29,7 @@ require('prismjs/components/prism-gherkin')
|
|||
require('./lib/common/login')
|
||||
require('./locale')
|
||||
require('../vendor/md-toc')
|
||||
var Viz = require('viz.js')
|
||||
const Viz = require('viz.js')
|
||||
const ui = getUIElements()
|
||||
|
||||
// auto update last change
|
||||
|
@ -314,8 +314,9 @@ export function finishView (view) {
|
|||
// sequence diagram
|
||||
const sequences = view.find('div.sequence-diagram.raw').removeClass('raw')
|
||||
sequences.each((key, value) => {
|
||||
let $value
|
||||
try {
|
||||
var $value = $(value)
|
||||
$value = $(value)
|
||||
const $ele = $(value).parent().parent()
|
||||
|
||||
const sequence = $value
|
||||
|
@ -337,15 +338,16 @@ export function finishView (view) {
|
|||
// flowchart
|
||||
const flow = view.find('div.flow-chart.raw').removeClass('raw')
|
||||
flow.each((key, value) => {
|
||||
let $value
|
||||
try {
|
||||
var $value = $(value)
|
||||
$value = $(value)
|
||||
const $ele = $(value).parent().parent()
|
||||
|
||||
const chart = window.flowchart.parse($value.text())
|
||||
$value.html('')
|
||||
chart.drawSVG(value, {
|
||||
'line-width': 2,
|
||||
'fill': 'none',
|
||||
fill: 'none',
|
||||
'font-size': '16px',
|
||||
'font-family': "'Andale Mono', monospace"
|
||||
})
|
||||
|
@ -359,13 +361,14 @@ export function finishView (view) {
|
|||
}
|
||||
})
|
||||
// graphviz
|
||||
var graphvizs = view.find('div.graphviz.raw').removeClass('raw')
|
||||
const graphvizs = view.find('div.graphviz.raw').removeClass('raw')
|
||||
graphvizs.each(function (key, value) {
|
||||
let $value
|
||||
try {
|
||||
var $value = $(value)
|
||||
var $ele = $(value).parent().parent()
|
||||
$value = $(value)
|
||||
const $ele = $(value).parent().parent()
|
||||
|
||||
var graphviz = Viz($value.text())
|
||||
const graphviz = Viz($value.text())
|
||||
if (!graphviz) throw Error('viz.js output empty graph')
|
||||
$value.html(graphviz)
|
||||
|
||||
|
@ -380,8 +383,9 @@ export function finishView (view) {
|
|||
// mermaid
|
||||
const mermaids = view.find('div.mermaid.raw').removeClass('raw')
|
||||
mermaids.each((key, value) => {
|
||||
let $value
|
||||
try {
|
||||
var $value = $(value)
|
||||
$value = $(value)
|
||||
const $ele = $(value).closest('pre')
|
||||
|
||||
window.mermaid.mermaidAPI.parse($value.text())
|
||||
|
@ -389,7 +393,7 @@ export function finishView (view) {
|
|||
$ele.text($value.text())
|
||||
window.mermaid.init(undefined, $ele)
|
||||
} catch (err) {
|
||||
var errormessage = err
|
||||
let errormessage = err
|
||||
if (err.str) {
|
||||
errormessage = err.str
|
||||
}
|
||||
|
@ -402,9 +406,10 @@ export function finishView (view) {
|
|||
// abc.js
|
||||
const abcs = view.find('div.abc.raw').removeClass('raw')
|
||||
abcs.each((key, value) => {
|
||||
let $value
|
||||
try {
|
||||
var $value = $(value)
|
||||
var $ele = $(value).parent().parent()
|
||||
$value = $(value)
|
||||
const $ele = $(value).parent().parent()
|
||||
|
||||
window.ABCJS.renderAbc(value, $value.text())
|
||||
|
||||
|
@ -493,7 +498,7 @@ export function finishView (view) {
|
|||
let code = ''
|
||||
if (codeDiv.length > 0) code = codeDiv.html()
|
||||
else code = langDiv.html()
|
||||
var result
|
||||
let result
|
||||
if (!reallang) {
|
||||
result = {
|
||||
value: code
|
||||
|
@ -571,7 +576,7 @@ export function postProcess (code) {
|
|||
}
|
||||
// show yaml meta paring error
|
||||
if (md.metaError) {
|
||||
var warning = result.find('div#meta-error')
|
||||
let warning = result.find('div#meta-error')
|
||||
if (warning && warning.length > 0) {
|
||||
warning.text(md.metaError)
|
||||
} else {
|
||||
|
@ -583,14 +588,14 @@ export function postProcess (code) {
|
|||
}
|
||||
window.postProcess = postProcess
|
||||
|
||||
var domevents = Object.getOwnPropertyNames(document).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(Object.getPrototypeOf(document)))).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(window))).filter(function (i) {
|
||||
const domevents = Object.getOwnPropertyNames(document).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(Object.getPrototypeOf(document)))).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(window))).filter(function (i) {
|
||||
return !i.indexOf('on') && (document[i] === null || typeof document[i] === 'function')
|
||||
}).filter(function (elem, pos, self) {
|
||||
return self.indexOf(elem) === pos
|
||||
})
|
||||
|
||||
export function removeDOMEvents (view) {
|
||||
for (var i = 0, l = domevents.length; i < l; i++) {
|
||||
for (let i = 0, l = domevents.length; i < l; i++) {
|
||||
view.find('[' + domevents[i] + ']').removeAttr(domevents[i])
|
||||
}
|
||||
}
|
||||
|
@ -739,13 +744,13 @@ export function generateToc (id) {
|
|||
const target = $(`#${id}`)
|
||||
target.html('')
|
||||
/* eslint-disable no-unused-vars */
|
||||
var toc = new window.Toc('doc', {
|
||||
'level': 3,
|
||||
'top': -1,
|
||||
'class': 'toc',
|
||||
'ulClass': 'nav',
|
||||
'targetId': id,
|
||||
'process': getHeaderContent
|
||||
const toc = new window.Toc('doc', {
|
||||
level: 3,
|
||||
top: -1,
|
||||
class: 'toc',
|
||||
ulClass: 'nav',
|
||||
targetId: id,
|
||||
process: getHeaderContent
|
||||
})
|
||||
/* eslint-enable no-unused-vars */
|
||||
if (target.text() === 'undefined') { target.html('') }
|
||||
|
@ -858,7 +863,7 @@ const linkifyAnchors = (level, containingElement) => {
|
|||
const headers = containingElement.getElementsByTagName(`h${level}`)
|
||||
|
||||
for (let i = 0, l = headers.length; i < l; i++) {
|
||||
let header = headers[i]
|
||||
const header = headers[i]
|
||||
if (header.getElementsByClassName('anchor').length === 0) {
|
||||
if (typeof header.id === 'undefined' || header.id === '') {
|
||||
header.id = createHeaderId(getHeaderContent(header))
|
||||
|
@ -903,7 +908,7 @@ export function deduplicatedHeaderId (view) {
|
|||
if (window.linkifyHeaderStyle === 'gfm') {
|
||||
// consistent with GitHub, GitLab, Pandoc & co.
|
||||
// all headers contained in the document, in order of appearance
|
||||
const allHeaders = view.find(`:header`).toArray()
|
||||
const allHeaders = view.find(':header').toArray()
|
||||
// list of finaly assigned header IDs
|
||||
const headerIds = new Set()
|
||||
for (let j = 0; j < allHeaders.length; j++) {
|
||||
|
@ -938,12 +943,12 @@ export function renderTOC (view) {
|
|||
const target = $(`#${id}`)
|
||||
target.html('')
|
||||
/* eslint-disable no-unused-vars */
|
||||
let TOC = new window.Toc('doc', {
|
||||
'level': 3,
|
||||
'top': -1,
|
||||
'class': 'toc',
|
||||
'targetId': id,
|
||||
'process': getHeaderContent
|
||||
const TOC = new window.Toc('doc', {
|
||||
level: 3,
|
||||
top: -1,
|
||||
class: 'toc',
|
||||
targetId: id,
|
||||
process: getHeaderContent
|
||||
})
|
||||
/* eslint-enable no-unused-vars */
|
||||
if (target.text() === 'undefined') { target.html('') }
|
||||
|
@ -991,7 +996,7 @@ function highlightRender (code, lang) {
|
|||
return result.value
|
||||
}
|
||||
|
||||
export let md = markdownit('default', {
|
||||
export const md = markdownit('default', {
|
||||
html: true,
|
||||
breaks: true,
|
||||
langPrefix: '',
|
||||
|
@ -1044,7 +1049,7 @@ md.use(markdownitContainer, 'info', { render: renderContainer })
|
|||
md.use(markdownitContainer, 'warning', { render: renderContainer })
|
||||
md.use(markdownitContainer, 'danger', { render: renderContainer })
|
||||
|
||||
let defaultImageRender = md.renderer.rules.image
|
||||
const defaultImageRender = md.renderer.rules.image
|
||||
md.renderer.rules.image = function (tokens, idx, options, env, self) {
|
||||
tokens[idx].attrJoin('class', 'raw')
|
||||
return defaultImageRender(...arguments)
|
||||
|
@ -1203,7 +1208,8 @@ function meta (state, start, end, silent) {
|
|||
if (!get(state, start).match(/^---$/)) return false
|
||||
|
||||
const data = []
|
||||
for (var line = start + 1; line < end; line++) {
|
||||
let line
|
||||
for (line = start + 1; line < end; line++) {
|
||||
const str = get(state, line)
|
||||
if (str.match(/^(\.{3}|-{3})$/)) break
|
||||
if (state.tShift[line] < 0) break
|
||||
|
|
|
@ -147,7 +147,7 @@ export function writeHistory (title, tags) {
|
|||
}
|
||||
|
||||
function writeHistoryToStorage (title, tags) {
|
||||
let data = store.get('notehistory')
|
||||
const data = store.get('notehistory')
|
||||
let notehistory
|
||||
if (data && typeof data === 'string') {
|
||||
notehistory = JSON.parse(data)
|
||||
|
@ -220,7 +220,7 @@ export function getStorageHistory (callback) {
|
|||
if (typeof data === 'string') { data = JSON.parse(data) }
|
||||
callback(data)
|
||||
}
|
||||
// eslint-disable-next-line standard/no-callback-literal
|
||||
// eslint-disable-next-line node/no-callback-literal
|
||||
callback([])
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,7 @@ function parseToHistory (list, notehistory, callback) {
|
|||
for (let i = 0; i < notehistory.length; i++) {
|
||||
// migrate LZString encoded id to base64url encoded id
|
||||
try {
|
||||
let id = LZString.decompressFromBase64(notehistory[i].id)
|
||||
const id = LZString.decompressFromBase64(notehistory[i].id)
|
||||
if (id && checkNoteIdValid(id)) {
|
||||
notehistory[i].id = encodeNoteId(id)
|
||||
}
|
||||
|
|
2183
public/js/index.js
2183
public/js/index.js
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
import modeType from './modeType'
|
||||
|
||||
let state = {
|
||||
const state = {
|
||||
syncscroll: true,
|
||||
currentMode: modeType.view,
|
||||
nightMode: false
|
||||
|
|
|
@ -7,7 +7,7 @@ let checkAuth = false
|
|||
let profile = null
|
||||
let lastLoginState = getLoginState()
|
||||
let lastUserId = getUserId()
|
||||
var loginStateChangeEvent = null
|
||||
let loginStateChangeEvent = null
|
||||
|
||||
export function setloginStateChangeEvent (func) {
|
||||
loginStateChangeEvent = func
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
let config = {
|
||||
const config = {
|
||||
docmaxlength: null
|
||||
}
|
||||
|
||||
|
|
|
@ -35,30 +35,30 @@ export default class Editor {
|
|||
},
|
||||
Enter: 'newlineAndIndentContinueMarkdownList',
|
||||
Tab: function (cm) {
|
||||
var tab = '\t'
|
||||
const tab = '\t'
|
||||
|
||||
// contruct x length spaces
|
||||
var spaces = Array(parseInt(cm.getOption('indentUnit')) + 1).join(' ')
|
||||
const spaces = Array(parseInt(cm.getOption('indentUnit')) + 1).join(' ')
|
||||
|
||||
// auto indent whole line when in list or blockquote
|
||||
var cursor = cm.getCursor()
|
||||
var line = cm.getLine(cursor.line)
|
||||
const cursor = cm.getCursor()
|
||||
const line = cm.getLine(cursor.line)
|
||||
|
||||
// this regex match the following patterns
|
||||
// 1. blockquote starts with "> " or ">>"
|
||||
// 2. unorder list starts with *+-
|
||||
// 3. order list starts with "1." or "1)"
|
||||
var regex = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))/
|
||||
const regex = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))/
|
||||
|
||||
var match
|
||||
var multiple = cm.getSelection().split('\n').length > 1 ||
|
||||
let match
|
||||
const multiple = cm.getSelection().split('\n').length > 1 ||
|
||||
cm.getSelections().length > 1
|
||||
|
||||
if (multiple) {
|
||||
cm.execCommand('defaultTab')
|
||||
} else if ((match = regex.exec(line)) !== null) {
|
||||
var ch = match[1].length
|
||||
var pos = {
|
||||
const ch = match[1].length
|
||||
const pos = {
|
||||
line: cursor.line,
|
||||
ch: ch
|
||||
}
|
||||
|
@ -77,8 +77,8 @@ export default class Editor {
|
|||
},
|
||||
'Cmd-Left': 'goLineLeftSmart',
|
||||
'Cmd-Right': 'goLineRight',
|
||||
'Home': 'goLineLeftSmart',
|
||||
'End': 'goLineRight',
|
||||
Home: 'goLineLeftSmart',
|
||||
End: 'goLineRight',
|
||||
'Ctrl-C': function (cm) {
|
||||
if (!isMac && cm.getOption('keyMap').substr(0, 3) === 'vim') {
|
||||
document.execCommand('copy')
|
||||
|
@ -140,27 +140,27 @@ export default class Editor {
|
|||
}
|
||||
|
||||
addToolBar () {
|
||||
var inlineAttach = inlineAttachment.editors.codemirror4.attach(this.editor)
|
||||
const inlineAttach = inlineAttachment.editors.codemirror4.attach(this.editor)
|
||||
this.toolBar = $(toolBarTemplate)
|
||||
this.toolbarPanel = this.editor.addPanel(this.toolBar[0], {
|
||||
position: 'top'
|
||||
})
|
||||
|
||||
var makeBold = $('#makeBold')
|
||||
var makeItalic = $('#makeItalic')
|
||||
var makeStrike = $('#makeStrike')
|
||||
var makeHeader = $('#makeHeader')
|
||||
var makeCode = $('#makeCode')
|
||||
var makeQuote = $('#makeQuote')
|
||||
var makeGenericList = $('#makeGenericList')
|
||||
var makeOrderedList = $('#makeOrderedList')
|
||||
var makeCheckList = $('#makeCheckList')
|
||||
var makeLink = $('#makeLink')
|
||||
var makeImage = $('#makeImage')
|
||||
var makeTable = $('#makeTable')
|
||||
var makeLine = $('#makeLine')
|
||||
var makeComment = $('#makeComment')
|
||||
var uploadImage = $('#uploadImage')
|
||||
const makeBold = $('#makeBold')
|
||||
const makeItalic = $('#makeItalic')
|
||||
const makeStrike = $('#makeStrike')
|
||||
const makeHeader = $('#makeHeader')
|
||||
const makeCode = $('#makeCode')
|
||||
const makeQuote = $('#makeQuote')
|
||||
const makeGenericList = $('#makeGenericList')
|
||||
const makeOrderedList = $('#makeOrderedList')
|
||||
const makeCheckList = $('#makeCheckList')
|
||||
const makeLink = $('#makeLink')
|
||||
const makeImage = $('#makeImage')
|
||||
const makeTable = $('#makeTable')
|
||||
const makeLine = $('#makeLine')
|
||||
const makeComment = $('#makeComment')
|
||||
const uploadImage = $('#uploadImage')
|
||||
|
||||
makeBold.click(() => {
|
||||
utils.wrapTextWith(this.editor, this.editor, '**')
|
||||
|
@ -223,7 +223,7 @@ export default class Editor {
|
|||
})
|
||||
|
||||
uploadImage.bind('change', function (e) {
|
||||
var files = e.target.files || e.dataTransfer.files
|
||||
const files = e.target.files || e.dataTransfer.files
|
||||
e.dataTransfer = {}
|
||||
e.dataTransfer.files = files
|
||||
inlineAttach.onDrop(e)
|
||||
|
@ -256,12 +256,12 @@ export default class Editor {
|
|||
updateStatusBar () {
|
||||
if (!this.statusBar) return
|
||||
|
||||
var cursor = this.editor.getCursor()
|
||||
var cursorText = 'Line ' + (cursor.line + 1) + ', Columns ' + (cursor.ch + 1)
|
||||
const cursor = this.editor.getCursor()
|
||||
const cursorText = 'Line ' + (cursor.line + 1) + ', Columns ' + (cursor.ch + 1)
|
||||
this.statusCursor.text(cursorText)
|
||||
var fileText = ' — ' + editor.lineCount() + ' Lines'
|
||||
const fileText = ' — ' + editor.lineCount() + ' Lines'
|
||||
this.statusFile.text(fileText)
|
||||
var docLength = editor.getValue().length
|
||||
const docLength = editor.getValue().length
|
||||
this.statusLength.text('Length ' + docLength)
|
||||
if (docLength > (config.docmaxlength * 0.95)) {
|
||||
this.statusLength.css('color', 'red')
|
||||
|
@ -276,9 +276,9 @@ export default class Editor {
|
|||
}
|
||||
|
||||
setIndent () {
|
||||
var cookieIndentType = Cookies.get('indent_type')
|
||||
var cookieTabSize = parseInt(Cookies.get('tab_size'))
|
||||
var cookieSpaceUnits = parseInt(Cookies.get('space_units'))
|
||||
const cookieIndentType = Cookies.get('indent_type')
|
||||
let cookieTabSize = parseInt(Cookies.get('tab_size'))
|
||||
let cookieSpaceUnits = parseInt(Cookies.get('space_units'))
|
||||
if (cookieIndentType) {
|
||||
if (cookieIndentType === 'tab') {
|
||||
this.editor.setOption('indentWithTabs', true)
|
||||
|
@ -296,9 +296,9 @@ export default class Editor {
|
|||
this.editor.setOption('tabSize', cookieTabSize)
|
||||
}
|
||||
|
||||
var type = this.statusIndicators.find('.indent-type')
|
||||
var widthLabel = this.statusIndicators.find('.indent-width-label')
|
||||
var widthInput = this.statusIndicators.find('.indent-width-input')
|
||||
const type = this.statusIndicators.find('.indent-type')
|
||||
const widthLabel = this.statusIndicators.find('.indent-width-label')
|
||||
const widthInput = this.statusIndicators.find('.indent-width-input')
|
||||
|
||||
const setType = () => {
|
||||
if (this.editor.getOption('indentWithTabs')) {
|
||||
|
@ -318,7 +318,7 @@ export default class Editor {
|
|||
setType()
|
||||
|
||||
const setUnit = () => {
|
||||
var unit = this.editor.getOption('indentUnit')
|
||||
const unit = this.editor.getOption('indentUnit')
|
||||
if (this.editor.getOption('indentWithTabs')) {
|
||||
Cookies.set('tab_size', unit, {
|
||||
expires: 365,
|
||||
|
@ -364,7 +364,7 @@ export default class Editor {
|
|||
}
|
||||
})
|
||||
widthInput.on('change', () => {
|
||||
var val = parseInt(widthInput.val())
|
||||
let val = parseInt(widthInput.val())
|
||||
if (!val) val = this.editor.getOption('indentUnit')
|
||||
if (val < 1) val = 1
|
||||
else if (val > 10) val = 10
|
||||
|
@ -382,18 +382,18 @@ export default class Editor {
|
|||
}
|
||||
|
||||
setKeymap () {
|
||||
var cookieKeymap = Cookies.get('keymap')
|
||||
const cookieKeymap = Cookies.get('keymap')
|
||||
if (cookieKeymap) {
|
||||
this.editor.setOption('keyMap', cookieKeymap)
|
||||
}
|
||||
|
||||
var label = this.statusIndicators.find('.ui-keymap-label')
|
||||
var sublime = this.statusIndicators.find('.ui-keymap-sublime')
|
||||
var emacs = this.statusIndicators.find('.ui-keymap-emacs')
|
||||
var vim = this.statusIndicators.find('.ui-keymap-vim')
|
||||
const label = this.statusIndicators.find('.ui-keymap-label')
|
||||
const sublime = this.statusIndicators.find('.ui-keymap-sublime')
|
||||
const emacs = this.statusIndicators.find('.ui-keymap-emacs')
|
||||
const vim = this.statusIndicators.find('.ui-keymap-vim')
|
||||
|
||||
const setKeymapLabel = () => {
|
||||
var keymap = this.editor.getOption('keyMap')
|
||||
const keymap = this.editor.getOption('keyMap')
|
||||
Cookies.set('keymap', keymap, {
|
||||
expires: 365,
|
||||
sameSite: window.cookiePolicy
|
||||
|
@ -419,15 +419,15 @@ export default class Editor {
|
|||
}
|
||||
|
||||
setTheme () {
|
||||
var cookieTheme = Cookies.get('theme')
|
||||
const cookieTheme = Cookies.get('theme')
|
||||
if (cookieTheme) {
|
||||
this.editor.setOption('theme', cookieTheme)
|
||||
}
|
||||
|
||||
var themeToggle = this.statusTheme.find('.ui-theme-toggle')
|
||||
const themeToggle = this.statusTheme.find('.ui-theme-toggle')
|
||||
|
||||
const checkTheme = () => {
|
||||
var theme = this.editor.getOption('theme')
|
||||
const theme = this.editor.getOption('theme')
|
||||
if (theme === 'one-dark') {
|
||||
themeToggle.removeClass('active')
|
||||
} else {
|
||||
|
@ -436,7 +436,7 @@ export default class Editor {
|
|||
}
|
||||
|
||||
themeToggle.click(() => {
|
||||
var theme = this.editor.getOption('theme')
|
||||
let theme = this.editor.getOption('theme')
|
||||
if (theme === 'one-dark') {
|
||||
theme = 'default'
|
||||
} else {
|
||||
|
@ -455,9 +455,9 @@ export default class Editor {
|
|||
}
|
||||
|
||||
setSpellcheck () {
|
||||
var cookieSpellcheck = Cookies.get('spellcheck')
|
||||
const cookieSpellcheck = Cookies.get('spellcheck')
|
||||
if (cookieSpellcheck) {
|
||||
var mode = null
|
||||
let mode = null
|
||||
if (cookieSpellcheck === 'true' || cookieSpellcheck === true) {
|
||||
mode = 'spell-checker'
|
||||
} else {
|
||||
|
@ -468,10 +468,10 @@ export default class Editor {
|
|||
}
|
||||
}
|
||||
|
||||
var spellcheckToggle = this.statusSpellcheck.find('.ui-spellcheck-toggle')
|
||||
const spellcheckToggle = this.statusSpellcheck.find('.ui-spellcheck-toggle')
|
||||
|
||||
const checkSpellcheck = () => {
|
||||
var mode = this.editor.getOption('mode')
|
||||
const mode = this.editor.getOption('mode')
|
||||
if (mode === defaultEditorMode) {
|
||||
spellcheckToggle.removeClass('active')
|
||||
} else {
|
||||
|
@ -480,7 +480,7 @@ export default class Editor {
|
|||
}
|
||||
|
||||
spellcheckToggle.click(() => {
|
||||
var mode = this.editor.getOption('mode')
|
||||
let mode = this.editor.getOption('mode')
|
||||
if (mode === defaultEditorMode) {
|
||||
mode = 'spell-checker'
|
||||
} else {
|
||||
|
@ -501,7 +501,7 @@ export default class Editor {
|
|||
|
||||
// workaround spellcheck might not activate beacuse the ajax loading
|
||||
if (window.num_loaded < 2) {
|
||||
var spellcheckTimer = setInterval(
|
||||
const spellcheckTimer = setInterval(
|
||||
() => {
|
||||
if (window.num_loaded >= 2) {
|
||||
if (this.editor.getOption('mode') === 'spell-checker') {
|
||||
|
@ -516,7 +516,7 @@ export default class Editor {
|
|||
}
|
||||
|
||||
resetEditorKeymapToBrowserKeymap () {
|
||||
var keymap = this.editor.getOption('keyMap')
|
||||
const keymap = this.editor.getOption('keyMap')
|
||||
if (!this.jumpToAddressBarKeymapValue) {
|
||||
this.jumpToAddressBarKeymapValue = CodeMirror.keyMap[keymap][jumpToAddressBarKeymapName]
|
||||
delete CodeMirror.keyMap[keymap][jumpToAddressBarKeymapName]
|
||||
|
@ -524,14 +524,15 @@ export default class Editor {
|
|||
}
|
||||
|
||||
restoreOverrideEditorKeymap () {
|
||||
var keymap = this.editor.getOption('keyMap')
|
||||
const keymap = this.editor.getOption('keyMap')
|
||||
if (this.jumpToAddressBarKeymapValue) {
|
||||
CodeMirror.keyMap[keymap][jumpToAddressBarKeymapName] = this.jumpToAddressBarKeymapValue
|
||||
this.jumpToAddressBarKeymapValue = null
|
||||
}
|
||||
}
|
||||
|
||||
setOverrideBrowserKeymap () {
|
||||
var overrideBrowserKeymap = $(
|
||||
const overrideBrowserKeymap = $(
|
||||
'.ui-preferences-override-browser-keymap label > input[type="checkbox"]'
|
||||
)
|
||||
if (overrideBrowserKeymap.is(':checked')) {
|
||||
|
@ -547,10 +548,10 @@ export default class Editor {
|
|||
}
|
||||
|
||||
setPreferences () {
|
||||
var overrideBrowserKeymap = $(
|
||||
const overrideBrowserKeymap = $(
|
||||
'.ui-preferences-override-browser-keymap label > input[type="checkbox"]'
|
||||
)
|
||||
var cookieOverrideBrowserKeymap = Cookies.get(
|
||||
const cookieOverrideBrowserKeymap = Cookies.get(
|
||||
'preferences-override-browser-keymap'
|
||||
)
|
||||
if (cookieOverrideBrowserKeymap && cookieOverrideBrowserKeymap === 'true') {
|
||||
|
|
|
@ -3,17 +3,17 @@ export function wrapTextWith (editor, cm, symbol) {
|
|||
if (!cm.getSelection()) {
|
||||
return CodeMirror.Pass
|
||||
} else {
|
||||
let ranges = cm.listSelections()
|
||||
const ranges = cm.listSelections()
|
||||
for (let i = 0; i < ranges.length; i++) {
|
||||
let range = ranges[i]
|
||||
const range = ranges[i]
|
||||
if (!range.empty()) {
|
||||
const from = range.from()
|
||||
const to = range.to()
|
||||
|
||||
if (symbol !== 'Backspace') {
|
||||
let selection = cm.getRange(from, to)
|
||||
let anchorIndex = editor.indexFromPos(ranges[i].anchor)
|
||||
let headIndex = editor.indexFromPos(ranges[i].head)
|
||||
const selection = cm.getRange(from, to)
|
||||
const anchorIndex = editor.indexFromPos(ranges[i].anchor)
|
||||
const headIndex = editor.indexFromPos(ranges[i].head)
|
||||
cm.replaceRange(symbol + selection + symbol, from, to, '+input')
|
||||
if (anchorIndex > headIndex) {
|
||||
ranges[i].anchor.ch += symbol.length
|
||||
|
@ -24,18 +24,18 @@ export function wrapTextWith (editor, cm, symbol) {
|
|||
}
|
||||
cm.setSelections(ranges)
|
||||
} else {
|
||||
let preEndPos = {
|
||||
const preEndPos = {
|
||||
line: to.line,
|
||||
ch: to.ch + symbol.length
|
||||
}
|
||||
let preText = cm.getRange(to, preEndPos)
|
||||
let preIndex = wrapSymbols.indexOf(preText)
|
||||
let postEndPos = {
|
||||
const preText = cm.getRange(to, preEndPos)
|
||||
const preIndex = wrapSymbols.indexOf(preText)
|
||||
const postEndPos = {
|
||||
line: from.line,
|
||||
ch: from.ch - symbol.length
|
||||
}
|
||||
let postText = cm.getRange(postEndPos, from)
|
||||
let postIndex = wrapSymbols.indexOf(postText)
|
||||
const postText = cm.getRange(postEndPos, from)
|
||||
const postIndex = wrapSymbols.indexOf(postText)
|
||||
// check if surround symbol are list in array and matched
|
||||
if (preIndex > -1 && postIndex > -1 && preIndex === postIndex) {
|
||||
cm.replaceRange('', to, preEndPos, '+delete')
|
||||
|
@ -48,25 +48,25 @@ export function wrapTextWith (editor, cm, symbol) {
|
|||
}
|
||||
|
||||
export function insertText (cm, text, cursorEnd = 0) {
|
||||
let cursor = cm.getCursor()
|
||||
const cursor = cm.getCursor()
|
||||
cm.replaceSelection(text, cursor, cursor)
|
||||
cm.focus()
|
||||
cm.setCursor({ line: cursor.line, ch: cursor.ch + cursorEnd })
|
||||
}
|
||||
|
||||
export function insertLink (cm, isImage) {
|
||||
let cursor = cm.getCursor()
|
||||
let ranges = cm.listSelections()
|
||||
const cursor = cm.getCursor()
|
||||
const ranges = cm.listSelections()
|
||||
const linkEnd = '](https://)'
|
||||
const symbol = (isImage) ? '![' : '['
|
||||
|
||||
for (let i = 0; i < ranges.length; i++) {
|
||||
let range = ranges[i]
|
||||
const range = ranges[i]
|
||||
if (!range.empty()) {
|
||||
const from = range.from()
|
||||
const to = range.to()
|
||||
let anchorIndex = editor.indexFromPos(ranges[i].anchor)
|
||||
let headIndex = editor.indexFromPos(ranges[i].head)
|
||||
const anchorIndex = editor.indexFromPos(ranges[i].anchor)
|
||||
const headIndex = editor.indexFromPos(ranges[i].head)
|
||||
let selection = cm.getRange(from, to)
|
||||
selection = symbol + selection + linkEnd
|
||||
cm.replaceRange(selection, from, to)
|
||||
|
@ -87,9 +87,9 @@ export function insertLink (cm, isImage) {
|
|||
}
|
||||
|
||||
export function insertHeader (cm) {
|
||||
let cursor = cm.getCursor()
|
||||
let startOfLine = { line: cursor.line, ch: 0 }
|
||||
let startOfLineText = cm.getRange(startOfLine, { line: cursor.line, ch: 1 })
|
||||
const cursor = cm.getCursor()
|
||||
const startOfLine = { line: cursor.line, ch: 0 }
|
||||
const startOfLineText = cm.getRange(startOfLine, { line: cursor.line, ch: 1 })
|
||||
// See if it is already a header
|
||||
if (startOfLineText === '#') {
|
||||
cm.replaceRange('#', startOfLine, startOfLine)
|
||||
|
@ -100,11 +100,11 @@ export function insertHeader (cm) {
|
|||
}
|
||||
|
||||
export function insertOnStartOfLines (cm, symbol) {
|
||||
let cursor = cm.getCursor()
|
||||
let ranges = cm.listSelections()
|
||||
const cursor = cm.getCursor()
|
||||
const ranges = cm.listSelections()
|
||||
|
||||
for (let i = 0; i < ranges.length; i++) {
|
||||
let range = ranges[i]
|
||||
const range = ranges[i]
|
||||
if (!range.empty()) {
|
||||
const from = range.from()
|
||||
const to = range.to()
|
||||
|
|
|
@ -155,12 +155,12 @@ const buildMap = _.throttle(buildMapInner, buildMapThrottle)
|
|||
// Optimizations are required only for big texts.
|
||||
function buildMapInner (callback) {
|
||||
if (!viewArea || !markdownArea) return
|
||||
let i, offset, nonEmptyList, pos, a, b, _lineHeightMap, linesCount, acc, _scrollMap
|
||||
let i, pos, a, b, acc
|
||||
|
||||
offset = viewArea.scrollTop() - viewArea.offset().top
|
||||
_scrollMap = []
|
||||
nonEmptyList = []
|
||||
_lineHeightMap = []
|
||||
const offset = viewArea.scrollTop() - viewArea.offset().top
|
||||
const _scrollMap = []
|
||||
const nonEmptyList = []
|
||||
const _lineHeightMap = []
|
||||
viewTop = 0
|
||||
viewBottom = viewArea[0].scrollHeight - viewArea.height()
|
||||
|
||||
|
@ -181,7 +181,7 @@ function buildMapInner (callback) {
|
|||
acc += Math.round(h / lineHeight)
|
||||
}
|
||||
_lineHeightMap.push(acc)
|
||||
linesCount = acc
|
||||
const linesCount = acc
|
||||
|
||||
for (i = 0; i < linesCount; i++) {
|
||||
_scrollMap.push(-1)
|
||||
|
@ -290,11 +290,12 @@ export function syncScrollToEdit (event, preventAnimate) {
|
|||
posTo += Math.ceil(posToNextDiff)
|
||||
}
|
||||
|
||||
let duration = 0
|
||||
if (preventAnimate) {
|
||||
editArea.scrollTop(posTo)
|
||||
} else {
|
||||
const posDiff = Math.abs(scrollInfo.top - posTo)
|
||||
var duration = posDiff / 50
|
||||
duration = posDiff / 50
|
||||
duration = duration >= 100 ? duration : 100
|
||||
editArea.stop(true, true).animate({
|
||||
scrollTop: posTo
|
||||
|
@ -331,11 +332,11 @@ export function syncScrollToView (event, preventAnimate) {
|
|||
}
|
||||
if (viewScrolling) return
|
||||
|
||||
let lineNo, posTo
|
||||
let posTo
|
||||
let topDiffPercent, posToNextDiff
|
||||
const scrollInfo = editor.getScrollInfo()
|
||||
const textHeight = editor.defaultTextHeight()
|
||||
lineNo = Math.floor(scrollInfo.top / textHeight)
|
||||
const lineNo = Math.floor(scrollInfo.top / textHeight)
|
||||
// if reach the last line, will start lerp to the bottom
|
||||
const diffToBottom = (scrollInfo.top + scrollInfo.clientHeight) - (scrollInfo.height - textHeight)
|
||||
if (scrollInfo.height > scrollInfo.clientHeight && diffToBottom > 0) {
|
||||
|
@ -350,11 +351,12 @@ export function syncScrollToView (event, preventAnimate) {
|
|||
posTo += Math.floor(posToNextDiff)
|
||||
}
|
||||
|
||||
let duration = 0
|
||||
if (preventAnimate) {
|
||||
viewArea.scrollTop(posTo)
|
||||
} else {
|
||||
const posDiff = Math.abs(viewArea.scrollTop() - posTo)
|
||||
var duration = posDiff / 50
|
||||
duration = posDiff / 50
|
||||
duration = duration >= 100 ? duration : 100
|
||||
viewArea.stop(true, true).animate({
|
||||
scrollTop: posTo
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
/* eslint-env browser, jquery */
|
||||
// allow some attributes
|
||||
|
||||
var filterXSS = require('xss')
|
||||
const filterXSS = require('xss')
|
||||
|
||||
var whiteListAttr = ['id', 'class', 'style']
|
||||
const whiteListAttr = ['id', 'class', 'style']
|
||||
window.whiteListAttr = whiteListAttr
|
||||
// allow link starts with '.', '/' and custom protocol with '://', exclude link starts with javascript://
|
||||
var linkRegex = /^(?!javascript:\/\/)([\w|-]+:\/\/)|^([.|/])+/i
|
||||
const linkRegex = /^(?!javascript:\/\/)([\w|-]+:\/\/)|^([.|/])+/i
|
||||
// allow data uri, from https://gist.github.com/bgrins/6194623
|
||||
var dataUriRegex = /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@/?%\s]*)\s*$/i
|
||||
const dataUriRegex = /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@/?%\s]*)\s*$/i
|
||||
// custom white list
|
||||
var whiteList = filterXSS.whiteList
|
||||
const whiteList = filterXSS.whiteList
|
||||
// allow ol specify start number
|
||||
whiteList['ol'] = ['start']
|
||||
whiteList.ol = ['start']
|
||||
// allow li specify value number
|
||||
whiteList['li'] = ['value']
|
||||
whiteList.li = ['value']
|
||||
// allow style tag
|
||||
whiteList['style'] = []
|
||||
whiteList.style = []
|
||||
// allow kbd tag
|
||||
whiteList['kbd'] = []
|
||||
whiteList.kbd = []
|
||||
// allow ifram tag with some safe attributes
|
||||
whiteList['iframe'] = ['allowfullscreen', 'name', 'referrerpolicy', 'src', 'width', 'height']
|
||||
whiteList.iframe = ['allowfullscreen', 'name', 'referrerpolicy', 'src', 'width', 'height']
|
||||
// allow summary tag
|
||||
whiteList['summary'] = []
|
||||
whiteList.summary = []
|
||||
// allow ruby tag
|
||||
whiteList['ruby'] = []
|
||||
whiteList.ruby = []
|
||||
// allow rp tag for ruby
|
||||
whiteList['rp'] = []
|
||||
whiteList.rp = []
|
||||
// allow rt tag for ruby
|
||||
whiteList['rt'] = []
|
||||
whiteList.rt = []
|
||||
// allow figure tag
|
||||
whiteList['figure'] = []
|
||||
whiteList.figure = []
|
||||
// allow figcaption tag
|
||||
whiteList['figcaption'] = []
|
||||
whiteList.figcaption = []
|
||||
|
||||
var filterXSSOptions = {
|
||||
const filterXSSOptions = {
|
||||
allowCommentTag: true,
|
||||
whiteList: whiteList,
|
||||
escapeHtml: function (html) {
|
||||
|
|
|
@ -17,28 +17,28 @@ import { md } from './extra'
|
|||
root.RevealMarkdown.initialize()
|
||||
}
|
||||
}(this, function () {
|
||||
var DEFAULT_SLIDE_SEPARATOR = '^\r?\n---\r?\n$'
|
||||
var DEFAULT_NOTES_SEPARATOR = '^note:'
|
||||
var DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\.element\\s*?(.+?)$'
|
||||
var DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '\\.slide:\\s*?(\\S.+?)$'
|
||||
const DEFAULT_SLIDE_SEPARATOR = '^\r?\n---\r?\n$'
|
||||
const DEFAULT_NOTES_SEPARATOR = '^note:'
|
||||
const DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\.element\\s*?(.+?)$'
|
||||
const DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '\\.slide:\\s*?(\\S.+?)$'
|
||||
|
||||
var SCRIPT_END_PLACEHOLDER = '__SCRIPT_END__'
|
||||
const SCRIPT_END_PLACEHOLDER = '__SCRIPT_END__'
|
||||
|
||||
/**
|
||||
* Retrieves the markdown contents of a slide section
|
||||
* element. Normalizes leading tabs/whitespace.
|
||||
*/
|
||||
function getMarkdownFromSlide (section) {
|
||||
var template = section.querySelector('script')
|
||||
const template = section.querySelector('script')
|
||||
|
||||
// strip leading whitespace so it isn't evaluated as code
|
||||
var text = (template || section).textContent
|
||||
let text = (template || section).textContent
|
||||
|
||||
// restore script end tags
|
||||
text = text.replace(new RegExp(SCRIPT_END_PLACEHOLDER, 'g'), '</script>')
|
||||
|
||||
var leadingWs = text.match(/^\n?(\s*)/)[1].length
|
||||
var leadingTabs = text.match(/^\n?(\t*)/)[1].length
|
||||
const leadingWs = text.match(/^\n?(\s*)/)[1].length
|
||||
const leadingTabs = text.match(/^\n?(\t*)/)[1].length
|
||||
|
||||
if (leadingTabs > 0) {
|
||||
text = text.replace(new RegExp('\\n?\\t{' + leadingTabs + '}', 'g'), '\n')
|
||||
|
@ -56,12 +56,12 @@ import { md } from './extra'
|
|||
* to the output markdown slide.
|
||||
*/
|
||||
function getForwardedAttributes (section) {
|
||||
var attributes = section.attributes
|
||||
var result = []
|
||||
const attributes = section.attributes
|
||||
const result = []
|
||||
|
||||
for (var i = 0, len = attributes.length; i < len; i++) {
|
||||
var name = attributes[i].name
|
||||
var value = attributes[i].value
|
||||
for (let i = 0, len = attributes.length; i < len; i++) {
|
||||
const name = attributes[i].name
|
||||
const value = attributes[i].value
|
||||
|
||||
// disregard attributes that are used for markdown loading/parsing
|
||||
if (/data-(markdown|separator|vertical|notes)/gi.test(name)) continue
|
||||
|
@ -95,7 +95,7 @@ import { md } from './extra'
|
|||
function createMarkdownSlide (content, options) {
|
||||
options = getSlidifyOptions(options)
|
||||
|
||||
var notesMatch = content.split(new RegExp(options.notesSeparator, 'mgi'))
|
||||
const notesMatch = content.split(new RegExp(options.notesSeparator, 'mgi'))
|
||||
|
||||
if (notesMatch.length === 2) {
|
||||
content = notesMatch[0] + '<aside class="notes" data-markdown>' + notesMatch[1].trim() + '</aside>'
|
||||
|
@ -115,15 +115,15 @@ import { md } from './extra'
|
|||
function slidify (markdown, options) {
|
||||
options = getSlidifyOptions(options)
|
||||
|
||||
var separatorRegex = new RegExp(options.separator + (options.verticalSeparator ? '|' + options.verticalSeparator : ''), 'mg')
|
||||
var horizontalSeparatorRegex = new RegExp(options.separator)
|
||||
const separatorRegex = new RegExp(options.separator + (options.verticalSeparator ? '|' + options.verticalSeparator : ''), 'mg')
|
||||
const horizontalSeparatorRegex = new RegExp(options.separator)
|
||||
|
||||
var matches
|
||||
var lastIndex = 0
|
||||
var isHorizontal
|
||||
var wasHorizontal = true
|
||||
var content
|
||||
var sectionStack = []
|
||||
let matches
|
||||
let lastIndex = 0
|
||||
let isHorizontal
|
||||
let wasHorizontal = true
|
||||
let content
|
||||
const sectionStack = []
|
||||
|
||||
// iterate until all blocks between separators are stacked up
|
||||
while ((matches = separatorRegex.exec(markdown)) !== null) {
|
||||
|
@ -153,10 +153,10 @@ import { md } from './extra'
|
|||
// add the remaining slide
|
||||
(wasHorizontal ? sectionStack : sectionStack[sectionStack.length - 1]).push(markdown.substring(lastIndex))
|
||||
|
||||
var markdownSections = ''
|
||||
let markdownSections = ''
|
||||
|
||||
// flatten the hierarchical stack, and insert <section data-markdown> tags
|
||||
for (var i = 0, len = sectionStack.length; i < len; i++) {
|
||||
for (let i = 0, len = sectionStack.length; i < len; i++) {
|
||||
// vertical
|
||||
if (sectionStack[i] instanceof Array) {
|
||||
markdownSections += '<section ' + options.attributes + '>'
|
||||
|
@ -180,17 +180,17 @@ import { md } from './extra'
|
|||
* handles loading of external markdown.
|
||||
*/
|
||||
function processSlides () {
|
||||
var sections = document.querySelectorAll('[data-markdown]')
|
||||
var section
|
||||
const sections = document.querySelectorAll('[data-markdown]')
|
||||
let section
|
||||
|
||||
for (var i = 0, len = sections.length; i < len; i++) {
|
||||
for (let i = 0, len = sections.length; i < len; i++) {
|
||||
section = sections[i]
|
||||
|
||||
if (section.getAttribute('data-markdown').length) {
|
||||
var xhr = new XMLHttpRequest()
|
||||
var url = section.getAttribute('data-markdown')
|
||||
const xhr = new XMLHttpRequest()
|
||||
const url = section.getAttribute('data-markdown')
|
||||
|
||||
var datacharset = section.getAttribute('data-charset')
|
||||
const datacharset = section.getAttribute('data-charset')
|
||||
|
||||
// see https://developer.mozilla.org/en-US/docs/Web/API/element.getAttribute#Notes
|
||||
if (datacharset !== null && datacharset !== '') {
|
||||
|
@ -247,18 +247,18 @@ import { md } from './extra'
|
|||
* http://stackoverflow.com/questions/5690269/disabling-chrome-cache-for-website-development/7000899#answer-11786277
|
||||
*/
|
||||
function addAttributeInElement (node, elementTarget, separator) {
|
||||
var mardownClassesInElementsRegex = new RegExp(separator, 'mg')
|
||||
var mardownClassRegex = new RegExp('([^"= ]+?)="([^"=]+?)"', 'mg')
|
||||
var nodeValue = node.nodeValue
|
||||
var matches
|
||||
var matchesClass
|
||||
const mardownClassesInElementsRegex = new RegExp(separator, 'mg')
|
||||
const mardownClassRegex = /([^"= ]+?)="([^"=]+?)"/mg
|
||||
let nodeValue = node.nodeValue
|
||||
let matches
|
||||
let matchesClass
|
||||
if ((matches = mardownClassesInElementsRegex.exec(nodeValue))) {
|
||||
var classes = matches[1]
|
||||
const classes = matches[1]
|
||||
nodeValue = nodeValue.substring(0, matches.index) + nodeValue.substring(mardownClassesInElementsRegex.lastIndex)
|
||||
node.nodeValue = nodeValue
|
||||
while ((matchesClass = mardownClassRegex.exec(classes))) {
|
||||
var name = matchesClass[1]
|
||||
var value = matchesClass[2]
|
||||
const name = matchesClass[1]
|
||||
const value = matchesClass[2]
|
||||
if (name.substr(0, 5) === 'data-' || window.whiteListAttr.indexOf(name) !== -1) { elementTarget.setAttribute(name, escapeAttrValue(value)) }
|
||||
}
|
||||
return true
|
||||
|
@ -272,13 +272,13 @@ import { md } from './extra'
|
|||
*/
|
||||
function addAttributes (section, element, previousElement, separatorElementAttributes, separatorSectionAttributes) {
|
||||
if (element != null && element.childNodes !== undefined && element.childNodes.length > 0) {
|
||||
var previousParentElement = element
|
||||
for (var i = 0; i < element.childNodes.length; i++) {
|
||||
var childElement = element.childNodes[i]
|
||||
let previousParentElement = element
|
||||
for (let i = 0; i < element.childNodes.length; i++) {
|
||||
const childElement = element.childNodes[i]
|
||||
if (i > 0) {
|
||||
let j = i - 1
|
||||
while (j >= 0) {
|
||||
var aPreviousChildElement = element.childNodes[j]
|
||||
const aPreviousChildElement = element.childNodes[j]
|
||||
if (typeof aPreviousChildElement.setAttribute === 'function' && aPreviousChildElement.tagName !== 'BR') {
|
||||
previousParentElement = aPreviousChildElement
|
||||
break
|
||||
|
@ -286,7 +286,7 @@ import { md } from './extra'
|
|||
j = j - 1
|
||||
}
|
||||
}
|
||||
var parentSection = section
|
||||
let parentSection = section
|
||||
if (childElement.nodeName === 'section') {
|
||||
parentSection = childElement
|
||||
previousParentElement = childElement
|
||||
|
@ -309,21 +309,21 @@ import { md } from './extra'
|
|||
* DOM to HTML.
|
||||
*/
|
||||
function convertSlides () {
|
||||
var sections = document.querySelectorAll('[data-markdown]')
|
||||
const sections = document.querySelectorAll('[data-markdown]')
|
||||
|
||||
for (var i = 0, len = sections.length; i < len; i++) {
|
||||
var section = sections[i]
|
||||
for (let i = 0, len = sections.length; i < len; i++) {
|
||||
const section = sections[i]
|
||||
|
||||
// Only parse the same slide once
|
||||
if (!section.getAttribute('data-markdown-parsed')) {
|
||||
section.setAttribute('data-markdown-parsed', true)
|
||||
|
||||
var notes = section.querySelector('aside.notes')
|
||||
var markdown = getMarkdownFromSlide(section)
|
||||
const notes = section.querySelector('aside.notes')
|
||||
let markdown = getMarkdownFromSlide(section)
|
||||
markdown = markdown.replace(/</g, '<').replace(/>/g, '>')
|
||||
var rendered = md.render(markdown)
|
||||
let rendered = md.render(markdown)
|
||||
rendered = preventXSS(rendered)
|
||||
var result = window.postProcess(rendered)
|
||||
const result = window.postProcess(rendered)
|
||||
section.innerHTML = result[0].outerHTML
|
||||
addAttributes(section, section, null, section.getAttribute('data-element-attributes') ||
|
||||
section.parentNode.getAttribute('data-element-attributes') ||
|
||||
|
|
|
@ -26,7 +26,7 @@ function extend () {
|
|||
|
||||
for (const source of arguments) {
|
||||
for (const key in source) {
|
||||
if (source.hasOwnProperty(key)) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
target[key] = source[key]
|
||||
}
|
||||
}
|
||||
|
@ -36,18 +36,21 @@ function extend () {
|
|||
}
|
||||
|
||||
// Optional libraries used to extend on reveal.js
|
||||
const deps = [{
|
||||
src: `${serverurl}/build/reveal.js/lib/js/classList.js`,
|
||||
condition () {
|
||||
return !document.body.classList
|
||||
const deps = [
|
||||
{
|
||||
src: `${serverurl}/build/reveal.js/lib/js/classList.js`,
|
||||
condition () {
|
||||
return !document.body.classList
|
||||
}
|
||||
},
|
||||
{
|
||||
src: `${serverurl}/build/reveal.js/plugin/notes/notes.js`,
|
||||
async: true,
|
||||
condition () {
|
||||
return !!document.body.classList
|
||||
}
|
||||
}
|
||||
}, {
|
||||
src: `${serverurl}/build/reveal.js/plugin/notes/notes.js`,
|
||||
async: true,
|
||||
condition () {
|
||||
return !!document.body.classList
|
||||
}
|
||||
}]
|
||||
]
|
||||
|
||||
const slideOptions = {
|
||||
separator: '^(\r\n?|\n)---(\r\n?|\n)$',
|
||||
|
@ -73,60 +76,64 @@ const defaultOptions = {
|
|||
// options from yaml meta
|
||||
const meta = JSON.parse($('#meta').text())
|
||||
const metaSlideOptions = !!meta && !!meta.slideOptions ? meta.slideOptions : {}
|
||||
var options = {
|
||||
autoPlayMedia: metaSlideOptions.autoPlayMedia,
|
||||
autoSlide: metaSlideOptions.autoSlide,
|
||||
autoSlideStoppable: metaSlideOptions.autoSlideStoppable,
|
||||
backgroundTransition: metaSlideOptions.backgroundTransition,
|
||||
center: metaSlideOptions.center,
|
||||
controls: metaSlideOptions.controls,
|
||||
controlsBackArrows: metaSlideOptions.controlsBackArrows,
|
||||
controlsLayout: metaSlideOptions.controlsLayout,
|
||||
controlsTutorial: metaSlideOptions.controlsTutorial,
|
||||
defaultTiming: metaSlideOptions.defaultTiming,
|
||||
display: metaSlideOptions.display,
|
||||
embedded: metaSlideOptions.embedded,
|
||||
fragmentInURL: metaSlideOptions.fragmentInURL,
|
||||
fragments: metaSlideOptions.fragments,
|
||||
hash: metaSlideOptions.hash,
|
||||
height: metaSlideOptions.height,
|
||||
help: metaSlideOptions.help,
|
||||
hideAddressBar: metaSlideOptions.hideAddressBar,
|
||||
hideCursorTime: metaSlideOptions.hideCursorTime,
|
||||
hideInactiveCursor: metaSlideOptions.hideInactiveCursor,
|
||||
history: metaSlideOptions.history,
|
||||
keyboard: metaSlideOptions.keyboard,
|
||||
loop: metaSlideOptions.loop,
|
||||
margin: metaSlideOptions.margin,
|
||||
maxScale: metaSlideOptions.maxScale,
|
||||
minScale: metaSlideOptions.minScale,
|
||||
minimumTimePerSlide: metaSlideOptions.minimumTimePerSlide,
|
||||
mobileViewDistance: metaSlideOptions.mobileViewDistance,
|
||||
mouseWheel: metaSlideOptions.mouseWheel,
|
||||
navigationMode: metaSlideOptions.navigationMode,
|
||||
overview: metaSlideOptions.overview,
|
||||
parallaxBackgroundHorizontal: metaSlideOptions.parallaxBackgroundHorizontal,
|
||||
parallaxBackgroundImage: metaSlideOptions.parallaxBackgroundImage,
|
||||
parallaxBackgroundSize: metaSlideOptions.parallaxBackgroundSize,
|
||||
parallaxBackgroundVertical: metaSlideOptions.parallaxBackgroundVertical,
|
||||
preloadIframes: metaSlideOptions.preloadIframes,
|
||||
previewLinks: metaSlideOptions.previewLinks,
|
||||
progress: metaSlideOptions.progress,
|
||||
rtl: metaSlideOptions.rtl,
|
||||
showNotes: metaSlideOptions.showNotes,
|
||||
shuffle: metaSlideOptions.shuffle,
|
||||
slideNumber: metaSlideOptions.slideNumber,
|
||||
theme: metaSlideOptions.theme,
|
||||
totalTime: metaSlideOptions.totalTime,
|
||||
touch: metaSlideOptions.touch,
|
||||
transition: metaSlideOptions.transition,
|
||||
transitionSpeed: metaSlideOptions.transitionSpeed,
|
||||
viewDistance: metaSlideOptions.viewDistance,
|
||||
width: metaSlideOptions.width
|
||||
} || {}
|
||||
let options =
|
||||
{
|
||||
autoPlayMedia: metaSlideOptions.autoPlayMedia,
|
||||
autoSlide: metaSlideOptions.autoSlide,
|
||||
autoSlideStoppable: metaSlideOptions.autoSlideStoppable,
|
||||
backgroundTransition: metaSlideOptions.backgroundTransition,
|
||||
center: metaSlideOptions.center,
|
||||
controls: metaSlideOptions.controls,
|
||||
controlsBackArrows: metaSlideOptions.controlsBackArrows,
|
||||
controlsLayout: metaSlideOptions.controlsLayout,
|
||||
controlsTutorial: metaSlideOptions.controlsTutorial,
|
||||
defaultTiming: metaSlideOptions.defaultTiming,
|
||||
display: metaSlideOptions.display,
|
||||
embedded: metaSlideOptions.embedded,
|
||||
fragmentInURL: metaSlideOptions.fragmentInURL,
|
||||
fragments: metaSlideOptions.fragments,
|
||||
hash: metaSlideOptions.hash,
|
||||
height: metaSlideOptions.height,
|
||||
help: metaSlideOptions.help,
|
||||
hideAddressBar: metaSlideOptions.hideAddressBar,
|
||||
hideCursorTime: metaSlideOptions.hideCursorTime,
|
||||
hideInactiveCursor: metaSlideOptions.hideInactiveCursor,
|
||||
history: metaSlideOptions.history,
|
||||
keyboard: metaSlideOptions.keyboard,
|
||||
loop: metaSlideOptions.loop,
|
||||
margin: metaSlideOptions.margin,
|
||||
maxScale: metaSlideOptions.maxScale,
|
||||
minScale: metaSlideOptions.minScale,
|
||||
minimumTimePerSlide: metaSlideOptions.minimumTimePerSlide,
|
||||
mobileViewDistance: metaSlideOptions.mobileViewDistance,
|
||||
mouseWheel: metaSlideOptions.mouseWheel,
|
||||
navigationMode: metaSlideOptions.navigationMode,
|
||||
overview: metaSlideOptions.overview,
|
||||
parallaxBackgroundHorizontal: metaSlideOptions.parallaxBackgroundHorizontal,
|
||||
parallaxBackgroundImage: metaSlideOptions.parallaxBackgroundImage,
|
||||
parallaxBackgroundSize: metaSlideOptions.parallaxBackgroundSize,
|
||||
parallaxBackgroundVertical: metaSlideOptions.parallaxBackgroundVertical,
|
||||
preloadIframes: metaSlideOptions.preloadIframes,
|
||||
previewLinks: metaSlideOptions.previewLinks,
|
||||
progress: metaSlideOptions.progress,
|
||||
rtl: metaSlideOptions.rtl,
|
||||
showNotes: metaSlideOptions.showNotes,
|
||||
shuffle: metaSlideOptions.shuffle,
|
||||
slideNumber: metaSlideOptions.slideNumber,
|
||||
theme: metaSlideOptions.theme,
|
||||
totalTime: metaSlideOptions.totalTime,
|
||||
touch: metaSlideOptions.touch,
|
||||
transition: metaSlideOptions.transition,
|
||||
transitionSpeed: metaSlideOptions.transitionSpeed,
|
||||
viewDistance: metaSlideOptions.viewDistance,
|
||||
width: metaSlideOptions.width
|
||||
} || {}
|
||||
|
||||
for (const key in options) {
|
||||
if (options.hasOwnProperty(key) && options[key] === undefined) {
|
||||
if (
|
||||
Object.prototype.hasOwnProperty.call(options, key) &&
|
||||
options[key] === undefined
|
||||
) {
|
||||
delete options[key]
|
||||
}
|
||||
}
|
||||
|
@ -165,14 +172,14 @@ window.viewAjaxCallback = () => {
|
|||
function renderSlide (event) {
|
||||
if (window.location.search.match(/print-pdf/gi)) {
|
||||
const slides = $('.slides')
|
||||
let title = document.title
|
||||
const title = document.title
|
||||
finishView(slides)
|
||||
document.title = title
|
||||
Reveal.layout()
|
||||
} else {
|
||||
const markdown = $(event.currentSlide)
|
||||
if (!markdown.attr('data-rendered')) {
|
||||
let title = document.title
|
||||
const title = document.title
|
||||
finishView(markdown)
|
||||
markdown.attr('data-rendered', 'true')
|
||||
document.title = title
|
||||
|
@ -181,7 +188,7 @@ function renderSlide (event) {
|
|||
}
|
||||
}
|
||||
|
||||
Reveal.addEventListener('ready', event => {
|
||||
Reveal.addEventListener('ready', (event) => {
|
||||
renderSlide(event)
|
||||
const markdown = $(event.currentSlide)
|
||||
// force browser redraw
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import base64url from 'base64url'
|
||||
|
||||
let uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
|
||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
|
||||
|
||||
export function checkNoteIdValid (id) {
|
||||
let result = id.match(uuidRegex)
|
||||
const result = id.match(uuidRegex)
|
||||
if (result && result.length === 1) {
|
||||
return true
|
||||
} else {
|
||||
|
@ -13,16 +13,16 @@ export function checkNoteIdValid (id) {
|
|||
|
||||
export function encodeNoteId (id) {
|
||||
// remove dashes in UUID and encode in url-safe base64
|
||||
let str = id.replace(/-/g, '')
|
||||
let hexStr = Buffer.from(str, 'hex')
|
||||
const str = id.replace(/-/g, '')
|
||||
const hexStr = Buffer.from(str, 'hex')
|
||||
return base64url.encode(hexStr)
|
||||
}
|
||||
|
||||
export function decodeNoteId (encodedId) {
|
||||
// decode from url-safe base64
|
||||
let id = base64url.toBuffer(encodedId).toString('hex')
|
||||
const id = base64url.toBuffer(encodedId).toString('hex')
|
||||
// add dashes between the UUID string parts
|
||||
let idParts = []
|
||||
const idParts = []
|
||||
idParts.push(id.substr(0, 8))
|
||||
idParts.push(id.substr(8, 4))
|
||||
idParts.push(id.substr(12, 4))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue