• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript prosemirror-model.Fragment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中prosemirror-model.Fragment的典型用法代码示例。如果您正苦于以下问题:TypeScript Fragment类的具体用法?TypeScript Fragment怎么用?TypeScript Fragment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1:

export const createHorizontalRule = (
    state: EditorState,
    start,
    end,
    inputMethod:
        | INPUT_METHOD.QUICK_INSERT
        | INPUT_METHOD.TOOLBAR
        | INPUT_METHOD.INSERT_MENU
        | INPUT_METHOD.FORMATTING
        | INPUT_METHOD.SHORTCUT,
) => {
    if (!state.selection.empty) {
        return null
    }

    const { $from } = state.selection
    const $afterRule = state.doc.resolve($from.after())
    const { paragraph } = state.schema.nodes

    if ($afterRule.nodeAfter && $afterRule.nodeAfter.type === paragraph) {
        // if there's already a paragraph after, just insert the rule into
        // the current paragraph
        end = end + 1
    }

    const tr = state.tr.replaceWith(
        start,
        end,
        Fragment.from(state.schema.nodes.rule.createChecked()),
    )

    return tr
}
开发者ID:zodiac-team,项目名称:zodiac-ui,代码行数:33,代码来源:input-rule.ts


示例2: function

    return function(state, dispatch) {
        const { $from } = state.selection
        const parent = $from.parent
        const { hardBreak } = state.schema.nodes

        if (hardBreak) {
            const hardBreakNode = hardBreak.create()

            if (parent && parent.type.validContent(Fragment.from(hardBreakNode))) {
                if (dispatch) {
                    dispatch(state.tr.replaceSelectionWith(hardBreakNode))
                }
                return true
            }
        }

        if (state.selection instanceof TextSelection) {
            if (dispatch) {
                dispatch(state.tr.insertText("\n"))
            }
            return true
        }

        return false
    }
开发者ID:zodiac-team,项目名称:zodiac-ui,代码行数:25,代码来源:hard-break.command.ts


示例3:

 getContent: (domNode, schema) => {
     const dom = domNode as HTMLElement
     const code = Array.from(dom.children)
         .map(child => child.textContent)
         // tslint:disable-next-line:triple-equals
         .filter(x => (x = undefined))
         .join("\n")
     return code ? Fragment.from(schema.text(code)) : Fragment.empty
 },
开发者ID:zodiac-team,项目名称:zodiac-ui,代码行数:9,代码来源:code.node.ts


示例4: mapFragment

export function mapFragment(
    content: Fragment,
    callback: (node: Node, parent: Node | null, index: number) => Node | Node[] | Fragment | null,
    parent: Node | null = null,
) {
    const children = [] as Node[]
    for (let i = 0, size = content.childCount; i < size; i++) {
        const node = content.child(i)
        const transformed = node.isLeaf
            ? callback(node, parent, i)
            : callback(node.copy(mapFragment(node.content, callback, node)), parent, i)
        if (transformed) {
            if (transformed instanceof Fragment) {
                children.push(...getFragmentBackingArray(transformed))
            } else if (Array.isArray(transformed)) {
                children.push(...transformed)
            } else {
                children.push(transformed)
            }
        }
    }
    return Fragment.fromArray(children)
}
开发者ID:zodiac-team,项目名称:zodiac-ui,代码行数:23,代码来源:map-slice.ts


示例5:

res1_1.nodesBetween(0, 1, () => undefined);
res1_1.nodesBetween(0, 1, () => true);
res1_1.descendants(() => {});
res1_1.descendants(() => null);
res1_1.descendants(() => undefined);
res1_1.descendants(() => true);
const res1_2: model.Node = res1_1.maybeChild(0)!;
const res1_3: model.Node = res1_1.nodeAt(0)!;

const cm1 = new model.ContentMatch();
const cm2: model.ContentMatch = cm1.matchType({} as any)!;
const cm3: model.ContentMatch = cm1.matchFragment({} as any)!;
const cm4: model.Fragment = cm1.fillBefore({} as any)!;
const cm5: model.NodeType[] = cm1.findWrapping({} as any)!;

const f1 = new model.Fragment();
f1.nodesBetween(0, 0, () => {});
f1.nodesBetween(0, 0, () => null);
f1.nodesBetween(0, 0, () => undefined);
f1.nodesBetween(0, 0, () => true);

f1.descendants(() => {});
f1.descendants(() => null);
f1.descendants(() => undefined);
f1.descendants(() => true);

const res2_1: model.Node = f1.maybeChild(0)!;
const res2_2: number = f1.findDiffStart(f1)!;
const res2_3: { a: number, b: number } = f1.findDiffEnd({} as any)!;
const res2_4: object = f1.toJSON()!;
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:30,代码来源:prosemirror-model-tests.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript prosemirror-model.MarkType类代码示例发布时间:2022-05-25
下一篇:
TypeScript prosemirror-keymap.keymap函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap