本文整理汇总了TypeScript中prosemirror-state.Transaction类的典型用法代码示例。如果您正苦于以下问题:TypeScript Transaction类的具体用法?TypeScript Transaction怎么用?TypeScript Transaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Transaction类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
const applyCodeBlock = (from: number, to: number, tr: Transaction): void => {
const { schema } = tr.doc.type
if (schema.marks.code) {
const codeMark = schema.marks.code.create()
tr.addMark(tr.mapping.map(from), tr.mapping.map(to), codeMark).setStoredMarks([codeMark])
}
}
示例2: cardAction
export const resolveCard = url => (tr: Transaction) =>
cardAction(tr, {
type: "RESOLVE",
url,
})
示例3: function
return function(state: EditorState, dispatch) {
let { tr } = state
const { $from, $to } = state.selection
const { paragraph } = state.schema.nodes
const { alignment, indentation } = state.schema.marks
/** Alignment or Indentation is not valid inside block types */
const removeAlignTr = removeBlockMarks(state, [alignment, indentation])
tr = removeAlignTr || tr
const range = $from.blockRange($to) as any
const wrapping = range && (findWrapping(range, type) as any)
if (range && wrapping) {
tr.wrap(range, wrapping).scrollIntoView()
} else {
/** We always want to append a block type */
tr.replaceRangeWith(
$to.pos + 1,
$to.pos + 1,
type.createAndFill({}, paragraph.create()),
)
tr.setSelection(Selection.near(tr.doc.resolve(state.selection.to + 1)))
}
if (dispatch) {
dispatch(tr)
}
return true
}