當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript prosemirror-state.Transaction類代碼示例

本文整理匯總了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])
    }
}
開發者ID:zodiac-team,項目名稱:zodiac-ui,代碼行數:8,代碼來源:utils.ts

示例2: cardAction

export const resolveCard = url => (tr: Transaction) =>
    cardAction(tr, {
        type: "RESOLVE",
        url,
    })
開發者ID:zodiac-team,項目名稱:zodiac-ui,代碼行數:5,代碼來源:actions.ts

示例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
    }
開發者ID:zodiac-team,項目名稱:zodiac-ui,代碼行數:28,代碼來源:keymap.ts


注:本文中的prosemirror-state.Transaction類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。