This commit is contained in:
1 parent
802630b74c
commit
aa4a4236ed
2 files changed
+5
-9
No files matched your search
@@ -43,8 +43,7 @@ function getImageDecorations(view: EditorView) {
|
|||||||
syntaxTree(state).iterate({
|
syntaxTree(state).iterate({
|
||||||
from,
|
from,
|
||||||
to,
|
to,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
enter: (node: { name: string; from: number; to: number; node: { getChild: (type: string) => any } }) => {
|
||||||
enter: (node: any) => {
|
|
||||||
if (node.name === 'Image') {
|
if (node.name === 'Image') {
|
||||||
// 查找图片语法中的 URL 节点
|
// 查找图片语法中的 URL 节点
|
||||||
const urlNode = node.node.getChild('URL');
|
const urlNode = node.node.getChild('URL');
|
||||||
|
|||||||
@@ -76,8 +76,7 @@ export function formatMarkdownTable(tableStr: string): string {
|
|||||||
|
|
||||||
export const tableFormatterPlugin = ViewPlugin.fromClass(
|
export const tableFormatterPlugin = ViewPlugin.fromClass(
|
||||||
class {
|
class {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
lastTableRange: { from: number; to: number } | null = null;
|
||||||
lastTableRange: any = null;
|
|
||||||
|
|
||||||
constructor(view: EditorView) {
|
constructor(view: EditorView) {
|
||||||
this.lastTableRange = this.getCurrentTableRange(view);
|
this.lastTableRange = this.getCurrentTableRange(view);
|
||||||
@@ -107,18 +106,16 @@ export const tableFormatterPlugin = ViewPlugin.fromClass(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getCurrentTableRange(view: EditorView) {
|
getCurrentTableRange(view: EditorView): { from: number; to: number } | null {
|
||||||
const state = view.state;
|
const state = view.state;
|
||||||
const pos = state.selection.main.head;
|
const pos = state.selection.main.head;
|
||||||
const tree = syntaxTree(state);
|
const tree = syntaxTree(state);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
let tableRange: { from: number; to: number } | null = null;
|
||||||
let tableRange: any = null;
|
|
||||||
|
|
||||||
tree.iterate({
|
tree.iterate({
|
||||||
from: pos,
|
from: pos,
|
||||||
to: pos,
|
to: pos,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
enter: (node: { name: string; from: number; to: number }) => {
|
||||||
enter: (node: any) => {
|
|
||||||
if (node.name === 'Table') {
|
if (node.name === 'Table') {
|
||||||
tableRange = { from: node.from, to: node.to };
|
tableRange = { from: node.from, to: node.to };
|
||||||
return false; // stop iteration
|
return false; // stop iteration
|
||||||
|
|||||||
Reference in new issue
Block a user