@milkdown/prose
Advanced tools
Comparing version 7.2.2 to 7.2.3
@@ -1,2 +0,2 @@ | ||
import { PluginKey, Plugin, NodeSelection } from 'prosemirror-state'; | ||
import { PluginKey, Plugin, NodeSelection, AllSelection } from 'prosemirror-state'; | ||
import { InputRule } from 'prosemirror-inputrules'; | ||
@@ -288,3 +288,37 @@ import { expectDomTypeError, missingRootElement, getAtomFromSchemaFail } from '@milkdown/exception'; | ||
export { browser, calculateNodePosition, calculateTextPosition, cloneTr, customInputRules, customInputRulesKey, equalNodeType, findChildren, findChildrenByMark, findParentNode, findParentNodeClosestToPos, findSelectedNodeOfType, flatten, getMarkFromSchema, getNodeFromSchema, markRule, posToDOMRect }; | ||
const toggleMarkdownMark = (markType, mark) => { | ||
return (state, dispatch) => { | ||
var _a; | ||
const { tr, selection } = state; | ||
const { from, to, $cursor, ranges } = selection; | ||
const cursorMarks = (_a = $cursor == null ? void 0 : $cursor.marks()) != null ? _a : []; | ||
if ($cursor) { | ||
if (markType.isInSet(state.storedMarks || cursorMarks)) { | ||
dispatch == null ? void 0 : dispatch(tr.removeStoredMark(markType)); | ||
return true; | ||
} | ||
dispatch == null ? void 0 : dispatch(tr.addStoredMark(markType.create())); | ||
return true; | ||
} | ||
let has = false; | ||
for (let i = 0; !has && i < ranges.length; i++) { | ||
const { $from, $to } = ranges[i]; | ||
has = state.doc.rangeHasMark($from.pos, $to.pos, markType); | ||
} | ||
if (has) { | ||
for (let i = 0; i < ranges.length; i++) { | ||
const { $from, $to } = ranges[i]; | ||
tr.removeMark($from.pos, $to.pos, markType); | ||
} | ||
dispatch == null ? void 0 : dispatch(tr.scrollIntoView()); | ||
return true; | ||
} | ||
if (selection instanceof AllSelection) | ||
return false; | ||
dispatch == null ? void 0 : dispatch(tr.insertText(mark, from).insertText(mark, to + mark.length).scrollIntoView()); | ||
return true; | ||
}; | ||
}; | ||
export { browser, calculateNodePosition, calculateTextPosition, cloneTr, customInputRules, customInputRulesKey, equalNodeType, findChildren, findChildrenByMark, findParentNode, findParentNodeClosestToPos, findSelectedNodeOfType, flatten, getMarkFromSchema, getNodeFromSchema, markRule, posToDOMRect, toggleMarkdownMark }; | ||
//# sourceMappingURL=index.js.map |
import { InputRule } from 'prosemirror-inputrules'; | ||
import { PluginKey, Plugin, Transaction, Selection } from 'prosemirror-state'; | ||
import { PluginKey, Plugin, Transaction, Selection, Command } from 'prosemirror-state'; | ||
import { MarkType, NodeType, Node, Schema, ResolvedPos } from 'prosemirror-model'; | ||
@@ -92,3 +92,5 @@ import { EditorView } from 'prosemirror-view'; | ||
export { ContentNodeWithPos, NodeWithPos, browser, calculateNodePosition, calculateTextPosition, cloneTr, customInputRules, customInputRulesKey, equalNodeType, findChildren, findChildrenByMark, findParentNode, findParentNodeClosestToPos, findSelectedNodeOfType, flatten, getMarkFromSchema, getNodeFromSchema, markRule, posToDOMRect }; | ||
declare const toggleMarkdownMark: (markType: MarkType, mark: string) => Command; | ||
export { ContentNodeWithPos, NodeWithPos, browser, calculateNodePosition, calculateTextPosition, cloneTr, customInputRules, customInputRulesKey, equalNodeType, findChildren, findChildrenByMark, findParentNode, findParentNodeClosestToPos, findSelectedNodeOfType, flatten, getMarkFromSchema, getNodeFromSchema, markRule, posToDOMRect, toggleMarkdownMark }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { PluginKey, Plugin, NodeSelection } from 'prosemirror-state'; | ||
import { PluginKey, Plugin, NodeSelection, AllSelection } from 'prosemirror-state'; | ||
import { InputRule } from 'prosemirror-inputrules'; | ||
@@ -288,3 +288,37 @@ import { expectDomTypeError, missingRootElement, getAtomFromSchemaFail } from '@milkdown/exception'; | ||
export { browser, calculateNodePosition, calculateTextPosition, cloneTr, customInputRules, customInputRulesKey, equalNodeType, findChildren, findChildrenByMark, findParentNode, findParentNodeClosestToPos, findSelectedNodeOfType, flatten, getMarkFromSchema, getNodeFromSchema, markRule, posToDOMRect }; | ||
const toggleMarkdownMark = (markType, mark) => { | ||
return (state, dispatch) => { | ||
var _a; | ||
const { tr, selection } = state; | ||
const { from, to, $cursor, ranges } = selection; | ||
const cursorMarks = (_a = $cursor == null ? void 0 : $cursor.marks()) != null ? _a : []; | ||
if ($cursor) { | ||
if (markType.isInSet(state.storedMarks || cursorMarks)) { | ||
dispatch == null ? void 0 : dispatch(tr.removeStoredMark(markType)); | ||
return true; | ||
} | ||
dispatch == null ? void 0 : dispatch(tr.addStoredMark(markType.create())); | ||
return true; | ||
} | ||
let has = false; | ||
for (let i = 0; !has && i < ranges.length; i++) { | ||
const { $from, $to } = ranges[i]; | ||
has = state.doc.rangeHasMark($from.pos, $to.pos, markType); | ||
} | ||
if (has) { | ||
for (let i = 0; i < ranges.length; i++) { | ||
const { $from, $to } = ranges[i]; | ||
tr.removeMark($from.pos, $to.pos, markType); | ||
} | ||
dispatch == null ? void 0 : dispatch(tr.scrollIntoView()); | ||
return true; | ||
} | ||
if (selection instanceof AllSelection) | ||
return false; | ||
dispatch == null ? void 0 : dispatch(tr.insertText(mark, from).insertText(mark, to + mark.length).scrollIntoView()); | ||
return true; | ||
}; | ||
}; | ||
export { browser, calculateNodePosition, calculateTextPosition, cloneTr, customInputRules, customInputRulesKey, equalNodeType, findChildren, findChildrenByMark, findParentNode, findParentNodeClosestToPos, findSelectedNodeOfType, flatten, getMarkFromSchema, getNodeFromSchema, markRule, posToDOMRect, toggleMarkdownMark }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@milkdown/prose", | ||
"type": "module", | ||
"version": "7.2.2", | ||
"version": "7.2.3", | ||
"license": "MIT", | ||
@@ -133,3 +133,3 @@ "repository": { | ||
"tslib": "^2.5.0", | ||
"@milkdown/exception": "7.2.2" | ||
"@milkdown/exception": "7.2.3" | ||
}, | ||
@@ -136,0 +136,0 @@ "nx": { |
@@ -6,1 +6,2 @@ /* Copyright 2021, Milkdown by Mirone. */ | ||
export * from './prose' | ||
export * from './commands' |
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
80269
91
1262
+ Added@milkdown/exception@7.2.3(transitive)
- Removed@milkdown/exception@7.2.2(transitive)
Updated@milkdown/exception@7.2.3