Table of Contents
Mdjs.editor
开源声明
页面截图
代码文件结构
src下文件结构
dist下文件结构变动
扩展开发可能涉及到的变量和函数
示例代码:
示例代码_Dialog
Home Web Front-end HTML Tutorial Git@OSC 推荐 | 基于 Mdjs 的 Markdown 编辑器_html/css_WEB-ITnose

Git@OSC 推荐 | 基于 Mdjs 的 Markdown 编辑器_html/css_WEB-ITnose

Jun 21, 2016 am 09:00 AM

Mdjs.editor

一款基于 Mdjs 写的在线Markdown编辑器

2016年01月11日

编辑器版本 0.1 Dev Mdjs 版本: ( 0.4 Dev )

演示页面: http://hangxingliu.github.io/mdjs.editor

欢迎大家参考学习,也望大家能够对本解析器中的不足或错误进行指正批评.

开发者: 刘越(HangxingLiu) @航行刘

[TOC]

开源声明

Mdjs遵循Apache Licence 2.0

允许使用在商业应用中,允许通过修改来满足实际需求(但需要在被修改的文件中说明).

页面截图

代码文件结构

  • src 编辑器源代码( 建议用于研究学习 )
  • dist 压缩优化过的编辑器源代码

src下文件结构

  • lib 编辑器所以来的脚本库
  • css 编辑器所依赖的样式表
  • img 编辑器内所需要的图片

  • 三个页面

    • index.html 编辑器主页面
    • settings.html 编辑器设置子页面
      • settings.css
      • settings.js
    • help.html 编辑器帮助与关于子页面
  • Toast消息显示组件(类似Android的显示一会儿的Toast组件)

    • toast.css
    • toast.js
  • Dialog对话框组件

    • dialog.css
    • dialog.js
  • 本地文件读写库(用于编辑器读写用户本地的Markdown文件)

    • localio.js
  • LocalStorage内容配置读写脚本

    • h5storage.js
  • 将Markdown生成的HTML转换为完整的HTML的导出脚本

    • export.js
  • 编辑器输入框的历史记录功能脚本(撤销,重做)

    • history.jq.js
  • 编辑器相关组件

    • editor.css
    • editor.js
  • Markdown解析成的HTML的样式表

    • mdcss.css

dist下文件结构变动

  1. lib下面与编辑器页面相关的脚本(除了 jquery.min.js 外)均合并到 editor.all.js
  2. lib下的 h5storage.js 在合并到了 editor.all.js 内仍保留一份以便于 settings.html 页面引用
  3. css下的编辑器相关的样式表均合并到 editor.all.css

扩展开发可能涉及到的变量和函数

  1. window.nowFile 目前正在编辑的Markdown内容的HTML5原生File对象
  2. window.shortcutMap 可以通过 shortcutMap[keyCode]=CallbackFunction 给编辑器绑上**Ctrl+_x_**类型的快捷键
  3. onMenu_ new / open / save / export / help / settings 分别对应了菜单栏的六个按钮的响应事件
  4. preview() 这个方法可以马上预览编辑器输入框内的Markdown内容,并且将内容保存到LocalStorage如果没有禁用的话
  5. fileStatusChange(fileOrFileName) 这个方法用于通知编辑器,当前正在编辑的Markdown文件有变化了,编辑器会同步文件名和 nowFile
  6. showIframeDlg(title,url) 显示一个大对话框,内置网页为**url**,标题为**title**
  7. LIOEvent.onDone = onReadMdDone ; LIOEvent.onError = onReadMdError ; LIOEvent.onAbort = onReadMdAbort ;这三个接口和实现的方法分别为当加载本地Markdown文件成功,失败,被中断.
    1. onDone(markdownContent)
    2. onError(errInfo)
    3. onAbort()
  8. 一些编辑器元素的JQuery对象
    1. filedlg : 用于选择本地文件的 input[type=file]
    2. editorView : 包裹编辑器输入框和预览区的 div
      1. editorView.undo() : 撤销
      2. editorView.redo() : 重做
    3. inputView : 编辑器输入框 textarea
    4. outputView : 编辑器预览区域 div
  9. 显示Toast消息:
    1. Toast.text(text,[showTime]) 普通消息
    2. Toast.warn(warnInfo,[showTime]) 警告消息
    3. Toast.err(errInfo,[showTime]) 错误消息
  10. Dialog对话框,HTML代码如下**示例代码_Dialog**
  11. 读写存在LocalStorage内的内容标题和配置可使用 H5S 对象
    1. H5S.content
    2. H5S.title
    3. H5S.settings
    4. H5S.getValue(settingKey)

示例代码:

示例代码_Dialog

<div class="dialog_bg" style="/*display: none;*/">    <div class="dialog" id="newdlg" style="display: none;">    <div class="dialog_tt">对话框标题</div>    <div class="dialog_bd">        对话框消息<br/>        <span class="dialog_warn">            警告/出错消息        </span>        <input type="text" class="dialog_input" placeholder="输入框"/>    </div>    <div class="dialog_ft">        <button class="dialog_ok" onclick="showNewFileDlg();">确定</button>        <button class="dialog_cancel" onclick="hideDialog();">取消</button>    </div></div>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1657
14
PHP Tutorial
1257
29
C# Tutorial
1229
24
Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? Apr 05, 2025 am 06:15 AM

To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

HTML, CSS, and JavaScript: Essential Tools for Web Developers HTML, CSS, and JavaScript: Essential Tools for Web Developers Apr 09, 2025 am 12:12 AM

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

HTML: The Structure, CSS: The Style, JavaScript: The Behavior HTML: The Structure, CSS: The Style, JavaScript: The Behavior Apr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web Design The Future of HTML: Evolution and Trends in Web Design Apr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

See all articles