@automattic/rtjson-to-wpblocks
Version:
Javascript code to convert Day One RTJson to WordPress Gutenberg Blocks
124 lines (106 loc) • 2.41 kB
TypeScript
declare namespace RTJ {
namespace RTJEmbeddedObject {
type Photo = {
type: "photo";
identifier: string;
};
type Audio = {
type: "audio";
identifier: string;
};
type Video = {
type: "video";
identifier: string;
};
type PDFAttachment = {
type: "pdfAttachment";
identifier: string;
};
type ExternalVideo = {
type: "externalVideo";
url: string;
};
type ExternalAudio = {
type: "externalAudio";
url: string;
};
type RenderableCodeBlock = {
type: "renderableCodeBlock";
contents: string;
};
type HorizontalRuleLine = {
type: "horizontalRuleLine";
};
type DayOneEntry = {
type: "dayOneEntry";
entryID: string;
journalID?: string;
};
type Preview = {
type: "preview";
identifier: string;
};
}
type RTJEmbeddedObject =
| RTJEmbeddedObject.Audio
| RTJEmbeddedObject.Photo
| RTJEmbeddedObject.Video
| RTJEmbeddedObject.PDFAttachment
| RTJEmbeddedObject.ExternalVideo
| RTJEmbeddedObject.ExternalAudio
| RTJEmbeddedObject.RenderableCodeBlock
| RTJEmbeddedObject.HorizontalRuleLine
| RTJEmbeddedObject.DayOneEntry
| RTJEmbeddedObject.Preview;
type TextNodeAttributes = {
bold?: boolean;
italic?: boolean;
highlightedColor?: string;
inlineCode?: boolean;
strikethrough?: boolean;
linkURL?: string;
autolink?: boolean;
cursorPlacement?: number;
pageLink?: boolean;
line?: {
header?: number;
listStyle?: "bulleted" | "numbered" | "checkbox";
checked?: boolean;
listIndex?: number;
indentLevel?: number;
quote?: boolean;
codeBlock?: boolean;
identifier?: string;
};
};
type TextNode = {
text: string;
attributes?: TextNodeAttributes;
};
type EmbeddedContentNode = {
embeddedObjects: Array<RTJEmbeddedObject>;
};
type Node = TextNode | EmbeddedContentNode;
type Document = {
contents: Array<Node>;
meta?: {
version: 1;
created: {
version: number;
platform: string;
};
"small-lines-removed": boolean;
};
};
}
type RTJNode = RTJ.Node;
type RTJDoc = RTJ.Document;
type MediaLookup = {
[key: string]: {
id?: number;
url: string;
};
};
interface String {
fixWhitespace(): string;
}