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
ff6336ef
Commit
ff6336ef
authored
Mar 28, 2025
by
pangchong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 提交上传
parent
92b01eb2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
15 deletions
+90
-15
components.d.ts
+4
-0
src/views/editor/components/ContentEditor.vue
+29
-1
src/views/editor/components/ContentTree.vue
+4
-12
src/views/editor/functions/extra-menu.ts
+44
-0
src/views/editor/functions/index.ts
+9
-2
No files found.
components.d.ts
View file @
ff6336ef
...
@@ -7,6 +7,7 @@ export {}
...
@@ -7,6 +7,7 @@ export {}
declare
module
'vue'
{
declare
module
'vue'
{
export
interface
GlobalComponents
{
export
interface
GlobalComponents
{
NButton
:
typeof
import
(
'naive-ui'
)[
'NButton'
]
NCard
:
typeof
import
(
'naive-ui'
)[
'NCard'
]
NCard
:
typeof
import
(
'naive-ui'
)[
'NCard'
]
NConfigProvider
:
typeof
import
(
'naive-ui'
)[
'NConfigProvider'
]
NConfigProvider
:
typeof
import
(
'naive-ui'
)[
'NConfigProvider'
]
NInput
:
typeof
import
(
'naive-ui'
)[
'NInput'
]
NInput
:
typeof
import
(
'naive-ui'
)[
'NInput'
]
...
@@ -15,7 +16,10 @@ declare module 'vue' {
...
@@ -15,7 +16,10 @@ declare module 'vue' {
NLayoutFooter
:
typeof
import
(
'naive-ui'
)[
'NLayoutFooter'
]
NLayoutFooter
:
typeof
import
(
'naive-ui'
)[
'NLayoutFooter'
]
NLayoutHeader
:
typeof
import
(
'naive-ui'
)[
'NLayoutHeader'
]
NLayoutHeader
:
typeof
import
(
'naive-ui'
)[
'NLayoutHeader'
]
NMessageProvider
:
typeof
import
(
'naive-ui'
)[
'NMessageProvider'
]
NMessageProvider
:
typeof
import
(
'naive-ui'
)[
'NMessageProvider'
]
NResult
:
typeof
import
(
'naive-ui'
)[
'NResult'
]
NSpace
:
typeof
import
(
'naive-ui'
)[
'NSpace'
]
NTree
:
typeof
import
(
'naive-ui'
)[
'NTree'
]
NTree
:
typeof
import
(
'naive-ui'
)[
'NTree'
]
NUpload
:
typeof
import
(
'naive-ui'
)[
'NUpload'
]
RouterLink
:
typeof
import
(
'vue-router'
)[
'RouterLink'
]
RouterLink
:
typeof
import
(
'vue-router'
)[
'RouterLink'
]
RouterView
:
typeof
import
(
'vue-router'
)[
'RouterView'
]
RouterView
:
typeof
import
(
'vue-router'
)[
'RouterView'
]
}
}
...
...
src/views/editor/components/ContentEditor.vue
View file @
ff6336ef
<
template
>
<
template
>
<div
class=
"z-10 h-full flex flex-col"
>
<div
class=
"z-10 h-full flex flex-col"
>
<!-- 工具栏 -->
<!-- 工具栏 -->
<Toolbar
:editor=
"editorRef"
:editorId=
"editorId"
class=
"border-b border-solid border-borderColor"
/>
<Toolbar
:editor=
"editorRef"
:editorId=
"editorId"
:defaultConfig=
"toolbarConfig"
class=
"border-b border-solid border-borderColor"
/>
<!-- 编辑器 -->
<!-- 编辑器 -->
<div
class=
"p-[15px] flex flex-1 overflow-hidden"
>
<div
class=
"p-[15px] flex flex-1 overflow-hidden"
>
<slot
name=
"left"
></slot>
<slot
name=
"left"
></slot>
...
@@ -28,6 +28,7 @@ import { Boot, IModuleConf } from '@wangeditor/editor'
...
@@ -28,6 +28,7 @@ import { Boot, IModuleConf } from '@wangeditor/editor'
import
renderElemConf
from
'../functions/render-elem'
import
renderElemConf
from
'../functions/render-elem'
import
elemToHtmlConf
from
'../functions/elem-to-html'
import
elemToHtmlConf
from
'../functions/elem-to-html'
import
parseHtmlConf
from
'../functions/parse-elem-html'
import
parseHtmlConf
from
'../functions/parse-elem-html'
import
myMenuConf
from
'../functions/extra-menu'
const
module
:
Partial
<
IModuleConf
>
=
{
const
module
:
Partial
<
IModuleConf
>
=
{
renderElems
:
renderElemConf
,
renderElems
:
renderElemConf
,
...
@@ -35,6 +36,33 @@ const module: Partial<IModuleConf> = {
...
@@ -35,6 +36,33 @@ const module: Partial<IModuleConf> = {
parseElemsHtml
:
parseHtmlConf
parseElemsHtml
:
parseHtmlConf
}
}
Boot
.
registerModule
(
module
)
Boot
.
registerModule
(
module
)
Boot
.
registerMenu
(
myMenuConf
)
// 注册菜单
//菜单配置
const
toolbarConfig
=
{
toolbarKeys
:
[
'headerSelect'
,
'bold'
,
'italic'
,
'underline'
,
'through'
,
'color'
,
'fontSize'
,
'lineHeight'
,
'bulletedList'
,
'numberedList'
,
'justifyLeft'
,
'justifyCenter'
,
'justifyRight'
,
'undo'
,
'redo'
,
'uploadImage'
,
'insertLink'
,
'fullScreen'
,
'clearStyle'
,
'XML'
]
}
type
InsertFnType
=
(
url
:
string
,
alt
:
string
,
href
:
string
)
=>
void
type
InsertFnType
=
(
url
:
string
,
alt
:
string
,
href
:
string
)
=>
void
const
ps
=
defineProps
({
const
ps
=
defineProps
({
...
...
src/views/editor/components/ContentTree.vue
View file @
ff6336ef
...
@@ -10,7 +10,6 @@
...
@@ -10,7 +10,6 @@
:data=
"realComposableData"
:data=
"realComposableData"
:node-props=
"nodeProps"
:node-props=
"nodeProps"
v-model:selected-keys=
"treeSelectedKeys"
v-model:selected-keys=
"treeSelectedKeys"
:render-label=
"nodeProps.renderLabel"
:pattern=
"searchKey"
:pattern=
"searchKey"
block-line
block-line
/>
/>
...
@@ -24,22 +23,15 @@ import { nodeSet } from '@/views/editor/constants/nodeParsed.ts'
...
@@ -24,22 +23,15 @@ import { nodeSet } from '@/views/editor/constants/nodeParsed.ts'
import
FileXML
from
'@/assets/file/CES-QEC-V250-A.xml?raw'
import
FileXML
from
'@/assets/file/CES-QEC-V250-A.xml?raw'
import
type
{
TreeOption
}
from
'naive-ui'
import
type
{
TreeOption
}
from
'naive-ui'
import
{
nodeProps
}
from
'../functions'
import
{
nodeProps
}
from
'../functions'
import
{
editorRef
}
from
'../constants'
const
xmlProcessing
=
useXMLProcessing
()
const
xmlProcessing
=
useXMLProcessing
()
watchEffect
(
function
()
{
console
.
log
(
'the keys'
,
treeSelectedKeys
.
value
,
editorRef
.
value
?.
editorRef
?.
getEditableContainer
())
})
const
treeRef
=
ref
()
const
treeRef
=
ref
()
const
expandedKeys
=
ref
<
string
[]
>
([])
const
expandedKeys
=
ref
<
string
[]
>
([])
onMounted
(
function
()
{
onMounted
(
function
()
{
const
res
=
xmlProcessing
.
processXML
(
FileXML
,
nodeSet
)
//
const res = xmlProcessing.processXML(FileXML, nodeSet)
treeData
.
value
=
res
.
treeData
//
treeData.value = res.treeData
xmlDOM
.
value
=
res
.
xmlDOM
//
xmlDOM.value = res.xmlDOM
xmlContent
.
value
=
res
.
xmlContent
//
xmlContent.value = res.xmlContent
})
})
function
getAllKeys
(
item
:
TreeOption
[])
{
function
getAllKeys
(
item
:
TreeOption
[])
{
...
...
src/views/editor/functions/extra-menu.ts
0 → 100644
View file @
ff6336ef
import
{
IButtonMenu
,
IDomEditor
}
from
'@wangeditor/editor'
import
{
uploadXml
}
from
'.'
class
XMLMenu
implements
IButtonMenu
{
title
:
string
tag
:
string
constructor
()
{
this
.
title
=
'上传XML'
// 自定义菜单标题
this
.
tag
=
'button'
// 菜单的标签,默认是button
}
getValue
(
editor
:
IDomEditor
):
string
|
boolean
{
// 获取菜单执行时的 value,用不到则返回空字符串或 false
return
''
}
isActive
(
editor
:
IDomEditor
):
boolean
{
// 菜单是否需要激活,用不到则返回 false
return
false
}
isDisabled
(
editor
:
IDomEditor
):
boolean
{
// 菜单是否需要禁用,用不到则返回 false
return
false
}
async
exec
(
editor
:
IDomEditor
,
value
:
string
|
boolean
)
{
// 点击菜单时触发的函数
if
(
this
.
isDisabled
(
editor
))
return
const
arrFileHandle
=
await
(
window
as
any
).
showOpenFilePicker
({
types
:
[
{
accept
:
{
'XML/*'
:
[
'.xml'
]
}
}
]
})
const
file
=
await
arrFileHandle
[
0
].
getFile
()
uploadXml
(
file
)
}
}
export
default
{
key
:
'XML'
,
// 定义 menu key,要保证唯一、不重复
factory
()
{
return
new
XMLMenu
()
// 返回定义的菜单类实例
}
}
src/views/editor/functions/index.ts
View file @
ff6336ef
import
{
IDomEditor
}
from
'@wangeditor/editor'
import
{
IDomEditor
}
from
'@wangeditor/editor'
import
{
editorRef
}
from
'../constants'
import
{
editorRef
,
treeData
,
xmlContent
,
xmlDOM
}
from
'../constants'
import
{
TreeOption
}
from
'naive-ui'
import
{
TreeOption
}
from
'naive-ui'
import
{
nodeSet
}
from
'../constants/nodeParsed'
export
const
handleEditor
=
(
editor
:
IDomEditor
)
=>
{
export
const
handleEditor
=
(
editor
:
IDomEditor
)
=>
{
// console.log(editor.getElemsByTypePrefix('JOBCARD'))
// console.log(editor.getElemsByTypePrefix('JOBCARD'))
// console.log(editor)
// console.log(editor)
// const headers = editor.getElemsByTypePrefix('header')
// const headers = editor.getElemsByTypePrefix('header')
...
@@ -34,3 +34,10 @@ export const nodeProps = ({ option }: { option: TreeOption }) => {
...
@@ -34,3 +34,10 @@ export const nodeProps = ({ option }: { option: TreeOption }) => {
}
}
}
}
}
}
const
xmlProcessing
=
useXMLProcessing
()
export
const
uploadXml
=
async
(
file
:
File
)
=>
{
const
res
=
await
xmlProcessing
.
processFile
(
file
,
nodeSet
)
treeData
.
value
=
res
.
treeData
xmlDOM
.
value
=
res
.
xmlDOM
xmlContent
.
value
=
res
.
xmlContent
}
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