@portabletext/plugin-markdown-shortcuts 9.0.4 → 9.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/behavior.markdown-shortcuts.ts","../src/plugin.markdown-shortcuts.tsx"],"mappings":";KAKY;EACV;EACA;GACC;;KAGS;EACV,0BACE;IAEA,SAAS,KAAK;QACV;EACN,kBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;;;;;KCLA,+BAA+B;EACzC,qBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;EAEV,kBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;EAEV,kBACE,SACA,QACA,OACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;IACR;MAAQ;;;;;IAIR;;EAEF,gBACE,SACA;IAEA,SAAS,KAAK;IACd;MAAQ;;QACJ;EACN,mBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;EAEV,iBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;EAEV,mBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;EAEV,mBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;EAEV,qBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;EAEV,4BACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;;;;;iBAOI,0BACd,iBACA,eACA,eACA,cACA,cACA,sBACA,YACA,iBACA,aACA,wBACA,iBACC,+CAA4B,IAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/behavior.markdown-shortcuts.ts","../src/plugin.markdown-shortcuts.tsx"],"mappings":";KAMY;EACV;EACA;GACC;;KAGS;EACV,0BACE;IAEA,SAAS,KAAK;QACV;EACN,kBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;;;;;KCNA,+BAA+B;EACzC,qBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;EAEV,kBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;EAEV,kBACE,SACA,QACA,OACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;IACR;MAAQ;;;;;IAIR;;EAEF,gBACE,SACA;IAEA,SAAS,KAAK;IACd;MAAQ;;QACJ;EACN,mBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;EAEV,iBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;EAEV,mBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;EAEV,mBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;EAEV,qBACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;EAEV,4BACE,SACA;IAEA,SAAS,KAAK;;;;IAId,QAAQ;;;;;;iBAOI,0BACd,iBACA,eACA,eACA,cACA,cACA,sBACA,YACA,iBACA,aACA,wBACA,iBACC,+CAA4B,IAAA"}
package/dist/index.js CHANGED
@@ -6,7 +6,8 @@ import { useEffect } from "react";
6
6
  import { defineBehavior, raise } from "@portabletext/editor/behaviors";
7
7
  import * as selectors from "@portabletext/editor/selectors";
8
8
  import { getPreviousInlineObject } from "@portabletext/editor/selectors";
9
- import { getPathSubSchema } from "@portabletext/editor/traversal";
9
+ import { getPathSubSchema, getSibling } from "@portabletext/editor/traversal";
10
+ import { isEmptyTextBlock, isTextBlock } from "@portabletext/editor/utils";
10
11
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
12
  function createMarkdownBehaviors(config) {
12
13
  return [defineBehavior({
@@ -56,6 +57,8 @@ function createMarkdownBehaviors(config) {
56
57
  guard: ({ snapshot }) => {
57
58
  let selectionCollapsed = selectors.isSelectionCollapsed(snapshot), focusTextBlock = selectors.getFocusTextBlock(snapshot), focusSpan = selectors.getFocusSpan(snapshot);
58
59
  if (!selectionCollapsed || !focusTextBlock || !focusSpan || focusTextBlock.node.children[0]._key !== focusSpan.node._key || snapshot.context.selection?.focus.offset !== 0) return !1;
60
+ let previousSibling = getSibling(snapshot, focusTextBlock.path, { direction: "previous" }), previousSiblingHasTextContent = previousSibling !== void 0 && isTextBlock(snapshot.context, previousSibling.node) && !isEmptyTextBlock(snapshot.context, previousSibling.node);
61
+ if (previousSibling && !previousSiblingHasTextContent) return !1;
59
62
  let subSchema = getPathSubSchema(snapshot, focusTextBlock.path), defaultStyle = config.defaultStyle?.({
60
63
  context: { schema: subSchema },
61
64
  schema: subSchema
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["{\n blockquoteStyle,\n boldDecorator,\n codeDecorator,\n defaultStyle,\n headingStyle,\n horizontalRuleObject,\n linkObject,\n italicDecorator,\n orderedList,\n strikeThroughDecorator,\n unorderedList,\n}: MarkdownShortcutsPluginProps","() => {\n const behaviors = createMarkdownBehaviors({\n defaultStyle,\n })\n\n const unregisterBehaviors = behaviors.map((behavior) =>\n editor.registerBehavior({behavior}),\n )\n\n return () => {\n for (const unregisterBehavior of unregisterBehaviors) {\n unregisterBehavior()\n }\n }\n }","[defaultStyle, editor]","createBlockquoteRule({blockquoteStyle})","createHeadingRule({headingStyle})","createHorizontalRuleRule({horizontalRuleObject})","createMarkdownLinkRule({linkObject})","createOrderedListRule({orderedList})","createUnorderedListRule({unorderedList})","boldDecorator ? (\n <>\n <CharacterPairDecoratorPlugin\n decorator={boldDecorator}\n pair={{char: '*', amount: 2}}\n />\n <CharacterPairDecoratorPlugin\n decorator={boldDecorator}\n pair={{char: '_', amount: 2}}\n />\n </>\n ) : null","codeDecorator ? (\n <CharacterPairDecoratorPlugin\n decorator={codeDecorator}\n pair={{char: '`', amount: 1}}\n />\n ) : null","italicDecorator ? (\n <>\n <CharacterPairDecoratorPlugin\n decorator={italicDecorator}\n pair={{char: '*', amount: 1}}\n />\n <CharacterPairDecoratorPlugin\n decorator={italicDecorator}\n pair={{char: '_', amount: 1}}\n />\n </>\n ) : null","strikeThroughDecorator ? (\n <CharacterPairDecoratorPlugin\n decorator={strikeThroughDecorator}\n pair={{char: '~', amount: 2}}\n />\n ) : null","inputRules ? <InputRulePlugin rules={inputRules} /> : null","<>\n {boldDecorator ? (\n <>\n <CharacterPairDecoratorPlugin\n decorator={boldDecorator}\n pair={{char: '*', amount: 2}}\n />\n <CharacterPairDecoratorPlugin\n decorator={boldDecorator}\n pair={{char: '_', amount: 2}}\n />\n </>\n ) : null}\n {codeDecorator ? (\n <CharacterPairDecoratorPlugin\n decorator={codeDecorator}\n pair={{char: '`', amount: 1}}\n />\n ) : null}\n {italicDecorator ? (\n <>\n <CharacterPairDecoratorPlugin\n decorator={italicDecorator}\n pair={{char: '*', amount: 1}}\n />\n <CharacterPairDecoratorPlugin\n decorator={italicDecorator}\n pair={{char: '_', amount: 1}}\n />\n </>\n ) : null}\n {strikeThroughDecorator ? (\n <CharacterPairDecoratorPlugin\n decorator={strikeThroughDecorator}\n pair={{char: '~', amount: 2}}\n />\n ) : null}\n {inputRules ? <InputRulePlugin rules={inputRules} /> : null}\n </>"],"sources":["../src/behavior.markdown-shortcuts.ts","../src/rule.blockquote.ts","../src/rule.heading.ts","../src/rule.horizontal-rule.ts","../src/rule.markdown-link.ts","../src/rule.ordered-list.ts","../src/rule.unordered-list.ts","../src/plugin.markdown-shortcuts.tsx"],"sourcesContent":["import type {EditorContext} from '@portabletext/editor'\nimport {defineBehavior, raise} from '@portabletext/editor/behaviors'\nimport * as selectors from '@portabletext/editor/selectors'\nimport {getPathSubSchema} from '@portabletext/editor/traversal'\n\nexport type ObjectWithOptionalKey = {\n _type: string\n _key?: string\n [other: string]: unknown\n}\n\nexport type MarkdownBehaviorsConfig = {\n horizontalRuleObject?: ({\n context,\n }: {\n context: Pick<EditorContext, 'schema' | 'keyGenerator'>\n }) => ObjectWithOptionalKey | undefined\n defaultStyle?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n}\n\nexport function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {\n const automaticHrOnPaste = defineBehavior({\n on: 'clipboard.paste',\n guard: ({snapshot, event}) => {\n const text = event.originEvent.dataTransfer.getData('text/plain')\n const hrRegExp = /^(---)$|^(—-)$|^(___)$|^(\\*\\*\\*)$/\n const hrCharacters = text.match(hrRegExp)?.[0]\n const focusBlock = selectors.getFocusBlock(snapshot)\n const focusTextBlock = selectors.getFocusTextBlock(snapshot)\n\n if (!focusBlock) {\n return false\n }\n\n const hrObject = config.horizontalRuleObject?.({\n context: {\n schema: getPathSubSchema(snapshot, focusBlock.path),\n keyGenerator: snapshot.context.keyGenerator,\n },\n })\n\n if (!hrCharacters || !hrObject) {\n return false\n }\n\n return {hrCharacters, hrObject, focusBlock, focusTextBlock}\n },\n actions: [\n (_, {hrCharacters}) => [\n raise({\n type: 'insert.text',\n text: hrCharacters,\n }),\n ],\n ({snapshot}, {hrObject, focusBlock, focusTextBlock}) =>\n focusTextBlock\n ? [\n raise({\n type: 'insert.block',\n block: {\n _type: snapshot.context.schema.block.name,\n children: focusTextBlock.node.children,\n },\n placement: 'after',\n }),\n raise({\n type: 'insert.block',\n block: hrObject,\n placement: 'after',\n }),\n raise({\n type: 'delete.block',\n at: focusBlock.path,\n }),\n ]\n : [\n raise({\n type: 'insert.block',\n block: hrObject,\n placement: 'after',\n }),\n ],\n ],\n })\n\n const clearStyleOnBackspace = defineBehavior({\n on: 'delete.backward',\n guard: ({snapshot}) => {\n const selectionCollapsed = selectors.isSelectionCollapsed(snapshot)\n const focusTextBlock = selectors.getFocusTextBlock(snapshot)\n const focusSpan = selectors.getFocusSpan(snapshot)\n\n if (!selectionCollapsed || !focusTextBlock || !focusSpan) {\n return false\n }\n\n const atTheBeginningOfBLock =\n focusTextBlock.node.children[0]._key === focusSpan.node._key &&\n snapshot.context.selection?.focus.offset === 0\n\n if (!atTheBeginningOfBLock) {\n // A style can only clear at the start of the block; resolving the\n // sub-schema and calling the consumer's `defaultStyle` callback on\n // every other backspace is wasted work with a consumer-visible\n // call frequency.\n return false\n }\n\n const subSchema = getPathSubSchema(snapshot, focusTextBlock.path)\n const defaultStyle = config.defaultStyle?.({\n context: {schema: subSchema},\n schema: subSchema,\n })\n\n if (defaultStyle && focusTextBlock.node.style !== defaultStyle) {\n return {defaultStyle, focusTextBlock}\n }\n\n return false\n },\n actions: [\n (_, {defaultStyle, focusTextBlock}) => [\n raise({\n type: 'block.set',\n props: {style: defaultStyle},\n at: focusTextBlock.path,\n }),\n ],\n ],\n })\n\n const markdownBehaviors = [automaticHrOnPaste, clearStyleOnBackspace]\n\n return markdownBehaviors\n}\n","import type {EditorContext} from '@portabletext/editor'\nimport {raise} from '@portabletext/editor/behaviors'\nimport {getPreviousInlineObject} from '@portabletext/editor/selectors'\nimport {getPathSubSchema} from '@portabletext/editor/traversal'\nimport {defineInputRule} from '@portabletext/plugin-input-rule'\n\nexport function createBlockquoteRule(config: {\n blockquoteStyle: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n}) {\n return defineInputRule({\n on: /^> /,\n guard: ({snapshot, event}) => {\n const subSchema = getPathSubSchema(snapshot, event.focusBlock.path)\n const style = config.blockquoteStyle({\n context: {schema: subSchema},\n schema: subSchema,\n })\n\n if (!style) {\n return false\n }\n\n const previousInlineObject = getPreviousInlineObject(snapshot)\n\n if (previousInlineObject) {\n return false\n }\n\n const match = event.matches.at(0)\n\n if (!match) {\n return false\n }\n\n return {style, match}\n },\n actions: [\n ({event}, {style, match}) => [\n raise({\n type: 'block.unset',\n props: ['listItem', 'level'],\n at: event.focusBlock.path,\n }),\n raise({\n type: 'block.set',\n props: {style},\n at: event.focusBlock.path,\n }),\n raise({\n type: 'delete',\n at: match.targetOffsets,\n }),\n ],\n ],\n })\n}\n","import type {EditorContext} from '@portabletext/editor'\nimport {raise} from '@portabletext/editor/behaviors'\nimport {getPreviousInlineObject} from '@portabletext/editor/selectors'\nimport {getPathSubSchema} from '@portabletext/editor/traversal'\nimport {defineInputRule} from '@portabletext/plugin-input-rule'\n\nexport function createHeadingRule(config: {\n headingStyle: ({\n context,\n schema,\n props,\n level,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n props: {level: number}\n /**\n * @deprecated Use `props.level` instead\n */\n level: number\n }) => string | undefined\n}) {\n return defineInputRule({\n on: /^#+ /,\n guard: ({snapshot, event}) => {\n const previousInlineObject = getPreviousInlineObject(snapshot)\n\n if (previousInlineObject) {\n return false\n }\n\n const match = event.matches.at(0)\n\n if (!match) {\n return false\n }\n\n const level = match.text.length - 1\n\n const subSchema = getPathSubSchema(snapshot, event.focusBlock.path)\n const style = config.headingStyle({\n context: {schema: subSchema},\n schema: subSchema,\n props: {level},\n level,\n })\n\n if (!style) {\n return false\n }\n\n return {match, style}\n },\n actions: [\n ({event}, {match, style}) => [\n raise({\n type: 'block.unset',\n props: ['listItem', 'level'],\n at: event.focusBlock.path,\n }),\n raise({\n type: 'block.set',\n props: {style},\n at: event.focusBlock.path,\n }),\n raise({\n type: 'delete',\n at: match.targetOffsets,\n }),\n ],\n ],\n })\n}\n","import type {EditorContext} from '@portabletext/editor'\nimport {raise} from '@portabletext/editor/behaviors'\nimport {getPreviousInlineObject} from '@portabletext/editor/selectors'\nimport {getPathSubSchema} from '@portabletext/editor/traversal'\nimport {defineInputRule} from '@portabletext/plugin-input-rule'\nimport type {ObjectWithOptionalKey} from './behavior.markdown-shortcuts'\n\nexport function createHorizontalRuleRule(config: {\n horizontalRuleObject: ({\n context,\n }: {\n context: Pick<EditorContext, 'schema' | 'keyGenerator'>\n }) => ObjectWithOptionalKey | undefined\n}) {\n return defineInputRule({\n on: /^(---)|^(—-)|^(___)|^(\\*\\*\\*)/,\n guard: ({snapshot, event}) => {\n const subSchema = getPathSubSchema(snapshot, event.focusBlock.path)\n const hrObject = config.horizontalRuleObject({\n context: {\n schema: subSchema,\n keyGenerator: snapshot.context.keyGenerator,\n },\n })\n\n if (!hrObject) {\n // If no horizontal rule object is provided, then we can safely skip\n // this rule.\n return false\n }\n\n const previousInlineObject = getPreviousInlineObject(snapshot)\n\n if (previousInlineObject) {\n // Input Rules only look at the plain text of the text block. This\n // means that the RegExp is matched even if there is a leading inline\n // object.\n return false\n }\n\n // In theory, an Input Rule could return multiple matches. But in this\n // case we only expect one match.\n const match = event.matches.at(0)\n\n if (!match) {\n return false\n }\n\n return {hrObject, match}\n },\n actions: [\n (_, {hrObject, match}) => [\n raise({\n type: 'insert.block',\n block: hrObject,\n placement: 'before',\n select: 'none',\n }),\n raise({\n type: 'delete',\n at: match.targetOffsets,\n }),\n ],\n ],\n })\n}\n","import type {EditorContext} from '@portabletext/editor'\nimport {raise, type BehaviorAction} from '@portabletext/editor/behaviors'\nimport {getPathSubSchema} from '@portabletext/editor/traversal'\nimport {defineInputRule} from '@portabletext/plugin-input-rule'\nimport type {ObjectWithOptionalKey} from './behavior.markdown-shortcuts'\n\nexport function createMarkdownLinkRule(config: {\n linkObject: ({\n context,\n props,\n }: {\n context: Pick<EditorContext, 'schema' | 'keyGenerator'>\n props: {href: string}\n }) => ObjectWithOptionalKey | undefined\n}) {\n return defineInputRule({\n on: /\\[(?<text>[^[\\]]+)]\\((?<href>.+)\\)/,\n // The rule annotates the text and deletes only the markers and the href\n // region, so an inline object inside the link TEXT is harmless and the\n // link must fire. The unlisted `href` group stays protected: deleting\n // `](href)` across an inline object would destroy it, and the captured\n // href text would silently omit it.\n inlineObjects: {allow: ['text']},\n actions: [\n ({snapshot, event}) => {\n const newText = event.textBefore + event.textInserted\n let textLengthDelta = 0\n const actions: Array<BehaviorAction> = []\n\n for (const match of event.matches.reverse()) {\n const textMatch = match.groups['text']\n const hrefMatch = match.groups['href']\n\n if (textMatch === undefined || hrefMatch === undefined) {\n continue\n }\n\n textLengthDelta =\n textLengthDelta -\n (match.targetOffsets.focus.offset -\n match.targetOffsets.anchor.offset -\n textMatch.text.length)\n\n const linkObject = config.linkObject({\n context: {\n schema: getPathSubSchema(snapshot, event.focusBlock.path),\n keyGenerator: snapshot.context.keyGenerator,\n },\n props: {href: hrefMatch.text},\n })\n\n if (!linkObject) {\n continue\n }\n\n const {_type, _key, ...value} = linkObject\n\n const leftSideOffsets = {\n anchor: match.targetOffsets.anchor,\n focus: textMatch.targetOffsets.anchor,\n }\n const rightSideOffsets = {\n anchor: textMatch.targetOffsets.focus,\n focus: match.targetOffsets.focus,\n }\n\n actions.push(\n raise({\n type: 'select',\n at: textMatch.targetOffsets,\n }),\n )\n actions.push(\n raise({\n type: 'annotation.add',\n annotation: {\n name: _type,\n _key,\n value,\n },\n }),\n )\n actions.push(\n raise({\n type: 'delete',\n at: rightSideOffsets,\n }),\n )\n actions.push(\n raise({\n type: 'delete',\n at: leftSideOffsets,\n }),\n )\n }\n\n if (actions.length === 0) {\n return []\n }\n\n const endCaretPosition = {\n path: event.focusBlock.path,\n offset: newText.length - textLengthDelta * -1,\n }\n\n return [\n ...actions,\n raise({\n type: 'select',\n at: {\n anchor: endCaretPosition,\n focus: endCaretPosition,\n },\n }),\n ]\n },\n ],\n })\n}\n","import type {EditorContext} from '@portabletext/editor'\nimport {raise} from '@portabletext/editor/behaviors'\nimport {getPreviousInlineObject} from '@portabletext/editor/selectors'\nimport {getPathSubSchema} from '@portabletext/editor/traversal'\nimport {defineInputRule} from '@portabletext/plugin-input-rule'\n\nexport function createOrderedListRule(config: {\n orderedList: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n}) {\n return defineInputRule({\n on: /^1\\. /,\n guard: ({snapshot, event}) => {\n const subSchema = getPathSubSchema(snapshot, event.focusBlock.path)\n const orderedList = config.orderedList({\n context: {schema: subSchema},\n schema: subSchema,\n })\n\n if (!orderedList) {\n return false\n }\n\n const previousInlineObject = getPreviousInlineObject(snapshot)\n\n if (previousInlineObject) {\n return false\n }\n\n const match = event.matches.at(0)\n\n if (!match) {\n return false\n }\n\n return {match, orderedList}\n },\n actions: [\n ({event}, {match, orderedList}) => [\n raise({\n type: 'block.unset',\n props: ['style'],\n at: event.focusBlock.path,\n }),\n raise({\n type: 'block.set',\n props: {\n listItem: orderedList,\n level: event.focusBlock.node.level ?? 1,\n },\n at: event.focusBlock.path,\n }),\n raise({\n type: 'delete',\n at: match.targetOffsets,\n }),\n ],\n ],\n })\n}\n","import type {EditorContext} from '@portabletext/editor'\nimport {raise} from '@portabletext/editor/behaviors'\nimport {getPreviousInlineObject} from '@portabletext/editor/selectors'\nimport {getPathSubSchema} from '@portabletext/editor/traversal'\nimport {defineInputRule} from '@portabletext/plugin-input-rule'\n\nexport function createUnorderedListRule(config: {\n unorderedList: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n}) {\n return defineInputRule({\n on: /^(-|\\*) /,\n guard: ({snapshot, event}) => {\n const subSchema = getPathSubSchema(snapshot, event.focusBlock.path)\n const unorderedList = config.unorderedList({\n context: {schema: subSchema},\n schema: subSchema,\n })\n\n if (!unorderedList) {\n return false\n }\n\n const previousInlineObject = getPreviousInlineObject(snapshot)\n\n if (previousInlineObject) {\n return false\n }\n\n const match = event.matches.at(0)\n\n if (!match) {\n return false\n }\n\n return {match, unorderedList}\n },\n actions: [\n ({event}, {match, unorderedList}) => [\n raise({\n type: 'block.unset',\n props: ['style'],\n at: event.focusBlock.path,\n }),\n raise({\n type: 'block.set',\n props: {\n listItem: unorderedList,\n level: event.focusBlock.node.level ?? 1,\n },\n at: event.focusBlock.path,\n }),\n raise({\n type: 'delete',\n at: match.targetOffsets,\n }),\n ],\n ],\n })\n}\n","import type {EditorContext} from '@portabletext/editor'\nimport {useEditor} from '@portabletext/editor'\nimport {CharacterPairDecoratorPlugin} from '@portabletext/plugin-character-pair-decorator'\nimport {InputRulePlugin} from '@portabletext/plugin-input-rule'\nimport {useEffect, useMemo} from 'react'\nimport {\n createMarkdownBehaviors,\n type MarkdownBehaviorsConfig,\n type ObjectWithOptionalKey,\n} from './behavior.markdown-shortcuts'\nimport {createBlockquoteRule} from './rule.blockquote'\nimport {createHeadingRule} from './rule.heading'\nimport {createHorizontalRuleRule} from './rule.horizontal-rule'\nimport {createMarkdownLinkRule} from './rule.markdown-link'\nimport {createOrderedListRule} from './rule.ordered-list'\nimport {createUnorderedListRule} from './rule.unordered-list'\n\n/**\n * @public\n */\nexport type MarkdownShortcutsPluginProps = MarkdownBehaviorsConfig & {\n blockquoteStyle?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n defaultStyle?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n headingStyle?: ({\n context,\n schema,\n props,\n level,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n props: {level: number}\n /**\n * @deprecated Use `props.level` instead\n */\n level: number\n }) => string | undefined\n linkObject?: ({\n context,\n props,\n }: {\n context: Pick<EditorContext, 'schema' | 'keyGenerator'>\n props: {href: string}\n }) => ObjectWithOptionalKey | undefined\n unorderedList?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n orderedList?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n boldDecorator?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n codeDecorator?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n italicDecorator?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n strikeThroughDecorator?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n}\n\n/**\n * @public\n */\nexport function MarkdownShortcutsPlugin({\n blockquoteStyle,\n boldDecorator,\n codeDecorator,\n defaultStyle,\n headingStyle,\n horizontalRuleObject,\n linkObject,\n italicDecorator,\n orderedList,\n strikeThroughDecorator,\n unorderedList,\n}: MarkdownShortcutsPluginProps) {\n const editor = useEditor()\n\n useEffect(() => {\n const behaviors = createMarkdownBehaviors({\n defaultStyle,\n })\n\n const unregisterBehaviors = behaviors.map((behavior) =>\n editor.registerBehavior({behavior}),\n )\n\n return () => {\n for (const unregisterBehavior of unregisterBehaviors) {\n unregisterBehavior()\n }\n }\n }, [defaultStyle, editor])\n\n const inputRules = useMemo(() => {\n const rules = []\n if (blockquoteStyle) {\n rules.push(createBlockquoteRule({blockquoteStyle}))\n }\n if (headingStyle) {\n rules.push(createHeadingRule({headingStyle}))\n }\n if (horizontalRuleObject) {\n rules.push(createHorizontalRuleRule({horizontalRuleObject}))\n }\n if (linkObject) {\n rules.push(createMarkdownLinkRule({linkObject}))\n }\n if (orderedList) {\n rules.push(createOrderedListRule({orderedList}))\n }\n if (unorderedList) {\n rules.push(createUnorderedListRule({unorderedList}))\n }\n return rules.length > 0 ? rules : null\n }, [\n blockquoteStyle,\n headingStyle,\n horizontalRuleObject,\n linkObject,\n orderedList,\n unorderedList,\n ])\n\n return (\n <>\n {boldDecorator ? (\n <>\n <CharacterPairDecoratorPlugin\n decorator={boldDecorator}\n pair={{char: '*', amount: 2}}\n />\n <CharacterPairDecoratorPlugin\n decorator={boldDecorator}\n pair={{char: '_', amount: 2}}\n />\n </>\n ) : null}\n {codeDecorator ? (\n <CharacterPairDecoratorPlugin\n decorator={codeDecorator}\n pair={{char: '`', amount: 1}}\n />\n ) : null}\n {italicDecorator ? (\n <>\n <CharacterPairDecoratorPlugin\n decorator={italicDecorator}\n pair={{char: '*', amount: 1}}\n />\n <CharacterPairDecoratorPlugin\n decorator={italicDecorator}\n pair={{char: '_', amount: 1}}\n />\n </>\n ) : null}\n {strikeThroughDecorator ? (\n <CharacterPairDecoratorPlugin\n decorator={strikeThroughDecorator}\n pair={{char: '~', amount: 2}}\n />\n ) : null}\n {inputRules ? <InputRulePlugin rules={inputRules} /> : null}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;AA6BA,SAAgB,wBAAwB,QAAiC;CAiHvE,OAAO,CAhHoB,eAAe;EACxC,IAAI;EACJ,QAAQ,EAAC,UAAU,YAAW;GAG5B,IAAM,eAFO,MAAM,YAAY,aAAa,QAAQ,YAE/B,CAAA,CAAK,MAAM,mCAAQ,CAAC,GAAG,IACtC,aAAa,UAAU,cAAc,QAAQ,GAC7C,iBAAiB,UAAU,kBAAkB,QAAQ;GAE3D,IAAI,CAAC,YACH,OAAO;GAGT,IAAM,WAAW,OAAO,uBAAuB,EAC7C,SAAS;IACP,QAAQ,iBAAiB,UAAU,WAAW,IAAI;IAClD,cAAc,SAAS,QAAQ;GACjC,EACF,CAAC;GAMD,OAJI,CAAC,gBAAgB,CAAC,WACb,KAGF;IAAC;IAAc;IAAU;IAAY;GAAc;EAC5D;EACA,SAAS,EACN,GAAG,EAAC,mBAAkB,CACrB,MAAM;GACJ,MAAM;GACN,MAAM;EACR,CAAC,CACH,IACC,EAAC,YAAW,EAAC,UAAU,YAAY,qBAClC,iBACI;GACE,MAAM;IACJ,MAAM;IACN,OAAO;KACL,OAAO,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AwCJ"}
1
+ {"version":3,"file":"index.js","names":["{\n blockquoteStyle,\n boldDecorator,\n codeDecorator,\n defaultStyle,\n headingStyle,\n horizontalRuleObject,\n linkObject,\n italicDecorator,\n orderedList,\n strikeThroughDecorator,\n unorderedList,\n}: MarkdownShortcutsPluginProps","() => {\n const behaviors = createMarkdownBehaviors({\n defaultStyle,\n })\n\n const unregisterBehaviors = behaviors.map((behavior) =>\n editor.registerBehavior({behavior}),\n )\n\n return () => {\n for (const unregisterBehavior of unregisterBehaviors) {\n unregisterBehavior()\n }\n }\n }","[defaultStyle, editor]","createBlockquoteRule({blockquoteStyle})","createHeadingRule({headingStyle})","createHorizontalRuleRule({horizontalRuleObject})","createMarkdownLinkRule({linkObject})","createOrderedListRule({orderedList})","createUnorderedListRule({unorderedList})","boldDecorator ? (\n <>\n <CharacterPairDecoratorPlugin\n decorator={boldDecorator}\n pair={{char: '*', amount: 2}}\n />\n <CharacterPairDecoratorPlugin\n decorator={boldDecorator}\n pair={{char: '_', amount: 2}}\n />\n </>\n ) : null","codeDecorator ? (\n <CharacterPairDecoratorPlugin\n decorator={codeDecorator}\n pair={{char: '`', amount: 1}}\n />\n ) : null","italicDecorator ? (\n <>\n <CharacterPairDecoratorPlugin\n decorator={italicDecorator}\n pair={{char: '*', amount: 1}}\n />\n <CharacterPairDecoratorPlugin\n decorator={italicDecorator}\n pair={{char: '_', amount: 1}}\n />\n </>\n ) : null","strikeThroughDecorator ? (\n <CharacterPairDecoratorPlugin\n decorator={strikeThroughDecorator}\n pair={{char: '~', amount: 2}}\n />\n ) : null","inputRules ? <InputRulePlugin rules={inputRules} /> : null","<>\n {boldDecorator ? (\n <>\n <CharacterPairDecoratorPlugin\n decorator={boldDecorator}\n pair={{char: '*', amount: 2}}\n />\n <CharacterPairDecoratorPlugin\n decorator={boldDecorator}\n pair={{char: '_', amount: 2}}\n />\n </>\n ) : null}\n {codeDecorator ? (\n <CharacterPairDecoratorPlugin\n decorator={codeDecorator}\n pair={{char: '`', amount: 1}}\n />\n ) : null}\n {italicDecorator ? (\n <>\n <CharacterPairDecoratorPlugin\n decorator={italicDecorator}\n pair={{char: '*', amount: 1}}\n />\n <CharacterPairDecoratorPlugin\n decorator={italicDecorator}\n pair={{char: '_', amount: 1}}\n />\n </>\n ) : null}\n {strikeThroughDecorator ? (\n <CharacterPairDecoratorPlugin\n decorator={strikeThroughDecorator}\n pair={{char: '~', amount: 2}}\n />\n ) : null}\n {inputRules ? <InputRulePlugin rules={inputRules} /> : null}\n </>"],"sources":["../src/behavior.markdown-shortcuts.ts","../src/rule.blockquote.ts","../src/rule.heading.ts","../src/rule.horizontal-rule.ts","../src/rule.markdown-link.ts","../src/rule.ordered-list.ts","../src/rule.unordered-list.ts","../src/plugin.markdown-shortcuts.tsx"],"sourcesContent":["import type {EditorContext} from '@portabletext/editor'\nimport {defineBehavior, raise} from '@portabletext/editor/behaviors'\nimport * as selectors from '@portabletext/editor/selectors'\nimport {getPathSubSchema, getSibling} from '@portabletext/editor/traversal'\nimport {isEmptyTextBlock, isTextBlock} from '@portabletext/editor/utils'\n\nexport type ObjectWithOptionalKey = {\n _type: string\n _key?: string\n [other: string]: unknown\n}\n\nexport type MarkdownBehaviorsConfig = {\n horizontalRuleObject?: ({\n context,\n }: {\n context: Pick<EditorContext, 'schema' | 'keyGenerator'>\n }) => ObjectWithOptionalKey | undefined\n defaultStyle?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n}\n\nexport function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {\n const automaticHrOnPaste = defineBehavior({\n on: 'clipboard.paste',\n guard: ({snapshot, event}) => {\n const text = event.originEvent.dataTransfer.getData('text/plain')\n const hrRegExp = /^(---)$|^(—-)$|^(___)$|^(\\*\\*\\*)$/\n const hrCharacters = text.match(hrRegExp)?.[0]\n const focusBlock = selectors.getFocusBlock(snapshot)\n const focusTextBlock = selectors.getFocusTextBlock(snapshot)\n\n if (!focusBlock) {\n return false\n }\n\n const hrObject = config.horizontalRuleObject?.({\n context: {\n schema: getPathSubSchema(snapshot, focusBlock.path),\n keyGenerator: snapshot.context.keyGenerator,\n },\n })\n\n if (!hrCharacters || !hrObject) {\n return false\n }\n\n return {hrCharacters, hrObject, focusBlock, focusTextBlock}\n },\n actions: [\n (_, {hrCharacters}) => [\n raise({\n type: 'insert.text',\n text: hrCharacters,\n }),\n ],\n ({snapshot}, {hrObject, focusBlock, focusTextBlock}) =>\n focusTextBlock\n ? [\n raise({\n type: 'insert.block',\n block: {\n _type: snapshot.context.schema.block.name,\n children: focusTextBlock.node.children,\n },\n placement: 'after',\n }),\n raise({\n type: 'insert.block',\n block: hrObject,\n placement: 'after',\n }),\n raise({\n type: 'delete.block',\n at: focusBlock.path,\n }),\n ]\n : [\n raise({\n type: 'insert.block',\n block: hrObject,\n placement: 'after',\n }),\n ],\n ],\n })\n\n const clearStyleOnBackspace = defineBehavior({\n on: 'delete.backward',\n guard: ({snapshot}) => {\n const selectionCollapsed = selectors.isSelectionCollapsed(snapshot)\n const focusTextBlock = selectors.getFocusTextBlock(snapshot)\n const focusSpan = selectors.getFocusSpan(snapshot)\n\n if (!selectionCollapsed || !focusTextBlock || !focusSpan) {\n return false\n }\n\n const atTheBeginningOfBLock =\n focusTextBlock.node.children[0]._key === focusSpan.node._key &&\n snapshot.context.selection?.focus.offset === 0\n\n if (!atTheBeginningOfBLock) {\n // A style can only clear at the start of the block; resolving the\n // sub-schema and calling the consumer's `defaultStyle` callback on\n // every other backspace is wasted work with a consumer-visible\n // call frequency.\n return false\n }\n\n const previousSibling = getSibling(snapshot, focusTextBlock.path, {\n direction: 'previous',\n })\n\n const previousSiblingHasTextContent =\n previousSibling !== undefined &&\n isTextBlock(snapshot.context, previousSibling.node) &&\n !isEmptyTextBlock(snapshot.context, previousSibling.node)\n\n if (previousSibling && !previousSiblingHasTextContent) {\n // An empty or object previous block takes priority over clearing\n // the style: falling through lets core's own Backspace handling\n // (list clearing, block removal) run on it first.\n return false\n }\n\n const subSchema = getPathSubSchema(snapshot, focusTextBlock.path)\n const defaultStyle = config.defaultStyle?.({\n context: {schema: subSchema},\n schema: subSchema,\n })\n\n if (defaultStyle && focusTextBlock.node.style !== defaultStyle) {\n return {defaultStyle, focusTextBlock}\n }\n\n return false\n },\n actions: [\n (_, {defaultStyle, focusTextBlock}) => [\n raise({\n type: 'block.set',\n props: {style: defaultStyle},\n at: focusTextBlock.path,\n }),\n ],\n ],\n })\n\n const markdownBehaviors = [automaticHrOnPaste, clearStyleOnBackspace]\n\n return markdownBehaviors\n}\n","import type {EditorContext} from '@portabletext/editor'\nimport {raise} from '@portabletext/editor/behaviors'\nimport {getPreviousInlineObject} from '@portabletext/editor/selectors'\nimport {getPathSubSchema} from '@portabletext/editor/traversal'\nimport {defineInputRule} from '@portabletext/plugin-input-rule'\n\nexport function createBlockquoteRule(config: {\n blockquoteStyle: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n}) {\n return defineInputRule({\n on: /^> /,\n guard: ({snapshot, event}) => {\n const subSchema = getPathSubSchema(snapshot, event.focusBlock.path)\n const style = config.blockquoteStyle({\n context: {schema: subSchema},\n schema: subSchema,\n })\n\n if (!style) {\n return false\n }\n\n const previousInlineObject = getPreviousInlineObject(snapshot)\n\n if (previousInlineObject) {\n return false\n }\n\n const match = event.matches.at(0)\n\n if (!match) {\n return false\n }\n\n return {style, match}\n },\n actions: [\n ({event}, {style, match}) => [\n raise({\n type: 'block.unset',\n props: ['listItem', 'level'],\n at: event.focusBlock.path,\n }),\n raise({\n type: 'block.set',\n props: {style},\n at: event.focusBlock.path,\n }),\n raise({\n type: 'delete',\n at: match.targetOffsets,\n }),\n ],\n ],\n })\n}\n","import type {EditorContext} from '@portabletext/editor'\nimport {raise} from '@portabletext/editor/behaviors'\nimport {getPreviousInlineObject} from '@portabletext/editor/selectors'\nimport {getPathSubSchema} from '@portabletext/editor/traversal'\nimport {defineInputRule} from '@portabletext/plugin-input-rule'\n\nexport function createHeadingRule(config: {\n headingStyle: ({\n context,\n schema,\n props,\n level,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n props: {level: number}\n /**\n * @deprecated Use `props.level` instead\n */\n level: number\n }) => string | undefined\n}) {\n return defineInputRule({\n on: /^#+ /,\n guard: ({snapshot, event}) => {\n const previousInlineObject = getPreviousInlineObject(snapshot)\n\n if (previousInlineObject) {\n return false\n }\n\n const match = event.matches.at(0)\n\n if (!match) {\n return false\n }\n\n const level = match.text.length - 1\n\n const subSchema = getPathSubSchema(snapshot, event.focusBlock.path)\n const style = config.headingStyle({\n context: {schema: subSchema},\n schema: subSchema,\n props: {level},\n level,\n })\n\n if (!style) {\n return false\n }\n\n return {match, style}\n },\n actions: [\n ({event}, {match, style}) => [\n raise({\n type: 'block.unset',\n props: ['listItem', 'level'],\n at: event.focusBlock.path,\n }),\n raise({\n type: 'block.set',\n props: {style},\n at: event.focusBlock.path,\n }),\n raise({\n type: 'delete',\n at: match.targetOffsets,\n }),\n ],\n ],\n })\n}\n","import type {EditorContext} from '@portabletext/editor'\nimport {raise} from '@portabletext/editor/behaviors'\nimport {getPreviousInlineObject} from '@portabletext/editor/selectors'\nimport {getPathSubSchema} from '@portabletext/editor/traversal'\nimport {defineInputRule} from '@portabletext/plugin-input-rule'\nimport type {ObjectWithOptionalKey} from './behavior.markdown-shortcuts'\n\nexport function createHorizontalRuleRule(config: {\n horizontalRuleObject: ({\n context,\n }: {\n context: Pick<EditorContext, 'schema' | 'keyGenerator'>\n }) => ObjectWithOptionalKey | undefined\n}) {\n return defineInputRule({\n on: /^(---)|^(—-)|^(___)|^(\\*\\*\\*)/,\n guard: ({snapshot, event}) => {\n const subSchema = getPathSubSchema(snapshot, event.focusBlock.path)\n const hrObject = config.horizontalRuleObject({\n context: {\n schema: subSchema,\n keyGenerator: snapshot.context.keyGenerator,\n },\n })\n\n if (!hrObject) {\n // If no horizontal rule object is provided, then we can safely skip\n // this rule.\n return false\n }\n\n const previousInlineObject = getPreviousInlineObject(snapshot)\n\n if (previousInlineObject) {\n // Input Rules only look at the plain text of the text block. This\n // means that the RegExp is matched even if there is a leading inline\n // object.\n return false\n }\n\n // In theory, an Input Rule could return multiple matches. But in this\n // case we only expect one match.\n const match = event.matches.at(0)\n\n if (!match) {\n return false\n }\n\n return {hrObject, match}\n },\n actions: [\n (_, {hrObject, match}) => [\n raise({\n type: 'insert.block',\n block: hrObject,\n placement: 'before',\n select: 'none',\n }),\n raise({\n type: 'delete',\n at: match.targetOffsets,\n }),\n ],\n ],\n })\n}\n","import type {EditorContext} from '@portabletext/editor'\nimport {raise, type BehaviorAction} from '@portabletext/editor/behaviors'\nimport {getPathSubSchema} from '@portabletext/editor/traversal'\nimport {defineInputRule} from '@portabletext/plugin-input-rule'\nimport type {ObjectWithOptionalKey} from './behavior.markdown-shortcuts'\n\nexport function createMarkdownLinkRule(config: {\n linkObject: ({\n context,\n props,\n }: {\n context: Pick<EditorContext, 'schema' | 'keyGenerator'>\n props: {href: string}\n }) => ObjectWithOptionalKey | undefined\n}) {\n return defineInputRule({\n on: /\\[(?<text>[^[\\]]+)]\\((?<href>.+)\\)/,\n // The rule annotates the text and deletes only the markers and the href\n // region, so an inline object inside the link TEXT is harmless and the\n // link must fire. The unlisted `href` group stays protected: deleting\n // `](href)` across an inline object would destroy it, and the captured\n // href text would silently omit it.\n inlineObjects: {allow: ['text']},\n actions: [\n ({snapshot, event}) => {\n const newText = event.textBefore + event.textInserted\n let textLengthDelta = 0\n const actions: Array<BehaviorAction> = []\n\n for (const match of event.matches.reverse()) {\n const textMatch = match.groups['text']\n const hrefMatch = match.groups['href']\n\n if (textMatch === undefined || hrefMatch === undefined) {\n continue\n }\n\n textLengthDelta =\n textLengthDelta -\n (match.targetOffsets.focus.offset -\n match.targetOffsets.anchor.offset -\n textMatch.text.length)\n\n const linkObject = config.linkObject({\n context: {\n schema: getPathSubSchema(snapshot, event.focusBlock.path),\n keyGenerator: snapshot.context.keyGenerator,\n },\n props: {href: hrefMatch.text},\n })\n\n if (!linkObject) {\n continue\n }\n\n const {_type, _key, ...value} = linkObject\n\n const leftSideOffsets = {\n anchor: match.targetOffsets.anchor,\n focus: textMatch.targetOffsets.anchor,\n }\n const rightSideOffsets = {\n anchor: textMatch.targetOffsets.focus,\n focus: match.targetOffsets.focus,\n }\n\n actions.push(\n raise({\n type: 'select',\n at: textMatch.targetOffsets,\n }),\n )\n actions.push(\n raise({\n type: 'annotation.add',\n annotation: {\n name: _type,\n _key,\n value,\n },\n }),\n )\n actions.push(\n raise({\n type: 'delete',\n at: rightSideOffsets,\n }),\n )\n actions.push(\n raise({\n type: 'delete',\n at: leftSideOffsets,\n }),\n )\n }\n\n if (actions.length === 0) {\n return []\n }\n\n const endCaretPosition = {\n path: event.focusBlock.path,\n offset: newText.length - textLengthDelta * -1,\n }\n\n return [\n ...actions,\n raise({\n type: 'select',\n at: {\n anchor: endCaretPosition,\n focus: endCaretPosition,\n },\n }),\n ]\n },\n ],\n })\n}\n","import type {EditorContext} from '@portabletext/editor'\nimport {raise} from '@portabletext/editor/behaviors'\nimport {getPreviousInlineObject} from '@portabletext/editor/selectors'\nimport {getPathSubSchema} from '@portabletext/editor/traversal'\nimport {defineInputRule} from '@portabletext/plugin-input-rule'\n\nexport function createOrderedListRule(config: {\n orderedList: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n}) {\n return defineInputRule({\n on: /^1\\. /,\n guard: ({snapshot, event}) => {\n const subSchema = getPathSubSchema(snapshot, event.focusBlock.path)\n const orderedList = config.orderedList({\n context: {schema: subSchema},\n schema: subSchema,\n })\n\n if (!orderedList) {\n return false\n }\n\n const previousInlineObject = getPreviousInlineObject(snapshot)\n\n if (previousInlineObject) {\n return false\n }\n\n const match = event.matches.at(0)\n\n if (!match) {\n return false\n }\n\n return {match, orderedList}\n },\n actions: [\n ({event}, {match, orderedList}) => [\n raise({\n type: 'block.unset',\n props: ['style'],\n at: event.focusBlock.path,\n }),\n raise({\n type: 'block.set',\n props: {\n listItem: orderedList,\n level: event.focusBlock.node.level ?? 1,\n },\n at: event.focusBlock.path,\n }),\n raise({\n type: 'delete',\n at: match.targetOffsets,\n }),\n ],\n ],\n })\n}\n","import type {EditorContext} from '@portabletext/editor'\nimport {raise} from '@portabletext/editor/behaviors'\nimport {getPreviousInlineObject} from '@portabletext/editor/selectors'\nimport {getPathSubSchema} from '@portabletext/editor/traversal'\nimport {defineInputRule} from '@portabletext/plugin-input-rule'\n\nexport function createUnorderedListRule(config: {\n unorderedList: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n}) {\n return defineInputRule({\n on: /^(-|\\*) /,\n guard: ({snapshot, event}) => {\n const subSchema = getPathSubSchema(snapshot, event.focusBlock.path)\n const unorderedList = config.unorderedList({\n context: {schema: subSchema},\n schema: subSchema,\n })\n\n if (!unorderedList) {\n return false\n }\n\n const previousInlineObject = getPreviousInlineObject(snapshot)\n\n if (previousInlineObject) {\n return false\n }\n\n const match = event.matches.at(0)\n\n if (!match) {\n return false\n }\n\n return {match, unorderedList}\n },\n actions: [\n ({event}, {match, unorderedList}) => [\n raise({\n type: 'block.unset',\n props: ['style'],\n at: event.focusBlock.path,\n }),\n raise({\n type: 'block.set',\n props: {\n listItem: unorderedList,\n level: event.focusBlock.node.level ?? 1,\n },\n at: event.focusBlock.path,\n }),\n raise({\n type: 'delete',\n at: match.targetOffsets,\n }),\n ],\n ],\n })\n}\n","import type {EditorContext} from '@portabletext/editor'\nimport {useEditor} from '@portabletext/editor'\nimport {CharacterPairDecoratorPlugin} from '@portabletext/plugin-character-pair-decorator'\nimport {InputRulePlugin} from '@portabletext/plugin-input-rule'\nimport {useEffect, useMemo} from 'react'\nimport {\n createMarkdownBehaviors,\n type MarkdownBehaviorsConfig,\n type ObjectWithOptionalKey,\n} from './behavior.markdown-shortcuts'\nimport {createBlockquoteRule} from './rule.blockquote'\nimport {createHeadingRule} from './rule.heading'\nimport {createHorizontalRuleRule} from './rule.horizontal-rule'\nimport {createMarkdownLinkRule} from './rule.markdown-link'\nimport {createOrderedListRule} from './rule.ordered-list'\nimport {createUnorderedListRule} from './rule.unordered-list'\n\n/**\n * @public\n */\nexport type MarkdownShortcutsPluginProps = MarkdownBehaviorsConfig & {\n blockquoteStyle?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n defaultStyle?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n headingStyle?: ({\n context,\n schema,\n props,\n level,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n props: {level: number}\n /**\n * @deprecated Use `props.level` instead\n */\n level: number\n }) => string | undefined\n linkObject?: ({\n context,\n props,\n }: {\n context: Pick<EditorContext, 'schema' | 'keyGenerator'>\n props: {href: string}\n }) => ObjectWithOptionalKey | undefined\n unorderedList?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n orderedList?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n boldDecorator?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n codeDecorator?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n italicDecorator?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n strikeThroughDecorator?: ({\n context,\n schema,\n }: {\n context: Pick<EditorContext, 'schema'>\n /**\n * @deprecated Use `context.schema` instead\n */\n schema: EditorContext['schema']\n }) => string | undefined\n}\n\n/**\n * @public\n */\nexport function MarkdownShortcutsPlugin({\n blockquoteStyle,\n boldDecorator,\n codeDecorator,\n defaultStyle,\n headingStyle,\n horizontalRuleObject,\n linkObject,\n italicDecorator,\n orderedList,\n strikeThroughDecorator,\n unorderedList,\n}: MarkdownShortcutsPluginProps) {\n const editor = useEditor()\n\n useEffect(() => {\n const behaviors = createMarkdownBehaviors({\n defaultStyle,\n })\n\n const unregisterBehaviors = behaviors.map((behavior) =>\n editor.registerBehavior({behavior}),\n )\n\n return () => {\n for (const unregisterBehavior of unregisterBehaviors) {\n unregisterBehavior()\n }\n }\n }, [defaultStyle, editor])\n\n const inputRules = useMemo(() => {\n const rules = []\n if (blockquoteStyle) {\n rules.push(createBlockquoteRule({blockquoteStyle}))\n }\n if (headingStyle) {\n rules.push(createHeadingRule({headingStyle}))\n }\n if (horizontalRuleObject) {\n rules.push(createHorizontalRuleRule({horizontalRuleObject}))\n }\n if (linkObject) {\n rules.push(createMarkdownLinkRule({linkObject}))\n }\n if (orderedList) {\n rules.push(createOrderedListRule({orderedList}))\n }\n if (unorderedList) {\n rules.push(createUnorderedListRule({unorderedList}))\n }\n return rules.length > 0 ? rules : null\n }, [\n blockquoteStyle,\n headingStyle,\n horizontalRuleObject,\n linkObject,\n orderedList,\n unorderedList,\n ])\n\n return (\n <>\n {boldDecorator ? (\n <>\n <CharacterPairDecoratorPlugin\n decorator={boldDecorator}\n pair={{char: '*', amount: 2}}\n />\n <CharacterPairDecoratorPlugin\n decorator={boldDecorator}\n pair={{char: '_', amount: 2}}\n />\n </>\n ) : null}\n {codeDecorator ? (\n <CharacterPairDecoratorPlugin\n decorator={codeDecorator}\n pair={{char: '`', amount: 1}}\n />\n ) : null}\n {italicDecorator ? (\n <>\n <CharacterPairDecoratorPlugin\n decorator={italicDecorator}\n pair={{char: '*', amount: 1}}\n />\n <CharacterPairDecoratorPlugin\n decorator={italicDecorator}\n pair={{char: '_', amount: 1}}\n />\n </>\n ) : null}\n {strikeThroughDecorator ? (\n <CharacterPairDecoratorPlugin\n decorator={strikeThroughDecorator}\n pair={{char: '~', amount: 2}}\n />\n ) : null}\n {inputRules ? <InputRulePlugin rules={inputRules} /> : null}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;AA8BA,SAAgB,wBAAwB,QAAiC;CAiIvE,OAAO,CAhIoB,eAAe;EACxC,IAAI;EACJ,QAAQ,EAAC,UAAU,YAAW;GAG5B,IAAM,eAFO,MAAM,YAAY,aAAa,QAAQ,YAE/B,CAAA,CAAK,MAAM,mCAAQ,CAAC,GAAG,IACtC,aAAa,UAAU,cAAc,QAAQ,GAC7C,iBAAiB,UAAU,kBAAkB,QAAQ;GAE3D,IAAI,CAAC,YACH,OAAO;GAGT,IAAM,WAAW,OAAO,uBAAuB,EAC7C,SAAS;IACP,QAAQ,iBAAiB,UAAU,WAAW,IAAI;IAClD,cAAc,SAAS,QAAQ;GACjC,EACF,CAAC;GAMD,OAJI,CAAC,gBAAgB,CAAC,WACb,KAGF;IAAC;IAAc;IAAU;IAAY;GAAc;EAC5D;EACA,SAAS,EACN,GAAG,EAAC,mBAAkB,CACrB,MAAM;GACJ,MAAM;GACN,MAAM;EACR,CAAC,CACH,IACC,EAAC,YAAW,EAAC,UAAU,YAAY,qBAClC,iBACI;GACE,MAAM;IACJ,MAAM;IACN,OAAO;KACL,OAAO,SAAS,QAAQ,OAAO,MAAM;KACrC,UAAU,eAAe,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UAAA;EACGJ;EAYAC;EAMAC;EAYAC;EAMAC;CACD,EAAA,CAAA,GArCCJ,EAAAA,MAAAA,IAYAC,EAAAA,MAAAA,IAMAC,EAAAA,MAAAA,IAYAC,EAAAA,MAAAA,IAMAC,EAAAA,MAAAA,8BArCHC;AAwCJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/plugin-markdown-shortcuts",
3
- "version": "9.0.4",
3
+ "version": "9.0.5",
4
4
  "description": "Add helpful Markdown shortcuts to the editor",
5
5
  "keywords": [
6
6
  "behaviors",
@@ -31,8 +31,8 @@
31
31
  "./package.json": "./package.json"
32
32
  },
33
33
  "dependencies": {
34
- "@portabletext/plugin-character-pair-decorator": "^9.0.4",
35
- "@portabletext/plugin-input-rule": "^7.0.4"
34
+ "@portabletext/plugin-character-pair-decorator": "^9.0.5",
35
+ "@portabletext/plugin-input-rule": "^7.0.5"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@sanity/pkg-utils": "^12.3.0",
@@ -46,13 +46,13 @@
46
46
  "typescript": "^7.0.2",
47
47
  "vite": "^8.2.0",
48
48
  "vitest": "^4.1.11",
49
- "@portabletext/editor": "^8.1.0",
49
+ "@portabletext/editor": "^8.1.1",
50
50
  "@portabletext/test": "2.0.0",
51
51
  "racejar": "3.0.0"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "react": "^19.2",
55
- "@portabletext/editor": "^8.1.0"
55
+ "@portabletext/editor": "^8.1.1"
56
56
  },
57
57
  "engines": {
58
58
  "node": ">=22.12"