Skip to content

Commit

Permalink
feat!: import yfmCut plugin from separate cut-extension package
Browse files Browse the repository at this point in the history
  • Loading branch information
makhnatkin authored and d3m1d0v committed Oct 23, 2024
1 parent 6dbbc52 commit fd43a36
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 19 deletions.
4 changes: 2 additions & 2 deletions demo/md-plugins.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
import {transform as yfmCut} from '@diplodoc/cut-extension';
import {transform as foldingHeadings} from '@diplodoc/folding-headings-extension';
import '@diplodoc/folding-headings-extension/runtime';
import {transform as yfmHtmlBlock} from '@diplodoc/html-extension';
Expand All @@ -7,7 +8,6 @@ import {transform as mermaid} from '@diplodoc/mermaid-extension';
import anchors from '@diplodoc/transform/lib/plugins/anchors';
import checkbox from '@diplodoc/transform/lib/plugins/checkbox';
import code from '@diplodoc/transform/lib/plugins/code';
import cut from '@diplodoc/transform/lib/plugins/cut';
import deflist from '@diplodoc/transform/lib/plugins/deflist';
import file from '@diplodoc/transform/lib/plugins/file';
import imsize from '@diplodoc/transform/lib/plugins/imsize';
Expand All @@ -34,7 +34,7 @@ export const YFM_HTML_BLOCK_RUNTIME = 'extension:yfm-html-block';
const defaultPlugins: PluginWithParams[] = [
anchors,
code,
cut,
yfmCut({bundle: false}) as PluginWithParams,
deflist,
file,
imsize,
Expand Down
8 changes: 5 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
"tslib": "^2.3.1"
},
"devDependencies": {
"@diplodoc/cut-extension": "^0.3.1",
"@diplodoc/folding-headings-extension": "0.1.0",
"@diplodoc/html-extension": "2.3.2",
"@diplodoc/latex-extension": "1.0.3",
Expand Down Expand Up @@ -276,6 +277,7 @@
}
},
"peerDependencies": {
"@diplodoc/cut-extension": "^0.3.1",
"@diplodoc/folding-headings-extension": "^0.1.0",
"@diplodoc/html-extension": "2.3.2",
"@diplodoc/latex-extension": "^1.0.3",
Expand Down
5 changes: 2 additions & 3 deletions src/extensions/yfm/YfmCut/YfmCutSpecs/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import log from '@diplodoc/transform/lib/log';
import yfmPlugin from '@diplodoc/transform/lib/plugins/cut';
import {transform as yfmCut} from '@diplodoc/cut-extension';
import type {NodeSpec} from 'prosemirror-model';

import type {ExtensionAuto, ExtensionNodeSpec} from '../../../../core';
Expand Down Expand Up @@ -29,7 +28,7 @@ export const YfmCutSpecs: ExtensionAuto<YfmCutSpecsOptions> = (builder, opts) =>
const schemaSpecs = getSchemaSpecs(opts, builder.context.get('placeholder'));

builder
.configureMd((md) => md.use(yfmPlugin, {log}))
.configureMd((md) => md.use(yfmCut({bundle: false})))
.addNode(CutNode.Cut, () => ({
spec: schemaSpecs[CutNode.Cut],
toMd: serializerTokens[CutNode.Cut],
Expand Down
10 changes: 0 additions & 10 deletions src/extensions/yfm/YfmCut/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,4 @@
.yfm-cut-title:focus {
outline: 0;
}

/* TODO: Remove this after updating @diplodoc/transform to version 4.19.0 or higher */
/* This ensures backward compatibility with earlier versions of cut-extension */
.yfm-cut-title {
list-style: none;
}
.yfm-cut-title::-webkit-details-marker,
.yfm-cut-title::marker {
display: none;
}
}
4 changes: 3 additions & 1 deletion src/extensions/yfm/YfmCut/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@diplodoc/cut-extension/runtime';
import {chainCommands} from 'prosemirror-commands';

import type {Action, ExtensionAuto} from '../../../core';
Expand All @@ -12,7 +13,8 @@ import {YfmCutTitleNodeView} from './nodeviews/yfm-cut-title';
import {cutActivePlugin} from './plugins/active';
import {cutAutoOpenPlugin} from './plugins/auto-open';

import './index.scss';
import '@diplodoc/cut-extension/runtime/styles.css';
import './index.scss'; // eslint-disable-line import/order

const cutAction = 'toYfmCut';

Expand Down

0 comments on commit fd43a36

Please sign in to comment.