Bugfix: Can not select emoji

This commit is contained in:
Jocs 2018-04-01 12:09:55 +08:00
parent 13f4164b32
commit efe58c7835
5 changed files with 6 additions and 14 deletions

View File

@ -120,7 +120,7 @@ Mark Text build for these platforms ![Conda](https://img.shields.io/conda/pn/con
| ![]( https://github.com/ryanoasis/nerd-fonts/wiki/screenshots/v1.0.x/mac-pass-sm.png) | ![]( https://github.com/ryanoasis/nerd-fonts/wiki/screenshots/v1.0.x/windows-pass-sm.png) | ![]( https://github.com/ryanoasis/nerd-fonts/wiki/screenshots/v1.0.x/linux-pass-sm.png) | | ![]( https://github.com/ryanoasis/nerd-fonts/wiki/screenshots/v1.0.x/mac-pass-sm.png) | ![]( https://github.com/ryanoasis/nerd-fonts/wiki/screenshots/v1.0.x/windows-pass-sm.png) | ![]( https://github.com/ryanoasis/nerd-fonts/wiki/screenshots/v1.0.x/linux-pass-sm.png) |
| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
| [latest version](https://github.com/marktext/marktext/releases/download/v0.8.12/marktext-0.8.12.dmg) | [latest version](https://github.com/marktext/marktext/releases/download/v0.8.12/marktext-setup-0.8.12.exe) | [latest version](https://github.com/marktext/marktext/releases/download/v0.8.12/marktext-0.8.12-x86_64.AppImage) | | [latest version](https://github.com/marktext/marktext/releases/download/v0.9.25/marktext-0.9.25.dmg) | [latest version](https://github.com/marktext/marktext/releases/download/v0.9.25/marktext-setup-0.9.25.exe) | [latest version](https://github.com/marktext/marktext/releases/download/v0.9.25/marktext-0.9.25-x86_64.AppImage) |
Did not found your system ? Go the the [release page](https://github.com/marktext/marktext/releases). Still not found ? Shoot an [issue](https://github.com/marktext/marktext/issues). Did not found your system ? Go the the [release page](https://github.com/marktext/marktext/releases). Still not found ? Shoot an [issue](https://github.com/marktext/marktext/issues).

View File

@ -61,16 +61,6 @@ const copyCutCtrl = ContentState => {
}) })
} }
// const mathText = $(`.${CLASS_OR_ID['AG_MATH']} span`)
// if (mathText.length > 0) {
// mathText.each((i, m) => {
// const ele = $(m)
// console.log(ele.text())
// ele.text(ele.text().replace(/\\/g, ''))
// })
// }
const codefense = $(`pre.${CLASS_OR_ID['AG_CODE_BLOCK']}`) const codefense = $(`pre.${CLASS_OR_ID['AG_CODE_BLOCK']}`)
if (codefense.length > 0) { if (codefense.length > 0) {
codefense.each((i, cf) => { codefense.each((i, cf) => {

View File

@ -35,6 +35,7 @@ const pasteCtrl = ContentState => {
} }
const stateFragments = this.html2State(html) const stateFragments = this.html2State(html)
if (stateFragments.length <= 0) return if (stateFragments.length <= 0) return
// step 1: if select content, cut the content, and chop the block text into two part by the cursor. // step 1: if select content, cut the content, and chop the block text into two part by the cursor.
const { start, end } = this.cursor const { start, end } = this.cursor

View File

@ -147,7 +147,7 @@ class Aganippe {
const { left, top } = emojiNode.getBoundingClientRect() const { left, top } = emojiNode.getBoundingClientRect()
const cb = item => { const cb = item => {
setInlineEmoji(emojiNode, item, selection) setInlineEmoji(emojiNode, item, selection)
this.floatBox.hideIfNeeded(['emojis']) this.floatBox.hideIfNeeded(['emoji'])
} }
if (list.length) { if (list.length) {
this.floatBox.showIfNeeded({ this.floatBox.showIfNeeded({
@ -155,7 +155,7 @@ class Aganippe {
}, 'emoji', cb) }, 'emoji', cb)
this.floatBox.setOptions(list) this.floatBox.setOptions(list)
} else { } else {
this.floatBox.hideIfNeeded('emojis') this.floatBox.hideIfNeeded('emoji')
} }
} }
} }

View File

@ -222,7 +222,8 @@ const importRegister = ContentState => {
} }
// transform `paste's text/html data` to content state blocks. // transform `paste's text/html data` to content state blocks.
ContentState.prototype.html2State = function (html) { ContentState.prototype.html2State = function (html) {
const markdown = turndownService.turndown(html) // remove double `\\` in Math but I dont know why there are two '\' when paste. @jocs
const markdown = turndownService.turndown(html).replace(/(\\)\\/g, '$1')
return this.getStateFragment(markdown) return this.getStateFragment(markdown)
} }