mirror of
https://github.com/idrawjs/idraw
synced 2026-05-24 10:08:34 +00:00
feat: implement @idraw/core is and check static attributes
This commit is contained in:
parent
1f4ea809e1
commit
a8b54bf34d
3 changed files with 12 additions and 9 deletions
|
|
@ -1,6 +1,10 @@
|
|||
export const elementTypes = {
|
||||
'text': true,
|
||||
'rect': true,
|
||||
'image': true,
|
||||
'svg': true,
|
||||
}
|
||||
|
||||
const elementTypes = {
|
||||
'text': {}, // TODO
|
||||
'rect': {}, // TODO
|
||||
'image': {}, // TODO
|
||||
'svg': {}, // TODO
|
||||
}
|
||||
|
||||
export const elementNames = Object.keys(elementTypes);
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ function fontFamily(value: any) {
|
|||
return typeof value === 'string' && value.length > 0;
|
||||
}
|
||||
|
||||
|
||||
const is = {
|
||||
x, y, w, h, angle, number,
|
||||
borderWidth, borderRadius, color,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { TypeData, TypeElement, TypeElemDesc } from '@idraw/types';
|
||||
import { elementTypes } from './../constant/element';
|
||||
import { elementNames } from './../constant/element';
|
||||
|
||||
export function parseData(data: any): TypeData {
|
||||
const result: TypeData = {
|
||||
|
|
@ -24,7 +24,7 @@ function isElement(
|
|||
if (!(isNumber(elem.x) && isNumber(elem.y) && isNumber(elem.w) && isNumber(elem.h))) {
|
||||
return false;
|
||||
}
|
||||
if (!(typeof elem.type === 'string' && Object.keys(elementTypes).includes(elem.type))) {
|
||||
if (!(typeof elem.type === 'string' && elementNames.includes(elem.type))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue