Files
dashboards/packages/dashboard-ui/src/components/RichTextEditor.module.css
T
Alireza HassaniandCursor ac287e02cc Sanitize rich-text paste and allow empty business postal codes.
Strip background/font-family/colors on paste while keeping bold, lists, and font size; treat business address postal code as optional.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-04 18:42:21 +03:30

361 lines
6.8 KiB
CSS

.wrapper {
width: 100%;
max-width: 100%;
min-width: 0;
border: 1px solid rgba(148, 163, 184, 0.35);
border-radius: var(--radius-sm);
background: var(--surface);
overflow: visible;
transition: border-color 0.2s, box-shadow 0.2s;
box-sizing: border-box;
}
.wrapper:focus-within {
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(var(--primary-rgb) / 0.12);
}
.toolbar {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 2px;
padding: 4px 6px;
border-bottom: 1px solid rgba(148, 163, 184, 0.2);
background: var(--elevated-surface);
position: relative;
z-index: 2;
}
.toolbar button {
width: 28px;
height: 28px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 6px;
color: var(--text-secondary);
transition: background 0.15s, color 0.15s;
}
.toolbar button:hover:not(:disabled) {
background: rgba(var(--primary-rgb) / 0.1);
color: var(--primary);
}
.toolbar button:disabled {
opacity: 0.45;
cursor: not-allowed;
}
.toolbar button.toolbarBtnActive {
background: rgba(var(--primary-rgb) / 0.1);
color: var(--primary);
}
.dirBtn {
width: auto;
min-width: 34px;
padding: 0 6px;
font-size: 11px;
font-weight: 600;
letter-spacing: 0.02em;
}
.toolbar button.codeModeBtn {
width: auto;
min-width: 28px;
padding: 0 8px;
gap: 4px;
font-size: 11px;
font-weight: 600;
letter-spacing: 0.02em;
}
.fontSizeSelect:disabled {
opacity: 0.45;
cursor: not-allowed;
}
.fontSizeWrap {
display: inline-flex;
align-items: center;
}
.fontSizeSelect {
appearance: none;
-webkit-appearance: none;
width: auto;
min-width: 52px;
height: 28px;
padding: 0 22px 0 8px;
border: 1px solid rgba(148, 163, 184, 0.35);
border-radius: 6px;
background-color: transparent;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 4px center;
background-size: 12px;
color: var(--text-secondary);
font-size: 11px;
font-weight: 600;
font-family: var(--font-ui);
line-height: 1;
cursor: pointer;
}
.fontSizeSelect:hover,
.fontSizeSelect:focus {
border-color: var(--primary);
color: var(--primary);
outline: none;
}
.srOnly {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
.divider {
width: 1px;
height: 20px;
background: rgba(148, 163, 184, 0.3);
margin: 0 4px;
}
.colorPickerWrap {
position: relative;
width: 28px;
height: 28px;
}
.colorBtn {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 3px;
width: 28px;
height: 28px;
border-radius: 6px;
color: var(--text-secondary);
transition: background 0.15s, color 0.15s;
}
.colorBtn:hover,
.colorBtnActive {
background: rgba(var(--primary-rgb) / 0.1);
color: var(--primary);
}
.colorSwatch {
width: 14px;
height: 3px;
margin-top: 1px;
border-radius: 2px;
background: var(--text-primary);
}
.colorPopover {
position: absolute;
top: calc(100% + 6px);
left: 50%;
transform: translateX(-50%);
z-index: 20;
display: flex;
flex-direction: column;
gap: 8px;
min-width: 168px;
padding: 10px;
border: 1px solid rgba(148, 163, 184, 0.35);
border-radius: var(--radius-sm);
background: var(--elevated-surface);
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}
.colorVisualInput {
width: 100%;
height: 32px;
padding: 0;
border: 1px solid rgba(148, 163, 184, 0.35);
border-radius: 6px;
cursor: pointer;
background: transparent;
}
.hexField {
display: flex;
flex-direction: column;
gap: 4px;
}
.hexLabel {
font-size: 11px;
font-weight: 600;
letter-spacing: 0.04em;
color: var(--text-muted);
}
.hexInput {
min-height: var(--field-height);
padding: var(--field-padding-y) var(--field-padding-x);
border: 1px solid rgba(148, 163, 184, 0.35);
border-radius: var(--radius-sm);
background: var(--elevated-surface);
font-size: var(--field-font-size);
font-family: var(--font-ui);
color: var(--text-primary);
text-transform: uppercase;
}
.hexInput:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(var(--primary-rgb) / 0.12);
}
.editorShell {
position: relative;
width: 100%;
max-width: 100%;
min-width: 0;
overflow: hidden;
}
.editor {
width: 100%;
max-width: 100%;
min-width: 0;
min-height: 140px;
padding: var(--field-padding-y) var(--field-padding-x);
padding-bottom: 40px;
font-size: var(--field-font-size);
line-height: 1.5;
color: var(--text-primary);
outline: none;
box-sizing: border-box;
overflow-x: hidden;
overflow-wrap: break-word;
word-break: break-word;
unicode-bidi: isolate;
}
.editor:empty::before {
content: attr(data-placeholder);
color: var(--text-muted);
pointer-events: none;
}
.codeEditor {
display: block;
width: 100%;
max-width: 100%;
min-width: 0;
min-height: 140px;
padding: var(--field-padding-y) var(--field-padding-x);
border: 0;
resize: vertical;
outline: none;
box-sizing: border-box;
background: var(--elevated-surface);
color: var(--text-primary);
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
monospace;
font-size: 12px;
line-height: 1.55;
white-space: pre-wrap;
overflow-wrap: break-word;
word-break: break-word;
unicode-bidi: isolate;
direction: ltr;
}
.codeEditor::placeholder {
color: var(--text-muted);
font-family: var(--font-ui);
}
.editor > * {
max-width: 100%;
box-sizing: border-box;
}
.editor ul,
.editor ol {
padding-inline-start: 1.5em;
padding-inline-end: 0;
margin: 0.5em 0;
}
.editor p {
margin: 0 0 0.5em;
}
.editor p:last-child {
margin-bottom: 0;
}
.editor b,
.editor strong {
font-weight: 700;
}
.editor i,
.editor em {
font-style: italic;
}
.editor u {
text-decoration: underline;
}
.editor blockquote {
margin: 0.5em 0;
margin-inline-start: 1.5em;
margin-inline-end: 0;
padding: 0;
border: 0;
}
.editor img {
max-width: 100%;
height: auto;
border-radius: var(--radius-sm);
margin: 0.5em 0;
cursor: pointer;
}
.editor img.richTextImageSelected {
outline: 2px solid var(--primary);
outline-offset: 2px;
}
.resizeHandle {
position: absolute;
width: 12px;
height: 12px;
border: 2px solid white;
border-radius: 3px;
background: var(--primary);
box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
cursor: nwse-resize;
z-index: 2;
padding: 0;
}
.uploadError {
margin: 0;
padding: 6px 10px;
font-size: 12px;
color: #b91c1c;
background: rgba(239, 68, 68, 0.08);
border-bottom: 1px solid rgba(239, 68, 68, 0.15);
}