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


TypeScript Node.descendants方法代码示例

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


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

示例1: getAttrs

domOutputSpec = ['div', ['div', { class: 'foo' }, 0]];

export const nodeSpec: model.NodeSpec = {
    attrs: {
        name: { default: '' }
    },
    parseDOM: [
        {
            tag: 'span[data-name]',
            getAttrs(dom) {
                if (dom instanceof HTMLElement) {
                    return {
                        name: dom.getAttribute('data-name')!
                    };
                }
            }
        }
    ],
    toDOM(node) {
        const { name } = node.attrs;
        const attrs = {
            'data-emoji-name': name
        };
        return ['span', attrs, 0];
    }
};

const node = new model.Node();
node.nodesBetween(0, 1, () => {});
node.descendants(() => {});
开发者ID:anurse,项目名称:DefinitelyTyped,代码行数:30,代码来源:prosemirror-model-tests.ts

示例2:

        const { name } = node.attrs;
        const attrs = {
            'data-emoji-name': name
        };
        return ['span', attrs, 0];
    }
};

// Verify that non-null assertion operator can be used.

const res1_1 = new model.Node();
res1_1.nodesBetween(0, 1, () => {});
res1_1.nodesBetween(0, 1, () => null);
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);
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:31,代码来源:prosemirror-model-tests.ts


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