-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
292 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
docs/zh/api/components/extends/editor/components/fs-editor-wang5/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# FsEditorWang5 | ||
|
||
> wangEditor5 组件封装 | ||
> 文档:https://www.wangeditor.com/v5/for-frame.html#使用-1 | ||
## Props | ||
|
||
| Prop name | Description | Type | Values | Default | | ||
| ------------- | ---------------------------------------------------------------------------- | ------- | ------ | ------- | | ||
| container | 容器配置<br/>包装 editor 和 toolbar 的外部容器配置,可以设置 class,style 等 | object | - | | | ||
| mode | editor 的模式 | string | - | | | ||
| toolbarConfig | 工具条配置 | object | - | | | ||
| editorConfig | 编辑器默认配置 | object | - | | | ||
| uploader | uploader 参数<br/>配置则开启上传 | object | - | | | ||
| readonly | 只读 | boolean | - | | | ||
| disabled | 是否禁用 | boolean | - | | | ||
|
||
--- |
17 changes: 17 additions & 0 deletions
17
docs/zh/api/components/extends/time/components/fs-time-humanize.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# FsTimeHumanize | ||
|
||
> 日期人性化格式展示组件 | ||
> 例如几天前,几分钟前,几个小时前 | ||
## Props | ||
|
||
| Prop name | Description | Type | Values | Default | | ||
| ---------------- | ------------------------------------------------------------------------- | ------------------------------- | ------ | ---------------------------------- | | ||
| modelValue | 日期时间值,支持 long,string,date 等,由 dayjs 转化 | undefined | - | undefined | | ||
| valueFormat | 输入格式化,不传则由 dayjs 自动转化 | string | - | undefined | | ||
| format | 日期输出格式化 | string | - | "YYYY-MM-DD HH:mm:ss" | | ||
| useFormatGreater | 距离时间超过多少毫秒时,直接使用 format 格式,默认大于 3 天后 | number | - | 1000 _ 60 _ 60 _ 24 _ 3 | | ||
| options | HumanizeDuration 参数<br/>https://github.com/EvanHahn/HumanizeDuration.js | HumanizerOptions | - | function() {<br/> return {};<br/>} | | ||
| text | 前后文本 | { prev: string; after: string } | - | function() {<br/> return {};<br/>} | | ||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule fs-admin-antdv
updated
4 files
+1 −1 | src/main.ts | |
+6 −2 | src/plugin/fast-crud/index.ts | |
+13 −45 | src/views/crud/component/editor/crud.jsx | |
+3 −1 | src/views/crud/component/uploader/form/crud.jsx |
Submodule fs-admin-naive-ui
updated
2 files
+1 −1 | src/views/crud/component/editor/crud.jsx | |
+27 −0 | src/views/crud/component/select/crud.jsx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
222 changes: 222 additions & 0 deletions
222
packages/fast-extends/src/editor/components/fs-editor-wang5/index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
<template> | ||
<div class="fs-editor-wang5" v-bind="container"> | ||
<Toolbar | ||
style="border-bottom: 1px solid #ccc" | ||
:ref="toolbarRef" | ||
:editor="editorRef" | ||
:defaultConfig="toolbarConfig" | ||
:mode="mode" | ||
/> | ||
<Editor | ||
style="height: 500px; overflow-y: hidden;" | ||
:defaultConfig="editorConfig" | ||
:mode="mode" | ||
@onCreated="handleCreated" | ||
v-bind="$attrs" | ||
/> | ||
<fs-uploader ref="uploaderImplRef" :type="uploader?.type" /> | ||
</div> | ||
</template> | ||
<script lang="ts"> | ||
import '@wangeditor/editor/dist/css/style.css' // 引入 css | ||
import { onBeforeUnmount,defineComponent, ref, shallowRef, onMounted,watch,computed } from 'vue' | ||
import { Editor, Toolbar } from '@wangeditor/editor-for-vue' | ||
import defaultConfig from "../../type/config"; | ||
import _ from "lodash-es"; | ||
type InsertFnType = (url: string, alt?: string, href?: string) => void | ||
/** | ||
* wangEditor5组件封装 | ||
* 文档:https://www.wangeditor.com/v5/for-frame.html#使用-1 | ||
*/ | ||
export default defineComponent({ | ||
components: { Editor, Toolbar }, | ||
name: "FsEditorWang5", | ||
inheritAttrs: false, | ||
props: { | ||
/** | ||
* 容器配置 | ||
* 包装editor和toolbar的外部容器配置,可以设置class,style等 | ||
*/ | ||
container:{ | ||
type:Object | ||
}, | ||
/** | ||
* editor的模式 | ||
*/ | ||
mode:{ | ||
type:String | ||
}, | ||
/** | ||
* 工具条配置 | ||
*/ | ||
toolbarConfig: { | ||
type: Object | ||
}, | ||
/** | ||
* 编辑器默认配置 | ||
*/ | ||
editorConfig:{ | ||
type: Object | ||
}, | ||
/** | ||
* uploader参数 | ||
* 配置则开启上传 | ||
*/ | ||
uploader: { | ||
type: Object | ||
}, | ||
/** | ||
* 只读 | ||
*/ | ||
readonly:{ | ||
type: Boolean | ||
}, | ||
/** | ||
* 是否禁用 | ||
*/ | ||
disabled: { | ||
type: Boolean | ||
} | ||
}, | ||
setup(props:any){ | ||
// 编辑器实例,必须用 shallowRef | ||
const editorRef = shallowRef() | ||
const toolbarRef = ref() | ||
const uploaderImplRef = ref() | ||
const valueHtml = ref('') | ||
function toggleEnabled(value){ | ||
if(!editorRef.value){ | ||
return | ||
} | ||
if(value){ | ||
editorRef.value.enable() | ||
}else{ | ||
editorRef.value.disable() | ||
} | ||
} | ||
watch(()=>{ | ||
return props.readonly | ||
},(value)=>{ | ||
toggleEnabled(!value) | ||
},{ | ||
immediate: true | ||
}) | ||
watch(()=>{ | ||
return props.disabled | ||
},(value)=>{ | ||
toggleEnabled(!value) | ||
},{ | ||
immediate: true | ||
}) | ||
const toolbarConfig = computed(()=>{ | ||
return _.merge({ },defaultConfig.wangEditor5.toolbarConfig,props.toolbarConfig) | ||
}) | ||
const MENU_CONF:any = {} | ||
if (props.uploader) { | ||
async function doUpload(option) { | ||
option.options = props.uploader; | ||
let uploaderRef = uploaderImplRef.value.getUploaderRef(); | ||
if (uploaderRef == null) { | ||
throw new Error("Sorry,The component is not ready yet"); | ||
} | ||
return await uploaderRef?.upload(option); | ||
} | ||
MENU_CONF.uploadImage = { | ||
async customUpload(file: File, insertFn: InsertFnType) { // TS 语法 | ||
// async customUpload(file, insertFn) { // JS 语法 | ||
// file 即选中的文件 | ||
// 自己实现上传,并得到图片 url alt href | ||
// 最后插入图片 | ||
const item:any = { | ||
status: "uploading", | ||
progress: 0, | ||
message:undefined | ||
}; | ||
const onProgress = (e) => { | ||
item.progress = e.percent; | ||
}; | ||
const onError = (e) => { | ||
item.status = "error"; | ||
item.message = "文件上传出错:" + e.message; | ||
console.error(item.message, e); | ||
}; | ||
const option = { | ||
file: file, | ||
fileName: file.name, | ||
onProgress, | ||
onError | ||
}; | ||
|
||
const res = await doUpload(option); | ||
let url = res?.url; | ||
if (props.uploader?.buildUrl) { | ||
url = await props.uploader.buildUrl(res); | ||
} | ||
// 上传图片,返回结果,将图片插入到编辑器中 | ||
insertFn(url) | ||
} | ||
}; | ||
} | ||
|
||
|
||
const editorConfig = computed(()=>{ | ||
return _.merge({ | ||
placeholder: '请输入内容...', | ||
MENU_CONF | ||
},defaultConfig.wangEditor5.editorConfig,props.editorConfig) | ||
}) | ||
|
||
|
||
|
||
// 组件销毁时,也及时销毁编辑器 | ||
onBeforeUnmount(() => { | ||
const editor = editorRef.value | ||
if (editor == null) return | ||
editor.destroy() | ||
}) | ||
|
||
const handleCreated = (editor) => { | ||
editorRef.value = editor // 记录 editor 实例,重要! | ||
} | ||
|
||
function getEditorRef(){ | ||
return editorRef | ||
} | ||
function getToolRef(){ | ||
return toolbarRef | ||
} | ||
|
||
|
||
|
||
return { | ||
uploaderImplRef, | ||
getToolRef, | ||
getEditorRef, | ||
toolbarRef, | ||
editorRef, | ||
valueHtml, | ||
toolbarConfig, | ||
editorConfig, | ||
handleCreated | ||
}; | ||
}, | ||
}); | ||
</script> | ||
<style lang="less"> | ||
.fs-editor-wang5 { | ||
border:1px solid #eee; | ||
.w-e-full-screen-container{ | ||
z-index: 20; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export default { | ||
wangEditor: {}, | ||
quillEditor: {} | ||
wangEditor5:{editorConfig:{},toolbarConfig:{}}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.