repo
stringlengths
5
106
file_url
stringlengths
78
301
file_path
stringlengths
4
211
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:56:49
2026-01-05 02:23:25
truncated
bool
2 classes
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/prefComponents/keybindings/KeybindingConfigurator.js
src/renderer/prefComponents/keybindings/KeybindingConfigurator.js
import { ipcRenderer } from 'electron' import { isEqualAccelerator } from 'common/keybinding' import getCommandDescriptionById from '@/commands/descriptions' import { isOsx } from '@/util' const SHORTCUT_TYPE_DEFAULT = 0 const SHORTCUT_TYPE_USER = 1 const getShortcutDescriptionById = id => { const description = get...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/prefComponents/sideBar/config.js
src/renderer/prefComponents/sideBar/config.js
import GeneralIcon from '@/assets/icons/pref_general.svg' import EditorIcon from '@/assets/icons/pref_editor.svg' import MarkdownIcon from '@/assets/icons/pref_markdown.svg' import ThemeIcon from '@/assets/icons/pref_theme.svg' import ImageIcon from '@/assets/icons/pref_image.svg' import SpellIcon from '@/assets/icons/...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/prefComponents/markdown/config.js
src/renderer/prefComponents/markdown/config.js
export const bulletListMarkerOptions = [{ label: '*', value: '*' }, { label: '-', value: '-' }, { label: '+', value: '+' }] export const orderListDelimiterOptions = [{ label: '.', value: '.' }, { label: ')', value: ')' }] export const preferHeadingStyleOptions = [{ label: 'ATX heading', value:...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/components/exportSettings/exportOptions.js
src/renderer/components/exportSettings/exportOptions.js
export const pageSizeList = [ { label: 'A3 (297mm x 420mm)', value: 'A3' }, { label: 'A4 (210mm x 297mm)', value: 'A4' }, { label: 'A5 (148mm x 210mm)', value: 'A5' }, { label: 'US Legal (8.5" x 13")', value: 'Legal' }, { label: 'US Letter (8.5" x 11")', value: 'Letter'...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/components/sideBar/help.js
src/renderer/components/sideBar/help.js
import FilesIcon from '@/assets/icons/files.svg' import SearchIcon from '@/assets/icons/search.svg' import TocIcon from '@/assets/icons/toc.svg' import SettingIcon from '@/assets/icons/setting.svg' export const sideBarIcons = [ { name: 'files', icon: FilesIcon }, { name: 'search', icon: SearchIcon ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/axios/index.js
src/renderer/axios/index.js
import axios from 'axios' import adapter from 'axios/lib/adapters/http' axios.defaults.adapter = adapter const http = axios.create({ adapter }) export default http
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/assets/window-controls.js
src/renderer/assets/window-controls.js
/* Copyright (c) GitHub, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublice...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/assets/symbolIcon/index.js
src/renderer/assets/symbolIcon/index.js
(function(window){var svgSprite='<svg><symbol id="icon-info" viewBox="0 0 1024 1024"><path d="M512 35.776C249.024 35.776 35.776 249.024 35.776 512S249.024 988.224 512 988.224 988.224 774.976 988.224 512 774.976 35.776 512 35.776zM563.776 748.224l-96 0 0-288 96 0L563.776 748.224zM515.776 388.224c-39.744 0-72-32.256-72-7...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
true
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/spellchecker/languageMap.js
src/renderer/spellchecker/languageMap.js
import langMap from 'iso-639-1' /** * Return the native language name by language code. * * @param {string} langCode The ISO two or four-letter language code (e.g. en, en-US) or BCP-47 code. */ export const getLanguageName = languageCode => { if (!languageCode || languageCode.length < 2) { return null } ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/spellchecker/index.js
src/renderer/spellchecker/index.js
import { ipcRenderer } from 'electron' import { isOsx } from '@/util' /** * High level spell checker API based on Chromium built-in spell checker. */ export class SpellChecker { /** * ctor * * @param {boolean} enabled Whether spell checking is enabled in settings. */ constructor (enabled = true, lang...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/codeMirror/loadmode.js
src/renderer/codeMirror/loadmode.js
// CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE const loadMore = CodeMirror => { if (!CodeMirror.modeURL) { CodeMirror.modeURL = '../../mode/%N/%N.js' } const loading = {} function splitCallback (cont, n) { let countDown =...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/codeMirror/index.js
src/renderer/codeMirror/index.js
import { filter } from 'fuzzaldrin' import 'codemirror/addon/edit/closebrackets' import 'codemirror/addon/edit/closetag' import 'codemirror/addon/selection/active-line' import 'codemirror/mode/meta' import codeMirror from 'codemirror/lib/codemirror' import loadmode from './loadmode' import overlayMode from './overlayM...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/codeMirror/overlayMode.js
src/renderer/codeMirror/overlayMode.js
// CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // Utility function that allows modes to be combined. The mode given // as the base argument takes care of most of the normal mode // functionality, but a second (typically simple) mode is us...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/codeMirror/modes.js
src/renderer/codeMirror/modes.js
const languages = [{ name: 'objectivec', mode: 'clike', mime: 'text/x-objectivec' }, { name: 'swift', mode: 'swift', mime: 'text/x-swift' }, { name: 'c_cpp', mode: 'clike', mime: 'text/x-csrc' }, { name: 'c', mode: 'clike', mime: 'text/x-csrc' }, { name: 'c++', mode: 'clike', mime: 'text/x...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/codeMirror/mltiplexMode.js
src/renderer/codeMirror/mltiplexMode.js
// CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: http://codemirror.net/LICENSE const multiplexMode = CodeMirror => { CodeMirror.multiplexingMode = function (outer /*, others */) { // Others should be {open, close, mode [, delimStyle] [, innerStyle]} objects con...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/bus/index.js
src/renderer/bus/index.js
import Vue from 'vue' export default new Vue()
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/router/index.js
src/renderer/router/index.js
import App from '@/pages/app' import Preference from '@/pages/preference' import General from '@/prefComponents/general' import Editor from '@/prefComponents/editor' import Markdown from '@/prefComponents/markdown' import SpellChecker from '@/prefComponents/spellchecker' import Theme from '@/prefComponents/theme' impor...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/renderer/mixins/index.js
src/renderer/mixins/index.js
import { ipcRenderer } from 'electron' import { isSamePathSync } from 'common/filesystem/paths' import bus from '../bus' export const tabsMixins = { methods: { selectFile (file) { if (file.id !== this.currentFile.id) { this.$store.dispatch('UPDATE_CURRENT_FILE', file) } }, removeFileI...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/webpack.config.js
src/muya/webpack.config.js
'use strict' process.env.BABEL_ENV = 'renderer' const path = require('path') const MiniCssExtractPlugin = require('mini-css-extract-plugin') const postcssPresetEnv = require('postcss-preset-env') /** @type {import('webpack').Configuration} */ module.exports = { mode: 'production', devtool: 'hidden-nosources-sour...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/index.js
src/muya/lib/index.js
import ContentState from './contentState' import EventCenter from './eventHandler/event' import MouseEvent from './eventHandler/mouseEvent' import Clipboard from './eventHandler/clipboard' import Keyboard from './eventHandler/keyboard' import DragDrop from './eventHandler/dragDrop' import Resize from './eventHandler/re...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/searchCtrl.js
src/muya/lib/contentState/searchCtrl.js
import execAll from 'execall' import { defaultSearchOption } from '../config' const matchString = (text, value, options) => { const { isCaseSensitive, isWholeWord, isRegexp } = options /* eslint-disable no-useless-escape */ const SPECIAL_CHAR_REG = /[\[\]\\^$.\|\?\*\+\(\)\/]{1}/g /* eslint-enable no-useless-es...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/paragraphCtrl.js
src/muya/lib/contentState/paragraphCtrl.js
import selection from '../selection' import { PARAGRAPH_TYPES, DEFAULT_TURNDOWN_CONFIG } from '../config' import ExportMarkdown from '../utils/exportMarkdown' // get header level // eg: h1 => 1 // h2 => 2 const getCurrentLevel = type => { if (/\d/.test(type)) { return Number(/\d/.exec(type)[0]) } else { ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
true
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/core.js
src/muya/lib/contentState/core.js
const coreApi = ContentState => { /** * Replace the word range with the given replacement. * * @param {*} line A line block reference of the line that contain the word to * replace - must be a valid reference. * @param {*} wordCursor The range of the word to replace (line: "abc >foo< ab...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/formatCtrl.js
src/muya/lib/contentState/formatCtrl.js
import selection from '../selection' import { tokenizer, generator } from '../parser/' import { FORMAT_MARKER_MAP, FORMAT_TYPES } from '../config' import { getImageInfo } from '../utils/getImageInfo' const getOffset = (offset, { range: { start, end }, type, tag, anchor, alt }) => { const dis = offset - start const...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/tabCtrl.js
src/muya/lib/contentState/tabCtrl.js
import selection from '../selection' import { HTML_TAGS, VOID_HTML_TAGS, HAS_TEXT_BLOCK_REG } from '../config' import { tokenizer } from '../parser' /** * parseSelector * div#id.className => {tag: 'div', id: 'id', className: 'className', isVoid: false} */ const parseSelector = (str = '') => { const REG_EXP = /(#...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/history.js
src/muya/lib/contentState/history.js
import { deepCopy } from '../utils' import { UNDO_DEPTH } from '../config' class History { constructor (contentState) { this.stack = [] this.index = -1 this.contentState = contentState this.pending = null } undo () { this.commitPending() if (this.index > 0) { this.index = this.inde...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/linkCtrl.js
src/muya/lib/contentState/linkCtrl.js
const linkCtrl = ContentState => { /** * Change a link into text. */ ContentState.prototype.unlink = function (linkInfo) { const { key, token } = linkInfo const block = this.getBlock(key) const { text } = block let anchor switch (token.type) { case 'html_tag': anchor = token....
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/footnoteCtrl.js
src/muya/lib/contentState/footnoteCtrl.js
/* eslint-disable no-useless-escape */ const FOOTNOTE_REG = /^\[\^([^\^\[\]\s]+?)(?<!\\)\]: / /* eslint-enable no-useless-escape */ const footnoteCtrl = ContentState => { ContentState.prototype.updateFootnote = function (block, line) { const { start, end } = this.cursor const { text } = line const match =...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/index.js
src/muya/lib/contentState/index.js
import { HAS_TEXT_BLOCK_REG, DEFAULT_TURNDOWN_CONFIG } from '../config' import { getUniqueId, deepCopy } from '../utils' import selection from '../selection' import StateRender from '../parser/render' import enterCtrl from './enterCtrl' import updateCtrl from './updateCtrl' import backspaceCtrl from './backspaceCtrl' i...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/clickCtrl.js
src/muya/lib/contentState/clickCtrl.js
import selection from '../selection' import { isMuyaEditorElement } from '../selection/dom' import { HAS_TEXT_BLOCK_REG, CLASS_OR_ID } from '../config' import { getParentCheckBox } from '../utils/getParentCheckBox' import { cumputeCheckboxStatus } from '../utils/cumputeCheckBoxStatus' const clickCtrl = ContentState =>...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/backspaceCtrl.js
src/muya/lib/contentState/backspaceCtrl.js
import selection from '../selection' import { findNearestParagraph, findOutMostParagraph } from '../selection/dom' import { tokenizer, generator } from '../parser/' import { getImageInfo } from '../utils/getImageInfo' const backspaceCtrl = ContentState => { ContentState.prototype.checkBackspaceCase = function () { ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/arrowCtrl.js
src/muya/lib/contentState/arrowCtrl.js
import { EVENT_KEYS, CLASS_OR_ID } from '../config' import { findNearestParagraph } from '../selection/dom' import selection from '../selection' // If the next block is header, put cursor after the `#{1,6} *` const adjustOffset = (offset, block, event) => { if (/^span$/.test(block.type) && block.functionType === 'at...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/htmlBlock.js
src/muya/lib/contentState/htmlBlock.js
import { VOID_HTML_TAGS, HTML_TAGS } from '../config' import { inlineRules } from '../parser/rules' const HTML_BLOCK_REG = /^<([a-zA-Z\d-]+)(?=\s|>)[^<>]*?>$/ const htmlBlock = ContentState => { ContentState.prototype.createHtmlBlock = function (code) { const block = this.createBlock('figure') block.functio...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/emojiCtrl.js
src/muya/lib/contentState/emojiCtrl.js
import { tokenizer, generator } from '../parser/' const emojiCtrl = ContentState => { ContentState.prototype.setEmoji = function (item) { let { key, offset } = this.cursor.start const startBlock = this.getBlock(key) const { text } = startBlock const tokens = tokenizer(text, { options: this.muya...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/tableBlockCtrl.js
src/muya/lib/contentState/tableBlockCtrl.js
import { isLengthEven, getParagraphReference } from '../utils' const TABLE_BLOCK_REG = /^\|.*?(\\*)\|.*?(\\*)\|/ const tableBlockCtrl = ContentState => { ContentState.prototype.createTableInFigure = function ({ rows, columns }, tableContents = []) { const table = this.createBlock('table', { row: rows - 1,...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/pasteCtrl.js
src/muya/lib/contentState/pasteCtrl.js
import { PARAGRAPH_TYPES, PREVIEW_DOMPURIFY_CONFIG, HAS_TEXT_BLOCK_REG, IMAGE_EXT_REG, URL_REG } from '../config' import { sanitize, getUniqueId, getImageInfo as getImageSrc, getPageTitle } from '../utils' import { getImageInfo } from '../utils/getImageInfo' const LIST_REG = /ul|ol/ const LINE_BREAKS_REG = /\n/ cons...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/deleteCtrl.js
src/muya/lib/contentState/deleteCtrl.js
import selection from '../selection' const deleteCtrl = ContentState => { // Handle `delete` keydown event on document. ContentState.prototype.docDeleteHandler = function (event) { // handle delete selected image const { selectedImage } = this if (selectedImage) { event.preventDefault() thi...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/copyCutCtrl.js
src/muya/lib/contentState/copyCutCtrl.js
import selection from '../selection' import { CLASS_OR_ID } from '../config' import { escapeHTML } from '../utils' import { getSanitizeHtml } from '../utils/exportHtml' import ExportMarkdown from '../utils/exportMarkdown' import marked from '../parser/marked' const copyCutCtrl = ContentState => { ContentState.protot...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/tableDragBarCtrl.js
src/muya/lib/contentState/tableDragBarCtrl.js
const calculateAspects = (tableId, barType) => { const table = document.querySelector(`#${tableId}`) if (barType === 'bottom') { const firstRow = table.querySelector('tr') return Array.from(firstRow.children).map(cell => cell.clientWidth) } else { return Array.from(table.querySelectorAll('tr')).map(ro...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/dragDropCtrl.js
src/muya/lib/contentState/dragDropCtrl.js
import { findNearestParagraph, findOutMostParagraph } from '../selection/dom' import { verticalPositionInRect, getUniqueId, getImageInfo as getImageSrc, checkImageContentType } from '../utils' import { getImageInfo } from '../utils/getImageInfo' import { URL_REG, IMAGE_EXT_REG } from '../config' const GHOST_ID = 'mu-d...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/codeBlockCtrl.js
src/muya/lib/contentState/codeBlockCtrl.js
import { loadLanguage } from '../prism/index' import { escapeHTML } from '../utils' // import resizeCodeBlockLineNumber from '../utils/resizeCodeLineNumber' import selection from '../selection' const CODE_UPDATE_REP = /^`{3,}(.*)/ const codeBlockCtrl = ContentState => { /** * check edit language */ ContentSta...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/tableSelectCellsCtrl.js
src/muya/lib/contentState/tableSelectCellsCtrl.js
import { getAllTableCells, getIndex } from './tableDragBarCtrl' const tableSelectCellsCtrl = ContentState => { ContentState.prototype.handleCellMouseDown = function (event) { if (event.buttons === 2) { // the contextmenu is emit. return } const { eventCenter } = this.muya const { target }...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/marktext.js
src/muya/lib/contentState/marktext.js
// __MARKTEXT_ONLY__ import { extractWord, offsetToWordCursor, validateLineCursor } from '../marktext/spellchecker' import selection from '../selection' const marktextApi = ContentState => { /** * Replace the current selected word with the given replacement. * * NOTE: Unsafe method because exacly one word ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/tocCtrl.js
src/muya/lib/contentState/tocCtrl.js
const tocCtrl = ContentState => { ContentState.prototype.getTOC = function () { const { blocks } = this const toc = [] for (const block of blocks) { if (/^h\d$/.test(block.type)) { const { headingStyle, key, type } = block const { text } = block.children[0] const content = h...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/imageCtrl.js
src/muya/lib/contentState/imageCtrl.js
import { URL_REG, DATA_URL_REG } from '../config' import { correctImageSrc } from '../utils/getImageInfo' const imageCtrl = ContentState => { /** * insert inline image at the cursor position. */ ContentState.prototype.insertImage = function ({ alt = '', src = '', title = '' }) { const match = /(?:\/|\\)?...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/enterCtrl.js
src/muya/lib/contentState/enterCtrl.js
import selection from '../selection' import { isOsx } from '../config' /* eslint-disable no-useless-escape */ const FOOTNOTE_REG = /^\[\^([^\^\[\]\s]+?)(?<!\\)\]:$/ /* eslint-enable no-useless-escape */ const checkAutoIndent = (text, offset) => { const pairStr = text.substring(offset - 1, offset + 1) return /^(\{...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/containerCtrl.js
src/muya/lib/contentState/containerCtrl.js
const FUNCTION_TYPE_LANG = { multiplemath: 'latex', flowchart: 'yaml', mermaid: 'yaml', sequence: 'yaml', plantuml: 'yaml', 'vega-lite': 'yaml', html: 'markup' } const containerCtrl = ContentState => { ContentState.prototype.createContainerBlock = function (functionType, value = '', style = undefined) ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/updateCtrl.js
src/muya/lib/contentState/updateCtrl.js
import { tokenizer } from '../parser/' import { conflict } from '../utils' const INLINE_UPDATE_FRAGMENTS = [ '(?:^|\n) {0,3}([*+-] {1,4})', // Bullet list '(?:^|\n)(\\[[x ]{1}\\] {1,4})', // Task list '(?:^|\n) {0,3}(\\d{1,9}(?:\\.|\\)) {1,4})', // Order list '(?:^|\n) {0,3}(#{1,6})(?=\\s{1,}|$)', // ATX headi...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/contentState/inputCtrl.js
src/muya/lib/contentState/inputCtrl.js
import selection from '../selection' import { getTextContent } from '../selection/dom' import { beginRules } from '../parser/rules' import { tokenizer } from '../parser/' import { CLASS_OR_ID } from '../config' const BRACKET_HASH = { '{': '}', '[': ']', '(': ')', '*': '*', _: '_', '"': '"', '\'': '\'', ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/prism/index.js
src/muya/lib/prism/index.js
import Prism from 'prismjs' import { filter } from 'fuzzaldrin' import initLoadLanguage, { loadedLanguages, transformAliasToOrigin } from './loadLanguage' import { languages } from 'prismjs/components.js' const prism = Prism window.Prism = Prism /* eslint-disable */ import('prismjs/plugins/keep-markup/prism-keep-marku...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/prism/loadLanguage.js
src/muya/lib/prism/loadLanguage.js
import components from 'prismjs/components.js' import getLoader from 'prismjs/dependencies' import { getDefer } from '../utils' /** * The set of all languages which have been loaded using the below function. * * @type {Set<string>} */ export const loadedLanguages = new Set(['markup', 'css', 'clike', 'javascript']) ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/renderers/index.js
src/muya/lib/renderers/index.js
const rendererCache = new Map() /** * * @param {string} name the renderer name: katex, sequence, plantuml, flowchart, mermaid, vega-lite */ const loadRenderer = async (name) => { if (!rendererCache.has(name)) { let m switch (name) { case 'sequence': m = await import('../parser/render/sequence...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/marktext/spellchecker.js
src/muya/lib/marktext/spellchecker.js
// __MARKTEXT_ONLY__ import { deepClone } from '../utils' // Source: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/common/model/wordHelper.ts // /(-?\d*\.\d\w*)|([^\`\~\!\@\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/ /* eslint-disable no-useless-escape */ const WORD_SEPARATORS = /(?:[`~...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/cumputeCheckBoxStatus.js
src/muya/lib/utils/cumputeCheckBoxStatus.js
export const cumputeCheckboxStatus = function (parentCheckbox) { const children = parentCheckbox.parentElement.lastElementChild.children const len = children.length for (let i = 0; i < len; i++) { const checkbox = children[i].firstElementChild if (checkbox.checked === false) { return false } }...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/getLinkInfo.js
src/muya/lib/utils/getLinkInfo.js
import { findNearestParagraph } from '../selection/dom' import { tokenizer } from '../parser' export const getLinkInfo = a => { const paragraph = findNearestParagraph(a) const raw = a.getAttribute('data-raw') const start = a.getAttribute('data-start') const end = a.getAttribute('data-end') const tokens = tok...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/getImageInfo.js
src/muya/lib/utils/getImageInfo.js
import { isWin } from '../config' import { findNearestParagraph, getOffsetOfParagraph } from '../selection/dom' import { tokenizer } from '../parser' export const getImageInfo = image => { const paragraph = findNearestParagraph(image) const raw = image.getAttribute('data-raw') const offset = getOffsetOfParagraph...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/index.js
src/muya/lib/utils/index.js
import runSanitize from './dompurify' import { URL_REG, DATA_URL_REG, IMAGE_EXT_REG } from '../config' export { getUniqueId, getLongUniqueId } from './random' const TIMEOUT = 1500 const HTML_TAG_REPLACEMENTS = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' } export const isMetaKey = ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/exportHtml.js
src/muya/lib/utils/exportHtml.js
import marked from '../parser/marked' import Prism from 'prismjs' import katex from 'katex' import 'katex/dist/contrib/mhchem.min.js' import loadRenderer from '../renderers' import githubMarkdownCss from 'github-markdown-css/github-markdown.css' import exportStyle from '../assets/styles/exportStyle.css' import highligh...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/turndownService.js
src/muya/lib/utils/turndownService.js
import TurndownService from 'turndown' import { identity } from './index' const turndownPluginGfm = require('joplin-turndown-plugin-gfm') export const usePluginAddRules = (turndownService, keeps) => { // Use the gfm plugin const { gfm } = turndownPluginGfm turndownService.use(gfm) // We need a extra striketh...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/markdownFile.js
src/muya/lib/utils/markdownFile.js
// __MARKTEXT_ONLY__ const MARKDOWN_EXTENSIONS = Object.freeze([ 'markdown', 'mdown', 'mkdn', 'md', 'mkd', 'mdwn', 'mdtxt', 'mdtext', 'mdx', 'text', 'txt' ]) /** * Returns true if the filename matches one of the markdown extensions allowed in MarkText. * * @param {string} filename Path or fil...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/hash.js
src/muya/lib/utils/hash.js
/** * generate constants map hash, the value is lowercase of the key, * also translate `_` to `-`] */ export const genUpper2LowerKeyHash = keys => { return keys.reduce((acc, key) => { const value = key.toLowerCase().replace(/_/g, '-') return Object.assign(acc, { [key]: value }) }, {}) } /** * generate ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/getParentCheckBox.js
src/muya/lib/utils/getParentCheckBox.js
import { CLASS_OR_ID } from '../config' export const getParentCheckBox = function (checkbox) { const parent = checkbox.parentElement.parentElement.parentElement if (parent.id !== CLASS_OR_ID.AG_EDITOR_ID) { return parent.firstElementChild } else { return null } }
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/dompurify.js
src/muya/lib/utils/dompurify.js
import { sanitize, isValidAttribute } from 'dompurify' export { isValidAttribute } export default sanitize
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/exportMarkdown.js
src/muya/lib/utils/exportMarkdown.js
/** * Hi contributors! * * Before you edit or update codes in this file, * make sure you have read this below: * Commonmark Spec: https://spec.commonmark.org/0.29/ * GitHub Flavored Markdown Spec: https://github.github.com/gfm/ * Pandoc Markdown: https://pandoc.org/MANUAL.html#pandocs-markdown * The output mark...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/url.js
src/muya/lib/utils/url.js
import { isValidAttribute } from '../utils/dompurify' import { isWin } from '../config' // __MARKTEXT_PATCH__ import { hasMarkdownExtension } from './markdownFile' // __MARKTEXT_PATCH__ export const sanitizeHyperlink = rawLink => { if (rawLink && typeof rawLink === 'string') { if (isValidAttribute('a', 'href', r...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/resizeCodeLineNumber.js
src/muya/lib/utils/resizeCodeLineNumber.js
/** * This file copy from prismjs/plugins/prism-line-number */ /** * Regular expression used for determining line breaks * @type {RegExp} */ const NEW_LINE_EXP = /\n(?!$)/g /** * Returns style declarations for the element * @param {Element} element */ const getStyles = function (element) { if (!element) { ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/domManipulate.js
src/muya/lib/utils/domManipulate.js
/** * [description `add` or `remove` className of element */ export const operateClassName = (element, ctrl, className) => { element.classList[ctrl](className) } export const insertBefore = (newNode, originNode) => { const parentNode = originNode.parentNode parentNode.insertBefore(newNode, originNode) } // D...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/random.js
src/muya/lib/utils/random.js
const ID_PREFIX = 'ag-' let id = 0 export const getUniqueId = () => `${ID_PREFIX}${id++}` export const getLongUniqueId = () => `${getUniqueId()}-${(+new Date()).toString(32)}`
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/utils/importMarkdown.js
src/muya/lib/utils/importMarkdown.js
/** * translate markdown format to content state used by MarkText * there is some difference when parse loose list item and tight lsit item. * Both of them add a p block in li block, use the CSS style to distinguish loose and tight. */ import StateRender from '../parser/render' import { tokenizer } from '../parser'...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/assets/libs/snap.svg-min.js
src/muya/lib/assets/libs/snap.svg-min.js
// Snap.svg 0.5.1 // // Copyright (c) 2013 – 2017 Adobe Systems Incorporated. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LIC...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
true
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/assets/libs/sequence-diagram-snap.js
src/muya/lib/assets/libs/sequence-diagram-snap.js
/** js sequence diagrams 2.0.1 * https://bramp.github.io/js-sequence-diagrams/ * (c) 2012-2017 Andrew Brampton (bramp.net) * @license Simplified BSD license. */ import _ from 'underscore' import Snap from 'snapsvg' import WebFont from 'webfontloader' function Diagram() { this.title = undefined; this.actor...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
true
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/eventHandler/dragDrop.js
src/muya/lib/eventHandler/dragDrop.js
class DragDrop { constructor (muya) { this.muya = muya this.dragOverBinding() this.dropBinding() this.dragendBinding() this.dragStartBinding() } dragStartBinding () { const { container, eventCenter } = this.muya const dragStartHandler = event => { if (event.target.tagName === '...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/eventHandler/clipboard.js
src/muya/lib/eventHandler/clipboard.js
class Clipboard { constructor (muya) { this.muya = muya this._copyType = 'normal' // `normal` or `copyAsMarkdown` or `copyAsHtml` this._pasteType = 'normal' // `normal` or `pasteAsPlainText` this._copyInfo = null this.listen() } listen () { const { container, eventCenter, contentState } =...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/eventHandler/resize.js
src/muya/lib/eventHandler/resize.js
// import resizeCodeBlockLineNumber from '../utils/resizeCodeLineNumber' // import { throttle } from '../utils' class Resize { constructor (muya) { this.muya = muya this.listen() } listen () { // FIXME: Disabled due to #1648. // const { codeBlockLineNumbers } = this.muya.options // if (!code...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/eventHandler/clickEvent.js
src/muya/lib/eventHandler/clickEvent.js
import { operateClassName } from '../utils/domManipulate' import { getImageInfo } from '../utils/getImageInfo' import { CLASS_OR_ID } from '../config' import selection from '../selection' class ClickEvent { constructor (muya) { this.muya = muya this.clickBinding() this.contextClickBingding() } conte...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/eventHandler/event.js
src/muya/lib/eventHandler/event.js
import { getUniqueId } from '../utils' class EventCenter { constructor () { this.events = [] this.listeners = {} } /** * [attachDOMEvent] bind event listener to target, and return a unique ID, * this ID */ attachDOMEvent (target, event, listener, capture) { if (this.checkHasBind(target, e...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/eventHandler/mouseEvent.js
src/muya/lib/eventHandler/mouseEvent.js
import { getLinkInfo } from '../utils/getLinkInfo' import { collectFootnotes } from '../utils' class MouseEvent { constructor (muya) { this.muya = muya this.mouseBinding() this.mouseDown() } mouseBinding () { const { container, eventCenter } = this.muya const handler = event => { const...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/eventHandler/keyboard.js
src/muya/lib/eventHandler/keyboard.js
import { EVENT_KEYS } from '../config' import selection from '../selection' import { findNearestParagraph } from '../selection/dom' import { getParagraphReference, getImageInfo } from '../utils' import { checkEditEmoji } from '../ui/emojis' class Keyboard { constructor (muya) { this.muya = muya this.isCompos...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/selection/index.js
src/muya/lib/selection/index.js
/** * This file is copy from [medium-editor](https://github.com/yabwe/medium-editor) * and customize for specialized use. */ import Cursor from './cursor' import { CLASS_OR_ID } from '../config' import { isBlockContainer, traverseUp, getFirstSelectableLeafNode, getClosestBlockContainer, getCursorPositionWi...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/selection/dom.js
src/muya/lib/selection/dom.js
import { LOWERCASE_TAGS, CLASS_OR_ID, blockContainerElementNames, emptyElementNames } from '../config' const CHOP_TEXT_REG = /(\*{1,3})([^*]+)(\1)/g export const getTextContent = (node, blackList) => { if (node.nodeType === 3) { return node.textContent } else if (!blackList) { return node.textContent }...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/selection/cursor.js
src/muya/lib/selection/cursor.js
import { compareParagraphsOrder } from './dom' class Cursor { // You need to provide either `anchor`&&`focus` or `start`&&`end` or all. constructor ({ anchor, focus, start, end, noHistory = false }) { if (anchor && focus && start && end) { this.anchor = anchor this.focus = focus this.start = ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/config/index.js
src/muya/lib/config/index.js
import htmlTags from 'html-tags' import voidHtmlTags from 'html-tags/void' import { generateKeyHash, genUpper2LowerKeyHash } from '../utils/hash' import { getLongUniqueId } from '../utils/random' // [0.25, 0.5, 1, 2, 4, 8] <—?—> [256M, 500M/768M, 1G/1000M, 2G, 4G, 8G] // Electron 2.0.2 not support yet! So give a defau...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/emojiPicker/index.js
src/muya/lib/ui/emojiPicker/index.js
import BaseScrollFloat from '../baseScrollFloat' import Emoji from '../emojis' import { patch, h } from '../../parser/render/snabbdom' import './index.css' class EmojiPicker extends BaseScrollFloat { static pluginName = 'emojiPicker' constructor (muya) { const name = 'ag-emoji-picker' super(muya, name) ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/tooltip/index.js
src/muya/lib/ui/tooltip/index.js
import './index.css' const position = (source, ele) => { const rect = source.getBoundingClientRect() const { top, right, height } = rect Object.assign(ele.style, { top: `${top + height + 15}px`, left: `${right - ele.offsetWidth / 2 - 10}px` }) } class Tooltip { constructor (muya) { this.muya = ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/tablePicker/index.js
src/muya/lib/ui/tablePicker/index.js
import BaseFloat from '../baseFloat' import { patch, h } from '../../parser/render/snabbdom' import './index.css' import { EVENT_KEYS } from '../../config' class TablePicker extends BaseFloat { static pluginName = 'tablePicker' constructor (muya) { const name = 'ag-table-picker' super(muya, name) this...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/emojis/index.js
src/muya/lib/ui/emojis/index.js
import { filter } from 'fuzzaldrin' import emojis from './emojisJson' import { CLASS_OR_ID } from '../../config' const emojisForSearch = {} for (const emoji of emojis) { const newEmoji = Object.assign({}, emoji, { search: [...emoji.aliases, ...emoji.tags].join(' ') }) if (emojisForSearch[newEmoji.category]) { ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/fileIcons/index.js
src/muya/lib/ui/fileIcons/index.js
// Because the sidebar also use the file icons, So I put this file out of floatBox directory. import '@marktext/file-icons/build/index.css' import fileIcons from '@marktext/file-icons' fileIcons.getClassByName = function (name) { const icon = fileIcons.matchName(name) return icon ? icon.getClass(0, false) : null ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/quickInsert/index.js
src/muya/lib/ui/quickInsert/index.js
import { filter } from 'fuzzaldrin' import { patch, h } from '../../parser/render/snabbdom' import { deepCopy } from '../../utils' import BaseScrollFloat from '../baseScrollFloat' import { quickInsertObj } from './config' import './index.css' class QuickInsert extends BaseScrollFloat { static pluginName = 'quickInse...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/quickInsert/config.js
src/muya/lib/ui/quickInsert/config.js
import paragraphIcon from '../../assets/pngicon/paragraph/2.png' import htmlIcon from '../../assets/pngicon/html/2.png' import hrIcon from '../../assets/pngicon/horizontal_line/2.png' import frontMatterIcon from '../../assets/pngicon/front_matter/2.png' import header1Icon from '../../assets/pngicon/heading_1/2.png' imp...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/linkTools/index.js
src/muya/lib/ui/linkTools/index.js
import BaseFloat from '../baseFloat' import { patch, h } from '../../parser/render/snabbdom' import icons from './config' import './index.css' const defaultOptions = { placement: 'bottom', modifiers: { offset: { offset: '0, 5' } }, showArrow: false } class LinkTools extends BaseFloat { static...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/linkTools/config.js
src/muya/lib/ui/linkTools/config.js
import unlinkIcon from '../../assets/pngicon/unlink/2.png' import linkJumpIcon from '../../assets/pngicon/link_jump/2.png' const icons = [ { type: 'unlink', icon: unlinkIcon }, { type: 'jump', icon: linkJumpIcon } ] export default icons
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/tableTools/index.js
src/muya/lib/ui/tableTools/index.js
import BaseFloat from '../baseFloat' import { patch, h } from '../../parser/render/snabbdom' import { toolList } from './config' import './index.css' const defaultOptions = { placement: 'right-start', modifiers: { offset: { offset: '0, 5' } }, showArrow: false } class TableBarTools extends Base...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/tableTools/config.js
src/muya/lib/ui/tableTools/config.js
export const toolList = { left: [{ label: 'Insert Row Above', action: 'insert', location: 'previous', target: 'row' }, { label: 'Insert Row Below', action: 'insert', location: 'next', target: 'row' }, { label: 'Remove Row', action: 'remove', location: 'current', tar...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/codePicker/index.js
src/muya/lib/ui/codePicker/index.js
import BaseScrollFloat from '../baseScrollFloat' import { patch, h } from '../../parser/render/snabbdom' import { search } from '../../prism/index' import fileIcons from '../fileIcons' import './index.css' const defaultOptions = { placement: 'bottom-start', modifiers: { offset: { offset: '0, 0' } ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/imageSelector/index.js
src/muya/lib/ui/imageSelector/index.js
import { createApi } from 'unsplash-js' import BaseFloat from '../baseFloat' import { patch, h } from '../../parser/render/snabbdom' import { EVENT_KEYS, URL_REG, isWin } from '../../config' import { getUniqueId, getImageInfo as getImageSrc } from '../../utils' import { getImageInfo } from '../../utils/getImageInfo' i...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/frontMenu/index.js
src/muya/lib/ui/frontMenu/index.js
import BaseFloat from '../baseFloat' import { patch, h } from '../../parser/render/snabbdom' import { menu, getSubMenu, getLabel } from './config' import './index.css' const MAX_SUBMENU_HEIGHT = 400 const ITEM_HEIGHT = 28 const PADDING = 10 const defaultOptions = { placement: 'bottom', modifiers: { offset: {...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/frontMenu/config.js
src/muya/lib/ui/frontMenu/config.js
import copyIcon from '../../assets/pngicon/copy/2.png' import newIcon from '../../assets/pngicon/paragraph/2.png' import deleteIcon from '../../assets/pngicon/delete/2.png' import turnIcon from '../../assets/pngicon/turninto/2.png' import { isOsx } from '../../config' import { quickInsertObj } from '../quickInsert/conf...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/transformer/index.js
src/muya/lib/ui/transformer/index.js
import './index.css' const CIRCLES = [ 'top-left', 'top-right', 'bottom-left', 'bottom-right' ] const CIRCLE_RADIO = 6 class Transformer { static pluginName = 'transformer' constructor (muya, options) { this.muya = muya this.options = options this.reference = null this.imageInfo = null ...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/formatPicker/index.js
src/muya/lib/ui/formatPicker/index.js
import BaseFloat from '../baseFloat' import { patch, h } from '../../parser/render/snabbdom' import icons from './config' import './index.css' const defaultOptions = { placement: 'top', modifiers: { offset: { offset: '0, 5' } }, showArrow: false } class FormatPicker extends BaseFloat { static...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false
marktext/marktext
https://github.com/marktext/marktext/blob/aa71e33e07845419533d767ad0d260a7c267cec7/src/muya/lib/ui/formatPicker/config.js
src/muya/lib/ui/formatPicker/config.js
import { isOsx } from '../../config' import strongIcon from '../../assets/pngicon/format_strong/2.png' import emphasisIcon from '../../assets/pngicon/format_emphasis/2.png' import underlineIcon from '../../assets/pngicon/format_underline/2.png' import codeIcon from '../../assets/pngicon/code/2.png' import imageIcon fro...
javascript
MIT
aa71e33e07845419533d767ad0d260a7c267cec7
2026-01-04T14:57:09.944492Z
false