当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Selection.near方法代码示例

本文整理汇总了TypeScript中prosemirror-state.Selection.near方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Selection.near方法的具体用法?TypeScript Selection.near怎么用?TypeScript Selection.near使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在prosemirror-state.Selection的用法示例。


在下文中一共展示了Selection.near方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: 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

示例2: filterCommands

    return filterCommands(canLinkBeCreatedInRange(from, to), (state, dispatch) => {
        const link = state.schema.marks.link
        if (href.trim()) {
            const { tr } = state
            if (from === to) {
                const textContent = text || href
                tr.insertText(textContent, from, to)
                tr.addMark(
                    from,
                    from + textContent.length,
                    link.create({ href: normalizeUrl(href) }),
                )
            } else {
                tr.addMark(from, to, link.create({ href: normalizeUrl(href) }))
                tr.setSelection(Selection.near(tr.doc.resolve(to)))
            }

            // queueCardsFromChangedTr(state, tr);

            if (dispatch) {
                tr.setMeta(pluginKey, LinkAction.HIDE_TOOLBAR)
                dispatch(tr)
            }
            return true
        }
        return false
    })
开发者ID:zodiac-team,项目名称:zodiac-ui,代码行数:27,代码来源:link.commands.ts

示例3: function

    return function(state: EditorState, dispatch) {
        const { tr } = state
        const { $to } = state.selection
        const { codeBlock } = state.schema.nodes

        const getNextNode = state.doc.nodeAt($to.pos + 1)
        const addPos = getNextNode && getNextNode.isText ? 0 : 1

        /** We always want to append a block type */
        tr.replaceRangeWith($to.pos + addPos, $to.pos + addPos, codeBlock.createAndFill() as Node)
        tr.setSelection(Selection.near(tr.doc.resolve(state.selection.to + addPos)))
        if (dispatch) {
            dispatch(tr)
        }
        return true
    }
开发者ID:zodiac-team,项目名称:zodiac-ui,代码行数:16,代码来源:block-type.command.ts


注:本文中的prosemirror-state.Selection.near方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。