Skip to content

Commit

Permalink
fix: 删除文字的时候前一张图片不会被删除
Browse files Browse the repository at this point in the history
  • Loading branch information
guqianfeng committed Dec 13, 2021
1 parent 38b4b22 commit bac1b1e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
14 changes: 8 additions & 6 deletions src/config/menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,21 @@ export default {
// type -> 'emoji' / 'image'
type: 'emoji',
// content -> 数组
content: '😀 😃 😄 😁 😆 😅 😂 🤣 😊 😇 🙂 🙃 😉 😌 😍 😘 😗 😙 😚 😋 😛 😝 😜 🤓 😎 😏 😒 😞 😔 😟 😕 🙁 😣 😖 😫 😩 😢 😭 😤 😠 😡 😳 😱 😨 🤗 🤔 😶 😑 😬 🙄 😯 😴 😷 🤑 😈 🤡 💩 👻 💀 👀 👣'.split(
/\s/
),
content:
'😀 😃 😄 😁 😆 😅 😂 🤣 😊 😇 🙂 🙃 😉 😌 😍 😘 😗 😙 😚 😋 😛 😝 😜 🤓 😎 😏 😒 😞 😔 😟 😕 🙁 😣 😖 😫 😩 😢 😭 😤 😠 😡 😳 😱 😨 🤗 🤔 😶 😑 😬 🙄 😯 😴 😷 🤑 😈 🤡 💩 👻 💀 👀 👣'.split(
/\s/
),
},
{
// tab 的标题
title: '手势',
// type -> 'emoji' / 'image'
type: 'emoji',
// content -> 数组
content: '👐 🙌 👏 🤝 👍 👎 👊 ✊ 🤛 🤜 🤞 ✌️ 🤘 👌 👈 👉 👆 👇 ☝️ ✋ 🤚 🖐 🖖 👋 🤙 💪 🖕 ✍️ 🙏'.split(
/\s/
),
content:
'👐 🙌 👏 🤝 👍 👎 👊 ✊ 🤛 🤜 🤞 ✌️ 🤘 👌 👈 👉 👆 👇 ☝️ ✋ 🤚 🖐 🖖 👋 🤙 💪 🖕 ✍️ 🙏'.split(
/\s/
),
},
],

Expand Down
3 changes: 2 additions & 1 deletion src/lib/simplehtmlparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ SimpleHtmlParser.prototype = {

// regexps

startTagRe: /^<([^>\s\/]+)((\s+[^=>\s]+(\s*=\s*((\"[^"]*\")|(\'[^']*\')|[^>\s]+))?)*)\s*\/?\s*>/m,
startTagRe:
/^<([^>\s\/]+)((\s+[^=>\s]+(\s*=\s*((\"[^"]*\")|(\'[^']*\')|[^>\s]+))?)*)\s*\/?\s*>/m,
endTagRe: /^<\/([^>\s]+)[^>]*>/m,
attrRe: /([^=\s]+)(\s*=\s*((\"([^"]*)\")|(\'([^']*)\')|[^>\s]+))?/gm,

Expand Down
8 changes: 0 additions & 8 deletions src/menus/img/bind-event/keyboard-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,5 @@ export default function bindEventKeyboardEvent(editor: Editor) {
lastChildNodeInPrevNode =
lastChildNodeInPrevNode.childNodes[lastChildNodeInPrevNode.childNodes.length - 1]
}

if (
lastChildNodeInPrevNode instanceof HTMLElement &&
lastChildNodeInPrevNode.tagName === 'IMG'
) {
lastChildNodeInPrevNode.remove()
e.preventDefault()
}
})
}
4 changes: 2 additions & 2 deletions src/menus/lineHeight/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class LineHeight extends DropListMenu implements MenuActive {
//获取range 开头结束的dom
const StartElem: DomElement = $(editor.selection.getSelectionStartElem())
const EndElem: DomElement = $(editor.selection.getSelectionEndElem())
const childList: NodeListOf<ChildNode> | undefined = editor.selection.getRange()
?.commonAncestorContainer.childNodes
const childList: NodeListOf<ChildNode> | undefined =
editor.selection.getRange()?.commonAncestorContainer.childNodes
arrayDom_a.push(this.getDom(StartElem.elems[0]))
childList?.forEach((item, index) => {
if (item === this.getDom(StartElem.elems[0])) {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
export function EMPTY_FN() {}

//用于校验是否为url格式字符串
export const urlRegex = /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&amp;:/~+#]*[\w\-@?^=%&amp;/~+#])?/
export const urlRegex =
/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&amp;:/~+#]*[\w\-@?^=%&amp;/~+#])?/

// 编辑器为了方便继续输入/换行等原因 主动生成的空标签
export const EMPTY_P = '<p data-we-empty-p=""><br></p>'
Expand Down

0 comments on commit bac1b1e

Please sign in to comment.