Code Monkey home page Code Monkey logo

Comments (7)

Houfeng avatar Houfeng commented on September 1, 2024

@devotion987

//toolbar 是小写的
let btn = mditor.toolbar.getItem('image')

from mditor.

wugy11 avatar wugy11 commented on September 1, 2024

@Houfeng 小写也不行

from mditor.

Houfeng avatar Houfeng commented on September 1, 2024

@devotion987
是否写在了 ready 中?

//获取或设置编辑器的值
mditor.on('ready', function(){
  //toolbar 是小写的
  let btn = mditor.toolbar.getItem('image')
  console.log(btn);
});

from mditor.

wugy11 avatar wugy11 commented on September 1, 2024

我是这么写的,按照你的方式没错了,感谢!
$(document).ready(function () {

// window.mditor =
mditor = Mditor.fromTextarea(document.getElementById('md-editor'));

//更改按钮行为
//示例,更改「图片」按钮配置,其它按钮是同样的方法
let btn = mditor.toolbar.getItem('image');
//替换按钮动作
//btn.handler = function(){
//自定义处理逻辑
//this 指向当前 mditor 实例
}; 

});

from mditor.

wugy11 avatar wugy11 commented on September 1, 2024

@Houfeng 你好大神,想请教下点击“图片”工具条从本地选择图片然后上传到服务器,在上述代码
btn.handler == function() {}
代码块中该如何实现?谢谢!

from mditor.

Houfeng avatar Houfeng commented on September 1, 2024

@devotion987
你先去 google 一下,了解一些对应的浏览器 api,实现的过程中,有具体的问题,我会很乐意回答。

from mditor.

wugy11 avatar wugy11 commented on September 1, 2024

@Houfeng 最近在使用tale搭建博客,编辑器使用的是mditor,觉得图片上传功能使用不太方便,想到两种实现方式,第一种是上面说的,第二种是当使用截图工具截取图片时,ctrl+v直接复制将图片上传到本地或者七牛服务器,然后返回图片链接地址。由于本人主要做后端开发,对前端了解不太多,还请指点一二,功能完成也可以分享出来,不胜感激,另外,有QQ或Q群可以加下,方便交流!

from mditor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.