feat(editor): blog editor element with exact untouched value
- golem15-journal-blogeditor (BlogEditorElement): light-DOM element with a TipTap WYSIWYG tab and a Source tab that edits the exact HTML string - The value is the exact served string until a user edit; external values go in with emitUpdate false; summer-change fires on user edits only and an echo set is a no-op - StarterKit without the trailing node, links without target, rel or class; injectCSS false with the ProseMirror base rules in blogeditor.css under the element tag, colours from --c-* only - Committed bundle embedded through admin.go; vitest smoke on an imported post fixture (footer, style block, spans, figure, table, entities)
This commit is contained in:
229
assets/src/blogeditor/blogeditor.css
Normal file
229
assets/src/blogeditor/blogeditor.css
Normal file
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Blog Editor styles (D-13). Every selector sits under the element tag and
|
||||
* every colour comes from the admin's public --c-* variables; TipTap's own
|
||||
* injected stylesheet is off (injectCSS false), so its ProseMirror base
|
||||
* rules are repeated here.
|
||||
*/
|
||||
|
||||
golem15-journal-blogeditor {
|
||||
display: block;
|
||||
border: 1px solid var(--c-border);
|
||||
border-radius: 12px;
|
||||
background: var(--c-surface);
|
||||
color: var(--c-text);
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor[invalid] {
|
||||
border-color: var(--c-danger);
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .blogeditor__bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 6px 8px;
|
||||
border-bottom: 1px solid var(--c-border);
|
||||
background: var(--c-subtle);
|
||||
border-radius: 12px 12px 0 0;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .blogeditor__tabs {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor button {
|
||||
font: inherit;
|
||||
font-size: 13px;
|
||||
line-height: 1.2;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: var(--c-text);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor button:hover {
|
||||
background: var(--c-hover);
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor button:focus-visible {
|
||||
outline: 2px solid var(--c-ring);
|
||||
outline-offset: 1px;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor button[aria-selected="true"],
|
||||
golem15-journal-blogeditor button[aria-pressed="true"] {
|
||||
background: var(--c-sel);
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor button:disabled {
|
||||
color: var(--c-muted);
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .blogeditor__content {
|
||||
min-height: 240px;
|
||||
max-height: 70vh;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .blogeditor__source {
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
min-height: 320px;
|
||||
padding: 12px 16px;
|
||||
border: 0;
|
||||
border-radius: 0 0 12px 12px;
|
||||
background: var(--c-bg);
|
||||
color: var(--c-text);
|
||||
font-family: "DM Mono", ui-monospace, monospace;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .blogeditor__source:focus {
|
||||
outline: 2px solid var(--c-ring);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor [hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* ProseMirror base rules (TipTap's injected style, repeated here). */
|
||||
golem15-journal-blogeditor .ProseMirror {
|
||||
position: relative;
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
white-space: break-spaces;
|
||||
-webkit-font-variant-ligatures: none;
|
||||
font-variant-ligatures: none;
|
||||
font-feature-settings: "liga" 0;
|
||||
min-height: 240px;
|
||||
padding: 12px 16px;
|
||||
outline: none;
|
||||
font-size: 15px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror[contenteditable="false"] {
|
||||
color: var(--c-muted);
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror [contenteditable="false"] {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror pre {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor img.ProseMirror-separator {
|
||||
display: inline !important;
|
||||
border: none !important;
|
||||
margin: 0 !important;
|
||||
width: 0 !important;
|
||||
height: 0 !important;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror-gapcursor {
|
||||
display: none;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror-gapcursor::after {
|
||||
content: "";
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: -2px;
|
||||
width: 20px;
|
||||
border-top: 1px solid var(--c-text);
|
||||
animation: blogeditor-cursor-blink 1.1s steps(2, start) infinite;
|
||||
}
|
||||
|
||||
@keyframes blogeditor-cursor-blink {
|
||||
to {
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror-hideselection *::selection {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror-hideselection * {
|
||||
caret-color: transparent;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror-focused .ProseMirror-gapcursor {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Content. */
|
||||
golem15-journal-blogeditor .ProseMirror > * + * {
|
||||
margin-top: 0.75em;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror :where(p, ul, ol, blockquote, table, figure, pre) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror h2 { font-size: 1.5em; font-weight: 600; margin: 1em 0 0.5em; }
|
||||
golem15-journal-blogeditor .ProseMirror h3 { font-size: 1.25em; font-weight: 600; margin: 1em 0 0.5em; }
|
||||
golem15-journal-blogeditor .ProseMirror h4 { font-size: 1.1em; font-weight: 600; margin: 1em 0 0.5em; }
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror ul { list-style: disc; padding-left: 1.5em; }
|
||||
golem15-journal-blogeditor .ProseMirror ol { list-style: decimal; padding-left: 1.5em; }
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror a {
|
||||
color: var(--c-primary);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror blockquote {
|
||||
margin-left: 0;
|
||||
padding-left: 1em;
|
||||
border-left: 3px solid var(--c-border-strong);
|
||||
color: var(--c-muted);
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror code {
|
||||
padding: 0 4px;
|
||||
border-radius: 4px;
|
||||
background: var(--c-subtle);
|
||||
font-family: "DM Mono", ui-monospace, monospace;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror pre {
|
||||
padding: 8px 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--c-subtle);
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror pre code {
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror hr {
|
||||
border: 0;
|
||||
border-top: 1px solid var(--c-border-strong);
|
||||
}
|
||||
|
||||
golem15-journal-blogeditor .ProseMirror img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
Reference in New Issue
Block a user