From 8fc7e04272ab222416e2cbfbaa57eb2565a8f87a Mon Sep 17 00:00:00 2001 From: chenlei <791563973@qq.com> Date: Sun, 30 May 2021 21:00:52 +0800 Subject: [PATCH 01/13] =?UTF-8?q?fix:=20=E8=AE=BE=E7=BD=AE=E5=AD=97?= =?UTF-8?q?=E4=BD=93=E5=A4=A7=E5=B0=8F=E5=92=8C=E9=A2=9C=E8=89=B2=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=85=89=E6=A0=87=E8=B7=B3=E5=88=B0=E8=A1=8C=E9=A6=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/menus.ts | 14 ++++++-------- src/lib/simplehtmlparser.js | 3 +-- src/menus/font-color/index.ts | 13 ------------- src/menus/font-size/index.ts | 14 -------------- src/menus/lineHeight/index.ts | 4 ++-- src/utils/const.ts | 3 +-- 6 files changed, 10 insertions(+), 41 deletions(-) diff --git a/src/config/menus.ts b/src/config/menus.ts index c53c6ff5c..820e397f2 100644 --- a/src/config/menus.ts +++ b/src/config/menus.ts @@ -182,10 +182,9 @@ export default { // type -> 'emoji' / 'image' type: 'emoji', // content -> ๆ•ฐ็ป„ - content: - '๐Ÿ˜€ ๐Ÿ˜ƒ ๐Ÿ˜„ ๐Ÿ˜ ๐Ÿ˜† ๐Ÿ˜… ๐Ÿ˜‚ ๐Ÿคฃ ๐Ÿ˜Š ๐Ÿ˜‡ ๐Ÿ™‚ ๐Ÿ™ƒ ๐Ÿ˜‰ ๐Ÿ˜Œ ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜š ๐Ÿ˜‹ ๐Ÿ˜› ๐Ÿ˜ ๐Ÿ˜œ ๐Ÿค“ ๐Ÿ˜Ž ๐Ÿ˜ ๐Ÿ˜’ ๐Ÿ˜ž ๐Ÿ˜” ๐Ÿ˜Ÿ ๐Ÿ˜• ๐Ÿ™ ๐Ÿ˜ฃ ๐Ÿ˜– ๐Ÿ˜ซ ๐Ÿ˜ฉ ๐Ÿ˜ข ๐Ÿ˜ญ ๐Ÿ˜ค ๐Ÿ˜  ๐Ÿ˜ก ๐Ÿ˜ณ ๐Ÿ˜ฑ ๐Ÿ˜จ ๐Ÿค— ๐Ÿค” ๐Ÿ˜ถ ๐Ÿ˜‘ ๐Ÿ˜ฌ ๐Ÿ™„ ๐Ÿ˜ฏ ๐Ÿ˜ด ๐Ÿ˜ท ๐Ÿค‘ ๐Ÿ˜ˆ ๐Ÿคก ๐Ÿ’ฉ ๐Ÿ‘ป ๐Ÿ’€ ๐Ÿ‘€ ๐Ÿ‘ฃ'.split( - /\s/ - ), + content: '๐Ÿ˜€ ๐Ÿ˜ƒ ๐Ÿ˜„ ๐Ÿ˜ ๐Ÿ˜† ๐Ÿ˜… ๐Ÿ˜‚ ๐Ÿคฃ ๐Ÿ˜Š ๐Ÿ˜‡ ๐Ÿ™‚ ๐Ÿ™ƒ ๐Ÿ˜‰ ๐Ÿ˜Œ ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜š ๐Ÿ˜‹ ๐Ÿ˜› ๐Ÿ˜ ๐Ÿ˜œ ๐Ÿค“ ๐Ÿ˜Ž ๐Ÿ˜ ๐Ÿ˜’ ๐Ÿ˜ž ๐Ÿ˜” ๐Ÿ˜Ÿ ๐Ÿ˜• ๐Ÿ™ ๐Ÿ˜ฃ ๐Ÿ˜– ๐Ÿ˜ซ ๐Ÿ˜ฉ ๐Ÿ˜ข ๐Ÿ˜ญ ๐Ÿ˜ค ๐Ÿ˜  ๐Ÿ˜ก ๐Ÿ˜ณ ๐Ÿ˜ฑ ๐Ÿ˜จ ๐Ÿค— ๐Ÿค” ๐Ÿ˜ถ ๐Ÿ˜‘ ๐Ÿ˜ฌ ๐Ÿ™„ ๐Ÿ˜ฏ ๐Ÿ˜ด ๐Ÿ˜ท ๐Ÿค‘ ๐Ÿ˜ˆ ๐Ÿคก ๐Ÿ’ฉ ๐Ÿ‘ป ๐Ÿ’€ ๐Ÿ‘€ ๐Ÿ‘ฃ'.split( + /\s/ + ), }, { // tab ็š„ๆ ‡้ข˜ @@ -193,10 +192,9 @@ export default { // type -> 'emoji' / 'image' type: 'emoji', // content -> ๆ•ฐ็ป„ - content: - '๐Ÿ‘ ๐Ÿ™Œ ๐Ÿ‘ ๐Ÿค ๐Ÿ‘ ๐Ÿ‘Ž ๐Ÿ‘Š โœŠ ๐Ÿค› ๐Ÿคœ ๐Ÿคž โœŒ๏ธ ๐Ÿค˜ ๐Ÿ‘Œ ๐Ÿ‘ˆ ๐Ÿ‘‰ ๐Ÿ‘† ๐Ÿ‘‡ โ˜๏ธ โœ‹ ๐Ÿคš ๐Ÿ– ๐Ÿ–– ๐Ÿ‘‹ ๐Ÿค™ ๐Ÿ’ช ๐Ÿ–• โœ๏ธ ๐Ÿ™'.split( - /\s/ - ), + content: '๐Ÿ‘ ๐Ÿ™Œ ๐Ÿ‘ ๐Ÿค ๐Ÿ‘ ๐Ÿ‘Ž ๐Ÿ‘Š โœŠ ๐Ÿค› ๐Ÿคœ ๐Ÿคž โœŒ๏ธ ๐Ÿค˜ ๐Ÿ‘Œ ๐Ÿ‘ˆ ๐Ÿ‘‰ ๐Ÿ‘† ๐Ÿ‘‡ โ˜๏ธ โœ‹ ๐Ÿคš ๐Ÿ– ๐Ÿ–– ๐Ÿ‘‹ ๐Ÿค™ ๐Ÿ’ช ๐Ÿ–• โœ๏ธ ๐Ÿ™'.split( + /\s/ + ), }, ], diff --git a/src/lib/simplehtmlparser.js b/src/lib/simplehtmlparser.js index 21eb17a5a..502696297 100644 --- a/src/lib/simplehtmlparser.js +++ b/src/lib/simplehtmlparser.js @@ -61,8 +61,7 @@ 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, diff --git a/src/menus/font-color/index.ts b/src/menus/font-color/index.ts index c98f0603d..5d0b55142 100644 --- a/src/menus/font-color/index.ts +++ b/src/menus/font-color/index.ts @@ -46,19 +46,6 @@ class FontColor extends DropListMenu implements MenuActive { if ($selectionElem == null) return - const isFont = $selectionElem?.nodeName.toLowerCase() !== 'p' - const isSameColor = $selectionElem?.getAttribute('color') === value - - if (isEmptySelection) { - if (isFont && !isSameColor) { - const $elems = editor.selection.getSelectionRangeTopNodes() - editor.selection.createRangeByElem($elems[0]) - editor.selection.moveCursor($elems[0].elems[0]) - } - editor.selection.setRangeToElem($selectionElem) - // ๆ’ๅ…ฅ็ฉบ็™ฝ้€‰ๅŒบ - editor.selection.createEmptyRange() - } // ่Žทๅ–้€‰ๅŒบ่Œƒๅ›ด็š„ๆ–‡ๅญ— const $selectionText = editor.selection.getSelectionText() // ๅฆ‚ๆžœ่ฎพ็ฝฎ็š„ๆ˜ฏ a ๆ ‡็ญพๅฐฑ็‰นๆฎŠๅค„็†ไธ€ไธ‹๏ผŒ้ฟๅ…ๅ›ž่ฝฆๆข่กŒ่ฎพ็ฝฎ้ขœ่‰ฒๆ— ๆ•ˆ็š„ๆƒ…ๅ†ต diff --git a/src/menus/font-size/index.ts b/src/menus/font-size/index.ts index 897352d69..12d698474 100644 --- a/src/menus/font-size/index.ts +++ b/src/menus/font-size/index.ts @@ -43,20 +43,6 @@ class FontSize extends DropListMenu implements MenuActive { if (selectionElem == null) return - const isFont = selectionElem?.nodeName.toLowerCase() !== 'p' - const isSameSize = selectionElem?.getAttribute('size') === value - if (isEmptySelection) { - if (isFont && !isSameSize) { - const $elems = editor.selection.getSelectionRangeTopNodes() - const focusElem = $elems[0].elems[0] - editor.selection.createRangeByElem($elems[0]) - editor.selection.moveCursor(focusElem) - selectionElem = focusElem - } - editor.selection.setRangeToElem(selectionElem) - // ๆ’ๅ…ฅ็ฉบ็™ฝ้€‰ๅŒบ - editor.selection.createEmptyRange() - } editor.cmd.do('fontSize', value) if (isEmptySelection) { // ้œ€่ฆๅฐ†้€‰ๅŒบ่Œƒๅ›ดๆŠ˜ๅ ่ตทๆฅ diff --git a/src/menus/lineHeight/index.ts b/src/menus/lineHeight/index.ts index 35e76ffad..8e780112e 100644 --- a/src/menus/lineHeight/index.ts +++ b/src/menus/lineHeight/index.ts @@ -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 | undefined = - editor.selection.getRange()?.commonAncestorContainer.childNodes + const childList: NodeListOf | 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])) { diff --git a/src/utils/const.ts b/src/utils/const.ts index 2b49406cc..2423d015a 100644 --- a/src/utils/const.ts +++ b/src/utils/const.ts @@ -6,8 +6,7 @@ export function EMPTY_FN() {} //็”จไบŽๆ ก้ชŒๆ˜ฏๅฆไธบurlๆ ผๅผๅญ—็ฌฆไธฒ -export const urlRegex = - /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/ +export const urlRegex = /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/ // ็ผ–่พ‘ๅ™จไธบไบ†ๆ–นไพฟ็ปง็ปญ่พ“ๅ…ฅ/ๆข่กŒ็ญ‰ๅŽŸๅ›  ไธปๅŠจ็”Ÿๆˆ็š„็ฉบๆ ‡็ญพ export const EMPTY_P = '


' From bd464598850a47bcafbac44110a2d28e59797ffc Mon Sep 17 00:00:00 2001 From: luochao <651644100@qq.com> Date: Thu, 3 Jun 2021 22:42:56 +0800 Subject: [PATCH 02/13] release: v4.7.2 --- CHANGELOG.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dcf7aed7..e6c93a96a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## [4.7.2](https://github.com/wangeditor-team/wangEditor/compare/v4.7.1...v4.7.2) (2021-06-03) + + +### Bug Fixes + +* ็ฆไฟฎๅคๅคš่กŒๆ’ๅ…ฅ้“พๆŽฅ้€ ๆˆ้กต้ขๅกๆญป,ๆญขๅคš่กŒๆ’ๅ…ฅ้“พ้“พๆŽฅ ([110b37a](https://github.com/wangeditor-team/wangEditor/commit/110b37a8bb3b6bd5d87e1d831c8dab6f52e2b6df)) +* ่ฎพ็ฝฎๅญ—ไฝ“ๅคงๅฐๅ’Œ้ขœ่‰ฒๆ—ถ๏ผŒๅ…‰ๆ ‡่ทณๅˆฐ่กŒ้ฆ– ([8fc7e04](https://github.com/wangeditor-team/wangEditor/commit/8fc7e04272ab222416e2cbfbaa57eb2565a8f87a)) +* ไฟฎๅค็ป™ๆ ‡้ข˜ๅŠ ่ถ…้“พๆŽฅ็š„้—ฎ้ข˜ ([0d7a05e](https://github.com/wangeditor-team/wangEditor/commit/0d7a05e8c922bc48dc655bee90b8192a816057f9)) +* ไฟฎๅคๅˆ ้™คๅ…จ้ƒจๅ†…ๅฎนๅŽEMPTY_Pๅ‰ๆœ‰ไธช็ฉบๆ ผ ([1811f8c](https://github.com/wangeditor-team/wangEditor/commit/1811f8c417f8466df5d458a6c215fad1e4b2b7c3)) +* ts ๆž„ๅปบ้”™่ฏฏ ([4603677](https://github.com/wangeditor-team/wangEditor/commit/46036774c73f909dae99c950b0ffcc67f7414b9f)) + ## [4.7.1](https://github.com/wangeditor-team/wangEditor/compare/v4.7.0...v4.7.1) (2021-05-20) diff --git a/package.json b/package.json index a9733da21..5128fb2cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wangeditor", - "version": "4.7.1", + "version": "4.7.2", "description": "wangEditor - ่ฝป้‡็บง web ๅฏŒๆ–‡ๆœฌ็ผ–่พ‘ๅ™จ๏ผŒ้…็ฝฎๆ–นไพฟ๏ผŒไฝฟ็”จ็ฎ€ๅ•๏ผŒๅผ€ๆบๅ…่ดน", "homepage": "http://www.wangeditor.com/", "keywords": [ From 0648a9340a7c156dbc16b83e955f684854cb8c76 Mon Sep 17 00:00:00 2001 From: TGuoW <15768620356@163.com> Date: Sun, 6 Jun 2021 16:53:18 +0800 Subject: [PATCH 03/13] =?UTF-8?q?fix:=20=E7=89=B9=E6=AE=8A=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E6=97=A0=E6=B3=95=E9=80=9A=E8=BF=87backspace?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/menus/img/bind-event/index.ts | 3 ++ src/menus/img/bind-event/keyboard-event.ts | 63 ++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/menus/img/bind-event/keyboard-event.ts diff --git a/src/menus/img/bind-event/index.ts b/src/menus/img/bind-event/index.ts index bd96c1f85..d2f88ba90 100644 --- a/src/menus/img/bind-event/index.ts +++ b/src/menus/img/bind-event/index.ts @@ -8,6 +8,7 @@ import bindPasteImg from './paste-img' import bindDropImg from './drop-img' import bindDragImgSize from './drag-size' import bindTooltipImg from './tooltip-event' +import bindKeyboardEvent from './keyboard-event' /** * ็ป‘ๅฎšไบ‹ไปถ @@ -26,6 +27,8 @@ function bindEvent(editor: Editor): void { //Tooltip bindTooltipImg(editor) + + bindKeyboardEvent(editor) } export default bindEvent diff --git a/src/menus/img/bind-event/keyboard-event.ts b/src/menus/img/bind-event/keyboard-event.ts new file mode 100644 index 000000000..dadc70dac --- /dev/null +++ b/src/menus/img/bind-event/keyboard-event.ts @@ -0,0 +1,63 @@ +import Editor from '../../../editor' + +export default function bindEventKeyboardEvent(editor: Editor) { + const { txt, selection } = editor + const { keydownEvents } = txt.eventHooks + + keydownEvents.push(function (e) { + // ๅˆ ้™คๅ›พ็‰‡ๆ—ถ๏ผŒๆœ‰ๆ—ถไผšๅ› ไธบๆต่งˆๅ™จbugๅˆ ไธๆŽ‰ใ€‚ๅ› ๆญค่ฟ™้‡Œๆ‰‹ๅŠจๅˆคๆ–ญๅ…‰ๆ ‡ๅ‰้ขๆ˜ฏไธๆ˜ฏๅ›พ็‰‡๏ผŒๆ˜ฏๅฐฑๅˆ ๆŽ‰ + const $selectionContainerElem = selection.getSelectionContainerElem() + const range = selection.getRange() + + if ( + !range || + !$selectionContainerElem || + e.keyCode !== 8 || + !selection.isSelectionEmpty() + ) { + return + } + let { startContainer, startOffset } = range + + // ๅŒไธ€ๆฎต่ฝๅ†…ไธŠไธ€ไธช่Š‚็‚น + let prevNode: Node | null = null + if (startOffset === 0) { + // ๆญคๆ—ถไธŠไธ€ไธช่Š‚็‚น้œ€่ฆ้€š่ฟ‡previousSiblingๅŽปๆ‰พ + while ( + startContainer !== $selectionContainerElem.elems[0] && + $selectionContainerElem.elems[0].contains(startContainer) && + startContainer.parentNode && + !prevNode + ) { + if (startContainer.previousSibling) { + prevNode = startContainer.previousSibling as Node + break + } + startContainer = startContainer.parentNode + } + } else if (startContainer.nodeType !== 3) { + // ้žๆ–‡ๆœฌ่Š‚็‚นๆ‰้œ€่ฆ่ขซๅค„็†๏ผŒๆฏ”ๅฆ‚p + prevNode = startContainer.childNodes[startOffset - 1] + } + + if (!prevNode) { + return + } + + let lastChildNodeInPrevNode = prevNode + + // ๆ‰พๅˆฐๆœ€ๅณไพงๅถๅญ่Š‚็‚น + while (lastChildNodeInPrevNode.childNodes.length) { + lastChildNodeInPrevNode = + lastChildNodeInPrevNode.childNodes[lastChildNodeInPrevNode.childNodes.length - 1] + } + + if ( + lastChildNodeInPrevNode instanceof HTMLElement && + lastChildNodeInPrevNode.tagName === 'IMG' + ) { + lastChildNodeInPrevNode.remove() + e.preventDefault() + } + }) +} From 313665c5a656314477f8973e0cdff9c4ba125aeb Mon Sep 17 00:00:00 2001 From: lichenabson <1114795127@qq.com> Date: Mon, 7 Jun 2021 15:07:53 +0800 Subject: [PATCH 04/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E7=B2=98?= =?UTF-8?q?=E8=B4=B4=E6=97=B6=E8=BF=87=E6=BB=A4meta=E7=9A=84=E8=A1=8C?= =?UTF-8?q?=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/menus.ts | 14 ++++++-------- src/lib/simplehtmlparser.js | 3 +-- src/menus/lineHeight/index.ts | 4 ++-- src/text/paste/paste-event.ts | 2 +- src/utils/const.ts | 3 +-- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/config/menus.ts b/src/config/menus.ts index c53c6ff5c..820e397f2 100644 --- a/src/config/menus.ts +++ b/src/config/menus.ts @@ -182,10 +182,9 @@ export default { // type -> 'emoji' / 'image' type: 'emoji', // content -> ๆ•ฐ็ป„ - content: - '๐Ÿ˜€ ๐Ÿ˜ƒ ๐Ÿ˜„ ๐Ÿ˜ ๐Ÿ˜† ๐Ÿ˜… ๐Ÿ˜‚ ๐Ÿคฃ ๐Ÿ˜Š ๐Ÿ˜‡ ๐Ÿ™‚ ๐Ÿ™ƒ ๐Ÿ˜‰ ๐Ÿ˜Œ ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜š ๐Ÿ˜‹ ๐Ÿ˜› ๐Ÿ˜ ๐Ÿ˜œ ๐Ÿค“ ๐Ÿ˜Ž ๐Ÿ˜ ๐Ÿ˜’ ๐Ÿ˜ž ๐Ÿ˜” ๐Ÿ˜Ÿ ๐Ÿ˜• ๐Ÿ™ ๐Ÿ˜ฃ ๐Ÿ˜– ๐Ÿ˜ซ ๐Ÿ˜ฉ ๐Ÿ˜ข ๐Ÿ˜ญ ๐Ÿ˜ค ๐Ÿ˜  ๐Ÿ˜ก ๐Ÿ˜ณ ๐Ÿ˜ฑ ๐Ÿ˜จ ๐Ÿค— ๐Ÿค” ๐Ÿ˜ถ ๐Ÿ˜‘ ๐Ÿ˜ฌ ๐Ÿ™„ ๐Ÿ˜ฏ ๐Ÿ˜ด ๐Ÿ˜ท ๐Ÿค‘ ๐Ÿ˜ˆ ๐Ÿคก ๐Ÿ’ฉ ๐Ÿ‘ป ๐Ÿ’€ ๐Ÿ‘€ ๐Ÿ‘ฃ'.split( - /\s/ - ), + content: '๐Ÿ˜€ ๐Ÿ˜ƒ ๐Ÿ˜„ ๐Ÿ˜ ๐Ÿ˜† ๐Ÿ˜… ๐Ÿ˜‚ ๐Ÿคฃ ๐Ÿ˜Š ๐Ÿ˜‡ ๐Ÿ™‚ ๐Ÿ™ƒ ๐Ÿ˜‰ ๐Ÿ˜Œ ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜š ๐Ÿ˜‹ ๐Ÿ˜› ๐Ÿ˜ ๐Ÿ˜œ ๐Ÿค“ ๐Ÿ˜Ž ๐Ÿ˜ ๐Ÿ˜’ ๐Ÿ˜ž ๐Ÿ˜” ๐Ÿ˜Ÿ ๐Ÿ˜• ๐Ÿ™ ๐Ÿ˜ฃ ๐Ÿ˜– ๐Ÿ˜ซ ๐Ÿ˜ฉ ๐Ÿ˜ข ๐Ÿ˜ญ ๐Ÿ˜ค ๐Ÿ˜  ๐Ÿ˜ก ๐Ÿ˜ณ ๐Ÿ˜ฑ ๐Ÿ˜จ ๐Ÿค— ๐Ÿค” ๐Ÿ˜ถ ๐Ÿ˜‘ ๐Ÿ˜ฌ ๐Ÿ™„ ๐Ÿ˜ฏ ๐Ÿ˜ด ๐Ÿ˜ท ๐Ÿค‘ ๐Ÿ˜ˆ ๐Ÿคก ๐Ÿ’ฉ ๐Ÿ‘ป ๐Ÿ’€ ๐Ÿ‘€ ๐Ÿ‘ฃ'.split( + /\s/ + ), }, { // tab ็š„ๆ ‡้ข˜ @@ -193,10 +192,9 @@ export default { // type -> 'emoji' / 'image' type: 'emoji', // content -> ๆ•ฐ็ป„ - content: - '๐Ÿ‘ ๐Ÿ™Œ ๐Ÿ‘ ๐Ÿค ๐Ÿ‘ ๐Ÿ‘Ž ๐Ÿ‘Š โœŠ ๐Ÿค› ๐Ÿคœ ๐Ÿคž โœŒ๏ธ ๐Ÿค˜ ๐Ÿ‘Œ ๐Ÿ‘ˆ ๐Ÿ‘‰ ๐Ÿ‘† ๐Ÿ‘‡ โ˜๏ธ โœ‹ ๐Ÿคš ๐Ÿ– ๐Ÿ–– ๐Ÿ‘‹ ๐Ÿค™ ๐Ÿ’ช ๐Ÿ–• โœ๏ธ ๐Ÿ™'.split( - /\s/ - ), + content: '๐Ÿ‘ ๐Ÿ™Œ ๐Ÿ‘ ๐Ÿค ๐Ÿ‘ ๐Ÿ‘Ž ๐Ÿ‘Š โœŠ ๐Ÿค› ๐Ÿคœ ๐Ÿคž โœŒ๏ธ ๐Ÿค˜ ๐Ÿ‘Œ ๐Ÿ‘ˆ ๐Ÿ‘‰ ๐Ÿ‘† ๐Ÿ‘‡ โ˜๏ธ โœ‹ ๐Ÿคš ๐Ÿ– ๐Ÿ–– ๐Ÿ‘‹ ๐Ÿค™ ๐Ÿ’ช ๐Ÿ–• โœ๏ธ ๐Ÿ™'.split( + /\s/ + ), }, ], diff --git a/src/lib/simplehtmlparser.js b/src/lib/simplehtmlparser.js index 21eb17a5a..502696297 100644 --- a/src/lib/simplehtmlparser.js +++ b/src/lib/simplehtmlparser.js @@ -61,8 +61,7 @@ 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, diff --git a/src/menus/lineHeight/index.ts b/src/menus/lineHeight/index.ts index 35e76ffad..8e780112e 100644 --- a/src/menus/lineHeight/index.ts +++ b/src/menus/lineHeight/index.ts @@ -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 | undefined = - editor.selection.getRange()?.commonAncestorContainer.childNodes + const childList: NodeListOf | 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])) { diff --git a/src/text/paste/paste-event.ts b/src/text/paste/paste-event.ts index 1be77b628..f5bdcf50f 100644 --- a/src/text/paste/paste-event.ts +++ b/src/text/paste/paste-event.ts @@ -52,7 +52,7 @@ export function getPasteHtml( pasteHtml = pasteHtml.replace(/<(\d)/gm, (_, num) => '<' + num) // pdfๅคๅˆถๅชไผšๆœ‰ไธ€ไธชmetaๆ ‡็ญพ๏ผŒparseHtmlไธญ็š„่ฟ‡ๆปคmetaๆ ‡็ญพไผšๅฏผ่‡ดๅŽ้ขๅ†…ๅฎนไธขๅคฑ - pasteHtml = pasteHtml.replace(//gim, '') + pasteHtml = pasteHtml.replace(/<(\/?meta.*?)>/gim, '') // ๅ‰”้™คๅคšไฝ™็š„ๆ ‡็ญพใ€ๅฑžๆ€ง pasteHtml = parseHtml(pasteHtml, filterStyle, ignoreImg) diff --git a/src/utils/const.ts b/src/utils/const.ts index 2b49406cc..2423d015a 100644 --- a/src/utils/const.ts +++ b/src/utils/const.ts @@ -6,8 +6,7 @@ export function EMPTY_FN() {} //็”จไบŽๆ ก้ชŒๆ˜ฏๅฆไธบurlๆ ผๅผๅญ—็ฌฆไธฒ -export const urlRegex = - /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/ +export const urlRegex = /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/ // ็ผ–่พ‘ๅ™จไธบไบ†ๆ–นไพฟ็ปง็ปญ่พ“ๅ…ฅ/ๆข่กŒ็ญ‰ๅŽŸๅ›  ไธปๅŠจ็”Ÿๆˆ็š„็ฉบๆ ‡็ญพ export const EMPTY_P = '


' From 4ed9c87bfd84f813c894c73b54b9d8e868dd05d7 Mon Sep 17 00:00:00 2001 From: wangfupeng Date: Thu, 10 Jun 2021 10:26:08 +0800 Subject: [PATCH 05/13] chore: dev deploy config --- .github/workflows/dev.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 6f8e55b28..5c532fcdf 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -38,7 +38,7 @@ jobs: mkdir -p ~/.ssh/ echo "${{secrets.WFP_ID_RSA}}" > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa - ssh-keyscan ${{secrets.TECENT_SERVER}} >> ~/.ssh/known_hosts + ssh-keyscan ${{secrets.BAIDU_SERVER}} >> ~/.ssh/known_hosts - name: scp test files # ๆ‹ท่ดๆต‹่ฏ•้กต้ข๏ผŒๅˆฐ่ฟœ็จ‹ๆœๅŠกๅ™จ run: | ## ่Žทๅ–ๅฝ“ๅ‰ๅˆ†ๆ”ฏๅ็งฐ๏ผŒๅนถๅˆ›ๅปบไธ€ไธชๅŒๅ็š„ๆ–‡ไปถๅคน @@ -51,7 +51,7 @@ jobs: ## ๅฐ†่ฏฅๆ–‡ไปถๅคน๏ผŒๅŠๅ…ถๆ‰€ๆœ‰ๆ–‡ไปถ๏ผŒไธŠไผ ๅˆฐๆœๅŠกๅ™จ echo current branch name is: $currentBranchName - ssh work@${{secrets.TECENT_SERVER}} "rm -rf /home/work/wangEditor-team/example-pages/$currentBranchName" - scp -r ./$currentBranchName work@${{secrets.TECENT_SERVER}}:/home/work/wangEditor-team/example-pages/$currentBranchName + ssh work@${{secrets.BAIDU_SERVER}} "rm -rf /home/work/wangEditor-team/v4-examples/$currentBranchName" + scp -r ./$currentBranchName work@${{secrets.BAIDU_SERVER}}:/home/work/wangEditor-team/v4-examples/$currentBranchName - name: delete ssh key # ๅˆ ้™ค ssh key run: rm -rf ~/.ssh/id_rsa From a645cdd54284acaffa1d52d10cfc3bd7b5cc3599 Mon Sep 17 00:00:00 2001 From: wangfupeng Date: Thu, 10 Jun 2021 10:40:01 +0800 Subject: [PATCH 06/13] chore: publish deploy --- .github/workflows/dev.yml | 2 +- .github/workflows/npm-publish.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 5c532fcdf..6215c387d 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -2,7 +2,7 @@ # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions # github actions ไธญๆ–‡ๆ–‡ๆกฃ https://docs.github.com/cn/actions/getting-started-with-github-actions -name: deploy to tecent server - example page +name: deploy to baidu server - example page on: push: diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 783359720..706b28362 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -37,7 +37,7 @@ jobs: mkdir -p ~/.ssh/ echo "${{secrets.WFP_ID_RSA}}" > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa - ssh-keyscan ${{secrets.TECENT_SERVER}} >> ~/.ssh/known_hosts + ssh-keyscan ${{secrets.BAIDU_SERVER}} >> ~/.ssh/known_hosts - name: rebuild we-demo and scp run: | ## ไธ‹่ฝฝ demo ๏ผŒๅฎ‰่ฃ…ๆœ€ๆ–ฐ็š„ๆ’ไปถ๏ผŒๅนถ้‡ๆ–ฐๆ‰“ๅŒ… @@ -52,5 +52,5 @@ jobs: ## ๅฐ† dist ๆ–‡ไปถๅคน๏ผŒ้‡ๅ‘ฝๅไธบ publish-npm-test ๏ผŒๅนถไธŠไผ ๅˆฐๆœๅŠกๅ™จ mv dist publish-npm-test - ssh work@${{secrets.TECENT_SERVER}} "rm -rf /home/work/wangEditor-team/example-pages/publish-npm-test" - scp -r ./publish-npm-test work@${{secrets.TECENT_SERVER}}:/home/work/wangEditor-team/example-pages/publish-npm-test + ssh work@${{secrets.BAIDU_SERVER}} "rm -rf /home/work/wangEditor-team/v4-examples/publish-npm-test" + scp -r ./publish-npm-test work@${{secrets.BAIDU_SERVER}}:/home/work/wangEditor-team/v4-examples/publish-npm-test From 23eb557a5dabcdc6201753695a8590dec539fe9e Mon Sep 17 00:00:00 2001 From: WangJolin <1113584801@qq.com> Date: Thu, 10 Jun 2021 14:54:18 +0800 Subject: [PATCH 07/13] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Da=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E5=8C=85=E8=A3=B9img=E7=9A=84=20=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=20=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/link.html | 5 ++++- src/menus/link/bind-event/tooltip-event.ts | 21 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/examples/link.html b/examples/link.html index 6fbb29424..7c65df226 100644 --- a/examples/link.html +++ b/examples/link.html @@ -13,6 +13,7 @@

wangEditor demo

+



@@ -41,7 +42,9 @@ diff --git a/src/menus/link/bind-event/tooltip-event.ts b/src/menus/link/bind-event/tooltip-event.ts index 19cd6fbdf..6bcc62492 100644 --- a/src/menus/link/bind-event/tooltip-event.ts +++ b/src/menus/link/bind-event/tooltip-event.ts @@ -36,9 +36,24 @@ function createShowHideFn(editor: Editor) { editor.selection.createRangeByElem($link) editor.selection.restoreSelection() - // ็”จๆ–‡ๅญ—๏ผŒๆ›ฟๆข้“พๆŽฅ - const selectionText = $link.text() - editor.cmd.do('insertHTML', '' + selectionText + '') + const $childNodes = $link.childNodes() + // ๅฆ‚ๆžœ้“พๆŽฅๆ˜ฏๅ›พ็‰‡ + if ($childNodes?.getNodeName() === 'IMG') { + // ่Žทๅ–้€‰ไธญ็š„ๅ›พ็‰‡ + const $selectIMG = editor.selection.getSelectionContainerElem()?.children() + ?.elems[0].children[0] + // ๆ’ๅ…ฅๅ›พ็‰‡ + editor.cmd.do( + 'insertHTML', + `` + ) + } else { + // ็”จๆ–‡ๅญ—๏ผŒๆ›ฟๆข้“พๆŽฅ + const selectionText = $link.text() + editor.cmd.do('insertHTML', '' + selectionText + '') + } // ่ฟ”ๅ›ž true๏ผŒ่กจ็คบๆ‰ง่กŒๅฎŒไน‹ๅŽ๏ผŒ้š่— tooltipใ€‚ๅฆๅˆ™ไธ้š่—ใ€‚ return true From 27aec31aeb04089bf5457fb9275b2916098cbdc2 Mon Sep 17 00:00:00 2001 From: wangfupeng Date: Thu, 10 Jun 2021 15:26:11 +0800 Subject: [PATCH 08/13] =?UTF-8?q?chore:=20=E4=BF=AE=E6=94=B9=20upload=20AP?= =?UTF-8?q?I=20=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/i18next.html | 2 +- examples/jq-create-dom.html | 2 +- examples/txt-html-function.html | 2 +- examples/upload-image-alt.html | 2 +- examples/upload-image.html | 14 +++++++------- examples/upload-img-accept-empty.html | 2 +- examples/upload-video.html | 2 +- src/config/menus.ts | 14 ++++++++------ src/lib/simplehtmlparser.js | 3 ++- src/menus/lineHeight/index.ts | 4 ++-- src/utils/const.ts | 3 ++- test/unit/editor/upload-core.test.ts | 2 +- test/unit/menus/img/upload-img.test.ts | 4 ++-- test/unit/menus/video/upload-video.test.ts | 2 +- 14 files changed, 31 insertions(+), 27 deletions(-) diff --git a/examples/i18next.html b/examples/i18next.html index 2961a0cc3..24fd057e8 100644 --- a/examples/i18next.html +++ b/examples/i18next.html @@ -20,7 +20,7 @@ diff --git a/examples/upload-img-accept-empty.html b/examples/upload-img-accept-empty.html index 4d318ecaa..9365c2461 100644 --- a/examples/upload-img-accept-empty.html +++ b/examples/upload-img-accept-empty.html @@ -20,7 +20,7 @@ const E = window.wangEditor const editor = new E('#div1') editor.config.uploadImgAccept = [] - editor.config.uploadImgServer = '/api/upload-img' + editor.config.uploadImgServer = 'http://106.12.198.214:3000/api/upload-img' // editor.config.showLinkImgAlt = true // editor.config.showLinkImgHref = true editor.config.showLinkImg = false diff --git a/examples/upload-video.html b/examples/upload-video.html index 0792dda89..399db89e1 100644 --- a/examples/upload-video.html +++ b/examples/upload-video.html @@ -27,7 +27,7 @@ var editor = new E('#div1') // ไธŠไผ ๅœฐๅ€ - editor.config.uploadVideoServer = '/api/upload-video'; + editor.config.uploadVideoServer = 'http://106.12.198.214:3000/api/upload-video'; // ่‡ชๅฎšไน‰ๆ’ๅ…ฅ่ง†้ข‘ // editor.config.customInsertVideo = (url) => { diff --git a/src/config/menus.ts b/src/config/menus.ts index 820e397f2..c53c6ff5c 100644 --- a/src/config/menus.ts +++ b/src/config/menus.ts @@ -182,9 +182,10 @@ export default { // type -> 'emoji' / 'image' type: 'emoji', // content -> ๆ•ฐ็ป„ - content: '๐Ÿ˜€ ๐Ÿ˜ƒ ๐Ÿ˜„ ๐Ÿ˜ ๐Ÿ˜† ๐Ÿ˜… ๐Ÿ˜‚ ๐Ÿคฃ ๐Ÿ˜Š ๐Ÿ˜‡ ๐Ÿ™‚ ๐Ÿ™ƒ ๐Ÿ˜‰ ๐Ÿ˜Œ ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜š ๐Ÿ˜‹ ๐Ÿ˜› ๐Ÿ˜ ๐Ÿ˜œ ๐Ÿค“ ๐Ÿ˜Ž ๐Ÿ˜ ๐Ÿ˜’ ๐Ÿ˜ž ๐Ÿ˜” ๐Ÿ˜Ÿ ๐Ÿ˜• ๐Ÿ™ ๐Ÿ˜ฃ ๐Ÿ˜– ๐Ÿ˜ซ ๐Ÿ˜ฉ ๐Ÿ˜ข ๐Ÿ˜ญ ๐Ÿ˜ค ๐Ÿ˜  ๐Ÿ˜ก ๐Ÿ˜ณ ๐Ÿ˜ฑ ๐Ÿ˜จ ๐Ÿค— ๐Ÿค” ๐Ÿ˜ถ ๐Ÿ˜‘ ๐Ÿ˜ฌ ๐Ÿ™„ ๐Ÿ˜ฏ ๐Ÿ˜ด ๐Ÿ˜ท ๐Ÿค‘ ๐Ÿ˜ˆ ๐Ÿคก ๐Ÿ’ฉ ๐Ÿ‘ป ๐Ÿ’€ ๐Ÿ‘€ ๐Ÿ‘ฃ'.split( - /\s/ - ), + content: + '๐Ÿ˜€ ๐Ÿ˜ƒ ๐Ÿ˜„ ๐Ÿ˜ ๐Ÿ˜† ๐Ÿ˜… ๐Ÿ˜‚ ๐Ÿคฃ ๐Ÿ˜Š ๐Ÿ˜‡ ๐Ÿ™‚ ๐Ÿ™ƒ ๐Ÿ˜‰ ๐Ÿ˜Œ ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜š ๐Ÿ˜‹ ๐Ÿ˜› ๐Ÿ˜ ๐Ÿ˜œ ๐Ÿค“ ๐Ÿ˜Ž ๐Ÿ˜ ๐Ÿ˜’ ๐Ÿ˜ž ๐Ÿ˜” ๐Ÿ˜Ÿ ๐Ÿ˜• ๐Ÿ™ ๐Ÿ˜ฃ ๐Ÿ˜– ๐Ÿ˜ซ ๐Ÿ˜ฉ ๐Ÿ˜ข ๐Ÿ˜ญ ๐Ÿ˜ค ๐Ÿ˜  ๐Ÿ˜ก ๐Ÿ˜ณ ๐Ÿ˜ฑ ๐Ÿ˜จ ๐Ÿค— ๐Ÿค” ๐Ÿ˜ถ ๐Ÿ˜‘ ๐Ÿ˜ฌ ๐Ÿ™„ ๐Ÿ˜ฏ ๐Ÿ˜ด ๐Ÿ˜ท ๐Ÿค‘ ๐Ÿ˜ˆ ๐Ÿคก ๐Ÿ’ฉ ๐Ÿ‘ป ๐Ÿ’€ ๐Ÿ‘€ ๐Ÿ‘ฃ'.split( + /\s/ + ), }, { // tab ็š„ๆ ‡้ข˜ @@ -192,9 +193,10 @@ export default { // type -> 'emoji' / 'image' type: 'emoji', // content -> ๆ•ฐ็ป„ - content: '๐Ÿ‘ ๐Ÿ™Œ ๐Ÿ‘ ๐Ÿค ๐Ÿ‘ ๐Ÿ‘Ž ๐Ÿ‘Š โœŠ ๐Ÿค› ๐Ÿคœ ๐Ÿคž โœŒ๏ธ ๐Ÿค˜ ๐Ÿ‘Œ ๐Ÿ‘ˆ ๐Ÿ‘‰ ๐Ÿ‘† ๐Ÿ‘‡ โ˜๏ธ โœ‹ ๐Ÿคš ๐Ÿ– ๐Ÿ–– ๐Ÿ‘‹ ๐Ÿค™ ๐Ÿ’ช ๐Ÿ–• โœ๏ธ ๐Ÿ™'.split( - /\s/ - ), + content: + '๐Ÿ‘ ๐Ÿ™Œ ๐Ÿ‘ ๐Ÿค ๐Ÿ‘ ๐Ÿ‘Ž ๐Ÿ‘Š โœŠ ๐Ÿค› ๐Ÿคœ ๐Ÿคž โœŒ๏ธ ๐Ÿค˜ ๐Ÿ‘Œ ๐Ÿ‘ˆ ๐Ÿ‘‰ ๐Ÿ‘† ๐Ÿ‘‡ โ˜๏ธ โœ‹ ๐Ÿคš ๐Ÿ– ๐Ÿ–– ๐Ÿ‘‹ ๐Ÿค™ ๐Ÿ’ช ๐Ÿ–• โœ๏ธ ๐Ÿ™'.split( + /\s/ + ), }, ], diff --git a/src/lib/simplehtmlparser.js b/src/lib/simplehtmlparser.js index 502696297..21eb17a5a 100644 --- a/src/lib/simplehtmlparser.js +++ b/src/lib/simplehtmlparser.js @@ -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, diff --git a/src/menus/lineHeight/index.ts b/src/menus/lineHeight/index.ts index 8e780112e..35e76ffad 100644 --- a/src/menus/lineHeight/index.ts +++ b/src/menus/lineHeight/index.ts @@ -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 | undefined = editor.selection.getRange() - ?.commonAncestorContainer.childNodes + const childList: NodeListOf | 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])) { diff --git a/src/utils/const.ts b/src/utils/const.ts index 2423d015a..2b49406cc 100644 --- a/src/utils/const.ts +++ b/src/utils/const.ts @@ -6,7 +6,8 @@ export function EMPTY_FN() {} //็”จไบŽๆ ก้ชŒๆ˜ฏๅฆไธบurlๆ ผๅผๅญ—็ฌฆไธฒ -export const urlRegex = /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/ +export const urlRegex = + /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/ // ็ผ–่พ‘ๅ™จไธบไบ†ๆ–นไพฟ็ปง็ปญ่พ“ๅ…ฅ/ๆข่กŒ็ญ‰ๅŽŸๅ›  ไธปๅŠจ็”Ÿๆˆ็š„็ฉบๆ ‡็ญพ export const EMPTY_P = '


' diff --git a/test/unit/editor/upload-core.test.ts b/test/unit/editor/upload-core.test.ts index fd5bfbea2..aafe3aed8 100644 --- a/test/unit/editor/upload-core.test.ts +++ b/test/unit/editor/upload-core.test.ts @@ -6,7 +6,7 @@ import post from '../../../src/editor/upload/upload-core' import mockXHR from '../../helpers/mock-xhr' -const API_URL = 'http://localhost:8881/api/upload-img' +const API_URL = 'http://106.12.198.214:3000/api/upload-img' const origilaXHR = window.XMLHttpRequest const deaultResponse = { status: 200, res: JSON.stringify({ data: ['url1'], errno: 0 }) } diff --git a/test/unit/menus/img/upload-img.test.ts b/test/unit/menus/img/upload-img.test.ts index 624d33c20..339770e29 100644 --- a/test/unit/menus/img/upload-img.test.ts +++ b/test/unit/menus/img/upload-img.test.ts @@ -13,8 +13,8 @@ let id = 1 const imgUrl = 'http://www.wangeditor.com/imgs/logo.jpeg' const errorUrl = 'error.jpeg' -const uploadImgServer = 'http://localhost:8881/api/upload-img' -const uploadImgServerWithHash = 'http://localhost:8881/api/upload-img#/123' +const uploadImgServer = 'http://106.12.198.214:3000/api/upload-img' +const uploadImgServerWithHash = 'http://106.12.198.214:3000/api/upload-img#/123' const defaultRes = { status: 200, diff --git a/test/unit/menus/video/upload-video.test.ts b/test/unit/menus/video/upload-video.test.ts index 2c1d896e3..aec379660 100644 --- a/test/unit/menus/video/upload-video.test.ts +++ b/test/unit/menus/video/upload-video.test.ts @@ -16,7 +16,7 @@ let id = 1 const videoUrl = 'https://stream7.iqilu.com/10339/upload_transcode/202002/18/20200218114723HDu3hhxqIT.mp4' -const uploadVideoServer = 'http://localhost:8881/api/upload-video' +const uploadVideoServer = 'http://106.12.198.214:3000/api/upload-video' const defaultRes = { status: 200, From 9b5fb5e4908ca51193ed2e0f4af1286706365d4c Mon Sep 17 00:00:00 2001 From: wangfupeng Date: Thu, 10 Jun 2021 15:34:16 +0800 Subject: [PATCH 09/13] =?UTF-8?q?chore:=20=E5=88=A0=E9=99=A4=20server=20?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/server.yml | 34 ---------- docs/dev.md | 1 - package.json | 4 -- server/README.md | 22 +----- server/controller/save-file.js | 97 -------------------------- server/controller/saveVideo-file.js | 102 ---------------------------- server/index.js | 14 ---- server/pm2.conf.json | 13 ---- server/rm.sh | 6 -- server/router.js | 29 -------- server/util.js | 14 ---- 11 files changed, 1 insertion(+), 335 deletions(-) delete mode 100644 .github/workflows/server.yml delete mode 100644 server/controller/save-file.js delete mode 100644 server/controller/saveVideo-file.js delete mode 100644 server/pm2.conf.json delete mode 100644 server/rm.sh delete mode 100644 server/router.js delete mode 100644 server/util.js diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml deleted file mode 100644 index 0904c8497..000000000 --- a/.github/workflows/server.yml +++ /dev/null @@ -1,34 +0,0 @@ -# ๆต‹่ฏ•ๆœบๅฎ‰่ฃ… git node pm2 - -name: deploy to tecent server - server - -on: - push: - branches: - - 'server' - paths: - - '.github/workflows/*' - - 'server/**' -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: set ssh key # ไธดๆ—ถ่ฎพ็ฝฎ ssh key - run: | - mkdir -p ~/.ssh/ - echo "${{secrets.WFP_ID_RSA}}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - ssh-keyscan ${{secrets.TECENT_SERVER}} >> ~/.ssh/known_hosts - - name: deploy - run: | - ssh work@${{secrets.TECENT_SERVER}} " - cd /home/work/wangEditor-team/wangEditor; # ไบ‹ๅ…ˆ git clone ** server ๅˆ†ๆ”ฏ** - git checkout . ; # ๆธ…็ฉบๆ‰€ๆœ‰ๆ”นๅŠจ - git checkout server; # ๅˆ‡ๆขๅˆฐ server ๅˆ†ๆ”ฏ - git pull origin server; - npm i; - npm run server; # ๅฏๅŠจๆˆ–้‡ๅฏ๏ผŒไฟ่ฏๆœๅŠกๅ™จๅฎ‰่ฃ…ไบ† pm2 - echo ========= wangEditor server start success ========= - " - - name: delete ssh key # ๅˆ ้™ค ssh key - run: rm -rf ~/.ssh/id_rsa diff --git a/docs/dev.md b/docs/dev.md index 97eb18290..972819415 100644 --- a/docs/dev.md +++ b/docs/dev.md @@ -40,7 +40,6 @@ npm run start - `master` ไธปๅนฒๅˆ†ๆ”ฏ๏ผŒๅฝ“ๅ‰ๆญฃๅœจ่ฟ่กŒ็š„ไปฃ็ ใ€‚**ไธๅฏ**็›ดๆŽฅๅพ€ `master` ๆไบคไปฃ็ ใ€‚ - `dev` ๅผ€ๅ‘ๅˆ†ๆ”ฏ๏ผŒๅฝ“ๅ‰ๆญฃๅœจๅผ€ๅ‘ใ€ไฝ†ๅฐšๆœชๅ‘ๅธƒ็š„ไปฃ็ ใ€‚**ไธๅฏ**็›ดๆŽฅๅพ€ `dev` ๆไบคไปฃ็ ๏ผŒไฝ†ๅฏไปฅๅˆๅนถๅ…ถไป–ๅˆ†ๆ”ฏใ€‚ -- `server` ๅผ€ๅ‘ๅˆ†ๆ”ฏ๏ผŒ็”จไบŽ้ƒจ็ฝฒ server ็ซฏๅŠŸ่ƒฝ๏ผŒ**ไธๅฏ**็›ดๆŽฅๅพ€ `server` ๆไบคไปฃ็ ๏ผŒไฝ†ๅฏไปฅๅˆๅนถๅ…ถไป–ๅˆ†ๆ”ฏใ€‚ - `feature-xxx` ๅผ€ๅ‘ๆ–ฐๅŠŸ่ƒฝ - `fix-xxx` bug ไฟฎๅค - `hotfix-xxx` ้ซ˜ไผ˜็ดงๆ€ฅ bug ไฟฎๅค๏ผŒไฟฎๅคๅฎŒ้œ€็ดงๆ€ฅไธŠ็บฟ diff --git a/package.json b/package.json index 5128fb2cd..80ab8bcdb 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "scripts": { "dev": "cross-env NODE_ENV=development webpack --watch --config build/webpack.dev.js", "example": "cross-env PORT=8881 nodemon server/www.js", - "server": "cross-env NODE_ENV=prd_dev pm2 start server/pm2.conf.json", "build": "cross-env NODE_ENV=production webpack --config build/webpack.prod.js", "build:dev": "cross-env NODE_ENV=development webpack --config build/webpack.dev.js", "build:un-min": "cross-env NODE_ENV=production webpack --config build/webpack.un-min.prod.js", @@ -81,11 +80,8 @@ "jest": "^26.0.1", "jquery": "^3.5.1", "koa": "^2.13.0", - "koa-bodyparser": "^4.3.0", - "koa-json": "^2.0.2", "koa-logger": "^3.2.1", "koa-onerror": "^4.1.0", - "koa-router": "^9.0.1", "koa-static": "^5.0.0", "less": "^3.11.1", "less-loader": "^6.0.0", diff --git a/server/README.md b/server/README.md index a0e056c09..e82c59510 100644 --- a/server/README.md +++ b/server/README.md @@ -1,23 +1,3 @@ # ๆœๅŠก็ซฏ -ๆไพ›ๆ–‡ไปถไธŠไผ ๆŽฅๅฃ๏ผŒ็”จไบŽๆต‹่ฏ•ใ€‚ - -## ๅผ€ๅ‘็Žฏๅขƒ - -`npm start` ๆ—ถไผšๅฏๅŠจ server ๏ผŒๅนถไธ”ไพ่ต–ไบŽ koa2-static ๆฅๅฏๅŠจ examples ้กต้ข็š„้™ๆ€ๆœๅŠกใ€‚ - -## ๆต‹่ฏ•็Žฏๅขƒ - -### ๅ‘ๅธƒๅˆฐๆต‹่ฏ•ๆœบ - -ไปฃ็  push ๅˆฐ `server` ๅˆ†ๆ”ฏ๏ผŒๅณๅฏ่‡ชๅŠจๅ‘ๅธƒๅˆฐๆต‹่ฏ•ๆœบใ€‚ - -ๅ…ทไฝ“ๅฏๅ‚่€ƒ `.github/workflows/server.yml` ใ€‚ - -### ๆต‹่ฏ•ๆœบ้…็ฝฎ - -nginx ้œ€่ฆ้…็ฝฎ๏ผŒๅšๅๅ‘ไปฃ็†๏ผŒๅ‚่€ƒๆต‹่ฏ•ๆœบ `/etc/nginx/nginx.conf` -- ไปฃ็†ๆŽฅๅฃ `/api/` -- ไปฃ็†ๅ›พ็‰‡ url `/server/upload-files/` - -ๅฎšๆ—ถๅˆ ้™คๆ–‡ไปถ๏ผŒ้…็ฝฎ crontab ๅฎšๆ—ถๆ‰ง่กŒ `server/rm.sh` +`npm start` ๆ—ถไผšๅฏๅŠจ server ๏ผŒไพ่ต–ไบŽ koa2-static ๆฅๅฏๅŠจ examples ้กต้ข็š„้™ๆ€ๆœๅŠกใ€‚ diff --git a/server/controller/save-file.js b/server/controller/save-file.js deleted file mode 100644 index 780e50e47..000000000 --- a/server/controller/save-file.js +++ /dev/null @@ -1,97 +0,0 @@ -/** - * @description ไฟๅญ˜ไธŠไผ ็š„ๆ–‡ไปถ - * @author wangfupeng - */ - -const os = require('os') -const fs = require('fs') -const path = require('path') -const formidable = require('formidable') -const { objForEach } = require('../util') -const FILE_FOLDER = 'upload-files' -const isWindows = os.type().toLowerCase().indexOf('windows') >= 0 -const TMP_FOLDER = 'upload-files-tmp' - -/** - * ่Žทๅ–้šๆœบๆ•ฐ - */ -function getRandom() { - return Math.random().toString(36).slice(-3) -} - -/** - * ็ป™ๆ–‡ไปถๅๅŠ ๅŽ็ผ€๏ผŒๅฆ‚ a.png ่ฝฌๆขไธบ a-123123.png - * @param {string} fileName ๆ–‡ไปถๅ - */ -function genRandomFileName(fileName = '') { - // ๅฆ‚ fileName === 'a.123.png' - - const r = getRandom() - if (!fileName) return r - - const length = fileName.length // 9 - const pointLastIndexOf = fileName.lastIndexOf('.') // 5 - if (pointLastIndexOf < 0) return `${fileName}-${r}` - - const fileNameWithOutExt = fileName.slice(0, pointLastIndexOf) // "a.123" - const ext = fileName.slice(pointLastIndexOf + 1, length) // "png" - return `${fileNameWithOutExt}-${r}.${ext}` -} - -/** - * ไฟๅญ˜ไธŠไผ ็š„ๆ–‡ไปถ - * @param {Object} req request - */ -function saveFiles(req) { - return new Promise((resolve, reject) => { - const imgLinks = [] - const form = formidable({ multiples: true }) - - // windows ็ณป็ปŸ๏ผŒๅค„็† rename ๆŠฅ้”™ - if (isWindows) { - const tmpPath = path.resolve(__dirname, '..', '..', TMP_FOLDER) // ๅœจๆ น็›ฎๅฝ•ไธ‹ - if (!fs.existsSync(tmpPath)) { - fs.mkdirSync(tmpPath) - } - form.uploadDir = TMP_FOLDER - } - - form.parse(req, function (err, fields, files) { - if (err) { - reject('formidable, form.parse err', err.stack) - } - // ๅญ˜ๅ‚จๅ›พ็‰‡็š„ๆ–‡ไปถๅคน - const storePath = path.resolve(__dirname, '..', FILE_FOLDER) - if (!fs.existsSync(storePath)) { - fs.mkdirSync(storePath) - } - - // ้ๅŽ†ๆ‰€ๆœ‰ไธŠไผ ๆฅ็š„ๅ›พ็‰‡ - objForEach(files, (name, file) => { - console.log('name...', name) - - // ๅ›พ็‰‡ไธดๆ—ถไฝ็ฝฎ - const tempFilePath = file.path - // ๅ›พ็‰‡ๅ็งฐๅ’Œ่ทฏๅพ„ - const fileName = genRandomFileName(name) // ไธบๆ–‡ไปถๅๅขžๅŠ ไธ€ไธช้šๆœบๆ•ฐ๏ผŒ้˜ฒๆญขๅŒๅๆ–‡ไปถ่ฆ†็›– - console.log('fileName...', fileName) - const fullFileName = path.join(storePath, fileName) - console.log('fullFileName...', fullFileName) - // ๅฐ†ไธดๆ—ถๆ–‡ไปถไฟๅญ˜ไธบๆญฃๅผๆ–‡ไปถ - fs.renameSync(tempFilePath, fullFileName) - // ๅญ˜ๅ‚จ้“พๆŽฅ - const url = `/server/${FILE_FOLDER}/` + fileName - imgLinks.push({ url, alt: fileName, href: url }) - }) - console.log('imgLinks...', imgLinks) - - // ่ฟ”ๅ›ž็ป“ๆžœ - resolve({ - errno: 0, - data: imgLinks, - }) - }) - }) -} - -module.exports = saveFiles diff --git a/server/controller/saveVideo-file.js b/server/controller/saveVideo-file.js deleted file mode 100644 index ba72bd2bc..000000000 --- a/server/controller/saveVideo-file.js +++ /dev/null @@ -1,102 +0,0 @@ -/** - * @description ไฟๅญ˜ไธŠไผ ็š„ๆ–‡ไปถ - * @author wangfupeng - */ - -const os = require('os') -const fs = require('fs') -const path = require('path') -const multiparty = require('multiparty') -const { objForEach } = require('../util') -const FILE_FOLDER = 'upload-files' -const isWindows = os.type().toLowerCase().indexOf('windows') >= 0 -const TMP_FOLDER = 'upload-files-tmp' -const fse = require('fs-extra'); - -/** - * ่Žทๅ–้šๆœบๆ•ฐ - */ -function getRandom() { - return Math.random().toString(36).slice(-3) -} - -/** - * ็ป™ๆ–‡ไปถๅๅŠ ๅŽ็ผ€๏ผŒๅฆ‚ a.png ่ฝฌๆขไธบ a-123123.png - * @param {string} fileName ๆ–‡ไปถๅ - */ -function genRandomFileName(fileName = '') { - // ๅฆ‚ fileName === 'a.123.png' - - const r = getRandom() - if (!fileName) return r - - const length = fileName.length // 9 - const pointLastIndexOf = fileName.lastIndexOf('.') // 5 - if (pointLastIndexOf < 0) return `${fileName}-${r}` - - const fileNameWithOutExt = fileName.slice(0, pointLastIndexOf) // "a.123" - const ext = fileName.slice(pointLastIndexOf + 1, length) // "png" - return `${fileNameWithOutExt}-${r}.${ext}` -} - -/** - * ไฟๅญ˜ไธŠไผ ็š„ๆ–‡ไปถ - * @param {Object} req request - */ -function saveFiles(req) { - return new Promise((resolve, reject) => { - const videoLinks = [] - const multipart = new multiparty.Form(); - - // windows ็ณป็ปŸ๏ผŒๅค„็† rename ๆŠฅ้”™ - if (isWindows) { - const tmpPath = path.resolve(__dirname, '..', '..', TMP_FOLDER) // ๅœจๆ น็›ฎๅฝ•ไธ‹ - if (!fs.existsSync(tmpPath)) { - fs.mkdirSync(tmpPath) - } - - } - - multipart.parse(req, function (err, fields, files) { - if (err) { - reject('formidable, form.parse err', err.stack) - } - // ๅญ˜ๅ‚จ่ง†้ข‘็š„ๆ–‡ไปถๅคน - const storePath = path.resolve(__dirname, '..', FILE_FOLDER) - if (!fs.existsSync(storePath)) { - fs.mkdirSync(storePath) - } - - // ้ๅŽ†ๆ‰€ๆœ‰ไธŠไผ ๆฅ็š„่ง†้ข‘ - objForEach(files, async (name, file) => { - console.log('name...', name) - console.log('file.path...', file) - // ่ง†้ข‘ไธดๆ—ถไฝ็ฝฎ - const tempFilePath = file[0].path - console.log('tempFilePath...', tempFilePath) - // ่ง†้ข‘ๅ็งฐๅ’Œ่ทฏๅพ„ - const fileName = genRandomFileName(name) // ไธบๆ–‡ไปถๅๅขžๅŠ ไธ€ไธช้šๆœบๆ•ฐ๏ผŒ้˜ฒๆญขๅŒๅๆ–‡ไปถ่ฆ†็›– - console.log('fileName...', fileName) - const fullFileName = path.join(storePath, fileName) - console.log('fullFileName...', fullFileName) - // ๅฐ†ไธดๆ—ถๆ–‡ไปถไฟๅญ˜ไธบๆญฃๅผๆ–‡ไปถ - fse.moveSync(tempFilePath, fullFileName); - // ๅญ˜ๅ‚จ้“พๆŽฅ - const url = `/server/${FILE_FOLDER}/` + fileName - console.log('url...', url) - videoLinks.push(url) - }) - console.log('videoLinks...', videoLinks) - - // ่ฟ”ๅ›ž็ป“ๆžœ - resolve({ - errno: 0, - data: { - url: videoLinks[0] - }, - }) - }) - }) -} - -module.exports = saveFiles diff --git a/server/index.js b/server/index.js index c5d6c39cf..0b67667f1 100644 --- a/server/index.js +++ b/server/index.js @@ -6,24 +6,13 @@ const path = require('path') const Koa = require('koa') const app = new Koa() -const json = require('koa-json') const onerror = require('koa-onerror') -const bodyparser = require('koa-bodyparser') const logger = require('koa-logger') const koaStatic = require('koa-static') -const router = require('./router') - // error handler onerror(app) -// middlewares -app.use( - bodyparser({ - enableTypes: ['json', 'form', 'text'], - }) -) -app.use(json()) app.use(logger()) const staticPath = path.join(__dirname, '..') app.use(koaStatic(staticPath)) @@ -36,9 +25,6 @@ app.use(async (ctx, next) => { console.log(`${ctx.method} ${ctx.url} - ${ms}ms`) }) -// routes -app.use(router.routes(), router.allowedMethods()) - // error-handling app.on('error', (err, ctx) => { console.error('server error', err, ctx) diff --git a/server/pm2.conf.json b/server/pm2.conf.json deleted file mode 100644 index 1af1a7ec7..000000000 --- a/server/pm2.conf.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "apps": [ - { - "name": "wangEditor-server", - "script": "server/www.js", - "watch": false, - "instances": 1, - "error_file": "./logs/err.log", - "out_file": "./logs/out.log", - "log_date_format": "YYYY-MM-DD HH:mm:ss Z" - } - ] -} diff --git a/server/rm.sh b/server/rm.sh deleted file mode 100644 index d65f6e046..000000000 --- a/server/rm.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# ๅˆ ้™คไธŠไผ ็š„ๆ–‡ไปถ๏ผŒ็”จไบŽ crontab ่ฐƒ็”จ -# ๆฏๅคฉๅ‡Œๆ™จ 4 ็‚น่ฐƒ็”จ๏ผš`0 4 * * * /home/work/wangEditor-team/wangEditor/server/rm.sh` - -cd /home/work/wangEditor-team/wangEditor/server/upload-files # ๆต‹่ฏ•ๆœบ็š„ path -rm -rf * diff --git a/server/router.js b/server/router.js deleted file mode 100644 index c9fe31399..000000000 --- a/server/router.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @description ๆœๅŠก็ซฏ่ทฏ็”ฑ - * @author wangfupeng - */ - -const router = require('koa-router')() -const saveFiles = require('./controller/save-file') -const saveVideoFile = require('./controller/saveVideo-file') - -router.prefix('/api') - -// ๆต‹่ฏ•็”จ -router.get('/test', async function (ctx, next) { - ctx.body = 'hello test' -}) - -// ไธŠไผ ๅ›พ็‰‡ -router.post('/upload-img', async function (ctx, next) { - const data = await saveFiles(ctx.req) - ctx.body = data -}) - -// ไธŠไผ ่ง†้ข‘ -router.post('/upload-video', async function (ctx, next) { - const data = await saveVideoFile(ctx.req) - ctx.body = data -}) - -module.exports = router diff --git a/server/util.js b/server/util.js deleted file mode 100644 index bdc0237ed..000000000 --- a/server/util.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - // ้ๅŽ†ๅฏน่ฑก - objForEach: function (obj, fn) { - let key, result - for (key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - result = fn.call(obj, key, obj[key]) - if (result === false) { - break - } - } - } - }, -} From e7edde0698873ed7e728d85e1bdda69294735372 Mon Sep 17 00:00:00 2001 From: wangfupeng Date: Thu, 10 Jun 2021 15:39:52 +0800 Subject: [PATCH 10/13] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=9C=BA=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/dev.md | 2 +- docs/pub.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/dev.md b/docs/dev.md index 972819415..a257a64a7 100644 --- a/docs/dev.md +++ b/docs/dev.md @@ -105,7 +105,7 @@ npm run start ๅฝ“ๆไบคๅฎŒ่‡ชๅทฑ็š„ๅˆ†ๆ”ฏไน‹ๅŽ๏ผŒgithub actions ไผš่‡ชๅŠจ่งฆๅ‘้ƒจ็ฝฒๅˆฐ่…พ่ฎฏไบ‘ๆต‹่ฏ•ๆœบใ€‚ ๆŸฅ็œ‹ [actions ๅˆ—่กจ](https://github.com/wangeditor-team/wangEditor/actions)๏ผŒๅพ…ๆ‰€ๆœ‰ไปปๅŠก่ฟ่กŒๅฎŒๆˆไน‹ๅŽใ€‚ -ๆ‰“ๅผ€ๆต่งˆๅ™จ่ฎฟ้—ฎ `http://106.55.153.217:8881/<ไฝ ็š„ๅˆ†ๆ”ฏๅ>/examples/index.html` ๏ผŒ่ฟ™ๅฐฑๆ˜ฏไฝ ๆœฌๆฌกๅˆ†ๆ”ฏไปฃ็ ็š„่ฟœ็จ‹ๆต‹่ฏ•็Žฏๅขƒใ€‚ +ๆ‰“ๅผ€ๆต่งˆๅ™จ่ฎฟ้—ฎ `http://106.12.198.214:8881/<ไฝ ็š„ๅˆ†ๆ”ฏๅ>/examples/index.html` ๏ผŒ่ฟ™ๅฐฑๆ˜ฏไฝ ๆœฌๆฌกๅˆ†ๆ”ฏไปฃ็ ็š„่ฟœ็จ‹ๆต‹่ฏ•็Žฏๅขƒใ€‚ ่ฆไฟ่ฏ่ฟ™ไธ€ๆญฅๆˆๅŠŸ๏ผŒๅ†่ฟ›่กŒไธ‹ไธ€ๆญฅใ€‚ diff --git a/docs/pub.md b/docs/pub.md index 8cd4c95de..b00c694f6 100644 --- a/docs/pub.md +++ b/docs/pub.md @@ -66,7 +66,7 @@ ## ๅ›žๅฝ’ๆต‹่ฏ• -ๅ‘ๅธƒๅฎŒๆˆไน‹ๅŽ๏ผŒ่ฎฟ้—ฎ http://106.55.153.217:8881/publish-npm-test/ ๅณๅฏๅพ—ๅˆฐๆœ€ๆ–ฐ็‰ˆๆœฌ็š„ demo ใ€‚ +ๅ‘ๅธƒๅฎŒๆˆไน‹ๅŽ๏ผŒ่ฎฟ้—ฎ http://106.12.198.214:8881/publish-npm-test/ ๅณๅฏๅพ—ๅˆฐๆœ€ๆ–ฐ็‰ˆๆœฌ็š„ demo ใ€‚ ## ไฟฎๆ”นไปปๅŠก็Šถๆ€ From 392433727a14b153bf9219a20030a3d03fa70965 Mon Sep 17 00:00:00 2001 From: luochao <651644100@qq.com> Date: Thu, 10 Jun 2021 21:21:58 +0800 Subject: [PATCH 11/13] release: v4.7.3 --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- src/config/menus.ts | 14 ++++++-------- src/lib/simplehtmlparser.js | 3 +-- src/menus/lineHeight/index.ts | 4 ++-- src/utils/const.ts | 3 +-- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6c93a96a..46b887926 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## [4.7.3](https://github.com/wangeditor-team/wangEditor/compare/v4.7.2...v4.7.3) (2021-06-10) + + +### Bug Fixes + +* ็‰นๆฎŠๆƒ…ๅ†ตไธ‹ๆ— ๆณ•้€š่ฟ‡backspaceๅˆ ้™คๅ›พ็‰‡ ([0648a93](https://github.com/wangeditor-team/wangEditor/commit/0648a9340a7c156dbc16b83e955f684854cb8c76)) +* ไผ˜ๅŒ–็ฒ˜่ดดๆ—ถ่ฟ‡ๆปคmeta็š„่กŒไธบ ([313665c](https://github.com/wangeditor-team/wangEditor/commit/313665c5a656314477f8973e0cdff9c4ba125aeb)) + ## [4.7.2](https://github.com/wangeditor-team/wangEditor/compare/v4.7.1...v4.7.2) (2021-06-03) diff --git a/package.json b/package.json index 80ab8bcdb..222118643 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wangeditor", - "version": "4.7.2", + "version": "4.7.3", "description": "wangEditor - ่ฝป้‡็บง web ๅฏŒๆ–‡ๆœฌ็ผ–่พ‘ๅ™จ๏ผŒ้…็ฝฎๆ–นไพฟ๏ผŒไฝฟ็”จ็ฎ€ๅ•๏ผŒๅผ€ๆบๅ…่ดน", "homepage": "http://www.wangeditor.com/", "keywords": [ diff --git a/src/config/menus.ts b/src/config/menus.ts index c53c6ff5c..820e397f2 100644 --- a/src/config/menus.ts +++ b/src/config/menus.ts @@ -182,10 +182,9 @@ export default { // type -> 'emoji' / 'image' type: 'emoji', // content -> ๆ•ฐ็ป„ - content: - '๐Ÿ˜€ ๐Ÿ˜ƒ ๐Ÿ˜„ ๐Ÿ˜ ๐Ÿ˜† ๐Ÿ˜… ๐Ÿ˜‚ ๐Ÿคฃ ๐Ÿ˜Š ๐Ÿ˜‡ ๐Ÿ™‚ ๐Ÿ™ƒ ๐Ÿ˜‰ ๐Ÿ˜Œ ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜š ๐Ÿ˜‹ ๐Ÿ˜› ๐Ÿ˜ ๐Ÿ˜œ ๐Ÿค“ ๐Ÿ˜Ž ๐Ÿ˜ ๐Ÿ˜’ ๐Ÿ˜ž ๐Ÿ˜” ๐Ÿ˜Ÿ ๐Ÿ˜• ๐Ÿ™ ๐Ÿ˜ฃ ๐Ÿ˜– ๐Ÿ˜ซ ๐Ÿ˜ฉ ๐Ÿ˜ข ๐Ÿ˜ญ ๐Ÿ˜ค ๐Ÿ˜  ๐Ÿ˜ก ๐Ÿ˜ณ ๐Ÿ˜ฑ ๐Ÿ˜จ ๐Ÿค— ๐Ÿค” ๐Ÿ˜ถ ๐Ÿ˜‘ ๐Ÿ˜ฌ ๐Ÿ™„ ๐Ÿ˜ฏ ๐Ÿ˜ด ๐Ÿ˜ท ๐Ÿค‘ ๐Ÿ˜ˆ ๐Ÿคก ๐Ÿ’ฉ ๐Ÿ‘ป ๐Ÿ’€ ๐Ÿ‘€ ๐Ÿ‘ฃ'.split( - /\s/ - ), + content: '๐Ÿ˜€ ๐Ÿ˜ƒ ๐Ÿ˜„ ๐Ÿ˜ ๐Ÿ˜† ๐Ÿ˜… ๐Ÿ˜‚ ๐Ÿคฃ ๐Ÿ˜Š ๐Ÿ˜‡ ๐Ÿ™‚ ๐Ÿ™ƒ ๐Ÿ˜‰ ๐Ÿ˜Œ ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜š ๐Ÿ˜‹ ๐Ÿ˜› ๐Ÿ˜ ๐Ÿ˜œ ๐Ÿค“ ๐Ÿ˜Ž ๐Ÿ˜ ๐Ÿ˜’ ๐Ÿ˜ž ๐Ÿ˜” ๐Ÿ˜Ÿ ๐Ÿ˜• ๐Ÿ™ ๐Ÿ˜ฃ ๐Ÿ˜– ๐Ÿ˜ซ ๐Ÿ˜ฉ ๐Ÿ˜ข ๐Ÿ˜ญ ๐Ÿ˜ค ๐Ÿ˜  ๐Ÿ˜ก ๐Ÿ˜ณ ๐Ÿ˜ฑ ๐Ÿ˜จ ๐Ÿค— ๐Ÿค” ๐Ÿ˜ถ ๐Ÿ˜‘ ๐Ÿ˜ฌ ๐Ÿ™„ ๐Ÿ˜ฏ ๐Ÿ˜ด ๐Ÿ˜ท ๐Ÿค‘ ๐Ÿ˜ˆ ๐Ÿคก ๐Ÿ’ฉ ๐Ÿ‘ป ๐Ÿ’€ ๐Ÿ‘€ ๐Ÿ‘ฃ'.split( + /\s/ + ), }, { // tab ็š„ๆ ‡้ข˜ @@ -193,10 +192,9 @@ export default { // type -> 'emoji' / 'image' type: 'emoji', // content -> ๆ•ฐ็ป„ - content: - '๐Ÿ‘ ๐Ÿ™Œ ๐Ÿ‘ ๐Ÿค ๐Ÿ‘ ๐Ÿ‘Ž ๐Ÿ‘Š โœŠ ๐Ÿค› ๐Ÿคœ ๐Ÿคž โœŒ๏ธ ๐Ÿค˜ ๐Ÿ‘Œ ๐Ÿ‘ˆ ๐Ÿ‘‰ ๐Ÿ‘† ๐Ÿ‘‡ โ˜๏ธ โœ‹ ๐Ÿคš ๐Ÿ– ๐Ÿ–– ๐Ÿ‘‹ ๐Ÿค™ ๐Ÿ’ช ๐Ÿ–• โœ๏ธ ๐Ÿ™'.split( - /\s/ - ), + content: '๐Ÿ‘ ๐Ÿ™Œ ๐Ÿ‘ ๐Ÿค ๐Ÿ‘ ๐Ÿ‘Ž ๐Ÿ‘Š โœŠ ๐Ÿค› ๐Ÿคœ ๐Ÿคž โœŒ๏ธ ๐Ÿค˜ ๐Ÿ‘Œ ๐Ÿ‘ˆ ๐Ÿ‘‰ ๐Ÿ‘† ๐Ÿ‘‡ โ˜๏ธ โœ‹ ๐Ÿคš ๐Ÿ– ๐Ÿ–– ๐Ÿ‘‹ ๐Ÿค™ ๐Ÿ’ช ๐Ÿ–• โœ๏ธ ๐Ÿ™'.split( + /\s/ + ), }, ], diff --git a/src/lib/simplehtmlparser.js b/src/lib/simplehtmlparser.js index 21eb17a5a..502696297 100644 --- a/src/lib/simplehtmlparser.js +++ b/src/lib/simplehtmlparser.js @@ -61,8 +61,7 @@ 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, diff --git a/src/menus/lineHeight/index.ts b/src/menus/lineHeight/index.ts index 35e76ffad..8e780112e 100644 --- a/src/menus/lineHeight/index.ts +++ b/src/menus/lineHeight/index.ts @@ -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 | undefined = - editor.selection.getRange()?.commonAncestorContainer.childNodes + const childList: NodeListOf | 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])) { diff --git a/src/utils/const.ts b/src/utils/const.ts index 2b49406cc..2423d015a 100644 --- a/src/utils/const.ts +++ b/src/utils/const.ts @@ -6,8 +6,7 @@ export function EMPTY_FN() {} //็”จไบŽๆ ก้ชŒๆ˜ฏๅฆไธบurlๆ ผๅผๅญ—็ฌฆไธฒ -export const urlRegex = - /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/ +export const urlRegex = /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/ // ็ผ–่พ‘ๅ™จไธบไบ†ๆ–นไพฟ็ปง็ปญ่พ“ๅ…ฅ/ๆข่กŒ็ญ‰ๅŽŸๅ›  ไธปๅŠจ็”Ÿๆˆ็š„็ฉบๆ ‡็ญพ export const EMPTY_P = '


' From cebf20a79df1f979376f27eee128ae3c95a4a4eb Mon Sep 17 00:00:00 2001 From: shi-lai-mu <478889187@qq.com> Date: Sat, 5 Jun 2021 00:30:46 +0800 Subject: [PATCH 12/13] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A1=8C?= =?UTF-8?q?=E5=86=85code=E5=9B=9E=E8=BD=A6=E5=90=8E=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E5=8F=8A=E6=8F=92=E5=85=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/menus.ts | 14 ++++++++------ src/lib/simplehtmlparser.js | 3 ++- src/menus/code/bind-event/jump-code-block-down.ts | 5 +++-- src/menus/code/create-panel-conf.ts | 9 +++++---- src/menus/lineHeight/index.ts | 4 ++-- src/text/event-hooks/enter-to-create-p.ts | 15 +++++++++++++-- src/utils/const.ts | 3 ++- src/utils/dom-core.ts | 2 +- test/unit/text/enter-to-create-p.test.ts | 2 +- 9 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/config/menus.ts b/src/config/menus.ts index 820e397f2..c53c6ff5c 100644 --- a/src/config/menus.ts +++ b/src/config/menus.ts @@ -182,9 +182,10 @@ export default { // type -> 'emoji' / 'image' type: 'emoji', // content -> ๆ•ฐ็ป„ - content: '๐Ÿ˜€ ๐Ÿ˜ƒ ๐Ÿ˜„ ๐Ÿ˜ ๐Ÿ˜† ๐Ÿ˜… ๐Ÿ˜‚ ๐Ÿคฃ ๐Ÿ˜Š ๐Ÿ˜‡ ๐Ÿ™‚ ๐Ÿ™ƒ ๐Ÿ˜‰ ๐Ÿ˜Œ ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜š ๐Ÿ˜‹ ๐Ÿ˜› ๐Ÿ˜ ๐Ÿ˜œ ๐Ÿค“ ๐Ÿ˜Ž ๐Ÿ˜ ๐Ÿ˜’ ๐Ÿ˜ž ๐Ÿ˜” ๐Ÿ˜Ÿ ๐Ÿ˜• ๐Ÿ™ ๐Ÿ˜ฃ ๐Ÿ˜– ๐Ÿ˜ซ ๐Ÿ˜ฉ ๐Ÿ˜ข ๐Ÿ˜ญ ๐Ÿ˜ค ๐Ÿ˜  ๐Ÿ˜ก ๐Ÿ˜ณ ๐Ÿ˜ฑ ๐Ÿ˜จ ๐Ÿค— ๐Ÿค” ๐Ÿ˜ถ ๐Ÿ˜‘ ๐Ÿ˜ฌ ๐Ÿ™„ ๐Ÿ˜ฏ ๐Ÿ˜ด ๐Ÿ˜ท ๐Ÿค‘ ๐Ÿ˜ˆ ๐Ÿคก ๐Ÿ’ฉ ๐Ÿ‘ป ๐Ÿ’€ ๐Ÿ‘€ ๐Ÿ‘ฃ'.split( - /\s/ - ), + content: + '๐Ÿ˜€ ๐Ÿ˜ƒ ๐Ÿ˜„ ๐Ÿ˜ ๐Ÿ˜† ๐Ÿ˜… ๐Ÿ˜‚ ๐Ÿคฃ ๐Ÿ˜Š ๐Ÿ˜‡ ๐Ÿ™‚ ๐Ÿ™ƒ ๐Ÿ˜‰ ๐Ÿ˜Œ ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜š ๐Ÿ˜‹ ๐Ÿ˜› ๐Ÿ˜ ๐Ÿ˜œ ๐Ÿค“ ๐Ÿ˜Ž ๐Ÿ˜ ๐Ÿ˜’ ๐Ÿ˜ž ๐Ÿ˜” ๐Ÿ˜Ÿ ๐Ÿ˜• ๐Ÿ™ ๐Ÿ˜ฃ ๐Ÿ˜– ๐Ÿ˜ซ ๐Ÿ˜ฉ ๐Ÿ˜ข ๐Ÿ˜ญ ๐Ÿ˜ค ๐Ÿ˜  ๐Ÿ˜ก ๐Ÿ˜ณ ๐Ÿ˜ฑ ๐Ÿ˜จ ๐Ÿค— ๐Ÿค” ๐Ÿ˜ถ ๐Ÿ˜‘ ๐Ÿ˜ฌ ๐Ÿ™„ ๐Ÿ˜ฏ ๐Ÿ˜ด ๐Ÿ˜ท ๐Ÿค‘ ๐Ÿ˜ˆ ๐Ÿคก ๐Ÿ’ฉ ๐Ÿ‘ป ๐Ÿ’€ ๐Ÿ‘€ ๐Ÿ‘ฃ'.split( + /\s/ + ), }, { // tab ็š„ๆ ‡้ข˜ @@ -192,9 +193,10 @@ export default { // type -> 'emoji' / 'image' type: 'emoji', // content -> ๆ•ฐ็ป„ - content: '๐Ÿ‘ ๐Ÿ™Œ ๐Ÿ‘ ๐Ÿค ๐Ÿ‘ ๐Ÿ‘Ž ๐Ÿ‘Š โœŠ ๐Ÿค› ๐Ÿคœ ๐Ÿคž โœŒ๏ธ ๐Ÿค˜ ๐Ÿ‘Œ ๐Ÿ‘ˆ ๐Ÿ‘‰ ๐Ÿ‘† ๐Ÿ‘‡ โ˜๏ธ โœ‹ ๐Ÿคš ๐Ÿ– ๐Ÿ–– ๐Ÿ‘‹ ๐Ÿค™ ๐Ÿ’ช ๐Ÿ–• โœ๏ธ ๐Ÿ™'.split( - /\s/ - ), + content: + '๐Ÿ‘ ๐Ÿ™Œ ๐Ÿ‘ ๐Ÿค ๐Ÿ‘ ๐Ÿ‘Ž ๐Ÿ‘Š โœŠ ๐Ÿค› ๐Ÿคœ ๐Ÿคž โœŒ๏ธ ๐Ÿค˜ ๐Ÿ‘Œ ๐Ÿ‘ˆ ๐Ÿ‘‰ ๐Ÿ‘† ๐Ÿ‘‡ โ˜๏ธ โœ‹ ๐Ÿคš ๐Ÿ– ๐Ÿ–– ๐Ÿ‘‹ ๐Ÿค™ ๐Ÿ’ช ๐Ÿ–• โœ๏ธ ๐Ÿ™'.split( + /\s/ + ), }, ], diff --git a/src/lib/simplehtmlparser.js b/src/lib/simplehtmlparser.js index 502696297..21eb17a5a 100644 --- a/src/lib/simplehtmlparser.js +++ b/src/lib/simplehtmlparser.js @@ -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, diff --git a/src/menus/code/bind-event/jump-code-block-down.ts b/src/menus/code/bind-event/jump-code-block-down.ts index a1845bddd..dbb5b9ade 100644 --- a/src/menus/code/bind-event/jump-code-block-down.ts +++ b/src/menus/code/bind-event/jump-code-block-down.ts @@ -41,9 +41,10 @@ export default function bindEventJumpCodeBlock(editor: Editor) { if ($preElem.length && $preElem?.getNodeName() === 'PRE' && $nextElem.length === 0) { // ๅ…‰ๆ ‡ๅค„ไบŽ้€‰ๅŒบๅผ€ๅคด if (selection.getCursorPos() === 0) { - // ๆŒ‰ไธ‹delete้”ฎ้˜ปๆญข้ป˜่ฎค่กŒไธบ + // ๆŒ‰ไธ‹delete้”ฎๆ—ถๆœซๅฐพ่ฟฝๅŠ ็ฉบ่กŒ if (e.keyCode === 8) { - e.preventDefault() + const $emptyP = $(EMPTY_P) + $textElem.append($emptyP) } } } diff --git a/src/menus/code/create-panel-conf.ts b/src/menus/code/create-panel-conf.ts index e531ef32a..4f1b57bf0 100644 --- a/src/menus/code/create-panel-conf.ts +++ b/src/menus/code/create-panel-conf.ts @@ -17,9 +17,8 @@ export default function (editor: Editor, text: string, languageType: string): Pa const btnOkId = getRandom('btn-ok') /** - * ๆ’ๅ…ฅ้“พๆŽฅ + * ๆ’ๅ…ฅไปฃ็ ๅ— * @param text ๆ–‡ๅญ— - * @param code ้“พๆŽฅ */ function insertCode(text: string): void { // ้€‰ๅŒบๅค„ไบŽ้“พๆŽฅไธญ๏ผŒๅˆ™้€‰ไธญๆ•ดไธช่œๅ•๏ผŒๅ†ๆ‰ง่กŒ insertHTML @@ -39,8 +38,10 @@ export default function (editor: Editor, text: string, languageType: string): Pa const $codeElem = $code?.getNodeTop(editor) // ้€š่ฟ‡domๆ“ไฝœๆทปๅŠ ๆข่กŒๆ ‡็ญพ - // @ts-ignore - $(EMPTY_P).insertAfter($codeElem) + if ($codeElem?.getNextSibling().elems.length === 0) { + // @ts-ignore + $(EMPTY_P).insertAfter($codeElem) + } } /** diff --git a/src/menus/lineHeight/index.ts b/src/menus/lineHeight/index.ts index 8e780112e..35e76ffad 100644 --- a/src/menus/lineHeight/index.ts +++ b/src/menus/lineHeight/index.ts @@ -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 | undefined = editor.selection.getRange() - ?.commonAncestorContainer.childNodes + const childList: NodeListOf | 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])) { diff --git a/src/text/event-hooks/enter-to-create-p.ts b/src/text/event-hooks/enter-to-create-p.ts index b4a79223d..6173886bc 100644 --- a/src/text/event-hooks/enter-to-create-p.ts +++ b/src/text/event-hooks/enter-to-create-p.ts @@ -4,6 +4,7 @@ */ import Editor from '../../editor/index' +import { EMPTY_P } from '../../utils/const' import $, { DomElement } from '../../utils/dom-core' /** @@ -14,7 +15,7 @@ import $, { DomElement } from '../../utils/dom-core' */ function enterToCreateP(editor: Editor, enterUpEvents: Function[], enterDownEvents: Function[]) { function insertEmptyP($selectionElem: DomElement) { - const $p = $('


') + const $p = $(EMPTY_P) $p.insertBefore($selectionElem) if ($selectionElem.html().indexOf('= 0) { // ๆœ‰ๅ›พ็‰‡็š„ๅ›ž่ฝฆ้”ฎๅผน่ตทๆ—ถ @@ -36,7 +37,17 @@ function enterToCreateP(editor: Editor, enterUpEvents: Function[], enterDownEven if ($parentElem.html() === '
') { // ๅ›ž่ฝฆไน‹ๅ‰ๅ…‰ๆ ‡ๆ‰€ๅœจไธ€ไธช

.....

๏ผŒๅฟฝ็„ถๅ›ž่ฝฆ็”Ÿๆˆไธ€ไธช็ฉบ็š„


// ่€Œไธ”็ปง็ปญๅ›ž่ฝฆ่ทณไธๅ‡บๅŽป๏ผŒๅ› ๆญคๅช่ƒฝ็‰นๆฎŠๅค„็† - insertEmptyP($selectionElem) + insertEmptyP($parentElem) + return + } + + if ( + $selectionElem.getNodeName() === 'FONT' && + $selectionElem.text() === '' && + $selectionElem.attr('face') === 'monospace' + ) { + // ่กŒๅ†…codeๅ›ž่ฝฆๆ—ถไผšไบง็”Ÿไธ€ไธช
๏ผŒๅฏผ่‡ดๆ ทๅผ้—ฎ้ข˜ + insertEmptyP($parentElem) return } diff --git a/src/utils/const.ts b/src/utils/const.ts index 2423d015a..2b49406cc 100644 --- a/src/utils/const.ts +++ b/src/utils/const.ts @@ -6,7 +6,8 @@ export function EMPTY_FN() {} //็”จไบŽๆ ก้ชŒๆ˜ฏๅฆไธบurlๆ ผๅผๅญ—็ฌฆไธฒ -export const urlRegex = /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/ +export const urlRegex = + /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/ // ็ผ–่พ‘ๅ™จไธบไบ†ๆ–นไพฟ็ปง็ปญ่พ“ๅ…ฅ/ๆข่กŒ็ญ‰ๅŽŸๅ›  ไธปๅŠจ็”Ÿๆˆ็š„็ฉบๆ ‡็ญพ export const EMPTY_P = '


' diff --git a/src/utils/dom-core.ts b/src/utils/dom-core.ts index 1176c2810..a8411f780 100644 --- a/src/utils/dom-core.ts +++ b/src/utils/dom-core.ts @@ -748,7 +748,7 @@ export class DomElement { } return this.forEach(elem => { const parent = referenceNode.parentNode as Node - parent.insertBefore(elem, referenceNode) + parent?.insertBefore(elem, referenceNode) }) } diff --git a/test/unit/text/enter-to-create-p.test.ts b/test/unit/text/enter-to-create-p.test.ts index c462c6897..27b7356bb 100644 --- a/test/unit/text/enter-to-create-p.test.ts +++ b/test/unit/text/enter-to-create-p.test.ts @@ -143,7 +143,7 @@ describe('editor.text event-hooks tab-to-space test', () => { fn() }) - expect(editor.$textElem.elems[0].innerHTML.indexOf('


')).toBeGreaterThanOrEqual(0) + expect(editor.$textElem.elems[0].innerHTML.indexOf(EMPTY_P)).toBeGreaterThanOrEqual(0) }) test('ๅฝ“็ผ–่พ‘ๅ™จ้€‰ๅŒบๅ†…ๅฎน $textElm๏ผŒๆ‰ง่กŒenter down๏ผŒๆ’ๅ…ฅ


', () => { From 371d7dd45cee907b47f40ca7db9582c9f36f2fc7 Mon Sep 17 00:00:00 2001 From: luochao <651644100@qq.com> Date: Thu, 17 Jun 2021 22:13:23 +0800 Subject: [PATCH 13/13] release: v4.7.4 --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- src/config/menus.ts | 14 ++++++-------- src/lib/simplehtmlparser.js | 3 +-- src/menus/lineHeight/index.ts | 4 ++-- src/utils/const.ts | 3 +-- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46b887926..246be5711 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## [4.7.4](https://github.com/wangeditor-team/wangEditor/compare/v4.7.3...v4.7.4) (2021-06-17) + + +### Bug Fixes + +* ไฟฎๅค่กŒๅ†…codeๅ›ž่ฝฆๅŽๅฏผ่‡ดๆ ทๅผๅŠๆ’ๅ…ฅ้—ฎ้ข˜ ([cebf20a](https://github.com/wangeditor-team/wangEditor/commit/cebf20a79df1f979376f27eee128ae3c95a4a4eb)) +* ไฟฎๅคaๆ ‡็ญพๅŒ…่ฃนimg็š„ ๅ–ๆถˆ้“พๆŽฅ ้—ฎ้ข˜ ([23eb557](https://github.com/wangeditor-team/wangEditor/commit/23eb557a5dabcdc6201753695a8590dec539fe9e)) + ## [4.7.3](https://github.com/wangeditor-team/wangEditor/compare/v4.7.2...v4.7.3) (2021-06-10) diff --git a/package.json b/package.json index 222118643..30e097cc7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wangeditor", - "version": "4.7.3", + "version": "4.7.4", "description": "wangEditor - ่ฝป้‡็บง web ๅฏŒๆ–‡ๆœฌ็ผ–่พ‘ๅ™จ๏ผŒ้…็ฝฎๆ–นไพฟ๏ผŒไฝฟ็”จ็ฎ€ๅ•๏ผŒๅผ€ๆบๅ…่ดน", "homepage": "http://www.wangeditor.com/", "keywords": [ diff --git a/src/config/menus.ts b/src/config/menus.ts index c53c6ff5c..820e397f2 100644 --- a/src/config/menus.ts +++ b/src/config/menus.ts @@ -182,10 +182,9 @@ export default { // type -> 'emoji' / 'image' type: 'emoji', // content -> ๆ•ฐ็ป„ - content: - '๐Ÿ˜€ ๐Ÿ˜ƒ ๐Ÿ˜„ ๐Ÿ˜ ๐Ÿ˜† ๐Ÿ˜… ๐Ÿ˜‚ ๐Ÿคฃ ๐Ÿ˜Š ๐Ÿ˜‡ ๐Ÿ™‚ ๐Ÿ™ƒ ๐Ÿ˜‰ ๐Ÿ˜Œ ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜š ๐Ÿ˜‹ ๐Ÿ˜› ๐Ÿ˜ ๐Ÿ˜œ ๐Ÿค“ ๐Ÿ˜Ž ๐Ÿ˜ ๐Ÿ˜’ ๐Ÿ˜ž ๐Ÿ˜” ๐Ÿ˜Ÿ ๐Ÿ˜• ๐Ÿ™ ๐Ÿ˜ฃ ๐Ÿ˜– ๐Ÿ˜ซ ๐Ÿ˜ฉ ๐Ÿ˜ข ๐Ÿ˜ญ ๐Ÿ˜ค ๐Ÿ˜  ๐Ÿ˜ก ๐Ÿ˜ณ ๐Ÿ˜ฑ ๐Ÿ˜จ ๐Ÿค— ๐Ÿค” ๐Ÿ˜ถ ๐Ÿ˜‘ ๐Ÿ˜ฌ ๐Ÿ™„ ๐Ÿ˜ฏ ๐Ÿ˜ด ๐Ÿ˜ท ๐Ÿค‘ ๐Ÿ˜ˆ ๐Ÿคก ๐Ÿ’ฉ ๐Ÿ‘ป ๐Ÿ’€ ๐Ÿ‘€ ๐Ÿ‘ฃ'.split( - /\s/ - ), + content: '๐Ÿ˜€ ๐Ÿ˜ƒ ๐Ÿ˜„ ๐Ÿ˜ ๐Ÿ˜† ๐Ÿ˜… ๐Ÿ˜‚ ๐Ÿคฃ ๐Ÿ˜Š ๐Ÿ˜‡ ๐Ÿ™‚ ๐Ÿ™ƒ ๐Ÿ˜‰ ๐Ÿ˜Œ ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜š ๐Ÿ˜‹ ๐Ÿ˜› ๐Ÿ˜ ๐Ÿ˜œ ๐Ÿค“ ๐Ÿ˜Ž ๐Ÿ˜ ๐Ÿ˜’ ๐Ÿ˜ž ๐Ÿ˜” ๐Ÿ˜Ÿ ๐Ÿ˜• ๐Ÿ™ ๐Ÿ˜ฃ ๐Ÿ˜– ๐Ÿ˜ซ ๐Ÿ˜ฉ ๐Ÿ˜ข ๐Ÿ˜ญ ๐Ÿ˜ค ๐Ÿ˜  ๐Ÿ˜ก ๐Ÿ˜ณ ๐Ÿ˜ฑ ๐Ÿ˜จ ๐Ÿค— ๐Ÿค” ๐Ÿ˜ถ ๐Ÿ˜‘ ๐Ÿ˜ฌ ๐Ÿ™„ ๐Ÿ˜ฏ ๐Ÿ˜ด ๐Ÿ˜ท ๐Ÿค‘ ๐Ÿ˜ˆ ๐Ÿคก ๐Ÿ’ฉ ๐Ÿ‘ป ๐Ÿ’€ ๐Ÿ‘€ ๐Ÿ‘ฃ'.split( + /\s/ + ), }, { // tab ็š„ๆ ‡้ข˜ @@ -193,10 +192,9 @@ export default { // type -> 'emoji' / 'image' type: 'emoji', // content -> ๆ•ฐ็ป„ - content: - '๐Ÿ‘ ๐Ÿ™Œ ๐Ÿ‘ ๐Ÿค ๐Ÿ‘ ๐Ÿ‘Ž ๐Ÿ‘Š โœŠ ๐Ÿค› ๐Ÿคœ ๐Ÿคž โœŒ๏ธ ๐Ÿค˜ ๐Ÿ‘Œ ๐Ÿ‘ˆ ๐Ÿ‘‰ ๐Ÿ‘† ๐Ÿ‘‡ โ˜๏ธ โœ‹ ๐Ÿคš ๐Ÿ– ๐Ÿ–– ๐Ÿ‘‹ ๐Ÿค™ ๐Ÿ’ช ๐Ÿ–• โœ๏ธ ๐Ÿ™'.split( - /\s/ - ), + content: '๐Ÿ‘ ๐Ÿ™Œ ๐Ÿ‘ ๐Ÿค ๐Ÿ‘ ๐Ÿ‘Ž ๐Ÿ‘Š โœŠ ๐Ÿค› ๐Ÿคœ ๐Ÿคž โœŒ๏ธ ๐Ÿค˜ ๐Ÿ‘Œ ๐Ÿ‘ˆ ๐Ÿ‘‰ ๐Ÿ‘† ๐Ÿ‘‡ โ˜๏ธ โœ‹ ๐Ÿคš ๐Ÿ– ๐Ÿ–– ๐Ÿ‘‹ ๐Ÿค™ ๐Ÿ’ช ๐Ÿ–• โœ๏ธ ๐Ÿ™'.split( + /\s/ + ), }, ], diff --git a/src/lib/simplehtmlparser.js b/src/lib/simplehtmlparser.js index 21eb17a5a..502696297 100644 --- a/src/lib/simplehtmlparser.js +++ b/src/lib/simplehtmlparser.js @@ -61,8 +61,7 @@ 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, diff --git a/src/menus/lineHeight/index.ts b/src/menus/lineHeight/index.ts index 35e76ffad..8e780112e 100644 --- a/src/menus/lineHeight/index.ts +++ b/src/menus/lineHeight/index.ts @@ -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 | undefined = - editor.selection.getRange()?.commonAncestorContainer.childNodes + const childList: NodeListOf | 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])) { diff --git a/src/utils/const.ts b/src/utils/const.ts index 2b49406cc..2423d015a 100644 --- a/src/utils/const.ts +++ b/src/utils/const.ts @@ -6,8 +6,7 @@ export function EMPTY_FN() {} //็”จไบŽๆ ก้ชŒๆ˜ฏๅฆไธบurlๆ ผๅผๅญ—็ฌฆไธฒ -export const urlRegex = - /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/ +export const urlRegex = /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/ // ็ผ–่พ‘ๅ™จไธบไบ†ๆ–นไพฟ็ปง็ปญ่พ“ๅ…ฅ/ๆข่กŒ็ญ‰ๅŽŸๅ›  ไธปๅŠจ็”Ÿๆˆ็š„็ฉบๆ ‡็ญพ export const EMPTY_P = '


'