@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
49 lines (48 loc) • 1.41 kB
TypeScript
import { Mark, MarkSpec } from 'prosemirror-model';
/**
* This annotation is purely for reference, & does _nothing_ given annotating
* `minLength` on an array of strings is not supported with our schema+spec
* generator.
*
* We're keeping it to signal that data consumer `sources` shouldn't be empty
* strings
*
* // @minLength 1
*/
declare type DataConsumerSource = string;
export interface DataConsumerAttributes {
/**
* @minItems 1
*/
sources: Array<DataConsumerSource>;
}
/**
* @name dataConsumer_mark
* @description This mark is used for metadata surrounding a node consuming data
* from a given source node
*/
export interface DataConsumerDefinition {
type: 'dataConsumer';
attrs: DataConsumerAttributes;
}
export interface DataConsumerMark extends Mark {
attrs: DataConsumerAttributes;
}
export declare const dataConsumer: MarkSpec;
/**
* We want to ensure any "invalid ADF" doesn't get serialised, but the entire
* mark itself is not valid without a non-empty `sources`.
*
* We _almost could_ simply return `null` if sources length is < 0 & would fit
* the type signature of prosemirror-model's `fragment` but not `mark`'s toJSON.
*
* So we'll leave any extra transformation checks in
* `editor-json-transformer`(?)
*/
export declare const toJSON: (mark: Mark) => {
type: string;
attrs: {
[key: string]: any;
};
};
export {};