Commit 69ed1919 by pangchong

feat: 对比

parent 52be4051
...@@ -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}>`
} }
} }
......
...@@ -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
} }
......
...@@ -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
......
...@@ -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%;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment