Ir al contenido

API Reference

shadow: false · scoped: false — light DOM. ProseMirror controla el DOM editable de forma imperativa.

Props

PropAtributoTipoDefaultDescripción
accountFontsaccount-fontsstring | undefined | { label: string; value: string; }[]Account/imported fonts shown in a separate "Imported fonts" section. JS property: `Array<{ label: string; value: string }>`. HTML attribute: JSON string of the same array.
autofocusautofocusbooleanfalse
customExtensionsobject[] | undefinedExtra Tiptap extensions appended to the preset (JS property only). Registered at editor creation — required for new schema nodes (images, tables, embeds, …) that `getEditorInstance()` cannot add afterwards.
disableddisabledbooleanfalse
featuresfeaturesobject | string | undefinedFeature overrides (JSON string for HTML attr, or object via JS property).
fontFamiliesfont-familiesstring | undefined | { label: string; value: string; }[]Font families available in the bubble menu font selector. JS property: `Array<{ label: string; value: string }>`. HTML attribute: JSON string of the same array. If not provided, a default list of system fonts is used.
fontLoader(() => Promise<{ label: string; value: string; url?: string | undefined; }[]>) | undefinedAsync callback that loads account/imported fonts. Called once when the font dropdown opens for the first time. Must return `Array<{ label: string; value: string; url?: string }>`. If `url` is provided, the font is registered via FontFace API. JS property only — cannot be set via HTML attribute.
fontsLoadingfonts-loadingboolean | undefinedWhether account fonts are currently loading.
helperTexthelper-textstring | undefined
imageUpload((file: File) => Promise<string>) | undefinedHost image upload handler (JS property): `(file) => Promise<url>`.
labellabelstring | undefined
localelocalestring'en'BCP-47 locale for UI strings (e.g. 'en', 'es-CO', 'pt-BR'). Default English.
maxLengthmax-lengthnumber | undefined
placeholderplaceholderstring''
presetpreset"comment" | "document" | "email" | "task"'task'Preset controlling allowed nodes/marks, toolbar and sanitization.
readonlyreadonlybooleanfalse
requiredrequiredbooleanfalse
secondaryLabelsecondary-labelstring | undefined
showCharacterCountshow-character-countbooleanfalse
statusstatus"default" | "error" | "info" | "success" | "warning"'default'
toolbartoolbar"auto" | "basic" | "compact" | "full" | "none"'auto'Toolbar layout. `auto` uses the preset default.
valuevaluenull | stringnullProseMirror document as a JSON string. `null`/empty = empty editor.

Eventos

EventoDetailBubblesCancelableDescripción
coBlurvoid
coChangeRichTextOutputEmitted on blur (committed value).
coClearvoid
coFocusvoid
coFontPopupHidevoidEmitted when the font dropdown closes.
coFontPopupShowvoidEmitted when the font dropdown opens — host should load account fonts.
coInputRichTextOutputEmitted on every keystroke.
coReadyvoidEmitted once the editor is mounted and ready.

Slots

Este componente no expone slots.

CSS Parts

PartDescripción
::part(content)Editable ProseMirror surface
::part(helper)Helper text row
::part(label)Field label
::part(toolbar)Formatting toolbar
::part(wrapper)Outer container

CSS Custom Properties

Este componente no expone CSS custom properties.

Estas propiedades solo pueden asignarse vía JavaScript (no como atributos HTML):

PropTipoDescripción
customExtensionsExtension[]Extensiones Tiptap adicionales (schema nuevo)
imageUpload(file: File) => Promise<string>Handler de subida de imágenes a CDN
fontLoader() => Promise<FontEntry[]>Callback async para cargar fuentes de cuenta
MétodoRetornoDescripción
getJSON()Promise<object | null>Documento ProseMirror JSON, o null si vacío
getHtml()Promise<string>HTML sanitizado
getText()Promise<string>Texto plano
clear()Promise<void>Limpia el contenido y emite coClear
focusEditor()Promise<void>Foca el editor programáticamente
setContent(content)Promise<void>Establece contenido (HTML string u objeto JSON)
getEditorInstance()Promise<Editor | null>Instancia Tiptap — escape hatch para control avanzado
EventoPayloadCuándo
coInput{ json, html, text }Cada cambio (keystroke)
coChange{ json, html, text }Al perder foco (valor confirmado)
coFocusvoidAl ganar foco
coBlurvoidAl perder foco
coClearvoidDespués de clear()
coReadyvoidEditor montado y listo
coFontPopupShowvoidSe abrió el selector de fuentes
coFontPopupHidevoidSe cerró el selector de fuentes

shadow: true

Props

PropAtributoTipoDefaultDescripción
compactcompactbooleanfalseReduced padding.
emptyTextempty-textstring | undefinedText shown when there is no content.
formatformat"html" | "json"'html'Input format. `html` is the lightweight path.
presetpreset"comment" | "document" | "email" | "task"'document'Sanitization profile to apply.
valuevaluenull | stringnullHTML string (default) or ProseMirror JSON string.

Eventos

Este componente no emite eventos personalizados.

Slots

Este componente no expone slots.

CSS Parts

PartDescripción
::part(content)
::part(empty)

CSS Custom Properties

Este componente no expone CSS custom properties.


shadow: true — normalmente renderizado internamente por el editor.

Props

PropAtributoTipoDefaultDescripción
disableddisabledbooleanfalse
editorEditor | undefinedEditor instance (set as a property by the host editor).
imageUpload((file: File) => Promise<any>) | undefinedImage upload handler (JS property): `(file) => Promise<url | {src, fileId}>`.
localelocalestring'en'BCP-47 locale for UI strings (e.g. 'en', 'es-CO', 'pt-BR'). Default English.
variantvariant"basic" | "compact" | "full" | "none"'basic'Toolbar layout variant.

Eventos

EventoDetailBubblesCancelableDescripción
coAction{ action: string; payload?: unknown; }Emitted whenever a toolbar action runs (observability for hosts).
coPopoverChange{ open: boolean; }Emitted when a toolbar popover/dropdown opens or closes (host hides the selection bubble while one is open to avoid spatial overlap).

Slots

Este componente no expone slots.

CSS Parts

PartDescripción
::part(button)A toolbar button
::part(toolbar)The toolbar container

CSS Custom Properties

Este componente no expone CSS custom properties.

EventoPayloadDescripción
coAction{ action: string; payload?: unknown }Se ejecutó una acción de toolbar
coPopoverChange{ open: boolean }Un popover/dropdown se abrió o cerró

Package API — @prolibu-suite/cobalt-rich-text

Sección titulada «Package API — @prolibu-suite/cobalt-rich-text»
import { createEditor } from '@prolibu-suite/cobalt-rich-text';
const editor = createEditor({
preset: 'task',
element: document.getElementById('editor'),
content: null,
editable: true,
placeholder: 'Escribe aquí…',
maxLength: 5000,
features: { variables: true },
imageUpload: async (file) => uploadToCDN(file),
onUpdate: ({ editor }) => { /* ... */ },
onFocus: () => { /* ... */ },
onBlur: () => { /* ... */ },
});
import {
getExtensions,
defaultToolbarForPreset,
maxLengthForPreset,
PRESETS,
} from '@prolibu-suite/cobalt-rich-text';
const exts = getExtensions('email', {
placeholder: 'Escribe tu email…',
features: { variables: true, mentions: true },
});
defaultToolbarForPreset('task'); // 'basic'
maxLengthForPreset('comment'); // 2000
PRESETS; // ['comment', 'task', 'email', 'document']
import { jsonToHtml, htmlToJson, jsonToText } from '@prolibu-suite/cobalt-rich-text';
const html = jsonToHtml(prosemirrorDoc, 'task'); // HTML sanitizado
const json = htmlToJson(htmlString, 'task'); // sanitiza antes de parsear
const text = jsonToText(prosemirrorDoc); // texto plano
import { sanitize, SANITIZE_CONFIGS } from '@prolibu-suite/cobalt-rich-text';
const clean = sanitize(dirtyHtml, 'email');
import type {
RichTextPreset, // 'comment' | 'task' | 'email' | 'document'
ToolbarVariant, // 'none' | 'compact' | 'basic' | 'full'
RichTextOutput, // { json: object; html: string; text: string }
RichTextFeatures, // { mentions?, variables?, image?, characterCount?, link? }
CreateEditorOptions,
ImageUploadHandler,
} from '@prolibu-suite/cobalt-rich-text';