mirror of
https://github.com/maputnik/editor.git
synced 2026-10-17 00:13:44 +00:00
Add font-faces, sky, roll and centerAltitude (#2189)
After: <img width="425" height="366" alt="image" src="https://github.com/user-attachments/assets/f737de31-57e8-4445-b114-a5acdabb619c" /> ## Launch Checklist - [x] Briefly describe the changes in this PR. - [x] Include before/after visuals or gifs if this PR includes visual changes. - [x] Write tests for all new functionality. - [x] Add an entry to `CHANGELOG.md` under the `## main` section.
This commit is contained in:
@@ -15,6 +15,21 @@ type LinterError = {
|
||||
message: string;
|
||||
};
|
||||
|
||||
|
||||
type EditorProps = {
|
||||
parent: HTMLElement,
|
||||
value: string,
|
||||
lintType: LintType,
|
||||
onChange: (value: string) => void,
|
||||
onFocus: () => void,
|
||||
onBlur: () => void,
|
||||
spec?: StylePropertySpecification,
|
||||
/**
|
||||
* An empty optional editor means the value is unset, which is valid
|
||||
*/
|
||||
optional?: boolean,
|
||||
};
|
||||
|
||||
function getDiagnosticsFromExpressionErrors(errors: LinterError[], ast: ValueNode | PropertyNode) {
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
for (const error of errors) {
|
||||
@@ -128,15 +143,7 @@ function createMaplibreExpressionLinter(spec?: StylePropertySpecification) {
|
||||
};
|
||||
}
|
||||
|
||||
export function createEditor(props: {
|
||||
parent: HTMLElement,
|
||||
value: string,
|
||||
lintType: LintType,
|
||||
onChange: (value: string) => void,
|
||||
onFocus: () => void,
|
||||
onBlur: () => void,
|
||||
spec?: StylePropertySpecification,
|
||||
}): EditorView {
|
||||
export function createEditor(props: EditorProps): EditorView {
|
||||
let specificLinter: (view: EditorView) => Diagnostic[] = () => [];
|
||||
switch (props.lintType) {
|
||||
case "style":
|
||||
@@ -181,6 +188,9 @@ export function createEditor(props: {
|
||||
}),
|
||||
lintGutter(),
|
||||
linter((view: EditorView) => {
|
||||
if (props.optional && view.state.doc.toString().trim() === "") {
|
||||
return [];
|
||||
}
|
||||
const jsonErrors = jsonParseLinter()(view);
|
||||
if (jsonErrors.length > 0) {
|
||||
return jsonErrors;
|
||||
|
||||
Reference in New Issue
Block a user