Documentation
¶
Index ¶
- Constants
- Variables
- func ParseHTML(in string) (*html.Node, error)
- func PrettyHTML(in string) (string, error)
- type Content
- func (x *Content) ClearContent()
- func (x *Content) ClearRawHtml()
- func (x *Content) ClearTiptapJson()
- func (x *Content) Extract() *ExtractedContent
- func (x *Content) GetContent() *RichTextHtmlNode
- func (x *Content) GetContentType() ContentType
- func (x *Content) GetRawHtml() string
- func (x *Content) GetTiptapJson() *structpb.Struct
- func (x *Content) GetVersion() string
- func (x *Content) HasContent() bool
- func (x *Content) HasRawHtml() bool
- func (x *Content) HasTiptapJson() bool
- func (*Content) ProtoMessage()
- func (x *Content) ProtoReflect() protoreflect.Message
- func (x *Content) Reset()
- func (m *Content) Sanitize() error
- func (x *Content) Scan(value any) error
- func (x *Content) SetContent(v *RichTextHtmlNode)
- func (x *Content) SetContentType(v ContentType)
- func (x *Content) SetRawHtml(v string)
- func (x *Content) SetTiptapJson(v *structpb.Struct)
- func (x *Content) SetVersion(v string)
- func (x *Content) String() string
- func (x *Content) Value() (driver.Value, error)
- type ContentDiff
- func (x *ContentDiff) ClearStats()
- func (x *ContentDiff) GetOps() []*ContentDiffOp
- func (x *ContentDiff) GetStats() *ContentDiffStats
- func (dr *ContentDiff) HasChanges() bool
- func (x *ContentDiff) HasStats() bool
- func (*ContentDiff) ProtoMessage()
- func (x *ContentDiff) ProtoReflect() protoreflect.Message
- func (x *ContentDiff) Reset()
- func (m *ContentDiff) Sanitize() error
- func (x *ContentDiff) SetOps(v []*ContentDiffOp)
- func (x *ContentDiff) SetStats(v *ContentDiffStats)
- func (x *ContentDiff) String() string
- type ContentDiffOp
- func (x *ContentDiffOp) GetKind() Kind
- func (x *ContentDiffOp) GetText() string
- func (*ContentDiffOp) ProtoMessage()
- func (x *ContentDiffOp) ProtoReflect() protoreflect.Message
- func (x *ContentDiffOp) Reset()
- func (m *ContentDiffOp) Sanitize() error
- func (x *ContentDiffOp) SetKind(v Kind)
- func (x *ContentDiffOp) SetText(v string)
- func (x *ContentDiffOp) String() string
- type ContentDiffOp_builder
- type ContentDiffStats
- func (x *ContentDiffStats) GetDeletedRunes() uint32
- func (x *ContentDiffStats) GetInsertedRunes() uint32
- func (x *ContentDiffStats) GetOpCount() uint32
- func (*ContentDiffStats) ProtoMessage()
- func (x *ContentDiffStats) ProtoReflect() protoreflect.Message
- func (x *ContentDiffStats) Reset()
- func (m *ContentDiffStats) Sanitize() error
- func (x *ContentDiffStats) SetDeletedRunes(v uint32)
- func (x *ContentDiffStats) SetInsertedRunes(v uint32)
- func (x *ContentDiffStats) SetOpCount(v uint32)
- func (x *ContentDiffStats) String() string
- type ContentDiffStats_builder
- type ContentDiff_builder
- type ContentType
- type Content_builder
- type ExtractedContent
- func (x *ExtractedContent) GetFirstHeading() string
- func (x *ExtractedContent) GetSummary(length int) string
- func (x *ExtractedContent) GetText() string
- func (x *ExtractedContent) GetWordCount() uint32
- func (*ExtractedContent) ProtoMessage()
- func (x *ExtractedContent) ProtoReflect() protoreflect.Message
- func (x *ExtractedContent) Reset()
- func (m *ExtractedContent) Sanitize() error
- func (x *ExtractedContent) SetFirstHeading(v string)
- func (x *ExtractedContent) SetText(v string)
- func (x *ExtractedContent) SetWordCount(v uint32)
- func (x *ExtractedContent) String() string
- type ExtractedContent_builder
- type Kind
- type NodeType
- type RichTextHtmlNode
- func (x *RichTextHtmlNode) ClearId()
- func (x *RichTextHtmlNode) ClearText()
- func (x *RichTextHtmlNode) GetAttrs() map[string]string
- func (x *RichTextHtmlNode) GetContent() []*RichTextHtmlNode
- func (x *RichTextHtmlNode) GetId() string
- func (x *RichTextHtmlNode) GetTag() string
- func (x *RichTextHtmlNode) GetText() string
- func (x *RichTextHtmlNode) GetType() NodeType
- func (x *RichTextHtmlNode) HasId() bool
- func (x *RichTextHtmlNode) HasText() bool
- func (*RichTextHtmlNode) ProtoMessage()
- func (x *RichTextHtmlNode) ProtoReflect() protoreflect.Message
- func (x *RichTextHtmlNode) Reset()
- func (m *RichTextHtmlNode) Sanitize() error
- func (x *RichTextHtmlNode) SetAttrs(v map[string]string)
- func (x *RichTextHtmlNode) SetContent(v []*RichTextHtmlNode)
- func (x *RichTextHtmlNode) SetId(v string)
- func (x *RichTextHtmlNode) SetTag(v string)
- func (x *RichTextHtmlNode) SetText(v string)
- func (x *RichTextHtmlNode) SetType(v NodeType)
- func (x *RichTextHtmlNode) String() string
- func (n *RichTextHtmlNode) ToHTML() (string, error)
- func (n *RichTextHtmlNode) ToHTMLNode() (*html.Node, error)
- type RichTextHtmlNode_builder
Constants ¶
const ( ContentVersionLegacyJSONV1 = "legacy_json/v1" ContentVersionTiptapV1 = "tiptap/v1" )
Variables ¶
var ( ContentType_name = map[int32]string{ 0: "CONTENT_TYPE_UNSPECIFIED", 1: "CONTENT_TYPE_HTML", 2: "CONTENT_TYPE_TIPTAP_JSON", } ContentType_value = map[string]int32{ "CONTENT_TYPE_UNSPECIFIED": 0, "CONTENT_TYPE_HTML": 1, "CONTENT_TYPE_TIPTAP_JSON": 2, } )
Enum value maps for ContentType.
var ( NodeType_name = map[int32]string{ 0: "NODE_TYPE_UNSPECIFIED", 1: "NODE_TYPE_DOC", 2: "NODE_TYPE_ELEMENT", 3: "NODE_TYPE_TEXT", 4: "NODE_TYPE_COMMENT", } NodeType_value = map[string]int32{ "NODE_TYPE_UNSPECIFIED": 0, "NODE_TYPE_DOC": 1, "NODE_TYPE_ELEMENT": 2, "NODE_TYPE_TEXT": 3, "NODE_TYPE_COMMENT": 4, } )
Enum value maps for NodeType.
var ( Kind_name = map[int32]string{ 0: "KIND_UNSPECIFIED", 1: "KIND_EQUAL", 2: "KIND_INSERT", 3: "KIND_DELETE", } Kind_value = map[string]int32{ "KIND_UNSPECIFIED": 0, "KIND_EQUAL": 1, "KIND_INSERT": 2, "KIND_DELETE": 3, } )
Enum value maps for Kind.
var File_resources_common_content_content_proto protoreflect.FileDescriptor
var File_resources_common_content_diff_activity_proto protoreflect.FileDescriptor
Functions ¶
func PrettyHTML ¶
Types ¶
type Content ¶
type Content struct {
Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
ContentType ContentType `` /* 137-byte string literal not displayed */
// Deprecated: Legacy HTML (only for viewing old content)
RawHtml *string `protobuf:"bytes,3,opt,name=raw_html,json=rawHtml,proto3,oneof" json:"raw_html,omitempty"`
// Deprecated: Legacy custom HTML to JSON AST (only for viewing old content)
Content *RichTextHtmlNode `protobuf:"bytes,4,opt,name=content,proto3,oneof" json:"content,omitempty"`
// Tiptap JSON Document
TiptapJson *structpb.Struct `protobuf:"bytes,5,opt,name=tiptap_json,json=tiptapJson,proto3" json:"tiptap_json,omitempty"`
// contains filtered or unexported fields
}
func (*Content) ClearContent ¶
func (x *Content) ClearContent()
func (*Content) ClearRawHtml ¶
func (x *Content) ClearRawHtml()
func (*Content) ClearTiptapJson ¶
func (x *Content) ClearTiptapJson()
func (*Content) Extract ¶
func (x *Content) Extract() *ExtractedContent
func (*Content) GetContent ¶
func (x *Content) GetContent() *RichTextHtmlNode
func (*Content) GetContentType ¶
func (x *Content) GetContentType() ContentType
func (*Content) GetRawHtml ¶
func (*Content) GetTiptapJson ¶
func (*Content) GetVersion ¶
func (*Content) HasContent ¶
func (*Content) HasRawHtml ¶
func (*Content) HasTiptapJson ¶
func (*Content) ProtoMessage ¶
func (*Content) ProtoMessage()
func (*Content) ProtoReflect ¶
func (x *Content) ProtoReflect() protoreflect.Message
func (*Content) Sanitize ¶
Sanitize sanitizes the message's fields, in case of complex types it calls their Sanitize() method recursively.
func (*Content) SetContent ¶
func (x *Content) SetContent(v *RichTextHtmlNode)
func (*Content) SetContentType ¶
func (x *Content) SetContentType(v ContentType)
func (*Content) SetRawHtml ¶
func (*Content) SetTiptapJson ¶
func (*Content) SetVersion ¶
type ContentDiff ¶
type ContentDiff struct {
// Quick summary for badge like "+12 / -3"
Stats *ContentDiffStats `protobuf:"bytes,1,opt,name=stats,proto3" json:"stats,omitempty"`
// The diff itself for inline rendering
Ops []*ContentDiffOp `protobuf:"bytes,2,rep,name=ops,proto3" json:"ops,omitempty"`
// contains filtered or unexported fields
}
func (*ContentDiff) ClearStats ¶
func (x *ContentDiff) ClearStats()
func (*ContentDiff) GetOps ¶
func (x *ContentDiff) GetOps() []*ContentDiffOp
func (*ContentDiff) GetStats ¶
func (x *ContentDiff) GetStats() *ContentDiffStats
func (*ContentDiff) HasChanges ¶
func (dr *ContentDiff) HasChanges() bool
func (*ContentDiff) HasStats ¶
func (x *ContentDiff) HasStats() bool
func (*ContentDiff) ProtoMessage ¶
func (*ContentDiff) ProtoMessage()
func (*ContentDiff) ProtoReflect ¶
func (x *ContentDiff) ProtoReflect() protoreflect.Message
func (*ContentDiff) Reset ¶
func (x *ContentDiff) Reset()
func (*ContentDiff) Sanitize ¶
func (m *ContentDiff) Sanitize() error
Sanitize sanitizes the message's fields, in case of complex types it calls their Sanitize() method recursively.
func (*ContentDiff) SetOps ¶
func (x *ContentDiff) SetOps(v []*ContentDiffOp)
func (*ContentDiff) SetStats ¶
func (x *ContentDiff) SetStats(v *ContentDiffStats)
func (*ContentDiff) String ¶
func (x *ContentDiff) String() string
type ContentDiffOp ¶
type ContentDiffOp struct {
Kind Kind `protobuf:"varint,1,opt,name=kind,proto3,enum=resources.common.content.Kind" json:"kind,omitempty"`
// Plain text segment. Can contain whitespace and newlines.
// Client renders:
// - EQUAL: normal text
// - INSERT: highlighted
// - DELETE: strikethrough or hidden behind a toggle
Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"`
// contains filtered or unexported fields
}
One diff operation, designed for inline client rendering.
func (*ContentDiffOp) GetKind ¶
func (x *ContentDiffOp) GetKind() Kind
func (*ContentDiffOp) GetText ¶
func (x *ContentDiffOp) GetText() string
func (*ContentDiffOp) ProtoMessage ¶
func (*ContentDiffOp) ProtoMessage()
func (*ContentDiffOp) ProtoReflect ¶
func (x *ContentDiffOp) ProtoReflect() protoreflect.Message
func (*ContentDiffOp) Reset ¶
func (x *ContentDiffOp) Reset()
func (*ContentDiffOp) Sanitize ¶
func (m *ContentDiffOp) Sanitize() error
Sanitize sanitizes the message's fields, in case of complex types it calls their Sanitize() method recursively.
func (*ContentDiffOp) SetKind ¶
func (x *ContentDiffOp) SetKind(v Kind)
func (*ContentDiffOp) SetText ¶
func (x *ContentDiffOp) SetText(v string)
func (*ContentDiffOp) String ¶
func (x *ContentDiffOp) String() string
type ContentDiffOp_builder ¶
type ContentDiffOp_builder struct {
Kind Kind
// Plain text segment. Can contain whitespace and newlines.
// Client renders:
// - EQUAL: normal text
// - INSERT: highlighted
// - DELETE: strikethrough or hidden behind a toggle
Text string
// contains filtered or unexported fields
}
func (ContentDiffOp_builder) Build ¶
func (b0 ContentDiffOp_builder) Build() *ContentDiffOp
type ContentDiffStats ¶
type ContentDiffStats struct {
// Counts are measured in runes/codepoints on the server side.
InsertedRunes uint32 `protobuf:"varint,1,opt,name=inserted_runes,json=insertedRunes,proto3" json:"inserted_runes,omitempty"`
DeletedRunes uint32 `protobuf:"varint,2,opt,name=deleted_runes,json=deletedRunes,proto3" json:"deleted_runes,omitempty"`
// Optional: number of diff ops (after cleanup/coalescing).
OpCount uint32 `protobuf:"varint,3,opt,name=op_count,json=opCount,proto3" json:"op_count,omitempty"`
// contains filtered or unexported fields
}
Optional stats to quickly show "what changed" without parsing ops.
func (*ContentDiffStats) GetDeletedRunes ¶
func (x *ContentDiffStats) GetDeletedRunes() uint32
func (*ContentDiffStats) GetInsertedRunes ¶
func (x *ContentDiffStats) GetInsertedRunes() uint32
func (*ContentDiffStats) GetOpCount ¶
func (x *ContentDiffStats) GetOpCount() uint32
func (*ContentDiffStats) ProtoMessage ¶
func (*ContentDiffStats) ProtoMessage()
func (*ContentDiffStats) ProtoReflect ¶
func (x *ContentDiffStats) ProtoReflect() protoreflect.Message
func (*ContentDiffStats) Reset ¶
func (x *ContentDiffStats) Reset()
func (*ContentDiffStats) Sanitize ¶
func (m *ContentDiffStats) Sanitize() error
Sanitize sanitizes the message's fields, in case of complex types it calls their Sanitize() method recursively.
func (*ContentDiffStats) SetDeletedRunes ¶
func (x *ContentDiffStats) SetDeletedRunes(v uint32)
func (*ContentDiffStats) SetInsertedRunes ¶
func (x *ContentDiffStats) SetInsertedRunes(v uint32)
func (*ContentDiffStats) SetOpCount ¶
func (x *ContentDiffStats) SetOpCount(v uint32)
func (*ContentDiffStats) String ¶
func (x *ContentDiffStats) String() string
type ContentDiffStats_builder ¶
type ContentDiffStats_builder struct {
// Counts are measured in runes/codepoints on the server side.
InsertedRunes uint32
DeletedRunes uint32
// Optional: number of diff ops (after cleanup/coalescing).
OpCount uint32
// contains filtered or unexported fields
}
func (ContentDiffStats_builder) Build ¶
func (b0 ContentDiffStats_builder) Build() *ContentDiffStats
type ContentDiff_builder ¶
type ContentDiff_builder struct {
// Quick summary for badge like "+12 / -3"
Stats *ContentDiffStats
// The diff itself for inline rendering
Ops []*ContentDiffOp
// contains filtered or unexported fields
}
func (ContentDiff_builder) Build ¶
func (b0 ContentDiff_builder) Build() *ContentDiff
type ContentType ¶
type ContentType int32
const ( ContentType_CONTENT_TYPE_UNSPECIFIED ContentType = 0 // Used for legacy HTML content ContentType_CONTENT_TYPE_HTML ContentType = 1 // Used for Tiptap JSON content ContentType_CONTENT_TYPE_TIPTAP_JSON ContentType = 2 )
func (ContentType) Descriptor ¶
func (ContentType) Descriptor() protoreflect.EnumDescriptor
func (ContentType) Enum ¶
func (x ContentType) Enum() *ContentType
func (ContentType) Number ¶
func (x ContentType) Number() protoreflect.EnumNumber
func (ContentType) String ¶
func (x ContentType) String() string
func (ContentType) Type ¶
func (ContentType) Type() protoreflect.EnumType
type Content_builder ¶
type Content_builder struct {
Version string
ContentType ContentType
// Deprecated: Legacy HTML (only for viewing old content)
RawHtml *string
// Deprecated: Legacy custom HTML to JSON AST (only for viewing old content)
Content *RichTextHtmlNode
// Tiptap JSON Document
TiptapJson *structpb.Struct
// contains filtered or unexported fields
}
func (Content_builder) Build ¶
func (b0 Content_builder) Build() *Content
type ExtractedContent ¶
type ExtractedContent struct {
Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
WordCount uint32 `protobuf:"varint,2,opt,name=word_count,json=wordCount,proto3" json:"word_count,omitempty"`
FirstHeading string `protobuf:"bytes,3,opt,name=first_heading,json=firstHeading,proto3" json:"first_heading,omitempty"`
// contains filtered or unexported fields
}
func ExtractFromHTML ¶
func ExtractFromHTML(doc *RichTextHtmlNode) *ExtractedContent
func ExtractFromTiptap ¶
func ExtractFromTiptap(doc *structpb.Struct) *ExtractedContent
ExtractFromTiptap converts a Tiptap JSON doc (Struct) into text + derived fields. Assumes you've already sanitized/validated the doc (allowed nodes/marks, URL policy, etc.).
func (*ExtractedContent) GetFirstHeading ¶
func (x *ExtractedContent) GetFirstHeading() string
func (*ExtractedContent) GetSummary ¶
func (x *ExtractedContent) GetSummary(length int) string
func (*ExtractedContent) GetText ¶
func (x *ExtractedContent) GetText() string
func (*ExtractedContent) GetWordCount ¶
func (x *ExtractedContent) GetWordCount() uint32
func (*ExtractedContent) ProtoMessage ¶
func (*ExtractedContent) ProtoMessage()
func (*ExtractedContent) ProtoReflect ¶
func (x *ExtractedContent) ProtoReflect() protoreflect.Message
func (*ExtractedContent) Reset ¶
func (x *ExtractedContent) Reset()
func (*ExtractedContent) Sanitize ¶
func (m *ExtractedContent) Sanitize() error
Sanitize sanitizes the message's fields, in case of complex types it calls their Sanitize() method recursively.
func (*ExtractedContent) SetFirstHeading ¶
func (x *ExtractedContent) SetFirstHeading(v string)
func (*ExtractedContent) SetText ¶
func (x *ExtractedContent) SetText(v string)
func (*ExtractedContent) SetWordCount ¶
func (x *ExtractedContent) SetWordCount(v uint32)
func (*ExtractedContent) String ¶
func (x *ExtractedContent) String() string
type ExtractedContent_builder ¶
type ExtractedContent_builder struct {
Text string
WordCount uint32
FirstHeading string
// contains filtered or unexported fields
}
func (ExtractedContent_builder) Build ¶
func (b0 ExtractedContent_builder) Build() *ExtractedContent
type Kind ¶
type Kind int32
func (Kind) Descriptor ¶
func (Kind) Descriptor() protoreflect.EnumDescriptor
func (Kind) Number ¶
func (x Kind) Number() protoreflect.EnumNumber
func (Kind) Type ¶
func (Kind) Type() protoreflect.EnumType
type NodeType ¶
type NodeType int32
func (NodeType) Descriptor ¶
func (NodeType) Descriptor() protoreflect.EnumDescriptor
func (NodeType) Number ¶
func (x NodeType) Number() protoreflect.EnumNumber
func (NodeType) Type ¶
func (NodeType) Type() protoreflect.EnumType
type RichTextHtmlNode ¶
type RichTextHtmlNode struct {
Type NodeType `protobuf:"varint,1,opt,name=type,proto3,enum=resources.common.content.NodeType" json:"type,omitempty"`
Id *string `protobuf:"bytes,2,opt,name=id,proto3,oneof" json:"id,omitempty"`
Tag string `protobuf:"bytes,3,opt,name=tag,proto3" json:"tag,omitempty"`
Attrs map[string]string `` /* 137-byte string literal not displayed */
Text *string `protobuf:"bytes,5,opt,name=text,proto3,oneof" json:"text,omitempty"`
Content []*RichTextHtmlNode `protobuf:"bytes,6,rep,name=content,proto3" json:"content,omitempty"`
// contains filtered or unexported fields
}
func FromHTML ¶
func FromHTML(in string) (*RichTextHtmlNode, error)
func FromHTMLNode ¶
func FromHTMLNode(node *html.Node) (*RichTextHtmlNode, error)
FromHTMLNode converts html.Node to RichTextHtmlNode.
func (*RichTextHtmlNode) ClearId ¶
func (x *RichTextHtmlNode) ClearId()
func (*RichTextHtmlNode) ClearText ¶
func (x *RichTextHtmlNode) ClearText()
func (*RichTextHtmlNode) GetAttrs ¶
func (x *RichTextHtmlNode) GetAttrs() map[string]string
func (*RichTextHtmlNode) GetContent ¶
func (x *RichTextHtmlNode) GetContent() []*RichTextHtmlNode
func (*RichTextHtmlNode) GetId ¶
func (x *RichTextHtmlNode) GetId() string
func (*RichTextHtmlNode) GetTag ¶
func (x *RichTextHtmlNode) GetTag() string
func (*RichTextHtmlNode) GetText ¶
func (x *RichTextHtmlNode) GetText() string
func (*RichTextHtmlNode) GetType ¶
func (x *RichTextHtmlNode) GetType() NodeType
func (*RichTextHtmlNode) HasId ¶
func (x *RichTextHtmlNode) HasId() bool
func (*RichTextHtmlNode) HasText ¶
func (x *RichTextHtmlNode) HasText() bool
func (*RichTextHtmlNode) ProtoMessage ¶
func (*RichTextHtmlNode) ProtoMessage()
func (*RichTextHtmlNode) ProtoReflect ¶
func (x *RichTextHtmlNode) ProtoReflect() protoreflect.Message
func (*RichTextHtmlNode) Reset ¶
func (x *RichTextHtmlNode) Reset()
func (*RichTextHtmlNode) Sanitize ¶
func (m *RichTextHtmlNode) Sanitize() error
Sanitize sanitizes the message's fields, in case of complex types it calls their Sanitize() method recursively.
func (*RichTextHtmlNode) SetAttrs ¶
func (x *RichTextHtmlNode) SetAttrs(v map[string]string)
func (*RichTextHtmlNode) SetContent ¶
func (x *RichTextHtmlNode) SetContent(v []*RichTextHtmlNode)
func (*RichTextHtmlNode) SetId ¶
func (x *RichTextHtmlNode) SetId(v string)
func (*RichTextHtmlNode) SetTag ¶
func (x *RichTextHtmlNode) SetTag(v string)
func (*RichTextHtmlNode) SetText ¶
func (x *RichTextHtmlNode) SetText(v string)
func (*RichTextHtmlNode) SetType ¶
func (x *RichTextHtmlNode) SetType(v NodeType)
func (*RichTextHtmlNode) String ¶
func (x *RichTextHtmlNode) String() string
func (*RichTextHtmlNode) ToHTML ¶
func (n *RichTextHtmlNode) ToHTML() (string, error)
ToHTML HTML potentially not pretty.
func (*RichTextHtmlNode) ToHTMLNode ¶
func (n *RichTextHtmlNode) ToHTMLNode() (*html.Node, error)
ToHTMLNode converts RichTextHtmlNode to html.Node.
type RichTextHtmlNode_builder ¶
type RichTextHtmlNode_builder struct {
Type NodeType
Id *string
Tag string
Attrs map[string]string
Text *string
Content []*RichTextHtmlNode
// contains filtered or unexported fields
}
func (RichTextHtmlNode_builder) Build ¶
func (b0 RichTextHtmlNode_builder) Build() *RichTextHtmlNode