Update @codemirror/view to latest (#18550)
This commit is contained in:
1 parent
717731d4b5
commit
8903d89377
5 files changed
+45
-54
No files matched your search
@@ -94,8 +94,6 @@
|
|||||||
"prettier",
|
"prettier",
|
||||||
// Old versions are required to test
|
// Old versions are required to test
|
||||||
"node",
|
"node",
|
||||||
// Only pinned version works, https://github.com/prettier/prettier/pull/18524#issuecomment-3694806317
|
|
||||||
"@codemirror/view",
|
|
||||||
],
|
],
|
||||||
ignorePaths: ["tests/**", "packages/**"],
|
ignorePaths: ["tests/**", "packages/**"],
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
"@codemirror/language-data": "6.5.2",
|
"@codemirror/language-data": "6.5.2",
|
||||||
"@codemirror/lint": "6.9.2",
|
"@codemirror/lint": "6.9.2",
|
||||||
"@codemirror/state": "6.5.3",
|
"@codemirror/state": "6.5.3",
|
||||||
"@codemirror/view": "6.39.4",
|
"@codemirror/view": "6.39.8",
|
||||||
"@docusaurus/preset-classic": "3.9.2",
|
"@docusaurus/preset-classic": "3.9.2",
|
||||||
"@lezer/highlight": "1.2.3",
|
"@lezer/highlight": "1.2.3",
|
||||||
"@mdx-js/react": "3.1.1",
|
"@mdx-js/react": "3.1.1",
|
||||||
@@ -53,9 +53,6 @@
|
|||||||
"vite": "7.2.7",
|
"vite": "7.2.7",
|
||||||
"yaml": "2.8.2"
|
"yaml": "2.8.2"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
|
||||||
"@codemirror/view": "6.39.4"
|
|
||||||
},
|
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [
|
||||||
">0.5%",
|
">0.5%",
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ function setup(props, { emit }) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const componentDidMount = async () => {
|
const componentDidMount = () => {
|
||||||
const options = { ...props };
|
const options = { ...props };
|
||||||
for (const property of [
|
for (const property of [
|
||||||
"ruler",
|
"ruler",
|
||||||
@@ -117,8 +117,6 @@ function setup(props, { emit }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const lang = await getLanguageExtension(props.mode);
|
|
||||||
|
|
||||||
const state = EditorState.create({
|
const state = EditorState.create({
|
||||||
doc: props.value || "",
|
doc: props.value || "",
|
||||||
extensions: [
|
extensions: [
|
||||||
@@ -134,7 +132,7 @@ function setup(props, { emit }) {
|
|||||||
props.autoCloseBrackets ? closeBrackets() : undefined,
|
props.autoCloseBrackets ? closeBrackets() : undefined,
|
||||||
props.matchBrackets ? bracketMatching() : undefined,
|
props.matchBrackets ? bracketMatching() : undefined,
|
||||||
|
|
||||||
languageExt.of(lang),
|
languageExt.of([]),
|
||||||
editorTheme.of(
|
editorTheme.of(
|
||||||
theme.value === "dark" ? catppuccinMocha : catppuccinLatte,
|
theme.value === "dark" ? catppuccinMocha : catppuccinLatte,
|
||||||
),
|
),
|
||||||
@@ -183,30 +181,19 @@ function setup(props, { emit }) {
|
|||||||
|
|
||||||
updateSelection();
|
updateSelection();
|
||||||
updateOverlay();
|
updateOverlay();
|
||||||
|
updateMode();
|
||||||
};
|
};
|
||||||
|
|
||||||
const componentWillUnmount = () => {
|
const componentWillUnmount = () => {
|
||||||
_codeMirror?.destroy();
|
_codeMirror?.destroy();
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateValue = (value) => {
|
const foldCode = () => {
|
||||||
if (_cached === value) {
|
if (!_codeMirror || !(props.autoFold instanceof RegExp)) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
_cached = value;
|
|
||||||
_codeMirror.dispatch({
|
|
||||||
changes: {
|
|
||||||
from: 0,
|
|
||||||
to: _codeMirror.state.doc.length,
|
|
||||||
insert: value,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!(props.autoFold instanceof RegExp)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const lines = value.split("\n");
|
const lines = props.value.split("\n");
|
||||||
const effects = [];
|
const effects = [];
|
||||||
|
|
||||||
for (let i = lines.length - 1; i >= 0; i--) {
|
for (let i = lines.length - 1; i >= 0; i--) {
|
||||||
@@ -229,6 +216,21 @@ function setup(props, { emit }) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateValue = (value) => {
|
||||||
|
if (_cached === value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_cached = value;
|
||||||
|
_codeMirror?.dispatch({
|
||||||
|
changes: {
|
||||||
|
from: 0,
|
||||||
|
to: _codeMirror.state.doc.length,
|
||||||
|
insert: value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
foldCode();
|
||||||
|
};
|
||||||
|
|
||||||
const updateSelection = () => {
|
const updateSelection = () => {
|
||||||
if (!props.selection || !_codeMirror) {
|
if (!props.selection || !_codeMirror) {
|
||||||
return;
|
return;
|
||||||
@@ -247,11 +249,7 @@ function setup(props, { emit }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateOverlay = () => {
|
const updateOverlay = () => {
|
||||||
if (!_codeMirror) {
|
_codeMirror?.dispatch({
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_codeMirror.dispatch({
|
|
||||||
effects: _overlay.of({
|
effects: _overlay.of({
|
||||||
start: props.overlayStart,
|
start: props.overlayStart,
|
||||||
end: props.overlayEnd,
|
end: props.overlayEnd,
|
||||||
@@ -259,6 +257,13 @@ function setup(props, { emit }) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateMode = async () => {
|
||||||
|
_codeMirror?.dispatch({
|
||||||
|
effects: languageExt.reconfigure(await getLanguageExtension(props.mode)),
|
||||||
|
});
|
||||||
|
foldCode();
|
||||||
|
};
|
||||||
|
|
||||||
const handleChange = (value) => {
|
const handleChange = (value) => {
|
||||||
_cached = value;
|
_cached = value;
|
||||||
onChange(value);
|
onChange(value);
|
||||||
@@ -298,18 +303,7 @@ function setup(props, { emit }) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(() => props.mode, updateMode);
|
||||||
() => props.mode,
|
|
||||||
async (mode) => {
|
|
||||||
if (!_codeMirror) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_codeMirror.dispatch({
|
|
||||||
effects: languageExt.reconfigure(await getLanguageExtension(mode)),
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.ruler,
|
() => props.ruler,
|
||||||
|
|||||||
@@ -9,13 +9,15 @@ import packageJson from "./package.json" with { type: "json" };
|
|||||||
const IS_PRODUCTION = process.env.NODE_ENV === "production";
|
const IS_PRODUCTION = process.env.NODE_ENV === "production";
|
||||||
const IS_CI = Boolean(process.env.CI);
|
const IS_CI = Boolean(process.env.CI);
|
||||||
const OUT_DIRECTORY = "./static/playground/";
|
const OUT_DIRECTORY = "./static/playground/";
|
||||||
const DEPENDENCIES_EXCLUDE_FROM_CDN = new Set(
|
const DEPENDENCIES_EXCLUDE_FROM_CDN = new Set([
|
||||||
[
|
"cm6-graphql",
|
||||||
IS_PRODUCTION ? undefined : "vue",
|
"@docusaurus/preset-classic",
|
||||||
"cm6-graphql",
|
]);
|
||||||
"@docusaurus/preset-classic",
|
|
||||||
].filter(Boolean),
|
// Local develop requires `vue` for HMR
|
||||||
);
|
if (!IS_PRODUCTION) {
|
||||||
|
DEPENDENCIES_EXCLUDE_FROM_CDN.add("vue");
|
||||||
|
}
|
||||||
|
|
||||||
export default defineConfig(async () => ({
|
export default defineConfig(async () => ({
|
||||||
base: IS_PRODUCTION ? "/playground/" : undefined,
|
base: IS_PRODUCTION ? "/playground/" : undefined,
|
||||||
|
|||||||
+5
-5
@@ -1914,15 +1914,15 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@codemirror/view@npm:6.39.4":
|
"@codemirror/view@npm:6.39.8, @codemirror/view@npm:^6.0.0, @codemirror/view@npm:^6.17.0, @codemirror/view@npm:^6.23.0, @codemirror/view@npm:^6.27.0, @codemirror/view@npm:^6.35.0":
|
||||||
version: 6.39.4
|
version: 6.39.8
|
||||||
resolution: "@codemirror/view@npm:6.39.4"
|
resolution: "@codemirror/view@npm:6.39.8"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@codemirror/state": "npm:^6.5.0"
|
"@codemirror/state": "npm:^6.5.0"
|
||||||
crelt: "npm:^1.0.6"
|
crelt: "npm:^1.0.6"
|
||||||
style-mod: "npm:^4.1.0"
|
style-mod: "npm:^4.1.0"
|
||||||
w3c-keyname: "npm:^2.2.4"
|
w3c-keyname: "npm:^2.2.4"
|
||||||
checksum: 10/8fa1122f2c1dec38eb3a68cd7173c77ea21625bcf2164374bef482213b35222a7811bcc74f221c932c165f8d0a13a17b57456bed6fbae2b12cb9b8355664995a
|
checksum: 10/a15941940fabc9b595da00a7760947cf7ce83f3f819be31250a73d2a1de5d1b5528a5803aa19c74656d2d7cbc39f47daec4962190ffc0849f4f359e45b4f1c3a
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -13232,7 +13232,7 @@ __metadata:
|
|||||||
"@codemirror/language-data": "npm:6.5.2"
|
"@codemirror/language-data": "npm:6.5.2"
|
||||||
"@codemirror/lint": "npm:6.9.2"
|
"@codemirror/lint": "npm:6.9.2"
|
||||||
"@codemirror/state": "npm:6.5.3"
|
"@codemirror/state": "npm:6.5.3"
|
||||||
"@codemirror/view": "npm:6.39.4"
|
"@codemirror/view": "npm:6.39.8"
|
||||||
"@docusaurus/core": "npm:3.9.2"
|
"@docusaurus/core": "npm:3.9.2"
|
||||||
"@docusaurus/faster": "npm:3.9.2"
|
"@docusaurus/faster": "npm:3.9.2"
|
||||||
"@docusaurus/module-type-aliases": "npm:3.9.2"
|
"@docusaurus/module-type-aliases": "npm:3.9.2"
|
||||||
|
|||||||
Reference in new issue
Block a user