Files
wyucandClaude Opus 4.6 843d33e5cc chore: enforce Prettier formatting and fix lint issues
- Add .prettierignore to exclude vendor packages, lock files, markdown, and YAML
- Update .prettierrc: printWidth 100, singleQuote, trailingComma "all"
- Run Prettier across all source files for consistent formatting
- Fix unused imports (UserRequirements, setTTSProvider)
- Fix eslint-disable comment placement after Prettier reformat

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 16:09:45 +08:00

33 lines
1018 B
TypeScript

import { EditorState } from 'prosemirror-state';
import { type DirectEditorProps, EditorView } from 'prosemirror-view';
import { Schema, DOMParser } from 'prosemirror-model';
import { buildPlugins, type PluginOptions } from './plugins/index';
import { schemaNodes, schemaMarks } from './schema/index';
const schema = new Schema({
nodes: schemaNodes,
marks: schemaMarks,
});
export const createDocument = (content: string) => {
const htmlString = `<div>${content}</div>`;
const parser = new window.DOMParser();
const element = parser.parseFromString(htmlString, 'text/html').body.firstElementChild;
return DOMParser.fromSchema(schema).parse(element as Element);
};
export const initProsemirrorEditor = (
dom: Element,
content: string,
props: Omit<DirectEditorProps, 'state'>,
pluginOptions?: PluginOptions,
) => {
return new EditorView(dom, {
state: EditorState.create({
doc: createDocument(content),
plugins: buildPlugins(schema, pluginOptions),
}),
...props,
});
};