mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 01:21:41 +08:00
Update deps and automatically format style (#1168)
This commit is contained in:
parent
afe688911a
commit
2686cfafe4
19
.eslintrc.js
19
.eslintrc.js
@ -29,15 +29,24 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
// allow paren-less arrow functions
|
// allow paren-less arrow functions
|
||||||
'arrow-parens': 0,
|
'arrow-parens': "off",
|
||||||
// allow async-await
|
// allow async-await
|
||||||
'generator-star-spacing': 0,
|
'generator-star-spacing': "off",
|
||||||
// allow console
|
// allow console
|
||||||
'no-console': 0,
|
'no-console': "off",
|
||||||
// allow debugger during development
|
// allow debugger during development
|
||||||
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
|
'no-debugger': process.env.NODE_ENV === 'production' ? "error" : "off",
|
||||||
|
'no-return-assign': "warn",
|
||||||
|
'no-new': "warn",
|
||||||
// disallow semicolons
|
// disallow semicolons
|
||||||
semi: [2, "never"]
|
semi: [2, "never"],
|
||||||
|
'require-atomic-updates': "off",
|
||||||
|
// TODO: fix these errors someday
|
||||||
|
'prefer-const': "off",
|
||||||
|
'no-new': "off",
|
||||||
|
'no-mixed-operators': "off",
|
||||||
|
'no-prototype-builtins': "off",
|
||||||
|
"no-return-await": "off"
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
'import/resolver': {
|
'import/resolver': {
|
||||||
|
78
package.json
78
package.json
@ -158,35 +158,35 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hfelix/electron-localshortcut": "^3.1.1",
|
"@hfelix/electron-localshortcut": "^3.1.1",
|
||||||
"@octokit/rest": "^16.28.2",
|
"@octokit/rest": "^16.28.5",
|
||||||
"arg": "^4.1.0",
|
"arg": "^4.1.1",
|
||||||
"axios": "^0.19.0",
|
"axios": "^0.19.0",
|
||||||
"chokidar": "^3.0.1",
|
"chokidar": "^3.0.2",
|
||||||
"codemirror": "^5.46.0",
|
"codemirror": "^5.48.2",
|
||||||
"command-exists": "^1.2.8",
|
"command-exists": "^1.2.8",
|
||||||
"dayjs": "^1.8.14",
|
"dayjs": "^1.8.15",
|
||||||
"dom-autoscroller": "^2.3.4",
|
"dom-autoscroller": "^2.3.4",
|
||||||
"dompurify": "^1.0.11",
|
"dompurify": "^1.0.11",
|
||||||
"dragula": "^3.7.2",
|
"dragula": "^3.7.2",
|
||||||
"electron-is-accelerator": "^0.1.2",
|
"electron-is-accelerator": "^0.1.2",
|
||||||
"electron-log": "^3.0.6",
|
"electron-log": "^3.0.6",
|
||||||
"electron-store": "^3.3.0",
|
"electron-store": "^4.0.0",
|
||||||
"electron-window-state": "^5.0.3",
|
"electron-window-state": "^5.0.3",
|
||||||
"element-resize-detector": "^1.2.0",
|
"element-resize-detector": "^1.2.0",
|
||||||
"element-ui": "^2.9.1",
|
"element-ui": "^2.10.1",
|
||||||
"file-icons-js": "^1.0.3",
|
"file-icons-js": "^1.0.3",
|
||||||
"flowchart.js": "^1.12.0",
|
"flowchart.js": "^1.12.1",
|
||||||
"fs-extra": "^8.0.1",
|
"fs-extra": "^8.1.0",
|
||||||
"fuzzaldrin": "^2.1.0",
|
"fuzzaldrin": "^2.1.0",
|
||||||
"github-markdown-css": "^3.0.1",
|
"github-markdown-css": "^3.0.1",
|
||||||
"html-tags": "^3.0.0",
|
"html-tags": "^3.0.0",
|
||||||
"katex": "^0.10.2",
|
"katex": "^0.10.2",
|
||||||
"keyboard-layout": "^2.0.16",
|
"keyboard-layout": "^2.0.16",
|
||||||
"keytar": "^4.10.0",
|
"keytar": "^4.12.0",
|
||||||
"mermaid": "^8.0.0",
|
"mermaid": "^8.0.0",
|
||||||
"plist": "^3.0.1",
|
"plist": "^3.0.1",
|
||||||
"popper.js": "^1.15.0",
|
"popper.js": "^1.15.0",
|
||||||
"prismjs": "^1.16.0",
|
"prismjs": "^1.17.1",
|
||||||
"snabbdom": "^0.7.3",
|
"snabbdom": "^0.7.3",
|
||||||
"snabbdom-to-html": "^5.1.1",
|
"snabbdom-to-html": "^5.1.1",
|
||||||
"source-map-support": "^0.5.12",
|
"source-map-support": "^0.5.12",
|
||||||
@ -194,19 +194,19 @@
|
|||||||
"turndown-plugin-gfm": "^1.0.2",
|
"turndown-plugin-gfm": "^1.0.2",
|
||||||
"underscore": "^1.9.1",
|
"underscore": "^1.9.1",
|
||||||
"vega": "^5.4.0",
|
"vega": "^5.4.0",
|
||||||
"vega-embed": "^4.2.0",
|
"vega-embed": "^4.2.1",
|
||||||
"vega-lite": "^3.3.0",
|
"vega-lite": "^3.3.0",
|
||||||
"view-image": "^0.0.1",
|
"view-image": "^0.0.1",
|
||||||
"vscode-ripgrep": "^1.2.5",
|
"vscode-ripgrep": "^1.5.5",
|
||||||
"vue": "^2.6.10",
|
"vue": "^2.6.10",
|
||||||
"vue-electron": "^1.0.6",
|
"vue-electron": "^1.0.6",
|
||||||
"vue-router": "^3.0.6",
|
"vue-router": "^3.0.7",
|
||||||
"vuex": "^3.1.1"
|
"vuex": "^3.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@markedjs/html-differ": "^2.0.1",
|
"@markedjs/html-differ": "^2.0.1",
|
||||||
"babel-core": "^6.26.3",
|
"babel-core": "^6.26.3",
|
||||||
"babel-eslint": "^10.0.1",
|
"babel-eslint": "^10.0.2",
|
||||||
"babel-loader": "^7.1.5",
|
"babel-loader": "^7.1.5",
|
||||||
"babel-plugin-component": "^1.1.1",
|
"babel-plugin-component": "^1.1.1",
|
||||||
"babel-plugin-istanbul": "^5.1.1",
|
"babel-plugin-istanbul": "^5.1.1",
|
||||||
@ -224,24 +224,24 @@
|
|||||||
"del": "^4.1.1",
|
"del": "^4.1.1",
|
||||||
"devtron": "^1.4.0",
|
"devtron": "^1.4.0",
|
||||||
"dotenv": "^8.0.0",
|
"dotenv": "^8.0.0",
|
||||||
"electron": "^5.0.4",
|
"electron": "^5.0.7",
|
||||||
"electron-builder": "^20.40.2",
|
"electron-builder": "^21.1.1",
|
||||||
"electron-devtools-installer": "^2.2.4",
|
"electron-devtools-installer": "^2.2.4",
|
||||||
"electron-rebuild": "^1.8.4",
|
"electron-rebuild": "^1.8.5",
|
||||||
"electron-updater": "^4.0.6",
|
"electron-updater": "^4.1.2",
|
||||||
"eslint": "^5.16.0",
|
"eslint": "^6.1.0",
|
||||||
"eslint-config-standard": "^12.0.0",
|
"eslint-config-standard": "^13.0.1",
|
||||||
"eslint-friendly-formatter": "^4.0.1",
|
"eslint-friendly-formatter": "^4.0.1",
|
||||||
"eslint-import-resolver-alias": "^1.1.2",
|
"eslint-import-resolver-alias": "^1.1.2",
|
||||||
"eslint-loader": "^2.1.2",
|
"eslint-loader": "^2.2.1",
|
||||||
"eslint-plugin-html": "^5.0.4",
|
"eslint-plugin-html": "^6.0.0",
|
||||||
"eslint-plugin-import": "^2.17.2",
|
"eslint-plugin-import": "^2.18.2",
|
||||||
"eslint-plugin-node": "^9.0.1",
|
"eslint-plugin-node": "^9.1.0",
|
||||||
"eslint-plugin-promise": "^4.1.1",
|
"eslint-plugin-promise": "^4.2.1",
|
||||||
"eslint-plugin-standard": "^4.0.0",
|
"eslint-plugin-standard": "^4.0.0",
|
||||||
"eslint-plugin-vue": "^5.2.2",
|
"eslint-plugin-vue": "^5.2.3",
|
||||||
"esm": "^3.2.22",
|
"esm": "^3.2.25",
|
||||||
"file-loader": "^3.0.1",
|
"file-loader": "^4.1.0",
|
||||||
"git-revision-webpack-plugin": "^3.0.3",
|
"git-revision-webpack-plugin": "^3.0.3",
|
||||||
"html-webpack-plugin": "^3.2.0",
|
"html-webpack-plugin": "^3.2.0",
|
||||||
"inject-loader": "^4.0.1",
|
"inject-loader": "^4.0.1",
|
||||||
@ -254,30 +254,30 @@
|
|||||||
"karma-spec-reporter": "0.0.32",
|
"karma-spec-reporter": "0.0.32",
|
||||||
"karma-webpack": "^3.0.5",
|
"karma-webpack": "^3.0.5",
|
||||||
"license-checker": "^25.0.1",
|
"license-checker": "^25.0.1",
|
||||||
"marked": "^0.6.2",
|
"marked": "^0.7.0",
|
||||||
"mini-css-extract-plugin": "^0.6.0",
|
"mini-css-extract-plugin": "^0.8.0",
|
||||||
"mocha": "^6.1.4",
|
"mocha": "^6.2.0",
|
||||||
"multispinner": "^0.2.1",
|
"multispinner": "^0.2.1",
|
||||||
"node-fetch": "^2.5.0",
|
"node-fetch": "^2.6.0",
|
||||||
"node-loader": "^0.6.0",
|
"node-loader": "^0.6.0",
|
||||||
"postcss-loader": "^3.0.0",
|
"postcss-loader": "^3.0.0",
|
||||||
"postcss-preset-env": "^6.6.0",
|
"postcss-preset-env": "^6.6.0",
|
||||||
"raw-loader": "^2.0.0",
|
"raw-loader": "^2.0.0",
|
||||||
"require-dir": "^1.2.0",
|
"require-dir": "^1.2.0",
|
||||||
"spectron": "^5.0.0",
|
"spectron": "^7.0.0",
|
||||||
"style-loader": "^0.23.1",
|
"style-loader": "^0.23.1",
|
||||||
"svg-sprite-loader": "^4.1.6",
|
"svg-sprite-loader": "^4.1.6",
|
||||||
"svgo": "^1.2.2",
|
"svgo": "^1.3.0",
|
||||||
"svgo-loader": "^2.2.0",
|
"svgo-loader": "^2.2.1",
|
||||||
"to-string-loader": "^1.1.5",
|
"to-string-loader": "^1.1.5",
|
||||||
"url-loader": "^1.1.2",
|
"url-loader": "^1.1.2",
|
||||||
"vue-html-loader": "^1.2.4",
|
"vue-html-loader": "^1.2.4",
|
||||||
"vue-loader": "^15.7.0",
|
"vue-loader": "^15.7.1",
|
||||||
"vue-style-loader": "^4.1.2",
|
"vue-style-loader": "^4.1.2",
|
||||||
"vue-template-compiler": "^2.6.10",
|
"vue-template-compiler": "^2.6.10",
|
||||||
"webpack": "^4.31.0",
|
"webpack": "^4.36.1",
|
||||||
"webpack-bundle-analyzer": "^3.3.2",
|
"webpack-bundle-analyzer": "^3.3.2",
|
||||||
"webpack-cli": "^3.3.2",
|
"webpack-cli": "^3.3.6",
|
||||||
"webpack-dev-server": "^3.7.2",
|
"webpack-dev-server": "^3.7.2",
|
||||||
"webpack-hot-middleware": "^2.25.0",
|
"webpack-hot-middleware": "^2.25.0",
|
||||||
"webpack-merge": "^4.2.1"
|
"webpack-merge": "^4.2.1"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
class EnvPaths {
|
class EnvPaths {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} userDataPath The user data path.
|
* @param {string} userDataPath The user data path.
|
||||||
* @returns
|
* @returns
|
||||||
|
@ -11,7 +11,7 @@ export const exists = async p => {
|
|||||||
try {
|
try {
|
||||||
await fs.access(p)
|
await fs.access(p)
|
||||||
return true
|
return true
|
||||||
} catch(_) {
|
} catch (_) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,6 @@ export const isMarkdownFile = filepath => {
|
|||||||
return isFile(filepath) && hasMarkdownExtension(filepath)
|
return isFile(filepath) && hasMarkdownExtension(filepath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the path is a markdown file or symbolic link to a markdown file.
|
* Returns true if the path is a markdown file or symbolic link to a markdown file.
|
||||||
*
|
*
|
||||||
|
@ -5,11 +5,10 @@ import Keybindings from '../keyboard/shortcutHandler'
|
|||||||
import AppMenu from '../menu'
|
import AppMenu from '../menu'
|
||||||
|
|
||||||
class Accessor {
|
class Accessor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {AppEnvironment} appEnvironment The application environment instance.
|
* @param {AppEnvironment} appEnvironment The application environment instance.
|
||||||
*/
|
*/
|
||||||
constructor(appEnvironment) {
|
constructor (appEnvironment) {
|
||||||
const userDataPath = appEnvironment.paths.userDataPath
|
const userDataPath = appEnvironment.paths.userDataPath
|
||||||
|
|
||||||
this.env = appEnvironment
|
this.env = appEnvironment
|
||||||
|
@ -10,7 +10,6 @@ const patchEnvPath = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class AppEnvironment {
|
export class AppEnvironment {
|
||||||
|
|
||||||
constructor (options) {
|
constructor (options) {
|
||||||
this._id = envId++
|
this._id = envId++
|
||||||
this._appPaths = new AppPaths(options.userDataPath)
|
this._appPaths = new AppPaths(options.userDataPath)
|
||||||
@ -24,7 +23,7 @@ export class AppEnvironment {
|
|||||||
*
|
*
|
||||||
* @returns {number} Returns an unique identifier.
|
* @returns {number} Returns an unique identifier.
|
||||||
*/
|
*/
|
||||||
get id() {
|
get id () {
|
||||||
return this._id
|
return this._id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,14 +17,13 @@ import EditorWindow from '../windows/editor'
|
|||||||
import SettingWindow from '../windows/setting'
|
import SettingWindow from '../windows/setting'
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Accessor} accessor The application accessor for application instances.
|
* @param {Accessor} accessor The application accessor for application instances.
|
||||||
* @param {arg.Result} args Parsed application arguments.
|
* @param {arg.Result} args Parsed application arguments.
|
||||||
*/
|
*/
|
||||||
constructor (accessor, args) {
|
constructor (accessor, args) {
|
||||||
this._accessor = accessor
|
this._accessor = accessor
|
||||||
this._args = args || {_: []}
|
this._args = args || { _: [] }
|
||||||
this._openFilesCache = []
|
this._openFilesCache = []
|
||||||
this._openFilesTimer = null
|
this._openFilesTimer = null
|
||||||
this._windowManager = this._accessor.windowManager
|
this._windowManager = this._accessor.windowManager
|
||||||
@ -271,7 +270,7 @@ class App {
|
|||||||
* @param {boolean} openFilesInSameWindow Open all files in the same window with
|
* @param {boolean} openFilesInSameWindow Open all files in the same window with
|
||||||
* the first directory and discard other directories.
|
* the first directory and discard other directories.
|
||||||
*/
|
*/
|
||||||
_openPathList (pathsToOpen, openFilesInSameWindow=false) {
|
_openPathList (pathsToOpen, openFilesInSameWindow = false) {
|
||||||
const { _windowManager } = this
|
const { _windowManager } = this
|
||||||
const openFilesInNewWindow = this._accessor.preferences.getItem('openFilesInNewWindow')
|
const openFilesInNewWindow = this._accessor.preferences.getItem('openFilesInNewWindow')
|
||||||
|
|
||||||
@ -372,12 +371,11 @@ class App {
|
|||||||
const { rootDirectory, fileList } = item
|
const { rootDirectory, fileList } = item
|
||||||
this._createEditorWindow(rootDirectory, fileList)
|
this._createEditorWindow(rootDirectory, fileList)
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
// Open each file and directory in a new window.
|
// Open each file and directory in a new window.
|
||||||
else {
|
|
||||||
for (const pathname of filesToOpen) {
|
for (const pathname of filesToOpen) {
|
||||||
this._createEditorWindow(null, [ pathname ])
|
this._createEditorWindow(null, [pathname])
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const item of directoriesToOpen) {
|
for (const item of directoriesToOpen) {
|
||||||
@ -441,7 +439,7 @@ class App {
|
|||||||
ipcMain.on('app-open-file-by-id', (windowId, filePath) => {
|
ipcMain.on('app-open-file-by-id', (windowId, filePath) => {
|
||||||
const openFilesInNewWindow = this._accessor.preferences.getItem('openFilesInNewWindow')
|
const openFilesInNewWindow = this._accessor.preferences.getItem('openFilesInNewWindow')
|
||||||
if (openFilesInNewWindow) {
|
if (openFilesInNewWindow) {
|
||||||
this._createEditorWindow(null, [ filePath ])
|
this._createEditorWindow(null, [filePath])
|
||||||
} else {
|
} else {
|
||||||
const editor = this._windowManager.get(windowId)
|
const editor = this._windowManager.get(windowId)
|
||||||
if (editor) {
|
if (editor) {
|
||||||
@ -467,7 +465,7 @@ class App {
|
|||||||
ipcMain.on('app-open-markdown-by-id', (windowId, data) => {
|
ipcMain.on('app-open-markdown-by-id', (windowId, data) => {
|
||||||
const openFilesInNewWindow = this._accessor.preferences.getItem('openFilesInNewWindow')
|
const openFilesInNewWindow = this._accessor.preferences.getItem('openFilesInNewWindow')
|
||||||
if (openFilesInNewWindow) {
|
if (openFilesInNewWindow) {
|
||||||
this._createEditorWindow(null, [], [ data ])
|
this._createEditorWindow(null, [], [data])
|
||||||
} else {
|
} else {
|
||||||
const editor = this._windowManager.get(windowId)
|
const editor = this._windowManager.get(windowId)
|
||||||
if (editor) {
|
if (editor) {
|
||||||
@ -504,6 +502,7 @@ class App {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('mt::open-setting-window', () => {
|
ipcMain.on('mt::open-setting-window', () => {
|
||||||
ipcMain.emit('app-create-settings-window')
|
ipcMain.emit('app-create-settings-window')
|
||||||
})
|
})
|
||||||
|
@ -3,7 +3,6 @@ import EnvPaths from 'common/envPaths'
|
|||||||
import { ensureDirSync } from 'common/filesystem'
|
import { ensureDirSync } from 'common/filesystem'
|
||||||
|
|
||||||
class AppPaths extends EnvPaths {
|
class AppPaths extends EnvPaths {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure and sets all application paths.
|
* Configure and sets all application paths.
|
||||||
*
|
*
|
||||||
|
@ -5,7 +5,7 @@ import Watcher, { WATCHER_STABILITY_THRESHOLD, WATCHER_STABILITY_POLL_INTERVAL }
|
|||||||
import { WindowType } from '../windows/base'
|
import { WindowType } from '../windows/base'
|
||||||
|
|
||||||
class WindowActivityList {
|
class WindowActivityList {
|
||||||
constructor() {
|
constructor () {
|
||||||
// Oldest Newest
|
// Oldest Newest
|
||||||
// <number>, ... , <number>
|
// <number>, ... , <number>
|
||||||
this._buf = []
|
this._buf = []
|
||||||
@ -51,13 +51,12 @@ class WindowActivityList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class WindowManager extends EventEmitter {
|
class WindowManager extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {AppMenu} appMenu The application menu instance.
|
* @param {AppMenu} appMenu The application menu instance.
|
||||||
* @param {Preference} preferences The preference instance.
|
* @param {Preference} preferences The preference instance.
|
||||||
*/
|
*/
|
||||||
constructor(appMenu, preferences) {
|
constructor (appMenu, preferences) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
this._appMenu = appMenu
|
this._appMenu = appMenu
|
||||||
@ -137,7 +136,7 @@ class WindowManager extends EventEmitter {
|
|||||||
window.removeAllListeners('window-focus')
|
window.removeAllListeners('window-focus')
|
||||||
|
|
||||||
this._windowActivity.delete(windowId)
|
this._windowActivity.delete(windowId)
|
||||||
let nextWindowId = this._windowActivity.getNewest()
|
const nextWindowId = this._windowActivity.getNewest()
|
||||||
this.setActiveWindow(nextWindowId)
|
this.setActiveWindow(nextWindowId)
|
||||||
|
|
||||||
_windows.delete(windowId)
|
_windows.delete(windowId)
|
||||||
@ -232,7 +231,7 @@ class WindowManager extends EventEmitter {
|
|||||||
const lastActiveEditorId = this.getActiveEditorId() // editor id or null
|
const lastActiveEditorId = this.getActiveEditorId() // editor id or null
|
||||||
|
|
||||||
if (this.windowCount <= 1) {
|
if (this.windowCount <= 1) {
|
||||||
return [ { windowId: lastActiveEditorId, fileList } ]
|
return [{ windowId: lastActiveEditorId, fileList }]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Array of scores, same order like fileList.
|
// Array of scores, same order like fileList.
|
||||||
|
@ -12,7 +12,7 @@ const cli = () => {
|
|||||||
let argv = process.argv.slice(1)
|
let argv = process.argv.slice(1)
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
// Don't pass electron development arguments to Mark Text and change user data path.
|
// Don't pass electron development arguments to Mark Text and change user data path.
|
||||||
argv = [ '--user-data-dir', path.join(getPath('appData'), 'marktext-dev') ]
|
argv = ['--user-data-dir', path.join(getPath('appData'), 'marktext-dev')]
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = parseArgs(argv, true)
|
const args = parseArgs(argv, true)
|
||||||
|
@ -21,7 +21,7 @@ export const defaultPreferenceWinOptions = {
|
|||||||
height: 650,
|
height: 650,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
webSecurity: false,
|
webSecurity: false
|
||||||
},
|
},
|
||||||
fullscreenable: false,
|
fullscreenable: false,
|
||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
|
@ -171,21 +171,21 @@ class DataCenter extends EventEmitter {
|
|||||||
ipcMain.on('mt::ask-for-modify-image-folder-path', e => {
|
ipcMain.on('mt::ask-for-modify-image-folder-path', e => {
|
||||||
const win = BrowserWindow.fromWebContents(e.sender)
|
const win = BrowserWindow.fromWebContents(e.sender)
|
||||||
const folder = dialog.showOpenDialog(win, {
|
const folder = dialog.showOpenDialog(win, {
|
||||||
properties: [ 'openDirectory', 'createDirectory' ]
|
properties: ['openDirectory', 'createDirectory']
|
||||||
})
|
})
|
||||||
if (folder && folder[0]) {
|
if (folder && folder[0]) {
|
||||||
this.setItem('imageFolderPath', folder[0])
|
this.setItem('imageFolderPath', folder[0])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('mt::set-user-data', (e, userData) =>{
|
ipcMain.on('mt::set-user-data', (e, userData) => {
|
||||||
this.setItems(userData)
|
this.setItems(userData)
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('mt::ask-for-image-path', e => {
|
ipcMain.on('mt::ask-for-image-path', e => {
|
||||||
const win = BrowserWindow.fromWebContents(e.sender)
|
const win = BrowserWindow.fromWebContents(e.sender)
|
||||||
const files = dialog.showOpenDialog(win, {
|
const files = dialog.showOpenDialog(win, {
|
||||||
properties: [ 'openFile' ],
|
properties: ['openFile'],
|
||||||
filters: [{
|
filters: [{
|
||||||
name: 'Images',
|
name: 'Images',
|
||||||
extensions: IMAGE_EXTENSIONS
|
extensions: IMAGE_EXTENSIONS
|
||||||
|
@ -24,7 +24,7 @@ export const normalizeAndResolvePath = pathname => {
|
|||||||
|
|
||||||
export const writeFile = (pathname, content, extension) => {
|
export const writeFile = (pathname, content, extension) => {
|
||||||
if (!pathname) {
|
if (!pathname) {
|
||||||
return Promise.reject('[ERROR] Cannot save file without path.')
|
return Promise.reject(new Error('[ERROR] Cannot save file without path.'))
|
||||||
}
|
}
|
||||||
pathname = !extension || pathname.endsWith(extension) ? pathname : `${pathname}${extension}`
|
pathname = !extension || pathname.endsWith(extension) ? pathname : `${pathname}${extension}`
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ const add = async (win, pathname, type, endOfLine) => {
|
|||||||
try {
|
try {
|
||||||
const data = await loadMarkdownFile(pathname, endOfLine)
|
const data = await loadMarkdownFile(pathname, endOfLine)
|
||||||
file.data = data
|
file.data = data
|
||||||
} catch(err) {
|
} catch (err) {
|
||||||
// Only notify user about opened files.
|
// Only notify user about opened files.
|
||||||
if (type === 'file') {
|
if (type === 'file') {
|
||||||
win.webContents.send('AGANI::show-notification', {
|
win.webContents.send('AGANI::show-notification', {
|
||||||
@ -124,7 +124,6 @@ const unlinkDir = (win, pathname, type) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Watcher {
|
class Watcher {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Preference} preferences The preference instance.
|
* @param {Preference} preferences The preference instance.
|
||||||
*/
|
*/
|
||||||
@ -306,7 +305,7 @@ class Watcher {
|
|||||||
* @param {string} pathname The path to ignore.
|
* @param {string} pathname The path to ignore.
|
||||||
* @param {number} [duration] The duration in ms to ignore the changed event.
|
* @param {number} [duration] The duration in ms to ignore the changed event.
|
||||||
*/
|
*/
|
||||||
ignoreChangedEvent (windowId, pathname, duration=WATCHER_STABILITY_THRESHOLD + WATCHER_STABILITY_POLL_INTERVAL + 1000) {
|
ignoreChangedEvent (windowId, pathname, duration = WATCHER_STABILITY_THRESHOLD + WATCHER_STABILITY_POLL_INTERVAL + 1000) {
|
||||||
this._ignoreChangeEvents.push({ windowId, pathname, duration, start: new Date() })
|
this._ignoreChangeEvents.push({ windowId, pathname, duration, start: new Date() })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ export const getVirtualLetters = () => {
|
|||||||
// Full list of supported virtual keys:
|
// Full list of supported virtual keys:
|
||||||
// https://github.com/parro-it/keyboardevent-from-electron-accelerator/blob/afdbd57bead1e139d7bd03c763778dce6ca8c35d/main.js#L104
|
// https://github.com/parro-it/keyboardevent-from-electron-accelerator/blob/afdbd57bead1e139d7bd03c763778dce6ca8c35d/main.js#L104
|
||||||
const currentKeymap = getCurrentKeymap()
|
const currentKeymap = getCurrentKeymap()
|
||||||
let vkeys = {}
|
const vkeys = {}
|
||||||
for (const key in currentKeymap) {
|
for (const key in currentKeymap) {
|
||||||
// TODO(fxha): Possibly, we can fix more broken accelerators without apply a manually fix later.
|
// TODO(fxha): Possibly, we can fix more broken accelerators without apply a manually fix later.
|
||||||
if (!key.startsWith('Key')) {
|
if (!key.startsWith('Key')) {
|
||||||
|
@ -14,7 +14,6 @@ import { getKeyboardLanguage, getVirtualLetters } from '../keyboard'
|
|||||||
// Upgrade Heading: Ctrl+= -> points to Ctrl+Plus which is ok; Ctrl+Plus is broken
|
// Upgrade Heading: Ctrl+= -> points to Ctrl+Plus which is ok; Ctrl+Plus is broken
|
||||||
|
|
||||||
class Keybindings {
|
class Keybindings {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} userDataPath The user data path.
|
* @param {string} userDataPath The user data path.
|
||||||
*/
|
*/
|
||||||
@ -282,7 +281,7 @@ class Keybindings {
|
|||||||
|
|
||||||
export const parseMenu = menuTemplate => {
|
export const parseMenu = menuTemplate => {
|
||||||
const { submenu, accelerator, click, id, visible } = menuTemplate
|
const { submenu, accelerator, click, id, visible } = menuTemplate
|
||||||
let items = []
|
const items = []
|
||||||
if (Array.isArray(menuTemplate)) {
|
if (Array.isArray(menuTemplate)) {
|
||||||
for (const item of menuTemplate) {
|
for (const item of menuTemplate) {
|
||||||
const subitems = parseMenu(item)
|
const subitems = parseMenu(item)
|
||||||
|
@ -398,7 +398,7 @@ export const importFile = async win => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dialog.showOpenDialog(win, {
|
dialog.showOpenDialog(win, {
|
||||||
properties: [ 'openFile' ],
|
properties: ['openFile'],
|
||||||
filters: [{
|
filters: [{
|
||||||
name: 'All Files',
|
name: 'All Files',
|
||||||
extensions: PANDOC_EXTENSIONS
|
extensions: PANDOC_EXTENSIONS
|
||||||
|
@ -2,13 +2,13 @@ import { ipcMain } from 'electron'
|
|||||||
import { getMenuItemById } from '../../menu'
|
import { getMenuItemById } from '../../menu'
|
||||||
|
|
||||||
const MENU_ID_FORMAT_MAP = {
|
const MENU_ID_FORMAT_MAP = {
|
||||||
'strongMenuItem': 'strong',
|
strongMenuItem: 'strong',
|
||||||
'emphasisMenuItem': 'em',
|
emphasisMenuItem: 'em',
|
||||||
'inlineCodeMenuItem': 'inline_code',
|
inlineCodeMenuItem: 'inline_code',
|
||||||
'strikeMenuItem': 'del',
|
strikeMenuItem: 'del',
|
||||||
'hyperlinkMenuItem': 'link',
|
hyperlinkMenuItem: 'link',
|
||||||
'imageMenuItem': 'image',
|
imageMenuItem: 'image',
|
||||||
'mathMenuItem': 'inline_math'
|
mathMenuItem: 'inline_math'
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectFormat = formats => {
|
const selectFormat = formats => {
|
||||||
|
@ -12,21 +12,21 @@ const DISABLE_LABELS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
const MENU_ID_MAP = {
|
const MENU_ID_MAP = {
|
||||||
'heading1MenuItem': 'h1',
|
heading1MenuItem: 'h1',
|
||||||
'heading2MenuItem': 'h2',
|
heading2MenuItem: 'h2',
|
||||||
'heading3MenuItem': 'h3',
|
heading3MenuItem: 'h3',
|
||||||
'heading4MenuItem': 'h4',
|
heading4MenuItem: 'h4',
|
||||||
'heading5MenuItem': 'h5',
|
heading5MenuItem: 'h5',
|
||||||
'heading6MenuItem': 'h6',
|
heading6MenuItem: 'h6',
|
||||||
'tableMenuItem': 'figure',
|
tableMenuItem: 'figure',
|
||||||
'codeFencesMenuItem': 'pre',
|
codeFencesMenuItem: 'pre',
|
||||||
'quoteBlockMenuItem': 'blockquote',
|
quoteBlockMenuItem: 'blockquote',
|
||||||
'orderListMenuItem': 'ol',
|
orderListMenuItem: 'ol',
|
||||||
'bulletListMenuItem': 'ul',
|
bulletListMenuItem: 'ul',
|
||||||
'taskListMenuItem': 'ul',
|
taskListMenuItem: 'ul',
|
||||||
'paragraphMenuItem': 'p',
|
paragraphMenuItem: 'p',
|
||||||
'horizontalLineMenuItem': 'hr',
|
horizontalLineMenuItem: 'hr',
|
||||||
'frontMatterMenuItem': 'pre'
|
frontMatterMenuItem: 'pre'
|
||||||
}
|
}
|
||||||
|
|
||||||
const setParagraphMenuItemStatus = bool => {
|
const setParagraphMenuItemStatus = bool => {
|
||||||
|
@ -14,7 +14,6 @@ export const MenuType = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AppMenu {
|
class AppMenu {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Preference} preferences The preferences instances.
|
* @param {Preference} preferences The preferences instances.
|
||||||
* @param {Keybindings} keybindings The keybindings instances.
|
* @param {Keybindings} keybindings The keybindings instances.
|
||||||
@ -43,7 +42,7 @@ class AppMenu {
|
|||||||
if (isOsxOrWindows) app.addRecentDocument(filePath)
|
if (isOsxOrWindows) app.addRecentDocument(filePath)
|
||||||
if (isOsx) return
|
if (isOsx) return
|
||||||
|
|
||||||
let recentDocuments = this.getRecentlyUsedDocuments()
|
const recentDocuments = this.getRecentlyUsedDocuments()
|
||||||
const index = recentDocuments.indexOf(filePath)
|
const index = recentDocuments.indexOf(filePath)
|
||||||
let needSave = index !== 0
|
let needSave = index !== 0
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
@ -74,7 +73,7 @@ class AppMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let recentDocuments = JSON.parse(fs.readFileSync(RECENTS_PATH, 'utf-8'))
|
const recentDocuments = JSON.parse(fs.readFileSync(RECENTS_PATH, 'utf-8'))
|
||||||
.filter(f => f && (isFile(f) || isDirectory(f)))
|
.filter(f => f && (isFile(f) || isDirectory(f)))
|
||||||
|
|
||||||
if (recentDocuments.length > MAX_RECENTLY_USED_DOCUMENTS) {
|
if (recentDocuments.length > MAX_RECENTLY_USED_DOCUMENTS) {
|
||||||
|
@ -6,7 +6,7 @@ import { isOsx } from '../../config'
|
|||||||
|
|
||||||
export default function (keybindings, userPreference, recentlyUsedFiles) {
|
export default function (keybindings, userPreference, recentlyUsedFiles) {
|
||||||
const { autoSave } = userPreference.getAll()
|
const { autoSave } = userPreference.getAll()
|
||||||
let fileMenu = {
|
const fileMenu = {
|
||||||
label: 'File',
|
label: 'File',
|
||||||
submenu: [{
|
submenu: [{
|
||||||
label: 'New Tab',
|
label: 'New Tab',
|
||||||
@ -39,7 +39,7 @@ export default function (keybindings, userPreference, recentlyUsedFiles) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isOsx) {
|
if (!isOsx) {
|
||||||
let recentlyUsedMenu = {
|
const recentlyUsedMenu = {
|
||||||
label: 'Open Recent',
|
label: 'Open Recent',
|
||||||
submenu: []
|
submenu: []
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ export default function (keybindings, userPreference, recentlyUsedFiles) {
|
|||||||
userSetting(menuItem, browserWindow)
|
userSetting(menuItem, browserWindow)
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
type: 'separator',
|
type: 'separator'
|
||||||
}, {
|
}, {
|
||||||
label: 'Close Tab',
|
label: 'Close Tab',
|
||||||
accelerator: keybindings.getAccelerator('fileCloseTab'),
|
accelerator: keybindings.getAccelerator('fileCloseTab'),
|
||||||
|
@ -18,7 +18,7 @@ export dockMenu from './dock'
|
|||||||
*/
|
*/
|
||||||
export const configSettingMenu = (keybindings) => {
|
export const configSettingMenu = (keybindings) => {
|
||||||
return [
|
return [
|
||||||
...(process.platform === 'darwin' ? [ marktext(keybindings) ] : []),
|
...(process.platform === 'darwin' ? [marktext(keybindings)] : []),
|
||||||
prefEdit(keybindings),
|
prefEdit(keybindings),
|
||||||
help()
|
help()
|
||||||
]
|
]
|
||||||
@ -33,7 +33,7 @@ export const configSettingMenu = (keybindings) => {
|
|||||||
*/
|
*/
|
||||||
export default function (keybindings, preferences, recentlyUsedFiles) {
|
export default function (keybindings, preferences, recentlyUsedFiles) {
|
||||||
return [
|
return [
|
||||||
...(process.platform === 'darwin' ? [ marktext(keybindings) ] : []),
|
...(process.platform === 'darwin' ? [marktext(keybindings)] : []),
|
||||||
file(keybindings, preferences, recentlyUsedFiles),
|
file(keybindings, preferences, recentlyUsedFiles),
|
||||||
edit(keybindings, preferences),
|
edit(keybindings, preferences),
|
||||||
paragraph(keybindings),
|
paragraph(keybindings),
|
||||||
|
@ -2,7 +2,7 @@ import { ipcMain } from 'electron'
|
|||||||
import * as actions from '../actions/view'
|
import * as actions from '../actions/view'
|
||||||
|
|
||||||
export default function (keybindings) {
|
export default function (keybindings) {
|
||||||
let viewMenu = {
|
const viewMenu = {
|
||||||
label: 'View',
|
label: 'View',
|
||||||
submenu: [{
|
submenu: [{
|
||||||
id: 'sourceCodeModeMenuItem',
|
id: 'sourceCodeModeMenuItem',
|
||||||
|
@ -24,7 +24,6 @@ const isDarkSystemMode = () => {
|
|||||||
const PREFERENCES_FILE_NAME = 'preferences'
|
const PREFERENCES_FILE_NAME = 'preferences'
|
||||||
|
|
||||||
class Preference extends EventEmitter {
|
class Preference extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {AppPaths} userDataPath The path instance.
|
* @param {AppPaths} userDataPath The path instance.
|
||||||
*
|
*
|
||||||
|
@ -11,7 +11,7 @@ export const getUniqueId = () => {
|
|||||||
export const getRecommendTitleFromMarkdownString = markdown => {
|
export const getRecommendTitleFromMarkdownString = markdown => {
|
||||||
const tokens = markdown.match(/#{1,6} {1,}(.+)(?:\n|$)/g)
|
const tokens = markdown.match(/#{1,6} {1,}(.+)(?:\n|$)/g)
|
||||||
if (!tokens) return ''
|
if (!tokens) return ''
|
||||||
let headers = tokens.map(t => {
|
const headers = tokens.map(t => {
|
||||||
const matches = t.trim().match(/(#{1,6}) {1,}(.+)/)
|
const matches = t.trim().match(/(#{1,6}) {1,}(.+)/)
|
||||||
return {
|
return {
|
||||||
level: matches[1].length,
|
level: matches[1].length,
|
||||||
|
@ -25,7 +25,6 @@ export const WindowLifecycle = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BaseWindow extends EventEmitter {
|
class BaseWindow extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Accessor} accessor The application accessor for application instances.
|
* @param {Accessor} accessor The application accessor for application instances.
|
||||||
*/
|
*/
|
||||||
|
@ -9,7 +9,6 @@ import { TITLE_BAR_HEIGHT, editorWinOptions, isLinux, isOsx } from '../config'
|
|||||||
import { loadMarkdownFile } from '../filesystem/markdown'
|
import { loadMarkdownFile } from '../filesystem/markdown'
|
||||||
|
|
||||||
class EditorWindow extends BaseWindow {
|
class EditorWindow extends BaseWindow {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Accessor} accessor The application accessor for application instances.
|
* @param {Accessor} accessor The application accessor for application instances.
|
||||||
*/
|
*/
|
||||||
@ -195,7 +194,7 @@ class EditorWindow extends BaseWindow {
|
|||||||
openTabsFromPaths (filePaths) {
|
openTabsFromPaths (filePaths) {
|
||||||
if (!filePaths || filePaths.length === 0) return
|
if (!filePaths || filePaths.length === 0) return
|
||||||
|
|
||||||
const fileList = filePaths.map(p => ({filePath: p, options: {}, selected: false}))
|
const fileList = filePaths.map(p => ({ filePath: p, options: {}, selected: false }))
|
||||||
fileList[0].selected = true
|
fileList[0].selected = true
|
||||||
this.openTabs(fileList)
|
this.openTabs(fileList)
|
||||||
}
|
}
|
||||||
@ -237,7 +236,7 @@ class EditorWindow extends BaseWindow {
|
|||||||
* @param {[boolean]} selected Whether the tab should become the selected tab (true if not set).
|
* @param {[boolean]} selected Whether the tab should become the selected tab (true if not set).
|
||||||
* @param {[string]} markdown The markdown string.
|
* @param {[string]} markdown The markdown string.
|
||||||
*/
|
*/
|
||||||
openUntitledTab (selected=true, markdown='') {
|
openUntitledTab (selected = true, markdown = '') {
|
||||||
if (this.lifecycle === WindowLifecycle.QUITTED) return
|
if (this.lifecycle === WindowLifecycle.QUITTED) return
|
||||||
|
|
||||||
if (this.lifecycle === WindowLifecycle.READY) {
|
if (this.lifecycle === WindowLifecycle.READY) {
|
||||||
|
@ -6,7 +6,6 @@ import { centerWindowOptions } from './utils'
|
|||||||
import { TITLE_BAR_HEIGHT, defaultPreferenceWinOptions, isLinux, isOsx } from '../config'
|
import { TITLE_BAR_HEIGHT, defaultPreferenceWinOptions, isLinux, isOsx } from '../config'
|
||||||
|
|
||||||
class SettingWindow extends BaseWindow {
|
class SettingWindow extends BaseWindow {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Accessor} accessor The application accessor for application instances.
|
* @param {Accessor} accessor The application accessor for application instances.
|
||||||
*/
|
*/
|
||||||
|
@ -189,20 +189,20 @@ export const DEFAULT_TURNDOWN_CONFIG = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const FORMAT_MARKER_MAP = {
|
export const FORMAT_MARKER_MAP = {
|
||||||
'em': '*',
|
em: '*',
|
||||||
'inline_code': '`',
|
inline_code: '`',
|
||||||
'strong': '**',
|
strong: '**',
|
||||||
'del': '~~',
|
del: '~~',
|
||||||
'inline_math': '$',
|
inline_math: '$',
|
||||||
'u': {
|
u: {
|
||||||
open: '<u>',
|
open: '<u>',
|
||||||
close: '</u>'
|
close: '</u>'
|
||||||
},
|
},
|
||||||
'sub': {
|
sub: {
|
||||||
open: '<sub>',
|
open: '<sub>',
|
||||||
close: '</sub>'
|
close: '</sub>'
|
||||||
},
|
},
|
||||||
'sup': {
|
sup: {
|
||||||
open: '<sup>',
|
open: '<sup>',
|
||||||
close: '</sup>'
|
close: '</sup>'
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ const backspaceCtrl = ContentState => {
|
|||||||
|
|
||||||
if (this.isSelectAll()) {
|
if (this.isSelectAll()) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
this.blocks = [ this.createBlockP() ]
|
this.blocks = [this.createBlockP()]
|
||||||
this.init()
|
this.init()
|
||||||
|
|
||||||
this.render()
|
this.render()
|
||||||
|
@ -124,7 +124,7 @@ const clickCtrl = ContentState => {
|
|||||||
eventCenter.dispatch('format-click', {
|
eventCenter.dispatch('format-click', {
|
||||||
event,
|
event,
|
||||||
formatType,
|
formatType,
|
||||||
data,
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
const LINE_BREAKS_REG = /\n/
|
const LINE_BREAKS_REG = /\n/
|
||||||
const FUNCTION_TYPE_LANG = {
|
const FUNCTION_TYPE_LANG = {
|
||||||
'multiplemath': 'latex',
|
multiplemath: 'latex',
|
||||||
'flowchart': 'yaml',
|
flowchart: 'yaml',
|
||||||
'mermaid': 'yaml',
|
mermaid: 'yaml',
|
||||||
'sequence': 'yaml',
|
sequence: 'yaml',
|
||||||
'vega-lite': 'yaml',
|
'vega-lite': 'yaml',
|
||||||
'html': 'markup'
|
html: 'markup'
|
||||||
}
|
}
|
||||||
|
|
||||||
const containerCtrl = ContentState => {
|
const containerCtrl = ContentState => {
|
||||||
|
@ -184,7 +184,7 @@ const copyCutCtrl = ContentState => {
|
|||||||
const table = this.getTableBlock()
|
const table = this.getTableBlock()
|
||||||
if (!table) return
|
if (!table) return
|
||||||
const listIndentation = this.listIndentation
|
const listIndentation = this.listIndentation
|
||||||
const markdown = new ExportMarkdown([ table ], listIndentation).generate()
|
const markdown = new ExportMarkdown([table], listIndentation).generate()
|
||||||
event.clipboardData.setData('text/html', '')
|
event.clipboardData.setData('text/html', '')
|
||||||
event.clipboardData.setData('text/plain', markdown)
|
event.clipboardData.setData('text/plain', markdown)
|
||||||
break
|
break
|
||||||
|
@ -30,7 +30,7 @@ const deleteCtrl = ContentState => {
|
|||||||
}
|
}
|
||||||
startBlock.text += nextBlock.text
|
startBlock.text += nextBlock.text
|
||||||
|
|
||||||
const toBeRemoved = [ nextBlock ]
|
const toBeRemoved = [nextBlock]
|
||||||
|
|
||||||
let parent = this.getParent(nextBlock)
|
let parent = this.getParent(nextBlock)
|
||||||
let target = nextBlock
|
let target = nextBlock
|
||||||
|
@ -60,7 +60,8 @@ const dragDropCtrl = ContentState => {
|
|||||||
ContentState.prototype.dragoverHandler = function (event) {
|
ContentState.prototype.dragoverHandler = function (event) {
|
||||||
// Cancel to allow tab drag&drop.
|
// Cancel to allow tab drag&drop.
|
||||||
if (!event.dataTransfer.types.length) {
|
if (!event.dataTransfer.types.length) {
|
||||||
return event.dataTransfer.dropEffect = 'none'
|
event.dataTransfer.dropEffect = 'none'
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.dataTransfer.types.includes('text/uri-list')) {
|
if (event.dataTransfer.types.includes('text/uri-list')) {
|
||||||
|
@ -167,7 +167,6 @@ const enterCtrl = ContentState => {
|
|||||||
cb: () => {}
|
cb: () => {}
|
||||||
})
|
})
|
||||||
this.selectedImage = null
|
this.selectedImage = null
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +284,7 @@ const enterCtrl = ContentState => {
|
|||||||
start: { key, offset },
|
start: { key, offset },
|
||||||
end: { key, offset }
|
end: { key, offset }
|
||||||
}
|
}
|
||||||
return this.partialRender([ block ])
|
return this.partialRender([block])
|
||||||
}
|
}
|
||||||
|
|
||||||
const getFirstBlockInNextRow = row => {
|
const getFirstBlockInNextRow = row => {
|
||||||
@ -368,7 +367,7 @@ const enterCtrl = ContentState => {
|
|||||||
})
|
})
|
||||||
const headerContent = this.createBlock('span', {
|
const headerContent = this.createBlock('span', {
|
||||||
text: post,
|
text: post,
|
||||||
functionType: block.headingStyle === 'atx'? 'atxLine' : 'paragraphContent'
|
functionType: block.headingStyle === 'atx' ? 'atxLine' : 'paragraphContent'
|
||||||
})
|
})
|
||||||
this.appendChild(newBlock, headerContent)
|
this.appendChild(newBlock, headerContent)
|
||||||
if (block.marker) {
|
if (block.marker) {
|
||||||
@ -447,9 +446,9 @@ const enterCtrl = ContentState => {
|
|||||||
// If block is pre block when updated, need to focus it.
|
// If block is pre block when updated, need to focus it.
|
||||||
const preParagraphBlock = getParagraphBlock(block)
|
const preParagraphBlock = getParagraphBlock(block)
|
||||||
const blockNeedFocus = this.codeBlockUpdate(preParagraphBlock)
|
const blockNeedFocus = this.codeBlockUpdate(preParagraphBlock)
|
||||||
let tableNeedFocus = this.tableBlockUpdate(preParagraphBlock)
|
const tableNeedFocus = this.tableBlockUpdate(preParagraphBlock)
|
||||||
let htmlNeedFocus = this.updateHtmlBlock(preParagraphBlock)
|
const htmlNeedFocus = this.updateHtmlBlock(preParagraphBlock)
|
||||||
let mathNeedFocus = this.updateMathBlock(preParagraphBlock)
|
const mathNeedFocus = this.updateMathBlock(preParagraphBlock)
|
||||||
let cursorBlock
|
let cursorBlock
|
||||||
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
|
@ -27,7 +27,7 @@ const getOffset = (offset, { range: { start, end }, type, tag, anchor, alt }) =>
|
|||||||
if (dis >= 0 && dis < OPEN_MARKER_LEN) return -dis
|
if (dis >= 0 && dis < OPEN_MARKER_LEN) return -dis
|
||||||
if (dis >= OPEN_MARKER_LEN && dis <= len - CLOSE_MARKER_LEN) return -OPEN_MARKER_LEN
|
if (dis >= OPEN_MARKER_LEN && dis <= len - CLOSE_MARKER_LEN) return -OPEN_MARKER_LEN
|
||||||
if (dis > len - CLOSE_MARKER_LEN && dis <= len) return len - dis - OPEN_MARKER_LEN - CLOSE_MARKER_LEN
|
if (dis > len - CLOSE_MARKER_LEN && dis <= len) return len - dis - OPEN_MARKER_LEN - CLOSE_MARKER_LEN
|
||||||
if (dis > len) return - OPEN_MARKER_LEN - CLOSE_MARKER_LEN
|
if (dis > len) return -OPEN_MARKER_LEN - CLOSE_MARKER_LEN
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'link': {
|
case 'link': {
|
||||||
|
@ -63,9 +63,9 @@ class ContentState {
|
|||||||
|
|
||||||
// Use to cache the keys which you don't want to remove.
|
// Use to cache the keys which you don't want to remove.
|
||||||
this.exemption = new Set()
|
this.exemption = new Set()
|
||||||
this.blocks = [ this.createBlockP() ]
|
this.blocks = [this.createBlockP()]
|
||||||
this.stateRender = new StateRender(muya)
|
this.stateRender = new StateRender(muya)
|
||||||
this.renderRange = [ null, null ]
|
this.renderRange = [null, null]
|
||||||
this.currentCursor = null
|
this.currentCursor = null
|
||||||
// you'll select the outmost block of current cursor when you click the front icon.
|
// you'll select the outmost block of current cursor when you click the front icon.
|
||||||
this.selectedBlock = null
|
this.selectedBlock = null
|
||||||
@ -166,7 +166,7 @@ class ContentState {
|
|||||||
const startOutMostBlock = this.findOutMostBlock(startBlock)
|
const startOutMostBlock = this.findOutMostBlock(startBlock)
|
||||||
const endOutMostBlock = this.findOutMostBlock(endBlock)
|
const endOutMostBlock = this.findOutMostBlock(endBlock)
|
||||||
|
|
||||||
this.renderRange = [ startOutMostBlock.preSibling, endOutMostBlock.nextSibling ]
|
this.renderRange = [startOutMostBlock.preSibling, endOutMostBlock.nextSibling]
|
||||||
}
|
}
|
||||||
|
|
||||||
postRender () {
|
postRender () {
|
||||||
@ -193,7 +193,7 @@ class ContentState {
|
|||||||
partialRender (isRenderCursor = true) {
|
partialRender (isRenderCursor = true) {
|
||||||
const { blocks, searchMatches: { matches, index } } = this
|
const { blocks, searchMatches: { matches, index } } = this
|
||||||
const activeBlocks = this.getActiveBlocks()
|
const activeBlocks = this.getActiveBlocks()
|
||||||
const [ startKey, endKey ] = this.renderRange
|
const [startKey, endKey] = this.renderRange
|
||||||
matches.forEach((m, i) => {
|
matches.forEach((m, i) => {
|
||||||
m.active = i === index
|
m.active = i === index
|
||||||
})
|
})
|
||||||
@ -326,6 +326,7 @@ class ContentState {
|
|||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
// return block and its parents
|
// return block and its parents
|
||||||
getParents (block) {
|
getParents (block) {
|
||||||
const result = []
|
const result = []
|
||||||
@ -399,6 +400,7 @@ class ContentState {
|
|||||||
this.removeBlock(block)
|
this.removeBlock(block)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// help func in removeBlocks
|
// help func in removeBlocks
|
||||||
findFigure (block) {
|
findFigure (block) {
|
||||||
if (block.type === 'figure') {
|
if (block.type === 'figure') {
|
||||||
@ -490,7 +492,7 @@ class ContentState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getActiveBlocks () {
|
getActiveBlocks () {
|
||||||
let result = []
|
const result = []
|
||||||
let block = this.getBlock(this.cursor.start.key)
|
let block = this.getBlock(this.cursor.start.key)
|
||||||
if (block) result.push(block)
|
if (block) result.push(block)
|
||||||
while (block && block.parent) {
|
while (block && block.parent) {
|
||||||
|
@ -9,10 +9,10 @@ const BRACKET_HASH = {
|
|||||||
'[': ']',
|
'[': ']',
|
||||||
'(': ')',
|
'(': ')',
|
||||||
'*': '*',
|
'*': '*',
|
||||||
'_': '_',
|
_: '_',
|
||||||
'"': '"',
|
'"': '"',
|
||||||
'\'': '\'',
|
'\'': '\'',
|
||||||
'$': '$',
|
$: '$',
|
||||||
'~': '~'
|
'~': '~'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,10 +21,10 @@ const BACK_HASH = {
|
|||||||
']': '[',
|
']': '[',
|
||||||
')': '(',
|
')': '(',
|
||||||
'*': '*',
|
'*': '*',
|
||||||
'_': '_',
|
_: '_',
|
||||||
'"': '"',
|
'"': '"',
|
||||||
'\'': '\'',
|
'\'': '\'',
|
||||||
'$': '$',
|
$: '$',
|
||||||
'~': '~'
|
'~': '~'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ const inputCtrl = ContentState => {
|
|||||||
const key = start.key
|
const key = start.key
|
||||||
const block = this.getBlock(key)
|
const block = this.getBlock(key)
|
||||||
const paragraph = document.querySelector(`#${key}`)
|
const paragraph = document.querySelector(`#${key}`)
|
||||||
let text = getTextContent(paragraph, [ CLASS_OR_ID['AG_MATH_RENDER'], CLASS_OR_ID['AG_RUBY_RENDER'] ])
|
let text = getTextContent(paragraph, [CLASS_OR_ID['AG_MATH_RENDER'], CLASS_OR_ID['AG_RUBY_RENDER']])
|
||||||
|
|
||||||
let needRender = false
|
let needRender = false
|
||||||
let needRenderAll = false
|
let needRenderAll = false
|
||||||
|
@ -209,7 +209,7 @@ const paragraphCtrl = ContentState => {
|
|||||||
|
|
||||||
ContentState.prototype.handleCodeBlockMenu = function () {
|
ContentState.prototype.handleCodeBlockMenu = function () {
|
||||||
const { start, end, affiliation } = this.selectionChange(this.cursor)
|
const { start, end, affiliation } = this.selectionChange(this.cursor)
|
||||||
let startBlock = this.getBlock(start.key)
|
const startBlock = this.getBlock(start.key)
|
||||||
const endBlock = this.getBlock(end.key)
|
const endBlock = this.getBlock(end.key)
|
||||||
const startParents = this.getParents(startBlock)
|
const startParents = this.getParents(startBlock)
|
||||||
const endParents = this.getParents(endBlock)
|
const endParents = this.getParents(endBlock)
|
||||||
@ -547,8 +547,8 @@ const paragraphCtrl = ContentState => {
|
|||||||
headingStyle
|
headingStyle
|
||||||
})
|
})
|
||||||
const headerContent = this.createBlock('span', {
|
const headerContent = this.createBlock('span', {
|
||||||
text: headingStyle === 'atx'? newText.replace(/\n/g, ' ') : newText,
|
text: headingStyle === 'atx' ? newText.replace(/\n/g, ' ') : newText,
|
||||||
functionType: headingStyle === 'atx'? 'atxLine' : 'paragraphContent'
|
functionType: headingStyle === 'atx' ? 'atxLine' : 'paragraphContent'
|
||||||
})
|
})
|
||||||
this.appendChild(header, headerContent)
|
this.appendChild(header, headerContent)
|
||||||
key = headerContent.key
|
key = headerContent.key
|
||||||
|
@ -87,7 +87,7 @@ const pasteCtrl = ContentState => {
|
|||||||
if (this.selectedImage) {
|
if (this.selectedImage) {
|
||||||
this.replaceImage(this.selectedImage, {
|
this.replaceImage(this.selectedImage, {
|
||||||
alt: id,
|
alt: id,
|
||||||
src: imagePath,
|
src: imagePath
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.insertImage({
|
this.insertImage({
|
||||||
@ -377,9 +377,9 @@ const pasteCtrl = ContentState => {
|
|||||||
// No matter copy loose list to tight list or vice versa, the result is one loose list.
|
// No matter copy loose list to tight list or vice versa, the result is one loose list.
|
||||||
if (targetListType !== originListType) {
|
if (targetListType !== originListType) {
|
||||||
if (!targetListType) {
|
if (!targetListType) {
|
||||||
firstFragment.children.forEach(item => item.isLooseListItem = true)
|
firstFragment.children.forEach(item => (item.isLooseListItem = true))
|
||||||
} else {
|
} else {
|
||||||
originList.children.forEach(item => item.isLooseListItem = true)
|
originList.children.forEach(item => (item.isLooseListItem = true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ const searchCtrl = ContentState => {
|
|||||||
|
|
||||||
ContentState.prototype.search = function (value, opt = {}) {
|
ContentState.prototype.search = function (value, opt = {}) {
|
||||||
value = value.trim()
|
value = value.trim()
|
||||||
let matches = []
|
const matches = []
|
||||||
const { caseSensitive, highlightIndex } = Object.assign(defaultSearchOption, opt)
|
const { caseSensitive, highlightIndex } = Object.assign(defaultSearchOption, opt)
|
||||||
const { blocks } = this
|
const { blocks } = this
|
||||||
const search = blocks => {
|
const search = blocks => {
|
||||||
|
@ -112,7 +112,7 @@ const tabCtrl = ContentState => {
|
|||||||
let target = this.getNextSibling(listItem)
|
let target = this.getNextSibling(listItem)
|
||||||
while (target) {
|
while (target) {
|
||||||
this.appendChild(newList, target)
|
this.appendChild(newList, target)
|
||||||
let temp = target
|
const temp = target
|
||||||
target = this.getNextSibling(target)
|
target = this.getNextSibling(target)
|
||||||
this.removeBlock(temp, list)
|
this.removeBlock(temp, list)
|
||||||
}
|
}
|
||||||
@ -185,7 +185,6 @@ const tabCtrl = ContentState => {
|
|||||||
const tokens = tokenizer(text, [], false, labels)
|
const tokens = tokenizer(text, [], false, labels)
|
||||||
let result = null
|
let result = null
|
||||||
const walkTokens = tkns => {
|
const walkTokens = tkns => {
|
||||||
|
|
||||||
for (const token of tkns) {
|
for (const token of tkns) {
|
||||||
const { marker, type, range, children, srcAndTitle, hrefAndTitle, backlash, closeTag, isFullLink, label } = token
|
const { marker, type, range, children, srcAndTitle, hrefAndTitle, backlash, closeTag, isFullLink, label } = token
|
||||||
const { start, end } = range
|
const { start, end } = range
|
||||||
|
@ -260,7 +260,7 @@ const tableBlockCtrl = ContentState => {
|
|||||||
|
|
||||||
if (target === 'row') {
|
if (target === 'row') {
|
||||||
if (action === 'insert') {
|
if (action === 'insert') {
|
||||||
let newRow = (location === 'previous' && block.type === 'th')
|
const newRow = (location === 'previous' && block.type === 'th')
|
||||||
? createRow(column, true)
|
? createRow(column, true)
|
||||||
: createRow(column, false)
|
: createRow(column, false)
|
||||||
if (location === 'previous') {
|
if (location === 'previous') {
|
||||||
|
@ -234,7 +234,7 @@ const updateCtrl = ContentState => {
|
|||||||
this.removeBlock(nextSibling)
|
this.removeBlock(nextSibling)
|
||||||
this.removeBlock(block)
|
this.removeBlock(block)
|
||||||
const isLooseListItem = preSibling.children.some(c => c.isLooseListItem)
|
const isLooseListItem = preSibling.children.some(c => c.isLooseListItem)
|
||||||
preSibling.children.forEach(c => c.isLooseListItem = isLooseListItem)
|
preSibling.children.forEach(c => (c.isLooseListItem = isLooseListItem))
|
||||||
} else if (
|
} else if (
|
||||||
preSibling &&
|
preSibling &&
|
||||||
this.checkSameMarkerOrDelimiter(preSibling, bulletMarkerOrDelimiter)
|
this.checkSameMarkerOrDelimiter(preSibling, bulletMarkerOrDelimiter)
|
||||||
@ -242,7 +242,7 @@ const updateCtrl = ContentState => {
|
|||||||
this.appendChild(preSibling, newListItemBlock)
|
this.appendChild(preSibling, newListItemBlock)
|
||||||
this.removeBlock(block)
|
this.removeBlock(block)
|
||||||
const isLooseListItem = preSibling.children.some(c => c.isLooseListItem)
|
const isLooseListItem = preSibling.children.some(c => c.isLooseListItem)
|
||||||
preSibling.children.forEach(c => c.isLooseListItem = isLooseListItem)
|
preSibling.children.forEach(c => (c.isLooseListItem = isLooseListItem))
|
||||||
} else if (
|
} else if (
|
||||||
nextSibling &&
|
nextSibling &&
|
||||||
this.checkSameMarkerOrDelimiter(nextSibling, bulletMarkerOrDelimiter)
|
this.checkSameMarkerOrDelimiter(nextSibling, bulletMarkerOrDelimiter)
|
||||||
@ -250,7 +250,7 @@ const updateCtrl = ContentState => {
|
|||||||
this.insertBefore(newListItemBlock, nextSibling.children[0])
|
this.insertBefore(newListItemBlock, nextSibling.children[0])
|
||||||
this.removeBlock(block)
|
this.removeBlock(block)
|
||||||
const isLooseListItem = nextSibling.children.some(c => c.isLooseListItem)
|
const isLooseListItem = nextSibling.children.some(c => c.isLooseListItem)
|
||||||
nextSibling.children.forEach(c => c.isLooseListItem = isLooseListItem)
|
nextSibling.children.forEach(c => (c.isLooseListItem = isLooseListItem))
|
||||||
} else {
|
} else {
|
||||||
// Create a new list when changing list type, bullet or list delimiter
|
// Create a new list when changing list type, bullet or list delimiter
|
||||||
const listBlock = this.createBlock(wrapperTag, {
|
const listBlock = this.createBlock(wrapperTag, {
|
||||||
@ -284,7 +284,7 @@ const updateCtrl = ContentState => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TASK_LIST_REG.test(listItemText)) {
|
if (TASK_LIST_REG.test(listItemText)) {
|
||||||
const [,,tasklist,,,,] = listItemText.match(INLINE_UPDATE_REG) || []
|
const [,, tasklist,,,,] = listItemText.match(INLINE_UPDATE_REG) || [] // eslint-disable-line comma-spacing
|
||||||
return this.updateTaskListItem(block, 'tasklist', tasklist)
|
return this.updateTaskListItem(block, 'tasklist', tasklist)
|
||||||
} else {
|
} else {
|
||||||
return block
|
return block
|
||||||
@ -420,7 +420,7 @@ const updateCtrl = ContentState => {
|
|||||||
|
|
||||||
const text = line.text
|
const text = line.text
|
||||||
const lines = text.split('\n')
|
const lines = text.split('\n')
|
||||||
let setextLines = []
|
const setextLines = []
|
||||||
const postParagraphLines = []
|
const postParagraphLines = []
|
||||||
let setextLineHasPushed = false
|
let setextLineHasPushed = false
|
||||||
|
|
||||||
@ -467,7 +467,7 @@ const updateCtrl = ContentState => {
|
|||||||
const text = line.text
|
const text = line.text
|
||||||
const lines = text.split('\n')
|
const lines = text.split('\n')
|
||||||
const preParagraphLines = []
|
const preParagraphLines = []
|
||||||
let quoteLines = []
|
const quoteLines = []
|
||||||
let quoteLinesHasPushed = false
|
let quoteLinesHasPushed = false
|
||||||
|
|
||||||
for (const l of lines) {
|
for (const l of lines) {
|
||||||
@ -490,7 +490,7 @@ const updateCtrl = ContentState => {
|
|||||||
}
|
}
|
||||||
const headerContent = this.createBlock('span', {
|
const headerContent = this.createBlock('span', {
|
||||||
text: quoteLines.join('\n'),
|
text: quoteLines.join('\n'),
|
||||||
functionType: block.headingStyle === 'setext'? 'paragraphContent' : 'atxLine'
|
functionType: block.headingStyle === 'setext' ? 'paragraphContent' : 'atxLine'
|
||||||
})
|
})
|
||||||
this.appendChild(quoteParagraphBlock, headerContent)
|
this.appendChild(quoteParagraphBlock, headerContent)
|
||||||
} else {
|
} else {
|
||||||
|
@ -5,6 +5,7 @@ class EventCenter {
|
|||||||
this.events = []
|
this.events = []
|
||||||
this.listeners = {}
|
this.listeners = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [attachDOMEvent] bind event listener to target, and return a unique ID,
|
* [attachDOMEvent] bind event listener to target, and return a unique ID,
|
||||||
* this ID
|
* this ID
|
||||||
@ -22,6 +23,7 @@ class EventCenter {
|
|||||||
})
|
})
|
||||||
return eventId
|
return eventId
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [detachDOMEvent removeEventListener]
|
* [detachDOMEvent removeEventListener]
|
||||||
* @param {[type]} eventId [unique eventId]
|
* @param {[type]} eventId [unique eventId]
|
||||||
@ -34,12 +36,14 @@ class EventCenter {
|
|||||||
target.removeEventListener(event, listener, capture)
|
target.removeEventListener(event, listener, capture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [detachAllDomEvents remove all the DOM events handler]
|
* [detachAllDomEvents remove all the DOM events handler]
|
||||||
*/
|
*/
|
||||||
detachAllDomEvents () {
|
detachAllDomEvents () {
|
||||||
this.events.forEach(event => this.detachDOMEvent(event.eventId))
|
this.events.forEach(event => this.detachDOMEvent(event.eventId))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* inner method for subscribe and subscribeOnce
|
* inner method for subscribe and subscribeOnce
|
||||||
*/
|
*/
|
||||||
@ -49,15 +53,17 @@ class EventCenter {
|
|||||||
if (listeners && Array.isArray(listeners)) {
|
if (listeners && Array.isArray(listeners)) {
|
||||||
listeners.push(handler)
|
listeners.push(handler)
|
||||||
} else {
|
} else {
|
||||||
this.listeners[event] = [ handler ]
|
this.listeners[event] = [handler]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [subscribe] subscribe custom event
|
* [subscribe] subscribe custom event
|
||||||
*/
|
*/
|
||||||
subscribe (event, listener) {
|
subscribe (event, listener) {
|
||||||
this._subscribe(event, listener)
|
this._subscribe(event, listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [unsubscribe] unsubscribe custom event
|
* [unsubscribe] unsubscribe custom event
|
||||||
*/
|
*/
|
||||||
@ -68,12 +74,14 @@ class EventCenter {
|
|||||||
listeners.splice(index, 1)
|
listeners.splice(index, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [subscribeOnce] usbscribe event and listen once
|
* [subscribeOnce] usbscribe event and listen once
|
||||||
*/
|
*/
|
||||||
subscribeOnce (event, listener) {
|
subscribeOnce (event, listener) {
|
||||||
this._subscribe(event, listener, true)
|
this._subscribe(event, listener, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dispatch custom event
|
* dispatch custom event
|
||||||
*/
|
*/
|
||||||
@ -88,6 +96,7 @@ class EventCenter {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine whether the event has been bind
|
// Determine whether the event has been bind
|
||||||
checkHasBind (cTarget, cEvent, cListener, cCapture) {
|
checkHasBind (cTarget, cEvent, cListener, cCapture) {
|
||||||
for (const { target, event, listener, capture } of this.events) {
|
for (const { target, event, listener, capture } of this.events) {
|
||||||
|
@ -13,9 +13,11 @@ import './assets/styles/index.css'
|
|||||||
|
|
||||||
class Muya {
|
class Muya {
|
||||||
static plugins = []
|
static plugins = []
|
||||||
|
|
||||||
static use (plugin) {
|
static use (plugin) {
|
||||||
this.plugins.push(plugin)
|
this.plugins.push(plugin)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor (container, options) {
|
constructor (container, options) {
|
||||||
this.options = Object.assign({}, MUYA_DEFAULT_OPTION, options)
|
this.options = Object.assign({}, MUYA_DEFAULT_OPTION, options)
|
||||||
const { markdown } = this.options
|
const { markdown } = this.options
|
||||||
@ -64,7 +66,7 @@ class Muya {
|
|||||||
|
|
||||||
// Callback function to execute when mutations are observed
|
// Callback function to execute when mutations are observed
|
||||||
const callback = (mutationsList, observer) => {
|
const callback = (mutationsList, observer) => {
|
||||||
for(const mutation of mutationsList) {
|
for (const mutation of mutationsList) {
|
||||||
if (mutation.type === 'childList') {
|
if (mutation.type === 'childList') {
|
||||||
const { removedNodes, target } = mutation
|
const { removedNodes, target } = mutation
|
||||||
// If the code executes any of the following `if` statements, the editor has gone wrong.
|
// If the code executes any of the following `if` statements, the editor has gone wrong.
|
||||||
|
@ -15,16 +15,16 @@ export const block = {
|
|||||||
nptable: noop,
|
nptable: noop,
|
||||||
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
||||||
list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
||||||
html: '^ {0,3}(?:' // optional indentation
|
html: '^ {0,3}(?:' + // optional indentation
|
||||||
+ '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
'<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' + // (1)
|
||||||
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
'|comment[^\\n]*(\\n+|$)' + // (2)
|
||||||
+ '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
|
'|<\\?[\\s\\S]*?\\?>\\n*' + // (3)
|
||||||
+ '|<![A-Z][\\s\\S]*?>\\n*' // (4)
|
'|<![A-Z][\\s\\S]*?>\\n*' + // (4)
|
||||||
+ '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' // (5)
|
'|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' + // (5)
|
||||||
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
|
'|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' + // (6)
|
||||||
+ '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
|
'|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' + // (7) open tag
|
||||||
+ '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
|
'|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' + // (7) closing tag
|
||||||
+ ')',
|
')',
|
||||||
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
||||||
table: noop,
|
table: noop,
|
||||||
lheading: /^([^\n]+)\n {0,3}(=|-){2,} *(?:\n+|$)/,
|
lheading: /^([^\n]+)\n {0,3}(=|-){2,} *(?:\n+|$)/,
|
||||||
@ -38,19 +38,19 @@ export const block = {
|
|||||||
|
|
||||||
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/
|
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/
|
||||||
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/
|
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/
|
||||||
block.def = edit(block.def).
|
block.def = edit(block.def)
|
||||||
replace('label', block._label).
|
.replace('label', block._label)
|
||||||
replace('title', block._title).
|
.replace('title', block._title)
|
||||||
getRegex()
|
.getRegex()
|
||||||
|
|
||||||
block.checkbox = /^\[([ xX])\] +/
|
block.checkbox = /^\[([ xX])\] +/
|
||||||
block.bullet = /(?:[*+-]|\d{1,9}(?:\.|\)))/ // patched: support "(" as ordered list delimiter too
|
block.bullet = /(?:[*+-]|\d{1,9}(?:\.|\)))/ // patched: support "(" as ordered list delimiter too
|
||||||
// patched: fix https://github.com/marktext/marktext/issues/831#issuecomment-477719256
|
// patched: fix https://github.com/marktext/marktext/issues/831#issuecomment-477719256
|
||||||
// block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/
|
// block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/
|
||||||
block.item = /^(( {0,3})(bull) [^\n]*(?:\n(?!(\2bull |\2bull\n))[^\n]*)*|( {0,3})(bull)(?:\n(?!(\2bull |\2bull\n)))*)/
|
block.item = /^(( {0,3})(bull) [^\n]*(?:\n(?!(\2bull |\2bull\n))[^\n]*)*|( {0,3})(bull)(?:\n(?!(\2bull |\2bull\n)))*)/
|
||||||
block.item = edit(block.item, 'gm').
|
block.item = edit(block.item, 'gm')
|
||||||
replace(/bull/g, block.bullet).
|
.replace(/bull/g, block.bullet)
|
||||||
getRegex()
|
.getRegex()
|
||||||
|
|
||||||
block.list = edit(block.list)
|
block.list = edit(block.list)
|
||||||
.replace(/bull/g, block.bullet)
|
.replace(/bull/g, block.bullet)
|
||||||
@ -58,12 +58,12 @@ block.list = edit(block.list)
|
|||||||
.replace('def', '\\n+(?=' + block.def.source + ')')
|
.replace('def', '\\n+(?=' + block.def.source + ')')
|
||||||
.getRegex()
|
.getRegex()
|
||||||
|
|
||||||
block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
|
block._tag = 'address|article|aside|base|basefont|blockquote|body|caption' +
|
||||||
+ '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
|
'|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption' +
|
||||||
+ '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
|
'|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe' +
|
||||||
+ '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
|
'|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' +
|
||||||
+ '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
|
'|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr' +
|
||||||
+ '|track|ul'
|
'|track|ul'
|
||||||
block._comment = /<!--(?!-?>)[\s\S]*?-->/
|
block._comment = /<!--(?!-?>)[\s\S]*?-->/
|
||||||
block.html = edit(block.html, 'i')
|
block.html = edit(block.html, 'i')
|
||||||
.replace('comment', block._comment)
|
.replace('comment', block._comment)
|
||||||
@ -98,9 +98,9 @@ export const gfm = Object.assign({}, normal, {
|
|||||||
})
|
})
|
||||||
|
|
||||||
gfm.paragraph = edit(block.paragraph)
|
gfm.paragraph = edit(block.paragraph)
|
||||||
.replace('(?!', '(?!'
|
.replace('(?!', '(?!' +
|
||||||
+ gfm.fences.source.replace('\\1', '\\2') + '|'
|
gfm.fences.source.replace('\\1', '\\2') + '|' +
|
||||||
+ block.list.source.replace('\\1', '\\3') + '|')
|
block.list.source.replace('\\1', '\\3') + '|')
|
||||||
.getRegex()
|
.getRegex()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,14 +118,14 @@ export const tables = Object.assign({}, gfm, {
|
|||||||
|
|
||||||
export const pedantic = Object.assign({}, normal, {
|
export const pedantic = Object.assign({}, normal, {
|
||||||
html: edit(
|
html: edit(
|
||||||
'^ *(?:comment *(?:\\n|\\s*$)'
|
'^ *(?:comment *(?:\\n|\\s*$)' +
|
||||||
+ '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
'|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' + // closed tag
|
||||||
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
|
'|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
|
||||||
.replace('comment', block._comment)
|
.replace('comment', block._comment)
|
||||||
.replace(/tag/g, '(?!(?:'
|
.replace(/tag/g, '(?!(?:' +
|
||||||
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
|
'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub' +
|
||||||
+ '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
|
'|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)' +
|
||||||
+ '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
|
'\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
|
||||||
.getRegex(),
|
.getRegex(),
|
||||||
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/
|
||||||
})
|
})
|
||||||
|
@ -13,8 +13,8 @@ function marked (src, opt = {}) {
|
|||||||
throw new Error('marked(): input parameter is undefined or null')
|
throw new Error('marked(): input parameter is undefined or null')
|
||||||
}
|
}
|
||||||
if (typeof src !== 'string') {
|
if (typeof src !== 'string') {
|
||||||
throw new Error('marked(): input parameter is of type '
|
throw new Error('marked(): input parameter is of type ' +
|
||||||
+ Object.prototype.toString.call(src) + ', string expected')
|
Object.prototype.toString.call(src) + ', string expected')
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -119,8 +119,8 @@ export const gfm = Object.assign({}, normal, {
|
|||||||
emoji: /^(:)([a-z_\d+-]+?)\1/ // not real GFM but put it in here
|
emoji: /^(:)([a-z_\d+-]+?)\1/ // not real GFM but put it in here
|
||||||
})
|
})
|
||||||
|
|
||||||
gfm.url = edit(gfm.url, 'i').
|
gfm.url = edit(gfm.url, 'i')
|
||||||
replace('email', gfm._extended_email)
|
.replace('email', gfm._extended_email)
|
||||||
.getRegex()
|
.getRegex()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -392,8 +392,8 @@ Lexer.prototype.token = function (src, top) {
|
|||||||
type: this.options.sanitize
|
type: this.options.sanitize
|
||||||
? 'paragraph'
|
? 'paragraph'
|
||||||
: 'html',
|
: 'html',
|
||||||
pre: !this.options.sanitizer
|
pre: !this.options.sanitizer &&
|
||||||
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
(cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
||||||
text: cap[0]
|
text: cap[0]
|
||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
|
@ -27,7 +27,7 @@ Parser.prototype.parse = function (src) {
|
|||||||
// use an InlineLexer with a TextRenderer to extract pure text
|
// use an InlineLexer with a TextRenderer to extract pure text
|
||||||
this.inlineText = new InlineLexer(
|
this.inlineText = new InlineLexer(
|
||||||
src.links,
|
src.links,
|
||||||
Object.assign({}, this.options, {renderer: new TextRenderer()})
|
Object.assign({}, this.options, { renderer: new TextRenderer() })
|
||||||
)
|
)
|
||||||
this.tokens = src.reverse()
|
this.tokens = src.reverse()
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ Parser.prototype.tok = function () {
|
|||||||
return this.renderer.paragraph(this.parseText())
|
return this.renderer.paragraph(this.parseText())
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
let errMsg = 'Token with "' + this.token.type + '" type was not found.'
|
const errMsg = 'Token with "' + this.token.type + '" type was not found.'
|
||||||
if (this.options.silent) {
|
if (this.options.silent) {
|
||||||
console.error(errMsg)
|
console.error(errMsg)
|
||||||
} else {
|
} else {
|
||||||
|
@ -42,7 +42,7 @@ Renderer.prototype.emoji = function (text, emoji) {
|
|||||||
Renderer.prototype.code = function (code, infostring, escaped, codeBlockStyle) {
|
Renderer.prototype.code = function (code, infostring, escaped, codeBlockStyle) {
|
||||||
const lang = (infostring || '').match(/\S*/)[0]
|
const lang = (infostring || '').match(/\S*/)[0]
|
||||||
if (this.options.highlight) {
|
if (this.options.highlight) {
|
||||||
let out = this.options.highlight(code, lang)
|
const out = this.options.highlight(code, lang)
|
||||||
if (out !== null && out !== code) {
|
if (out !== null && out !== code) {
|
||||||
escaped = true
|
escaped = true
|
||||||
code = out
|
code = out
|
||||||
|
@ -18,7 +18,7 @@ Slugger.prototype.slug = function (value) {
|
|||||||
.replace(/\s/g, '-')
|
.replace(/\s/g, '-')
|
||||||
|
|
||||||
if (this.seen.hasOwnProperty(slug)) {
|
if (this.seen.hasOwnProperty(slug)) {
|
||||||
let originalSlug = slug
|
const originalSlug = slug
|
||||||
do {
|
do {
|
||||||
this.seen[originalSlug]++
|
this.seen[originalSlug]++
|
||||||
slug = originalSlug + '-' + this.seen[originalSlug]
|
slug = originalSlug + '-' + this.seen[originalSlug]
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* returns only the textual part of the token
|
* returns only the textual part of the token
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function TextRenderer() {}
|
function TextRenderer () {}
|
||||||
|
|
||||||
// no need for block level renderers
|
// no need for block level renderers
|
||||||
|
|
||||||
@ -16,11 +16,11 @@ TextRenderer.prototype.text = function (text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextRenderer.prototype.link =
|
TextRenderer.prototype.link =
|
||||||
TextRenderer.prototype.image = function(href, title, text) {
|
TextRenderer.prototype.image = function (href, title, text) {
|
||||||
return '' + text
|
return '' + text
|
||||||
}
|
}
|
||||||
|
|
||||||
TextRenderer.prototype.br = function() {
|
TextRenderer.prototype.br = function () {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ escape.escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g
|
|||||||
|
|
||||||
export const unescape = function unescape (html) {
|
export const unescape = function unescape (html) {
|
||||||
// explicitly match decimal, hex, and named HTML entities
|
// explicitly match decimal, hex, and named HTML entities
|
||||||
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function(_, n) {
|
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function (_, n) {
|
||||||
n = n.toLowerCase()
|
n = n.toLowerCase()
|
||||||
if (n === 'colon') return ':'
|
if (n === 'colon') return ':'
|
||||||
if (n.charAt(0) === '#') {
|
if (n.charAt(0) === '#') {
|
||||||
@ -47,19 +47,19 @@ export const edit = function edit (regex, opt) {
|
|||||||
regex = regex.source || regex
|
regex = regex.source || regex
|
||||||
opt = opt || ''
|
opt = opt || ''
|
||||||
return {
|
return {
|
||||||
replace: function(name, val) {
|
replace: function (name, val) {
|
||||||
val = val.source || val
|
val = val.source || val
|
||||||
val = val.replace(/(^|[^\[])\^/g, '$1') // eslint-disable-line no-useless-escape
|
val = val.replace(/(^|[^\[])\^/g, '$1') // eslint-disable-line no-useless-escape
|
||||||
regex = regex.replace(name, val)
|
regex = regex.replace(name, val)
|
||||||
return this
|
return this
|
||||||
},
|
},
|
||||||
getRegex: function() {
|
getRegex: function () {
|
||||||
return new RegExp(regex, opt)
|
return new RegExp(regex, opt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const cleanUrl = function cleanUrl(sanitize, base, href) {
|
export const cleanUrl = function cleanUrl (sanitize, base, href) {
|
||||||
if (sanitize) {
|
if (sanitize) {
|
||||||
let prot = ''
|
let prot = ''
|
||||||
try {
|
try {
|
||||||
@ -84,7 +84,7 @@ export const cleanUrl = function cleanUrl(sanitize, base, href) {
|
|||||||
return href
|
return href
|
||||||
}
|
}
|
||||||
|
|
||||||
const resolveUrl = function resolveUrl(base, href) {
|
const resolveUrl = function resolveUrl (base, href) {
|
||||||
if (!baseUrls[' ' + base]) {
|
if (!baseUrls[' ' + base]) {
|
||||||
// we can ignore everything in base after the last slash of its path component,
|
// we can ignore everything in base after the last slash of its path component,
|
||||||
// but we might need to add _that_
|
// but we might need to add _that_
|
||||||
@ -105,18 +105,18 @@ const resolveUrl = function resolveUrl(base, href) {
|
|||||||
return base + href
|
return base + href
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let baseUrls = {}
|
const baseUrls = {}
|
||||||
let originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i
|
const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i
|
||||||
|
|
||||||
export const noop = function noop () {}
|
export const noop = function noop () {}
|
||||||
noop.exec = noop
|
noop.exec = noop
|
||||||
|
|
||||||
export const splitCells = function splitCells(tableRow, count) {
|
export const splitCells = function splitCells (tableRow, count) {
|
||||||
// ensure that every cell-delimiting pipe has a space
|
// ensure that every cell-delimiting pipe has a space
|
||||||
// before it to distinguish it from an escaped pipe
|
// before it to distinguish it from an escaped pipe
|
||||||
let row = tableRow.replace(/\|/g, function (match, offset, str) {
|
const row = tableRow.replace(/\|/g, function (match, offset, str) {
|
||||||
let escaped = false,
|
let escaped = false
|
||||||
curr = offset
|
let curr = offset
|
||||||
while (--curr >= 0 && str[curr] === '\\') escaped = !escaped
|
while (--curr >= 0 && str[curr] === '\\') escaped = !escaped
|
||||||
if (escaped) {
|
if (escaped) {
|
||||||
// odd number of slashes means | is escaped
|
// odd number of slashes means | is escaped
|
||||||
@ -126,9 +126,9 @@ export const splitCells = function splitCells(tableRow, count) {
|
|||||||
// add space before unescaped |
|
// add space before unescaped |
|
||||||
return ' |'
|
return ' |'
|
||||||
}
|
}
|
||||||
}),
|
})
|
||||||
cells = row.split(/ \|/),
|
const cells = row.split(/ \|/)
|
||||||
i = 0
|
let i = 0
|
||||||
|
|
||||||
if (cells.length > count) {
|
if (cells.length > count) {
|
||||||
cells.splice(count)
|
cells.splice(count)
|
||||||
@ -146,7 +146,7 @@ export const splitCells = function splitCells(tableRow, count) {
|
|||||||
// Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
// Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
||||||
// /c*$/ is vulnerable to REDOS.
|
// /c*$/ is vulnerable to REDOS.
|
||||||
// invert: Remove suffix of non-c chars instead. Default falsey.
|
// invert: Remove suffix of non-c chars instead. Default falsey.
|
||||||
export const rtrim = function rtrim(str, c, invert) {
|
export const rtrim = function rtrim (str, c, invert) {
|
||||||
if (str.length === 0) {
|
if (str.length === 0) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ export const rtrim = function rtrim(str, c, invert) {
|
|||||||
|
|
||||||
// Step left until we fail to match the invert condition.
|
// Step left until we fail to match the invert condition.
|
||||||
while (suffLen < str.length) {
|
while (suffLen < str.length) {
|
||||||
let currChar = str.charAt(str.length - suffLen - 1)
|
const currChar = str.charAt(str.length - suffLen - 1)
|
||||||
if (currChar === c && !invert) {
|
if (currChar === c && !invert) {
|
||||||
suffLen++
|
suffLen++
|
||||||
} else if (currChar !== c && invert) {
|
} else if (currChar !== c && invert) {
|
||||||
@ -169,7 +169,7 @@ export const rtrim = function rtrim(str, c, invert) {
|
|||||||
return str.substr(0, str.length - suffLen)
|
return str.substr(0, str.length - suffLen)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const findClosingBracket = function findClosingBracket(str, b) {
|
export const findClosingBracket = function findClosingBracket (str, b) {
|
||||||
if (str.indexOf(b[1]) === -1) {
|
if (str.indexOf(b[1]) === -1) {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
@ -188,4 +188,3 @@ export const findClosingBracket = function findClosingBracket(str, b) {
|
|||||||
}
|
}
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,8 +109,8 @@ class StateRender {
|
|||||||
async renderDiagram () {
|
async renderDiagram () {
|
||||||
const cache = this.diagramCache
|
const cache = this.diagramCache
|
||||||
const RENDER_MAP = {
|
const RENDER_MAP = {
|
||||||
'flowchart': flowchart,
|
flowchart: flowchart,
|
||||||
'sequence': Diagram,
|
sequence: Diagram,
|
||||||
'vega-lite': vegaEmbed
|
'vega-lite': vegaEmbed
|
||||||
}
|
}
|
||||||
if (cache.size) {
|
if (cache.size) {
|
||||||
@ -123,7 +123,9 @@ class StateRender {
|
|||||||
Object.assign(options, { theme: this.muya.options.sequenceTheme })
|
Object.assign(options, { theme: this.muya.options.sequenceTheme })
|
||||||
} else if (functionType === 'vega-lite') {
|
} else if (functionType === 'vega-lite') {
|
||||||
Object.assign(options, {
|
Object.assign(options, {
|
||||||
actions: false, tooltip: false, renderer: 'svg',
|
actions: false,
|
||||||
|
tooltip: false,
|
||||||
|
renderer: 'svg',
|
||||||
theme: this.muya.options.vegaTheme
|
theme: this.muya.options.vegaTheme
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,14 @@ import { renderEditIcon } from './renderContainerEditIcon'
|
|||||||
import { h } from '../snabbdom'
|
import { h } from '../snabbdom'
|
||||||
|
|
||||||
const PRE_BLOCK_HASH = {
|
const PRE_BLOCK_HASH = {
|
||||||
'fencecode': `.${CLASS_OR_ID['AG_FENCE_CODE']}`,
|
fencecode: `.${CLASS_OR_ID['AG_FENCE_CODE']}`,
|
||||||
'indentcode': `.${CLASS_OR_ID['AG_INDENT_CODE']}`,
|
indentcode: `.${CLASS_OR_ID['AG_INDENT_CODE']}`,
|
||||||
'html': `.${CLASS_OR_ID['AG_HTML_BLOCK']}`,
|
html: `.${CLASS_OR_ID['AG_HTML_BLOCK']}`,
|
||||||
'frontmatter': `.${CLASS_OR_ID['AG_FRONT_MATTER']}`,
|
frontmatter: `.${CLASS_OR_ID['AG_FRONT_MATTER']}`,
|
||||||
'multiplemath': `.${CLASS_OR_ID['AG_MULTIPLE_MATH']}`,
|
multiplemath: `.${CLASS_OR_ID['AG_MULTIPLE_MATH']}`,
|
||||||
'flowchart': `.${CLASS_OR_ID['AG_FLOWCHART']}`,
|
flowchart: `.${CLASS_OR_ID['AG_FLOWCHART']}`,
|
||||||
'sequence': `.${CLASS_OR_ID['AG_SEQUENCE']}`,
|
sequence: `.${CLASS_OR_ID['AG_SEQUENCE']}`,
|
||||||
'mermaid': `.${CLASS_OR_ID['AG_MERMAID']}`,
|
mermaid: `.${CLASS_OR_ID['AG_MERMAID']}`,
|
||||||
'vega-lite': `.${CLASS_OR_ID['AG_VEGA_LITE']}`
|
'vega-lite': `.${CLASS_OR_ID['AG_VEGA_LITE']}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,16 +23,16 @@ import mermaidIcon from '../../../assets/pngicon/mermaid/2.png'
|
|||||||
import vegaIcon from '../../../assets/pngicon/chart/2.png'
|
import vegaIcon from '../../../assets/pngicon/chart/2.png'
|
||||||
|
|
||||||
const FUNCTION_TYPE_HASH = {
|
const FUNCTION_TYPE_HASH = {
|
||||||
'mermaid': mermaidIcon,
|
mermaid: mermaidIcon,
|
||||||
'flowchart': flowchartIcon,
|
flowchart: flowchartIcon,
|
||||||
'sequence': sequenceIcon,
|
sequence: sequenceIcon,
|
||||||
'vega-lite': vegaIcon,
|
'vega-lite': vegaIcon,
|
||||||
'table': newTableIcon,
|
table: newTableIcon,
|
||||||
'html': htmlIcon,
|
html: htmlIcon,
|
||||||
'multiplemath': mathblockIcon,
|
multiplemath: mathblockIcon,
|
||||||
'fencecode': codeIcon,
|
fencecode: codeIcon,
|
||||||
'indentcode': codeIcon,
|
indentcode: codeIcon,
|
||||||
'frontmatter': frontMatterIcon
|
frontmatter: frontMatterIcon
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function renderIcon (block) {
|
export default function renderIcon (block) {
|
||||||
|
@ -50,7 +50,7 @@ const renderToolBar = (type, tools, activeBlocks) => {
|
|||||||
}
|
}
|
||||||
}, iconVnode)
|
}, iconVnode)
|
||||||
})
|
})
|
||||||
let selector = `div.ag-tool-${type}.${CLASS_OR_ID['AG_TOOL_BAR']}`
|
const selector = `div.ag-tool-${type}.${CLASS_OR_ID['AG_TOOL_BAR']}`
|
||||||
|
|
||||||
return h(selector, {
|
return h(selector, {
|
||||||
attrs: {
|
attrs: {
|
||||||
|
@ -11,7 +11,7 @@ export default function softLineBreak (h, cursor, block, token, outerClass) {
|
|||||||
]
|
]
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
h(`span.${className}`, [ h(`span.${spaceClass}`, spaces), lineBreak ])
|
h(`span.${className}`, [h(`span.${spaceClass}`, spaces), lineBreak])
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ export default function htmlRuby (h, cursor, block, token, outerClass) {
|
|||||||
|
|
||||||
const previewSelector = `span.${CLASS_OR_ID['AG_RUBY_RENDER']}`
|
const previewSelector = `span.${CLASS_OR_ID['AG_RUBY_RENDER']}`
|
||||||
|
|
||||||
|
|
||||||
return children ? [
|
return children ? [
|
||||||
h(`span.${className}.${CLASS_OR_ID['AG_RUBY']}`, [
|
h(`span.${className}.${CLASS_OR_ID['AG_RUBY']}`, [
|
||||||
h(`span.${CLASS_OR_ID['AG_INLINE_RULE']}.${CLASS_OR_ID['AG_RUBY_TEXT']}`, content),
|
h(`span.${CLASS_OR_ID['AG_INLINE_RULE']}.${CLASS_OR_ID['AG_RUBY_TEXT']}`, content),
|
||||||
|
@ -2,36 +2,36 @@ import { escapeCharacters } from './escapeCharacter'
|
|||||||
|
|
||||||
/* eslint-disable no-useless-escape */
|
/* eslint-disable no-useless-escape */
|
||||||
export const beginRules = {
|
export const beginRules = {
|
||||||
'hr': /^(\*{3,}$|^\-{3,}$|^\_{3,}$)/,
|
hr: /^(\*{3,}$|^\-{3,}$|^\_{3,}$)/,
|
||||||
'code_fense': /^(`{3,})([^`]*)$/,
|
code_fense: /^(`{3,})([^`]*)$/,
|
||||||
'header': /(^ {0,3}#{1,6}(\s{1,}|$))/,
|
header: /(^ {0,3}#{1,6}(\s{1,}|$))/,
|
||||||
'reference_definition': /^( {0,3}\[)([^\]]+?)(\\*)(\]: *)(<?)([^\s>]+)(>?)(?:( +)(["'(]?)([^\n"'\(\)]+)\9)?( *)$/,
|
reference_definition: /^( {0,3}\[)([^\]]+?)(\\*)(\]: *)(<?)([^\s>]+)(>?)(?:( +)(["'(]?)([^\n"'\(\)]+)\9)?( *)$/,
|
||||||
|
|
||||||
// extra syntax (not belogs to GFM)
|
// extra syntax (not belogs to GFM)
|
||||||
'multiple_math': /^(\$\$)$/
|
multiple_math: /^(\$\$)$/
|
||||||
}
|
}
|
||||||
|
|
||||||
export const inlineRules = {
|
export const inlineRules = {
|
||||||
'strong': /^(\*\*|__)(?=\S)([\s\S]*?[^\s\\])(\\*)\1(?!(\*|_))/, // can nest
|
strong: /^(\*\*|__)(?=\S)([\s\S]*?[^\s\\])(\\*)\1(?!(\*|_))/, // can nest
|
||||||
'em': /^(\*|_)(?=\S)([\s\S]*?[^\s\*\\])(\\*)\1(?!\1)/, // can nest
|
em: /^(\*|_)(?=\S)([\s\S]*?[^\s\*\\])(\\*)\1(?!\1)/, // can nest
|
||||||
'inline_code': /^(`{1,3})([^`]+?|.{2,})\1/,
|
inline_code: /^(`{1,3})([^`]+?|.{2,})\1/,
|
||||||
'image': /^(\!\[)(.*?)(\\*)\]\((.*?)(\\*)\)/,
|
image: /^(\!\[)(.*?)(\\*)\]\((.*?)(\\*)\)/,
|
||||||
'link': /^(\[)((?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*?)(\\*)\]\((.*?)(\\*)\)/, // can nest
|
link: /^(\[)((?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*?)(\\*)\]\((.*?)(\\*)\)/, // can nest
|
||||||
'emoji': /^(:)([a-z_\d+-]+?)\1/,
|
emoji: /^(:)([a-z_\d+-]+?)\1/,
|
||||||
'del': /^(~{2})(?=\S)([\s\S]*?\S)(\\*)\1/, // can nest
|
del: /^(~{2})(?=\S)([\s\S]*?\S)(\\*)\1/, // can nest
|
||||||
'auto_link': /^(https?:\/\/[^\s]+)(?=\s|$)/,
|
auto_link: /^(https?:\/\/[^\s]+)(?=\s|$)/,
|
||||||
'reference_link': /^\[([^\]]+?)(\\*)\](?:\[([^\]]*?)(\\*)\])?/,
|
reference_link: /^\[([^\]]+?)(\\*)\](?:\[([^\]]*?)(\\*)\])?/,
|
||||||
'reference_image': /^\!\[([^\]]+?)(\\*)\](?:\[([^\]]*?)(\\*)\])?/,
|
reference_image: /^\!\[([^\]]+?)(\\*)\](?:\[([^\]]*?)(\\*)\])?/,
|
||||||
'tail_header': /^(\s{1,}#{1,})(\s*)$/,
|
tail_header: /^(\s{1,}#{1,})(\s*)$/,
|
||||||
'html_tag': /^(<!--[\s\S]*?-->|(<([a-zA-Z]{1}[a-zA-Z\d-]*) *[_\.\-/:a-zA-Z\d='";\? *]* *(?:\/)?>)(?:([\s\S]*?)(<\/\3 *>))?)/, // raw html
|
html_tag: /^(<!--[\s\S]*?-->|(<([a-zA-Z]{1}[a-zA-Z\d-]*) *[_\.\-/:a-zA-Z\d='";\? *]* *(?:\/)?>)(?:([\s\S]*?)(<\/\3 *>))?)/, // raw html
|
||||||
'html_escape': new RegExp(`^(${escapeCharacters.join('|')})`, 'i'),
|
html_escape: new RegExp(`^(${escapeCharacters.join('|')})`, 'i'),
|
||||||
'soft_line_break': /^(\n)(?!\n)/,
|
soft_line_break: /^(\n)(?!\n)/,
|
||||||
'hard_line_break': /^( {2,})(\n)(?!\n)/,
|
hard_line_break: /^( {2,})(\n)(?!\n)/,
|
||||||
|
|
||||||
// patched math marker `$`
|
// patched math marker `$`
|
||||||
'backlash': /^(\\)([\\`*{}\[\]()#+\-.!_>~:\|\<\>$]{1})/,
|
backlash: /^(\\)([\\`*{}\[\]()#+\-.!_>~:\|\<\>$]{1})/,
|
||||||
|
|
||||||
// extra (not belongs to GFM)
|
// extra (not belongs to GFM)
|
||||||
'inline_math': /^(\$)([^\$]*?[^\$\\])(\\*)\1(?!\1)/
|
inline_math: /^(\$)([^\$]*?[^\$\\])(\\*)\1(?!\1)/
|
||||||
}
|
}
|
||||||
/* eslint-enable no-useless-escape */
|
/* eslint-enable no-useless-escape */
|
||||||
|
@ -66,7 +66,7 @@ function initLoadLanguage (Prism) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (arr && !arr.length) {
|
if (arr && !arr.length) {
|
||||||
return Promise.reject('The first parameter should be a list of load languages or single language.')
|
return Promise.reject(new Error('The first parameter should be a list of load languages or single language.'))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.isArray(arr)) {
|
if (!Array.isArray(arr)) {
|
||||||
|
@ -51,7 +51,7 @@ export const getOffsetOfParagraph = (node, paragraph) => {
|
|||||||
do {
|
do {
|
||||||
preSibling = preSibling.previousSibling
|
preSibling = preSibling.previousSibling
|
||||||
if (preSibling) {
|
if (preSibling) {
|
||||||
offset += getTextContent(preSibling, [ CLASS_OR_ID['AG_MATH_RENDER'], CLASS_OR_ID['AG_RUBY_RENDER'] ]).length
|
offset += getTextContent(preSibling, [CLASS_OR_ID['AG_MATH_RENDER'], CLASS_OR_ID['AG_RUBY_RENDER']]).length
|
||||||
}
|
}
|
||||||
} while (preSibling)
|
} while (preSibling)
|
||||||
return (node === paragraph || node.parentNode === paragraph)
|
return (node === paragraph || node.parentNode === paragraph)
|
||||||
@ -72,7 +72,7 @@ export const findNearestParagraph = node => {
|
|||||||
|
|
||||||
export const findOutMostParagraph = node => {
|
export const findOutMostParagraph = node => {
|
||||||
do {
|
do {
|
||||||
let parentNode = node.parentNode
|
const parentNode = node.parentNode
|
||||||
if (isMuyaEditorElement(parentNode) && isAganippeParagraph(node)) return node
|
if (isMuyaEditorElement(parentNode) && isAganippeParagraph(node)) return node
|
||||||
node = parentNode
|
node = parentNode
|
||||||
} while (node)
|
} while (node)
|
||||||
|
@ -209,7 +209,7 @@ class Selection {
|
|||||||
// to move the cursor back to the start of the correct paragraph
|
// to move the cursor back to the start of the correct paragraph
|
||||||
importSelectionMoveCursorPastBlocks (root, index = 1, range) {
|
importSelectionMoveCursorPastBlocks (root, index = 1, range) {
|
||||||
const treeWalker = this.doc.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, filterOnlyParentElements, false)
|
const treeWalker = this.doc.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, filterOnlyParentElements, false)
|
||||||
let startContainer = range.startContainer
|
const startContainer = range.startContainer
|
||||||
let startBlock
|
let startBlock
|
||||||
let targetNode
|
let targetNode
|
||||||
let currIndex = 0
|
let currIndex = 0
|
||||||
@ -279,8 +279,8 @@ class Selection {
|
|||||||
const { left } = this.getCaretOffsets(root)
|
const { left } = this.getCaretOffsets(root)
|
||||||
const markedText = root.textContent
|
const markedText = root.textContent
|
||||||
const { type, info } = getCursorPositionWithinMarkedText(markedText, left)
|
const { type, info } = getCursorPositionWithinMarkedText(markedText, left)
|
||||||
let pre = markedText.slice(0, left)
|
const pre = markedText.slice(0, left)
|
||||||
let post = markedText.slice(left)
|
const post = markedText.slice(left)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'OUT':
|
case 'OUT':
|
||||||
return {
|
return {
|
||||||
@ -425,7 +425,7 @@ class Selection {
|
|||||||
let count = 0
|
let count = 0
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
const child = childNodes[i]
|
const child = childNodes[i]
|
||||||
const textLength = getTextContent(child, [ CLASS_OR_ID['AG_MATH_RENDER'], CLASS_OR_ID['AG_RUBY_RENDER'] ]).length
|
const textLength = getTextContent(child, [CLASS_OR_ID['AG_MATH_RENDER'], CLASS_OR_ID['AG_RUBY_RENDER']]).length
|
||||||
if (child.classList && child.classList.contains(CLASS_OR_ID['AG_FRONT_ICON'])) continue
|
if (child.classList && child.classList.contains(CLASS_OR_ID['AG_FRONT_ICON'])) continue
|
||||||
if (count + textLength >= offset) {
|
if (count + textLength >= offset) {
|
||||||
if (
|
if (
|
||||||
@ -547,9 +547,9 @@ class Selection {
|
|||||||
aOffset = 0
|
aOffset = 0
|
||||||
if (preElement) {
|
if (preElement) {
|
||||||
aOffset += getOffsetOfParagraph(preElement, anchorParagraph)
|
aOffset += getOffsetOfParagraph(preElement, anchorParagraph)
|
||||||
aOffset += getTextContent(preElement, [ CLASS_OR_ID['AG_MATH_RENDER'], CLASS_OR_ID['AG_RUBY_RENDER'] ]).length
|
aOffset += getTextContent(preElement, [CLASS_OR_ID['AG_MATH_RENDER'], CLASS_OR_ID['AG_RUBY_RENDER']]).length
|
||||||
}
|
}
|
||||||
aOffset += getTextContent(imageWrapper, [ CLASS_OR_ID['AG_MATH_RENDER'], CLASS_OR_ID['AG_RUBY_RENDER'] ]).length
|
aOffset += getTextContent(imageWrapper, [CLASS_OR_ID['AG_MATH_RENDER'], CLASS_OR_ID['AG_RUBY_RENDER']]).length
|
||||||
fOffset = aOffset
|
fOffset = aOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,10 +563,10 @@ class Selection {
|
|||||||
aOffset = 0
|
aOffset = 0
|
||||||
if (preElement) {
|
if (preElement) {
|
||||||
aOffset += getOffsetOfParagraph(preElement, anchorParagraph)
|
aOffset += getOffsetOfParagraph(preElement, anchorParagraph)
|
||||||
aOffset += getTextContent(preElement, [ CLASS_OR_ID['AG_MATH_RENDER'], CLASS_OR_ID['AG_RUBY_RENDER'] ]).length
|
aOffset += getTextContent(preElement, [CLASS_OR_ID['AG_MATH_RENDER'], CLASS_OR_ID['AG_RUBY_RENDER']]).length
|
||||||
}
|
}
|
||||||
if (anchorOffset === 3) {
|
if (anchorOffset === 3) {
|
||||||
aOffset += getTextContent(imageWrapper, [ CLASS_OR_ID['AG_MATH_RENDER'], CLASS_OR_ID['AG_RUBY_RENDER'] ]).length
|
aOffset += getTextContent(imageWrapper, [CLASS_OR_ID['AG_MATH_RENDER'], CLASS_OR_ID['AG_RUBY_RENDER']]).length
|
||||||
}
|
}
|
||||||
fOffset = aOffset
|
fOffset = aOffset
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import './index.css'
|
|||||||
|
|
||||||
class CodePicker extends BaseScrollFloat {
|
class CodePicker extends BaseScrollFloat {
|
||||||
static pluginName = 'codePicker'
|
static pluginName = 'codePicker'
|
||||||
|
|
||||||
constructor (muya) {
|
constructor (muya) {
|
||||||
const name = 'ag-list-picker'
|
const name = 'ag-list-picker'
|
||||||
super(muya, name)
|
super(muya, name)
|
||||||
|
@ -5,6 +5,7 @@ import './index.css'
|
|||||||
|
|
||||||
class EmojiPicker extends BaseScrollFloat {
|
class EmojiPicker extends BaseScrollFloat {
|
||||||
static pluginName = 'emojiPicker'
|
static pluginName = 'emojiPicker'
|
||||||
|
|
||||||
constructor (muya) {
|
constructor (muya) {
|
||||||
const name = 'ag-emoji-picker'
|
const name = 'ag-emoji-picker'
|
||||||
super(muya, name)
|
super(muya, name)
|
||||||
|
@ -9,7 +9,7 @@ for (const emoji of emojis) {
|
|||||||
if (emojisForSearch[newEmoji.category]) {
|
if (emojisForSearch[newEmoji.category]) {
|
||||||
emojisForSearch[newEmoji.category].push(newEmoji)
|
emojisForSearch[newEmoji.category].push(newEmoji)
|
||||||
} else {
|
} else {
|
||||||
emojisForSearch[newEmoji.category] = [ newEmoji ]
|
emojisForSearch[newEmoji.category] = [newEmoji]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ const defaultOptions = {
|
|||||||
|
|
||||||
class FormatPicker extends BaseFloat {
|
class FormatPicker extends BaseFloat {
|
||||||
static pluginName = 'formatPicker'
|
static pluginName = 'formatPicker'
|
||||||
|
|
||||||
constructor (muya, options = {}) {
|
constructor (muya, options = {}) {
|
||||||
const name = 'ag-format-picker'
|
const name = 'ag-format-picker'
|
||||||
const opts = Object.assign({}, defaultOptions, options)
|
const opts = Object.assign({}, defaultOptions, options)
|
||||||
|
@ -20,6 +20,7 @@ const defaultOptions = {
|
|||||||
|
|
||||||
class FrontMenu extends BaseFloat {
|
class FrontMenu extends BaseFloat {
|
||||||
static pluginName = 'frontMenu'
|
static pluginName = 'frontMenu'
|
||||||
|
|
||||||
constructor (muya, options = {}) {
|
constructor (muya, options = {}) {
|
||||||
const name = 'ag-front-menu'
|
const name = 'ag-front-menu'
|
||||||
const opts = Object.assign({}, defaultOptions, options)
|
const opts = Object.assign({}, defaultOptions, options)
|
||||||
|
@ -14,6 +14,7 @@ const iconhash = {
|
|||||||
|
|
||||||
class ImagePathPicker extends BaseScrollFloat {
|
class ImagePathPicker extends BaseScrollFloat {
|
||||||
static pluginName = 'imagePathPicker'
|
static pluginName = 'imagePathPicker'
|
||||||
|
|
||||||
constructor (muya) {
|
constructor (muya) {
|
||||||
const name = 'ag-list-picker'
|
const name = 'ag-list-picker'
|
||||||
super(muya, name)
|
super(muya, name)
|
||||||
@ -41,7 +42,7 @@ class ImagePathPicker extends BaseScrollFloat {
|
|||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { renderArray, oldVnode, scrollElement, activeItem } = this
|
const { renderArray, oldVnode, scrollElement, activeItem } = this
|
||||||
let children = renderArray.map((item) => {
|
const children = renderArray.map((item) => {
|
||||||
const { text, iconClass } = item
|
const { text, iconClass } = item
|
||||||
const icon = h('div.icon-wrapper', h('svg', {
|
const icon = h('div.icon-wrapper', h('svg', {
|
||||||
attrs: {
|
attrs: {
|
||||||
|
@ -8,6 +8,7 @@ import './index.css'
|
|||||||
|
|
||||||
class ImageSelector extends BaseFloat {
|
class ImageSelector extends BaseFloat {
|
||||||
static pluginName = 'imageSelector'
|
static pluginName = 'imageSelector'
|
||||||
|
|
||||||
constructor (muya) {
|
constructor (muya) {
|
||||||
const name = 'ag-image-selector'
|
const name = 'ag-image-selector'
|
||||||
const options = {
|
const options = {
|
||||||
@ -35,6 +36,7 @@ class ImageSelector extends BaseFloat {
|
|||||||
this.floatBox.classList.add('ag-image-selector-wrapper')
|
this.floatBox.classList.add('ag-image-selector-wrapper')
|
||||||
this.listen()
|
this.listen()
|
||||||
}
|
}
|
||||||
|
|
||||||
listen () {
|
listen () {
|
||||||
super.listen()
|
super.listen()
|
||||||
const { eventCenter } = this.muya
|
const { eventCenter } = this.muya
|
||||||
|
@ -30,7 +30,6 @@ const COMMAND_KEY = isOsx ? '⌘' : '⌃'
|
|||||||
// Caps Lock ⇪
|
// Caps Lock ⇪
|
||||||
// Fn
|
// Fn
|
||||||
|
|
||||||
|
|
||||||
// Command (or Cmd) ⌘
|
// Command (or Cmd) ⌘
|
||||||
// Shift ⇧
|
// Shift ⇧
|
||||||
// Option (or Alt) ⌥
|
// Option (or Alt) ⌥
|
||||||
@ -38,7 +37,6 @@ const COMMAND_KEY = isOsx ? '⌘' : '⌃'
|
|||||||
// Caps Lock ⇪
|
// Caps Lock ⇪
|
||||||
// Fn
|
// Fn
|
||||||
|
|
||||||
|
|
||||||
export const quicInsertObj = {
|
export const quicInsertObj = {
|
||||||
'basic block': [{
|
'basic block': [{
|
||||||
title: 'Paragraph',
|
title: 'Paragraph',
|
||||||
@ -59,7 +57,7 @@ export const quicInsertObj = {
|
|||||||
shortCut: `⌥${COMMAND_KEY}Y`,
|
shortCut: `⌥${COMMAND_KEY}Y`,
|
||||||
icon: frontMatterIcon
|
icon: frontMatterIcon
|
||||||
}],
|
}],
|
||||||
'header': [{
|
header: [{
|
||||||
title: 'Header 1',
|
title: 'Header 1',
|
||||||
subTitle: '# Lorem Ipsum is simply ...',
|
subTitle: '# Lorem Ipsum is simply ...',
|
||||||
label: 'heading 1',
|
label: 'heading 1',
|
||||||
@ -146,7 +144,7 @@ export const quicInsertObj = {
|
|||||||
shortCut: `⌥${COMMAND_KEY}X`,
|
shortCut: `⌥${COMMAND_KEY}X`,
|
||||||
icon: todoListIcon
|
icon: todoListIcon
|
||||||
}],
|
}],
|
||||||
'diagram': [{
|
diagram: [{
|
||||||
title: 'Vega Chart',
|
title: 'Vega Chart',
|
||||||
subTitle: 'Render flow chart by vega-lite.js.',
|
subTitle: 'Render flow chart by vega-lite.js.',
|
||||||
label: 'vega-lite',
|
label: 'vega-lite',
|
||||||
|
@ -7,6 +7,7 @@ import './index.css'
|
|||||||
|
|
||||||
class QuickInsert extends BaseScrollFloat {
|
class QuickInsert extends BaseScrollFloat {
|
||||||
static pluginName = 'quickInsert'
|
static pluginName = 'quickInsert'
|
||||||
|
|
||||||
constructor (muya) {
|
constructor (muya) {
|
||||||
const name = 'ag-quick-insert'
|
const name = 'ag-quick-insert'
|
||||||
super(muya, name)
|
super(muya, name)
|
||||||
@ -121,8 +122,8 @@ class QuickInsert extends BaseScrollFloat {
|
|||||||
selectItem (item) {
|
selectItem (item) {
|
||||||
const { contentState } = this.muya
|
const { contentState } = this.muya
|
||||||
this.block.text = ''
|
this.block.text = ''
|
||||||
let { key } = this.block
|
const { key } = this.block
|
||||||
let offset = 0
|
const offset = 0
|
||||||
contentState.cursor = {
|
contentState.cursor = {
|
||||||
start: { key, offset },
|
start: { key, offset },
|
||||||
end: { key, offset }
|
end: { key, offset }
|
||||||
|
@ -5,6 +5,7 @@ import { EVENT_KEYS } from '../../config'
|
|||||||
|
|
||||||
class TablePicker extends BaseFloat {
|
class TablePicker extends BaseFloat {
|
||||||
static pluginName = 'tablePicker'
|
static pluginName = 'tablePicker'
|
||||||
|
|
||||||
constructor (muya) {
|
constructor (muya) {
|
||||||
const name = 'ag-table-picker'
|
const name = 'ag-table-picker'
|
||||||
super(muya, name)
|
super(muya, name)
|
||||||
@ -124,7 +125,7 @@ class TablePicker extends BaseFloat {
|
|||||||
|
|
||||||
keyupHandler (event, type) {
|
keyupHandler (event, type) {
|
||||||
let number = +this.select[type]
|
let number = +this.select[type]
|
||||||
let value = +event.target.value
|
const value = +event.target.value
|
||||||
if (event.key === EVENT_KEYS.ArrowUp) {
|
if (event.key === EVENT_KEYS.ArrowUp) {
|
||||||
number++
|
number++
|
||||||
} else if (event.key === EVENT_KEYS.ArrowDown) {
|
} else if (event.key === EVENT_KEYS.ArrowDown) {
|
||||||
|
@ -46,7 +46,7 @@ class ExportHtml {
|
|||||||
theme: 'default'
|
theme: 'default'
|
||||||
})
|
})
|
||||||
mermaid.init(undefined, this.exportContainer.querySelectorAll('div.mermaid'))
|
mermaid.init(undefined, this.exportContainer.querySelectorAll('div.mermaid'))
|
||||||
if (this.muya){
|
if (this.muya) {
|
||||||
mermaid.initialize({
|
mermaid.initialize({
|
||||||
theme: this.muya.options.mermaidTheme
|
theme: this.muya.options.mermaidTheme
|
||||||
})
|
})
|
||||||
@ -56,8 +56,8 @@ class ExportHtml {
|
|||||||
async renderDiagram () {
|
async renderDiagram () {
|
||||||
const selector = 'code.language-vega-lite, code.language-flowchart, code.language-sequence'
|
const selector = 'code.language-vega-lite, code.language-flowchart, code.language-sequence'
|
||||||
const RENDER_MAP = {
|
const RENDER_MAP = {
|
||||||
'flowchart': flowchart,
|
flowchart: flowchart,
|
||||||
'sequence': Diagram,
|
sequence: Diagram,
|
||||||
'vega-lite': vegaEmbed
|
'vega-lite': vegaEmbed
|
||||||
}
|
}
|
||||||
const codes = this.exportContainer.querySelectorAll(selector)
|
const codes = this.exportContainer.querySelectorAll(selector)
|
||||||
@ -74,7 +74,9 @@ class ExportHtml {
|
|||||||
Object.assign(options, { theme: 'hand' })
|
Object.assign(options, { theme: 'hand' })
|
||||||
} else if (functionType === 'vega-lite') {
|
} else if (functionType === 'vega-lite') {
|
||||||
Object.assign(options, {
|
Object.assign(options, {
|
||||||
actions: false, tooltip: false, renderer: 'svg',
|
actions: false,
|
||||||
|
tooltip: false,
|
||||||
|
renderer: 'svg',
|
||||||
theme: 'latimes' // only render light theme
|
theme: 'latimes' // only render light theme
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ class ExportMarkdown {
|
|||||||
}
|
}
|
||||||
listInfo.listCount++
|
listInfo.listCount++
|
||||||
|
|
||||||
const delimiter = bulletMarkerOrDelimiter ? bulletMarkerOrDelimiter : '.'
|
const delimiter = bulletMarkerOrDelimiter || '.'
|
||||||
itemMarker = `${n}${delimiter} `
|
itemMarker = `${n}${delimiter} `
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ const turnSoftBreakToSpan = html => {
|
|||||||
const params = []
|
const params = []
|
||||||
let i = 0
|
let i = 0
|
||||||
const len = tokens.length
|
const len = tokens.length
|
||||||
for (; i< len; i++) {
|
for (; i < len; i++) {
|
||||||
let text = tokens[i]
|
let text = tokens[i]
|
||||||
if (i === 0 && startLen !== 0) {
|
if (i === 0 && startLen !== 0) {
|
||||||
text = '\n'.repeat(startLen) + text
|
text = '\n'.repeat(startLen) + text
|
||||||
@ -81,7 +81,7 @@ const importRegister = ContentState => {
|
|||||||
let token
|
let token
|
||||||
let block
|
let block
|
||||||
let value
|
let value
|
||||||
let parentList = [ rootState ]
|
const parentList = [rootState]
|
||||||
const languageLoaded = new Set()
|
const languageLoaded = new Set()
|
||||||
|
|
||||||
while ((token = tokens.shift())) {
|
while ((token = tokens.shift())) {
|
||||||
@ -133,7 +133,7 @@ const importRegister = ContentState => {
|
|||||||
|
|
||||||
const headingContent = this.createBlock('span', {
|
const headingContent = this.createBlock('span', {
|
||||||
text: value,
|
text: value,
|
||||||
functionType: headingStyle === 'atx'? 'atxLine' : 'paragraphContent'
|
functionType: headingStyle === 'atx' ? 'atxLine' : 'paragraphContent'
|
||||||
})
|
})
|
||||||
|
|
||||||
this.appendChild(block, headingContent)
|
this.appendChild(block, headingContent)
|
||||||
@ -363,8 +363,8 @@ const importRegister = ContentState => {
|
|||||||
const { anchor, focus } = this.cursor
|
const { anchor, focus } = this.cursor
|
||||||
const anchorBlock = this.getBlock(anchor.key)
|
const anchorBlock = this.getBlock(anchor.key)
|
||||||
const focusBlock = this.getBlock(focus.key)
|
const focusBlock = this.getBlock(focus.key)
|
||||||
let { text: anchorText } = anchorBlock
|
const { text: anchorText } = anchorBlock
|
||||||
let { text: focusText } = focusBlock
|
const { text: focusText } = focusBlock
|
||||||
if (anchor.key === focus.key) {
|
if (anchor.key === focus.key) {
|
||||||
const minOffset = Math.min(anchor.offset, focus.offset)
|
const minOffset = Math.min(anchor.offset, focus.offset)
|
||||||
const maxOffset = Math.max(anchor.offset, focus.offset)
|
const maxOffset = Math.max(anchor.offset, focus.offset)
|
||||||
|
492
src/renderer/codeMirror/modes.js
vendored
492
src/renderer/codeMirror/modes.js
vendored
@ -1,331 +1,331 @@
|
|||||||
const languages = [{
|
const languages = [{
|
||||||
'name': 'objectivec',
|
name: 'objectivec',
|
||||||
'mode': 'clike',
|
mode: 'clike',
|
||||||
'mime': 'text/x-objectivec'
|
mime: 'text/x-objectivec'
|
||||||
}, {
|
}, {
|
||||||
'name': 'swift',
|
name: 'swift',
|
||||||
'mode': 'swift',
|
mode: 'swift',
|
||||||
'mime': 'text/x-swift'
|
mime: 'text/x-swift'
|
||||||
}, {
|
}, {
|
||||||
'name': 'c_cpp',
|
name: 'c_cpp',
|
||||||
'mode': 'clike',
|
mode: 'clike',
|
||||||
'mime': 'text/x-csrc'
|
mime: 'text/x-csrc'
|
||||||
}, {
|
}, {
|
||||||
'name': 'c',
|
name: 'c',
|
||||||
'mode': 'clike',
|
mode: 'clike',
|
||||||
'mime': 'text/x-csrc'
|
mime: 'text/x-csrc'
|
||||||
}, {
|
}, {
|
||||||
'name': 'c++',
|
name: 'c++',
|
||||||
'mode': 'clike',
|
mode: 'clike',
|
||||||
'mime': 'text/x-c++src'
|
mime: 'text/x-c++src'
|
||||||
}, {
|
}, {
|
||||||
'name': 'cmake',
|
name: 'cmake',
|
||||||
'mode': 'cmake',
|
mode: 'cmake',
|
||||||
'mime': 'text/x-cmake'
|
mime: 'text/x-cmake'
|
||||||
}, {
|
}, {
|
||||||
'name': 'lisp',
|
name: 'lisp',
|
||||||
'mode': 'commonlisp',
|
mode: 'commonlisp',
|
||||||
'mime': 'text/x-common-lisp'
|
mime: 'text/x-common-lisp'
|
||||||
}, {
|
}, {
|
||||||
'name': 'pascal',
|
name: 'pascal',
|
||||||
'mode': 'pascal',
|
mode: 'pascal',
|
||||||
'mime': 'text/x-pascal'
|
mime: 'text/x-pascal'
|
||||||
}, {
|
}, {
|
||||||
'name': 'eiffel',
|
name: 'eiffel',
|
||||||
'mode': 'eiffel',
|
mode: 'eiffel',
|
||||||
'mime': 'text/x-eiffel'
|
mime: 'text/x-eiffel'
|
||||||
}, {
|
}, {
|
||||||
'name': 'yaml',
|
name: 'yaml',
|
||||||
'mode': 'yaml',
|
mode: 'yaml',
|
||||||
'mime': 'text/x-yaml'
|
mime: 'text/x-yaml'
|
||||||
}, {
|
}, {
|
||||||
'name': 'xml',
|
name: 'xml',
|
||||||
'mode': 'xml',
|
mode: 'xml',
|
||||||
'mime': 'application/xml'
|
mime: 'application/xml'
|
||||||
}, {
|
}, {
|
||||||
'name': 'django',
|
name: 'django',
|
||||||
'mode': 'django',
|
mode: 'django',
|
||||||
'mime': 'text/x-django'
|
mime: 'text/x-django'
|
||||||
}, {
|
}, {
|
||||||
'name': 'clojure',
|
name: 'clojure',
|
||||||
'mode': 'clojure',
|
mode: 'clojure',
|
||||||
'mime': 'text/x-clojure'
|
mime: 'text/x-clojure'
|
||||||
}, {
|
}, {
|
||||||
'name': 'crystal',
|
name: 'crystal',
|
||||||
'mode': 'crystal',
|
mode: 'crystal',
|
||||||
'mime': 'text/x-crystal'
|
mime: 'text/x-crystal'
|
||||||
}, {
|
}, {
|
||||||
'name': 'ruby',
|
name: 'ruby',
|
||||||
'mode': 'ruby',
|
mode: 'ruby',
|
||||||
'mime': 'text/x-ruby'
|
mime: 'text/x-ruby'
|
||||||
}, {
|
}, {
|
||||||
'name': 'python',
|
name: 'python',
|
||||||
'mode': 'python',
|
mode: 'python',
|
||||||
'mime': 'text/x-python'
|
mime: 'text/x-python'
|
||||||
}, {
|
}, {
|
||||||
'name': 'sh',
|
name: 'sh',
|
||||||
'mode': 'shell',
|
mode: 'shell',
|
||||||
'mime': 'text/x-sh'
|
mime: 'text/x-sh'
|
||||||
}, { /* alias */
|
}, { /* alias */
|
||||||
'name': 'shell',
|
name: 'shell',
|
||||||
'mode': 'shell',
|
mode: 'shell',
|
||||||
'mime': 'text/x-sh'
|
mime: 'text/x-sh'
|
||||||
}, {
|
}, {
|
||||||
'name': 'less',
|
name: 'less',
|
||||||
'mode': 'css',
|
mode: 'css',
|
||||||
'mime': 'text/css'
|
mime: 'text/css'
|
||||||
}, {
|
}, {
|
||||||
'name': 'php',
|
name: 'php',
|
||||||
'mode': 'php',
|
mode: 'php',
|
||||||
'mime': 'application/x-httpd-php'
|
mime: 'application/x-httpd-php'
|
||||||
}, {
|
}, {
|
||||||
'name': 'json',
|
name: 'json',
|
||||||
'mode': 'javascript',
|
mode: 'javascript',
|
||||||
'mime': 'application/json'
|
mime: 'application/json'
|
||||||
}, {
|
}, {
|
||||||
'name': 'smarty',
|
name: 'smarty',
|
||||||
'mode': 'smarty',
|
mode: 'smarty',
|
||||||
'mime': 'text/x-smarty'
|
mime: 'text/x-smarty'
|
||||||
}, {
|
}, {
|
||||||
'name': 'cobol',
|
name: 'cobol',
|
||||||
'mode': 'cobol',
|
mode: 'cobol',
|
||||||
'mime': 'text/x-cobol'
|
mime: 'text/x-cobol'
|
||||||
}, {
|
}, {
|
||||||
'name': 'go',
|
name: 'go',
|
||||||
'mode': 'go',
|
mode: 'go',
|
||||||
'mime': 'text/x-go'
|
mime: 'text/x-go'
|
||||||
}, { /* alias */
|
}, { /* alias */
|
||||||
'name': 'golang',
|
name: 'golang',
|
||||||
'mode': 'go',
|
mode: 'go',
|
||||||
'mime': 'text/x-go'
|
mime: 'text/x-go'
|
||||||
}, {
|
}, {
|
||||||
'name': 'makefile',
|
name: 'makefile',
|
||||||
'mode': 'shell', /* makefile syntax is not supported by CodeMirror */
|
mode: 'shell', /* makefile syntax is not supported by CodeMirror */
|
||||||
'mime': 'text/x-sh'
|
mime: 'text/x-sh'
|
||||||
}, {
|
}, {
|
||||||
'name': 'ocaml',
|
name: 'ocaml',
|
||||||
'mode': 'mllike',
|
mode: 'mllike',
|
||||||
'mime': 'text/x-ocaml'
|
mime: 'text/x-ocaml'
|
||||||
}, {
|
}, {
|
||||||
'name': 'textile',
|
name: 'textile',
|
||||||
'mode': 'textile',
|
mode: 'textile',
|
||||||
'mime': 'text/x-textile'
|
mime: 'text/x-textile'
|
||||||
}, {
|
}, {
|
||||||
'name': 'd',
|
name: 'd',
|
||||||
'mode': 'd',
|
mode: 'd',
|
||||||
'mime': 'text/x-d'
|
mime: 'text/x-d'
|
||||||
}, {
|
}, {
|
||||||
'name': 'jade',
|
name: 'jade',
|
||||||
'mode': 'pug',
|
mode: 'pug',
|
||||||
'mime': 'text/x-pug'
|
mime: 'text/x-pug'
|
||||||
}, {
|
}, {
|
||||||
'name': 'lua',
|
name: 'lua',
|
||||||
'mode': 'lua',
|
mode: 'lua',
|
||||||
'mime': 'text/x-lua'
|
mime: 'text/x-lua'
|
||||||
}, {
|
}, {
|
||||||
'name': 'coffee',
|
name: 'coffee',
|
||||||
'mode': 'coffeescript',
|
mode: 'coffeescript',
|
||||||
'mime': 'text/x-coffeescript'
|
mime: 'text/x-coffeescript'
|
||||||
}, {
|
}, {
|
||||||
'name': 'html',
|
name: 'html',
|
||||||
'mode': 'htmlmixed',
|
mode: 'htmlmixed',
|
||||||
'mime': 'text/html'
|
mime: 'text/html'
|
||||||
}, {
|
}, {
|
||||||
'name': 'pgsql',
|
name: 'pgsql',
|
||||||
'mode': 'sql',
|
mode: 'sql',
|
||||||
'mime': 'text/x-sql'
|
mime: 'text/x-sql'
|
||||||
}, {
|
}, {
|
||||||
'name': 'haskell',
|
name: 'haskell',
|
||||||
'mode': 'haskell',
|
mode: 'haskell',
|
||||||
'mime': 'text/x-haskell'
|
mime: 'text/x-haskell'
|
||||||
}, {
|
}, {
|
||||||
'name': 'jsp',
|
name: 'jsp',
|
||||||
'mode': 'htmlembedded',
|
mode: 'htmlembedded',
|
||||||
'mime': 'application/x-jsp'
|
mime: 'application/x-jsp'
|
||||||
}, {
|
}, {
|
||||||
'name': 'tcl',
|
name: 'tcl',
|
||||||
'mode': 'tcl',
|
mode: 'tcl',
|
||||||
'mime': 'text/x-tcl'
|
mime: 'text/x-tcl'
|
||||||
}, {
|
}, {
|
||||||
'name': 'ini',
|
name: 'ini',
|
||||||
'mode': 'properties',
|
mode: 'properties',
|
||||||
'mime': 'text/x-properties'
|
mime: 'text/x-properties'
|
||||||
}, {
|
}, {
|
||||||
'name': 'jsoniq',
|
name: 'jsoniq',
|
||||||
'mode': 'javascript',
|
mode: 'javascript',
|
||||||
'mime': 'application/json'
|
mime: 'application/json'
|
||||||
}, {
|
}, {
|
||||||
'name': 'vhdl',
|
name: 'vhdl',
|
||||||
'mode': 'vhdl',
|
mode: 'vhdl',
|
||||||
'mime': 'text/x-vhdl'
|
mime: 'text/x-vhdl'
|
||||||
}, {
|
}, {
|
||||||
'name': 'verilog',
|
name: 'verilog',
|
||||||
'mode': 'verilog',
|
mode: 'verilog',
|
||||||
'mime': 'text/x-systemverilog'
|
mime: 'text/x-systemverilog'
|
||||||
}, {
|
}, {
|
||||||
'name': 'csharp',
|
name: 'csharp',
|
||||||
'mode': 'clike',
|
mode: 'clike',
|
||||||
'mime': 'text/x-csharp'
|
mime: 'text/x-csharp'
|
||||||
}, {
|
}, {
|
||||||
'name': 'rust',
|
name: 'rust',
|
||||||
'mode': 'rust',
|
mode: 'rust',
|
||||||
'mime': 'text/x-rustsrc'
|
mime: 'text/x-rustsrc'
|
||||||
}, {
|
}, {
|
||||||
'name': 'livescript',
|
name: 'livescript',
|
||||||
'mode': 'livescript',
|
mode: 'livescript',
|
||||||
'mime': 'text/x-livescript'
|
mime: 'text/x-livescript'
|
||||||
}, {
|
}, {
|
||||||
'name': 'jsx',
|
name: 'jsx',
|
||||||
'mode': 'jsx',
|
mode: 'jsx',
|
||||||
'mime': 'text/jsx'
|
mime: 'text/jsx'
|
||||||
}, {
|
}, {
|
||||||
'name': 'protobuf',
|
name: 'protobuf',
|
||||||
'mode': 'protobuf',
|
mode: 'protobuf',
|
||||||
'mime': 'text/x-protobuf'
|
mime: 'text/x-protobuf'
|
||||||
}, {
|
}, {
|
||||||
'name': 'markdown',
|
name: 'markdown',
|
||||||
'mode': 'gfm',
|
mode: 'gfm',
|
||||||
'mime': 'text/x-gfm'
|
mime: 'text/x-gfm'
|
||||||
}, {
|
}, {
|
||||||
'name': 'rst',
|
name: 'rst',
|
||||||
'mode': 'rst',
|
mode: 'rst',
|
||||||
'mime': 'text/x-rst'
|
mime: 'text/x-rst'
|
||||||
}, {
|
}, {
|
||||||
'name': 'LaTeX',
|
name: 'LaTeX',
|
||||||
'mode': 'stex',
|
mode: 'stex',
|
||||||
'mime': 'text/x-latex'
|
mime: 'text/x-latex'
|
||||||
}, {
|
}, {
|
||||||
'name': 'java',
|
name: 'java',
|
||||||
'mode': 'clike',
|
mode: 'clike',
|
||||||
'mime': 'text/x-java'
|
mime: 'text/x-java'
|
||||||
}, {
|
}, {
|
||||||
'name': 'kotlin',
|
name: 'kotlin',
|
||||||
'mode': 'clike',
|
mode: 'clike',
|
||||||
'mime': 'text/x-kotlin'
|
mime: 'text/x-kotlin'
|
||||||
}, {
|
}, {
|
||||||
'name': 'javascript',
|
name: 'javascript',
|
||||||
'mode': 'javascript',
|
mode: 'javascript',
|
||||||
'mime': 'text/javascript'
|
mime: 'text/javascript'
|
||||||
}, {
|
}, {
|
||||||
'name': 'erlang',
|
name: 'erlang',
|
||||||
'mode': 'erlang',
|
mode: 'erlang',
|
||||||
'mime': 'text/x-erlang'
|
mime: 'text/x-erlang'
|
||||||
}, {
|
}, {
|
||||||
'name': 'scheme',
|
name: 'scheme',
|
||||||
'mode': 'scheme',
|
mode: 'scheme',
|
||||||
'mime': 'text/x-scheme'
|
mime: 'text/x-scheme'
|
||||||
}, {
|
}, {
|
||||||
'name': 'sass',
|
name: 'sass',
|
||||||
'mode': 'sass',
|
mode: 'sass',
|
||||||
'mime': 'text/x-sass'
|
mime: 'text/x-sass'
|
||||||
}, {
|
}, {
|
||||||
'name': 'groovy',
|
name: 'groovy',
|
||||||
'mode': 'groovy',
|
mode: 'groovy',
|
||||||
'mime': 'text/x-groovy'
|
mime: 'text/x-groovy'
|
||||||
}, {
|
}, {
|
||||||
'name': 'julia',
|
name: 'julia',
|
||||||
'mode': 'julia',
|
mode: 'julia',
|
||||||
'mime': 'text/x-julia'
|
mime: 'text/x-julia'
|
||||||
}, {
|
}, {
|
||||||
'name': 'haml',
|
name: 'haml',
|
||||||
'mode': 'haml',
|
mode: 'haml',
|
||||||
'mime': 'text/x-haml'
|
mime: 'text/x-haml'
|
||||||
}, {
|
}, {
|
||||||
'name': 'powershell',
|
name: 'powershell',
|
||||||
'mode': 'powershell',
|
mode: 'powershell',
|
||||||
'mime': 'application/x-powershell'
|
mime: 'application/x-powershell'
|
||||||
}, {
|
}, {
|
||||||
'name': 'typescript',
|
name: 'typescript',
|
||||||
'mode': 'javascript',
|
mode: 'javascript',
|
||||||
'mime': 'application/typescript'
|
mime: 'application/typescript'
|
||||||
}, {
|
}, {
|
||||||
'name': 'dart',
|
name: 'dart',
|
||||||
'mode': 'dart',
|
mode: 'dart',
|
||||||
'mime': 'application/dart'
|
mime: 'application/dart'
|
||||||
}, {
|
}, {
|
||||||
'name': 'xquery',
|
name: 'xquery',
|
||||||
'mode': 'xquery',
|
mode: 'xquery',
|
||||||
'mime': 'application/xquery'
|
mime: 'application/xquery'
|
||||||
}, {
|
}, {
|
||||||
'name': 'elm',
|
name: 'elm',
|
||||||
'mode': 'elm',
|
mode: 'elm',
|
||||||
'mime': 'text/x-elm'
|
mime: 'text/x-elm'
|
||||||
}, {
|
}, {
|
||||||
'name': 'plsql',
|
name: 'plsql',
|
||||||
'mode': 'sql',
|
mode: 'sql',
|
||||||
'mime': 'text/x-plsql'
|
mime: 'text/x-plsql'
|
||||||
}, {
|
}, {
|
||||||
'name': 'forth',
|
name: 'forth',
|
||||||
'mode': 'forth',
|
mode: 'forth',
|
||||||
'mime': 'text/x-forth'
|
mime: 'text/x-forth'
|
||||||
}, {
|
}, {
|
||||||
'name': 'scala',
|
name: 'scala',
|
||||||
'mode': 'clike',
|
mode: 'clike',
|
||||||
'mime': 'text/x-scala'
|
mime: 'text/x-scala'
|
||||||
}, {
|
}, {
|
||||||
'name': 'perl',
|
name: 'perl',
|
||||||
'mode': 'perl',
|
mode: 'perl',
|
||||||
'mime': 'text/x-perl'
|
mime: 'text/x-perl'
|
||||||
}, {
|
}, {
|
||||||
'name': 'haxe',
|
name: 'haxe',
|
||||||
'mode': 'haxe',
|
mode: 'haxe',
|
||||||
'mime': 'text/x-haxe'
|
mime: 'text/x-haxe'
|
||||||
}, {
|
}, {
|
||||||
'name': 'rhtml',
|
name: 'rhtml',
|
||||||
'mode': 'htmlembedded',
|
mode: 'htmlembedded',
|
||||||
'mime': 'application/x-erb'
|
mime: 'application/x-erb'
|
||||||
}, {
|
}, {
|
||||||
'name': 'scss',
|
name: 'scss',
|
||||||
'mode': 'css',
|
mode: 'css',
|
||||||
'mime': 'text/x-scss'
|
mime: 'text/x-scss'
|
||||||
}, {
|
}, {
|
||||||
'name': 'sql',
|
name: 'sql',
|
||||||
'mode': 'sql',
|
mode: 'sql',
|
||||||
'mime': 'text/x-sql'
|
mime: 'text/x-sql'
|
||||||
}, {
|
}, {
|
||||||
'name': 'css',
|
name: 'css',
|
||||||
'mode': 'css',
|
mode: 'css',
|
||||||
'mime': 'text/css'
|
mime: 'text/css'
|
||||||
}, {
|
}, {
|
||||||
'name': 'tex',
|
name: 'tex',
|
||||||
'mode': 'stex',
|
mode: 'stex',
|
||||||
'mime': 'text/x-stex'
|
mime: 'text/x-stex'
|
||||||
}, {
|
}, {
|
||||||
'name': 'r',
|
name: 'r',
|
||||||
'mode': 'r',
|
mode: 'r',
|
||||||
'mime': 'text/x-rsrc'
|
mime: 'text/x-rsrc'
|
||||||
}, {
|
}, {
|
||||||
'name': 'diff',
|
name: 'diff',
|
||||||
'mode': 'diff',
|
mode: 'diff',
|
||||||
'mime': 'text/x-diff'
|
mime: 'text/x-diff'
|
||||||
}, {
|
}, {
|
||||||
'name': 'twig',
|
name: 'twig',
|
||||||
'mode': 'twig',
|
mode: 'twig',
|
||||||
'mime': 'text/x-twig'
|
mime: 'text/x-twig'
|
||||||
}, {
|
}, {
|
||||||
'name': 'matlab',
|
name: 'matlab',
|
||||||
'mode': 'octave',
|
mode: 'octave',
|
||||||
'mime': 'text/x-octave'
|
mime: 'text/x-octave'
|
||||||
}, {
|
}, {
|
||||||
'name': 'soy_template',
|
name: 'soy_template',
|
||||||
'mode': 'soy',
|
mode: 'soy',
|
||||||
'mime': 'text/x-soy'
|
mime: 'text/x-soy'
|
||||||
}, {
|
}, {
|
||||||
'name': 'dockerfile',
|
name: 'dockerfile',
|
||||||
'mode': 'dockerfile',
|
mode: 'dockerfile',
|
||||||
'mime': 'text/x-dockerfile'
|
mime: 'text/x-dockerfile'
|
||||||
}, {
|
}, {
|
||||||
'name': 'toml',
|
name: 'toml',
|
||||||
'mode': 'toml',
|
mode: 'toml',
|
||||||
'mime': 'text/x-toml'
|
mime: 'text/x-toml'
|
||||||
}, {
|
}, {
|
||||||
'name': 'pgp',
|
name: 'pgp',
|
||||||
'mode': 'asciiarmor',
|
mode: 'asciiarmor',
|
||||||
'mime': 'application/pgp'
|
mime: 'application/pgp'
|
||||||
}, {
|
}, {
|
||||||
'name': 'Nginx',
|
name: 'Nginx',
|
||||||
'mode': 'nginx',
|
mode: 'nginx',
|
||||||
'mime': 'text/x-nginx-conf'
|
mime: 'text/x-nginx-conf'
|
||||||
}]
|
}]
|
||||||
|
|
||||||
export default languages
|
export default languages
|
||||||
|
@ -27,10 +27,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import bus from '../../bus'
|
import bus from '../../bus'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
this.name = 'Mark Text'
|
this.name = 'Mark Text'
|
||||||
this.copyright = `Copyright © 2017-${new Date().getFullYear()} Luo Ran`
|
this.copyright = `Copyright © 2017-${new Date().getFullYear()} Luo Ran`
|
||||||
@ -41,7 +41,7 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'appVersion': state => state.appVersion
|
appVersion: state => state.appVersion
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
@ -56,7 +56,7 @@
|
|||||||
bus.$emit('editor-blur')
|
bus.$emit('editor-blur')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -65,14 +65,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import bus from '../../bus'
|
import bus from '../../bus'
|
||||||
import loading from './loading'
|
import loading from './loading'
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import hotWords from './hotWords'
|
import hotWords from './hotWords'
|
||||||
import resource from '../../store/resource'
|
import resource from '../../store/resource'
|
||||||
import { dotuHistory, collection } from '../../util'
|
import { dotuHistory, collection } from '../../util'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
loading
|
loading
|
||||||
},
|
},
|
||||||
@ -102,8 +102,8 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'aiList': state => state.aidou.aiList,
|
aiList: state => state.aidou.aiList,
|
||||||
'aiLoading': state => state.aidou.aiLoading
|
aiLoading: state => state.aidou.aiLoading
|
||||||
}),
|
}),
|
||||||
emojis () {
|
emojis () {
|
||||||
return this.aiList.map(e => {
|
return this.aiList.map(e => {
|
||||||
@ -230,7 +230,7 @@
|
|||||||
this.search()
|
this.search()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -27,7 +27,6 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.cpt-loading {
|
.cpt-loading {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -74,36 +74,36 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import ViewImage from 'view-image'
|
import ViewImage from 'view-image'
|
||||||
import Muya from 'muya/lib'
|
import Muya from 'muya/lib'
|
||||||
import TablePicker from 'muya/lib/ui/tablePicker'
|
import TablePicker from 'muya/lib/ui/tablePicker'
|
||||||
import QuickInsert from 'muya/lib/ui/quickInsert'
|
import QuickInsert from 'muya/lib/ui/quickInsert'
|
||||||
import CodePicker from 'muya/lib/ui/codePicker'
|
import CodePicker from 'muya/lib/ui/codePicker'
|
||||||
import EmojiPicker from 'muya/lib/ui/emojiPicker'
|
import EmojiPicker from 'muya/lib/ui/emojiPicker'
|
||||||
import ImagePathPicker from 'muya/lib/ui/imagePicker'
|
import ImagePathPicker from 'muya/lib/ui/imagePicker'
|
||||||
import ImageSelector from 'muya/lib/ui/imageSelector'
|
import ImageSelector from 'muya/lib/ui/imageSelector'
|
||||||
import FormatPicker from 'muya/lib/ui/formatPicker'
|
import FormatPicker from 'muya/lib/ui/formatPicker'
|
||||||
import FrontMenu from 'muya/lib/ui/frontMenu'
|
import FrontMenu from 'muya/lib/ui/frontMenu'
|
||||||
import bus from '../../bus'
|
import bus from '../../bus'
|
||||||
import Search from '../search.vue'
|
import Search from '../search.vue'
|
||||||
import { animatedScrollTo } from '../../util'
|
import { animatedScrollTo } from '../../util'
|
||||||
import { addCommonStyle } from '../../util/theme'
|
import { addCommonStyle } from '../../util/theme'
|
||||||
import { guessClipboardFilePath } from '../../util/clipboard'
|
import { guessClipboardFilePath } from '../../util/clipboard'
|
||||||
import { showContextMenu } from '../../contextMenu/editor'
|
import { showContextMenu } from '../../contextMenu/editor'
|
||||||
import Printer from '@/services/printService'
|
import Printer from '@/services/printService'
|
||||||
import { DEFAULT_EDITOR_FONT_FAMILY } from '@/config'
|
import { DEFAULT_EDITOR_FONT_FAMILY } from '@/config'
|
||||||
import { moveImageToFolder, uploadImage } from '@/util/fileSystem'
|
import { moveImageToFolder, uploadImage } from '@/util/fileSystem'
|
||||||
import notice from '@/services/notification'
|
import notice from '@/services/notification'
|
||||||
|
|
||||||
import 'muya/themes/default.css'
|
import 'muya/themes/default.css'
|
||||||
import '@/assets/themes/codemirror/one-dark.css'
|
import '@/assets/themes/codemirror/one-dark.css'
|
||||||
import 'view-image/lib/imgViewer.css'
|
import 'view-image/lib/imgViewer.css'
|
||||||
import CloseIcon from '@/assets/icons/close.svg'
|
import CloseIcon from '@/assets/icons/close.svg'
|
||||||
|
|
||||||
const STANDAR_Y = 320
|
const STANDAR_Y = 320
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Search
|
Search
|
||||||
},
|
},
|
||||||
@ -121,33 +121,33 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'preferences': state => state.preferences,
|
preferences: state => state.preferences,
|
||||||
'preferLooseListItem': state => state.preferences.preferLooseListItem,
|
preferLooseListItem: state => state.preferences.preferLooseListItem,
|
||||||
'autoPairBracket': state => state.preferences.autoPairBracket,
|
autoPairBracket: state => state.preferences.autoPairBracket,
|
||||||
'autoPairMarkdownSyntax': state => state.preferences.autoPairMarkdownSyntax,
|
autoPairMarkdownSyntax: state => state.preferences.autoPairMarkdownSyntax,
|
||||||
'autoPairQuote': state => state.preferences.autoPairQuote,
|
autoPairQuote: state => state.preferences.autoPairQuote,
|
||||||
'bulletListMarker': state => state.preferences.bulletListMarker,
|
bulletListMarker: state => state.preferences.bulletListMarker,
|
||||||
'orderListDelimiter': state => state.preferences.orderListDelimiter,
|
orderListDelimiter: state => state.preferences.orderListDelimiter,
|
||||||
'tabSize': state => state.preferences.tabSize,
|
tabSize: state => state.preferences.tabSize,
|
||||||
'listIndentation': state => state.preferences.listIndentation,
|
listIndentation: state => state.preferences.listIndentation,
|
||||||
'lineHeight': state => state.preferences.lineHeight,
|
lineHeight: state => state.preferences.lineHeight,
|
||||||
'fontSize': state => state.preferences.fontSize,
|
fontSize: state => state.preferences.fontSize,
|
||||||
'codeFontSize': state => state.preferences.codeFontSize,
|
codeFontSize: state => state.preferences.codeFontSize,
|
||||||
'codeFontFamily': state => state.preferences.codeFontFamily,
|
codeFontFamily: state => state.preferences.codeFontFamily,
|
||||||
'editorFontFamily': state => state.preferences.editorFontFamily,
|
editorFontFamily: state => state.preferences.editorFontFamily,
|
||||||
'hideQuickInsertHint': state => state.preferences.hideQuickInsertHint,
|
hideQuickInsertHint: state => state.preferences.hideQuickInsertHint,
|
||||||
'editorLineWidth': state => state.preferences.editorLineWidth,
|
editorLineWidth: state => state.preferences.editorLineWidth,
|
||||||
'imageInsertAction': state => state.preferences.imageInsertAction,
|
imageInsertAction: state => state.preferences.imageInsertAction,
|
||||||
'imageFolderPath': state => state.preferences.imageFolderPath,
|
imageFolderPath: state => state.preferences.imageFolderPath,
|
||||||
'theme': state => state.preferences.theme,
|
theme: state => state.preferences.theme,
|
||||||
'hideScrollbar': state => state.preferences.hideScrollbar,
|
hideScrollbar: state => state.preferences.hideScrollbar,
|
||||||
|
|
||||||
'currentFile': state => state.editor.currentFile,
|
currentFile: state => state.editor.currentFile,
|
||||||
|
|
||||||
// edit modes
|
// edit modes
|
||||||
'typewriter': state => state.preferences.typewriter,
|
typewriter: state => state.preferences.typewriter,
|
||||||
'focus': state => state.preferences.focus,
|
focus: state => state.preferences.focus,
|
||||||
'sourceCode': state => state.preferences.sourceCode
|
sourceCode: state => state.preferences.sourceCode
|
||||||
}),
|
}),
|
||||||
|
|
||||||
getEditorLineWidth () {
|
getEditorLineWidth () {
|
||||||
@ -654,7 +654,6 @@
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
console.error(`unknow paragraph edit type: ${type}`)
|
console.error(`unknow paragraph edit type: ${type}`)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -759,7 +758,7 @@
|
|||||||
this.editor.destroy()
|
this.editor.destroy()
|
||||||
this.editor = null
|
this.editor = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -22,11 +22,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Tabs from './tabs.vue'
|
import Tabs from './tabs.vue'
|
||||||
import Editor from './editor.vue'
|
import Editor from './editor.vue'
|
||||||
import SourceCode from './sourceCode.vue'
|
import SourceCode from './sourceCode.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
filename: {
|
filename: {
|
||||||
type: String
|
type: String
|
||||||
@ -63,7 +63,7 @@
|
|||||||
Editor,
|
Editor,
|
||||||
SourceCode
|
SourceCode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import codeMirror, { setMode, setCursorAtLastLine, setTextDirection } from '../../codeMirror'
|
import codeMirror, { setMode, setCursorAtLastLine, setTextDirection } from '../../codeMirror'
|
||||||
import { wordCount as getWordCount } from 'muya/lib/utils'
|
import { wordCount as getWordCount } from 'muya/lib/utils'
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import { adjustCursor } from '../../util'
|
import { adjustCursor } from '../../util'
|
||||||
import bus from '../../bus'
|
import bus from '../../bus'
|
||||||
import { oneDarkThemes, railscastsThemes } from '@/config'
|
import { oneDarkThemes, railscastsThemes } from '@/config'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
markdown: String,
|
markdown: String,
|
||||||
cursor: Object,
|
cursor: Object,
|
||||||
@ -26,9 +26,9 @@
|
|||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'theme': state => state.preferences.theme,
|
theme: state => state.preferences.theme,
|
||||||
'sourceCode': state => state.preferences.sourceCode,
|
sourceCode: state => state.preferences.sourceCode,
|
||||||
'currentTab': state => state.editor.currentFile,
|
currentTab: state => state.editor.currentFile
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -186,7 +186,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -42,12 +42,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import autoScroll from 'dom-autoscroller'
|
import autoScroll from 'dom-autoscroller'
|
||||||
import dragula from 'dragula'
|
import dragula from 'dragula'
|
||||||
import { tabsMixins } from '../../mixins'
|
import { tabsMixins } from '../../mixins'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
this.autoScroller = null
|
this.autoScroller = null
|
||||||
this.drake = null
|
this.drake = null
|
||||||
@ -56,10 +56,10 @@
|
|||||||
mixins: [tabsMixins],
|
mixins: [tabsMixins],
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'currentFile': state => state.editor.currentFile,
|
currentFile: state => state.editor.currentFile,
|
||||||
'tabs': state => state.editor.tabs,
|
tabs: state => state.editor.tabs,
|
||||||
'showSideBar': state => state.layout.showSideBar,
|
showSideBar: state => state.layout.showSideBar,
|
||||||
'sideBarWidth': state => state.layout.sideBarWidth
|
sideBarWidth: state => state.layout.sideBarWidth
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -74,7 +74,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const tabs = this.$refs.tabContainer
|
const tabs = this.$refs.tabContainer
|
||||||
const newLeft = Math.max(0, Math.min(tabs.scrollLeft + delta, tabs.scrollWidth ))
|
const newLeft = Math.max(0, Math.min(tabs.scrollLeft + delta, tabs.scrollWidth))
|
||||||
tabs.scrollLeft = newLeft
|
tabs.scrollLeft = newLeft
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -86,7 +86,7 @@
|
|||||||
tabs.addEventListener('wheel', this.handleTabScroll)
|
tabs.addEventListener('wheel', this.handleTabScroll)
|
||||||
|
|
||||||
// Allow tab drag and drop to reorder tabs.
|
// Allow tab drag and drop to reorder tabs.
|
||||||
const drake = this.drake = dragula([ this.$refs.tabDropContainer ], {
|
const drake = this.drake = dragula([this.$refs.tabDropContainer], {
|
||||||
direction: 'horizontal',
|
direction: 'horizontal',
|
||||||
revertOnSpill: true,
|
revertOnSpill: true,
|
||||||
mirrorContainer: this.$refs.tabDropContainer,
|
mirrorContainer: this.$refs.tabDropContainer,
|
||||||
@ -113,7 +113,7 @@
|
|||||||
// in Mark Text window.
|
// in Mark Text window.
|
||||||
|
|
||||||
// Scroll when dragging a tab to the beginning or end of the tab container.
|
// Scroll when dragging a tab to the beginning or end of the tab container.
|
||||||
this.autoScroller = autoScroll([ tabs ], {
|
this.autoScroller = autoScroll([tabs], {
|
||||||
margin: 20,
|
margin: 20,
|
||||||
maxSpeed: 6,
|
maxSpeed: 6,
|
||||||
scrollWhenOutside: false,
|
scrollWhenOutside: false,
|
||||||
@ -135,7 +135,7 @@
|
|||||||
this.drake.destroy()
|
this.drake.destroy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -117,4 +117,3 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ContentIcon from '@/assets/icons/undraw_content.svg'
|
import ContentIcon from '@/assets/icons/undraw_content.svg'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
this.ContentIcon = ContentIcon
|
this.ContentIcon = ContentIcon
|
||||||
return {}
|
return {}
|
||||||
@ -26,7 +26,7 @@
|
|||||||
this.$store.dispatch('NEW_UNTITLED_TAB', {})
|
this.$store.dispatch('NEW_UNTITLED_TAB', {})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -24,10 +24,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import bus from '../bus'
|
import bus from '../bus'
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
showRename: false,
|
showRename: false,
|
||||||
@ -58,7 +58,7 @@
|
|||||||
this.showRename = false
|
this.showRename = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -102,10 +102,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import bus from '../bus'
|
import bus from '../bus'
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
showSearch: false,
|
showSearch: false,
|
||||||
@ -126,7 +126,7 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'searchMatches': state => state.editor.currentFile.searchMatches
|
searchMatches: state => state.editor.currentFile.searchMatches
|
||||||
}),
|
}),
|
||||||
highlightIndex () {
|
highlightIndex () {
|
||||||
if (this.searchMatches) {
|
if (this.searchMatches) {
|
||||||
@ -216,7 +216,7 @@
|
|||||||
},
|
},
|
||||||
noop () {}
|
noop () {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import fileIcons from 'muya/lib/ui/fileIcons'
|
import fileIcons from 'muya/lib/ui/fileIcons'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -23,7 +23,7 @@
|
|||||||
return icon.split(/\s/)
|
return icon.split(/\s/)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -56,12 +56,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import { fileMixins } from '../../mixins'
|
import { fileMixins } from '../../mixins'
|
||||||
import { PATH_SEPARATOR } from '../../config'
|
import { PATH_SEPARATOR } from '../../config'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [fileMixins],
|
mixins: [fileMixins],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@ -78,8 +78,8 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'tabs': state => state.editor.tabs,
|
tabs: state => state.editor.tabs,
|
||||||
'currentFile': state => state.editor.currentFile
|
currentFile: state => state.editor.currentFile
|
||||||
}),
|
}),
|
||||||
|
|
||||||
getMatches () {
|
getMatches () {
|
||||||
@ -113,7 +113,7 @@
|
|||||||
toggleSearchMatches () {
|
toggleSearchMatches () {
|
||||||
this.showSearchMatches = !this.showSearchMatches
|
this.showSearchMatches = !this.showSearchMatches
|
||||||
},
|
},
|
||||||
handleShowMoreMatches(event) {
|
handleShowMoreMatches (event) {
|
||||||
this.shownMatches += 15
|
this.shownMatches += 15
|
||||||
if (event.ctrlKey || event.metaKey ||
|
if (event.ctrlKey || event.metaKey ||
|
||||||
this.shownMatches >= this.searchResult.matches.length) {
|
this.shownMatches >= this.searchResult.matches.length) {
|
||||||
@ -121,7 +121,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import bus from '../../bus'
|
import bus from '../../bus'
|
||||||
import EmptyIcon from '@/assets/icons/undraw_toc_empty.svg'
|
import EmptyIcon from '@/assets/icons/undraw_toc_empty.svg'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
this.EmptyIcon = EmptyIcon
|
this.EmptyIcon = EmptyIcon
|
||||||
return {
|
return {
|
||||||
@ -35,7 +35,7 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'toc': state => state.editor.toc
|
toc: state => state.editor.toc
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -43,7 +43,7 @@
|
|||||||
bus.$emit('scroll-to-header', slug)
|
bus.$emit('scroll-to-header', slug)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -81,15 +81,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Folder from './treeFolder.vue'
|
import Folder from './treeFolder.vue'
|
||||||
import File from './treeFile.vue'
|
import File from './treeFile.vue'
|
||||||
import OpenedFile from './treeOpenedTab.vue'
|
import OpenedFile from './treeOpenedTab.vue'
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import bus from '../../bus'
|
import bus from '../../bus'
|
||||||
import { createFileOrDirectoryMixins } from '../../mixins'
|
import { createFileOrDirectoryMixins } from '../../mixins'
|
||||||
import FolderIcon from '@/assets/icons/undraw_folder.svg'
|
import FolderIcon from '@/assets/icons/undraw_folder.svg'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [createFileOrDirectoryMixins],
|
mixins: [createFileOrDirectoryMixins],
|
||||||
data () {
|
data () {
|
||||||
this.depth = 0
|
this.depth = 0
|
||||||
@ -118,7 +118,7 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'createCache': state => state.project.createCache
|
createCache: state => state.project.createCache
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
@ -166,7 +166,7 @@
|
|||||||
this.showDirectories = !this.showDirectories
|
this.showDirectories = !this.showDirectories
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -24,13 +24,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import FileIcon from './icon.vue'
|
import FileIcon from './icon.vue'
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import { fileMixins } from '../../mixins'
|
import { fileMixins } from '../../mixins'
|
||||||
import { showContextMenu } from '../../contextMenu/sideBar'
|
import { showContextMenu } from '../../contextMenu/sideBar'
|
||||||
import bus from '../../bus'
|
import bus from '../../bus'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [fileMixins],
|
mixins: [fileMixins],
|
||||||
name: 'file',
|
name: 'file',
|
||||||
data () {
|
data () {
|
||||||
@ -53,11 +53,11 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'renameCache': state => state.project.renameCache,
|
renameCache: state => state.project.renameCache,
|
||||||
'activeItem': state => state.project.activeItem,
|
activeItem: state => state.project.activeItem,
|
||||||
'clipboard': state => state.project.clipboard,
|
clipboard: state => state.project.clipboard,
|
||||||
'currentFile': state => state.editor.currentFile,
|
currentFile: state => state.editor.currentFile,
|
||||||
'tabs': state => state.editor.tabs
|
tabs: state => state.editor.tabs
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
@ -88,7 +88,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -50,12 +50,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import { showContextMenu } from '../../contextMenu/sideBar'
|
import { showContextMenu } from '../../contextMenu/sideBar'
|
||||||
import bus from '../../bus'
|
import bus from '../../bus'
|
||||||
import { createFileOrDirectoryMixins } from '../../mixins'
|
import { createFileOrDirectoryMixins } from '../../mixins'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [createFileOrDirectoryMixins],
|
mixins: [createFileOrDirectoryMixins],
|
||||||
name: 'folder',
|
name: 'folder',
|
||||||
data () {
|
data () {
|
||||||
@ -79,10 +79,10 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'renameCache': state => state.project.renameCache,
|
renameCache: state => state.project.renameCache,
|
||||||
'createCache': state => state.project.createCache,
|
createCache: state => state.project.createCache,
|
||||||
'activeItem': state => state.project.activeItem,
|
activeItem: state => state.project.activeItem,
|
||||||
'clipboard': state => state.project.clipboard
|
clipboard: state => state.project.clipboard
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
@ -116,7 +116,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import { tabsMixins } from '../../mixins'
|
import { tabsMixins } from '../../mixins'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [tabsMixins],
|
mixins: [tabsMixins],
|
||||||
props: {
|
props: {
|
||||||
file: {
|
file: {
|
||||||
@ -28,10 +28,10 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'currentFile': state => state.editor.currentFile
|
currentFile: state => state.editor.currentFile
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -98,29 +98,29 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ipcRenderer, remote } from 'electron'
|
import { ipcRenderer, remote } from 'electron'
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import { minimizePath, restorePath, maximizePath, closePath } from '../assets/window-controls.js'
|
import { minimizePath, restorePath, maximizePath, closePath } from '../assets/window-controls.js'
|
||||||
import { PATH_SEPARATOR } from '../config'
|
import { PATH_SEPARATOR } from '../config'
|
||||||
import { isOsx } from '@/util'
|
import { isOsx } from '@/util'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
this.isOsx = isOsx
|
this.isOsx = isOsx
|
||||||
this.HASH = {
|
this.HASH = {
|
||||||
'word': {
|
word: {
|
||||||
short: 'W',
|
short: 'W',
|
||||||
full: 'word'
|
full: 'word'
|
||||||
},
|
},
|
||||||
'character': {
|
character: {
|
||||||
short: 'C',
|
short: 'C',
|
||||||
full: 'character'
|
full: 'character'
|
||||||
},
|
},
|
||||||
'paragraph': {
|
paragraph: {
|
||||||
short: 'P',
|
short: 'P',
|
||||||
full: 'paragraph'
|
full: 'paragraph'
|
||||||
},
|
},
|
||||||
'all': {
|
all: {
|
||||||
short: 'A',
|
short: 'A',
|
||||||
full: '(with space)character'
|
full: '(with space)character'
|
||||||
}
|
}
|
||||||
@ -152,8 +152,8 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'titleBarStyle': state => state.preferences.titleBarStyle,
|
titleBarStyle: state => state.preferences.titleBarStyle,
|
||||||
'showTabBar': state => state.layout.showTabBar
|
showTabBar: state => state.layout.showTabBar
|
||||||
}),
|
}),
|
||||||
paths () {
|
paths () {
|
||||||
if (!this.pathname) return []
|
if (!this.pathname) return []
|
||||||
@ -167,8 +167,8 @@
|
|||||||
watch: {
|
watch: {
|
||||||
filename: function (value) {
|
filename: function (value) {
|
||||||
// Set filename when hover on dock
|
// Set filename when hover on dock
|
||||||
const title = this.project && this.project.name ?
|
const title = this.project && this.project.name
|
||||||
`${value} - ${this.project.name}` : `${value} - Mark Text`
|
? `${value} - ${this.project.name}` : `${value} - Mark Text`
|
||||||
document.title = title
|
document.title = title
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -234,7 +234,7 @@
|
|||||||
ipcRenderer.off('window-enter-full-screen', this.onEnterFullScreen)
|
ipcRenderer.off('window-enter-full-screen', this.onEnterFullScreen)
|
||||||
ipcRenderer.off('window-leave-full-screen', this.onLeaveFullScreen)
|
ipcRenderer.off('window-leave-full-screen', this.onLeaveFullScreen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@ -415,4 +415,3 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user