@prosekit/extensions
Advanced tools
Comparing version 0.1.6 to 0.2.0
@@ -6,3 +6,2 @@ import { CommandArgs } from '@prosekit/core'; | ||
import { ExtensionTyping } from '@prosekit/core'; | ||
import type { HLJSApi } from 'highlight.js'; | ||
import { IndentListOptions } from 'prosemirror-flat-list'; | ||
@@ -53,4 +52,2 @@ import { ListAttributes } from 'prosemirror-flat-list'; | ||
export declare function createPredictionPlugin(options: SuggestionOptions): Plugin_2; | ||
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>); | ||
@@ -68,6 +65,2 @@ | ||
export declare function defaultIsValid({ state }: { | ||
state: EditorState; | ||
}): boolean; | ||
export declare function defineAutocomplete(rule: AutocompleteRule): Extension; | ||
@@ -127,14 +120,3 @@ | ||
*/ | ||
export declare function defineCodeBlock(options?: { | ||
/** | ||
* @deprecated Use `defineCodeBlockHighlight` function instead. | ||
*/ | ||
hljs?: HLJSApi; | ||
/** | ||
* A parser for the `prosemirror-highlight` package to use for syntax highlighting. | ||
* | ||
* @deprecated Use the standalone `defineCodeBlockHighlight` function instead. | ||
*/ | ||
parser?: HighlightParser; | ||
}): Extension< { | ||
export declare function defineCodeBlock(): Extension< { | ||
NODES: "codeBlock"; | ||
@@ -174,9 +156,2 @@ COMMAND_ARGS: { | ||
/** | ||
* @deprecated | ||
*/ | ||
export declare function defineCodeBlockHighlightDeprecated(options: { | ||
hljs?: HLJSApi; | ||
}): Extension<ExtensionTyping<string, string, CommandArgs>>; | ||
/** | ||
* Adds input rules for `codeBlock` nodes. | ||
@@ -412,7 +387,2 @@ * | ||
/** | ||
* @deprecated Use `defineAutocomplete` instead. | ||
*/ | ||
export declare function defineSuggestion(options: SuggestionOptions): Extension<ExtensionTyping<string, string, CommandArgs>>; | ||
/** | ||
* @public | ||
@@ -478,14 +448,2 @@ */ | ||
/** | ||
* @returns Return a Transaction object if you want to append a transaction to current state (using ) | ||
*/ | ||
declare type MatchHandler_2 = (options: { | ||
rule: PredictionRule; | ||
match: RegExpMatchArray; | ||
matchAfter: RegExpMatchArray | null; | ||
state: EditorState; | ||
dismiss: VoidFunction; | ||
deleteMatch: VoidFunction; | ||
}) => void; | ||
export declare interface MentionAttrs { | ||
@@ -527,29 +485,4 @@ id: string; | ||
declare interface PredictionRule { | ||
match: RegExp; | ||
matchAfter?: RegExp; | ||
} | ||
export { PredictionRule } | ||
export { PredictionRule as PredictionRule_alias_1 } | ||
export declare function setTrMeta(tr: Transaction, meta: PredictionPluginState): Transaction; | ||
declare interface SuggestionOptions { | ||
rules: PredictionRule[]; | ||
onMatch: MatchHandler_2; | ||
onDeactivate: VoidFunction; | ||
/** | ||
* You can pass this function if you want to skip the matching in some cases. | ||
* By default, the plugin will only run the matching if the current selection | ||
* is empty, and the selection is not inside a | ||
* [code](https://prosemirror.net/docs/ref/#model.NodeSpec.code) node nor | ||
* inside a mark with the name as `code`. | ||
*/ | ||
isValid?: (options: { | ||
state: EditorState; | ||
}) => boolean; | ||
} | ||
export { SuggestionOptions } | ||
export { SuggestionOptions as SuggestionOptions_alias_1 } | ||
export { } |
@@ -33,43 +33,2 @@ // src/code-block/index.ts | ||
// src/code-block/code-block-highlight-deprecated.ts | ||
import { definePlugin as definePlugin2 } from "@prosekit/core"; | ||
import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state"; | ||
import { DecorationSet } from "@prosekit/pm/view"; | ||
import { getHighlightDecorations } from "prosemirror-highlightjs"; | ||
function defineCodeBlockHighlightDeprecated(options) { | ||
const hljs = options.hljs; | ||
const plugin = new ProseMirrorPlugin({ | ||
key, | ||
state: { | ||
init(_config, state) { | ||
const decorations = hljs ? getHighlightDecorations( | ||
state.doc, | ||
hljs, | ||
blockTypes, | ||
languageExtractor | ||
) : []; | ||
return DecorationSet.create(state.doc, decorations); | ||
}, | ||
apply(tr, set) { | ||
if (!tr.docChanged) { | ||
return set.map(tr.mapping, tr.doc); | ||
} | ||
const decorations = hljs ? getHighlightDecorations(tr.doc, hljs, blockTypes, languageExtractor) : []; | ||
return DecorationSet.create(tr.doc, decorations); | ||
} | ||
}, | ||
props: { | ||
decorations(state) { | ||
return key.getState(state); | ||
} | ||
} | ||
}); | ||
return definePlugin2(plugin); | ||
} | ||
var key = new PluginKey("prosekit-code-block-highlight"); | ||
var blockTypes = ["codeBlock"]; | ||
function languageExtractor(node) { | ||
return node.attrs.language || "javascript"; | ||
} | ||
// src/code-block/code-block-input-rule.ts | ||
@@ -121,17 +80,8 @@ import { defineInputRule, getNodeType } from "@prosekit/core"; | ||
// src/code-block/index.ts | ||
function defineCodeBlock(options) { | ||
const extensions = [ | ||
function defineCodeBlock() { | ||
return union([ | ||
defineCodeBlockSpec(), | ||
defineCodeBlockInputRule(), | ||
defineCodeBlockCommands() | ||
]; | ||
const parser = options == null ? void 0 : options.parser; | ||
if (parser) { | ||
extensions.push(defineCodeBlockHighlight({ parser })); | ||
} | ||
const hljs = options == null ? void 0 : options.hljs; | ||
if (hljs) { | ||
extensions.push(defineCodeBlockHighlightDeprecated({ hljs })); | ||
} | ||
return union(extensions); | ||
]); | ||
} | ||
@@ -138,0 +88,0 @@ export { |
{ | ||
"name": "@prosekit/extensions", | ||
"type": "module", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"private": false, | ||
@@ -109,7 +109,2 @@ "author": { | ||
}, | ||
"./suggestion": { | ||
"types": "./dist/prosekit-extensions-suggestion.d.ts", | ||
"import": "./dist/prosekit-extensions-suggestion.js", | ||
"default": "./dist/prosekit-extensions-suggestion.js" | ||
}, | ||
"./underline": { | ||
@@ -125,8 +120,6 @@ "types": "./dist/prosekit-extensions-underline.d.ts", | ||
"dependencies": { | ||
"@prosekit/core": "^0.1.8", | ||
"@prosekit/core": "^0.2.0", | ||
"@prosekit/pm": "^0.1.1", | ||
"highlight.js": "^11.9.0", | ||
"prosemirror-flat-list": "^0.4.5", | ||
"prosemirror-highlight": "^0.3.2", | ||
"prosemirror-highlightjs": "^0.9.1" | ||
"prosemirror-highlight": "^0.3.3" | ||
}, | ||
@@ -137,3 +130,3 @@ "devDependencies": { | ||
"typescript": "^5.3.3", | ||
"vitest": "^1.0.4" | ||
"vitest": "^1.1.0" | ||
}, | ||
@@ -192,5 +185,2 @@ "scripts": { | ||
], | ||
"suggestion": [ | ||
"./dist/prosekit-extensions-suggestion.d.ts" | ||
], | ||
"underline": [ | ||
@@ -197,0 +187,0 @@ "./dist/prosekit-extensions-underline.d.ts" |
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
4
47544
39
1454
+ Added@prosekit/core@0.2.7(transitive)
+ Addedclsx@2.1.1(transitive)
- Removedhighlight.js@^11.9.0
- Removedprosemirror-highlightjs@^0.9.1
- Removed@prosekit/core@0.1.9(transitive)
- Removedhighlight.js@11.11.0(transitive)
- Removedprosemirror-highlightjs@0.9.1(transitive)
Updated@prosekit/core@^0.2.0
Updatedprosemirror-highlight@^0.3.3