doctypes

package
v0.2.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 3 Imported by: 0

README

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ListNumber     = "number"
	ListBullet     = "bullet"
	ListCheckBox   = "checkBox"
	ListCheckedBox = "checkedBox"
	ListCode       = "code"
)

Functions

This section is empty.

Types

type AttachmentType

type AttachmentType = string
var (
	AttachmentImage AttachmentType = "doc_image"
	AttachmentFile  AttachmentType = "doc_file"
)

type BitableViewType

type BitableViewType = string
var (
	BitableViewGrid   BitableViewType = "grid"
	BitableViewKanban BitableViewType = "kanban"
)

type Block

type Block struct {
	Type           string               `json:"type"`
	Paragraph      *BlockParagraph      `json:"paragraph,omitempty"`
	HorizontalLine *BlockHorizontalLine `json:"horizontalLine,omitempty"`
	EmbeddedPage   *BlockEmbeddedPage   `json:"embeddedPage,omitempty"`
	ChatGroup      *BlockChatGroup      `json:"chatGroup,omitempty"`
	Table          *BlockTable          `json:"table,omitempty"`
	Sheet          *BlockSheet          `json:"sheet,omitempty"`
	Diagram        *BlockDiagram        `json:"diagram,omitempty"`
	Jira           *BlockJira           `json:"jira,omitempty"`
	Poll           *BlockPoll           `json:"poll,omitempty"`
	Bitable        *BlockBitable        `json:"bitable,omitempty"`
	UndefinedBlock *BlockUndefined      `json:"undefined_block,omitempty"`
	Gallery        *BlockGallery        `json:"gallery,omitempty"`
	Callout        *BlockCallout        `json:"callout,omitempty"`
	DocsApp        *BlockDocsApp        `json:"docsApp,omitempty"`
}

Block ...

type BlockBitable

type BlockBitable struct {
	Token    string          `json:"token"`
	ViewType BitableViewType `json:"viewType"`
	LocationEmbed
}

func NewBlockBitable

func NewBlockBitable(token string, viewType BitableViewType) *BlockBitable

NewBlockBitable for new bitable block @param: token represent a bitable docs token NOTE: if token is empty create a new bitable block, if token is not empty create a bitable copy from the existed bitable.

func (*BlockBitable) ToBlocks

func (b *BlockBitable) ToBlocks() []*Block

type BlockCallout

type BlockCallout struct {
	CalloutEmojiID         string           `json:"calloutEmojiId"`
	CalloutBackgroundColor *ColorRGBA       `json:"calloutBackgroundColor"`
	CalloutBorderColor     *ColorRGBA       `json:"calloutBorderColor"`
	CalloutTextColor       *ColorRGBA       `json:"calloutTextColor"`
	Body                   BlockCalloutBody `json:"body"`
	ZoneId                 string           `json:"zoneId"`
	LocationEmbed
}

BlockCallout ...

func NewBlockCallout

func NewBlockCallout(callout *BlockCallout) *BlockCallout

func (*BlockCallout) ToBlocks

func (b *BlockCallout) ToBlocks() []*Block

type BlockCalloutBody

type BlockCalloutBody struct {
	Blocks []*Block `json:"blocks"`
}

BlockCallout ...

type BlockChatGroup

type BlockChatGroup struct {
	OpenChatID string `json:"openChatId"`
	LocationEmbed
}

BlockChatGroup ...

func NewBlockChatGroup

func NewBlockChatGroup(openChatID string) *BlockChatGroup

NewBlockChatGroup @param: openChatID represent a open id for a chat, normally start with 'oc'

func (*BlockChatGroup) ToBlocks

func (c *BlockChatGroup) ToBlocks() []*Block

type BlockDiagram

type BlockDiagram struct {
	Token       string `json:"token"`
	DiagramType string `json:"diagramType"`
	LocationEmbed
}

type BlockDocsApp

type BlockDocsApp struct {
	TypeID     string `json:"typeId"`
	InstanceID string `json:"instanceID"`
}

BlockDocsApp ...

func (*BlockDocsApp) ToBlocks

func (b *BlockDocsApp) ToBlocks() []*Block

type BlockEmbeddedPage

type BlockEmbeddedPage struct {
	Type   EmbedType `json:"type"`
	URL    string    `json:"url"`
	Width  float64   `json:"width"`
	Height float64   `json:"height"`
	LocationEmbed
}

BlockEmbeddedPage represent a block which embedded a website page

func NewBlockEmbeddedPage

func NewBlockEmbeddedPage(embedType EmbedType, pageurl string) *BlockEmbeddedPage

NewBlockEmbeddedPage ...

func (*BlockEmbeddedPage) ToBlocks

func (e *BlockEmbeddedPage) ToBlocks() []*Block

func (*BlockEmbeddedPage) WidthAndHeight

func (e *BlockEmbeddedPage) WidthAndHeight(width, height float64) *BlockEmbeddedPage

WidthAndHeight for set width or height for the embedded website page

type BlockGallery

type BlockGallery struct {
	GalleryStyle GalleryStyle `json:"galleryStyle"`
	ImageList    []ImageItem  `json:"imageList"`
	LocationEmbed
}

func (*BlockGallery) ToBlocks

func (g *BlockGallery) ToBlocks() []*Block

type BlockHorizontalLine

type BlockHorizontalLine struct {
	LocationEmbed
}

BlockHorizontalLine ...

func NewBlockHorizontalLine

func NewBlockHorizontalLine() *BlockHorizontalLine

NewBlockHorizontalLine ...

func (*BlockHorizontalLine) ToBlocks

func (h *BlockHorizontalLine) ToBlocks() []*Block

type BlockJira

type BlockJira struct {
	Token     string `json:"token"`
	BlockType string `json:"block_type"`
	LocationEmbed
}

type BlockParagraph

type BlockParagraph struct {
	ParagraphStyle ParagraphStyle      `json:"style"`    // 段落样式
	Elements       []*ParagraphElement `json:"elements"` // 段落元素
	LocationEmbed
}

Paragraph represent a doc paragraph

func NewBlockParagraph

func NewBlockParagraph(elements ...IElement) *BlockParagraph

func NewBlockParagraphWithTextRun

func NewBlockParagraphWithTextRun(text string) *BlockParagraph

func (*BlockParagraph) Align

func (*BlockParagraph) HeadingLevel

func (p *BlockParagraph) HeadingLevel(level ParagraphHeadineLevel) *BlockParagraph

HeadingLevel represent heading level style

func (*BlockParagraph) List

func (p *BlockParagraph) List(l *List) *BlockParagraph

List ...

func (*BlockParagraph) SetQuote

func (p *BlockParagraph) SetQuote() *BlockParagraph

func (*BlockParagraph) ToBlocks

func (p *BlockParagraph) ToBlocks() []*Block

type BlockPoll

type BlockPoll struct {
	Token string `json:"token"`
	LocationEmbed
}

type BlockSheet

type BlockSheet struct {
	Token      string `json:"token"`
	RowSize    int    `json:"rowSize"`
	ColumnSize int    `json:"columnSize"`
	LocationEmbed
}

BlockSheet represent a sheet block

func NewBlockSheet

func NewBlockSheet(token string, rowSize, colSize int) *BlockSheet

NewBlockSheet represent create a sheet block @params: token represent a sheet docs token. NOTE: if token is empty, create a new sheet block, if token is not empty create a sheet block copy from the existed sheet.

func (*BlockSheet) ToBlocks

func (s *BlockSheet) ToBlocks() []*Block

type BlockTable

type BlockTable struct {
	TableID    string       `json:"tableId"`
	RowSize    int          `json:"rowSize"`
	ColumnSize int          `json:"columnSize"`
	TableRows  []*TableRow  `json:"tableRows"`
	TableStyle *TableStyle  `json:"tableStyle"`
	MergeCells []*MergeCell `json:"mergeCells"`
	LocationEmbed
}

BlockTable ...

func NewBlockTable

func NewBlockTable(rowSize, colSize int) *BlockTable

NewBlockTable represent create a table block

func (*BlockTable) MergedCell

func (t *BlockTable) MergedCell(rowStartIndex, rowEndIndex, colStartIndex, colEndIndex int) *BlockTable

MergedCell represent create a merged cell, can call the function many times to create more merged cell

func (*BlockTable) Rows

func (t *BlockTable) Rows(rows []*TableRow) *BlockTable

Rows represent add rows for table []*TableRow create by NewTableRows

func (*BlockTable) StyleWith

func (t *BlockTable) StyleWith(width int) *BlockTable

StyleWith represent set width of columns

func (*BlockTable) ToBlocks

func (t *BlockTable) ToBlocks() []*Block

type BlockUndefined

type BlockUndefined struct {
	LocationEmbed
}

type Blocks

type Blocks []*Block

func NewBlockCode

func NewBlockCode(codes []string) Blocks

func NewBlocksList

func NewBlocksList(listType ListType, list []*IndentList) Blocks

func (Blocks) ToBlocks

func (b Blocks) ToBlocks() []*Block

type Body

type Body struct {
	Blocks     []*Block    `json:"blocks,omitempty"`
	Attachment interface{} `json:"attachment,omitempty"`
}

func NewBody

func NewBody(blocks ...IBlocks) *Body

NewBody create a doc body

type ColorRGBA

type ColorRGBA struct {
	Red   uint8   `json:"red"`
	Green uint8   `json:"green"`
	Blue  uint8   `json:"blue"`
	Alpha float64 `json:"alpha"`
}

ColorRGBA

type DocsLink struct {
	URL string `json:"url"`
	LocationEmbed
}
func NewElementDocsLink(url string) *DocsLink

func (*DocsLink) ToElement

func (d *DocsLink) ToElement() *ParagraphElement

type ElementFile

type ElementFile struct {
	FileToken string       `json:"fileToken"`
	ViewType  FileViewType `json:"viewType"`
	FileName  string       `json:"fileName"`
	Location  *Location    `json:"location,omitempty"`
}

func NewElementFileByToken

func NewElementFileByToken(token string, viewType FileViewType) *ElementFile

func (*ElementFile) ToElement

func (f *ElementFile) ToElement() *ParagraphElement

type EmbedType

type EmbedType = string
var (
	EmbedBilibili EmbedType = "bilibili"
	EmbedXigua    EmbedType = "xigua"
	EmbedYouku    EmbedType = "youku"
	EmbedAirtable EmbedType = "airtable"
	EmbedBaiduMap EmbedType = "baidumap"
)

type Equation

type Equation struct {
	Equation string `json:"equation"`
	LocationEmbed
}

func NewElementEquation

func NewElementEquation(equation string) *Equation

func (*Equation) ToElement

func (e *Equation) ToElement() *ParagraphElement

type FileViewType

type FileViewType = string
var (
	FileViewPreview FileViewType = "preview"
	FileViewCard    FileViewType = "card"
	FileViewInline  FileViewType = "inline"
)

type GalleryStyle

type GalleryStyle struct {
	Align string `json:"align"`
}

type IBlocks

type IBlocks interface {
	//ToBlock() *Block
	ToBlocks() []*Block
}

type IElement

type IElement interface {
	ToElement() *ParagraphElement
}

type ImageItem

type ImageItem struct {
	FileToken string `json:"fileToken"`
}

type IndentList

type IndentList struct {
	Text  string
	Ident int // [1,16]
}
type Link struct {
	URL string `json:"url"`
}
func NewElementLink(url string) *Link

type List

type List struct {
	Type        string `json:"type"`
	IndentLevel int    `json:"indentLevel"`
	Number      int    `json:"number"`
}

TODO: Laily

type ListType

type ListType = string

type Location

type Location struct {
	ZoneID     string `json:"zoneID"`
	StartIndex int    `json:"startIndex"`
	EndIndex   int    `json:"endIndex"`
}

type LocationEmbed

type LocationEmbed struct {
	Location *Location `json:"location,omitempty"`
}

type MergeCell

type MergeCell struct {
	MergeCellID      string `json:"mergeCellId"`
	RowStartIndex    int    `json:"rowStartIndex"`
	RowEndIndex      int    `json:"rowEndIndex"`
	ColumnStartIndex int    `json:"columnStartIndex"`
	ColumnEndIndex   int    `json:"columnEndIndex"`
}

MergeCell represent a merged cell

type ParagraphAlignType

type ParagraphAlignType = string
var (
	ParagraphAlignLeft   ParagraphAlignType = "left"
	ParagraphAlignRight  ParagraphAlignType = "right"
	ParagraphAlignCenter ParagraphAlignType = "center"
)

type ParagraphElement

type ParagraphElement struct {
	Type      string       `json:"type"`
	TextRun   *TextRun     `json:"textRun,omitempty"`
	DocsLink  *DocsLink    `json:"docsLink,omitempty"`
	Person    *Person      `json:"person,omitempty"`
	Equation  *Equation    `json:"equation,omitempty"`
	Reminider *Reminder    `json:"reminder,omitempty"`
	File      *ElementFile `json:"file,omitempty"`
}

ParagraphElement ...

type ParagraphHeadineLevel

type ParagraphHeadineLevel = int

ParagraphHeadineLevel represent paragraph style heading level Doc: https://open.feishu.cn/document/ukTMukTMukTM/ukDM2YjL5AjN24SOwYjN#4b468696

var (
	ParagraphHeadineLevel1 ParagraphHeadineLevel = 1
	ParagraphHeadineLevel2 ParagraphHeadineLevel = 2
	ParagraphHeadineLevel3 ParagraphHeadineLevel = 3
	ParagraphHeadineLevel4 ParagraphHeadineLevel = 4
	ParagraphHeadineLevel5 ParagraphHeadineLevel = 5
	ParagraphHeadineLevel6 ParagraphHeadineLevel = 6
	ParagraphHeadineLevel7 ParagraphHeadineLevel = 7
	ParagraphHeadineLevel8 ParagraphHeadineLevel = 8
	ParagraphHeadineLevel9 ParagraphHeadineLevel = 9
)

type ParagraphStyle

type ParagraphStyle struct {
	HeadingLevel ParagraphHeadineLevel `json:"headingLevel,omitempty"`
	List         *List                 `json:"list"`
	Quote        bool                  `json:"quote"`
	Align        ParagraphAlignType    `json:"align"`
}

type Person

type Person struct {
	OpenID string `json:"openId"`
	LocationEmbed
}

func NewElementPerson

func NewElementPerson(openID string) *Person

func (*Person) ToElement

func (p *Person) ToElement() *ParagraphElement

type Reminder

type Reminder struct {
	IsWholeDay   bool  `json:"isWholeDay"`
	Timestamp    int64 `json:"timestamp"`
	ShouldNotify bool  `json:"shouldNotify"`
	NotifyType   int   `json:"notifyType"`
	LocationEmbed
}

func NewElementReminder

func NewElementReminder(isWholeDay bool, timestamp int64, shouldNotify bool, notifyType ReminderNotifyType) *Reminder

func (*Reminder) ToElement

func (r *Reminder) ToElement() *ParagraphElement

type ReminderNotifyType

type ReminderNotifyType = int
var (
	ReminderNotifyNow       ReminderNotifyType = 0
	ReminderNotify5mBefore  ReminderNotifyType = 1
	ReminderNotify15mBefore ReminderNotifyType = 2
	ReminderNotify30mBefore ReminderNotifyType = 3
	ReminderNotify1hBefore  ReminderNotifyType = 4
	ReminderNotify2hBefore  ReminderNotifyType = 5
	ReminderNotify1dBefore  ReminderNotifyType = 6
	ReminderNotify2dBefore  ReminderNotifyType = 7
)

type TableCell

type TableCell struct {
	ColumnIndex int         `json:"columnIndex"`
	ZoneID      string      `json:"zoneID"`
	Body        interface{} `json:"body"`
}

TableCell represent a normal table cell

type TableColumnProperties

type TableColumnProperties struct {
	Width int `json:"width"`
}

type TableRow

type TableRow struct {
	RowIndex   int          `json:"rowIndex"`
	TableCells []*TableCell `json:"tableCells"`
}

func NewTableRows

func NewTableRows(cellContents [][]interface{}) []*TableRow

NewTableRows represent create some rows by cell content

type TableStyle

type TableStyle struct {
	TableColumnProperties []TableColumnProperties `json:"tableColumnProperties"`
}

type TextRun

type TextRun struct {
	Text      string     `json:"text"`
	TextStyle *TextStyle `json:"style,omitempty"`
	LineID    string     `json:"lineID"`
	LocationEmbed
}

func NewElementTextRun

func NewElementTextRun(text string) *TextRun

func (*TextRun) SetBold

func (t *TextRun) SetBold() *TextRun

func (*TextRun) SetCodeInline

func (t *TextRun) SetCodeInline() *TextRun

func (*TextRun) SetColor

func (t *TextRun) SetColor(backgroudColor, textColor *ColorRGBA) *TextRun

func (*TextRun) SetItalic

func (t *TextRun) SetItalic() *TextRun
func (t *TextRun) SetLink(link string) *TextRun

func (*TextRun) SetStrickThrouth

func (t *TextRun) SetStrickThrouth() *TextRun

func (*TextRun) SetUnderline

func (t *TextRun) SetUnderline() *TextRun

func (*TextRun) ToElement

func (t *TextRun) ToElement() *ParagraphElement

type TextStyle

type TextStyle struct {
	Bold          bool       `json:"bold"`
	Italic        bool       `json:"italic"`
	StrikeThrough bool       `json:"strikeThrough"`
	Underline     bool       `json:"underline"`
	CodeInline    bool       `json:"codeInline"`
	BackColor     *ColorRGBA `json:"backColor,omitempty"`
	TextColor     *ColorRGBA `json:"textColor,omitempty"`
	Link          *Link      `json:"link"`
}

type Title

type Title struct {
	TitleStyle *ParagraphStyle     `json:"style,omitempty"`
	Elements   []*ParagraphElement `json:"elements"`
	LocationEmbed
}

func NewTitle

func NewTitle(content string) *Title

NewTitle create a doc title

func (*Title) Align

func (t *Title) Align(align ParagraphAlignType) *Title

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL