Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue3_onlineEditor
Overview
Overview
Details
Activity
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
pangchong
vue3_onlineEditor
Commits
69ed1919
Commit
69ed1919
authored
Apr 15, 2025
by
pangchong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 对比
parent
52be4051
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
3 deletions
+19
-3
src/configs/elem-to-html.ts
+2
-0
src/configs/parse-elem-html.ts
+3
-1
src/configs/render-elem.ts
+3
-2
src/views/editor/components/Compare.vue
+11
-0
No files found.
src/configs/elem-to-html.ts
View file @
69ed1919
...
@@ -4,9 +4,11 @@ import { nodeSet } from '@/configs/node.config'
...
@@ -4,9 +4,11 @@ import { nodeSet } from '@/configs/node.config'
const
elemToHtml
=
(
type
:
string
)
=>
{
const
elemToHtml
=
(
type
:
string
)
=>
{
return
(
elem
:
SlateElement
,
childrenHtml
:
string
):
string
=>
{
return
(
elem
:
SlateElement
,
childrenHtml
:
string
):
string
=>
{
const
dataKey
=
(
elem
as
any
).
dataKey
||
''
const
dataKey
=
(
elem
as
any
).
dataKey
||
''
const
modifyType
=
(
elem
as
any
).
modifyType
||
''
return
`<
${
type
}
return
`<
${
type
}
data-w-e-type="
${
type
}
"
data-w-e-type="
${
type
}
"
data-key="
${
dataKey
}
"
data-key="
${
dataKey
}
"
data-modify-type="
${
modifyType
}
"
>
${
childrenHtml
}
</
${
type
}
>`
>
${
childrenHtml
}
</
${
type
}
>`
}
}
}
}
...
...
src/configs/parse-elem-html.ts
View file @
69ed1919
...
@@ -5,11 +5,13 @@ const parseElemHtml = (type: string) => {
...
@@ -5,11 +5,13 @@ const parseElemHtml = (type: string) => {
return
(
domElem
:
Element
,
children
:
SlateDescendant
[],
editor
:
IDomEditor
):
SlateElement
=>
{
return
(
domElem
:
Element
,
children
:
SlateDescendant
[],
editor
:
IDomEditor
):
SlateElement
=>
{
const
dataKey
=
domElem
.
getAttribute
(
'data-key'
)
||
''
const
dataKey
=
domElem
.
getAttribute
(
'data-key'
)
||
''
const
dataIndent
=
domElem
.
getAttribute
(
'data-indent-level'
)
||
''
const
dataIndent
=
domElem
.
getAttribute
(
'data-indent-level'
)
||
''
const
modifyType
=
domElem
.
getAttribute
(
'data-modify-type'
)
||
''
const
myResume
=
{
const
myResume
=
{
type
,
type
,
dataKey
,
dataKey
,
children
,
children
,
dataIndent
dataIndent
,
modifyType
}
}
return
myResume
return
myResume
}
}
...
...
src/configs/render-elem.ts
View file @
69ed1919
...
@@ -6,6 +6,7 @@ import { handleClickDom } from '@/views/editor/functions/compare'
...
@@ -6,6 +6,7 @@ import { handleClickDom } from '@/views/editor/functions/compare'
const
renderElem
=
(
type
:
string
,
style
=
{
display
:
'block'
})
=>
{
const
renderElem
=
(
type
:
string
,
style
=
{
display
:
'block'
})
=>
{
return
(
elem
:
SlateElement
,
children
:
VNode
[]
|
null
,
editor
:
IDomEditor
):
VNode
=>
{
return
(
elem
:
SlateElement
,
children
:
VNode
[]
|
null
,
editor
:
IDomEditor
):
VNode
=>
{
const
dataKey
=
(
elem
as
any
).
dataKey
const
dataKey
=
(
elem
as
any
).
dataKey
const
modifyType
=
(
elem
as
any
).
modifyType
Object
.
assign
(
style
,
{
Object
.
assign
(
style
,
{
// @ts-ignore
// @ts-ignore
textIndent
:
Number
(
elem
.
dataIndent
)
*
5
+
'px'
textIndent
:
Number
(
elem
.
dataIndent
)
*
5
+
'px'
...
@@ -14,11 +15,11 @@ const renderElem = (type: string, style = { display: 'block' }) => {
...
@@ -14,11 +15,11 @@ const renderElem = (type: string, style = { display: 'block' }) => {
type
,
type
,
{
{
style
,
style
,
attrs
:
{
'data-key'
:
dataKey
},
attrs
:
{
'data-key'
:
dataKey
,
'data-modify-type'
:
modifyType
},
on
:
{
on
:
{
click
(
event
:
Event
)
{
click
(
event
:
Event
)
{
handleClickDom
(
event
)
handleClickDom
(
event
)
}
,
}
}
}
},
},
children
children
...
...
src/views/editor/components/Compare.vue
View file @
69ed1919
...
@@ -31,6 +31,17 @@
...
@@ -31,6 +31,17 @@
import
{
showCompare
,
compareLeftRef
,
compareRightRef
,
compareContainerRef
,
chooseRowRef
,
compareData
}
from
'../constants/compare'
import
{
showCompare
,
compareLeftRef
,
compareRightRef
,
compareContainerRef
,
chooseRowRef
,
compareData
}
from
'../constants/compare'
import
{
handleScrollTopLeft
,
handleScrollTopRight
}
from
'../functions/compare'
import
{
handleScrollTopLeft
,
handleScrollTopRight
}
from
'../functions/compare'
</
script
>
</
script
>
<
style
lang=
"less"
>
[
data-modify-type
=
'removed'
]
{
background-color
:
red
;
}
[
data-modify-type
=
'added'
]
{
background-color
:
blue
;
}
[
data-modify-type
=
'placeholder'
]
{
visibility
:
hidden
;
}
</
style
>
<
style
lang=
"less"
scoped
>
<
style
lang=
"less"
scoped
>
.choose-row
{
.choose-row
{
width
:
100%
;
width
:
100%
;
...
...
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