diff --git a/demo/Playground.tsx b/demo/Playground.tsx index b9d256e7..0d5af2fe 100644 --- a/demo/Playground.tsx +++ b/demo/Playground.tsx @@ -5,13 +5,13 @@ import {RadioButton, TextInput} from '@gravity-ui/uikit'; import { BasePreset, BehaviorPreset, - createExtension, MarkdownBlocksPreset, MarkdownMarksPreset, MarkupString, YfmEditorComponent, useYfmEditor, YfmPreset, + Extension, } from '../src'; import {PlaygroundHtmlPreview} from './HtmlPreview'; import {logger} from '../src/index'; @@ -43,33 +43,31 @@ export const Playground = React.memo((props) => { const [previewType, setPreviewType] = React.useState(PreviewType.Markup); const [yfmRaw, setYfmRaw] = React.useState(initial || ''); - const extensions = React.useMemo(() => { - return [ - createExtension((builder) => - builder - .use(BasePreset, {}) - .use(BehaviorPreset, { - history: { - undoKey: keys.undo, - redoKey: keys.redo, - }, - }) - .use(MarkdownBlocksPreset, { - image: false, - heading: false, - breaks: {preferredBreak: breaks ? 'soft' : 'hard'}, - }) - .use(MarkdownMarksPreset, { - bold: {boldKey: keys.bold}, - italic: {italicKey: keys.italic}, - strike: {strikeKey: keys.strike}, - underline: {underlineKey: keys.underline}, - code: {codeKey: keys.code}, - }) - .use(YfmPreset, {}), - )(), - ]; - }, [breaks]); + const extensions = React.useMemo( + () => (builder) => + builder + .use(BasePreset, {}) + .use(BehaviorPreset, { + history: { + undoKey: keys.undo, + redoKey: keys.redo, + }, + }) + .use(MarkdownBlocksPreset, { + image: false, + heading: false, + breaks: {preferredBreak: breaks ? 'soft' : 'hard'}, + }) + .use(MarkdownMarksPreset, { + bold: {boldKey: keys.bold}, + italic: {italicKey: keys.italic}, + strike: {strikeKey: keys.strike}, + underline: {underlineKey: keys.underline}, + code: {codeKey: keys.code}, + }) + .use(YfmPreset, {}), + [breaks], + ); const editor = useYfmEditor({ linkify, diff --git a/src/core/Editor.ts b/src/core/Editor.ts index e764f2be..7df1a47d 100644 --- a/src/core/Editor.ts +++ b/src/core/Editor.ts @@ -2,7 +2,7 @@ import {EditorView} from 'prosemirror-view'; import {EditorState} from 'prosemirror-state'; import type {CommonEditor, ContentHandler, MarkupString} from '../common'; -import type {ExtensionSpec} from './types/extension'; +import type {Extension} from './types/extension'; import {bindActions} from './utils/actions'; import type {Serializer} from './types/serializer'; import {ExtensionsManager} from './ExtensionsManager'; @@ -17,7 +17,7 @@ export type YfmEditorOptions = { domElem?: Element; /** yfm markup */ initialContent?: string; - extensions?: ExtensionSpec[]; + extensions?: Extension; allowHTML?: boolean; linkify?: boolean; /** markdown-it-attrs options */ @@ -48,7 +48,7 @@ export class YfmEditor implements CommonEditor, ActionStorage { constructor({ domElem, initialContent = '', - extensions = [], + extensions = () => {}, attrs: attrsOpts, allowHTML, linkify, diff --git a/src/core/ExtensionBuilder.test.ts b/src/core/ExtensionBuilder.test.ts index bbee2e8b..69ba56f1 100644 --- a/src/core/ExtensionBuilder.test.ts +++ b/src/core/ExtensionBuilder.test.ts @@ -74,6 +74,25 @@ describe('ExtensionBuilder', () => { expect(plugins.length).toBe(2); }); + it('should sort plugins by priority', () => { + const plugin0 = new Plugin({}); + const plugin1 = new Plugin({}); + const plugin2 = new Plugin({}); + const plugin3 = new Plugin({}); + const plugins = new ExtensionBuilder() + .addPlugin(() => plugin3, ExtensionBuilder.PluginPriority.VeryLow) + .addPlugin(() => plugin1) + .addPlugin(() => plugin0, ExtensionBuilder.PluginPriority.VeryHigh) + .addPlugin(() => plugin2) + .build() + .plugins({} as ExtensionDeps); + + expect(plugins.indexOf(plugin0)).toBe(0); + expect(plugins.indexOf(plugin1)).toBe(1); + expect(plugins.indexOf(plugin2)).toBe(2); + expect(plugins.indexOf(plugin3)).toBe(3); + }); + it('should add actions', () => { const actions = new ExtensionBuilder() .addAction('action1', () => ({ diff --git a/src/core/ExtensionBuilder.ts b/src/core/ExtensionBuilder.ts index 336172db..ce7fe565 100644 --- a/src/core/ExtensionBuilder.ts +++ b/src/core/ExtensionBuilder.ts @@ -146,17 +146,14 @@ export class ExtensionBuilder { return map; }, plugins: (deps) => { - // TODO: sort plugins here after WIKI-16660 - return plugins.reduce<{plugin: Plugin; priority: number}[]>( - (acc, {cb, priority}) => { + return plugins + .sort((a, b) => b.priority - a.priority) + .reduce((acc, {cb}) => { const res = cb(deps); - if (Array.isArray(res)) - acc.push(...res.map((plugin) => ({plugin, priority}))); - else acc.push({plugin: res, priority}); + if (Array.isArray(res)) acc.push(...res); + else acc.push(res); return acc; - }, - [], - ); + }, []); }, actions: (deps) => actions.reduce((obj, [name, cb]) => { diff --git a/src/core/ExtensionsManager.ts b/src/core/ExtensionsManager.ts index df8de4c2..5fff287e 100644 --- a/src/core/ExtensionsManager.ts +++ b/src/core/ExtensionsManager.ts @@ -1,17 +1,24 @@ import MarkdownIt from 'markdown-it'; import type {Plugin} from 'prosemirror-state'; import {ActionsManager} from './ActionsManager'; +import {ExtensionBuilder} from './ExtensionBuilder'; import {ParserTokensRegistry} from './ParserTokensRegistry'; import {SchemaSpecRegistry} from './SchemaSpecRegistry'; import {SerializerTokensRegistry} from './SerializerTokensRegistry'; import type {ActionSpec} from './types/actions'; -import type {ExtensionDeps, ExtensionSpec, YEMarkSpec, YENodeSpec} from './types/extension'; +import type { + Extension, + ExtensionDeps, + ExtensionSpec, + YEMarkSpec, + YENodeSpec, +} from './types/extension'; import type {MarkViewConstructor, NodeViewConstructor} from './types/node-views'; const attrs = require('markdown-it-attrs'); type ExtensionsManagerParams = { - extensions: ExtensionSpec[]; + extensions: Extension; options?: ExtensionsManagerOptions; }; @@ -25,7 +32,7 @@ type ExtensionsManagerOptions = { }; export class ExtensionsManager { - static process(extensions: ExtensionSpec[], options: ExtensionsManagerOptions) { + static process(extensions: Extension, options: ExtensionsManagerOptions) { return new this({extensions, options}).build(); } @@ -38,8 +45,10 @@ export class ExtensionsManager { #md: MarkdownIt; #mdWithoutAttrs: MarkdownIt; - #extensions: ExtensionSpec[]; + #extensions: Extension; + #builder: ExtensionBuilder; + #spec!: ExtensionSpec; #deps!: ExtensionDeps; #plugins: Plugin[] = []; #actions: Record = {}; @@ -51,6 +60,9 @@ export class ExtensionsManager { this.#md = new MarkdownIt(options.mdOpts ?? {}).use(attrs, options.attrsOpts ?? {}); this.#mdWithoutAttrs = new MarkdownIt(options.mdOpts ?? {}); + + // TODO: add prefilled context + this.#builder = new ExtensionBuilder(); } build() { @@ -75,12 +87,11 @@ export class ExtensionsManager { } private processExtensions() { - for (const ext of this.#extensions) { - this.#md = ext.configureMd(this.#md); - this.#mdWithoutAttrs = ext.configureMd(this.#mdWithoutAttrs); - ext.nodes().forEach(this.processNode); - ext.marks().forEach(this.processMark); - } + this.#spec = this.#builder.use(this.#extensions).build(); + this.#md = this.#spec.configureMd(this.#md); + this.#mdWithoutAttrs = this.#spec.configureMd(this.#mdWithoutAttrs); + this.#spec.nodes().forEach(this.processNode); + this.#spec.marks().forEach(this.processMark); } private processNode = (name: string, {spec, fromYfm, toYfm, view}: YENodeSpec) => { @@ -113,14 +124,8 @@ export class ExtensionsManager { } private createDerived() { - const plugins: {plugin: Plugin; priority: number}[] = []; - for (const ext of this.#extensions) { - plugins.push(...ext.plugins(this.#deps)); - Object.assign(this.#actions, ext.actions(this.#deps)); - } - - // TODO: move sorting to ExtensionBuilder after WIKI-16660 - this.#plugins = plugins.sort((a, b) => b.priority - a.priority).map((item) => item.plugin); + this.#plugins = this.#spec.plugins(this.#deps); + Object.assign(this.#actions, this.#spec.actions(this.#deps)); for (const [name, view] of this.#nodeViewCreators) { this.#nodeViews[name] = view(this.#deps); diff --git a/src/core/createExtension.ts b/src/core/createExtension.ts deleted file mode 100644 index 210eba1e..00000000 --- a/src/core/createExtension.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {ExtensionBuilder} from './ExtensionBuilder'; - -export function createExtension( - cb: (builder: ExtensionBuilder, opts?: Opts) => void, -) { - return (opts?: Opts) => { - const builder = new ExtensionBuilder(); - cb(builder, opts); - return builder.build(); - }; -} diff --git a/src/core/index.ts b/src/core/index.ts index 840c5d46..1d7ea607 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -1,7 +1,6 @@ export * from './Editor'; export * from './ExtensionBuilder'; export * from './ExtensionsManager'; -export * from './createExtension'; export {bindActions} from './utils/actions'; export {trackTransactionMetrics} from './utils/metrics'; export type {Keymap} from './types/keymap'; @@ -10,7 +9,6 @@ export type { Extension, ExtensionAuto, ExtensionWithOptions, - ExtensionSpec, ExtensionDeps, YENodeSpec, YEMarkSpec, diff --git a/src/core/types/extension.ts b/src/core/types/extension.ts index 2969a606..8866854b 100644 --- a/src/core/types/extension.ts +++ b/src/core/types/extension.ts @@ -17,7 +17,7 @@ export type ExtensionSpec = { configureMd(md: MarkdownIt): MarkdownIt; nodes(): OrderedMap; marks(): OrderedMap; - plugins(deps: ExtensionDeps): {plugin: Plugin; priority: number}[]; + plugins(deps: ExtensionDeps): Plugin[]; actions(deps: ExtensionDeps): Record; }; diff --git a/src/extensions/base/BaseSchema/BaseSchema.test.ts b/src/extensions/base/BaseSchema/BaseSchema.test.ts index 66ad13af..0baec44d 100644 --- a/src/extensions/base/BaseSchema/BaseSchema.test.ts +++ b/src/extensions/base/BaseSchema/BaseSchema.test.ts @@ -1,10 +1,10 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from './index'; +import {BaseNode, BaseSchema} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE()], + extensions: (builder) => builder.use(BaseSchema, {}), }).buildDeps(); const {doc, p} = builders(schema, { diff --git a/src/extensions/base/BaseSchema/index.ts b/src/extensions/base/BaseSchema/index.ts index f21d7231..87bbbbec 100644 --- a/src/extensions/base/BaseSchema/index.ts +++ b/src/extensions/base/BaseSchema/index.ts @@ -2,7 +2,7 @@ import type {NodeSpec} from 'prosemirror-model'; import type {Command} from 'prosemirror-state'; import {setBlockType} from 'prosemirror-commands'; import {hasParentNodeOfType} from 'prosemirror-utils'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {nodeTypeFactory} from '../../../utils/schema'; export enum BaseNode { @@ -82,13 +82,6 @@ export const BaseSchema: ExtensionAuto = (builder, opts) => { }); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const BaseSchemaE = createExtension((b, o) => b.use(BaseSchema, o ?? {})); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/base/index.ts b/src/extensions/base/index.ts index 4647f4bf..c442452f 100644 --- a/src/extensions/base/index.ts +++ b/src/extensions/base/index.ts @@ -1,4 +1,4 @@ -import {createExtension, ExtensionAuto} from '../../core'; +import type {ExtensionAuto} from '../../core'; import {BaseSchema, BaseSchemaOptions} from './BaseSchema'; import {BaseInputRules} from './BaseInputRules'; @@ -21,6 +21,3 @@ export const BasePreset: ExtensionAuto = (builder, opts) => { .use(BaseInputRules) .use(BaseStyles); }; - -/** @deprecated */ -export const BasePresetE = createExtension((b, o = {}) => b.use(BasePreset, o)); diff --git a/src/extensions/markdown/Blockquote/Blockquote.test.ts b/src/extensions/markdown/Blockquote/Blockquote.test.ts index 786a3b26..7aebf73d 100644 --- a/src/extensions/markdown/Blockquote/Blockquote.test.ts +++ b/src/extensions/markdown/Blockquote/Blockquote.test.ts @@ -1,11 +1,11 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {blockquote, BlockquoteE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {blockquote, Blockquote} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), BlockquoteE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Blockquote, {}), }).buildDeps(); const {doc, p, q} = builders(schema, { diff --git a/src/extensions/markdown/Blockquote/index.ts b/src/extensions/markdown/Blockquote/index.ts index 6490743d..a8256007 100644 --- a/src/extensions/markdown/Blockquote/index.ts +++ b/src/extensions/markdown/Blockquote/index.ts @@ -2,7 +2,7 @@ import {chainCommands, wrapIn} from 'prosemirror-commands'; import type {NodeType} from 'prosemirror-model'; import {wrappingInputRule} from 'prosemirror-inputrules'; import {hasParentNodeOfType} from 'prosemirror-utils'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {selectQuoteBeforeCursor, liftFromQuote, toggleQuote} from './commands'; import {blockquote, bqType} from './const'; @@ -51,13 +51,6 @@ export const Blockquote: ExtensionAuto = (builder, opts) => { }); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const BlockquoteE = createExtension((b, o = {}) => b.use(Blockquote, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/markdown/Bold/Bold.test.ts b/src/extensions/markdown/Bold/Bold.test.ts index d47230fd..e9b5c07b 100644 --- a/src/extensions/markdown/Bold/Bold.test.ts +++ b/src/extensions/markdown/Bold/Bold.test.ts @@ -1,11 +1,11 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {bold, BoldE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {bold, Bold} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), BoldE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Bold, {}), }).buildDeps(); const {doc, p, b} = builders(schema, { diff --git a/src/extensions/markdown/Bold/index.ts b/src/extensions/markdown/Bold/index.ts index 9d38dee8..f0655590 100644 --- a/src/extensions/markdown/Bold/index.ts +++ b/src/extensions/markdown/Bold/index.ts @@ -1,6 +1,6 @@ import {toggleMark} from 'prosemirror-commands'; import {createToggleMarkAction} from '../../../utils/actions'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {markTypeFactory} from '../../../utils/schema'; import {markInputRule} from '../../../utils/inputrules'; @@ -44,13 +44,6 @@ export const Bold: ExtensionAuto = (builder, opts) => { })); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const BoldE = createExtension((b, o = {}) => b.use(Bold, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/markdown/Code/Code.test.ts b/src/extensions/markdown/Code/Code.test.ts index 4bfed2a1..04c7c416 100644 --- a/src/extensions/markdown/Code/Code.test.ts +++ b/src/extensions/markdown/Code/Code.test.ts @@ -1,11 +1,11 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {code, CodeE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {code, Code} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), CodeE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Code, {}), }).buildDeps(); const {doc, p, c} = builders(schema, { diff --git a/src/extensions/markdown/Code/index.ts b/src/extensions/markdown/Code/index.ts index 55f49685..4e37b304 100644 --- a/src/extensions/markdown/Code/index.ts +++ b/src/extensions/markdown/Code/index.ts @@ -2,7 +2,7 @@ import type {Node} from 'prosemirror-model'; import {toggleMark} from 'prosemirror-commands'; import codemark from 'prosemirror-codemark'; import {createToggleMarkAction} from '../../../utils/actions'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {markTypeFactory} from '../../../utils/schema'; import './code.scss'; @@ -54,13 +54,6 @@ export const Code: ExtensionAuto = (builder, opts) => { .addPlugin(({schema}) => codemark({markType: codeType(schema)})); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const CodeE = createExtension((b, o = {}) => b.use(Code, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/markdown/CodeBlock/CodeBlock.test.ts b/src/extensions/markdown/CodeBlock/CodeBlock.test.ts index 762c1a47..df6d399f 100644 --- a/src/extensions/markdown/CodeBlock/CodeBlock.test.ts +++ b/src/extensions/markdown/CodeBlock/CodeBlock.test.ts @@ -5,12 +5,12 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {CodeBlockE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {CodeBlock} from './index'; import {codeBlock, langAttr} from './const'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), CodeBlockE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(CodeBlock, {}), }).buildDeps(); const {doc, p, cb} = builders(schema, { diff --git a/src/extensions/markdown/CodeBlock/index.ts b/src/extensions/markdown/CodeBlock/index.ts index 46345d9b..b5cd3119 100644 --- a/src/extensions/markdown/CodeBlock/index.ts +++ b/src/extensions/markdown/CodeBlock/index.ts @@ -2,7 +2,7 @@ import {setBlockType} from 'prosemirror-commands'; import {textblockTypeInputRule} from 'prosemirror-inputrules'; import {NodeType} from 'prosemirror-model'; import {hasParentNodeOfType} from 'prosemirror-utils'; -import {Action, createExtension, ExtensionAuto, Keymap} from '../../../core'; +import type {Action, ExtensionAuto, Keymap} from '../../../core'; import {resetCodeblock} from './commands'; import {cbAction, cbType, codeBlock, langAttr} from './const'; @@ -85,13 +85,6 @@ export const CodeBlock: ExtensionAuto = (builder, opts) => { }); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const CodeBlockE = createExtension((b, o = {}) => b.use(CodeBlock, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/markdown/Deflist/Deflist.test.ts b/src/extensions/markdown/Deflist/Deflist.test.ts index 8cf9f436..e03725d9 100644 --- a/src/extensions/markdown/Deflist/Deflist.test.ts +++ b/src/extensions/markdown/Deflist/Deflist.test.ts @@ -1,12 +1,12 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {DeflistE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {Deflist} from './index'; import {DeflistNode} from './const'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), DeflistE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Deflist, {}), }).buildDeps(); const {doc, p, dl, dt, dd} = builders(schema, { diff --git a/src/extensions/markdown/Deflist/index.ts b/src/extensions/markdown/Deflist/index.ts index a237b82b..8966f4b3 100644 --- a/src/extensions/markdown/Deflist/index.ts +++ b/src/extensions/markdown/Deflist/index.ts @@ -1,5 +1,5 @@ import type {PluginSimple} from 'markdown-it'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {DeflistNode, dlAction} from './const'; import {splitDeflist, wrapToDeflist} from './commands'; import {fromYfm} from './fromYfm'; @@ -40,13 +40,6 @@ export const Deflist: ExtensionAuto = (builder, opts) => { }); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const DeflistE = createExtension((b, o = {}) => b.use(Deflist, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/markdown/Heading/Heading.test.ts b/src/extensions/markdown/Heading/Heading.test.ts index 86adf091..505e8dc2 100644 --- a/src/extensions/markdown/Heading/Heading.test.ts +++ b/src/extensions/markdown/Heading/Heading.test.ts @@ -1,13 +1,13 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {bold, BoldE} from '../Bold'; -import {HeadingE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {bold, Bold} from '../Bold'; +import {Heading} from './index'; import {heading, lvlAttr} from './const'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), HeadingE(), BoldE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Heading, {}).use(Bold, {}), }).buildDeps(); const {doc, b, p, h1, h2, h3, h4, h5, h6} = builders(schema, { diff --git a/src/extensions/markdown/Heading/index.ts b/src/extensions/markdown/Heading/index.ts index 23617822..bbb34c2a 100644 --- a/src/extensions/markdown/Heading/index.ts +++ b/src/extensions/markdown/Heading/index.ts @@ -1,6 +1,6 @@ import type {Node, NodeSpec} from 'prosemirror-model'; import {setBlockType} from 'prosemirror-commands'; -import {Action, createExtension, ExtensionAuto, Keymap} from '../../../core'; +import type {Action, ExtensionAuto, Keymap} from '../../../core'; import {headingAction} from './actions'; import {HeadingAction, HeadingLevel, heading, lvlAttr} from './const'; import {headingRule, hType} from './utils'; @@ -86,13 +86,6 @@ export const Heading: ExtensionAuto = (builder, opts) => { .addAction(HeadingAction.ToH6, ({schema}) => headingAction(hType(schema), 6)); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const HeadingE = createExtension((b, o = {}) => b.use(Heading, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/markdown/HorizontalRule/HorizontalRule.test.ts b/src/extensions/markdown/HorizontalRule/HorizontalRule.test.ts index 4b08b2d6..24682a07 100644 --- a/src/extensions/markdown/HorizontalRule/HorizontalRule.test.ts +++ b/src/extensions/markdown/HorizontalRule/HorizontalRule.test.ts @@ -1,11 +1,11 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {horizontalRule, HorizontalRuleE, markupAttr} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {horizontalRule, HorizontalRule, markupAttr} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), HorizontalRuleE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(HorizontalRule), }).buildDeps(); const {doc, p, hr, hr2, hr3} = builders(schema, { diff --git a/src/extensions/markdown/HorizontalRule/index.ts b/src/extensions/markdown/HorizontalRule/index.ts index a32faa75..763b5442 100644 --- a/src/extensions/markdown/HorizontalRule/index.ts +++ b/src/extensions/markdown/HorizontalRule/index.ts @@ -1,6 +1,6 @@ import type {NodeType} from 'prosemirror-model'; import {Command, NodeSelection, Selection} from 'prosemirror-state'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {nodeTypeFactory} from '../../../utils/schema'; export const horizontalRule = 'horizontal_rule'; @@ -42,13 +42,6 @@ export const HorizontalRule: ExtensionAuto = (builder) => { }); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const HorizontalRuleE = createExtension((b, o = {}) => b.use(HorizontalRule, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/markdown/Html/Html.test.ts b/src/extensions/markdown/Html/Html.test.ts index 9a7d63d3..19f05e52 100644 --- a/src/extensions/markdown/Html/Html.test.ts +++ b/src/extensions/markdown/Html/Html.test.ts @@ -1,12 +1,12 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {HtmlE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {Html} from './index'; import {HtmlAttr, HtmlNode} from './const'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), HtmlE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Html), options: {mdOpts: {html: true}}, }).buildDeps(); diff --git a/src/extensions/markdown/Html/index.ts b/src/extensions/markdown/Html/index.ts index d1c115de..1103e05d 100644 --- a/src/extensions/markdown/Html/index.ts +++ b/src/extensions/markdown/Html/index.ts @@ -1,5 +1,5 @@ import {logger} from '../../../logger'; -import {createExtension, ExtensionAuto} from '../../../core'; +import type {ExtensionAuto} from '../../../core'; import {HtmlNode} from './const'; import {fromYfm} from './fromYfm'; import {spec} from './spec'; @@ -24,13 +24,6 @@ export const Html: ExtensionAuto = (builder) => { })); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const HtmlE = createExtension((b, o = {}) => b.use(Html, o)); - declare global { namespace YfmEditor { interface Context { diff --git a/src/extensions/markdown/Image/Image.test.ts b/src/extensions/markdown/Image/Image.test.ts index a493a7d4..5c0af0ff 100644 --- a/src/extensions/markdown/Image/Image.test.ts +++ b/src/extensions/markdown/Image/Image.test.ts @@ -1,12 +1,12 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {ImageE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {Image} from './index'; import {image, ImageAttr} from './const'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), ImageE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Image), }).buildDeps(); const {doc, p, img, img2} = builders(schema, { diff --git a/src/extensions/markdown/Image/index.ts b/src/extensions/markdown/Image/index.ts index 34b38d76..733ed09a 100644 --- a/src/extensions/markdown/Image/index.ts +++ b/src/extensions/markdown/Image/index.ts @@ -1,4 +1,4 @@ -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {addImage, AddImageAttrs} from './actions'; import {addImageAction, image, ImageAttr} from './const'; @@ -58,13 +58,6 @@ export const Image: ExtensionAuto = (builder) => { builder.addAction(addImageAction, ({schema}) => addImage(schema)); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const ImageE = createExtension((b, o = {}) => b.use(Image, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/markdown/Italic/Italic.test.ts b/src/extensions/markdown/Italic/Italic.test.ts index e901111c..0fa01129 100644 --- a/src/extensions/markdown/Italic/Italic.test.ts +++ b/src/extensions/markdown/Italic/Italic.test.ts @@ -1,11 +1,11 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {italic, ItalicE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {italic, Italic} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), ItalicE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Italic, {}), }).buildDeps(); const {doc, p, i} = builders(schema, { diff --git a/src/extensions/markdown/Italic/index.ts b/src/extensions/markdown/Italic/index.ts index 71700726..fb6b79ec 100644 --- a/src/extensions/markdown/Italic/index.ts +++ b/src/extensions/markdown/Italic/index.ts @@ -1,6 +1,6 @@ import {toggleMark} from 'prosemirror-commands'; import {createToggleMarkAction} from '../../../utils/actions'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {markTypeFactory} from '../../../utils/schema'; import {markInputRule} from '../../../utils/inputrules'; @@ -39,13 +39,6 @@ export const Italic: ExtensionAuto = (builder, opts) => { } }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const ItalicE = createExtension((b, o = {}) => b.use(Italic, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/markdown/Link/Link.test.ts b/src/extensions/markdown/Link/Link.test.ts index f99b87ac..4d0fb4cc 100644 --- a/src/extensions/markdown/Link/Link.test.ts +++ b/src/extensions/markdown/Link/Link.test.ts @@ -1,11 +1,11 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {link, LinkE, LinkAttr} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {link, Link, LinkAttr} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), LinkE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Link), }).buildDeps(); const {doc, p, a, lnk, lnk4} = builders(schema, { diff --git a/src/extensions/markdown/Link/index.ts b/src/extensions/markdown/Link/index.ts index fc9fc25f..cf004faf 100644 --- a/src/extensions/markdown/Link/index.ts +++ b/src/extensions/markdown/Link/index.ts @@ -1,7 +1,7 @@ import {InputRule} from 'prosemirror-inputrules'; import type {Fragment, Mark, MarkType} from 'prosemirror-model'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {markTypeFactory} from '../../../utils/schema'; import {LinkActionMeta, LinkActionParams, linkCommand} from './actions'; @@ -87,13 +87,6 @@ export const Link: ExtensionAuto = (builder) => { .addInputRules(({schema}) => ({rules: [linkInputRule(linkType(schema))]})); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const LinkE = createExtension((b, o = {}) => b.use(Link, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/markdown/Lists/Lists.test.ts b/src/extensions/markdown/Lists/Lists.test.ts index 0db2cd5f..5099dfba 100644 --- a/src/extensions/markdown/Lists/Lists.test.ts +++ b/src/extensions/markdown/Lists/Lists.test.ts @@ -1,12 +1,12 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; import {ListNode} from './const'; -import {ListsE} from './index'; +import {Lists} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), ListsE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Lists, {}), }).buildDeps(); const {doc, p, li, ul, ol} = builders(schema, { diff --git a/src/extensions/markdown/Lists/index.ts b/src/extensions/markdown/Lists/index.ts index 2f786642..37a5eb07 100644 --- a/src/extensions/markdown/Lists/index.ts +++ b/src/extensions/markdown/Lists/index.ts @@ -1,5 +1,5 @@ import {liftListItem, sinkListItem, splitListItem} from 'prosemirror-schema-list'; -import {Action, createExtension, ExtensionAuto, Keymap} from '../../../core'; +import type {Action, ExtensionAuto, Keymap} from '../../../core'; import {actions} from './actions'; import {ListAction, ListNode} from './const'; import {fromYfm} from './fromYfm'; @@ -60,13 +60,6 @@ export const Lists: ExtensionAuto = (builder, opts) => { .addAction(ListAction.LiftListItem, actions.liftListItem); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const ListsE = createExtension((b, o = {}) => b.use(Lists, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/markdown/Mark/Mark.test.ts b/src/extensions/markdown/Mark/Mark.test.ts index 81a1fa44..4891b8d2 100644 --- a/src/extensions/markdown/Mark/Mark.test.ts +++ b/src/extensions/markdown/Mark/Mark.test.ts @@ -1,11 +1,11 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {mark, MarkE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {mark, Mark} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), MarkE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Mark), }).buildDeps(); const {doc, p, m} = builders(schema, { diff --git a/src/extensions/markdown/Mark/index.ts b/src/extensions/markdown/Mark/index.ts index 350775d1..5c1d9c94 100644 --- a/src/extensions/markdown/Mark/index.ts +++ b/src/extensions/markdown/Mark/index.ts @@ -1,5 +1,5 @@ import type {PluginSimple} from 'markdown-it'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {markTypeFactory} from '../../../utils/schema'; import {createToggleMarkAction} from '../../../utils/actions'; import {markInputRule} from '../../../utils/inputrules'; @@ -38,13 +38,6 @@ export const Mark: ExtensionAuto = (builder) => { })); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const MarkE = createExtension((b) => b.use(Mark)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/markdown/Strike/Strike.test.ts b/src/extensions/markdown/Strike/Strike.test.ts index 563f6575..8a84b6d9 100644 --- a/src/extensions/markdown/Strike/Strike.test.ts +++ b/src/extensions/markdown/Strike/Strike.test.ts @@ -1,11 +1,11 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {strike, StrikeE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {strike, Strike} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), StrikeE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Strike, {}), }).buildDeps(); const {doc, p, s} = builders(schema, { diff --git a/src/extensions/markdown/Strike/index.ts b/src/extensions/markdown/Strike/index.ts index cf23bb01..f5f14b94 100644 --- a/src/extensions/markdown/Strike/index.ts +++ b/src/extensions/markdown/Strike/index.ts @@ -1,5 +1,5 @@ import {toggleMark} from 'prosemirror-commands'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {createToggleMarkAction} from '../../../utils/actions'; import {markTypeFactory} from '../../../utils/schema'; import {markInputRule} from '../../../utils/inputrules'; @@ -41,13 +41,6 @@ export const Strike: ExtensionAuto = (builder, opts) => { } }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const StrikeE = createExtension((b, o = {}) => b.use(Strike, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/markdown/Table/Table.test.ts b/src/extensions/markdown/Table/Table.test.ts index 9d0a64c2..c35bba30 100644 --- a/src/extensions/markdown/Table/Table.test.ts +++ b/src/extensions/markdown/Table/Table.test.ts @@ -1,13 +1,13 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {blockquote, BlockquoteE} from '../Blockquote'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {blockquote, Blockquote} from '../Blockquote'; import {CellAlign, TableAttrs, TableNode} from './const'; -import {TableE} from './index'; +import {Table} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), BlockquoteE(), TableE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Blockquote, {}).use(Table), }).buildDeps(); const {doc, bq, table, thead, tbody, tr, thL, thC, thR, tdL, tdC, tdR} = builders(schema, { diff --git a/src/extensions/markdown/Table/index.ts b/src/extensions/markdown/Table/index.ts index 5cb37721..13525b77 100644 --- a/src/extensions/markdown/Table/index.ts +++ b/src/extensions/markdown/Table/index.ts @@ -1,4 +1,4 @@ -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {goToNextCell} from '../../../table-utils'; import {TableNode} from './const'; import {fromYfm} from './fromYfm'; @@ -51,13 +51,6 @@ export const Table: ExtensionAuto = (builder) => { .addAction('deleteTable', () => deleteTableAction); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const TableE = createExtension((b, o = {}) => b.use(Table, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/markdown/Underline/Underline.test.ts b/src/extensions/markdown/Underline/Underline.test.ts index bc4fec43..0cb5e43a 100644 --- a/src/extensions/markdown/Underline/Underline.test.ts +++ b/src/extensions/markdown/Underline/Underline.test.ts @@ -1,11 +1,11 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {underline, UnderlineE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {underline, Underline} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), UnderlineE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Underline, {}), }).buildDeps(); const {doc, p, u} = builders(schema, { diff --git a/src/extensions/markdown/Underline/index.ts b/src/extensions/markdown/Underline/index.ts index 31b22d2f..ed2b1b8e 100644 --- a/src/extensions/markdown/Underline/index.ts +++ b/src/extensions/markdown/Underline/index.ts @@ -1,5 +1,5 @@ import {toggleMark} from 'prosemirror-commands'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {createToggleMarkAction} from '../../../utils/actions'; import {markTypeFactory} from '../../../utils/schema'; import {markInputRule} from '../../../utils/inputrules'; @@ -37,13 +37,6 @@ export const Underline: ExtensionAuto = (builder, opts) => { } }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const UnderlineE = createExtension((b, o = {}) => b.use(Underline, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/yfm/Checkbox/Checkbox.test.ts b/src/extensions/yfm/Checkbox/Checkbox.test.ts index 513d1622..8d3859bb 100644 --- a/src/extensions/yfm/Checkbox/Checkbox.test.ts +++ b/src/extensions/yfm/Checkbox/Checkbox.test.ts @@ -1,12 +1,12 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; import {CheckboxNode} from './const'; -import {CheckboxE} from './index'; +import {Checkbox} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), CheckboxE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Checkbox, {}), }).buildDeps(); const { diff --git a/src/extensions/yfm/Checkbox/index.ts b/src/extensions/yfm/Checkbox/index.ts index e89b762c..df3d101a 100644 --- a/src/extensions/yfm/Checkbox/index.ts +++ b/src/extensions/yfm/Checkbox/index.ts @@ -1,5 +1,5 @@ import checkboxPlugin from '@doc-tools/transform/lib/plugins/checkbox'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {replaceParentNodeOfType} from 'prosemirror-utils'; import {CheckboxNode} from './const'; import {keymapPlugin} from './plugin'; @@ -108,13 +108,6 @@ export const Checkbox: ExtensionAuto = (builder, opts) => { })); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const CheckboxE = createExtension((b, o = {}) => b.use(Checkbox, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/yfm/Color/Color.test.ts b/src/extensions/yfm/Color/Color.test.ts index 96a96391..1a86fbb4 100644 --- a/src/extensions/yfm/Color/Color.test.ts +++ b/src/extensions/yfm/Color/Color.test.ts @@ -1,12 +1,12 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {ColorE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {Color} from './index'; import {color} from './const'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), ColorE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Color), }).buildDeps(); const {doc, p, c1, c2} = builders(schema, { diff --git a/src/extensions/yfm/Color/index.ts b/src/extensions/yfm/Color/index.ts index 6025e3d0..536c4681 100644 --- a/src/extensions/yfm/Color/index.ts +++ b/src/extensions/yfm/Color/index.ts @@ -1,6 +1,6 @@ import mdPlugin from 'markdown-it-color'; import {toggleMark} from 'prosemirror-commands'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {isMarkActive} from '../../../utils/marks'; import {markTypeFactory} from '../../../utils/schema'; import {className, color, colorAction, Colors, domColorAttr} from './const'; @@ -100,13 +100,6 @@ export const Color: ExtensionAuto = (builder) => { }); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const ColorE = createExtension((b) => b.use(Color)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/yfm/ImgSize/YfmImage.test.ts b/src/extensions/yfm/ImgSize/YfmImage.test.ts index d0b61463..54f77502 100644 --- a/src/extensions/yfm/ImgSize/YfmImage.test.ts +++ b/src/extensions/yfm/ImgSize/YfmImage.test.ts @@ -5,12 +5,12 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {ImgSizeE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {ImgSize} from './index'; import {image, ImageAttr} from './const'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), ImgSizeE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(ImgSize, {}), }).buildDeps(); const {doc, p, img, img2, img3, img4} = builders(schema, { diff --git a/src/extensions/yfm/ImgSize/index.ts b/src/extensions/yfm/ImgSize/index.ts index 3bfb4233..66a5da65 100644 --- a/src/extensions/yfm/ImgSize/index.ts +++ b/src/extensions/yfm/ImgSize/index.ts @@ -4,7 +4,7 @@ import imsize from '@doc-tools/transform/lib/plugins/imsize'; import {ImsizeAttr} from '@doc-tools/transform/lib/plugins/imsize/const'; import log from '@doc-tools/transform/lib/log'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {addImageAction, image} from './const'; import {addImage, AddImageAttrs} from './actions'; @@ -88,13 +88,6 @@ export const ImgSize: ExtensionAuto = (builder, opts) => { builder.addAction(addImageAction, ({schema}) => addImage(schema)); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const ImgSizeE = createExtension((b, o = {}) => b.use(ImgSize, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/yfm/Math/Math.test.ts b/src/extensions/yfm/Math/Math.test.ts index 38c47225..50912c3b 100644 --- a/src/extensions/yfm/Math/Math.test.ts +++ b/src/extensions/yfm/Math/Math.test.ts @@ -1,12 +1,12 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; -import {createExtension, ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; +import {ExtensionsManager} from '../../../core'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; import {MathNode} from './const'; import {Math} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), createExtension((b) => b.use(Math))()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Math), }).buildDeps(); const {doc, p, mathB, mathI} = builders(schema, { diff --git a/src/extensions/yfm/Monospace/Monospace.test.ts b/src/extensions/yfm/Monospace/Monospace.test.ts index 67c411f7..ae2a7f13 100644 --- a/src/extensions/yfm/Monospace/Monospace.test.ts +++ b/src/extensions/yfm/Monospace/Monospace.test.ts @@ -1,11 +1,11 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {monospace, MonospaceE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {monospace, Monospace} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), MonospaceE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Monospace), }).buildDeps(); const {doc, p, m} = builders(schema, { diff --git a/src/extensions/yfm/Monospace/index.ts b/src/extensions/yfm/Monospace/index.ts index 56674a13..02e1c42c 100644 --- a/src/extensions/yfm/Monospace/index.ts +++ b/src/extensions/yfm/Monospace/index.ts @@ -1,5 +1,5 @@ import yfmPlugin from '@doc-tools/transform/lib/plugins/monospace'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {markTypeFactory} from '../../../utils/schema'; import {createToggleMarkAction} from '../../../utils/actions'; import {markInputRule} from '../../../utils/inputrules'; @@ -38,13 +38,6 @@ export const Monospace: ExtensionAuto = (builder) => { })); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const MonospaceE = createExtension((b) => b.use(Monospace)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/yfm/Video/Video.test.ts b/src/extensions/yfm/Video/Video.test.ts index 629ca13c..02c99537 100644 --- a/src/extensions/yfm/Video/Video.test.ts +++ b/src/extensions/yfm/Video/Video.test.ts @@ -1,13 +1,13 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {VideoE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {Video} from './index'; import {video, VideoAttr} from './const'; import {VideoService} from './md-video'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), VideoE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Video, {}), }).buildDeps(); const {doc, p} = builders(schema, { diff --git a/src/extensions/yfm/Video/index.ts b/src/extensions/yfm/Video/index.ts index 0c97ddf2..7e050a8a 100644 --- a/src/extensions/yfm/Video/index.ts +++ b/src/extensions/yfm/Video/index.ts @@ -1,4 +1,4 @@ -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {vAction, video, VideoAttr} from './const'; import {createViewStub, serializeNodeToString} from './utils'; import {addVideo} from './actions'; @@ -105,13 +105,6 @@ export const Video: ExtensionAuto = (builder, opts) => { builder.addAction(vAction, () => addVideo); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const VideoE = createExtension((b, o = {}) => b.use(Video, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/yfm/YfmCut/YfmCut.test.ts b/src/extensions/yfm/YfmCut/YfmCut.test.ts index 85e5ebe3..ff3bff3d 100644 --- a/src/extensions/yfm/YfmCut/YfmCut.test.ts +++ b/src/extensions/yfm/YfmCut/YfmCut.test.ts @@ -1,13 +1,14 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {blockquote, BlockquoteE, italic, ItalicE} from '../../markdown'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {blockquote, Blockquote, italic, Italic} from '../../markdown'; import {CutNode} from './const'; -import {YfmCutE} from './index'; +import {YfmCut} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), ItalicE(), BlockquoteE(), YfmCutE()], + extensions: (builder) => + builder.use(BaseSchema, {}).use(Italic, {}).use(Blockquote, {}).use(YfmCut, {}), }).buildDeps(); const {doc, p, i, bq, cut, cutTitle, cutContent} = builders(schema, { diff --git a/src/extensions/yfm/YfmCut/index.ts b/src/extensions/yfm/YfmCut/index.ts index 777d1e2c..7a056ba0 100644 --- a/src/extensions/yfm/YfmCut/index.ts +++ b/src/extensions/yfm/YfmCut/index.ts @@ -1,7 +1,7 @@ import log from '@doc-tools/transform/lib/log'; import yfmPlugin from '@doc-tools/transform/lib/plugins/cut'; import {chainCommands} from 'prosemirror-commands'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {nodeInputRule} from '../../../utils/inputrules'; import {toYfm} from './toYfm'; import {CutNode, cutType} from './const'; @@ -66,13 +66,6 @@ export const YfmCut: ExtensionAuto = (builder, opts) => { } }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const YfmCutE = createExtension((b, o = {}) => b.use(YfmCut, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/yfm/YfmFile/YfmFile.test.ts b/src/extensions/yfm/YfmFile/YfmFile.test.ts index 73acfc47..c0e4f33e 100644 --- a/src/extensions/yfm/YfmFile/YfmFile.test.ts +++ b/src/extensions/yfm/YfmFile/YfmFile.test.ts @@ -3,11 +3,11 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {YfmFileE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {YfmFile} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), YfmFileE({fileUploadHandler: () => Promise.reject()})], + extensions: (builder) => builder.use(BaseSchema, {}).use(YfmFile), }).buildDeps(); const {same} = createMarkupChecker({parser, serializer}); diff --git a/src/extensions/yfm/YfmFile/index.ts b/src/extensions/yfm/YfmFile/index.ts index 1315b1a1..10a0fc54 100644 --- a/src/extensions/yfm/YfmFile/index.ts +++ b/src/extensions/yfm/YfmFile/index.ts @@ -6,7 +6,7 @@ import { PREFIX, } from '@doc-tools/transform/lib/plugins/file/const'; -import {createExtension, Extension} from '../../../core'; +import type {Extension} from '../../../core'; import {nodeTypeFactory} from '../../../utils/schema'; import {fileNodeAttrsSpec, KNOWN_ATTRS, LINK_TO_FILE_ATTRS_MAP} from './const'; @@ -79,10 +79,3 @@ export const YfmFile: Extension = (builder) => { }, })); }; - -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const YfmFileE = createExtension((b) => b.use(YfmFile)); diff --git a/src/extensions/yfm/YfmHeading/YfmHeading.test.ts b/src/extensions/yfm/YfmHeading/YfmHeading.test.ts index a728844b..8b6c74c9 100644 --- a/src/extensions/yfm/YfmHeading/YfmHeading.test.ts +++ b/src/extensions/yfm/YfmHeading/YfmHeading.test.ts @@ -1,13 +1,13 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {bold, BoldE} from '../../markdown/Bold'; -import {YfmHeadingE} from './index'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {bold, Bold} from '../../markdown/Bold'; +import {YfmHeading} from './index'; import {heading, YfmHeadingAttr} from './const'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), YfmHeadingE(), BoldE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(YfmHeading, {}).use(Bold, {}), options: {attrsOpts: {allowedAttributes: ['id']}}, }).buildDeps(); diff --git a/src/extensions/yfm/YfmHeading/index.ts b/src/extensions/yfm/YfmHeading/index.ts index dcf1f76e..1618f7e6 100644 --- a/src/extensions/yfm/YfmHeading/index.ts +++ b/src/extensions/yfm/YfmHeading/index.ts @@ -1,5 +1,5 @@ import type {Node, NodeSpec} from 'prosemirror-model'; -import {Action, createExtension, ExtensionAuto, Keymap} from '../../../core'; +import type {Action, ExtensionAuto, Keymap} from '../../../core'; import {HeadingAction, YfmHeadingAttr, heading} from './const'; import {getNodeAttrs, headingRule, hType} from './utils'; import {headingAction} from './actions'; @@ -123,13 +123,6 @@ export const YfmHeading: ExtensionAuto = (builder, opts) => { .addAction(HeadingAction.ToH6, () => headingAction(6)); }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const YfmHeadingE = createExtension((b, o = {}) => b.use(YfmHeading, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/yfm/YfmNote/YfmNote.test.ts b/src/extensions/yfm/YfmNote/YfmNote.test.ts index 1dc3df8f..c76b5a2d 100644 --- a/src/extensions/yfm/YfmNote/YfmNote.test.ts +++ b/src/extensions/yfm/YfmNote/YfmNote.test.ts @@ -1,13 +1,14 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; import {ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {italic, ItalicE, blockquote, BlockquoteE} from '../../markdown'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {italic, Italic, blockquote, Blockquote} from '../../markdown'; import {NoteAttrs, NoteNode} from './const'; -import {YfmNoteE} from './index'; +import {YfmNote} from './index'; const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), ItalicE(), BlockquoteE(), YfmNoteE()], + extensions: (builder) => + builder.use(BaseSchema, {}).use(Italic, {}).use(Blockquote, {}).use(YfmNote, {}), }).buildDeps(); const {doc, p, i, bq, note, noteTitle} = builders(schema, { diff --git a/src/extensions/yfm/YfmNote/index.ts b/src/extensions/yfm/YfmNote/index.ts index 0cc7c198..0c245aef 100644 --- a/src/extensions/yfm/YfmNote/index.ts +++ b/src/extensions/yfm/YfmNote/index.ts @@ -1,7 +1,7 @@ import log from '@doc-tools/transform/lib/log'; import yfmPlugin from '@doc-tools/transform/lib/plugins/notes'; import {chainCommands} from 'prosemirror-commands'; -import {Action, createExtension, ExtensionAuto} from '../../../core'; +import type {Action, ExtensionAuto} from '../../../core'; import {toYfm} from './toYfm'; import {NoteNode} from './const'; import {fromYfm} from './fromYfm'; @@ -55,13 +55,6 @@ export const YfmNote: ExtensionAuto = (builder, opts) => { } }; -/** - * @deprecated - * For tests only. - * Remove after WIKI-16660 - */ -export const YfmNoteE = createExtension((b, o = {}) => b.use(YfmNote, o)); - declare global { namespace YfmEditor { interface Actions { diff --git a/src/extensions/yfm/YfmTable/YfmTable.test.ts b/src/extensions/yfm/YfmTable/YfmTable.test.ts index c5f1bace..2aa055e8 100644 --- a/src/extensions/yfm/YfmTable/YfmTable.test.ts +++ b/src/extensions/yfm/YfmTable/YfmTable.test.ts @@ -1,15 +1,13 @@ import {builders} from 'prosemirror-test-builder'; import {createMarkupChecker} from '../../../../tests/sameMarkup'; -import {createExtension, ExtensionsManager} from '../../../core'; -import {BaseNode, BaseSchemaE} from '../../base/BaseSchema'; -import {blockquote, BlockquoteE} from '../../markdown/Blockquote'; +import {ExtensionsManager} from '../../../core'; +import {BaseNode, BaseSchema} from '../../base/BaseSchema'; +import {blockquote, Blockquote} from '../../markdown/Blockquote'; import {YfmTableNode} from './const'; import {YfmTable} from './index'; -const YfmTableE = createExtension((builder) => builder.use(YfmTable, {})); - const {schema, parser, serializer} = new ExtensionsManager({ - extensions: [BaseSchemaE(), BlockquoteE(), YfmTableE()], + extensions: (builder) => builder.use(BaseSchema, {}).use(Blockquote, {}).use(YfmTable, {}), }).buildDeps(); const {doc, p, bq, table, tbody, tr, td} = builders(schema, {