prosemirror-flat-list
Advanced tools
Comparing version 0.4.6 to 0.5.0
@@ -365,2 +365,18 @@ import type { Attrs } from 'prosemirror-model'; | ||
/** | ||
* A callback function to get the attributes for a list input rule. | ||
* | ||
* @public @group Input Rules | ||
*/ | ||
export declare type ListInputRuleAttributesGetter<T extends ListAttributes = ListAttributes> = (options: { | ||
/** | ||
* The match result of the regular expression. | ||
*/ | ||
match: RegExpMatchArray; | ||
/** | ||
* The previous attributes of the existing list node, if it exists. | ||
*/ | ||
attributes?: T; | ||
}) => T; | ||
/** | ||
* All input rules for lists. | ||
@@ -527,4 +543,4 @@ * | ||
*/ | ||
export declare function wrappingListInputRule<T extends ListAttributes = ListAttributes>(regexp: RegExp, getAttrs: T | ((matches: RegExpMatchArray) => T)): InputRule; | ||
export declare function wrappingListInputRule<T extends ListAttributes = ListAttributes>(regexp: RegExp, getAttrs: T | ListInputRuleAttributesGetter<T>): InputRule; | ||
export { } |
@@ -1449,3 +1449,2 @@ // src/commands/dedent-list.ts | ||
tr.deleteRange(start, end); | ||
const attrs = typeof getAttrs === "function" ? getAttrs(match) : getAttrs; | ||
const $pos = tr.selection.$from; | ||
@@ -1455,10 +1454,14 @@ const listNode = $pos.index(-1) === 0 && $pos.node(-1); | ||
const oldAttrs = listNode.attrs; | ||
const newAttrs = { ...oldAttrs, ...attrs }; | ||
const needUpdate = Object.keys(newAttrs).some( | ||
(key) => newAttrs[key] !== oldAttrs[key] | ||
); | ||
if (needUpdate) { | ||
return tr.setNodeMarkup($pos.before(-1), void 0, newAttrs); | ||
const newAttrs2 = typeof getAttrs === "function" ? getAttrs({ match, attributes: oldAttrs }) : getAttrs; | ||
const entries = Object.entries(newAttrs2).filter(([key, value]) => { | ||
return oldAttrs[key] !== value; | ||
}); | ||
if (entries.length === 0) { | ||
return null; | ||
} else { | ||
return null; | ||
const pos = $pos.before(-1); | ||
for (const [key, value] of entries) { | ||
tr.setNodeAttribute(pos, key, value); | ||
} | ||
return tr; | ||
} | ||
@@ -1471,3 +1474,4 @@ } | ||
} | ||
const wrapping = findWrapping2(range, getListType(state.schema), attrs); | ||
const newAttrs = typeof getAttrs === "function" ? getAttrs({ match }) : getAttrs; | ||
const wrapping = findWrapping2(range, getListType(state.schema), newAttrs); | ||
if (!wrapping) { | ||
@@ -1485,3 +1489,3 @@ return null; | ||
}), | ||
wrappingListInputRule(/^\s?(\d+)\.\s$/, (match) => { | ||
wrappingListInputRule(/^\s?(\d+)\.\s$/, ({ match }) => { | ||
const order = parseInteger(match[1]); | ||
@@ -1494,3 +1498,3 @@ return { | ||
}), | ||
wrappingListInputRule(/^\s?\[([\sXx]?)]\s$/, (match) => { | ||
wrappingListInputRule(/^\s?\[([\sXx]?)]\s$/, ({ match }) => { | ||
return { | ||
@@ -1497,0 +1501,0 @@ kind: "task", |
@@ -8,5 +8,5 @@ // This file is read by tools that parse documentation comments conforming to the TSDoc standard. | ||
"packageName": "@microsoft/api-extractor", | ||
"packageVersion": "7.39.0" | ||
"packageVersion": "7.39.4" | ||
} | ||
] | ||
} |
{ | ||
"name": "prosemirror-flat-list", | ||
"type": "module", | ||
"version": "0.4.6", | ||
"version": "0.5.0", | ||
"description": "Powerful list support for ProseMirror", | ||
@@ -38,3 +38,3 @@ "author": "ocavue <ocavue@gmail.com>", | ||
"prosemirror-commands": "^1.5.2", | ||
"prosemirror-inputrules": "^1.3.0", | ||
"prosemirror-inputrules": "^1.4.0", | ||
"prosemirror-model": "^1.19.4", | ||
@@ -46,3 +46,3 @@ "prosemirror-state": "^1.4.3", | ||
"devDependencies": { | ||
"@microsoft/api-extractor": "^7.39.0", | ||
"@microsoft/api-extractor": "^7.39.4", | ||
"@remirror/core": "^2.0.19", | ||
@@ -55,4 +55,4 @@ "@remirror/extension-blockquote": "^2.0.14", | ||
"@types/dedent": "^0.7.2", | ||
"@types/node": "^20.10.6", | ||
"@vitest/coverage-v8": "^1.1.1", | ||
"@types/node": "^20.11.14", | ||
"@vitest/coverage-v8": "^1.4.0", | ||
"dedent": "^1.5.1", | ||
@@ -62,5 +62,5 @@ "execa": "^8.0.1", | ||
"jest-remirror": "^2.1.5", | ||
"jsdom": "^23.0.1", | ||
"jsdom": "^23.2.0", | ||
"npm-run-all": "^4.1.5", | ||
"postcss": "^8.4.32", | ||
"postcss": "^8.4.33", | ||
"postcss-nesting": "^12.0.2", | ||
@@ -72,3 +72,3 @@ "react": "^18.2.0", | ||
"remark-parse": "^11.0.0", | ||
"remark-rehype": "^11.0.0", | ||
"remark-rehype": "^11.1.0", | ||
"remirror": "^2.0.38", | ||
@@ -78,4 +78,4 @@ "tsup": "^8.0.1", | ||
"unified": "^11.0.4", | ||
"vite": "^5.0.10", | ||
"vitest": "^1.1.1" | ||
"vite": "^5.1.6", | ||
"vitest": "^1.4.0" | ||
}, | ||
@@ -82,0 +82,0 @@ "typedocOptions": { |
Sorry, the diff of this file is not supported yet
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
132103
4083