Skip to content

Commit

Permalink
fix: 修复列表下无法设置超链接的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
liuqh committed Jul 22, 2021
1 parent 12542eb commit 00bfdb5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 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
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: 3 additions & 0 deletions src/menus/link/create-panel-conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export default function (editor: Editor, text: string, link: string): PanelConf
* @param link 链接
*/
function insertLink(text: string, link: string): void {
// fix: 修复列表下无法设置超链接的问题(替换选中文字中的标签)
const subStr = new RegExp(/(<\/*ul>)|(<\/*li>)|(<\/*ol>)/g)
text = text.replace(subStr, '')
if (isActive(editor)) {
// 选区处于链接中,则选中整个菜单,再执行 insertHTML
selectLinkElem()
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 00bfdb5

Please sign in to comment.