diff --git a/src/extensions/yfm/YfmCut/YfmCutSpecs/const.ts b/src/extensions/yfm/YfmCut/YfmCutSpecs/const.ts index 4095edb7..cbe301d4 100644 --- a/src/extensions/yfm/YfmCut/YfmCutSpecs/const.ts +++ b/src/extensions/yfm/YfmCut/YfmCutSpecs/const.ts @@ -1,5 +1,11 @@ +import {nodeTypeFactory} from '../../../../utils/schema'; + export enum CutNode { Cut = 'yfm_cut', CutTitle = 'yfm_cut_title', CutContent = 'yfm_cut_content', } + +export const cutType = nodeTypeFactory(CutNode.Cut); +export const cutTitleType = nodeTypeFactory(CutNode.CutTitle); +export const cutContentType = nodeTypeFactory(CutNode.CutContent); diff --git a/src/extensions/yfm/YfmCut/YfmCutSpecs/index.ts b/src/extensions/yfm/YfmCut/YfmCutSpecs/index.ts index e5b9a213..45a3ceca 100644 --- a/src/extensions/yfm/YfmCut/YfmCutSpecs/index.ts +++ b/src/extensions/yfm/YfmCut/YfmCutSpecs/index.ts @@ -3,17 +3,13 @@ import yfmPlugin from '@diplodoc/transform/lib/plugins/cut'; import type {NodeSpec} from 'prosemirror-model'; import type {ExtensionAuto, YENodeSpec} from '../../../../core'; -import {nodeTypeFactory} from '../../../../utils/schema'; import {CutNode} from './const'; import {fromYfm} from './fromYfm'; import {getSpec} from './spec'; import {toYfm} from './toYfm'; -export {CutNode} from './const'; -export const cutType = nodeTypeFactory(CutNode.Cut); -export const cutTitleType = nodeTypeFactory(CutNode.CutTitle); -export const cutContentType = nodeTypeFactory(CutNode.CutContent); +export {CutNode, cutType, cutTitleType, cutContentType} from './const'; export type YfmCutSpecsOptions = { cutView?: YENodeSpec['view']; diff --git a/src/extensions/yfm/YfmCut/YfmCutSpecs/spec.ts b/src/extensions/yfm/YfmCut/YfmCutSpecs/spec.ts index 48bd2051..1cef2a5c 100644 --- a/src/extensions/yfm/YfmCut/YfmCutSpecs/spec.ts +++ b/src/extensions/yfm/YfmCut/YfmCutSpecs/spec.ts @@ -1,6 +1,6 @@ import type {NodeSpec} from 'prosemirror-model'; -import {PlaceholderOptions} from '../../../../utils/placeholder'; +import type {PlaceholderOptions} from '../../../../utils/placeholder'; import {CutNode} from '../const'; import type {YfmCutSpecsOptions} from './index'; @@ -43,6 +43,7 @@ export const getSpec = ( DEFAULT_PLACEHOLDERS.Title, alwaysVisible: true, }, + definingAsContext: true, selectable: false, allowSelection: false, complex: 'leaf', @@ -63,6 +64,7 @@ export const getSpec = ( DEFAULT_PLACEHOLDERS.Content, alwaysVisible: true, }, + definingAsContext: true, selectable: false, allowSelection: false, complex: 'leaf', diff --git a/src/extensions/yfm/YfmCut/actions/toYfmCut.ts b/src/extensions/yfm/YfmCut/actions/toYfmCut.ts index 708ba00d..18c23f82 100644 --- a/src/extensions/yfm/YfmCut/actions/toYfmCut.ts +++ b/src/extensions/yfm/YfmCut/actions/toYfmCut.ts @@ -3,17 +3,12 @@ import type {Command} from 'prosemirror-state'; import {findParentNodeOfType} from 'prosemirror-utils'; import type {ActionSpec} from '../../../../core'; -import {nodeTypeFactory} from '../../../../utils/schema'; -import {CutNode} from '../const'; - -const yfmCutType = nodeTypeFactory(CutNode.Cut); -const yfmCutTitleType = nodeTypeFactory(CutNode.CutTitle); -const yfmCutContentType = nodeTypeFactory(CutNode.CutContent); +import {cutContentType, cutTitleType, cutType} from '../const'; const createYfmCutNode = (schema: Schema) => (content?: Node | Node[]) => { - return yfmCutType(schema).create(null, [ - yfmCutTitleType(schema).create(null), - yfmCutContentType(schema).create(null, content), + return cutType(schema).create(null, [ + cutTitleType(schema).create(null), + cutContentType(schema).create(null, content), ]); };