{"id":25706414,"url":"https://github.com/bh-lay/mditor","last_synced_at":"2025-04-30T12:03:08.700Z","repository":{"id":19038133,"uuid":"22262822","full_name":"bh-lay/mditor","owner":"bh-lay","description":"一款轻量级的markdown编辑器 ediotor for markdown","archived":false,"fork":false,"pushed_at":"2017-06-19T08:51:59.000Z","size":482,"stargazers_count":88,"open_issues_count":6,"forks_count":27,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-18T19:21:29.764Z","etag":null,"topics":["editor","markdown","mditor"],"latest_commit_sha":null,"homepage":"http://bh-lay.github.io/mditor/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bh-lay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-25T16:09:47.000Z","updated_at":"2024-12-17T01:44:33.000Z","dependencies_parsed_at":"2022-08-21T00:11:01.181Z","dependency_job_id":null,"html_url":"https://github.com/bh-lay/mditor","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bh-lay%2Fmditor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bh-lay%2Fmditor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bh-lay%2Fmditor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bh-lay%2Fmditor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bh-lay","download_url":"https://codeload.github.com/bh-lay/mditor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240622808,"owners_count":19830770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["editor","markdown","mditor"],"created_at":"2025-02-25T07:33:07.952Z","updated_at":"2025-02-25T07:33:56.733Z","avatar_url":"https://github.com/bh-lay.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"欢迎使用Mditor\n======\nMditor是一款轻量级的markdown编辑器。取名自markdown + editor，用于实现页面markdown输入框的便利操作。\n\n## 查看演示\n[http://bh-lay.github.io/mditor/](http://bh-lay.github.io/mditor/)\n\n## 常用格式及快捷键\n- **加粗文字** `Ctrl + B`\n- *斜体文字* `Ctrl + I`\n- [链接文字](http://bh-lay.com/) `Ctrl + L`\n- 图片![暴漫](src/images/baoman.jpg) `Ctrl + G`\n- `code` `Ctrl + Shift + K`\n- 代码块 `Ctrl + K`：\n``` javascript\n/**\n * 检测是否为数字\n * 兼容字符类数字 '23'\n */\nfunction isNum(ipt){\n\treturn (ipt !== '') \u0026\u0026 (ipt == +ipt) ? true : false;\n}\n```\n\n---------\n\n\n## 如何使用\n\n### 第一步、页面内放置待使用的文本域textarea\n```html\n\u003ctextarea id=\"md_editor\"\u003e……\u003c/textarea\u003e\n```\n### 第二步、引入jQuery和Mditor，并初始化，\n 注：因为后续Mditor会逐渐脱离对jQuery的依赖，参数请使用原生dom对象，而非jQuery对象。\n\n```html\n\u003cscript type=\"text/javascript\" src=\"src/jquery.js\"\u003e\u003c/script\u003e\n\u003cscript type=\"text/javascript\" src=\"src/mditor.js\"\u003e\u003c/script\u003e\n\u003cscript type=\"text/javascript\"\u003e\n  //获取textarea dom对象\n  var ele_textarea = document.getElementById('md_editor');\n  //实例化Mditor\n  var editor = new mditor(ele_textarea);\n\u003c/script\u003e\n```\n## 高级操作\n为了保证编辑、发布的显示效果一致，需要按照对应站点文章样式的css来展示编辑时的效果，默认显示效果class为`article`，可参照下面定义方式更改类名。\n\n### 一、实例化Mditor时，可以传入自定义参数\n```javascript\nvar editor = new mditor(document.getElementById('md_editor'),{\n  //自定义显示效果class\n  previewClass : 'article'\n});\n```\n\n### 二、可以通过javascript对实例化后的Mditor进行操作，如：\n```javascript\n//获取转换后的html\neditor.getHtml();\n\n//获取markdown格式内容\neditor.getContent();\n\n//插入内容\neditor.insert('**挤啊挤**')\n\n//进入预览界面\neditor.preview();\n\n//返回编辑界面\neditor.edit();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbh-lay%2Fmditor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbh-lay%2Fmditor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbh-lay%2Fmditor/lists"}