@prosekit/extensions
Advanced tools
Comparing version 0.2.1 to 0.2.2
import { Attrs } from '@prosekit/pm/model'; | ||
import type { BundledTheme } from 'shikiji'; | ||
import type { Command } from '@prosekit/pm/state'; | ||
import { CommandArgs } from '@prosekit/core'; | ||
@@ -20,2 +21,3 @@ import type { ContentMatch } from '@prosekit/pm/model'; | ||
import { ProseMirrorNode } from '@prosekit/pm/model'; | ||
import type { Selection as Selection_2 } from '@prosekit/pm/state'; | ||
import { ToggleCollapsedOptions } from 'prosemirror-flat-list'; | ||
@@ -572,2 +574,4 @@ import { Transaction } from '@prosekit/pm/state'; | ||
export declare function isInCodeBlock(selection: Selection_2): boolean | undefined; | ||
/** | ||
@@ -651,2 +655,4 @@ * @public | ||
export declare function withSkipCodeBlock(command: Command): Command; | ||
export { } |
import { | ||
isInCodeBlock | ||
} from "./chunk-DI46QWLX.js"; | ||
import { | ||
defineTextBlockInputRule | ||
@@ -15,2 +18,14 @@ } from "./chunk-DYFRBXUX.js"; | ||
} from "@prosekit/core"; | ||
// src/utils/with-skip-code-block.ts | ||
function withSkipCodeBlock(command) { | ||
return (state, dispatch, view) => { | ||
if (isInCodeBlock(state.selection)) { | ||
return false; | ||
} | ||
return command(state, dispatch, view); | ||
}; | ||
} | ||
// src/heading/index.ts | ||
function defineHeadingSpec() { | ||
@@ -38,10 +53,13 @@ return defineNodeSpec({ | ||
return defineKeymap({ | ||
"mod-1": toggleNode({ type: "heading", attrs: { level: 1 } }), | ||
"mod-2": toggleNode({ type: "heading", attrs: { level: 2 } }), | ||
"mod-3": toggleNode({ type: "heading", attrs: { level: 3 } }), | ||
"mod-4": toggleNode({ type: "heading", attrs: { level: 4 } }), | ||
"mod-5": toggleNode({ type: "heading", attrs: { level: 5 } }), | ||
"mod-6": toggleNode({ type: "heading", attrs: { level: 6 } }) | ||
"mod-1": toggleHeadingKeybinding(1), | ||
"mod-2": toggleHeadingKeybinding(2), | ||
"mod-3": toggleHeadingKeybinding(3), | ||
"mod-4": toggleHeadingKeybinding(4), | ||
"mod-5": toggleHeadingKeybinding(5), | ||
"mod-6": toggleHeadingKeybinding(6) | ||
}); | ||
} | ||
function toggleHeadingKeybinding(level) { | ||
return withSkipCodeBlock(toggleNode({ type: "heading", attrs: { level } })); | ||
} | ||
function defineHeadingInputRule() { | ||
@@ -48,0 +66,0 @@ return defineTextBlockInputRule({ |
@@ -0,1 +1,5 @@ | ||
import { | ||
isInCodeBlock | ||
} from "./chunk-DI46QWLX.js"; | ||
// src/placeholder/index.ts | ||
@@ -17,2 +21,5 @@ import { definePlugin } from "@prosekit/core"; | ||
} | ||
if (isInCodeBlock(state.selection)) { | ||
return null; | ||
} | ||
const placeholderText = options.placeholder; | ||
@@ -19,0 +26,0 @@ const deco = createPlaceholderDecoration(state, placeholderText); |
{ | ||
"name": "@prosekit/extensions", | ||
"type": "module", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"private": false, | ||
@@ -124,3 +124,3 @@ "author": { | ||
"dependencies": { | ||
"@prosekit/core": "^0.2.0", | ||
"@prosekit/core": "^0.2.2", | ||
"@prosekit/pm": "^0.1.1", | ||
@@ -127,0 +127,0 @@ "prosemirror-flat-list": "^0.4.5", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61487
44
1926
Updated@prosekit/core@^0.2.2