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

TypeScript prosemirror-commands.toggleMark函数代码示例

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

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



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

示例1: createLinkItem

 createLinkItem(url, title) {
   if (this.markActive(this.view.editor.state, this.outputSchema.marks.link)) {
     // can't see how to edit mark, only toggle. So toggle off to toggle back on with new attrs
     toggleMark(this.outputSchema.marks.link)(this.view.editor.state, this.view.props.dispatchTransaction);
   }
   toggleMark(this.outputSchema.marks.link, {
     href: url,
     title
   })(this.view.editor.state, this.view.props.dispatchTransaction);
 }
开发者ID:PRX,项目名称:publish.prx.org,代码行数:10,代码来源:prosemirror.markdown.editor.ts


示例2: return

 return (state, dispatch) => {
     const { subsup } = state.schema.marks
     if (subsup) {
         if (isMarkActive(state, subsup.create({ type: "sup" }))) {
             return toggleMark(subsup)(state, dispatch)
         }
         return toggleMark(subsup, { type: "sub" })(state, dispatch)
     }
     return false
 }
开发者ID:zodiac-team,项目名称:zodiac-ui,代码行数:10,代码来源:subsup.command.ts


示例3: return

 return (state, dispatch) => {
     const { strong } = state.schema.marks
     if (strong) {
         return toggleMark(strong)(state, dispatch)
     }
     return false
 }
开发者ID:zodiac-team,项目名称:zodiac-ui,代码行数:7,代码来源:strong.command.ts


示例4: return

 return (state, dispatch) => {
     const { em } = state.schema.marks
     if (em) {
         return toggleMark(em)(state, dispatch)
     }
     return false
 }
开发者ID:zodiac-team,项目名称:zodiac-ui,代码行数:7,代码来源:emphasis.command.ts


示例5: return

 return (state, dispatch) => {
     const { underline } = state.schema.marks
     if (underline) {
         return toggleMark(underline)(state, dispatch)
     }
     return false
 }
开发者ID:zodiac-team,项目名称:zodiac-ui,代码行数:7,代码来源:underline.command.ts


示例6: markItem

 markItem(markType, options) {
   let passedOptions = {
     active: (state) => {
       return this.markActive(state, markType);
     }
   };
   for (let prop in options) {
     if (options.hasOwnProperty(prop)) {
       passedOptions[prop] = options[prop];
     }
   }
   return this.cmdItem(toggleMark(markType), passedOptions);
 }
开发者ID:PRX,项目名称:publish.prx.org,代码行数:13,代码来源:prosemirror.markdown.editor.ts


示例7: constructor

 constructor() {
     this.tool = {
         tooltip: "Toggle Subscript",
         icon: "fa-subscript",
         run: toggleSubscript(),
         active(state) {
             const { subsup } = state.schema.marks
             if (subsup) {
                 return isMarkActive(state, subsup.create({ type: "sub" }))
             }
             return false
         },
         enable(state) {
             const { subsup } = state.schema.marks
             if (subsup) {
                 return toggleMark(subsup, { type: "sub" })(state)
             }
             return false
         },
     }
 }
开发者ID:zodiac-team,项目名称:zodiac-ui,代码行数:21,代码来源:subscript-tool.component.ts


示例8: isMarkActive

export const getTextFormattingState = (editorState: EditorState): TextFormattingState => {
    const { em, code, strike, strong, subsup, underline } = editorState.schema.marks
    const state: TextFormattingState = {}

    if (code) {
        state.codeActive = isMarkActive(editorState, code.create())
        state.codeDisabled = !toggleMark(code)(editorState)
    }
    if (em) {
        state.emActive = isMarkTypeActive(editorState, em)
        state.emDisabled = state.codeActive ? true : !toggleMark(em)(editorState)
    }
    if (strike) {
        state.strikeActive = isMarkTypeActive(editorState, strike)
        state.strikeDisabled = state.codeActive ? true : !toggleMark(strike)(editorState)
    }
    if (strong) {
        state.strongActive = isMarkTypeActive(editorState, strong)
        state.strongDisabled = state.codeActive ? true : !toggleMark(strong)(editorState)
    }
    if (subsup) {
        const subMark = subsup.create({ type: "sub" })
        const supMark = subsup.create({ type: "sup" })
        state.subscriptActive = isMarkActive(editorState, subMark)
        state.subscriptDisabled = state.codeActive
            ? true
            : !toggleMark(subsup, { type: "sub" })(editorState)
        state.superscriptActive = isMarkActive(editorState, supMark)
        state.superscriptDisabled = state.codeActive
            ? true
            : !toggleMark(subsup, { type: "sup" })(editorState)
    }
    if (underline) {
        state.underlineActive = isMarkTypeActive(editorState, underline)
        state.underlineDisabled = state.codeActive ? true : !toggleMark(underline)(editorState)
    }
    return state
}
开发者ID:zodiac-team,项目名称:zodiac-ui,代码行数:38,代码来源:utils.ts


示例9: buildKeymap

  buildKeymap(mapKeys = undefined) {
    const mac = typeof navigator !== 'undefined' ? /Mac/.test(navigator.platform) : false;
    let keys = {};
    function bind(key, cmd) {
      if (mapKeys) {
        let mapped = mapKeys[key];
        if (mapped === false) {
          return;
        }
        if (mapped) {
          key = mapped;
        }
      }
      keys[key] = cmd;
    }

    if (this.outputSchema.marks.strong) {
      bind('Mod-b', toggleMark(this.outputSchema.marks.strong));
    }
    if (this.outputSchema.marks.em) {
      bind('Mod-i', toggleMark(this.outputSchema.marks.em));
    }
    if (this.outputSchema.marks.code) {
      bind('Mod-`', toggleMark(this.outputSchema.marks.code));
    }
    if (this.outputSchema.nodes.bullet_list) {
      bind('Shift-Ctrl-8', wrapInList(this.outputSchema.nodes.bullet_list));
    }
    if (this.outputSchema.nodes.ordered_list) {
      bind('Shift-Ctrl-9', wrapInList(this.outputSchema.nodes.ordered_list));
    }
    if (this.outputSchema.nodes.blockquote) {
      bind('Ctrl->', wrapIn(this.outputSchema.nodes.blockquote));
    }
    if (this.outputSchema.nodes.hard_break) {
      let cmd = chainCommands(newlineInCode, (state, dispatchTransaction) => {
        dispatchTransaction(state.tr.replaceSelectionWith(this.outputSchema.nodes.hard_break.create()).scrollIntoView());
        return true;
      });
      bind('Mod-Enter', cmd);
      bind('Shift-Enter', cmd);
      if (mac) {
        bind('Ctrl-Enter', cmd);
      }
    }
    if (this.outputSchema.nodes.list_item) {
      bind('Enter', splitListItem(this.outputSchema.nodes.list_item));
      bind('Mod-[', liftListItem(this.outputSchema.nodes.list_item));
      bind('Mod-]', sinkListItem(this.outputSchema.nodes.list_item));
    }
    if (this.outputSchema.nodes.paragraph) {
      bind('Shift-Ctrl-0', setBlockType(this.outputSchema.nodes.paragraph));
    }
    if (this.outputSchema.nodes.code_block) {
      bind('Shift-Ctrl-\\', setBlockType(this.outputSchema.nodes.code_block));
    }
    if (this.outputSchema.nodes.heading) {
      for (let i = 1; i <= 6; i++) {
        bind('Shift-Ctrl-' + i, setBlockType(this.outputSchema.nodes.heading, {level: i}));
      }
    }
    if (this.outputSchema.nodes.horizontal_rule) {
      bind('Mod-_', (state, dispatchTransaction) => {
        dispatchTransaction(state.tr.replaceSelectionWith(this.outputSchema.nodes.horizontal_rule.create()).scrollIntoView());
        return true;
      });
    }

    return keys;
  }
开发者ID:PRX,项目名称:publish.prx.org,代码行数:70,代码来源:prosemirror.markdown.editor.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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