fix: select index and element-type

This commit is contained in:
chenshenhai 2021-08-06 11:31:06 +08:00
parent 78de5c5487
commit b35b7b0d1a
3 changed files with 19 additions and 6 deletions

View file

@ -1,7 +1,8 @@
# @idraw/core
* [] BUG: Type error about keyof TypeElemDesc
* [] BUG: Type error about TypeElement'uuid
* [] add type of TypeElemDesc-key
* [x] BUG: Type error about keyof TypeElemDesc
* [x] BUG: Type error about TypeElement'uuid
* [] Element default data
* [] Support gradient color
* [] Listen keyboard action

View file

@ -33,7 +33,7 @@ export class Element {
const ctx = this._ctx;
let idx = -1;
let uuid = null;
for (let i = 0; i < data.elements.length; i++) {
for (let i = data.elements.length - 1; i >= 0; i--) {
const ele = data.elements[i];
let bw = 0;
// @ts-ignore

View file

@ -8,15 +8,15 @@ type TypeElementAttrs = {
angle: number;
}
type TypeElementBase <T extends keyof TypeElemDesc> = TypeElementAttrs & {
type TypeElementBase <T extends keyof TypeElemDesc | TypeElemType> = TypeElementAttrs & {
name?: string;
uuid?: string;
type: T;
type: T | TypeElemType;
lock?: boolean;
desc: TypeElemDesc[T];
}
type TypeElement<T extends keyof TypeElemDesc> = TypeElementBase<T> & {
type TypeElement<T extends keyof TypeElemDesc | TypeElemType> = TypeElementBase<T> & {
uuid: string;
}
@ -36,6 +36,17 @@ type TypeElemDesc = {
// paint: TypeElemDescPaint,
}
// enum TypeElemType {
// text = 'text',
// rect = 'rect',
// circle = 'circle',
// image = 'image',
// svg = 'svg',
// html = 'html',
// }
type TypeElemType = 'text' | 'rect' | 'circle' | 'image' | 'svg' | 'html';
type TypeElemDescRect = {
color?: string;
} & TypeElemBoxDesc
@ -77,6 +88,7 @@ export {
TypeElemDescImage,
TypeElemDescSVG,
TypeElemDesc,
TypeElemType,
TypeElement,
TypeElementBase,
};