Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
374721fa
Commit
374721fa
authored
Jan 27, 2022
by
boojack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: memo formater
parent
076c42d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
Memo.tsx
web/src/components/Memo.tsx
+5
-5
MemoEditor.tsx
web/src/components/MemoEditor.tsx
+2
-0
No files found.
web/src/components/Memo.tsx
View file @
374721fa
...
@@ -146,6 +146,11 @@ export function formatMemoContent(content: string) {
...
@@ -146,6 +146,11 @@ export function formatMemoContent(content: string) {
content
=
content
.
replace
(
IMAGE_URL_REG
,
""
);
content
=
content
.
replace
(
IMAGE_URL_REG
,
""
);
}
}
content
=
content
.
replace
(
TAG_REG
,
"<span class='tag-span'>#$1</span>"
)
.
replace
(
LINK_REG
,
"<a class='link' target='_blank' rel='noreferrer' href='$1'>$1</a>"
)
.
replace
(
MEMO_LINK_REG
,
"<span class='memo-link-text' data-value='$2'>$1</span>"
);
// 中英文之间加空格
// 中英文之间加空格
if
(
shouldSplitMemoWord
)
{
if
(
shouldSplitMemoWord
)
{
content
=
content
content
=
content
...
@@ -153,11 +158,6 @@ export function formatMemoContent(content: string) {
...
@@ -153,11 +158,6 @@ export function formatMemoContent(content: string) {
.
replace
(
/
([
A-Za-z0-9?.,;[
\]]
+
)([\u
4e00-
\u
9fa5
])
/g
,
"$1 $2"
);
.
replace
(
/
([
A-Za-z0-9?.,;[
\]]
+
)([\u
4e00-
\u
9fa5
])
/g
,
"$1 $2"
);
}
}
content
=
content
.
replace
(
TAG_REG
,
"<span class='tag-span'>#$1</span>"
)
.
replace
(
LINK_REG
,
"<a class='link' target='_blank' rel='noreferrer' href='$1'>$1</a>"
)
.
replace
(
MEMO_LINK_REG
,
"<span class='memo-link-text' data-value='$2'>$1</span>"
);
const
tempDivContainer
=
document
.
createElement
(
"div"
);
const
tempDivContainer
=
document
.
createElement
(
"div"
);
tempDivContainer
.
innerHTML
=
content
;
tempDivContainer
.
innerHTML
=
content
;
for
(
let
i
=
0
;
i
<
tempDivContainer
.
children
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
tempDivContainer
.
children
.
length
;
i
++
)
{
...
...
web/src/components/MemoEditor.tsx
View file @
374721fa
...
@@ -116,6 +116,8 @@ const MemoEditor: React.FC<Props> = () => {
...
@@ -116,6 +116,8 @@ const MemoEditor: React.FC<Props> = () => {
return
()
=>
{
return
()
=>
{
editorRef
.
current
?.
element
.
removeEventListener
(
"paste"
,
handlePasteEvent
);
editorRef
.
current
?.
element
.
removeEventListener
(
"paste"
,
handlePasteEvent
);
editorRef
.
current
?.
element
.
removeEventListener
(
"drop"
,
handleDropEvent
);
editorRef
.
current
?.
element
.
removeEventListener
(
"drop"
,
handleDropEvent
);
editorRef
.
current
?.
element
.
removeEventListener
(
"click"
,
handleClickEvent
);
editorRef
.
current
?.
element
.
removeEventListener
(
"keydown"
,
handleKeyDownEvent
);
};
};
},
[]);
},
[]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment