// flynt-disable field-lower-snake-case
// flynt-disable missing-array-limits
// flynt-disable missing-deprecated-field-annotation
// flynt-disable missing-entity-id-field
// flynt-disable missing-string-validations
// flynt-disable unsigned-integers-not-allowed

/**
* This schema defines a rich content object as used in the Ricos project https://github.com/wix/ricos
* The content is defined in the RichContent message.
* The content's structure is fundamentally a tree of nodes that represent rich text and content blocks.
* Some nodes are basic rich text nodes (like paragraph, heading and list), other more complex nodes are
* ricos plugins that allow creating rich content blocks (like image, giphy and poll).
*/

syntax = "proto3";

package wix.rich_content.v1;
option java_package = "wix.rich_content.v1";

import "wix/api/entity.proto";
import "wix/api/annotations.proto";
import "wix/api/validations.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
import "wix/rich_content/v1/struct.proto";
import "wix/rich_content/v1/decoration_anchor.proto";
import "wix/rich_content/v1/decoration_color.proto";
import "wix/rich_content/v1/decoration_link.proto";
import "wix/rich_content/v1/decoration_mention.proto";
import "wix/rich_content/v1/decoration_spoiler.proto";
import "wix/rich_content/v1/node_caption.proto";
import "wix/rich_content/v1/node_code_block.proto";
import "wix/rich_content/v1/node_heading.proto";
import "wix/rich_content/v1/node_paragraph.proto";
import "wix/rich_content/v1/node_layout.proto";
import "wix/rich_content/v1/node_layout_cell.proto";
import "wix/rich_content/v1/plugin_button.proto";
import "wix/rich_content/v1/plugin_divider.proto";
import "wix/rich_content/v1/plugin_file.proto";
import "wix/rich_content/v1/plugin_gallery.proto";
import "wix/rich_content/v1/plugin_gif.proto";
import "wix/rich_content/v1/plugin_html.proto";
import "wix/rich_content/v1/plugin_image.proto";
import "wix/rich_content/v1/plugin_link_preview.proto";
import "wix/rich_content/v1/plugin_map.proto";
import "wix/rich_content/v1/plugin_poll.proto";
import "wix/rich_content/v1/plugin_app_embed.proto";
import "wix/rich_content/v1/plugin_video.proto";
import "wix/rich_content/v1/plugin_collapsible_list.proto";
import "wix/rich_content/v1/plugin_embed.proto";
import "wix/rich_content/v1/plugin_table.proto";
import "wix/rich_content/v1/plugin_table_cell.proto";
import "wix/rich_content/v1/decoration_fontsize.proto";
import "wix/rich_content/v1/plugin_audio.proto";
import "wix/rich_content/v1/node_list.proto";
import "wix/rich_content/v1/node_blockquote.proto";

message RichContent {
    option (wix.api.entity) = {
        fqdn: "wix.ricos.v1.rich_content",
        segment: PUBLIC
    };
    repeated Node nodes = 1; // Node objects representing a rich content document.
    Metadata metadata = 2; // Object metadata.
    DocumentStyle document_style = 3; // Global styling for header, paragraph, block quote, and code block nodes in the object.
}

message Node {
    enum Type {
        PARAGRAPH = 0;
        TEXT = 1;
        HEADING = 2;
        BULLETED_LIST = 3;
        ORDERED_LIST = 4;
        LIST_ITEM = 5;
        BLOCKQUOTE = 6;
        CODE_BLOCK = 7;
        VIDEO = 8;
        DIVIDER = 9;
        FILE = 10;
        GALLERY = 11;
        GIF = 12;
        HTML = 13;
        IMAGE = 14;
        LINK_PREVIEW = 15;
        // @deprecated
        MAP = 16;
        POLL = 17;
        APP_EMBED = 18;
        BUTTON = 19;
        COLLAPSIBLE_LIST = 20;
        TABLE = 21;
        EMBED = 22;
        COLLAPSIBLE_ITEM = 23;
        COLLAPSIBLE_ITEM_TITLE = 24;
        COLLAPSIBLE_ITEM_BODY = 25;
        TABLE_CELL = 26;
        TABLE_ROW = 27;
        EXTERNAL = 28;
        AUDIO = 29;
        CAPTION = 30;
        LAYOUT = 31;
        LAYOUT_CELL = 32;
    }

    Type type = 1; // Node type. Use `APP_EMBED` for nodes that embed content from other Wix apps. Use `EMBED` to embed content in [oEmbed](https://oembed.com/) format.
    string id = 2; // Node ID.
    repeated Node nodes = 3; // A list of child nodes.
    NodeStyle style = 4; // Padding and background color styling for the node.
    oneof data {
        ButtonData button_data = 5; // Data for a button node.
        CodeBlockData code_block_data = 6; // Data for a code block node.
        DividerData divider_data = 7; // Data for a divider node.
        FileData file_data = 8; // Data for a file node.
        GalleryData gallery_data = 9; // Data for a gallery node.
        GIFData gif_data = 10; // Data for a GIF node.
        HeadingData heading_data = 11; // Data for a heading node.
        HTMLData html_data = 12; // Data for an embedded HTML node.
        ImageData image_data = 13; // Data for an image node.
        LinkPreviewData link_preview_data = 14; // Data for a link preview node.
        MapData map_data = 15 [deprecated = true];
        ParagraphData paragraph_data = 16; // Data for a paragraph node.
        PollData poll_data = 17; // Data for a poll node.
        TextData text_data = 18; // Data for a text node. Used to apply decorations to text.
        AppEmbedData app_embed_data = 19; // Data for an app embed node.
        VideoData video_data = 20; // Data for a video node.
        EmbedData embed_data = 21; // Data for an oEmbed node.
        CollapsibleListData collapsible_list_data = 22; // Data for a collapsible list node.
        TableData table_data = 23; // Data for a table node.
        TableCellData table_cell_data = 24; // Data for a table cell node.
        Struct externalData = 25; // Data for a custom external node.
        AudioData audio_data = 26; // Data for an audio node.
        OrderedListData ordered_list_data = 27; // Data for an ordered list node.
        BulletedListData bulleted_list_data = 28; // Data for a bulleted list node.
        BlockquoteData blockquote_data = 29; // Data for a block quote node.
        CaptionData caption_data = 30; // Data for a caption node.
        LayoutData layout_data = 31; // Data for a layout node. Reserved for future use.
        LayoutCellData layout_cell_data = 32; // Data for a cell node.
    }
}

message NodeStyle {
    google.protobuf.StringValue padding_top = 1; // The top padding value in pixels.
    google.protobuf.StringValue padding_bottom = 2; // The bottom padding value in pixels.
    google.protobuf.StringValue background_color = 3; // The background color as a hexadecimal value.
}

message TextData {
    string text = 1; // The text to apply decorations to.
    repeated Decoration decorations = 2; // The decorations to apply.
}
// Adds appearence changes to text
message Decoration {
    enum Type {
        BOLD = 0;
        ITALIC = 1;
        UNDERLINE = 2;
        SPOILER = 3;
        ANCHOR = 4;
        MENTION = 5;
        LINK = 6;
        COLOR = 7;
        FONT_SIZE = 8;
        EXTERNAL = 9;
        STRIKETHROUGH = 10;
        SUPERSCRIPT = 11;
        SUBSCRIPT = 12;
    }

    Type type = 1; // The type of decoration to apply.
    oneof data {
        AnchorData anchor_data = 2; // Data for an anchor link decoration.
        ColorData color_data = 3; // Data for a color decoration.
        LinkData link_data = 4; // Data for an external link decoration.
        MentionData mention_data = 5; // Data for a mention decoration.
        FontSizeData font_size_data = 6; // Data for a font size decoration.
        google.protobuf.Int32Value font_weight_value = 7; // Font weight for a bold decoration.
        google.protobuf.BoolValue italic_data = 8; // Data for an italic decoration. Defaults to `true`.
        google.protobuf.BoolValue underline_data = 9; // Data for an underline decoration. Defaults to `true`.
        SpoilerData spoiler_data = 10; // Data for a spoiler decoration.
        google.protobuf.BoolValue strikethrough_data = 11; // Data for a strikethrough decoration. Defaults to `true`.
        google.protobuf.BoolValue superscript_data = 12; // Data for a superscript decoration. Defaults to `true`.
        google.protobuf.BoolValue subscript_data = 13; // Data for a subscript decoration. Defaults to `true`.
    }
}

message Metadata {
    int32 version = 1 [(wix.api.min) = 0]; // Schema version.
    google.protobuf.Timestamp created_timestamp = 2 [deprecated = true, (wix.api.field_deprecated) = {}, (wix.api.readOnly) = true]; // When the object was created.
    google.protobuf.Timestamp updated_timestamp = 3 [deprecated = true, (wix.api.field_deprecated) = {}]; // When the object was most recently updated.
    google.protobuf.StringValue id = 4; // Object ID.
}

message TextNodeStyle {
    repeated Decoration decorations = 1; // The decorations to apply to the node.
    NodeStyle node_style = 2; // Padding and background color for the node.
    google.protobuf.StringValue line_height = 3; // Line height for text in the node.

}

message DocumentStyle {
    TextNodeStyle header_one = 1; // Styling for H1 nodes.
    TextNodeStyle header_two = 2; // Styling for H2 nodes.
    TextNodeStyle header_three = 3; // Styling for H3 nodes.
    TextNodeStyle header_four = 4; // Styling for H4 nodes.
    TextNodeStyle header_five = 5; // Styling for H5 nodes.
    TextNodeStyle header_six = 6; // Styling for H6 nodes.
    TextNodeStyle paragraph = 7; // Styling for paragraph nodes.
    TextNodeStyle blockquote = 8; // Styling for block quote nodes.
    TextNodeStyle code_block = 9; // Styling for code block nodes.
}

