/** @module prosemirror */

import {EditorState, AllSelection, TextSelection, Plugin, PluginKey} from "prosemirror-state";
import {EditorView} from "prosemirror-view";
import {Schema, DOMSerializer} from "prosemirror-model";
import ProseMirrorInputRules from "./input-rules.mjs";
import {keymap} from "prosemirror-keymap";
import {dropCursor} from "prosemirror-dropcursor";
import {gapCursor} from "prosemirror-gapcursor";
import {history} from "prosemirror-history";
import ProseMirrorKeyMaps from "./keymaps.mjs";
import ProseMirrorMenu from "./menu.mjs";
import ProseMirrorDropDown from "./dropdown.mjs";
import "./extensions.mjs";
import {Step} from "prosemirror-transform";
import {parseHTMLString, serializeHTMLString} from "./util.mjs";
import {schema as defaultSchema} from "./schema.mjs";
import ProseMirrorPlugin from "./plugin.mjs";
import ProseMirrorImagePlugin from "./image-plugin.mjs";
import ProseMirrorDirtyPlugin from "./dirty-plugin.mjs";
import ProseMirrorContentLinkPlugin from "./content-link-plugin.mjs";
import ProseMirrorHighlightMatchesPlugin from "./highlight-matches-plugin.mjs";
import ProseMirrorClickHandler from "./click-handler.mjs";
import DOMParser from "./dom-parser.mjs";
import ProseMirrorPasteTransformer from "./paste-transformer.mjs";
import DisclosureWidget from "./schema/disclosure.mjs";
import * as chat from "./chat/_module.mjs";

export const dom = {
  parser: DOMParser.fromSchema(defaultSchema),
  serializer: DOMSerializer.fromSchema(defaultSchema),
  parseString: parseHTMLString,
  serializeString: serializeHTMLString
};

export * as collab from "prosemirror-collab";
export * as commands from "prosemirror-commands";
export * as transform from "prosemirror-transform";
export * as list from "prosemirror-schema-list";
export * as tables from "@massifrg/prosemirror-tables-sections";
export * as input from "prosemirror-inputrules";
export * as state from "prosemirror-state";

export * as types from "./_types.mjs";

export const nodeViews = {
  details: DisclosureWidget.view
};

export const plugins = {
  ProseMirrorPlugin, ProseMirrorContentLinkPlugin, ProseMirrorHighlightMatchesPlugin,
  ProseMirrorDirtyPlugin, ProseMirrorImagePlugin, ProseMirrorClickHandler, ProseMirrorPasteTransformer,
  ProseMirrorInputRules, ProseMirrorKeyMaps, ProseMirrorMenu, ProseMirrorDropDown,
  chat, dropCursor, gapCursor, history, keymap
};

// Legacy exports for backwards-compatibility.
export {
  AllSelection, TextSelection,
  DOMParser, DOMSerializer,
  EditorState, EditorView,
  Schema, Step,
  Plugin, PluginKey, ProseMirrorPlugin, ProseMirrorContentLinkPlugin, ProseMirrorHighlightMatchesPlugin,
  ProseMirrorDirtyPlugin, ProseMirrorImagePlugin, ProseMirrorClickHandler, ProseMirrorPasteTransformer,
  ProseMirrorInputRules, ProseMirrorKeyMaps, ProseMirrorMenu, ProseMirrorDropDown,
  defaultSchema, keymap
};
