tiptap.go 706 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package tiptap
  2. // @snippet_begin(TipTapEditorHTMLComponent)
  3. import (
  4. "context"
  5. "github.com/qor5/web"
  6. h "github.com/theplant/htmlgo"
  7. )
  8. type TipTapEditorBuilder struct {
  9. tag *h.HTMLTagBuilder
  10. }
  11. func TipTapEditor() (r *TipTapEditorBuilder) {
  12. r = &TipTapEditorBuilder{
  13. tag: h.Tag("tiptap-editor"),
  14. }
  15. return
  16. }
  17. func (b *TipTapEditorBuilder) FieldName(v string) (r *TipTapEditorBuilder) {
  18. b.tag.Attr(web.VFieldName(v)...)
  19. return b
  20. }
  21. func (b *TipTapEditorBuilder) Value(v string) (r *TipTapEditorBuilder) {
  22. b.tag.Attr(":value", h.JSONString(v))
  23. return b
  24. }
  25. func (b *TipTapEditorBuilder) MarshalHTML(ctx context.Context) (r []byte, err error) {
  26. return b.tag.MarshalHTML(ctx)
  27. }
  28. // @snippet_end