feat: Implement complete style-aware editor interface (Phase 2)

- Add StyleAwareEditor class with intelligent editing strategy detection
- Implement three editing modes: simple text, rich content, multi-property forms
- Create dynamic formatting toolbar with buttons for detected styles
- Add multi-property editing forms for complex elements (links, images, buttons)
- Integrate contentEditable with style application/removal functionality
- Replace markdown-based editor.js with style-aware architecture
- Add comprehensive CSS styling for modern, responsive editor interface
- Support fallback editing for error cases with graceful degradation
- Enable real-time style application to selected text in rich editor
- Preserve all element attributes and structure during editing workflow

Complete implementation of CLASSES.md style preservation specification.
Phase 2 foundation ready for final testing and refinement.
This commit is contained in:
2025-09-19 19:37:39 +02:00
parent 67f9f242b5
commit 3c4e83b302
7 changed files with 1863 additions and 20 deletions

View File

@@ -702,4 +702,310 @@ body:not(.insertr-edit-mode) .insertr-editing-hover::after {
margin-right: 0;
order: -1;
}
}/**
* Styles for StyleAwareEditor
* Clean, modern interface that integrates with existing Insertr styling
*/
/* Main editor container */
.insertr-style-aware-editor {
background: white;
border: 1px solid #d1d5db;
border-radius: 8px;
padding: 1rem;
min-width: 400px;
max-width: 600px;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
/* Style toolbar */
.insertr-style-toolbar {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.75rem;
background: #f9fafb;
border: 1px solid #e5e7eb;
border-radius: 6px;
margin-bottom: 1rem;
flex-wrap: wrap;
}
.insertr-toolbar-title {
font-size: 0.875rem;
font-weight: 500;
color: #6b7280;
margin-right: 0.5rem;
}
.insertr-style-btn {
background: white;
border: 1px solid #d1d5db;
border-radius: 4px;
padding: 0.375rem 0.75rem;
font-size: 0.875rem;
font-weight: 500;
color: #374151;
cursor: pointer;
transition: all 0.2s ease;
}
.insertr-style-btn:hover {
background: #f3f4f6;
border-color: #9ca3af;
}
.insertr-style-btn:active {
background: #e5e7eb;
transform: translateY(1px);
}
/* Simple text editor */
.insertr-simple-editor {
width: 100%;
border: 1px solid #d1d5db;
border-radius: 6px;
padding: 0.75rem;
font-size: 0.875rem;
line-height: 1.5;
resize: vertical;
font-family: inherit;
margin-bottom: 1rem;
}
.insertr-simple-editor:focus {
outline: none;
border-color: #3b82f6;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
/* Rich text editor */
.insertr-rich-editor {
width: 100%;
min-height: 100px;
border: 1px solid #d1d5db;
border-radius: 6px;
padding: 0.75rem;
font-size: 0.875rem;
line-height: 1.5;
margin-bottom: 1rem;
overflow-y: auto;
}
.insertr-rich-editor:focus {
outline: none;
border-color: #3b82f6;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
/* Multi-property editor */
.insertr-multi-property-editor {
margin-bottom: 1rem;
}
.insertr-styled-element-form {
background: #f9fafb;
border: 1px solid #e5e7eb;
border-radius: 6px;
padding: 1rem;
margin-bottom: 1rem;
}
.insertr-styled-element-form:last-child {
margin-bottom: 0;
}
.insertr-form-header {
margin: 0 0 0.75rem 0;
font-size: 1rem;
font-weight: 600;
color: #374151;
}
/* Property inputs */
.insertr-property-input,
.insertr-text-input {
margin-bottom: 0.75rem;
}
.insertr-property-input:last-child,
.insertr-text-input:last-child {
margin-bottom: 0;
}
.insertr-property-label,
.insertr-input-label {
display: block;
font-size: 0.875rem;
font-weight: 500;
color: #374151;
margin-bottom: 0.25rem;
}
.insertr-property-field,
.insertr-text-field {
width: 100%;
border: 1px solid #d1d5db;
border-radius: 4px;
padding: 0.5rem;
font-size: 0.875rem;
line-height: 1.4;
font-family: inherit;
transition: border-color 0.2s ease;
}
.insertr-property-field:focus,
.insertr-text-field:focus {
outline: none;
border-color: #3b82f6;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
/* URL inputs */
.insertr-property-field[type="url"] {
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
font-size: 0.8125rem;
}
/* Form actions */
.insertr-form-actions {
display: flex;
gap: 0.75rem;
justify-content: flex-end;
padding-top: 1rem;
border-top: 1px solid #e5e7eb;
}
.insertr-btn-save,
.insertr-btn-cancel {
padding: 0.5rem 1rem;
font-size: 0.875rem;
font-weight: 500;
border-radius: 6px;
cursor: pointer;
transition: all 0.2s ease;
border: 1px solid;
}
.insertr-btn-save {
background: #3b82f6;
border-color: #3b82f6;
color: white;
}
.insertr-btn-save:hover {
background: #2563eb;
border-color: #2563eb;
}
.insertr-btn-cancel {
background: white;
border-color: #d1d5db;
color: #374151;
}
.insertr-btn-cancel:hover {
background: #f9fafb;
border-color: #9ca3af;
}
/* Fallback editor */
.insertr-fallback-editor {
background: white;
border: 1px solid #d1d5db;
border-radius: 8px;
padding: 1rem;
min-width: 400px;
max-width: 500px;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}
.insertr-fallback-textarea {
width: 100%;
border: 1px solid #d1d5db;
border-radius: 6px;
padding: 0.75rem;
font-size: 0.875rem;
line-height: 1.5;
resize: vertical;
font-family: inherit;
margin-bottom: 1rem;
}
.insertr-fallback-textarea:focus {
outline: none;
border-color: #3b82f6;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
/* Responsive adjustments */
@media (max-width: 640px) {
.insertr-style-aware-editor,
.insertr-fallback-editor {
min-width: 300px;
max-width: calc(100vw - 2rem);
margin: 1rem;
}
.insertr-style-toolbar {
padding: 0.5rem;
gap: 0.375rem;
}
.insertr-style-btn {
padding: 0.25rem 0.5rem;
font-size: 0.8125rem;
}
.insertr-form-actions {
flex-direction: column;
}
.insertr-btn-save,
.insertr-btn-cancel {
width: 100%;
}
}
/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
.insertr-style-aware-editor,
.insertr-fallback-editor {
background: #1f2937;
border-color: #374151;
color: #f9fafb;
}
.insertr-style-toolbar,
.insertr-styled-element-form {
background: #111827;
border-color: #374151;
}
.insertr-style-btn {
background: #374151;
border-color: #4b5563;
color: #f9fafb;
}
.insertr-style-btn:hover {
background: #4b5563;
border-color: #6b7280;
}
.insertr-property-field,
.insertr-text-field,
.insertr-simple-editor,
.insertr-fallback-textarea {
background: #374151;
border-color: #4b5563;
color: #f9fafb;
}
.insertr-rich-editor {
background: #374151;
border-color: #4b5563;
color: #f9fafb;
}
}