home / skills / harborgrid-justin / lexiflow-premium / rich-text-editor-engineering
/frontend/.github-skills/rich-text-editor-engineering
This skill helps you design and integrate a contenteditable editor with custom data models, ensuring safe HTML, cross-browser selection, and basic formatting.
npx playbooks add skill harborgrid-justin/lexiflow-premium --skill rich-text-editor-engineeringReview the files below or copy the command above to add this skill to your agents.
---
name: rich-text-editor-engineering
description: Integrate or build a contenteditable-based editor with custom data models.
---
# Rich Text Editor Engineering
## Summary
Integrate or build a contenteditable-based editor with custom data models.
## Key Capabilities
- Manage selection state.
- Normalize HTML and Delta content.
- Implement custom formatting operations.
## PhD-Level Challenges
- Cross-browser selection inconsistencies.
- Sanitize pasted HTML content.
- Sync model with view.
## Acceptance Criteria
- Implement basic formatting.
- Handle image pasting.
- Ensure safe HTML output.
This skill helps engineers integrate or build a contenteditable-based rich text editor that maps a DOM view to a custom data model. It focuses on selection management, HTML/Delta normalization, and implementing formatting operations while producing safe, predictable output. The guidance targets teams building editorial features for complex apps like legal management platforms.
The skill inspects and controls the contenteditable DOM, extracting and normalizing HTML fragments into a structured model (Delta or a JSON document). It maintains a canonical selection state and provides APIs for applying formatting, inserting images, and sanitizing pasted content. Sync logic reconciles model changes back to the DOM and emits validated, safe HTML for storage or display.
How do I handle cross-browser selection differences?
Abstract selection as model ranges and translate DOM selections into that model on every interaction; normalize edge cases and re-render selection from the model.
What’s the best way to sanitize pasted HTML?
Sanitize at paste: strip disallowed tags/attributes, convert safe constructs to model nodes, and reject executable content. Prefer whitelist-based rules and validate image sources.
How can I ensure safe HTML output?
Emit HTML only from your validated model, not raw DOM. Use escaping and a final sanitization pass before storage or rendering.