Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/css/common/_codemirror.scss
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,57 @@
margin-inline: 0.25em;
font-weight: bold;
}

// WordPress core styles the dialog it builds around this markup with
// '.CodeMirror-dialog input' and button rules, so the dialog's own selectors
// stay scoped here to outrank those.
.CodeMirror-dialog {
.cs-editor-search-status.is-no-results {
color: var(--cs-color-error);
font-weight: 600;
white-space: normal;
}

.cs-editor-search-close {
padding: 2px 10px;
border: 1px solid var(--cs-color-border);
border-radius: var(--cs-control-radius);
background: var(--cs-color-surface);
color: var(--cs-color-text);
cursor: pointer;
font-size: inherit;
}

.cs-editor-search-form {
display: flex;
flex-wrap: wrap;
gap: 6px 8px;
align-items: center;
padding: 6px 8px;
background: var(--cs-color-surface-subtle);
border-block-end: 1px solid var(--cs-color-border-subtle);
font-size: 13px;
cursor: text;
}

.cs-editor-search-field {
flex: 1 0 14em;
min-inline-size: 14em;
padding: 3px 8px;
background: var(--cs-color-surface);
border: 1px solid var(--cs-color-border);
border-radius: var(--cs-control-radius);
}

.cs-editor-search-field:focus-visible,
.cs-editor-search-close:focus-visible {
outline: 2px solid var(--cs-color-accent);
outline-offset: 1px;
}

.cs-editor-search-status {
color: var(--cs-color-text-muted);
white-space: nowrap;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({ isExpanded, setIsExpande

codeEditorInstance.codemirror.setOption('extraKeys', {
...'object' === typeof extraKeys ? extraKeys : undefined,
[`${controlKey}-F`]: 'findPersistent',
[`${controlKey}-S`]: onSave,
[`${controlKey}-Enter`]: onSave
})
Expand Down
3 changes: 3 additions & 0 deletions src/js/entries/editor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineMode, getMode, registerHelper } from 'codemirror'
import { registerPersistentSearch } from '../utils/editorSearch'
import { Linter } from '../utils/Linter'
import type { EditorConfiguration, ModeSpec } from 'codemirror'

Expand All @@ -13,6 +14,8 @@ const mode: ModeSpec<ModeSpecOptions> = {

defineMode('php-snippet', (config: EditorConfiguration) => getMode(config, mode))

registerPersistentSearch()

registerHelper('lint', 'php', (text: string) => {
const linter = new Linter(text)
linter.lint()
Expand Down
Loading