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
3966aafd
Commit
3966aafd
authored
Apr 25, 2025
by
pangchong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 菜单节点显示当前文本内容
parent
50f71beb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
2 deletions
+73
-2
src/views/editor/components/Tree.vue
+3
-2
src/views/editor/functions/index.ts
+10
-0
src/views/editor/functions/tree.ts
+18
-0
src/views/editor/index.vue
+42
-0
No files found.
src/views/editor/components/Tree.vue
View file @
3966aafd
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
:node-props=
"nodeProps"
:node-props=
"nodeProps"
v-model:selected-keys=
"treeSelectedKeys"
v-model:selected-keys=
"treeSelectedKeys"
:pattern=
"searchKey"
:pattern=
"searchKey"
:render-label=
"renderLabel"
block-line
block-line
block-node
block-node
/>
/>
...
@@ -20,7 +21,7 @@
...
@@ -20,7 +21,7 @@
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
treeSelectedKeys
,
treeRef
,
searchKey
,
expandedKeys
,
treeData
}
from
'../constants/tree'
import
{
treeSelectedKeys
,
treeRef
,
searchKey
,
expandedKeys
,
treeData
}
from
'../constants/tree'
import
{
buildFilteredTree
,
getAllKeys
,
nodeProps
}
from
'../functions/tree'
import
{
buildFilteredTree
,
getAllKeys
,
nodeProps
,
renderLabel
}
from
'../functions/tree'
const
realComposableData
=
computed
(
function
()
{
const
realComposableData
=
computed
(
function
()
{
if
(
!
searchKey
.
value
)
{
if
(
!
searchKey
.
value
)
{
...
@@ -44,6 +45,6 @@ watch(
...
@@ -44,6 +45,6 @@ watch(
<
style
lang=
"less"
scoped
>
<
style
lang=
"less"
scoped
>
:deep
(
.n-tree
.n-tree-node-content
.n-tree-node-content__text
)
{
:deep
(
.n-tree
.n-tree-node-content
.n-tree-node-content__text
)
{
white-space
:
nowrap
;
white-space
:
nowrap
;
display
:
flex
;
display
:
inline-
flex
;
}
}
</
style
>
</
style
>
src/views/editor/functions/index.ts
View file @
3966aafd
...
@@ -46,6 +46,16 @@ export const getKey = (elem: any): string => {
...
@@ -46,6 +46,16 @@ export const getKey = (elem: any): string => {
}
}
// 右键
// 右键
export
const
handleContextMenu
=
(
event
:
MouseEvent
)
=>
{
export
const
handleContextMenu
=
(
event
:
MouseEvent
)
=>
{
const
dom
=
event
.
target
as
HTMLElement
//递归获取父节点,直到父节点是nodeSet中的数据
let
parent
=
dom
.
parentElement
while
(
parent
)
{
if
(
nodeSet
.
includes
(
parent
.
tagName
as
string
))
{
break
}
parent
=
parent
.
parentElement
}
console
.
log
(
parent
)
dropdownConfig
.
show
=
false
dropdownConfig
.
show
=
false
nextTick
(()
=>
{
nextTick
(()
=>
{
dropdownConfig
.
show
=
true
dropdownConfig
.
show
=
true
...
...
src/views/editor/functions/tree.ts
View file @
3966aafd
...
@@ -2,7 +2,25 @@ import { TreeRenderResult } from '@/lib/XMLProcessor/src/typing'
...
@@ -2,7 +2,25 @@ import { TreeRenderResult } from '@/lib/XMLProcessor/src/typing'
import
{
setEditorActive
}
from
'.'
import
{
setEditorActive
}
from
'.'
import
{
editorRef
}
from
'../constants'
import
{
editorRef
}
from
'../constants'
import
{
TreeOption
}
from
'naive-ui'
import
{
TreeOption
}
from
'naive-ui'
import
{
contentHoldNode
}
from
'@/configs/node.config'
export
const
renderLabel
=
({
option
}:
{
option
:
TreeOption
})
=>
{
const
container
=
editorRef
.
value
?.
getEditableContainer
()
const
dom
=
container
!
.
querySelector
(
`[data-key="
${
option
.
key
}
"]`
)
as
HTMLElement
if
(
contentHoldNode
.
includes
(
dom
.
tagName
as
string
))
{
return
{
default
:
()
=>
{
return
[
h
(
'span'
,
{},
option
.
label
),
h
(
'span'
,
{
class
:
'text-textColorDisabled ml-[5px]'
},
dom
.
innerText
)]
}
}
}
else
{
return
{
default
:
()
=>
{
return
option
.
label
}
}
}
}
//点击节点
//点击节点
export
const
nodeProps
=
({
option
}:
{
option
:
TreeOption
})
=>
{
export
const
nodeProps
=
({
option
}:
{
option
:
TreeOption
})
=>
{
return
{
return
{
...
...
src/views/editor/index.vue
View file @
3966aafd
...
@@ -65,5 +65,47 @@ onBeforeUnmount(() => {
...
@@ -65,5 +65,47 @@ onBeforeUnmount(() => {
// 销毁,并移除 editor
// 销毁,并移除 editor
editor
?.
destroy
()
editor
?.
destroy
()
})
})
/*
* PRETOPIC
* 序号1,2
*/
/*
* LIST1->L1ITEM
* 序号A,B
*/
/*
* LIST2->L2ITEM
* 序号(1),(2)
*/
/*
* LIST3->L3ITEM
* 序号(a),(b)
*/
/*
* TABLE
* TGROUP
* THEAD->ROW->ENTRY
* TBODY->ROW->ENTRY
*/
/*
* UNLIST->UNLITEM
* 无序列表
*/
/*
* TOPIC
* 序号1,2
*/
/*
* SUBTASK
* 序号A,B
*/
</
script
>
</
script
>
<
style
src=
"@wangeditor/editor/dist/css/style.css"
></
style
>
<
style
src=
"@wangeditor/editor/dist/css/style.css"
></
style
>
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