File tree Expand file tree Collapse file tree 7 files changed +59
-22
lines changed
Expand file tree Collapse file tree 7 files changed +59
-22
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,10 @@ import type {PluginWithParams} from 'markdown-it/lib';
33import file from '@doc-tools/transform/lib/plugins/file' ;
44import imsize from '@doc-tools/transform/lib/plugins/imsize' ;
55
6- const sub = require ( 'markdown-it-sub' ) ;
7- const ins = require ( 'markdown-it-ins' ) ;
8- const mark = require ( 'markdown-it-mark' ) ;
9- const color = require ( 'markdown-it-color' ) . colorPlugin ;
6+ import sub from 'markdown-it-sub' ;
7+ import ins from 'markdown-it-ins' ;
8+ import mark from 'markdown-it-mark' ;
9+ import color from 'markdown-it-color' ;
1010import math from 'markdown-it-katex' ;
1111
1212import meta from '@doc-tools/transform/lib/plugins/meta' ;
Original file line number Diff line number Diff line change 11import MarkdownIt from 'markdown-it' ;
2+ import attrsPlugin , { AttrsOptions } from 'markdown-it-attrs' ;
23import type { Plugin } from 'prosemirror-state' ;
34import { ActionsManager } from './ActionsManager' ;
45import { ExtensionBuilder } from './ExtensionBuilder' ;
@@ -15,8 +16,6 @@ import type {
1516} from './types/extension' ;
1617import type { MarkViewConstructor , NodeViewConstructor } from './types/node-views' ;
1718
18- const attrs = require ( 'markdown-it-attrs' ) ;
19-
2019type ExtensionsManagerParams = {
2120 extensions : Extension ;
2221 options ?: ExtensionsManagerOptions ;
@@ -59,7 +58,10 @@ export class ExtensionsManager {
5958 constructor ( { extensions, options = { } } : ExtensionsManagerParams ) {
6059 this . #extensions = extensions ;
6160
62- this . #md = new MarkdownIt ( options . mdOpts ?? { } ) . use ( attrs , options . attrsOpts ?? { } ) ;
61+ this . #md = new MarkdownIt ( options . mdOpts ?? { } ) . use < AttrsOptions > (
62+ attrsPlugin ,
63+ options . attrsOpts ?? { } ,
64+ ) ;
6365 this . #mdWithoutAttrs = new MarkdownIt ( options . mdOpts ?? { } ) ;
6466
6567 if ( options . linkifyTlds ) {
Original file line number Diff line number Diff line change 1- import type { PluginSimple } from 'markdown-it' ;
1+ import deflistPlugin from 'markdown-it-deflist ' ;
22import type { NodeSpec } from 'prosemirror-model' ;
33import type { ExtensionAuto } from '../../../../core' ;
44import { nodeTypeFactory } from '../../../../utils/schema' ;
@@ -7,8 +7,6 @@ import {fromYfm} from './fromYfm';
77import { getSpec } from './spec' ;
88import { toYfm } from './toYfm' ;
99
10- const mdPlugin : PluginSimple = require ( 'markdown-it-deflist' ) ;
11-
1210export { DeflistNode } from './const' ;
1311export const defListType = nodeTypeFactory ( DeflistNode . List ) ;
1412export const defTermType = nodeTypeFactory ( DeflistNode . Term ) ;
@@ -22,7 +20,7 @@ export type DeflistSpecsOptions = {
2220export const DeflistSpecs : ExtensionAuto < DeflistSpecsOptions > = ( builder , opts ) => {
2321 const spec = getSpec ( opts ) ;
2422
25- builder . configureMd ( ( md ) => md . use ( mdPlugin ) ) ;
23+ builder . configureMd ( ( md ) => md . use ( deflistPlugin ) ) ;
2624 builder
2725 . addNode ( DeflistNode . List , ( ) => ( {
2826 spec : spec [ DeflistNode . List ] ,
Original file line number Diff line number Diff line change 1- import type { PluginSimple } from 'markdown-it' ;
1+ import markPlugin from 'markdown-it-mark ' ;
22import type { ExtensionAuto } from '../../../../core' ;
33import { markTypeFactory } from '../../../../utils/schema' ;
4- const mdPlugin : PluginSimple = require ( 'markdown-it-mark' ) ;
54
65export const markMarkName = 'mark' ;
76export const markMarkType = markTypeFactory ( markMarkName ) ;
87
98export const MarkSpecs : ExtensionAuto = ( builder ) => {
109 builder
11- . configureMd ( ( md ) => md . use ( mdPlugin ) )
10+ . configureMd ( ( md ) => md . use ( markPlugin ) )
1211 . addMark ( markMarkName , ( ) => ( {
1312 spec : {
1413 parseDOM : [ { tag : 'mark' } ] ,
Original file line number Diff line number Diff line change 1- import type { PluginSimple } from 'markdown-it' ;
1+ import subPlugin from 'markdown-it-sub ' ;
22import type { ExtensionAuto } from '../../../../core' ;
33import { markTypeFactory } from '../../../../utils/schema' ;
44
5- const sub : PluginSimple = require ( 'markdown-it-sub' ) ;
6-
75export const subscriptMarkName = 'sub' ;
86export const subscriptType = markTypeFactory ( subscriptMarkName ) ;
97
108export const SubscriptSpecs : ExtensionAuto = ( builder ) => {
119 builder
12- . configureMd ( ( md ) => md . use ( sub ) )
10+ . configureMd ( ( md ) => md . use ( subPlugin ) )
1311 . addMark ( subscriptMarkName , ( ) => ( {
1412 spec : {
1513 excludes : '_' ,
Original file line number Diff line number Diff line change 1- import type { PluginSimple } from 'markdown-it' ;
1+ import insPlugin from 'markdown-it-ins ' ;
22import type { ExtensionAuto } from '../../../../core' ;
33import { markTypeFactory } from '../../../../utils/schema' ;
44
5- const ins : PluginSimple = require ( 'markdown-it-ins' ) ;
6-
75export const underlineMarkName = 'ins' ;
86export const underlineType = markTypeFactory ( underlineMarkName ) ;
97
108export const UnderlineSpecs : ExtensionAuto = ( builder ) => {
119 builder
12- . configureMd ( ( md ) => md . use ( ins ) )
10+ . configureMd ( ( md ) => md . use ( insPlugin ) )
1311 . addMark ( underlineMarkName , ( ) => ( {
1412 spec : {
1513 parseDOM : [ { tag : 'ins' } , { tag : 'u' } ] ,
Original file line number Diff line number Diff line change 1+ /* eslint-disable @typescript-eslint/no-duplicate-imports */
2+
3+ declare module 'markdown-it-attrs' {
4+ import type { PluginWithOptions } from 'markdown-it' ;
5+ export type AttrsOptions = {
6+ /** @default '{' */
7+ leftDelimiter ?: string ;
8+ /** @default '}' */
9+ rightDelimiter ?: string ;
10+ /**
11+ * empty array = all attributes are allowed
12+ * @default []
13+ */
14+ allowedAttributes ?: ( string | RegExp ) [ ] ;
15+ } ;
16+ declare const plugin : PluginWithOptions < AttrsOptions > ;
17+ export = plugin ;
18+ }
19+
20+ declare module 'markdown-it-deflist' {
21+ import type { PluginSimple } from 'markdown-it' ;
22+ declare const plugin : PluginSimple ;
23+ export = plugin ;
24+ }
25+
26+ declare module 'markdown-it-mark' {
27+ import type { PluginSimple } from 'markdown-it' ;
28+ declare const plugin : PluginSimple ;
29+ export = plugin ;
30+ }
31+
32+ declare module 'markdown-it-sub' {
33+ import type { PluginSimple } from 'markdown-it' ;
34+ declare const plugin : PluginSimple ;
35+ export = plugin ;
36+ }
37+
38+ declare module 'markdown-it-ins' {
39+ import type { PluginSimple } from 'markdown-it' ;
40+ declare const plugin : PluginSimple ;
41+ export = plugin ;
42+ }
You can’t perform that action at this time.
0 commit comments