'
29 | }
30 | throw e
31 | }
32 | }
33 |
34 | export {
35 | Renderer, Lexer, Parser
36 | }
37 |
38 | export default marked
39 |
--------------------------------------------------------------------------------
/src/renderer/commands/utils.js:
--------------------------------------------------------------------------------
1 | import path from 'path'
2 | import { isFile } from 'common/filesystem'
3 |
4 | /// Check whether the package is updatable at runtime.
5 | export const isUpdatable = () => {
6 | // TODO: If not updatable, allow to check whether there is a new version available.
7 |
8 | const resFile = isFile(path.join(process.resourcesPath, 'app-update.yml'))
9 | if (!resFile) {
10 | // No update resource file available.
11 | return false
12 | } else if (process.env.APPIMAGE) {
13 | // We are running as AppImage.
14 | return true
15 | } else if (process.platform === 'win32' && isFile(path.join(process.resourcesPath, 'md.ico'))) {
16 | // Windows is a little but tricky. The update resource file is always available and
17 | // there is no way to check the target type at runtime (electron-builder#4119).
18 | // As workaround we check whether "md.ico" exists that is only included in the setup.
19 | return true
20 | }
21 |
22 | // Otherwise assume that we cannot perform an auto update (standalone binary, archives,
23 | // packed for package manager).
24 | return false
25 | }
26 |
--------------------------------------------------------------------------------
/src/muya/lib/assets/icons/format_image.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.electron-vue/thirdPartyChecker.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const checker = require('license-checker')
4 |
5 | const getLicenses = (rootDir, callback) => {
6 | checker.init({
7 | start: rootDir,
8 | production: true,
9 | development: false,
10 | direct: true,
11 | excludePackages: 'file-icons@2.1.47', // file-icons is under MIT License, but license-checker shows no license.
12 | json: true,
13 | onlyAllow: 'Unlicense;WTFPL;ISC;MIT;BSD;ISC;Apache-2.0;MIT*;Apache;Apache*;BSD*;CC0-1.0;CC-BY-4.0;CC-BY-3.0',
14 | customPath: {
15 | licenses: '',
16 | licenseText: 'none'
17 | }
18 | }, function (err, packages) {
19 | callback(err, packages, checker)
20 | })
21 | }
22 |
23 | // Check that all production dependencies are allowed.
24 | const validateLicenses = rootDir => {
25 | getLicenses(rootDir, (err, packages, checker) => {
26 | if (err) {
27 | console.log(`[ERROR] ${err}`)
28 | process.exit(1)
29 | }
30 | console.log(checker.asSummary(packages))
31 | })
32 | }
33 |
34 | module.exports = {
35 | getLicenses: getLicenses,
36 | validateLicenses: validateLicenses
37 | }
38 |
--------------------------------------------------------------------------------
/docs/KEYBINDINGS.md:
--------------------------------------------------------------------------------
1 | # Key Bindings
2 |
3 | All key bindings can be overwritten with the `keybindings.json` file. The file is located in the [application data directory](APPLICATION_DATA_DIRECTORY.md). Each entry consists of a `id`/`accelerator` pair in JSON format.
4 |
5 | Here is an example:
6 |
7 | ```json
8 | {
9 | "file.save": "CmdOrCtrl+Shift+S",
10 | "file.save-as": "CmdOrCtrl+S"
11 | }
12 | ```
13 |
14 | ## Available modifiers
15 |
16 | - `Cmd` on macOS
17 | - `Option` on macOS
18 | - `Ctrl`
19 | - `Shift`
20 | - `Alt` (equal to `Option` on macOS)
21 |
22 | Please don't bind `AltGr`, use `Cltr+Alt` instead.
23 |
24 | ## Available keys
25 |
26 | - `0-9`, `A-Z`, `F1-F24` and punctuations like `/` or `#`
27 | - `Plus`, `Space`, `Tab`, `Backspace`, `Delete`, `Insert`, `Return/Enter`, `Esc`, `Home`, `End` and `PrintScreen`
28 | - `Up`, `Down`, `Left` and `Right`
29 | - `PageUp` and `PageDown`
30 | - Empty string `""` to unset a accelerator
31 |
32 | ## Available key bindings
33 |
34 | - [Key bindings for macOS](KEYBINDINGS_OSX.md)
35 | - [Key bindings for Linux](KEYBINDINGS_LINUX.md)
36 | - [Key bindings for Windows](KEYBINDINGS_WINDOWS.md)
37 |
--------------------------------------------------------------------------------
/src/main/app/paths.js:
--------------------------------------------------------------------------------
1 | import { app } from 'electron'
2 | import EnvPaths from 'common/envPaths'
3 | import { ensureDirSync } from 'common/filesystem'
4 |
5 | class AppPaths extends EnvPaths {
6 | /**
7 | * Configure and sets all application paths.
8 | *
9 | * @param {[string]} userDataPath The user data path or null.
10 | */
11 | constructor (userDataPath = '') {
12 | if (!userDataPath) {
13 | // Use default user data path.
14 | userDataPath = app.getPath('userData')
15 | }
16 |
17 | // Initialize environment paths
18 | super(userDataPath)
19 |
20 | // Changing the user data directory is only allowed during application bootstrap.
21 | app.setPath('userData', this._electronUserDataPath)
22 | }
23 | }
24 |
25 | export const ensureAppDirectoriesSync = paths => {
26 | ensureDirSync(paths.userDataPath)
27 | ensureDirSync(paths.logPath)
28 | // TODO(sessions): enable this...
29 | // ensureDirSync(paths.electronUserDataPath)
30 | // ensureDirSync(paths.globalStorage)
31 | // ensureDirSync(paths.preferencesPath)
32 | // ensureDirSync(paths.sessionsPath)
33 | }
34 |
35 | export default AppPaths
36 |
--------------------------------------------------------------------------------
/src/muya/lib/parser/marked/options.js:
--------------------------------------------------------------------------------
1 | export default {
2 | baseUrl: null,
3 | breaks: false,
4 | gfm: true,
5 | headerIds: true,
6 | headerPrefix: '',
7 | highlight: null,
8 | mathRenderer: null,
9 | emojiRenderer: null,
10 | tocRenderer: null,
11 | langPrefix: 'language-',
12 | mangle: true,
13 | pedantic: false,
14 | renderer: null, // new Renderer(),
15 | silent: false,
16 | smartLists: false,
17 | smartypants: false,
18 | xhtml: false,
19 | disableInline: false,
20 |
21 | // NOTE: sanitize and sanitizer are deprecated since version 0.7.0, should not be used and will be removed in the future.
22 | sanitize: false,
23 | sanitizer: null,
24 |
25 | // Markdown extensions:
26 | // TODO: We set whether to support `emoji`, `math`, `frontMatter` default value to `true`
27 | // After we add user setting, we maybe set math and frontMatter default value to false.
28 | // User need to enable them in the user setting.
29 | emoji: true,
30 | math: true,
31 | frontMatter: true,
32 | superSubScript: false,
33 | footnote: false,
34 | isGitlabCompatibilityEnabled: false,
35 |
36 | isHtmlEnabled: true
37 | }
38 |
--------------------------------------------------------------------------------
/src/muya/lib/ui/baseFloat/index.css:
--------------------------------------------------------------------------------
1 | .ag-float-wrapper {
2 | position: absolute;
3 | font-size: 12px;
4 | opacity: 0;
5 | width: 110px;
6 | height: auto;
7 | top: -1000px;
8 | right: -1000px;
9 | border-radius: 2px;
10 | box-shadow: var(--floatShadow);
11 | background-color: var(--floatBgColor);
12 | transition: opacity .25s ease-in-out;
13 | transform-origin: top;
14 | box-sizing: border-box;
15 | z-index: 10000;
16 | overflow: hidden;
17 | }
18 |
19 | .ag-float-container::-webkit-scrollbar:vertical {
20 | width: 0px;
21 | }
22 |
23 | [x-placement] {
24 | opacity: 1;
25 | }
26 |
27 | .ag-popper-arrow {
28 | width: 16px;
29 | height: 16px;
30 | background: inherit;
31 | border: 1px solid #ebeef5;
32 | display: inline-block;
33 | position: absolute;
34 | transform: rotate(45deg);
35 | }
36 |
37 | [x-placement="bottom-start"] > .ag-popper-arrow {
38 | border-right: none;
39 | border-bottom: none;
40 | top: -9px;
41 | }
42 |
43 | [x-placement="top-start"] > .ag-popper-arrow {
44 | border-left: none;
45 | border-top: none;
46 | bottom: -9px;
47 | }
48 |
49 | [x-out-of-boundaries] {
50 | display: none;
51 | }
52 |
--------------------------------------------------------------------------------
/src/muya/lib/parser/render/renderInlines/autoLink.js:
--------------------------------------------------------------------------------
1 | import { CLASS_OR_ID } from '../../../config'
2 | import { sanitizeHyperlink } from '../../../utils/url'
3 |
4 | // render auto_link to vdom
5 | export default function autoLink (h, cursor, block, token, outerClass) {
6 | const className = this.getClassName(outerClass, block, token, cursor)
7 | const { isLink, marker, href, email } = token
8 | const { start, end } = token.range
9 |
10 | const startMarker = this.highlight(h, block, start, start + marker.length, token)
11 | const endMarker = this.highlight(h, block, end - marker.length, end, token)
12 | const content = this.highlight(h, block, start + marker.length, end - marker.length, token)
13 |
14 | const hyperlink = isLink ? encodeURI(href) : `mailto:${email}`
15 | return [
16 | h(`span.${className}`, startMarker),
17 | h(`a.${CLASS_OR_ID.AG_INLINE_RULE}.${CLASS_OR_ID.AG_AUTO_LINK}`, {
18 | attrs: {
19 | spellcheck: 'false'
20 | },
21 | props: {
22 | href: sanitizeHyperlink(hyperlink),
23 | target: '_blank'
24 | }
25 | }, content),
26 | h(`span.${className}`, endMarker)
27 | ]
28 | }
29 |
--------------------------------------------------------------------------------
/src/muya/lib/utils/getImageInfo.js:
--------------------------------------------------------------------------------
1 | import { isWin } from '../config'
2 | import { findNearestParagraph, getOffsetOfParagraph } from '../selection/dom'
3 | import { tokenizer } from '../parser'
4 |
5 | export const getImageInfo = image => {
6 | const paragraph = findNearestParagraph(image)
7 | const raw = image.getAttribute('data-raw')
8 | const offset = getOffsetOfParagraph(image, paragraph)
9 | const tokens = tokenizer(raw)
10 | const token = tokens[0]
11 | token.range = {
12 | start: offset,
13 | end: offset + raw.length
14 | }
15 | return {
16 | key: paragraph.id,
17 | token,
18 | imageId: image.id
19 | }
20 | }
21 |
22 | export const correctImageSrc = src => {
23 | if (src) {
24 | // Fix ASCII and UNC paths on Windows (#1997).
25 | if (isWin && /^(?:[a-zA-Z]:\\|[a-zA-Z]:\/).+/.test(src)) {
26 | src = 'file:///' + src.replace(/\\/g, '/')
27 | } else if (isWin && /^\\\\\?\\.+/.test(src)) {
28 | src = 'file:///' + src.substring(4).replace(/\\/g, '/')
29 | } else if (/^\/.+/.test(src)) {
30 | // Also adding file protocol on UNIX.
31 | src = 'file://' + src
32 | }
33 | }
34 | return src
35 | }
36 |
--------------------------------------------------------------------------------
/docs/ENVIRONMENT.md:
--------------------------------------------------------------------------------
1 | # Environment
2 |
3 | | Name | Description |
4 | | ---------------------------- | ----------------------------------------------------------- |
5 | | `MARKTEXT_DEBUG` | Enable debug mode. |
6 | | `MARKTEXT_DEBUG_KEYBOARD` | Print more keyboard information when debug mode is enabled. |
7 | | `MARKTEXT_ERROR_INTERACTION` | Never show the error dialog to report bugs. |
8 | | `MARKTEXT_PANDOC` | Overwrite the pandoc path. |
9 |
10 | ## Development
11 |
12 | | Name | Description |
13 | | ------------------------------------ | ------------------------------------------------------------ |
14 | | `MARKTEXT_EXIT_ON_ERROR` | Exit on the first error or exception that occurs. |
15 | | `MARKTEXT_DEV_HIDE_BROWSER_ANALYZER` | Don't show the dependency analyzer. |
16 | | `MARKTEXT_IS_STABLE` | **Please don't use this!** Used to identify stable releases. |
17 |
--------------------------------------------------------------------------------
/src/muya/lib/parser/render/renderInlines/htmlRuby.js:
--------------------------------------------------------------------------------
1 | import { CLASS_OR_ID } from '../../../config'
2 | import { htmlToVNode } from '../snabbdom'
3 |
4 | export default function htmlRuby (h, cursor, block, token, outerClass) {
5 | const className = this.getClassName(outerClass, block, token, cursor)
6 | const { children } = token
7 | const { start, end } = token.range
8 | const content = this.highlight(h, block, start, end, token)
9 | const vNode = htmlToVNode(token.raw)
10 |
11 | const previewSelector = `span.${CLASS_OR_ID.AG_RUBY_RENDER}`
12 |
13 | return children
14 | ? [
15 | h(`span.${className}.${CLASS_OR_ID.AG_RUBY}`, [
16 | h(`span.${CLASS_OR_ID.AG_INLINE_RULE}.${CLASS_OR_ID.AG_RUBY_TEXT}`, content),
17 | h(previewSelector, {
18 | attrs: {
19 | contenteditable: 'false',
20 | spellcheck: 'false'
21 | }
22 | }, vNode)
23 | ])
24 | // if children is empty string, no need to render ruby charactors...
25 | ]
26 | : [
27 | h(`span.${className}.${CLASS_OR_ID.AG_RUBY}`, [
28 | h(`span.${CLASS_OR_ID.AG_INLINE_RULE}.${CLASS_OR_ID.AG_RUBY_TEXT}`, content)
29 | ])
30 | ]
31 | }
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017-present Luo Ran
4 | Copyright (c) 2018-present MarkText Contributors
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
--------------------------------------------------------------------------------
/src/renderer/node/paths.js:
--------------------------------------------------------------------------------
1 | import { rgPath } from 'vscode-ripgrep'
2 | import EnvPaths from 'common/envPaths'
3 |
4 | // // "vscode-ripgrep" is unpacked out of asar because of the binary.
5 | const rgDiskPath = rgPath.replace(/\bapp\.asar\b/, 'app.asar.unpacked')
6 |
7 | class RendererPaths extends EnvPaths {
8 | /**
9 | * Configure and sets all application paths.
10 | *
11 | * @param {string} userDataPath The user data path.
12 | */
13 | constructor (userDataPath) {
14 | if (!userDataPath) {
15 | throw new Error('No user data path is given.')
16 | }
17 |
18 | // Initialize environment paths
19 | super(userDataPath)
20 |
21 | // Allow to use a local ripgrep binary (e.g. an optimized version).
22 | if (process.env.MARKTEXT_RIPGREP_PATH) {
23 | // NOTE: Binary must be a compatible version, otherwise the searcher may fail.
24 | this._ripgrepBinaryPath = process.env.MARKTEXT_RIPGREP_PATH
25 | } else {
26 | this._ripgrepBinaryPath = rgDiskPath
27 | }
28 | }
29 |
30 | // Returns the path to ripgrep on disk.
31 | get ripgrepBinaryPath () {
32 | return this._ripgrepBinaryPath
33 | }
34 | }
35 |
36 | export default RendererPaths
37 |
--------------------------------------------------------------------------------
/src/main/menu/actions/window.js:
--------------------------------------------------------------------------------
1 | import { ipcMain, Menu } from 'electron'
2 | import { isOsx } from '../../config'
3 | import { COMMANDS } from '../../commands'
4 | import { zoomIn, zoomOut } from '../../windows/utils'
5 |
6 | export const minimizeWindow = win => {
7 | if (win) {
8 | if (isOsx) {
9 | Menu.sendActionToFirstResponder('performMiniaturize:')
10 | } else {
11 | win.minimize()
12 | }
13 | }
14 | }
15 |
16 | export const toggleAlwaysOnTop = win => {
17 | if (win) {
18 | ipcMain.emit('window-toggle-always-on-top', win)
19 | }
20 | }
21 |
22 | export const toggleFullScreen = win => {
23 | if (win) {
24 | win.setFullScreen(!win.isFullScreen())
25 | }
26 | }
27 |
28 | // --- Commands -------------------------------------------------------------
29 |
30 | export const loadWindowCommands = commandManager => {
31 | commandManager.add(COMMANDS.WINDOW_MINIMIZE, minimizeWindow)
32 | commandManager.add(COMMANDS.WINDOW_TOGGLE_ALWAYS_ON_TOP, toggleAlwaysOnTop)
33 | commandManager.add(COMMANDS.WINDOW_TOGGLE_FULL_SCREEN, toggleFullScreen)
34 | commandManager.add(COMMANDS.WINDOW_ZOOM_IN, zoomIn)
35 | commandManager.add(COMMANDS.WINDOW_ZOOM_OUT, zoomOut)
36 | }
37 |
--------------------------------------------------------------------------------
/src/muya/lib/parser/marked/LICENSE:
--------------------------------------------------------------------------------
1 | Marked
2 |
3 | Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/docs/EXPORT.md:
--------------------------------------------------------------------------------
1 | # Export a Document
2 |
3 | MarkText allows you to export a markdown document as PDF and HTML file or to print the document.
4 |
5 | ## Options
6 |
7 | ### Page options
8 |
9 | You can set the page size, orientation and margin before exporting a document.
10 |
11 | ### Style
12 |
13 | Adjust the page style without modify the page theme:
14 |
15 | - Overwrite font family, size and line height.
16 | - Auto numbering headings.
17 | - Option to show the front matter on the exported document.
18 |
19 | ### Theme
20 |
21 | MarkText allows you to select a page theme before exporting. You can learn more about page themes [here](EXPORT_THEMES.md).
22 |
23 | ### Header and footer
24 |
25 | You can include a header and/or footer in the exported document if you choose PDF or printing and also adjust the header/footer style. You can select between no, a single or a three cell header in export options. The header and/or footer appear on each page when defined and the header can be multiline but the footer only single line. Unfortunately, page numbering is currently not supported. An example can be seen below.
26 |
27 | 
28 |
29 | 
30 |
--------------------------------------------------------------------------------
/src/renderer/prefComponents/image/components/uploader/legalNoticesCheckbox.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | By using {{ uploaderService.name }}, you agree to {{ uploaderService.name }}'s
6 | Privacy Statement
7 | and
8 | Terms of Service.
9 | This service cannot be used in Europe due to GDPR issues.
10 |
11 |