/*! * Copyright 2022, Staffbase GmbH and contributors. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { BlockFactory } from "./block-factory"; import { JSONSchema7 } from "json-schema"; import { UiSchema } from "@rjsf/utils"; export interface BlockDefinition { /** * The tag name of the widget. It must be compatible with * webcomponent naming conventions. * * @see https://www.webcomponents.org/community/articles/how-should-i-name-my-element */ name: string; /** * The implementation of the web component. */ factory: Factory; /** * Can be used for extending from a built-in element. */ options?: ElementDefinitionOptions; /** * DOM attributes of the element, must be in kebab-case. */ attributes: string[]; /** * Set to `inline` if you want the element to behave like a span element * rather than a div element if not specified, it defaults to `block`. */ blockLevel?: "block" | "inline"; /** * Schema used for defining the configuration form. * * @example * ```json * { * "type": "object", * "required": [ * "firstName", * "lastName" * ], * "properties": { * "firstName": { * "type": "string", * "title": "First name" * }, * "lastName": { * "type": "string", * "title": "Last name" * } * } * } * ``` * @see https://react-jsonschema-form.readthedocs.io/en/latest/ */ configurationSchema: JSONSchema7; /** * * Schema to add more customization to the look and feel of the configuration form. * * ```json * { * "firstName": { * "ui:help": "Your first name." * } * } * ``` * * @see https://react-jsonschema-form.readthedocs.io/en/latest/api-reference/uiSchema/ */ uiSchema?: UiSchema; /** * Label displayed in the settings dialog and in the default widget preview. */ label?: string; /** * Icon displayed on the widget installation page. * We recommend an icon with the dimensions 32x32 px. */ iconUrl?: string; }