Documentation
¶
Overview ¶
Package richedit wraps Quill 2 as a rich-text input widget.
Quill is distributed under the BSD-3-Clause license; the quill-mention add-on used to implement @ mentions is MIT. See ATTRIBUTIONS.md.
The widget exposes the same surface as the legacy ckeditor package where the underlying capability exists in Quill. Features that have no built-in equivalent (table-properties / cell-properties dialogs, special-characters menu, find & replace, source view) are intentionally not surfaced.
Index ¶
- Variables
- type BytesWidget
- type InputRichTextWidget
- func (wgt *InputRichTextWidget) Changed(r *http.Request) bool
- func (wgt *InputRichTextWidget) Draw(w io.Writer, r *http.Request) (err error)
- func (wgt *InputRichTextWidget) Valid(r *http.Request) bool
- func (wgt *InputRichTextWidget) Value(r *http.Request) string
- func (wgt *InputRichTextWidget) WithAutoFocus(autoFocus bool) *InputRichTextWidget
- func (wgt *InputRichTextWidget) WithLength(minChars int, maxChars int) *InputRichTextWidget
- func (wgt *InputRichTextWidget) WithMentionFeed(marker string, minChars int, feed ...string) *InputRichTextWidget
- func (wgt *InputRichTextWidget) WithPlaceholder(placeholder string) *InputRichTextWidget
- func (wgt *InputRichTextWidget) WithPredicate(predicate func(value string) (bool, string)) *InputRichTextWidget
- func (wgt *InputRichTextWidget) WithRows(minRows int, maxRows int) *InputRichTextWidget
- func (wgt *InputRichTextWidget) WithToolbar(buttons ...string) *InputRichTextWidget
- func (wgt *InputRichTextWidget) WithWidth(css string) *InputRichTextWidget
- type InputWidget
- type RichEditFactory
- type Widget
Constants ¶
This section is empty.
Variables ¶
var Any = factory.Any
Function aliases
var Bytes = factory.Bytes
var HTML = factory.HTML
var HTMLUnsafe = factory.HTMLUnsafe
var Many = factory.Many
var Tag = factory.Tag
var Text = factory.Text
Functions ¶
This section is empty.
Types ¶
type BytesWidget ¶
type BytesWidget = widget.BytesWidget
type InputRichTextWidget ¶
type InputRichTextWidget struct {
*widget.InputWidgetBase[*InputRichTextWidget]
// contains filtered or unexported fields
}
InputRichTextWidget renders a rich text input field backed by Quill.
func (*InputRichTextWidget) Changed ¶
func (wgt *InputRichTextWidget) Changed(r *http.Request) bool
Changed indicates if the value of the field changed.
func (*InputRichTextWidget) Valid ¶
func (wgt *InputRichTextWidget) Valid(r *http.Request) bool
Valid validates the field's value against all validators.
func (*InputRichTextWidget) Value ¶
func (wgt *InputRichTextWidget) Value(r *http.Request) string
Value returns the value of the field.
func (*InputRichTextWidget) WithAutoFocus ¶
func (wgt *InputRichTextWidget) WithAutoFocus(autoFocus bool) *InputRichTextWidget
WithAutoFocus automatically focuses the cursor on the text input field. Auto-focus is off by default.
func (*InputRichTextWidget) WithLength ¶
func (wgt *InputRichTextWidget) WithLength(minChars int, maxChars int) *InputRichTextWidget
WithLength bounds the editor's value length, measured against the raw HTML markup (not the visible text). Pass a negative value for either bound to leave it unbounded. A non-zero minimum does not imply Required.
func (*InputRichTextWidget) WithMentionFeed ¶
func (wgt *InputRichTextWidget) WithMentionFeed(marker string, minChars int, feed ...string) *InputRichTextWidget
WithMentionFeed adds an autocomplete feed triggered by a single-character marker. When the user types the marker (e.g. @ or #), a suggestion panel appears next to the caret; the chosen entry is inserted into the document. Multiple feeds may be registered, each with its own marker.
Example:
wgt.WithMentionFeed("@", 0, "Harry Potter", "Tom Riddle")
Implemented via the quill-mention add-on (MIT). See ATTRIBUTIONS.md.
func (*InputRichTextWidget) WithPlaceholder ¶
func (wgt *InputRichTextWidget) WithPlaceholder(placeholder string) *InputRichTextWidget
WithPlaceholder sets the placeholder text of the field.
func (*InputRichTextWidget) WithPredicate ¶
func (wgt *InputRichTextWidget) WithPredicate(predicate func(value string) (bool, string)) *InputRichTextWidget
WithPredicate adds a custom server-side validator. value is the raw HTML markup. Predicates run after length checks but before the built-in script-tag / event-handler sanitizer.
func (*InputRichTextWidget) WithRows ¶
func (wgt *InputRichTextWidget) WithRows(minRows int, maxRows int) *InputRichTextWidget
WithRows sets the editor's visible height range, in rows. The editor starts at minRows tall and grows up to maxRows before scrolling. Defaults: 8 / 12. Values below 1 are clamped to 1; maxRows is clamped up to minRows.
func (*InputRichTextWidget) WithToolbar ¶
func (wgt *InputRichTextWidget) WithToolbar(buttons ...string) *InputRichTextWidget
WithToolbar sets the buttons to show in the toolbar. Button names follow the legacy ckeditor naming for source compatibility. Supported tokens:
"|" toolbar group separator "bold", "italic", "underline", "strikethrough", "code", "codeBlock" "subscript", "superscript" "fontColor", "fontBackgroundColor", "fontFamily", "fontSize" "alignment", "alignment:left", "alignment:center", "alignment:right", "alignment:justify" "numberedList", "bulletedList", "todoList" "outdent", "indent" "blockQuote", "heading" "link", "image", "mediaEmbed" "removeFormat"
Tokens not in this list are silently dropped. Features without an equivalent in Quill (find & replace, special characters menu, source view, page break, table-properties dialogs) are not supported.
func (*InputRichTextWidget) WithWidth ¶
func (wgt *InputRichTextWidget) WithWidth(css string) *InputRichTextWidget
WithWidth caps the editor's width (max-width). Pass any CSS length, e.g. "60ch", "800px" or "100%". Empty lets it fill the container — the default.
type InputWidget ¶
type InputWidget = widget.InputWidget
type RichEditFactory ¶
type RichEditFactory struct{}
RichEditFactory aggregates the widget constructors of this package. Use RichEditFactory{} to construct a new factory.
func (RichEditFactory) InputRichText ¶
func (f RichEditFactory) InputRichText(name string, value string) *InputRichTextWidget
InputRichText creates a new widget that renders a Quill rich-text editor. name is the state variable; value is the initial HTML (sanitized on submit — <script>, javascript: URIs, and on* handlers are rejected). Defaults: 8 minimum rows / 12 maximum, the common formatting toolbar. Customize the toolbar with WithToolbar; add @-mentions via WithMentionFeed.