content

package
v2026.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentVersionLegacyJSONV1 = "legacy_json/v1"
	ContentVersionTiptapV1     = "tiptap/v1"
)

Variables

View Source
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.

View Source
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.

View Source
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.

View Source
var File_resources_common_content_content_proto protoreflect.FileDescriptor
View Source
var File_resources_common_content_diff_activity_proto protoreflect.FileDescriptor

Functions

func ParseHTML

func ParseHTML(in string) (*html.Node, error)

func PrettyHTML

func PrettyHTML(in string) (string, error)

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 Empty

func Empty() *Content

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 (x *Content) GetRawHtml() string

func (*Content) GetTiptapJson

func (x *Content) GetTiptapJson() *structpb.Struct

func (*Content) GetVersion

func (x *Content) GetVersion() string

func (*Content) HasContent

func (x *Content) HasContent() bool

func (*Content) HasRawHtml

func (x *Content) HasRawHtml() bool

func (*Content) HasTiptapJson

func (x *Content) HasTiptapJson() bool

func (*Content) ProtoMessage

func (*Content) ProtoMessage()

func (*Content) ProtoReflect

func (x *Content) ProtoReflect() protoreflect.Message

func (*Content) Reset

func (x *Content) Reset()

func (*Content) Sanitize

func (m *Content) Sanitize() error

Sanitize sanitizes the message's fields, in case of complex types it calls their Sanitize() method recursively.

func (*Content) Scan

func (x *Content) Scan(value any) error

Scan implements driver.Valuer for protobuf Content.

func (*Content) SetContent

func (x *Content) SetContent(v *RichTextHtmlNode)

func (*Content) SetContentType

func (x *Content) SetContentType(v ContentType)

func (*Content) SetRawHtml

func (x *Content) SetRawHtml(v string)

func (*Content) SetTiptapJson

func (x *Content) SetTiptapJson(v *structpb.Struct)

func (*Content) SetVersion

func (x *Content) SetVersion(v string)

func (*Content) String

func (x *Content) String() string

func (*Content) Value

func (x *Content) Value() (driver.Value, error)

Value marshals the value into driver.Valuer.

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

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

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) 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

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

type Kind

type Kind int32
const (
	Kind_KIND_UNSPECIFIED Kind = 0
	Kind_KIND_EQUAL       Kind = 1
	Kind_KIND_INSERT      Kind = 2
	Kind_KIND_DELETE      Kind = 3
)

func (Kind) Descriptor

func (Kind) Descriptor() protoreflect.EnumDescriptor

func (Kind) Enum

func (x Kind) Enum() *Kind

func (Kind) Number

func (x Kind) Number() protoreflect.EnumNumber

func (Kind) String

func (x Kind) String() string

func (Kind) Type

func (Kind) Type() protoreflect.EnumType

type NodeType

type NodeType int32
const (
	NodeType_NODE_TYPE_UNSPECIFIED NodeType = 0
	NodeType_NODE_TYPE_DOC         NodeType = 1
	NodeType_NODE_TYPE_ELEMENT     NodeType = 2
	NodeType_NODE_TYPE_TEXT        NodeType = 3
	NodeType_NODE_TYPE_COMMENT     NodeType = 4
)

func (NodeType) Descriptor

func (NodeType) Descriptor() protoreflect.EnumDescriptor

func (NodeType) Enum

func (x NodeType) Enum() *NodeType

func (NodeType) Number

func (x NodeType) Number() protoreflect.EnumNumber

func (NodeType) String

func (x NodeType) String() string

func (NodeType) Type

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

Jump to

Keyboard shortcuts

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