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
|
||||||
|
@ -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,7 +5,6 @@ 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.
|
||||||
*/
|
*/
|
||||||
|
@ -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)
|
||||||
|
@ -17,7 +17,6 @@ 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.
|
||||||
@ -372,10 +371,9 @@ 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])
|
||||||
}
|
}
|
||||||
@ -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.
|
||||||
*
|
*
|
||||||
|
@ -51,7 +51,6 @@ class WindowActivityList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class WindowManager extends EventEmitter {
|
class WindowManager extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {AppMenu} appMenu The application menu instance.
|
* @param {AppMenu} appMenu The application menu instance.
|
||||||
@ -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)
|
||||||
|
@ -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,
|
||||||
|
@ -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}`
|
||||||
|
|
||||||
|
@ -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.
|
||||||
*/
|
*/
|
||||||
|
@ -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)
|
||||||
|
@ -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'),
|
||||||
|
@ -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.
|
||||||
*/
|
*/
|
||||||
|
@ -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>'
|
||||||
}
|
}
|
||||||
|
@ -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 => {
|
||||||
|
@ -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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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) {
|
||||||
|
@ -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 = {
|
|||||||
']': '[',
|
']': '[',
|
||||||
')': '(',
|
')': '(',
|
||||||
'*': '*',
|
'*': '*',
|
||||||
'_': '_',
|
_: '_',
|
||||||
'"': '"',
|
'"': '"',
|
||||||
'\'': '\'',
|
'\'': '\'',
|
||||||
'$': '$',
|
$: '$',
|
||||||
'~': '~'
|
'~': '~'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
@ -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) {
|
||||||
|
@ -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
|
||||||
*/
|
*/
|
||||||
@ -52,12 +56,14 @@ class EventCenter {
|
|||||||
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
|
||||||
|
@ -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
|
||||||
|
@ -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]
|
||||||
|
@ -105,8 +105,8 @@ 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
|
||||||
@ -114,9 +114,9 @@ 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)
|
||||||
@ -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) {
|
||||||
@ -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: {
|
||||||
|
@ -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)) {
|
||||||
|
@ -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 {
|
||||||
|
@ -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)
|
||||||
|
@ -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) {
|
||||||
|
@ -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} `
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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())) {
|
||||||
@ -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
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'appVersion': state => state.appVersion
|
appVersion: state => state.appVersion
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
|
@ -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 => {
|
||||||
|
@ -27,7 +27,6 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.cpt-loading {
|
.cpt-loading {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -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
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -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: {
|
||||||
|
@ -117,4 +117,3 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
@ -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) {
|
||||||
|
@ -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 () {
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'toc': state => state.editor.toc
|
toc: state => state.editor.toc
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -118,7 +118,7 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'createCache': state => state.project.createCache
|
createCache: state => state.project.createCache
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
|
@ -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 () {
|
||||||
|
@ -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 () {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'currentFile': state => state.editor.currentFile
|
currentFile: state => state.editor.currentFile
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,19 +108,19 @@
|
|||||||
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
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -415,4 +415,3 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import EnvPaths from 'common/envPaths'
|
|||||||
const rgDiskPath = rgPath.replace(/\bapp\.asar\b/, 'app.asar.unpacked')
|
const rgDiskPath = rgPath.replace(/\bapp\.asar\b/, 'app.asar.unpacked')
|
||||||
|
|
||||||
class RendererPaths extends EnvPaths {
|
class RendererPaths extends EnvPaths {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure and sets all application paths.
|
* Configure and sets all application paths.
|
||||||
*
|
*
|
||||||
|
@ -105,11 +105,10 @@ function processSubmatch (submatch, lineText, offsetRow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getText (input) {
|
function getText (input) {
|
||||||
return input.text ? input.text : Buffer.from(input.bytes, 'base64').toString()
|
return 'text' in input ? input.text : Buffer.from(input.bytes, 'base64').toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
class RipgrepDirectorySearcher {
|
class RipgrepDirectorySearcher {
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this.rgPath = global.marktext.paths.ripgrepBinaryPath
|
this.rgPath = global.marktext.paths.ripgrepBinaryPath
|
||||||
}
|
}
|
||||||
|
@ -70,19 +70,19 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'showTabBar': state => state.layout.showTabBar,
|
showTabBar: state => state.layout.showTabBar,
|
||||||
'sourceCode': state => state.preferences.sourceCode,
|
sourceCode: state => state.preferences.sourceCode,
|
||||||
'theme': state => state.preferences.theme,
|
theme: state => state.preferences.theme,
|
||||||
'textDirection': state => state.preferences.textDirection
|
textDirection: state => state.preferences.textDirection
|
||||||
}),
|
}),
|
||||||
...mapState({
|
...mapState({
|
||||||
'projectTree': state => state.project.projectTree,
|
projectTree: state => state.project.projectTree,
|
||||||
'pathname': state => state.editor.currentFile.pathname,
|
pathname: state => state.editor.currentFile.pathname,
|
||||||
'filename': state => state.editor.currentFile.filename,
|
filename: state => state.editor.currentFile.filename,
|
||||||
'isSaved': state => state.editor.currentFile.isSaved,
|
isSaved: state => state.editor.currentFile.isSaved,
|
||||||
'markdown': state => state.editor.currentFile.markdown,
|
markdown: state => state.editor.currentFile.markdown,
|
||||||
'cursor': state => state.editor.currentFile.cursor,
|
cursor: state => state.editor.currentFile.cursor,
|
||||||
'wordCount': state => state.editor.currentFile.wordCount
|
wordCount: state => state.editor.currentFile.wordCount
|
||||||
}),
|
}),
|
||||||
...mapState([
|
...mapState([
|
||||||
'windowActive', 'platform', 'init'
|
'windowActive', 'platform', 'init'
|
||||||
|
@ -31,8 +31,8 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'theme': state => state.preferences.theme,
|
theme: state => state.preferences.theme,
|
||||||
'titleBarStyle': state => state.preferences.titleBarStyle
|
titleBarStyle: state => state.preferences.titleBarStyle
|
||||||
}),
|
}),
|
||||||
showCustomTitleBar () {
|
showCustomTitleBar () {
|
||||||
return this.titleBarStyle === 'custom' && !this.isOsx
|
return this.titleBarStyle === 'custom' && !this.isOsx
|
||||||
|
@ -90,4 +90,3 @@ export default {
|
|||||||
background: var(--iconColor);
|
background: var(--iconColor);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
@ -97,4 +97,3 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
@ -104,4 +104,3 @@ div.el-select-dropdown {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
@ -9,4 +9,3 @@
|
|||||||
background: var(--editorColor04);
|
background: var(--editorColor04);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
@ -94,5 +94,3 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
export default {
|
export default {
|
||||||
// Dummy service used to opt-in real services.
|
// Dummy service used to opt-in real services.
|
||||||
none: {
|
none: {
|
||||||
name: "",
|
name: '',
|
||||||
isGdprCompliant: true,
|
isGdprCompliant: true,
|
||||||
privacyUrl: '',
|
privacyUrl: '',
|
||||||
tosUrl: '',
|
tosUrl: '',
|
||||||
@ -14,7 +14,7 @@ export default {
|
|||||||
|
|
||||||
// Real services
|
// Real services
|
||||||
smms: {
|
smms: {
|
||||||
name: "sm.ms",
|
name: 'sm.ms',
|
||||||
isGdprCompliant: false,
|
isGdprCompliant: false,
|
||||||
privacyUrl: '',
|
privacyUrl: '',
|
||||||
tosUrl: 'https://sm.ms/about/',
|
tosUrl: 'https://sm.ms/about/',
|
||||||
@ -23,7 +23,7 @@ export default {
|
|||||||
agreedToLegalNotices: false
|
agreedToLegalNotices: false
|
||||||
},
|
},
|
||||||
github: {
|
github: {
|
||||||
name: "GitHub",
|
name: 'GitHub',
|
||||||
isGdprCompliant: true,
|
isGdprCompliant: true,
|
||||||
privacyUrl: 'https://github.com/site/privacy',
|
privacyUrl: 'https://github.com/site/privacy',
|
||||||
tosUrl: 'https://github.com/site/terms',
|
tosUrl: 'https://github.com/site/terms',
|
||||||
|
@ -47,7 +47,7 @@ export const listIndentationOptions = [{
|
|||||||
value: 'tab'
|
value: 'tab'
|
||||||
}, {
|
}, {
|
||||||
label: '1 space',
|
label: '1 space',
|
||||||
value: 1,
|
value: 1
|
||||||
}, {
|
}, {
|
||||||
label: '2 spaces',
|
label: '2 spaces',
|
||||||
value: 2
|
value: 2
|
||||||
|
@ -42,7 +42,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
'theme': state => state.preferences.theme
|
theme: state => state.preferences.theme
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
|
@ -12,7 +12,8 @@ const routes = type => ([{
|
|||||||
}, {
|
}, {
|
||||||
path: '/editor', component: App
|
path: '/editor', component: App
|
||||||
}, {
|
}, {
|
||||||
path: '/preference', component: Preference,
|
path: '/preference',
|
||||||
|
component: Preference,
|
||||||
children: [{
|
children: [{
|
||||||
path: '', component: General
|
path: '', component: General
|
||||||
}, {
|
}, {
|
||||||
|
@ -109,7 +109,7 @@ const notification = {
|
|||||||
const notices = document.querySelectorAll('.mt-notification')
|
const notices = document.querySelectorAll('.mt-notification')
|
||||||
let i
|
let i
|
||||||
let hx = 0
|
let hx = 0
|
||||||
let len = notices.length
|
const len = notices.length
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
notices[i].style.transform = `translate(0, -${hx}px)`
|
notices[i].style.transform = `translate(0, -${hx}px)`
|
||||||
notices[i].style.zIndex = 10000 - i
|
notices[i].style.zIndex = 10000 - i
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { getImageInfo } from 'muya/lib/utils'
|
import { getImageInfo } from 'muya/lib/utils'
|
||||||
|
|
||||||
class MarkdownPrint {
|
class MarkdownPrint {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare document export and append a hidden print container to the window.
|
* Prepare document export and append a hidden print container to the window.
|
||||||
*
|
*
|
||||||
|
@ -525,7 +525,7 @@ const actions = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcRenderer.on('mt::new-untitled-tab', (e, selected = true, markdown = '', ) => {
|
ipcRenderer.on('mt::new-untitled-tab', (e, selected = true, markdown = '') => {
|
||||||
// Create a blank tab
|
// Create a blank tab
|
||||||
dispatch('NEW_UNTITLED_TAB', { markdown, selected })
|
dispatch('NEW_UNTITLED_TAB', { markdown, selected })
|
||||||
})
|
})
|
||||||
@ -802,7 +802,6 @@ const actions = {
|
|||||||
|
|
||||||
LISTEN_FOR_FILE_CHANGE ({ commit, state, rootState }) {
|
LISTEN_FOR_FILE_CHANGE ({ commit, state, rootState }) {
|
||||||
ipcRenderer.on('AGANI::update-file', (e, { type, change }) => {
|
ipcRenderer.on('AGANI::update-file', (e, { type, change }) => {
|
||||||
|
|
||||||
// TODO: A new "changed" notification from different files overwrite the old notification
|
// TODO: A new "changed" notification from different files overwrite the old notification
|
||||||
// and the old notification disappears. I think we should bind the notification to the tab.
|
// and the old notification disappears. I think we should bind the notification to the tab.
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user