mirror of
https://github.com/marktext/marktext.git
synced 2025-05-02 15:09:10 +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: {
|
||||
// allow paren-less arrow functions
|
||||
'arrow-parens': 0,
|
||||
'arrow-parens': "off",
|
||||
// allow async-await
|
||||
'generator-star-spacing': 0,
|
||||
'generator-star-spacing': "off",
|
||||
// allow console
|
||||
'no-console': 0,
|
||||
'no-console': "off",
|
||||
// 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
|
||||
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: {
|
||||
'import/resolver': {
|
||||
|
78
package.json
78
package.json
@ -158,35 +158,35 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@hfelix/electron-localshortcut": "^3.1.1",
|
||||
"@octokit/rest": "^16.28.2",
|
||||
"arg": "^4.1.0",
|
||||
"@octokit/rest": "^16.28.5",
|
||||
"arg": "^4.1.1",
|
||||
"axios": "^0.19.0",
|
||||
"chokidar": "^3.0.1",
|
||||
"codemirror": "^5.46.0",
|
||||
"chokidar": "^3.0.2",
|
||||
"codemirror": "^5.48.2",
|
||||
"command-exists": "^1.2.8",
|
||||
"dayjs": "^1.8.14",
|
||||
"dayjs": "^1.8.15",
|
||||
"dom-autoscroller": "^2.3.4",
|
||||
"dompurify": "^1.0.11",
|
||||
"dragula": "^3.7.2",
|
||||
"electron-is-accelerator": "^0.1.2",
|
||||
"electron-log": "^3.0.6",
|
||||
"electron-store": "^3.3.0",
|
||||
"electron-store": "^4.0.0",
|
||||
"electron-window-state": "^5.0.3",
|
||||
"element-resize-detector": "^1.2.0",
|
||||
"element-ui": "^2.9.1",
|
||||
"element-ui": "^2.10.1",
|
||||
"file-icons-js": "^1.0.3",
|
||||
"flowchart.js": "^1.12.0",
|
||||
"fs-extra": "^8.0.1",
|
||||
"flowchart.js": "^1.12.1",
|
||||
"fs-extra": "^8.1.0",
|
||||
"fuzzaldrin": "^2.1.0",
|
||||
"github-markdown-css": "^3.0.1",
|
||||
"html-tags": "^3.0.0",
|
||||
"katex": "^0.10.2",
|
||||
"keyboard-layout": "^2.0.16",
|
||||
"keytar": "^4.10.0",
|
||||
"keytar": "^4.12.0",
|
||||
"mermaid": "^8.0.0",
|
||||
"plist": "^3.0.1",
|
||||
"popper.js": "^1.15.0",
|
||||
"prismjs": "^1.16.0",
|
||||
"prismjs": "^1.17.1",
|
||||
"snabbdom": "^0.7.3",
|
||||
"snabbdom-to-html": "^5.1.1",
|
||||
"source-map-support": "^0.5.12",
|
||||
@ -194,19 +194,19 @@
|
||||
"turndown-plugin-gfm": "^1.0.2",
|
||||
"underscore": "^1.9.1",
|
||||
"vega": "^5.4.0",
|
||||
"vega-embed": "^4.2.0",
|
||||
"vega-embed": "^4.2.1",
|
||||
"vega-lite": "^3.3.0",
|
||||
"view-image": "^0.0.1",
|
||||
"vscode-ripgrep": "^1.2.5",
|
||||
"vscode-ripgrep": "^1.5.5",
|
||||
"vue": "^2.6.10",
|
||||
"vue-electron": "^1.0.6",
|
||||
"vue-router": "^3.0.6",
|
||||
"vue-router": "^3.0.7",
|
||||
"vuex": "^3.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@markedjs/html-differ": "^2.0.1",
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babel-eslint": "^10.0.2",
|
||||
"babel-loader": "^7.1.5",
|
||||
"babel-plugin-component": "^1.1.1",
|
||||
"babel-plugin-istanbul": "^5.1.1",
|
||||
@ -224,24 +224,24 @@
|
||||
"del": "^4.1.1",
|
||||
"devtron": "^1.4.0",
|
||||
"dotenv": "^8.0.0",
|
||||
"electron": "^5.0.4",
|
||||
"electron-builder": "^20.40.2",
|
||||
"electron": "^5.0.7",
|
||||
"electron-builder": "^21.1.1",
|
||||
"electron-devtools-installer": "^2.2.4",
|
||||
"electron-rebuild": "^1.8.4",
|
||||
"electron-updater": "^4.0.6",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-config-standard": "^12.0.0",
|
||||
"electron-rebuild": "^1.8.5",
|
||||
"electron-updater": "^4.1.2",
|
||||
"eslint": "^6.1.0",
|
||||
"eslint-config-standard": "^13.0.1",
|
||||
"eslint-friendly-formatter": "^4.0.1",
|
||||
"eslint-import-resolver-alias": "^1.1.2",
|
||||
"eslint-loader": "^2.1.2",
|
||||
"eslint-plugin-html": "^5.0.4",
|
||||
"eslint-plugin-import": "^2.17.2",
|
||||
"eslint-plugin-node": "^9.0.1",
|
||||
"eslint-plugin-promise": "^4.1.1",
|
||||
"eslint-loader": "^2.2.1",
|
||||
"eslint-plugin-html": "^6.0.0",
|
||||
"eslint-plugin-import": "^2.18.2",
|
||||
"eslint-plugin-node": "^9.1.0",
|
||||
"eslint-plugin-promise": "^4.2.1",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"eslint-plugin-vue": "^5.2.2",
|
||||
"esm": "^3.2.22",
|
||||
"file-loader": "^3.0.1",
|
||||
"eslint-plugin-vue": "^5.2.3",
|
||||
"esm": "^3.2.25",
|
||||
"file-loader": "^4.1.0",
|
||||
"git-revision-webpack-plugin": "^3.0.3",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"inject-loader": "^4.0.1",
|
||||
@ -254,30 +254,30 @@
|
||||
"karma-spec-reporter": "0.0.32",
|
||||
"karma-webpack": "^3.0.5",
|
||||
"license-checker": "^25.0.1",
|
||||
"marked": "^0.6.2",
|
||||
"mini-css-extract-plugin": "^0.6.0",
|
||||
"mocha": "^6.1.4",
|
||||
"marked": "^0.7.0",
|
||||
"mini-css-extract-plugin": "^0.8.0",
|
||||
"mocha": "^6.2.0",
|
||||
"multispinner": "^0.2.1",
|
||||
"node-fetch": "^2.5.0",
|
||||
"node-fetch": "^2.6.0",
|
||||
"node-loader": "^0.6.0",
|
||||
"postcss-loader": "^3.0.0",
|
||||
"postcss-preset-env": "^6.6.0",
|
||||
"raw-loader": "^2.0.0",
|
||||
"require-dir": "^1.2.0",
|
||||
"spectron": "^5.0.0",
|
||||
"spectron": "^7.0.0",
|
||||
"style-loader": "^0.23.1",
|
||||
"svg-sprite-loader": "^4.1.6",
|
||||
"svgo": "^1.2.2",
|
||||
"svgo-loader": "^2.2.0",
|
||||
"svgo": "^1.3.0",
|
||||
"svgo-loader": "^2.2.1",
|
||||
"to-string-loader": "^1.1.5",
|
||||
"url-loader": "^1.1.2",
|
||||
"vue-html-loader": "^1.2.4",
|
||||
"vue-loader": "^15.7.0",
|
||||
"vue-loader": "^15.7.1",
|
||||
"vue-style-loader": "^4.1.2",
|
||||
"vue-template-compiler": "^2.6.10",
|
||||
"webpack": "^4.31.0",
|
||||
"webpack": "^4.36.1",
|
||||
"webpack-bundle-analyzer": "^3.3.2",
|
||||
"webpack-cli": "^3.3.2",
|
||||
"webpack-cli": "^3.3.6",
|
||||
"webpack-dev-server": "^3.7.2",
|
||||
"webpack-hot-middleware": "^2.25.0",
|
||||
"webpack-merge": "^4.2.1"
|
||||
|
@ -1,7 +1,6 @@
|
||||
import path from 'path'
|
||||
|
||||
class EnvPaths {
|
||||
|
||||
/**
|
||||
* @param {string} userDataPath The user data path.
|
||||
* @returns
|
||||
|
@ -56,7 +56,6 @@ export const isMarkdownFile = filepath => {
|
||||
return isFile(filepath) && hasMarkdownExtension(filepath)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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'
|
||||
|
||||
class Accessor {
|
||||
|
||||
/**
|
||||
* @param {AppEnvironment} appEnvironment The application environment instance.
|
||||
*/
|
||||
|
@ -10,7 +10,6 @@ const patchEnvPath = () => {
|
||||
}
|
||||
|
||||
export class AppEnvironment {
|
||||
|
||||
constructor (options) {
|
||||
this._id = envId++
|
||||
this._appPaths = new AppPaths(options.userDataPath)
|
||||
|
@ -17,7 +17,6 @@ import EditorWindow from '../windows/editor'
|
||||
import SettingWindow from '../windows/setting'
|
||||
|
||||
class App {
|
||||
|
||||
/**
|
||||
* @param {Accessor} accessor The application accessor for application instances.
|
||||
* @param {arg.Result} args Parsed application arguments.
|
||||
@ -372,10 +371,9 @@ class App {
|
||||
const { rootDirectory, fileList } = item
|
||||
this._createEditorWindow(rootDirectory, fileList)
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// Open each file and directory in a new window.
|
||||
else {
|
||||
|
||||
for (const pathname of filesToOpen) {
|
||||
this._createEditorWindow(null, [pathname])
|
||||
}
|
||||
@ -504,6 +502,7 @@ class App {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
ipcMain.on('mt::open-setting-window', () => {
|
||||
ipcMain.emit('app-create-settings-window')
|
||||
})
|
||||
|
@ -3,7 +3,6 @@ import EnvPaths from 'common/envPaths'
|
||||
import { ensureDirSync } from 'common/filesystem'
|
||||
|
||||
class AppPaths extends EnvPaths {
|
||||
|
||||
/**
|
||||
* Configure and sets all application paths.
|
||||
*
|
||||
|
@ -51,7 +51,6 @@ class WindowActivityList {
|
||||
}
|
||||
|
||||
class WindowManager extends EventEmitter {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {AppMenu} appMenu The application menu instance.
|
||||
@ -137,7 +136,7 @@ class WindowManager extends EventEmitter {
|
||||
window.removeAllListeners('window-focus')
|
||||
|
||||
this._windowActivity.delete(windowId)
|
||||
let nextWindowId = this._windowActivity.getNewest()
|
||||
const nextWindowId = this._windowActivity.getNewest()
|
||||
this.setActiveWindow(nextWindowId)
|
||||
|
||||
_windows.delete(windowId)
|
||||
|
@ -21,7 +21,7 @@ export const defaultPreferenceWinOptions = {
|
||||
height: 650,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
webSecurity: false,
|
||||
webSecurity: false
|
||||
},
|
||||
fullscreenable: false,
|
||||
fullscreen: false,
|
||||
|
@ -24,7 +24,7 @@ export const normalizeAndResolvePath = pathname => {
|
||||
|
||||
export const writeFile = (pathname, content, extension) => {
|
||||
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}`
|
||||
|
||||
|
@ -124,7 +124,6 @@ const unlinkDir = (win, pathname, type) => {
|
||||
}
|
||||
|
||||
class Watcher {
|
||||
|
||||
/**
|
||||
* @param {Preference} preferences The preference instance.
|
||||
*/
|
||||
|
@ -19,7 +19,7 @@ export const getVirtualLetters = () => {
|
||||
// Full list of supported virtual keys:
|
||||
// https://github.com/parro-it/keyboardevent-from-electron-accelerator/blob/afdbd57bead1e139d7bd03c763778dce6ca8c35d/main.js#L104
|
||||
const currentKeymap = getCurrentKeymap()
|
||||
let vkeys = {}
|
||||
const vkeys = {}
|
||||
for (const key in currentKeymap) {
|
||||
// TODO(fxha): Possibly, we can fix more broken accelerators without apply a manually fix later.
|
||||
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
|
||||
|
||||
class Keybindings {
|
||||
|
||||
/**
|
||||
* @param {string} userDataPath The user data path.
|
||||
*/
|
||||
@ -282,7 +281,7 @@ class Keybindings {
|
||||
|
||||
export const parseMenu = menuTemplate => {
|
||||
const { submenu, accelerator, click, id, visible } = menuTemplate
|
||||
let items = []
|
||||
const items = []
|
||||
if (Array.isArray(menuTemplate)) {
|
||||
for (const item of menuTemplate) {
|
||||
const subitems = parseMenu(item)
|
||||
|
@ -2,13 +2,13 @@ import { ipcMain } from 'electron'
|
||||
import { getMenuItemById } from '../../menu'
|
||||
|
||||
const MENU_ID_FORMAT_MAP = {
|
||||
'strongMenuItem': 'strong',
|
||||
'emphasisMenuItem': 'em',
|
||||
'inlineCodeMenuItem': 'inline_code',
|
||||
'strikeMenuItem': 'del',
|
||||
'hyperlinkMenuItem': 'link',
|
||||
'imageMenuItem': 'image',
|
||||
'mathMenuItem': 'inline_math'
|
||||
strongMenuItem: 'strong',
|
||||
emphasisMenuItem: 'em',
|
||||
inlineCodeMenuItem: 'inline_code',
|
||||
strikeMenuItem: 'del',
|
||||
hyperlinkMenuItem: 'link',
|
||||
imageMenuItem: 'image',
|
||||
mathMenuItem: 'inline_math'
|
||||
}
|
||||
|
||||
const selectFormat = formats => {
|
||||
|
@ -12,21 +12,21 @@ const DISABLE_LABELS = [
|
||||
]
|
||||
|
||||
const MENU_ID_MAP = {
|
||||
'heading1MenuItem': 'h1',
|
||||
'heading2MenuItem': 'h2',
|
||||
'heading3MenuItem': 'h3',
|
||||
'heading4MenuItem': 'h4',
|
||||
'heading5MenuItem': 'h5',
|
||||
'heading6MenuItem': 'h6',
|
||||
'tableMenuItem': 'figure',
|
||||
'codeFencesMenuItem': 'pre',
|
||||
'quoteBlockMenuItem': 'blockquote',
|
||||
'orderListMenuItem': 'ol',
|
||||
'bulletListMenuItem': 'ul',
|
||||
'taskListMenuItem': 'ul',
|
||||
'paragraphMenuItem': 'p',
|
||||
'horizontalLineMenuItem': 'hr',
|
||||
'frontMatterMenuItem': 'pre'
|
||||
heading1MenuItem: 'h1',
|
||||
heading2MenuItem: 'h2',
|
||||
heading3MenuItem: 'h3',
|
||||
heading4MenuItem: 'h4',
|
||||
heading5MenuItem: 'h5',
|
||||
heading6MenuItem: 'h6',
|
||||
tableMenuItem: 'figure',
|
||||
codeFencesMenuItem: 'pre',
|
||||
quoteBlockMenuItem: 'blockquote',
|
||||
orderListMenuItem: 'ol',
|
||||
bulletListMenuItem: 'ul',
|
||||
taskListMenuItem: 'ul',
|
||||
paragraphMenuItem: 'p',
|
||||
horizontalLineMenuItem: 'hr',
|
||||
frontMatterMenuItem: 'pre'
|
||||
}
|
||||
|
||||
const setParagraphMenuItemStatus = bool => {
|
||||
|
@ -14,7 +14,6 @@ export const MenuType = {
|
||||
}
|
||||
|
||||
class AppMenu {
|
||||
|
||||
/**
|
||||
* @param {Preference} preferences The preferences instances.
|
||||
* @param {Keybindings} keybindings The keybindings instances.
|
||||
@ -43,7 +42,7 @@ class AppMenu {
|
||||
if (isOsxOrWindows) app.addRecentDocument(filePath)
|
||||
if (isOsx) return
|
||||
|
||||
let recentDocuments = this.getRecentlyUsedDocuments()
|
||||
const recentDocuments = this.getRecentlyUsedDocuments()
|
||||
const index = recentDocuments.indexOf(filePath)
|
||||
let needSave = index !== 0
|
||||
if (index > 0) {
|
||||
@ -74,7 +73,7 @@ class AppMenu {
|
||||
}
|
||||
|
||||
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)))
|
||||
|
||||
if (recentDocuments.length > MAX_RECENTLY_USED_DOCUMENTS) {
|
||||
|
@ -6,7 +6,7 @@ import { isOsx } from '../../config'
|
||||
|
||||
export default function (keybindings, userPreference, recentlyUsedFiles) {
|
||||
const { autoSave } = userPreference.getAll()
|
||||
let fileMenu = {
|
||||
const fileMenu = {
|
||||
label: 'File',
|
||||
submenu: [{
|
||||
label: 'New Tab',
|
||||
@ -39,7 +39,7 @@ export default function (keybindings, userPreference, recentlyUsedFiles) {
|
||||
}
|
||||
|
||||
if (!isOsx) {
|
||||
let recentlyUsedMenu = {
|
||||
const recentlyUsedMenu = {
|
||||
label: 'Open Recent',
|
||||
submenu: []
|
||||
}
|
||||
@ -150,7 +150,7 @@ export default function (keybindings, userPreference, recentlyUsedFiles) {
|
||||
userSetting(menuItem, browserWindow)
|
||||
}
|
||||
}, {
|
||||
type: 'separator',
|
||||
type: 'separator'
|
||||
}, {
|
||||
label: 'Close Tab',
|
||||
accelerator: keybindings.getAccelerator('fileCloseTab'),
|
||||
|
@ -2,7 +2,7 @@ import { ipcMain } from 'electron'
|
||||
import * as actions from '../actions/view'
|
||||
|
||||
export default function (keybindings) {
|
||||
let viewMenu = {
|
||||
const viewMenu = {
|
||||
label: 'View',
|
||||
submenu: [{
|
||||
id: 'sourceCodeModeMenuItem',
|
||||
|
@ -24,7 +24,6 @@ const isDarkSystemMode = () => {
|
||||
const PREFERENCES_FILE_NAME = 'preferences'
|
||||
|
||||
class Preference extends EventEmitter {
|
||||
|
||||
/**
|
||||
* @param {AppPaths} userDataPath The path instance.
|
||||
*
|
||||
|
@ -11,7 +11,7 @@ export const getUniqueId = () => {
|
||||
export const getRecommendTitleFromMarkdownString = markdown => {
|
||||
const tokens = markdown.match(/#{1,6} {1,}(.+)(?:\n|$)/g)
|
||||
if (!tokens) return ''
|
||||
let headers = tokens.map(t => {
|
||||
const headers = tokens.map(t => {
|
||||
const matches = t.trim().match(/(#{1,6}) {1,}(.+)/)
|
||||
return {
|
||||
level: matches[1].length,
|
||||
|
@ -25,7 +25,6 @@ export const WindowLifecycle = {
|
||||
}
|
||||
|
||||
class BaseWindow extends EventEmitter {
|
||||
|
||||
/**
|
||||
* @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'
|
||||
|
||||
class EditorWindow extends BaseWindow {
|
||||
|
||||
/**
|
||||
* @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'
|
||||
|
||||
class SettingWindow extends BaseWindow {
|
||||
|
||||
/**
|
||||
* @param {Accessor} accessor The application accessor for application instances.
|
||||
*/
|
||||
|
@ -189,20 +189,20 @@ export const DEFAULT_TURNDOWN_CONFIG = {
|
||||
}
|
||||
|
||||
export const FORMAT_MARKER_MAP = {
|
||||
'em': '*',
|
||||
'inline_code': '`',
|
||||
'strong': '**',
|
||||
'del': '~~',
|
||||
'inline_math': '$',
|
||||
'u': {
|
||||
em: '*',
|
||||
inline_code: '`',
|
||||
strong: '**',
|
||||
del: '~~',
|
||||
inline_math: '$',
|
||||
u: {
|
||||
open: '<u>',
|
||||
close: '</u>'
|
||||
},
|
||||
'sub': {
|
||||
sub: {
|
||||
open: '<sub>',
|
||||
close: '</sub>'
|
||||
},
|
||||
'sup': {
|
||||
sup: {
|
||||
open: '<sup>',
|
||||
close: '</sup>'
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ const clickCtrl = ContentState => {
|
||||
eventCenter.dispatch('format-click', {
|
||||
event,
|
||||
formatType,
|
||||
data,
|
||||
data
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
const LINE_BREAKS_REG = /\n/
|
||||
const FUNCTION_TYPE_LANG = {
|
||||
'multiplemath': 'latex',
|
||||
'flowchart': 'yaml',
|
||||
'mermaid': 'yaml',
|
||||
'sequence': 'yaml',
|
||||
multiplemath: 'latex',
|
||||
flowchart: 'yaml',
|
||||
mermaid: 'yaml',
|
||||
sequence: 'yaml',
|
||||
'vega-lite': 'yaml',
|
||||
'html': 'markup'
|
||||
html: 'markup'
|
||||
}
|
||||
|
||||
const containerCtrl = ContentState => {
|
||||
|
@ -60,7 +60,8 @@ const dragDropCtrl = ContentState => {
|
||||
ContentState.prototype.dragoverHandler = function (event) {
|
||||
// Cancel to allow tab drag&drop.
|
||||
if (!event.dataTransfer.types.length) {
|
||||
return event.dataTransfer.dropEffect = 'none'
|
||||
event.dataTransfer.dropEffect = 'none'
|
||||
return
|
||||
}
|
||||
|
||||
if (event.dataTransfer.types.includes('text/uri-list')) {
|
||||
|
@ -167,7 +167,6 @@ const enterCtrl = ContentState => {
|
||||
cb: () => {}
|
||||
})
|
||||
this.selectedImage = null
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@ -447,9 +446,9 @@ const enterCtrl = ContentState => {
|
||||
// If block is pre block when updated, need to focus it.
|
||||
const preParagraphBlock = getParagraphBlock(block)
|
||||
const blockNeedFocus = this.codeBlockUpdate(preParagraphBlock)
|
||||
let tableNeedFocus = this.tableBlockUpdate(preParagraphBlock)
|
||||
let htmlNeedFocus = this.updateHtmlBlock(preParagraphBlock)
|
||||
let mathNeedFocus = this.updateMathBlock(preParagraphBlock)
|
||||
const tableNeedFocus = this.tableBlockUpdate(preParagraphBlock)
|
||||
const htmlNeedFocus = this.updateHtmlBlock(preParagraphBlock)
|
||||
const mathNeedFocus = this.updateMathBlock(preParagraphBlock)
|
||||
let cursorBlock
|
||||
|
||||
switch (true) {
|
||||
|
@ -326,6 +326,7 @@ class ContentState {
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// return block and its parents
|
||||
getParents (block) {
|
||||
const result = []
|
||||
@ -399,6 +400,7 @@ class ContentState {
|
||||
this.removeBlock(block)
|
||||
}
|
||||
}
|
||||
|
||||
// help func in removeBlocks
|
||||
findFigure (block) {
|
||||
if (block.type === 'figure') {
|
||||
@ -490,7 +492,7 @@ class ContentState {
|
||||
}
|
||||
|
||||
getActiveBlocks () {
|
||||
let result = []
|
||||
const result = []
|
||||
let block = this.getBlock(this.cursor.start.key)
|
||||
if (block) result.push(block)
|
||||
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 () {
|
||||
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 startParents = this.getParents(startBlock)
|
||||
const endParents = this.getParents(endBlock)
|
||||
|
@ -87,7 +87,7 @@ const pasteCtrl = ContentState => {
|
||||
if (this.selectedImage) {
|
||||
this.replaceImage(this.selectedImage, {
|
||||
alt: id,
|
||||
src: imagePath,
|
||||
src: imagePath
|
||||
})
|
||||
} else {
|
||||
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.
|
||||
if (targetListType !== originListType) {
|
||||
if (!targetListType) {
|
||||
firstFragment.children.forEach(item => item.isLooseListItem = true)
|
||||
firstFragment.children.forEach(item => (item.isLooseListItem = true))
|
||||
} 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 = {}) {
|
||||
value = value.trim()
|
||||
let matches = []
|
||||
const matches = []
|
||||
const { caseSensitive, highlightIndex } = Object.assign(defaultSearchOption, opt)
|
||||
const { blocks } = this
|
||||
const search = blocks => {
|
||||
|
@ -112,7 +112,7 @@ const tabCtrl = ContentState => {
|
||||
let target = this.getNextSibling(listItem)
|
||||
while (target) {
|
||||
this.appendChild(newList, target)
|
||||
let temp = target
|
||||
const temp = target
|
||||
target = this.getNextSibling(target)
|
||||
this.removeBlock(temp, list)
|
||||
}
|
||||
@ -185,7 +185,6 @@ const tabCtrl = ContentState => {
|
||||
const tokens = tokenizer(text, [], false, labels)
|
||||
let result = null
|
||||
const walkTokens = tkns => {
|
||||
|
||||
for (const token of tkns) {
|
||||
const { marker, type, range, children, srcAndTitle, hrefAndTitle, backlash, closeTag, isFullLink, label } = token
|
||||
const { start, end } = range
|
||||
|
@ -260,7 +260,7 @@ const tableBlockCtrl = ContentState => {
|
||||
|
||||
if (target === 'row') {
|
||||
if (action === 'insert') {
|
||||
let newRow = (location === 'previous' && block.type === 'th')
|
||||
const newRow = (location === 'previous' && block.type === 'th')
|
||||
? createRow(column, true)
|
||||
: createRow(column, false)
|
||||
if (location === 'previous') {
|
||||
|
@ -234,7 +234,7 @@ const updateCtrl = ContentState => {
|
||||
this.removeBlock(nextSibling)
|
||||
this.removeBlock(block)
|
||||
const isLooseListItem = preSibling.children.some(c => c.isLooseListItem)
|
||||
preSibling.children.forEach(c => c.isLooseListItem = isLooseListItem)
|
||||
preSibling.children.forEach(c => (c.isLooseListItem = isLooseListItem))
|
||||
} else if (
|
||||
preSibling &&
|
||||
this.checkSameMarkerOrDelimiter(preSibling, bulletMarkerOrDelimiter)
|
||||
@ -242,7 +242,7 @@ const updateCtrl = ContentState => {
|
||||
this.appendChild(preSibling, newListItemBlock)
|
||||
this.removeBlock(block)
|
||||
const isLooseListItem = preSibling.children.some(c => c.isLooseListItem)
|
||||
preSibling.children.forEach(c => c.isLooseListItem = isLooseListItem)
|
||||
preSibling.children.forEach(c => (c.isLooseListItem = isLooseListItem))
|
||||
} else if (
|
||||
nextSibling &&
|
||||
this.checkSameMarkerOrDelimiter(nextSibling, bulletMarkerOrDelimiter)
|
||||
@ -250,7 +250,7 @@ const updateCtrl = ContentState => {
|
||||
this.insertBefore(newListItemBlock, nextSibling.children[0])
|
||||
this.removeBlock(block)
|
||||
const isLooseListItem = nextSibling.children.some(c => c.isLooseListItem)
|
||||
nextSibling.children.forEach(c => c.isLooseListItem = isLooseListItem)
|
||||
nextSibling.children.forEach(c => (c.isLooseListItem = isLooseListItem))
|
||||
} else {
|
||||
// Create a new list when changing list type, bullet or list delimiter
|
||||
const listBlock = this.createBlock(wrapperTag, {
|
||||
@ -284,7 +284,7 @@ const updateCtrl = ContentState => {
|
||||
}
|
||||
}
|
||||
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)
|
||||
} else {
|
||||
return block
|
||||
@ -420,7 +420,7 @@ const updateCtrl = ContentState => {
|
||||
|
||||
const text = line.text
|
||||
const lines = text.split('\n')
|
||||
let setextLines = []
|
||||
const setextLines = []
|
||||
const postParagraphLines = []
|
||||
let setextLineHasPushed = false
|
||||
|
||||
@ -467,7 +467,7 @@ const updateCtrl = ContentState => {
|
||||
const text = line.text
|
||||
const lines = text.split('\n')
|
||||
const preParagraphLines = []
|
||||
let quoteLines = []
|
||||
const quoteLines = []
|
||||
let quoteLinesHasPushed = false
|
||||
|
||||
for (const l of lines) {
|
||||
|
@ -5,6 +5,7 @@ class EventCenter {
|
||||
this.events = []
|
||||
this.listeners = {}
|
||||
}
|
||||
|
||||
/**
|
||||
* [attachDOMEvent] bind event listener to target, and return a unique ID,
|
||||
* this ID
|
||||
@ -22,6 +23,7 @@ class EventCenter {
|
||||
})
|
||||
return eventId
|
||||
}
|
||||
|
||||
/**
|
||||
* [detachDOMEvent removeEventListener]
|
||||
* @param {[type]} eventId [unique eventId]
|
||||
@ -34,12 +36,14 @@ class EventCenter {
|
||||
target.removeEventListener(event, listener, capture)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [detachAllDomEvents remove all the DOM events handler]
|
||||
*/
|
||||
detachAllDomEvents () {
|
||||
this.events.forEach(event => this.detachDOMEvent(event.eventId))
|
||||
}
|
||||
|
||||
/**
|
||||
* inner method for subscribe and subscribeOnce
|
||||
*/
|
||||
@ -52,12 +56,14 @@ class EventCenter {
|
||||
this.listeners[event] = [handler]
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [subscribe] subscribe custom event
|
||||
*/
|
||||
subscribe (event, listener) {
|
||||
this._subscribe(event, listener)
|
||||
}
|
||||
|
||||
/**
|
||||
* [unsubscribe] unsubscribe custom event
|
||||
*/
|
||||
@ -68,12 +74,14 @@ class EventCenter {
|
||||
listeners.splice(index, 1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [subscribeOnce] usbscribe event and listen once
|
||||
*/
|
||||
subscribeOnce (event, listener) {
|
||||
this._subscribe(event, listener, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* dispatch custom event
|
||||
*/
|
||||
@ -88,6 +96,7 @@ class EventCenter {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Determine whether the event has been bind
|
||||
checkHasBind (cTarget, cEvent, cListener, cCapture) {
|
||||
for (const { target, event, listener, capture } of this.events) {
|
||||
|
@ -13,9 +13,11 @@ import './assets/styles/index.css'
|
||||
|
||||
class Muya {
|
||||
static plugins = []
|
||||
|
||||
static use (plugin) {
|
||||
this.plugins.push(plugin)
|
||||
}
|
||||
|
||||
constructor (container, options) {
|
||||
this.options = Object.assign({}, MUYA_DEFAULT_OPTION, options)
|
||||
const { markdown } = this.options
|
||||
|
@ -15,16 +15,16 @@ export const block = {
|
||||
nptable: noop,
|
||||
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
||||
list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
||||
html: '^ {0,3}(?:' // optional indentation
|
||||
+ '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
||||
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
||||
+ '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
|
||||
+ '|<![A-Z][\\s\\S]*?>\\n*' // (4)
|
||||
+ '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' // (5)
|
||||
+ '|</?(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-]*\\s*>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
|
||||
+ ')',
|
||||
html: '^ {0,3}(?:' + // optional indentation
|
||||
'<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' + // (1)
|
||||
'|comment[^\\n]*(\\n+|$)' + // (2)
|
||||
'|<\\?[\\s\\S]*?\\?>\\n*' + // (3)
|
||||
'|<![A-Z][\\s\\S]*?>\\n*' + // (4)
|
||||
'|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' + // (5)
|
||||
'|</?(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-]*\\s*>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' + // (7) closing tag
|
||||
')',
|
||||
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
||||
table: noop,
|
||||
lheading: /^([^\n]+)\n {0,3}(=|-){2,} *(?:\n+|$)/,
|
||||
@ -38,19 +38,19 @@ export const block = {
|
||||
|
||||
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/
|
||||
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/
|
||||
block.def = edit(block.def).
|
||||
replace('label', block._label).
|
||||
replace('title', block._title).
|
||||
getRegex()
|
||||
block.def = edit(block.def)
|
||||
.replace('label', block._label)
|
||||
.replace('title', block._title)
|
||||
.getRegex()
|
||||
|
||||
block.checkbox = /^\[([ xX])\] +/
|
||||
block.bullet = /(?:[*+-]|\d{1,9}(?:\.|\)))/ // patched: support "(" as ordered list delimiter too
|
||||
// patched: fix https://github.com/marktext/marktext/issues/831#issuecomment-477719256
|
||||
// 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 = edit(block.item, 'gm').
|
||||
replace(/bull/g, block.bullet).
|
||||
getRegex()
|
||||
block.item = edit(block.item, 'gm')
|
||||
.replace(/bull/g, block.bullet)
|
||||
.getRegex()
|
||||
|
||||
block.list = edit(block.list)
|
||||
.replace(/bull/g, block.bullet)
|
||||
@ -58,12 +58,12 @@ block.list = edit(block.list)
|
||||
.replace('def', '\\n+(?=' + block.def.source + ')')
|
||||
.getRegex()
|
||||
|
||||
block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
|
||||
+ '|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'
|
||||
+ '|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'
|
||||
+ '|track|ul'
|
||||
block._tag = 'address|article|aside|base|basefont|blockquote|body|caption' +
|
||||
'|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' +
|
||||
'|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' +
|
||||
'|track|ul'
|
||||
block._comment = /<!--(?!-?>)[\s\S]*?-->/
|
||||
block.html = edit(block.html, 'i')
|
||||
.replace('comment', block._comment)
|
||||
@ -98,9 +98,9 @@ export const gfm = Object.assign({}, normal, {
|
||||
})
|
||||
|
||||
gfm.paragraph = edit(block.paragraph)
|
||||
.replace('(?!', '(?!'
|
||||
+ gfm.fences.source.replace('\\1', '\\2') + '|'
|
||||
+ block.list.source.replace('\\1', '\\3') + '|')
|
||||
.replace('(?!', '(?!' +
|
||||
gfm.fences.source.replace('\\1', '\\2') + '|' +
|
||||
block.list.source.replace('\\1', '\\3') + '|')
|
||||
.getRegex()
|
||||
|
||||
/**
|
||||
@ -118,14 +118,14 @@ export const tables = Object.assign({}, gfm, {
|
||||
|
||||
export const pedantic = Object.assign({}, normal, {
|
||||
html: edit(
|
||||
'^ *(?:comment *(?:\\n|\\s*$)'
|
||||
+ '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
||||
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
|
||||
'^ *(?:comment *(?:\\n|\\s*$)' +
|
||||
'|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' + // closed tag
|
||||
'|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
|
||||
.replace('comment', block._comment)
|
||||
.replace(/tag/g, '(?!(?:'
|
||||
+ '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)'
|
||||
+ '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
|
||||
.replace(/tag/g, '(?!(?:' +
|
||||
'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)' +
|
||||
'\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
|
||||
.getRegex(),
|
||||
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/
|
||||
})
|
||||
|
@ -13,8 +13,8 @@ function marked (src, opt = {}) {
|
||||
throw new Error('marked(): input parameter is undefined or null')
|
||||
}
|
||||
if (typeof src !== 'string') {
|
||||
throw new Error('marked(): input parameter is of type '
|
||||
+ Object.prototype.toString.call(src) + ', string expected')
|
||||
throw new Error('marked(): input parameter is of type ' +
|
||||
Object.prototype.toString.call(src) + ', string expected')
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -119,8 +119,8 @@ export const gfm = Object.assign({}, normal, {
|
||||
emoji: /^(:)([a-z_\d+-]+?)\1/ // not real GFM but put it in here
|
||||
})
|
||||
|
||||
gfm.url = edit(gfm.url, 'i').
|
||||
replace('email', gfm._extended_email)
|
||||
gfm.url = edit(gfm.url, 'i')
|
||||
.replace('email', gfm._extended_email)
|
||||
.getRegex()
|
||||
|
||||
/**
|
||||
|
@ -392,8 +392,8 @@ Lexer.prototype.token = function (src, top) {
|
||||
type: this.options.sanitize
|
||||
? 'paragraph'
|
||||
: 'html',
|
||||
pre: !this.options.sanitizer
|
||||
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
||||
pre: !this.options.sanitizer &&
|
||||
(cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
||||
text: cap[0]
|
||||
})
|
||||
continue
|
||||
|
@ -194,7 +194,7 @@ Parser.prototype.tok = function () {
|
||||
return this.renderer.paragraph(this.parseText())
|
||||
}
|
||||
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) {
|
||||
console.error(errMsg)
|
||||
} else {
|
||||
|
@ -42,7 +42,7 @@ Renderer.prototype.emoji = function (text, emoji) {
|
||||
Renderer.prototype.code = function (code, infostring, escaped, codeBlockStyle) {
|
||||
const lang = (infostring || '').match(/\S*/)[0]
|
||||
if (this.options.highlight) {
|
||||
let out = this.options.highlight(code, lang)
|
||||
const out = this.options.highlight(code, lang)
|
||||
if (out !== null && out !== code) {
|
||||
escaped = true
|
||||
code = out
|
||||
|
@ -18,7 +18,7 @@ Slugger.prototype.slug = function (value) {
|
||||
.replace(/\s/g, '-')
|
||||
|
||||
if (this.seen.hasOwnProperty(slug)) {
|
||||
let originalSlug = slug
|
||||
const originalSlug = slug
|
||||
do {
|
||||
this.seen[originalSlug]++
|
||||
slug = originalSlug + '-' + this.seen[originalSlug]
|
||||
|
@ -105,8 +105,8 @@ const resolveUrl = function resolveUrl(base, href) {
|
||||
return base + href
|
||||
}
|
||||
}
|
||||
let baseUrls = {}
|
||||
let originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i
|
||||
const baseUrls = {}
|
||||
const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i
|
||||
|
||||
export const noop = function noop () {}
|
||||
noop.exec = noop
|
||||
@ -114,9 +114,9 @@ noop.exec = noop
|
||||
export const splitCells = function splitCells (tableRow, count) {
|
||||
// ensure that every cell-delimiting pipe has a space
|
||||
// before it to distinguish it from an escaped pipe
|
||||
let row = tableRow.replace(/\|/g, function (match, offset, str) {
|
||||
let escaped = false,
|
||||
curr = offset
|
||||
const row = tableRow.replace(/\|/g, function (match, offset, str) {
|
||||
let escaped = false
|
||||
let curr = offset
|
||||
while (--curr >= 0 && str[curr] === '\\') escaped = !escaped
|
||||
if (escaped) {
|
||||
// odd number of slashes means | is escaped
|
||||
@ -126,9 +126,9 @@ export const splitCells = function splitCells(tableRow, count) {
|
||||
// add space before unescaped |
|
||||
return ' |'
|
||||
}
|
||||
}),
|
||||
cells = row.split(/ \|/),
|
||||
i = 0
|
||||
})
|
||||
const cells = row.split(/ \|/)
|
||||
let i = 0
|
||||
|
||||
if (cells.length > 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.
|
||||
while (suffLen < str.length) {
|
||||
let currChar = str.charAt(str.length - suffLen - 1)
|
||||
const currChar = str.charAt(str.length - suffLen - 1)
|
||||
if (currChar === c && !invert) {
|
||||
suffLen++
|
||||
} else if (currChar !== c && invert) {
|
||||
@ -188,4 +188,3 @@ export const findClosingBracket = function findClosingBracket(str, b) {
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
|
@ -109,8 +109,8 @@ class StateRender {
|
||||
async renderDiagram () {
|
||||
const cache = this.diagramCache
|
||||
const RENDER_MAP = {
|
||||
'flowchart': flowchart,
|
||||
'sequence': Diagram,
|
||||
flowchart: flowchart,
|
||||
sequence: Diagram,
|
||||
'vega-lite': vegaEmbed
|
||||
}
|
||||
if (cache.size) {
|
||||
@ -123,7 +123,9 @@ class StateRender {
|
||||
Object.assign(options, { theme: this.muya.options.sequenceTheme })
|
||||
} else if (functionType === 'vega-lite') {
|
||||
Object.assign(options, {
|
||||
actions: false, tooltip: false, renderer: 'svg',
|
||||
actions: false,
|
||||
tooltip: false,
|
||||
renderer: 'svg',
|
||||
theme: this.muya.options.vegaTheme
|
||||
})
|
||||
}
|
||||
|
@ -4,14 +4,14 @@ import { renderEditIcon } from './renderContainerEditIcon'
|
||||
import { h } from '../snabbdom'
|
||||
|
||||
const PRE_BLOCK_HASH = {
|
||||
'fencecode': `.${CLASS_OR_ID['AG_FENCE_CODE']}`,
|
||||
'indentcode': `.${CLASS_OR_ID['AG_INDENT_CODE']}`,
|
||||
'html': `.${CLASS_OR_ID['AG_HTML_BLOCK']}`,
|
||||
'frontmatter': `.${CLASS_OR_ID['AG_FRONT_MATTER']}`,
|
||||
'multiplemath': `.${CLASS_OR_ID['AG_MULTIPLE_MATH']}`,
|
||||
'flowchart': `.${CLASS_OR_ID['AG_FLOWCHART']}`,
|
||||
'sequence': `.${CLASS_OR_ID['AG_SEQUENCE']}`,
|
||||
'mermaid': `.${CLASS_OR_ID['AG_MERMAID']}`,
|
||||
fencecode: `.${CLASS_OR_ID['AG_FENCE_CODE']}`,
|
||||
indentcode: `.${CLASS_OR_ID['AG_INDENT_CODE']}`,
|
||||
html: `.${CLASS_OR_ID['AG_HTML_BLOCK']}`,
|
||||
frontmatter: `.${CLASS_OR_ID['AG_FRONT_MATTER']}`,
|
||||
multiplemath: `.${CLASS_OR_ID['AG_MULTIPLE_MATH']}`,
|
||||
flowchart: `.${CLASS_OR_ID['AG_FLOWCHART']}`,
|
||||
sequence: `.${CLASS_OR_ID['AG_SEQUENCE']}`,
|
||||
mermaid: `.${CLASS_OR_ID['AG_MERMAID']}`,
|
||||
'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'
|
||||
|
||||
const FUNCTION_TYPE_HASH = {
|
||||
'mermaid': mermaidIcon,
|
||||
'flowchart': flowchartIcon,
|
||||
'sequence': sequenceIcon,
|
||||
mermaid: mermaidIcon,
|
||||
flowchart: flowchartIcon,
|
||||
sequence: sequenceIcon,
|
||||
'vega-lite': vegaIcon,
|
||||
'table': newTableIcon,
|
||||
'html': htmlIcon,
|
||||
'multiplemath': mathblockIcon,
|
||||
'fencecode': codeIcon,
|
||||
'indentcode': codeIcon,
|
||||
'frontmatter': frontMatterIcon
|
||||
table: newTableIcon,
|
||||
html: htmlIcon,
|
||||
multiplemath: mathblockIcon,
|
||||
fencecode: codeIcon,
|
||||
indentcode: codeIcon,
|
||||
frontmatter: frontMatterIcon
|
||||
}
|
||||
|
||||
export default function renderIcon (block) {
|
||||
|
@ -50,7 +50,7 @@ const renderToolBar = (type, tools, activeBlocks) => {
|
||||
}
|
||||
}, 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, {
|
||||
attrs: {
|
||||
|
@ -10,7 +10,6 @@ export default function htmlRuby (h, cursor, block, token, outerClass) {
|
||||
|
||||
const previewSelector = `span.${CLASS_OR_ID['AG_RUBY_RENDER']}`
|
||||
|
||||
|
||||
return children ? [
|
||||
h(`span.${className}.${CLASS_OR_ID['AG_RUBY']}`, [
|
||||
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 */
|
||||
export const beginRules = {
|
||||
'hr': /^(\*{3,}$|^\-{3,}$|^\_{3,}$)/,
|
||||
'code_fense': /^(`{3,})([^`]*)$/,
|
||||
'header': /(^ {0,3}#{1,6}(\s{1,}|$))/,
|
||||
'reference_definition': /^( {0,3}\[)([^\]]+?)(\\*)(\]: *)(<?)([^\s>]+)(>?)(?:( +)(["'(]?)([^\n"'\(\)]+)\9)?( *)$/,
|
||||
hr: /^(\*{3,}$|^\-{3,}$|^\_{3,}$)/,
|
||||
code_fense: /^(`{3,})([^`]*)$/,
|
||||
header: /(^ {0,3}#{1,6}(\s{1,}|$))/,
|
||||
reference_definition: /^( {0,3}\[)([^\]]+?)(\\*)(\]: *)(<?)([^\s>]+)(>?)(?:( +)(["'(]?)([^\n"'\(\)]+)\9)?( *)$/,
|
||||
|
||||
// extra syntax (not belogs to GFM)
|
||||
'multiple_math': /^(\$\$)$/
|
||||
multiple_math: /^(\$\$)$/
|
||||
}
|
||||
|
||||
export const inlineRules = {
|
||||
'strong': /^(\*\*|__)(?=\S)([\s\S]*?[^\s\\])(\\*)\1(?!(\*|_))/, // can nest
|
||||
'em': /^(\*|_)(?=\S)([\s\S]*?[^\s\*\\])(\\*)\1(?!\1)/, // can nest
|
||||
'inline_code': /^(`{1,3})([^`]+?|.{2,})\1/,
|
||||
'image': /^(\!\[)(.*?)(\\*)\]\((.*?)(\\*)\)/,
|
||||
'link': /^(\[)((?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*?)(\\*)\]\((.*?)(\\*)\)/, // can nest
|
||||
'emoji': /^(:)([a-z_\d+-]+?)\1/,
|
||||
'del': /^(~{2})(?=\S)([\s\S]*?\S)(\\*)\1/, // can nest
|
||||
'auto_link': /^(https?:\/\/[^\s]+)(?=\s|$)/,
|
||||
'reference_link': /^\[([^\]]+?)(\\*)\](?:\[([^\]]*?)(\\*)\])?/,
|
||||
'reference_image': /^\!\[([^\]]+?)(\\*)\](?:\[([^\]]*?)(\\*)\])?/,
|
||||
'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_escape': new RegExp(`^(${escapeCharacters.join('|')})`, 'i'),
|
||||
'soft_line_break': /^(\n)(?!\n)/,
|
||||
'hard_line_break': /^( {2,})(\n)(?!\n)/,
|
||||
strong: /^(\*\*|__)(?=\S)([\s\S]*?[^\s\\])(\\*)\1(?!(\*|_))/, // can nest
|
||||
em: /^(\*|_)(?=\S)([\s\S]*?[^\s\*\\])(\\*)\1(?!\1)/, // can nest
|
||||
inline_code: /^(`{1,3})([^`]+?|.{2,})\1/,
|
||||
image: /^(\!\[)(.*?)(\\*)\]\((.*?)(\\*)\)/,
|
||||
link: /^(\[)((?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*?)(\\*)\]\((.*?)(\\*)\)/, // can nest
|
||||
emoji: /^(:)([a-z_\d+-]+?)\1/,
|
||||
del: /^(~{2})(?=\S)([\s\S]*?\S)(\\*)\1/, // can nest
|
||||
auto_link: /^(https?:\/\/[^\s]+)(?=\s|$)/,
|
||||
reference_link: /^\[([^\]]+?)(\\*)\](?:\[([^\]]*?)(\\*)\])?/,
|
||||
reference_image: /^\!\[([^\]]+?)(\\*)\](?:\[([^\]]*?)(\\*)\])?/,
|
||||
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_escape: new RegExp(`^(${escapeCharacters.join('|')})`, 'i'),
|
||||
soft_line_break: /^(\n)(?!\n)/,
|
||||
hard_line_break: /^( {2,})(\n)(?!\n)/,
|
||||
|
||||
// patched math marker `$`
|
||||
'backlash': /^(\\)([\\`*{}\[\]()#+\-.!_>~:\|\<\>$]{1})/,
|
||||
backlash: /^(\\)([\\`*{}\[\]()#+\-.!_>~:\|\<\>$]{1})/,
|
||||
|
||||
// extra (not belongs to GFM)
|
||||
'inline_math': /^(\$)([^\$]*?[^\$\\])(\\*)\1(?!\1)/
|
||||
inline_math: /^(\$)([^\$]*?[^\$\\])(\\*)\1(?!\1)/
|
||||
}
|
||||
/* eslint-enable no-useless-escape */
|
||||
|
@ -66,7 +66,7 @@ function initLoadLanguage (Prism) {
|
||||
})
|
||||
}
|
||||
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)) {
|
||||
|
@ -72,7 +72,7 @@ export const findNearestParagraph = node => {
|
||||
|
||||
export const findOutMostParagraph = node => {
|
||||
do {
|
||||
let parentNode = node.parentNode
|
||||
const parentNode = node.parentNode
|
||||
if (isMuyaEditorElement(parentNode) && isAganippeParagraph(node)) return node
|
||||
node = parentNode
|
||||
} while (node)
|
||||
|
@ -209,7 +209,7 @@ class Selection {
|
||||
// to move the cursor back to the start of the correct paragraph
|
||||
importSelectionMoveCursorPastBlocks (root, index = 1, range) {
|
||||
const treeWalker = this.doc.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, filterOnlyParentElements, false)
|
||||
let startContainer = range.startContainer
|
||||
const startContainer = range.startContainer
|
||||
let startBlock
|
||||
let targetNode
|
||||
let currIndex = 0
|
||||
@ -279,8 +279,8 @@ class Selection {
|
||||
const { left } = this.getCaretOffsets(root)
|
||||
const markedText = root.textContent
|
||||
const { type, info } = getCursorPositionWithinMarkedText(markedText, left)
|
||||
let pre = markedText.slice(0, left)
|
||||
let post = markedText.slice(left)
|
||||
const pre = markedText.slice(0, left)
|
||||
const post = markedText.slice(left)
|
||||
switch (type) {
|
||||
case 'OUT':
|
||||
return {
|
||||
|
@ -7,6 +7,7 @@ import './index.css'
|
||||
|
||||
class CodePicker extends BaseScrollFloat {
|
||||
static pluginName = 'codePicker'
|
||||
|
||||
constructor (muya) {
|
||||
const name = 'ag-list-picker'
|
||||
super(muya, name)
|
||||
|
@ -5,6 +5,7 @@ import './index.css'
|
||||
|
||||
class EmojiPicker extends BaseScrollFloat {
|
||||
static pluginName = 'emojiPicker'
|
||||
|
||||
constructor (muya) {
|
||||
const name = 'ag-emoji-picker'
|
||||
super(muya, name)
|
||||
|
@ -16,6 +16,7 @@ const defaultOptions = {
|
||||
|
||||
class FormatPicker extends BaseFloat {
|
||||
static pluginName = 'formatPicker'
|
||||
|
||||
constructor (muya, options = {}) {
|
||||
const name = 'ag-format-picker'
|
||||
const opts = Object.assign({}, defaultOptions, options)
|
||||
|
@ -20,6 +20,7 @@ const defaultOptions = {
|
||||
|
||||
class FrontMenu extends BaseFloat {
|
||||
static pluginName = 'frontMenu'
|
||||
|
||||
constructor (muya, options = {}) {
|
||||
const name = 'ag-front-menu'
|
||||
const opts = Object.assign({}, defaultOptions, options)
|
||||
|
@ -14,6 +14,7 @@ const iconhash = {
|
||||
|
||||
class ImagePathPicker extends BaseScrollFloat {
|
||||
static pluginName = 'imagePathPicker'
|
||||
|
||||
constructor (muya) {
|
||||
const name = 'ag-list-picker'
|
||||
super(muya, name)
|
||||
@ -41,7 +42,7 @@ class ImagePathPicker extends BaseScrollFloat {
|
||||
|
||||
render () {
|
||||
const { renderArray, oldVnode, scrollElement, activeItem } = this
|
||||
let children = renderArray.map((item) => {
|
||||
const children = renderArray.map((item) => {
|
||||
const { text, iconClass } = item
|
||||
const icon = h('div.icon-wrapper', h('svg', {
|
||||
attrs: {
|
||||
|
@ -8,6 +8,7 @@ import './index.css'
|
||||
|
||||
class ImageSelector extends BaseFloat {
|
||||
static pluginName = 'imageSelector'
|
||||
|
||||
constructor (muya) {
|
||||
const name = 'ag-image-selector'
|
||||
const options = {
|
||||
@ -35,6 +36,7 @@ class ImageSelector extends BaseFloat {
|
||||
this.floatBox.classList.add('ag-image-selector-wrapper')
|
||||
this.listen()
|
||||
}
|
||||
|
||||
listen () {
|
||||
super.listen()
|
||||
const { eventCenter } = this.muya
|
||||
|
@ -30,7 +30,6 @@ const COMMAND_KEY = isOsx ? '⌘' : '⌃'
|
||||
// Caps Lock ⇪
|
||||
// Fn
|
||||
|
||||
|
||||
// Command (or Cmd) ⌘
|
||||
// Shift ⇧
|
||||
// Option (or Alt) ⌥
|
||||
@ -38,7 +37,6 @@ const COMMAND_KEY = isOsx ? '⌘' : '⌃'
|
||||
// Caps Lock ⇪
|
||||
// Fn
|
||||
|
||||
|
||||
export const quicInsertObj = {
|
||||
'basic block': [{
|
||||
title: 'Paragraph',
|
||||
@ -59,7 +57,7 @@ export const quicInsertObj = {
|
||||
shortCut: `⌥${COMMAND_KEY}Y`,
|
||||
icon: frontMatterIcon
|
||||
}],
|
||||
'header': [{
|
||||
header: [{
|
||||
title: 'Header 1',
|
||||
subTitle: '# Lorem Ipsum is simply ...',
|
||||
label: 'heading 1',
|
||||
@ -146,7 +144,7 @@ export const quicInsertObj = {
|
||||
shortCut: `⌥${COMMAND_KEY}X`,
|
||||
icon: todoListIcon
|
||||
}],
|
||||
'diagram': [{
|
||||
diagram: [{
|
||||
title: 'Vega Chart',
|
||||
subTitle: 'Render flow chart by vega-lite.js.',
|
||||
label: 'vega-lite',
|
||||
|
@ -7,6 +7,7 @@ import './index.css'
|
||||
|
||||
class QuickInsert extends BaseScrollFloat {
|
||||
static pluginName = 'quickInsert'
|
||||
|
||||
constructor (muya) {
|
||||
const name = 'ag-quick-insert'
|
||||
super(muya, name)
|
||||
@ -121,8 +122,8 @@ class QuickInsert extends BaseScrollFloat {
|
||||
selectItem (item) {
|
||||
const { contentState } = this.muya
|
||||
this.block.text = ''
|
||||
let { key } = this.block
|
||||
let offset = 0
|
||||
const { key } = this.block
|
||||
const offset = 0
|
||||
contentState.cursor = {
|
||||
start: { key, offset },
|
||||
end: { key, offset }
|
||||
|
@ -5,6 +5,7 @@ import { EVENT_KEYS } from '../../config'
|
||||
|
||||
class TablePicker extends BaseFloat {
|
||||
static pluginName = 'tablePicker'
|
||||
|
||||
constructor (muya) {
|
||||
const name = 'ag-table-picker'
|
||||
super(muya, name)
|
||||
@ -124,7 +125,7 @@ class TablePicker extends BaseFloat {
|
||||
|
||||
keyupHandler (event, type) {
|
||||
let number = +this.select[type]
|
||||
let value = +event.target.value
|
||||
const value = +event.target.value
|
||||
if (event.key === EVENT_KEYS.ArrowUp) {
|
||||
number++
|
||||
} else if (event.key === EVENT_KEYS.ArrowDown) {
|
||||
|
@ -56,8 +56,8 @@ class ExportHtml {
|
||||
async renderDiagram () {
|
||||
const selector = 'code.language-vega-lite, code.language-flowchart, code.language-sequence'
|
||||
const RENDER_MAP = {
|
||||
'flowchart': flowchart,
|
||||
'sequence': Diagram,
|
||||
flowchart: flowchart,
|
||||
sequence: Diagram,
|
||||
'vega-lite': vegaEmbed
|
||||
}
|
||||
const codes = this.exportContainer.querySelectorAll(selector)
|
||||
@ -74,7 +74,9 @@ class ExportHtml {
|
||||
Object.assign(options, { theme: 'hand' })
|
||||
} else if (functionType === 'vega-lite') {
|
||||
Object.assign(options, {
|
||||
actions: false, tooltip: false, renderer: 'svg',
|
||||
actions: false,
|
||||
tooltip: false,
|
||||
renderer: 'svg',
|
||||
theme: 'latimes' // only render light theme
|
||||
})
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ class ExportMarkdown {
|
||||
}
|
||||
listInfo.listCount++
|
||||
|
||||
const delimiter = bulletMarkerOrDelimiter ? bulletMarkerOrDelimiter : '.'
|
||||
const delimiter = bulletMarkerOrDelimiter || '.'
|
||||
itemMarker = `${n}${delimiter} `
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ const importRegister = ContentState => {
|
||||
let token
|
||||
let block
|
||||
let value
|
||||
let parentList = [ rootState ]
|
||||
const parentList = [rootState]
|
||||
const languageLoaded = new Set()
|
||||
|
||||
while ((token = tokens.shift())) {
|
||||
@ -363,8 +363,8 @@ const importRegister = ContentState => {
|
||||
const { anchor, focus } = this.cursor
|
||||
const anchorBlock = this.getBlock(anchor.key)
|
||||
const focusBlock = this.getBlock(focus.key)
|
||||
let { text: anchorText } = anchorBlock
|
||||
let { text: focusText } = focusBlock
|
||||
const { text: anchorText } = anchorBlock
|
||||
const { text: focusText } = focusBlock
|
||||
if (anchor.key === focus.key) {
|
||||
const minOffset = Math.min(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 = [{
|
||||
'name': 'objectivec',
|
||||
'mode': 'clike',
|
||||
'mime': 'text/x-objectivec'
|
||||
name: 'objectivec',
|
||||
mode: 'clike',
|
||||
mime: 'text/x-objectivec'
|
||||
}, {
|
||||
'name': 'swift',
|
||||
'mode': 'swift',
|
||||
'mime': 'text/x-swift'
|
||||
name: 'swift',
|
||||
mode: 'swift',
|
||||
mime: 'text/x-swift'
|
||||
}, {
|
||||
'name': 'c_cpp',
|
||||
'mode': 'clike',
|
||||
'mime': 'text/x-csrc'
|
||||
name: 'c_cpp',
|
||||
mode: 'clike',
|
||||
mime: 'text/x-csrc'
|
||||
}, {
|
||||
'name': 'c',
|
||||
'mode': 'clike',
|
||||
'mime': 'text/x-csrc'
|
||||
name: 'c',
|
||||
mode: 'clike',
|
||||
mime: 'text/x-csrc'
|
||||
}, {
|
||||
'name': 'c++',
|
||||
'mode': 'clike',
|
||||
'mime': 'text/x-c++src'
|
||||
name: 'c++',
|
||||
mode: 'clike',
|
||||
mime: 'text/x-c++src'
|
||||
}, {
|
||||
'name': 'cmake',
|
||||
'mode': 'cmake',
|
||||
'mime': 'text/x-cmake'
|
||||
name: 'cmake',
|
||||
mode: 'cmake',
|
||||
mime: 'text/x-cmake'
|
||||
}, {
|
||||
'name': 'lisp',
|
||||
'mode': 'commonlisp',
|
||||
'mime': 'text/x-common-lisp'
|
||||
name: 'lisp',
|
||||
mode: 'commonlisp',
|
||||
mime: 'text/x-common-lisp'
|
||||
}, {
|
||||
'name': 'pascal',
|
||||
'mode': 'pascal',
|
||||
'mime': 'text/x-pascal'
|
||||
name: 'pascal',
|
||||
mode: 'pascal',
|
||||
mime: 'text/x-pascal'
|
||||
}, {
|
||||
'name': 'eiffel',
|
||||
'mode': 'eiffel',
|
||||
'mime': 'text/x-eiffel'
|
||||
name: 'eiffel',
|
||||
mode: 'eiffel',
|
||||
mime: 'text/x-eiffel'
|
||||
}, {
|
||||
'name': 'yaml',
|
||||
'mode': 'yaml',
|
||||
'mime': 'text/x-yaml'
|
||||
name: 'yaml',
|
||||
mode: 'yaml',
|
||||
mime: 'text/x-yaml'
|
||||
}, {
|
||||
'name': 'xml',
|
||||
'mode': 'xml',
|
||||
'mime': 'application/xml'
|
||||
name: 'xml',
|
||||
mode: 'xml',
|
||||
mime: 'application/xml'
|
||||
}, {
|
||||
'name': 'django',
|
||||
'mode': 'django',
|
||||
'mime': 'text/x-django'
|
||||
name: 'django',
|
||||
mode: 'django',
|
||||
mime: 'text/x-django'
|
||||
}, {
|
||||
'name': 'clojure',
|
||||
'mode': 'clojure',
|
||||
'mime': 'text/x-clojure'
|
||||
name: 'clojure',
|
||||
mode: 'clojure',
|
||||
mime: 'text/x-clojure'
|
||||
}, {
|
||||
'name': 'crystal',
|
||||
'mode': 'crystal',
|
||||
'mime': 'text/x-crystal'
|
||||
name: 'crystal',
|
||||
mode: 'crystal',
|
||||
mime: 'text/x-crystal'
|
||||
}, {
|
||||
'name': 'ruby',
|
||||
'mode': 'ruby',
|
||||
'mime': 'text/x-ruby'
|
||||
name: 'ruby',
|
||||
mode: 'ruby',
|
||||
mime: 'text/x-ruby'
|
||||
}, {
|
||||
'name': 'python',
|
||||
'mode': 'python',
|
||||
'mime': 'text/x-python'
|
||||
name: 'python',
|
||||
mode: 'python',
|
||||
mime: 'text/x-python'
|
||||
}, {
|
||||
'name': 'sh',
|
||||
'mode': 'shell',
|
||||
'mime': 'text/x-sh'
|
||||
name: 'sh',
|
||||
mode: 'shell',
|
||||
mime: 'text/x-sh'
|
||||
}, { /* alias */
|
||||
'name': 'shell',
|
||||
'mode': 'shell',
|
||||
'mime': 'text/x-sh'
|
||||
name: 'shell',
|
||||
mode: 'shell',
|
||||
mime: 'text/x-sh'
|
||||
}, {
|
||||
'name': 'less',
|
||||
'mode': 'css',
|
||||
'mime': 'text/css'
|
||||
name: 'less',
|
||||
mode: 'css',
|
||||
mime: 'text/css'
|
||||
}, {
|
||||
'name': 'php',
|
||||
'mode': 'php',
|
||||
'mime': 'application/x-httpd-php'
|
||||
name: 'php',
|
||||
mode: 'php',
|
||||
mime: 'application/x-httpd-php'
|
||||
}, {
|
||||
'name': 'json',
|
||||
'mode': 'javascript',
|
||||
'mime': 'application/json'
|
||||
name: 'json',
|
||||
mode: 'javascript',
|
||||
mime: 'application/json'
|
||||
}, {
|
||||
'name': 'smarty',
|
||||
'mode': 'smarty',
|
||||
'mime': 'text/x-smarty'
|
||||
name: 'smarty',
|
||||
mode: 'smarty',
|
||||
mime: 'text/x-smarty'
|
||||
}, {
|
||||
'name': 'cobol',
|
||||
'mode': 'cobol',
|
||||
'mime': 'text/x-cobol'
|
||||
name: 'cobol',
|
||||
mode: 'cobol',
|
||||
mime: 'text/x-cobol'
|
||||
}, {
|
||||
'name': 'go',
|
||||
'mode': 'go',
|
||||
'mime': 'text/x-go'
|
||||
name: 'go',
|
||||
mode: 'go',
|
||||
mime: 'text/x-go'
|
||||
}, { /* alias */
|
||||
'name': 'golang',
|
||||
'mode': 'go',
|
||||
'mime': 'text/x-go'
|
||||
name: 'golang',
|
||||
mode: 'go',
|
||||
mime: 'text/x-go'
|
||||
}, {
|
||||
'name': 'makefile',
|
||||
'mode': 'shell', /* makefile syntax is not supported by CodeMirror */
|
||||
'mime': 'text/x-sh'
|
||||
name: 'makefile',
|
||||
mode: 'shell', /* makefile syntax is not supported by CodeMirror */
|
||||
mime: 'text/x-sh'
|
||||
}, {
|
||||
'name': 'ocaml',
|
||||
'mode': 'mllike',
|
||||
'mime': 'text/x-ocaml'
|
||||
name: 'ocaml',
|
||||
mode: 'mllike',
|
||||
mime: 'text/x-ocaml'
|
||||
}, {
|
||||
'name': 'textile',
|
||||
'mode': 'textile',
|
||||
'mime': 'text/x-textile'
|
||||
name: 'textile',
|
||||
mode: 'textile',
|
||||
mime: 'text/x-textile'
|
||||
}, {
|
||||
'name': 'd',
|
||||
'mode': 'd',
|
||||
'mime': 'text/x-d'
|
||||
name: 'd',
|
||||
mode: 'd',
|
||||
mime: 'text/x-d'
|
||||
}, {
|
||||
'name': 'jade',
|
||||
'mode': 'pug',
|
||||
'mime': 'text/x-pug'
|
||||
name: 'jade',
|
||||
mode: 'pug',
|
||||
mime: 'text/x-pug'
|
||||
}, {
|
||||
'name': 'lua',
|
||||
'mode': 'lua',
|
||||
'mime': 'text/x-lua'
|
||||
name: 'lua',
|
||||
mode: 'lua',
|
||||
mime: 'text/x-lua'
|
||||
}, {
|
||||
'name': 'coffee',
|
||||
'mode': 'coffeescript',
|
||||
'mime': 'text/x-coffeescript'
|
||||
name: 'coffee',
|
||||
mode: 'coffeescript',
|
||||
mime: 'text/x-coffeescript'
|
||||
}, {
|
||||
'name': 'html',
|
||||
'mode': 'htmlmixed',
|
||||
'mime': 'text/html'
|
||||
name: 'html',
|
||||
mode: 'htmlmixed',
|
||||
mime: 'text/html'
|
||||
}, {
|
||||
'name': 'pgsql',
|
||||
'mode': 'sql',
|
||||
'mime': 'text/x-sql'
|
||||
name: 'pgsql',
|
||||
mode: 'sql',
|
||||
mime: 'text/x-sql'
|
||||
}, {
|
||||
'name': 'haskell',
|
||||
'mode': 'haskell',
|
||||
'mime': 'text/x-haskell'
|
||||
name: 'haskell',
|
||||
mode: 'haskell',
|
||||
mime: 'text/x-haskell'
|
||||
}, {
|
||||
'name': 'jsp',
|
||||
'mode': 'htmlembedded',
|
||||
'mime': 'application/x-jsp'
|
||||
name: 'jsp',
|
||||
mode: 'htmlembedded',
|
||||
mime: 'application/x-jsp'
|
||||
}, {
|
||||
'name': 'tcl',
|
||||
'mode': 'tcl',
|
||||
'mime': 'text/x-tcl'
|
||||
name: 'tcl',
|
||||
mode: 'tcl',
|
||||
mime: 'text/x-tcl'
|
||||
}, {
|
||||
'name': 'ini',
|
||||
'mode': 'properties',
|
||||
'mime': 'text/x-properties'
|
||||
name: 'ini',
|
||||
mode: 'properties',
|
||||
mime: 'text/x-properties'
|
||||
}, {
|
||||
'name': 'jsoniq',
|
||||
'mode': 'javascript',
|
||||
'mime': 'application/json'
|
||||
name: 'jsoniq',
|
||||
mode: 'javascript',
|
||||
mime: 'application/json'
|
||||
}, {
|
||||
'name': 'vhdl',
|
||||
'mode': 'vhdl',
|
||||
'mime': 'text/x-vhdl'
|
||||
name: 'vhdl',
|
||||
mode: 'vhdl',
|
||||
mime: 'text/x-vhdl'
|
||||
}, {
|
||||
'name': 'verilog',
|
||||
'mode': 'verilog',
|
||||
'mime': 'text/x-systemverilog'
|
||||
name: 'verilog',
|
||||
mode: 'verilog',
|
||||
mime: 'text/x-systemverilog'
|
||||
}, {
|
||||
'name': 'csharp',
|
||||
'mode': 'clike',
|
||||
'mime': 'text/x-csharp'
|
||||
name: 'csharp',
|
||||
mode: 'clike',
|
||||
mime: 'text/x-csharp'
|
||||
}, {
|
||||
'name': 'rust',
|
||||
'mode': 'rust',
|
||||
'mime': 'text/x-rustsrc'
|
||||
name: 'rust',
|
||||
mode: 'rust',
|
||||
mime: 'text/x-rustsrc'
|
||||
}, {
|
||||
'name': 'livescript',
|
||||
'mode': 'livescript',
|
||||
'mime': 'text/x-livescript'
|
||||
name: 'livescript',
|
||||
mode: 'livescript',
|
||||
mime: 'text/x-livescript'
|
||||
}, {
|
||||
'name': 'jsx',
|
||||
'mode': 'jsx',
|
||||
'mime': 'text/jsx'
|
||||
name: 'jsx',
|
||||
mode: 'jsx',
|
||||
mime: 'text/jsx'
|
||||
}, {
|
||||
'name': 'protobuf',
|
||||
'mode': 'protobuf',
|
||||
'mime': 'text/x-protobuf'
|
||||
name: 'protobuf',
|
||||
mode: 'protobuf',
|
||||
mime: 'text/x-protobuf'
|
||||
}, {
|
||||
'name': 'markdown',
|
||||
'mode': 'gfm',
|
||||
'mime': 'text/x-gfm'
|
||||
name: 'markdown',
|
||||
mode: 'gfm',
|
||||
mime: 'text/x-gfm'
|
||||
}, {
|
||||
'name': 'rst',
|
||||
'mode': 'rst',
|
||||
'mime': 'text/x-rst'
|
||||
name: 'rst',
|
||||
mode: 'rst',
|
||||
mime: 'text/x-rst'
|
||||
}, {
|
||||
'name': 'LaTeX',
|
||||
'mode': 'stex',
|
||||
'mime': 'text/x-latex'
|
||||
name: 'LaTeX',
|
||||
mode: 'stex',
|
||||
mime: 'text/x-latex'
|
||||
}, {
|
||||
'name': 'java',
|
||||
'mode': 'clike',
|
||||
'mime': 'text/x-java'
|
||||
name: 'java',
|
||||
mode: 'clike',
|
||||
mime: 'text/x-java'
|
||||
}, {
|
||||
'name': 'kotlin',
|
||||
'mode': 'clike',
|
||||
'mime': 'text/x-kotlin'
|
||||
name: 'kotlin',
|
||||
mode: 'clike',
|
||||
mime: 'text/x-kotlin'
|
||||
}, {
|
||||
'name': 'javascript',
|
||||
'mode': 'javascript',
|
||||
'mime': 'text/javascript'
|
||||
name: 'javascript',
|
||||
mode: 'javascript',
|
||||
mime: 'text/javascript'
|
||||
}, {
|
||||
'name': 'erlang',
|
||||
'mode': 'erlang',
|
||||
'mime': 'text/x-erlang'
|
||||
name: 'erlang',
|
||||
mode: 'erlang',
|
||||
mime: 'text/x-erlang'
|
||||
}, {
|
||||
'name': 'scheme',
|
||||
'mode': 'scheme',
|
||||
'mime': 'text/x-scheme'
|
||||
name: 'scheme',
|
||||
mode: 'scheme',
|
||||
mime: 'text/x-scheme'
|
||||
}, {
|
||||
'name': 'sass',
|
||||
'mode': 'sass',
|
||||
'mime': 'text/x-sass'
|
||||
name: 'sass',
|
||||
mode: 'sass',
|
||||
mime: 'text/x-sass'
|
||||
}, {
|
||||
'name': 'groovy',
|
||||
'mode': 'groovy',
|
||||
'mime': 'text/x-groovy'
|
||||
name: 'groovy',
|
||||
mode: 'groovy',
|
||||
mime: 'text/x-groovy'
|
||||
}, {
|
||||
'name': 'julia',
|
||||
'mode': 'julia',
|
||||
'mime': 'text/x-julia'
|
||||
name: 'julia',
|
||||
mode: 'julia',
|
||||
mime: 'text/x-julia'
|
||||
}, {
|
||||
'name': 'haml',
|
||||
'mode': 'haml',
|
||||
'mime': 'text/x-haml'
|
||||
name: 'haml',
|
||||
mode: 'haml',
|
||||
mime: 'text/x-haml'
|
||||
}, {
|
||||
'name': 'powershell',
|
||||
'mode': 'powershell',
|
||||
'mime': 'application/x-powershell'
|
||||
name: 'powershell',
|
||||
mode: 'powershell',
|
||||
mime: 'application/x-powershell'
|
||||
}, {
|
||||
'name': 'typescript',
|
||||
'mode': 'javascript',
|
||||
'mime': 'application/typescript'
|
||||
name: 'typescript',
|
||||
mode: 'javascript',
|
||||
mime: 'application/typescript'
|
||||
}, {
|
||||
'name': 'dart',
|
||||
'mode': 'dart',
|
||||
'mime': 'application/dart'
|
||||
name: 'dart',
|
||||
mode: 'dart',
|
||||
mime: 'application/dart'
|
||||
}, {
|
||||
'name': 'xquery',
|
||||
'mode': 'xquery',
|
||||
'mime': 'application/xquery'
|
||||
name: 'xquery',
|
||||
mode: 'xquery',
|
||||
mime: 'application/xquery'
|
||||
}, {
|
||||
'name': 'elm',
|
||||
'mode': 'elm',
|
||||
'mime': 'text/x-elm'
|
||||
name: 'elm',
|
||||
mode: 'elm',
|
||||
mime: 'text/x-elm'
|
||||
}, {
|
||||
'name': 'plsql',
|
||||
'mode': 'sql',
|
||||
'mime': 'text/x-plsql'
|
||||
name: 'plsql',
|
||||
mode: 'sql',
|
||||
mime: 'text/x-plsql'
|
||||
}, {
|
||||
'name': 'forth',
|
||||
'mode': 'forth',
|
||||
'mime': 'text/x-forth'
|
||||
name: 'forth',
|
||||
mode: 'forth',
|
||||
mime: 'text/x-forth'
|
||||
}, {
|
||||
'name': 'scala',
|
||||
'mode': 'clike',
|
||||
'mime': 'text/x-scala'
|
||||
name: 'scala',
|
||||
mode: 'clike',
|
||||
mime: 'text/x-scala'
|
||||
}, {
|
||||
'name': 'perl',
|
||||
'mode': 'perl',
|
||||
'mime': 'text/x-perl'
|
||||
name: 'perl',
|
||||
mode: 'perl',
|
||||
mime: 'text/x-perl'
|
||||
}, {
|
||||
'name': 'haxe',
|
||||
'mode': 'haxe',
|
||||
'mime': 'text/x-haxe'
|
||||
name: 'haxe',
|
||||
mode: 'haxe',
|
||||
mime: 'text/x-haxe'
|
||||
}, {
|
||||
'name': 'rhtml',
|
||||
'mode': 'htmlembedded',
|
||||
'mime': 'application/x-erb'
|
||||
name: 'rhtml',
|
||||
mode: 'htmlembedded',
|
||||
mime: 'application/x-erb'
|
||||
}, {
|
||||
'name': 'scss',
|
||||
'mode': 'css',
|
||||
'mime': 'text/x-scss'
|
||||
name: 'scss',
|
||||
mode: 'css',
|
||||
mime: 'text/x-scss'
|
||||
}, {
|
||||
'name': 'sql',
|
||||
'mode': 'sql',
|
||||
'mime': 'text/x-sql'
|
||||
name: 'sql',
|
||||
mode: 'sql',
|
||||
mime: 'text/x-sql'
|
||||
}, {
|
||||
'name': 'css',
|
||||
'mode': 'css',
|
||||
'mime': 'text/css'
|
||||
name: 'css',
|
||||
mode: 'css',
|
||||
mime: 'text/css'
|
||||
}, {
|
||||
'name': 'tex',
|
||||
'mode': 'stex',
|
||||
'mime': 'text/x-stex'
|
||||
name: 'tex',
|
||||
mode: 'stex',
|
||||
mime: 'text/x-stex'
|
||||
}, {
|
||||
'name': 'r',
|
||||
'mode': 'r',
|
||||
'mime': 'text/x-rsrc'
|
||||
name: 'r',
|
||||
mode: 'r',
|
||||
mime: 'text/x-rsrc'
|
||||
}, {
|
||||
'name': 'diff',
|
||||
'mode': 'diff',
|
||||
'mime': 'text/x-diff'
|
||||
name: 'diff',
|
||||
mode: 'diff',
|
||||
mime: 'text/x-diff'
|
||||
}, {
|
||||
'name': 'twig',
|
||||
'mode': 'twig',
|
||||
'mime': 'text/x-twig'
|
||||
name: 'twig',
|
||||
mode: 'twig',
|
||||
mime: 'text/x-twig'
|
||||
}, {
|
||||
'name': 'matlab',
|
||||
'mode': 'octave',
|
||||
'mime': 'text/x-octave'
|
||||
name: 'matlab',
|
||||
mode: 'octave',
|
||||
mime: 'text/x-octave'
|
||||
}, {
|
||||
'name': 'soy_template',
|
||||
'mode': 'soy',
|
||||
'mime': 'text/x-soy'
|
||||
name: 'soy_template',
|
||||
mode: 'soy',
|
||||
mime: 'text/x-soy'
|
||||
}, {
|
||||
'name': 'dockerfile',
|
||||
'mode': 'dockerfile',
|
||||
'mime': 'text/x-dockerfile'
|
||||
name: 'dockerfile',
|
||||
mode: 'dockerfile',
|
||||
mime: 'text/x-dockerfile'
|
||||
}, {
|
||||
'name': 'toml',
|
||||
'mode': 'toml',
|
||||
'mime': 'text/x-toml'
|
||||
name: 'toml',
|
||||
mode: 'toml',
|
||||
mime: 'text/x-toml'
|
||||
}, {
|
||||
'name': 'pgp',
|
||||
'mode': 'asciiarmor',
|
||||
'mime': 'application/pgp'
|
||||
name: 'pgp',
|
||||
mode: 'asciiarmor',
|
||||
mime: 'application/pgp'
|
||||
}, {
|
||||
'name': 'Nginx',
|
||||
'mode': 'nginx',
|
||||
'mime': 'text/x-nginx-conf'
|
||||
name: 'Nginx',
|
||||
mode: 'nginx',
|
||||
mime: 'text/x-nginx-conf'
|
||||
}]
|
||||
|
||||
export default languages
|
||||
|
@ -41,7 +41,7 @@
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
'appVersion': state => state.appVersion
|
||||
appVersion: state => state.appVersion
|
||||
})
|
||||
},
|
||||
created () {
|
||||
|
@ -102,8 +102,8 @@
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
'aiList': state => state.aidou.aiList,
|
||||
'aiLoading': state => state.aidou.aiLoading
|
||||
aiList: state => state.aidou.aiList,
|
||||
aiLoading: state => state.aidou.aiLoading
|
||||
}),
|
||||
emojis () {
|
||||
return this.aiList.map(e => {
|
||||
|
@ -27,7 +27,6 @@ export default {
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
.cpt-loading {
|
||||
position: absolute;
|
||||
|
@ -121,33 +121,33 @@
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
'preferences': state => state.preferences,
|
||||
'preferLooseListItem': state => state.preferences.preferLooseListItem,
|
||||
'autoPairBracket': state => state.preferences.autoPairBracket,
|
||||
'autoPairMarkdownSyntax': state => state.preferences.autoPairMarkdownSyntax,
|
||||
'autoPairQuote': state => state.preferences.autoPairQuote,
|
||||
'bulletListMarker': state => state.preferences.bulletListMarker,
|
||||
'orderListDelimiter': state => state.preferences.orderListDelimiter,
|
||||
'tabSize': state => state.preferences.tabSize,
|
||||
'listIndentation': state => state.preferences.listIndentation,
|
||||
'lineHeight': state => state.preferences.lineHeight,
|
||||
'fontSize': state => state.preferences.fontSize,
|
||||
'codeFontSize': state => state.preferences.codeFontSize,
|
||||
'codeFontFamily': state => state.preferences.codeFontFamily,
|
||||
'editorFontFamily': state => state.preferences.editorFontFamily,
|
||||
'hideQuickInsertHint': state => state.preferences.hideQuickInsertHint,
|
||||
'editorLineWidth': state => state.preferences.editorLineWidth,
|
||||
'imageInsertAction': state => state.preferences.imageInsertAction,
|
||||
'imageFolderPath': state => state.preferences.imageFolderPath,
|
||||
'theme': state => state.preferences.theme,
|
||||
'hideScrollbar': state => state.preferences.hideScrollbar,
|
||||
preferences: state => state.preferences,
|
||||
preferLooseListItem: state => state.preferences.preferLooseListItem,
|
||||
autoPairBracket: state => state.preferences.autoPairBracket,
|
||||
autoPairMarkdownSyntax: state => state.preferences.autoPairMarkdownSyntax,
|
||||
autoPairQuote: state => state.preferences.autoPairQuote,
|
||||
bulletListMarker: state => state.preferences.bulletListMarker,
|
||||
orderListDelimiter: state => state.preferences.orderListDelimiter,
|
||||
tabSize: state => state.preferences.tabSize,
|
||||
listIndentation: state => state.preferences.listIndentation,
|
||||
lineHeight: state => state.preferences.lineHeight,
|
||||
fontSize: state => state.preferences.fontSize,
|
||||
codeFontSize: state => state.preferences.codeFontSize,
|
||||
codeFontFamily: state => state.preferences.codeFontFamily,
|
||||
editorFontFamily: state => state.preferences.editorFontFamily,
|
||||
hideQuickInsertHint: state => state.preferences.hideQuickInsertHint,
|
||||
editorLineWidth: state => state.preferences.editorLineWidth,
|
||||
imageInsertAction: state => state.preferences.imageInsertAction,
|
||||
imageFolderPath: state => state.preferences.imageFolderPath,
|
||||
theme: state => state.preferences.theme,
|
||||
hideScrollbar: state => state.preferences.hideScrollbar,
|
||||
|
||||
'currentFile': state => state.editor.currentFile,
|
||||
currentFile: state => state.editor.currentFile,
|
||||
|
||||
// edit modes
|
||||
'typewriter': state => state.preferences.typewriter,
|
||||
'focus': state => state.preferences.focus,
|
||||
'sourceCode': state => state.preferences.sourceCode
|
||||
typewriter: state => state.preferences.typewriter,
|
||||
focus: state => state.preferences.focus,
|
||||
sourceCode: state => state.preferences.sourceCode
|
||||
}),
|
||||
|
||||
getEditorLineWidth () {
|
||||
@ -654,7 +654,6 @@
|
||||
}
|
||||
default:
|
||||
console.error(`unknow paragraph edit type: ${type}`)
|
||||
return
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -26,9 +26,9 @@
|
||||
|
||||
computed: {
|
||||
...mapState({
|
||||
'theme': state => state.preferences.theme,
|
||||
'sourceCode': state => state.preferences.sourceCode,
|
||||
'currentTab': state => state.editor.currentFile,
|
||||
theme: state => state.preferences.theme,
|
||||
sourceCode: state => state.preferences.sourceCode,
|
||||
currentTab: state => state.editor.currentFile
|
||||
})
|
||||
},
|
||||
|
||||
|
@ -56,10 +56,10 @@
|
||||
mixins: [tabsMixins],
|
||||
computed: {
|
||||
...mapState({
|
||||
'currentFile': state => state.editor.currentFile,
|
||||
'tabs': state => state.editor.tabs,
|
||||
'showSideBar': state => state.layout.showSideBar,
|
||||
'sideBarWidth': state => state.layout.sideBarWidth
|
||||
currentFile: state => state.editor.currentFile,
|
||||
tabs: state => state.editor.tabs,
|
||||
showSideBar: state => state.layout.showSideBar,
|
||||
sideBarWidth: state => state.layout.sideBarWidth
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
|
@ -117,4 +117,3 @@ export default {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
@ -126,7 +126,7 @@
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
'searchMatches': state => state.editor.currentFile.searchMatches
|
||||
searchMatches: state => state.editor.currentFile.searchMatches
|
||||
}),
|
||||
highlightIndex () {
|
||||
if (this.searchMatches) {
|
||||
|
@ -78,8 +78,8 @@
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
'tabs': state => state.editor.tabs,
|
||||
'currentFile': state => state.editor.currentFile
|
||||
tabs: state => state.editor.tabs,
|
||||
currentFile: state => state.editor.currentFile
|
||||
}),
|
||||
|
||||
getMatches () {
|
||||
|
@ -35,7 +35,7 @@
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
'toc': state => state.editor.toc
|
||||
toc: state => state.editor.toc
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
|
@ -118,7 +118,7 @@
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
'createCache': state => state.project.createCache
|
||||
createCache: state => state.project.createCache
|
||||
})
|
||||
},
|
||||
created () {
|
||||
|
@ -53,11 +53,11 @@
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
'renameCache': state => state.project.renameCache,
|
||||
'activeItem': state => state.project.activeItem,
|
||||
'clipboard': state => state.project.clipboard,
|
||||
'currentFile': state => state.editor.currentFile,
|
||||
'tabs': state => state.editor.tabs
|
||||
renameCache: state => state.project.renameCache,
|
||||
activeItem: state => state.project.activeItem,
|
||||
clipboard: state => state.project.clipboard,
|
||||
currentFile: state => state.editor.currentFile,
|
||||
tabs: state => state.editor.tabs
|
||||
})
|
||||
},
|
||||
created () {
|
||||
|
@ -79,10 +79,10 @@
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
'renameCache': state => state.project.renameCache,
|
||||
'createCache': state => state.project.createCache,
|
||||
'activeItem': state => state.project.activeItem,
|
||||
'clipboard': state => state.project.clipboard
|
||||
renameCache: state => state.project.renameCache,
|
||||
createCache: state => state.project.createCache,
|
||||
activeItem: state => state.project.activeItem,
|
||||
clipboard: state => state.project.clipboard
|
||||
})
|
||||
},
|
||||
created () {
|
||||
|
@ -28,7 +28,7 @@
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
'currentFile': state => state.editor.currentFile
|
||||
currentFile: state => state.editor.currentFile
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -108,19 +108,19 @@
|
||||
data () {
|
||||
this.isOsx = isOsx
|
||||
this.HASH = {
|
||||
'word': {
|
||||
word: {
|
||||
short: 'W',
|
||||
full: 'word'
|
||||
},
|
||||
'character': {
|
||||
character: {
|
||||
short: 'C',
|
||||
full: 'character'
|
||||
},
|
||||
'paragraph': {
|
||||
paragraph: {
|
||||
short: 'P',
|
||||
full: 'paragraph'
|
||||
},
|
||||
'all': {
|
||||
all: {
|
||||
short: 'A',
|
||||
full: '(with space)character'
|
||||
}
|
||||
@ -152,8 +152,8 @@
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
'titleBarStyle': state => state.preferences.titleBarStyle,
|
||||
'showTabBar': state => state.layout.showTabBar
|
||||
titleBarStyle: state => state.preferences.titleBarStyle,
|
||||
showTabBar: state => state.layout.showTabBar
|
||||
}),
|
||||
paths () {
|
||||
if (!this.pathname) return []
|
||||
@ -167,8 +167,8 @@
|
||||
watch: {
|
||||
filename: function (value) {
|
||||
// Set filename when hover on dock
|
||||
const title = this.project && this.project.name ?
|
||||
`${value} - ${this.project.name}` : `${value} - Mark Text`
|
||||
const title = this.project && this.project.name
|
||||
? `${value} - ${this.project.name}` : `${value} - Mark Text`
|
||||
document.title = title
|
||||
}
|
||||
},
|
||||
@ -415,4 +415,3 @@
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
@ -5,7 +5,6 @@ import EnvPaths from 'common/envPaths'
|
||||
const rgDiskPath = rgPath.replace(/\bapp\.asar\b/, 'app.asar.unpacked')
|
||||
|
||||
class RendererPaths extends EnvPaths {
|
||||
|
||||
/**
|
||||
* Configure and sets all application paths.
|
||||
*
|
||||
|
@ -105,11 +105,10 @@ function processSubmatch (submatch, lineText, offsetRow) {
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
constructor () {
|
||||
this.rgPath = global.marktext.paths.ripgrepBinaryPath
|
||||
}
|
||||
|
@ -70,19 +70,19 @@
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
'showTabBar': state => state.layout.showTabBar,
|
||||
'sourceCode': state => state.preferences.sourceCode,
|
||||
'theme': state => state.preferences.theme,
|
||||
'textDirection': state => state.preferences.textDirection
|
||||
showTabBar: state => state.layout.showTabBar,
|
||||
sourceCode: state => state.preferences.sourceCode,
|
||||
theme: state => state.preferences.theme,
|
||||
textDirection: state => state.preferences.textDirection
|
||||
}),
|
||||
...mapState({
|
||||
'projectTree': state => state.project.projectTree,
|
||||
'pathname': state => state.editor.currentFile.pathname,
|
||||
'filename': state => state.editor.currentFile.filename,
|
||||
'isSaved': state => state.editor.currentFile.isSaved,
|
||||
'markdown': state => state.editor.currentFile.markdown,
|
||||
'cursor': state => state.editor.currentFile.cursor,
|
||||
'wordCount': state => state.editor.currentFile.wordCount
|
||||
projectTree: state => state.project.projectTree,
|
||||
pathname: state => state.editor.currentFile.pathname,
|
||||
filename: state => state.editor.currentFile.filename,
|
||||
isSaved: state => state.editor.currentFile.isSaved,
|
||||
markdown: state => state.editor.currentFile.markdown,
|
||||
cursor: state => state.editor.currentFile.cursor,
|
||||
wordCount: state => state.editor.currentFile.wordCount
|
||||
}),
|
||||
...mapState([
|
||||
'windowActive', 'platform', 'init'
|
||||
|
@ -31,8 +31,8 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
'theme': state => state.preferences.theme,
|
||||
'titleBarStyle': state => state.preferences.titleBarStyle
|
||||
theme: state => state.preferences.theme,
|
||||
titleBarStyle: state => state.preferences.titleBarStyle
|
||||
}),
|
||||
showCustomTitleBar () {
|
||||
return this.titleBarStyle === 'custom' && !this.isOsx
|
||||
|
@ -90,4 +90,3 @@ export default {
|
||||
background: var(--iconColor);
|
||||
}
|
||||
</style>
|
||||
|
||||
|
@ -97,4 +97,3 @@ export default {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
@ -104,4 +104,3 @@ div.el-select-dropdown {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
@ -9,4 +9,3 @@
|
||||
background: var(--editorColor04);
|
||||
}
|
||||
</style>
|
||||
|
||||
|
@ -94,5 +94,3 @@ export default {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
export default {
|
||||
// Dummy service used to opt-in real services.
|
||||
none: {
|
||||
name: "",
|
||||
name: '',
|
||||
isGdprCompliant: true,
|
||||
privacyUrl: '',
|
||||
tosUrl: '',
|
||||
@ -14,7 +14,7 @@ export default {
|
||||
|
||||
// Real services
|
||||
smms: {
|
||||
name: "sm.ms",
|
||||
name: 'sm.ms',
|
||||
isGdprCompliant: false,
|
||||
privacyUrl: '',
|
||||
tosUrl: 'https://sm.ms/about/',
|
||||
@ -23,7 +23,7 @@ export default {
|
||||
agreedToLegalNotices: false
|
||||
},
|
||||
github: {
|
||||
name: "GitHub",
|
||||
name: 'GitHub',
|
||||
isGdprCompliant: true,
|
||||
privacyUrl: 'https://github.com/site/privacy',
|
||||
tosUrl: 'https://github.com/site/terms',
|
||||
|
@ -47,7 +47,7 @@ export const listIndentationOptions = [{
|
||||
value: 'tab'
|
||||
}, {
|
||||
label: '1 space',
|
||||
value: 1,
|
||||
value: 1
|
||||
}, {
|
||||
label: '2 spaces',
|
||||
value: 2
|
||||
|
@ -42,7 +42,7 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
'theme': state => state.preferences.theme
|
||||
theme: state => state.preferences.theme
|
||||
})
|
||||
},
|
||||
created () {
|
||||
|
@ -12,7 +12,8 @@ const routes = type => ([{
|
||||
}, {
|
||||
path: '/editor', component: App
|
||||
}, {
|
||||
path: '/preference', component: Preference,
|
||||
path: '/preference',
|
||||
component: Preference,
|
||||
children: [{
|
||||
path: '', component: General
|
||||
}, {
|
||||
|
@ -109,7 +109,7 @@ const notification = {
|
||||
const notices = document.querySelectorAll('.mt-notification')
|
||||
let i
|
||||
let hx = 0
|
||||
let len = notices.length
|
||||
const len = notices.length
|
||||
for (i = 0; i < len; i++) {
|
||||
notices[i].style.transform = `translate(0, -${hx}px)`
|
||||
notices[i].style.zIndex = 10000 - i
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { getImageInfo } from 'muya/lib/utils'
|
||||
|
||||
class MarkdownPrint {
|
||||
|
||||
/**
|
||||
* 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
|
||||
dispatch('NEW_UNTITLED_TAB', { markdown, selected })
|
||||
})
|
||||
@ -802,7 +802,6 @@ const actions = {
|
||||
|
||||
LISTEN_FOR_FILE_CHANGE ({ commit, state, rootState }) {
|
||||
ipcRenderer.on('AGANI::update-file', (e, { type, change }) => {
|
||||
|
||||
// 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.
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user