Feat: add user preference whether hide the link popup (#1504)

This commit is contained in:
Ran Luo 2019-10-21 10:42:05 +08:00 committed by GitHub
parent d0d76f0b5d
commit a4b4a7a847
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 45 additions and 19 deletions

View File

@ -20,7 +20,7 @@ Preferences can be controlled and modified in the settings window or via the `pr
#### Editor
| Key | Type | Defaut | Description |
| ---------------------- | ------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ---------------------------------- | ------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| fontSize | Number | 16 | Font size in pixels. 12 ~ 32 |
| editorFontFamily | String | Open Sans | Font Family |
| lineHeight | Number | 1.6 | Line Height |
@ -36,6 +36,7 @@ Preferences can be controlled and modified in the settings window or via the `pr
| imageDropAction | String | folder | The default behavior after paste or drag the image to Mark Text, upload it to the image cloud (if configured), move to the specified folder, insert the path |
| defaultEncoding | String | `utf8` | The default file encoding |
| autoGuessEncoding | Boolean | true | Try to automatically guess the file encoding when opening files |
| hideLinkPopup | Boolean | false | It will not show the link popup when hover over the link if set `hideLinkPopup` to true |
#### Markdown
@ -48,6 +49,7 @@ Preferences can be controlled and modified in the settings window or via the `pr
| tabSize | Number | 4 | The number of spaces a tab is equal to |
| listIndentation | String | 1 | The list indentation of sub list items or paragraphs, optional value `dfm`, `tab` or number 1~4 |
| frontmatterType | String | `-` | The frontmatter type: `-` (YAML), `+` (TOML), `;` (JSON) or `{` (JSON) |
#### Theme
| Key | Type | Default | Description |

View File

@ -176,6 +176,11 @@
"description": "Editor--Hide hint for quickly creating paragraphs",
"type": "boolean"
},
"hideLinkPopup": {
"description": "Editor--Hide link popup when the cursor is hover on the link",
"type": "boolean",
"default": false
},
"preferLooseListItem": {
"description": "Markdown--The preferred list type",

View File

@ -255,6 +255,7 @@ export const MUYA_DEFAULT_OPTION = {
mermaidTheme: 'default', // dark / forest / default
vegaTheme: 'latimes', // excel / ggplot2 / quartz / vox / fivethirtyeight / dark / latimes
hideQuickInsertHint: false,
hideLinkPopup: false,
// Whether we should set spellcheck attribute on our container to highlight misspelled words.
// NOTE: The browser is not able to correct misspelled words words without a custom
// implementation like in Mark Text.

View File

@ -12,7 +12,8 @@ class MouseEvent {
const handler = event => {
const target = event.target
const parent = target.parentNode
if (parent && parent.tagName === 'A' && parent.classList.contains('ag-inline-rule')) {
const { hideLinkPopup } = this.muya.options
if (!hideLinkPopup && parent && parent.tagName === 'A' && parent.classList.contains('ag-inline-rule')) {
const rect = parent.getBoundingClientRect()
const reference = {
getBoundingClientRect () {

View File

@ -144,6 +144,7 @@ export default {
trimUnnecessaryCodeBlockEmptyLines: state => state.preferences.trimUnnecessaryCodeBlockEmptyLines,
editorFontFamily: state => state.preferences.editorFontFamily,
hideQuickInsertHint: state => state.preferences.hideQuickInsertHint,
hideLinkPopup: state => state.preferences.hideLinkPopup,
editorLineWidth: state => state.preferences.editorLineWidth,
imageInsertAction: state => state.preferences.imageInsertAction,
imageFolderPath: state => state.preferences.imageFolderPath,
@ -291,6 +292,12 @@ export default {
editor.setOptions({ orderListDelimiter: value })
}
},
hideLinkPopup: function (value, oldValue) {
const { editor } = this
if (value !== oldValue && editor) {
editor.setOptions({ hideLinkPopup: value })
}
},
codeFontSize: function (value, oldValue) {
if (value !== oldValue) {
addCommonStyle({
@ -434,7 +441,8 @@ export default {
hideQuickInsertHint,
editorLineWidth,
theme,
spellcheckerEnabled
spellcheckerEnabled,
hideLinkPopup
} = this
// use muya UI plugins
@ -471,6 +479,7 @@ export default {
listIndentation,
frontmatterType,
hideQuickInsertHint,
hideLinkPopup,
spellcheckEnabled: spellcheckerEnabled,
imageAction: this.imageAction.bind(this),
imagePathPicker: this.imagePathPicker.bind(this),

View File

@ -91,6 +91,11 @@
:bool="hideQuickInsertHint"
:onChange="value => onSelectChange('hideQuickInsertHint', value)"
></bool>
<bool
description="Hide link popup when the cursor is hover on the link."
:bool="hideLinkPopup"
:onChange="value => onSelectChange('hideLinkPopup', value)"
></bool>
<separator></separator>
<text-box
description="Defines the maximum editor area width. An empty string or suffixes of ch (characters), px (pixels) or % (percentage) are allowed."
@ -145,6 +150,7 @@ export default {
codeFontFamily: state => state.preferences.codeFontFamily,
trimUnnecessaryCodeBlockEmptyLines: state => state.preferences.trimUnnecessaryCodeBlockEmptyLines,
hideQuickInsertHint: state => state.preferences.hideQuickInsertHint,
hideLinkPopup: state => state.preferences.hideLinkPopup,
editorLineWidth: state => state.preferences.editorLineWidth,
defaultEncoding: state => state.preferences.defaultEncoding,
autoGuessEncoding: state => state.preferences.autoGuessEncoding

View File

@ -31,6 +31,7 @@ const state = {
textDirection: 'ltr',
hideQuickInsertHint: false,
imageInsertAction: 'folder',
hideLinkPopup: false,
preferLooseListItem: true,
bulletListMarker: '-',

View File

@ -28,6 +28,7 @@
"textDirection": "ltr",
"hideQuickInsertHint": false,
"imageInsertAction": "path",
"hideLinkPopup": false,
"preferLooseListItem": true,
"bulletListMarker": "-",