mirror of
https://github.com/maputnik/editor.git
synced 2025-12-06 06:10:00 +00:00
Compare commits
7 Commits
19d520426f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79bcf135a4 | ||
|
|
99b92832bb | ||
|
|
d209bcf81a | ||
|
|
a1f57daacc | ||
|
|
a075259261 | ||
|
|
c168e65d86 | ||
|
|
8095b0d641 |
6
.github/workflows/codeql-analysis.yml
vendored
6
.github/workflows/codeql-analysis.yml
vendored
@@ -42,7 +42,7 @@ jobs:
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4.31.5
|
||||
uses: github/codeql-action/init@fe4161a26a8629af62121b670040955b330f9af2 # v4.31.6
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
@@ -53,7 +53,7 @@ jobs:
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4.31.5
|
||||
uses: github/codeql-action/autobuild@fe4161a26a8629af62121b670040955b330f9af2 # v4.31.6
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
@@ -67,4 +67,4 @@ jobs:
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4.31.5
|
||||
uses: github/codeql-action/analyze@fe4161a26a8629af62121b670040955b330f9af2 # v4.31.6
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
- Fix issue with missing bottom error panel
|
||||
- Fixed headers in left panes (Layers list and Layer editor) to remain visible when scrolling
|
||||
- Fix error when using a source from localhost
|
||||
- Fix an issue with scrolling when using the code editor
|
||||
- _...Add new stuff here..._
|
||||
|
||||
## 3.0.0
|
||||
|
||||
@@ -178,11 +178,11 @@ describe("modals", () => {
|
||||
});
|
||||
|
||||
it("sprite object", () => {
|
||||
when.setTextInJsonEditor(JSON.stringify([{id: "1", url: "2"}]));
|
||||
when.setTextInJsonEditor(JSON.stringify([{ id: "1", url: "2" }]));
|
||||
|
||||
when.click("modal:settings.name");
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
sprite: [{ id: "1", url: "2"}],
|
||||
sprite: [{ id: "1", url: "2" }],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -342,8 +342,8 @@ describe("modals", () => {
|
||||
});
|
||||
|
||||
it("add variable", () => {
|
||||
when.click("global-state-add-variable");
|
||||
when.wait(100);
|
||||
when.click("global-state-add-variable");
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
state: { key1: { default: "value" } },
|
||||
});
|
||||
@@ -373,6 +373,7 @@ describe("modals", () => {
|
||||
|
||||
it("edit variable key", () => {
|
||||
when.click("global-state-add-variable");
|
||||
when.wait(100);
|
||||
when.setValue("global-state-variable-key:0", "mykey");
|
||||
when.typeKeys("{enter}");
|
||||
when.wait(100);
|
||||
@@ -383,6 +384,7 @@ describe("modals", () => {
|
||||
|
||||
it("edit variable value", () => {
|
||||
when.click("global-state-add-variable");
|
||||
when.wait(100);
|
||||
when.setValue("global-state-variable-value:0", "myvalue");
|
||||
when.typeKeys("{enter}");
|
||||
when.wait(100);
|
||||
|
||||
32
package-lock.json
generated
32
package-lock.json
generated
@@ -19,7 +19,7 @@
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"@mapbox/mapbox-gl-rtl-text": "^0.3.0",
|
||||
"@maplibre/maplibre-gl-geocoder": "^1.9.1",
|
||||
"@maplibre/maplibre-gl-inspect": "^1.8.0",
|
||||
"@maplibre/maplibre-gl-inspect": "^1.8.1",
|
||||
"@maplibre/maplibre-gl-style-spec": "^24.3.1",
|
||||
"array-move": "^4.0.0",
|
||||
"buffer": "^6.0.3",
|
||||
@@ -27,10 +27,10 @@
|
||||
"codemirror": "^6.0.2",
|
||||
"color": "^5.0.3",
|
||||
"detect-browser": "^5.3.0",
|
||||
"downshift": "^9.0.10",
|
||||
"downshift": "^9.0.12",
|
||||
"events": "^3.3.0",
|
||||
"file-saver": "^2.0.5",
|
||||
"i18next": "^25.6.3",
|
||||
"i18next": "^25.7.1",
|
||||
"i18next-browser-languagedetector": "^8.2.0",
|
||||
"i18next-resources-to-backend": "^1.2.1",
|
||||
"json-stringify-pretty-compact": "^4.0.0",
|
||||
@@ -68,7 +68,7 @@
|
||||
"@eslint/js": "^9.39.1",
|
||||
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
||||
"@rollup/plugin-replace": "^6.0.2",
|
||||
"@shellygo/cypress-test-utils": "^6.0.4",
|
||||
"@shellygo/cypress-test-utils": "^6.0.5",
|
||||
"@stylistic/eslint-plugin": "^5.6.1",
|
||||
"@types/codemirror": "^5.60.17",
|
||||
"@types/color": "^4.2.0",
|
||||
@@ -2156,9 +2156,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@maplibre/maplibre-gl-inspect": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-inspect/-/maplibre-gl-inspect-1.8.0.tgz",
|
||||
"integrity": "sha512-uRufOTPg4tXDYc+W8fVHbvSN2m2ThPy1ASmL7wvnQMObOKu738bA7M1fwZeCNsqDERb2nT4tW6bi4EYzUjGv2g==",
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-inspect/-/maplibre-gl-inspect-1.8.1.tgz",
|
||||
"integrity": "sha512-Wh+MpaksNNWwA6wyH94D0gNzJdd4fFeImO2nqLDO1AxdF4NAML+HTrLE3XjWmVSPOZ7dDi/0IAZ8dc4IakyT0g==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"lodash.isequal": "^4.5.0",
|
||||
@@ -2964,9 +2964,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@shellygo/cypress-test-utils": {
|
||||
"version": "6.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@shellygo/cypress-test-utils/-/cypress-test-utils-6.0.4.tgz",
|
||||
"integrity": "sha512-dGi1/3tCo1kju5Ub7HOeaG9IrC+e4l0KioNfpFgmmneB+iET6ZURFBbWuI6XOq9V3B4NVG0Xq24Gws5n8WWijw==",
|
||||
"version": "6.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@shellygo/cypress-test-utils/-/cypress-test-utils-6.0.5.tgz",
|
||||
"integrity": "sha512-86GhiBqmHQPoMHyzKNSuZrYPETkPtZA10nkW3l1xk7MJgx78fEZzx3vIIiE6mzDxpYmpmJo1igWx+vo30U33YA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -6140,9 +6140,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/downshift": {
|
||||
"version": "9.0.10",
|
||||
"resolved": "https://registry.npmjs.org/downshift/-/downshift-9.0.10.tgz",
|
||||
"integrity": "sha512-TP/iqV6bBok6eGD5tZ8boM8Xt7/+DZvnVNr8cNIhbAm2oUBd79Tudiccs2hbcV9p7xAgS/ozE7Hxy3a9QqS6Mw==",
|
||||
"version": "9.0.12",
|
||||
"resolved": "https://registry.npmjs.org/downshift/-/downshift-9.0.12.tgz",
|
||||
"integrity": "sha512-kFq2pNHm3kmhFfW55RW7+lXliEHg98sKImodICvJfbtvRB6OUiLr138Z8MW5/8t5JaeGZ4Wtomi3Ds72EKVH2Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.24.5",
|
||||
@@ -8343,9 +8343,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/i18next": {
|
||||
"version": "25.6.3",
|
||||
"resolved": "https://registry.npmjs.org/i18next/-/i18next-25.6.3.tgz",
|
||||
"integrity": "sha512-AEQvoPDljhp67a1+NsnG/Wb1Nh6YoSvtrmeEd24sfGn3uujCtXCF3cXpr7ulhMywKNFF7p3TX1u2j7y+caLOJg==",
|
||||
"version": "25.7.1",
|
||||
"resolved": "https://registry.npmjs.org/i18next/-/i18next-25.7.1.tgz",
|
||||
"integrity": "sha512-XbTnkh1yCZWSAZGnA9xcQfHcYNgZs2cNxm+c6v1Ma9UAUGCeJPplRe1ILia6xnDvXBjk0uXU+Z8FYWhA19SKFw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"@mapbox/mapbox-gl-rtl-text": "^0.3.0",
|
||||
"@maplibre/maplibre-gl-geocoder": "^1.9.1",
|
||||
"@maplibre/maplibre-gl-inspect": "^1.8.0",
|
||||
"@maplibre/maplibre-gl-inspect": "^1.8.1",
|
||||
"@maplibre/maplibre-gl-style-spec": "^24.3.1",
|
||||
"array-move": "^4.0.0",
|
||||
"buffer": "^6.0.3",
|
||||
@@ -44,10 +44,10 @@
|
||||
"codemirror": "^6.0.2",
|
||||
"color": "^5.0.3",
|
||||
"detect-browser": "^5.3.0",
|
||||
"downshift": "^9.0.10",
|
||||
"downshift": "^9.0.12",
|
||||
"events": "^3.3.0",
|
||||
"file-saver": "^2.0.5",
|
||||
"i18next": "^25.6.3",
|
||||
"i18next": "^25.7.1",
|
||||
"i18next-browser-languagedetector": "^8.2.0",
|
||||
"i18next-resources-to-backend": "^1.2.1",
|
||||
"json-stringify-pretty-compact": "^4.0.0",
|
||||
@@ -102,7 +102,7 @@
|
||||
"@eslint/js": "^9.39.1",
|
||||
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
||||
"@rollup/plugin-replace": "^6.0.2",
|
||||
"@shellygo/cypress-test-utils": "^6.0.4",
|
||||
"@shellygo/cypress-test-utils": "^6.0.5",
|
||||
"@stylistic/eslint-plugin": "^5.6.1",
|
||||
"@types/codemirror": "^5.60.17",
|
||||
"@types/color": "^4.2.0",
|
||||
|
||||
@@ -19,6 +19,7 @@ const CodeEditorInternal: React.FC<CodeEditorProps> = (props) => {
|
||||
value={props.value}
|
||||
onChange={props.onChange}
|
||||
className={"maputnik-code-editor"}
|
||||
withScroll={true}
|
||||
/>;
|
||||
</>;
|
||||
};
|
||||
|
||||
@@ -7,6 +7,7 @@ import stringifyPretty from "json-stringify-pretty-compact";
|
||||
|
||||
import {createEditor} from "../libs/codemirror-editor-factory";
|
||||
import type { StylePropertySpecification } from "maplibre-gl";
|
||||
import type { TransactionSpec } from "@codemirror/state";
|
||||
|
||||
export type InputJsonProps = {
|
||||
value: object
|
||||
@@ -16,6 +17,11 @@ export type InputJsonProps = {
|
||||
onBlur?(...args: unknown[]): unknown
|
||||
lintType: "layer" | "style" | "expression" | "json"
|
||||
spec?: StylePropertySpecification | undefined
|
||||
/**
|
||||
* When setting this and using search and replace, the editor will scroll to the selected text
|
||||
* Use this only when the editor is the only element in the page.
|
||||
*/
|
||||
withScroll?: boolean
|
||||
};
|
||||
type InputJsonInternalProps = InputJsonProps & WithTranslation;
|
||||
|
||||
@@ -28,6 +34,7 @@ class InputJsonInternal extends React.Component<InputJsonInternalProps, InputJso
|
||||
static defaultProps = {
|
||||
onFocus: () => {},
|
||||
onBlur: () => {},
|
||||
withScroll: false
|
||||
};
|
||||
_view: EditorView | undefined;
|
||||
_el: HTMLDivElement | null = null;
|
||||
@@ -74,16 +81,18 @@ class InputJsonInternal extends React.Component<InputJsonInternalProps, InputJso
|
||||
componentDidUpdate(prevProps: InputJsonProps) {
|
||||
if (!this.state.isEditing && prevProps.value !== this.props.value) {
|
||||
this._cancelNextChange = true;
|
||||
const currentSelection = this._view!.state.selection;
|
||||
this._view!.dispatch({
|
||||
const transactionSpec: TransactionSpec = {
|
||||
changes: {
|
||||
from: 0,
|
||||
to: this._view!.state.doc.length,
|
||||
insert: this.getPrettyJson(this.props.value)
|
||||
},
|
||||
selection: currentSelection,
|
||||
scrollIntoView: true
|
||||
});
|
||||
}
|
||||
};
|
||||
if (this.props.withScroll) {
|
||||
transactionSpec.selection = this._view!.state.selection;
|
||||
transactionSpec.scrollIntoView = true;
|
||||
}
|
||||
this._view!.dispatch(transactionSpec);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user