Upgrade linter and formatter to Ultracite (#1224)
This commit is contained in:
parent
b1d254283b
commit
0e320b391d
177 changed files with 6951 additions and 8342 deletions
|
|
@ -1,15 +1,15 @@
|
|||
import { textblockTypeInputRule } from 'prosemirror-inputrules';
|
||||
import { Schema } from 'prosemirror-model';
|
||||
import { schema } from 'prosemirror-schema-basic';
|
||||
import { addListNodes } from 'prosemirror-schema-list';
|
||||
import type { Transaction } from 'prosemirror-state';
|
||||
import type { EditorView } from 'prosemirror-view';
|
||||
import type { MutableRefObject } from 'react';
|
||||
import { textblockTypeInputRule } from "prosemirror-inputrules";
|
||||
import { Schema } from "prosemirror-model";
|
||||
import { schema } from "prosemirror-schema-basic";
|
||||
import { addListNodes } from "prosemirror-schema-list";
|
||||
import type { Transaction } from "prosemirror-state";
|
||||
import type { EditorView } from "prosemirror-view";
|
||||
import type { MutableRefObject } from "react";
|
||||
|
||||
import { buildContentFromDocument } from './functions';
|
||||
import { buildContentFromDocument } from "./functions";
|
||||
|
||||
export const documentSchema = new Schema({
|
||||
nodes: addListNodes(schema.spec.nodes, 'paragraph block*', 'block'),
|
||||
nodes: addListNodes(schema.spec.nodes, "paragraph block*", "block"),
|
||||
marks: schema.spec.marks,
|
||||
});
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ export function headingRule(level: number) {
|
|||
return textblockTypeInputRule(
|
||||
new RegExp(`^(#{1,${level}})\\s$`),
|
||||
documentSchema.nodes.heading,
|
||||
() => ({ level }),
|
||||
() => ({ level })
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -30,15 +30,17 @@ export const handleTransaction = ({
|
|||
editorRef: MutableRefObject<EditorView | null>;
|
||||
onSaveContent: (updatedContent: string, debounce: boolean) => void;
|
||||
}) => {
|
||||
if (!editorRef || !editorRef.current) return;
|
||||
if (!editorRef || !editorRef.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newState = editorRef.current.state.apply(transaction);
|
||||
editorRef.current.updateState(newState);
|
||||
|
||||
if (transaction.docChanged && !transaction.getMeta('no-save')) {
|
||||
if (transaction.docChanged && !transaction.getMeta("no-save")) {
|
||||
const updatedContent = buildContentFromDocument(newState.doc);
|
||||
|
||||
if (transaction.getMeta('no-debounce')) {
|
||||
if (transaction.getMeta("no-debounce")) {
|
||||
onSaveContent(updatedContent, false);
|
||||
} else {
|
||||
onSaveContent(updatedContent, true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue