feat:rich text editor by canvas

This commit is contained in:
黄云飞
2021-11-12 22:22:05 +08:00
commit 2739d4069f
36 changed files with 1251 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
import { ZERO } from "../dataset/constant/Common"
export function debounce(func: Function, delay: number) {
let timer: number
return function (...args: any) {
if (timer) clearTimeout(timer)
timer = setTimeout(() => {
// @ts-ignore
func.apply(this, args)
}, delay)
}
}
export function writeText(text: string) {
if (!text) return
window.navigator.clipboard.writeText(text.replaceAll(ZERO, `\n`))
}
export function deepClone(obj: any) {
if (!obj || typeof obj !== 'object') {
return obj;
}
let newObj: any = {};
if (Array.isArray(obj)) {
newObj = obj.map(item => deepClone(item));
} else {
Object.keys(obj).forEach((key) => {
return newObj[key] = deepClone(obj[key]);
})
}
return newObj;
}