2019-05-02 23:38:46 +02:00
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
|
|
*/
|
|
|
|
|
2020-02-11 19:47:36 +01:00
|
|
|
import { ExpressionAstExpression } from 'src/plugins/expressions';
|
2019-09-09 20:11:20 +02:00
|
|
|
import { CanvasElement } from '.';
|
2019-08-15 01:31:37 +02:00
|
|
|
|
2019-07-10 17:02:35 +02:00
|
|
|
export interface ElementSpec {
|
|
|
|
name: string;
|
2020-04-23 06:06:49 +02:00
|
|
|
icon?: string;
|
2019-07-10 17:02:35 +02:00
|
|
|
expression: string;
|
|
|
|
displayName?: string;
|
2020-04-23 06:06:49 +02:00
|
|
|
type?: string;
|
2019-07-10 17:02:35 +02:00
|
|
|
help?: string;
|
|
|
|
filter?: string;
|
|
|
|
width?: number;
|
|
|
|
height?: number;
|
|
|
|
}
|
2019-05-02 23:38:46 +02:00
|
|
|
|
2019-07-10 17:02:35 +02:00
|
|
|
export type ElementFactory = () => ElementSpec;
|
|
|
|
|
|
|
|
export interface CustomElement {
|
|
|
|
/**
|
|
|
|
* unique ID for the custom element
|
|
|
|
*/
|
|
|
|
id: string;
|
2019-05-02 23:38:46 +02:00
|
|
|
/**
|
2019-07-10 17:02:35 +02:00
|
|
|
* name of the custom element
|
2019-05-02 23:38:46 +02:00
|
|
|
*/
|
2019-07-10 17:02:35 +02:00
|
|
|
name: string;
|
2019-05-02 23:38:46 +02:00
|
|
|
/**
|
2019-07-10 17:02:35 +02:00
|
|
|
* name to be displayed from element picker
|
2019-05-02 23:38:46 +02:00
|
|
|
*/
|
2019-07-10 17:02:35 +02:00
|
|
|
displayName: string;
|
2019-05-02 23:38:46 +02:00
|
|
|
/**
|
2019-07-10 17:02:35 +02:00
|
|
|
* description of the custom element
|
2019-05-02 23:38:46 +02:00
|
|
|
*/
|
2019-07-10 17:02:35 +02:00
|
|
|
help?: string;
|
|
|
|
/**
|
|
|
|
* base 64 data URL string of the preview image
|
|
|
|
*/
|
|
|
|
image?: string;
|
|
|
|
/**
|
|
|
|
* the element object stringified
|
|
|
|
*/
|
|
|
|
content: string;
|
|
|
|
}
|
|
|
|
|
2019-07-26 20:37:15 +02:00
|
|
|
export interface ElementPosition {
|
2019-05-02 23:38:46 +02:00
|
|
|
/**
|
|
|
|
* distance from the left edge of the page
|
|
|
|
*/
|
|
|
|
left: number;
|
|
|
|
/**
|
|
|
|
* distance from the top edge of the page
|
|
|
|
* */
|
|
|
|
top: number;
|
|
|
|
/**
|
|
|
|
* width of the element
|
|
|
|
*/
|
|
|
|
width: number;
|
|
|
|
/**
|
|
|
|
* height of the element
|
|
|
|
*/
|
|
|
|
height: number;
|
|
|
|
/**
|
|
|
|
* angle of rotation
|
|
|
|
*/
|
|
|
|
angle: number;
|
|
|
|
/**
|
|
|
|
* the id of the parent of this element part of a group
|
|
|
|
*/
|
|
|
|
parent: string | null;
|
|
|
|
}
|
|
|
|
|
2020-04-30 23:51:24 +02:00
|
|
|
export type PositionedElement = CanvasElement & {
|
|
|
|
ast: ExpressionAstExpression;
|
|
|
|
} & {
|
|
|
|
position: ElementPosition;
|
|
|
|
};
|