Getting Started
Overview
Installation
Theme
Forms
Basic Inputs
Custom Inputs
Select
Components
Components
78
Micro Charts
Navigation
Libraries
Content Editor
Data View
Form Builder
Headless Editor
Image Designer
Kanban Board
PDF Builder
PDF Signer
PDF Viewer
Video Player
GitHub repositoryGitHub starsGitHub forksNgStarter UI npm versionNgStarter UI npm downloads per month

Comment Editor

Comment Editor is a simplified text editor for quick messages, comments, threads, and replies. Use it when users need to compose a short or medium response and send it immediately. It can include lightweight formatting, links, lists, images, and media when the comment flow needs them.

Use it for:
  • Writing comments in tasks, projects, activity feeds, reviews, and support threads.
  • Replying to a conversation with a compact compose box.
  • Sending message HTML through the sent event.
  • Adding a small toolbar, footer actions, cancel behavior, or image upload to a comment composer.

Do not use Comment Editor for long-form documents, CMS pages, complex content editing, markdown editing, code editing, search, or display-only comments. Use Content Editor or Text Editor when users need a fuller editing surface.

All APIs on this page are exported from @ngstarter-ui/components/comment-editor. The component owns a scoped NgsHeadlessEditor; no Tiptap or ProseMirror adapter is involved.

Content contract

  • value and submitted use the versioned JSON document model.
  • sent is an HTML compatibility output derived from JSON at send time.
  • Toolbar, footer, and bubble-menu controls are projected, so products can choose the exact command set and icons.
  • Additional engine behavior is installed through the same lightweight NgsHeadlessEditorPlugin contract.

Inputs

JSON state, editor behavior, labels, layout, and integration callbacks.

NameTypeDefaultDescription
valueModelSignal<NgsHeadlessEditorDocument>empty documentTwo-way bound versioned JSON document. This is the canonical content value.
pluginsreadonly NgsHeadlessEditorPlugin[][]Additional editor plugins installed after the basic text, color, and Comment Editor feature plugins.
contentMaxHeightnumber | undefinedundefinedMaximum expanded content height in pixels before the editing surface scrolls.
placeholderstringWrite something …Placeholder rendered while the JSON document is empty.
ariaLabelstringComment editorAccessible label for the contenteditable surface.
buttonCancelLabelstringCancelCancel action label.
buttonSendLabelstringSendSend action label.
buttonSubmitLabelstring | undefinedundefinedOptional submit-label alias. When set, it takes precedence over buttonSendLabel.
toolbarAlwaysVisiblebooleanfalseKeeps the projected toolbar visible while the editor is expanded.
fullViewModebooleanfalseKeeps the editor in its expanded layout.
cancelButtonAlwaysVisiblebooleanfalseShows cancel independently of interactive expansion state.
allowEmptyContentbooleanfalseLegacy-compatible option allowing an empty send.
allowEmptybooleanfalseAllows an empty JSON document to be submitted.
autoClearbooleantrueClears the document and closes transient UI state after a successful send.
loadingbooleanfalseShows the send action loading state and prevents send/cancel.
disabledbooleanfalseDisables editing and component actions.
readOnlybooleanfalseKeeps content visible while preventing document mutations.
imageUploadFn(file: Blob) => Promise<string>data URL fallbackUploads an image and resolves its final URL. The editor inserts an immediate preview placeholder and retains rejected upload state.

Outputs

JSON-first submission with an HTML compatibility output.

NameTypeDefaultDescription
submittedNgsHeadlessEditorDocument—Emits the canonical JSON document on send.
sentstring—Emits escaped serialized HTML generated from the same JSON document.
canceledvoid—Emits after cancel clears content and transient toolbar/full-view state.

Component methods and signals

Public surface available through a template reference such as #editor.

NameTypeDefaultDescription
editorNgsHeadlessEditorscoped instanceSignal-based editor service owned by this Comment Editor.
apiCommentEditorAPIscoped facadeStable facade used by command directives and application code.
isEditorActivatedSignal<boolean>computedWhether the expanded editor layout is active.
isToolbarVisibleSignal<boolean>computedWhether the projected toolbar is currently rendered.
isBubbleMenuVisibleSignal<boolean>computedWhether a non-collapsed selection should show the projected bubble menu.
isCancelVisibleSignal<boolean>computedWhether the cancel action is currently visible.
sendDisabledSignal<boolean>computedCombines disabled, loading, allow-empty, and editor-empty state.
send(event?) / submit(event?)void—Emits JSON and HTML outputs, then applies autoClear.
cancel(event?)void—Clears content, resets transient view state, and emits canceled.
clear()void—Resets the scoped editor to an empty paragraph.
focus()void—Focuses the editor surface and restores its model selection.
showFullView() / hideFullView()void—Controls transient expanded state.
showToolbar() / hideToolbar() / toggleToolbar()void—Controls the projected toolbar.
insertText(text)void—Programmatically inserts text at the selection; a standalone emoji receives the single-emoji mark.
insertImage(file)void—Creates an upload placeholder, invokes imageUploadFn, and replaces or annotates the media block.
insertYoutube(url)boolean—Validates a YouTube URL and inserts a privacy-enhanced embed block.
setTextColor(color) / unsetTextColor()boolean—Applies or removes the textColor mark for the current selection or caret.
setBackgroundColor(color) / unsetBackgroundColor()boolean—Applies or removes the backgroundColor highlight mark for the current selection or caret.
setLink(url) / unsetLink()boolean—Applies, edits, or removes the link mark for the current text selection.

Projection components

The Comment Editor owns behavior and layout; applications project the controls they need.

NameTypeDefaultDescription
CommentEditorToolbarngs-comment-editor-toolbaroptionalProjected top formatting toolbar controlled by toolbar visibility state.
CommentEditorFooterBarngs-comment-editor-footer-baroptionalProjected footer tools placed before cancel and send actions.
CommentEditorBubbleMenungs-comment-editor-bubble-menuoptionalProjected selection menu with link preview, editing, and formatting controls.
CommentEditorDividerngs-comment-editor-divideroptionalVisual separator for projected command groups.

Command directives

Composable behavior for projected buttons. Combine formatting directives with ngsCommentEditorCommand.

NameTypeDefaultDescription
ngsCommentEditorCommanddirective—Applies the shared command button class.
ngsCommentEditorCommandBolddirectiveMod-bToggles bold and reflects active/disabled state.
ngsCommentEditorCommandItalicdirectiveMod-iToggles italic and reflects active/disabled state.
ngsCommentEditorCommandStrikedirectiveMod-Shift-xToggles strike.
ngsCommentEditorCommandCodedirectiveMod-eToggles inline code.
ngsCommentEditorCommandBlockquotedirectiveMod-Shift-bToggles the active text block between paragraph and blockquote.
ngsCommentEditorCommandCodeBlockdirectiveMod-Alt-cToggles a code block.
ngsCommentEditorCommandBulletListdirectiveMod-Shift-8Toggles a bullet-list block.
ngsCommentEditorCommandOrderedListdirectiveMod-Shift-7Toggles an ordered-list block.
ngsCommentEditorCommandLinkdirective—Opens the link dialog and applies a normalized link mark.
ngsCommentEditorCommandEditLinkdirective—Edits the active link from the bubble menu.
ngsCommentEditorCommandUnsetLinkdirective—Removes the active link mark.
ngsCommentEditorCommandImagedirectiveimage/*Opens file selection and forwards the chosen image to insertImage().
ngsCommentEditorCommandYoutubedirective—Opens the YouTube dialog and inserts a validated media block.
ngsCommentEditorCommandToggleToolbardirective—Toggles projected toolbar visibility and reflects active state.

Comment Editor plugin and serialization

Public building blocks used by the prebuilt component and available to custom Angular shells.

NameTypeDefaultDescription
colorEditorPlugin()NgsHeadlessEditorPlugininstalled by CommentEditorAdds text and background color marks and their set/unset commands.
commentEditorPlugin()NgsHeadlessEditorPlugininstalled by CommentEditorAdds blockquote, code block, list, image, upload, YouTube, link, and single-emoji definitions and commands.
createCommentEditorMediaBlock(type, attrs)NgsHeadlessEditorBlock<null>—Creates a serializable image, upload-placeholder, or YouTube block.
normalizeLinkUrl(value)string—Normalizes HTTP(S), mailto, and tel destinations and prefixes plain hosts with HTTPS.
normalizeYoutubeUrl(value)string | null—Accepts watch, short, shorts, or embed URLs and returns a youtube-nocookie embed URL.
serializeCommentEditorDocument(document)string—Serializes supported JSON blocks and marks to escaped HTML. Unresolved upload placeholders are omitted.