成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

SimpleMDE.JS 輕松打造一個(gè)類似簡(jiǎn)書(shū)的純前端MarkDown語(yǔ)法編輯器

netScorpion / 3561人閱讀

摘要:一直想搞一個(gè)純前端的編輯器解析器。將個(gè)人博客的文章語(yǔ)法用實(shí)現(xiàn)。試了多個(gè)純前端庫(kù)以后,感覺(jué)的用法最簡(jiǎn)單,效果也與簡(jiǎn)書(shū)等最為接近。最終效果演示最終源碼下載入門款只需要引入一個(gè)標(biāo)簽即可。從而大幅縮減開(kāi)發(fā)時(shí)間和編輯文章的時(shí)間。

一直想搞一個(gè)純前端的markdown編輯器+解析器。
將個(gè)人博客zzzmh.cn 的文章語(yǔ)法用markdown實(shí)現(xiàn)。
既可以大幅節(jié)省寫(xiě)文章耗費(fèi)時(shí)間,也能通用到簡(jiǎn)書(shū)或思否。
試了多個(gè)純前端markdown庫(kù)以后,感覺(jué)simpleMDE的用法最簡(jiǎn)單,效果也與簡(jiǎn)書(shū)等最為接近。

最終效果演示: https://tczmh.gitee.io/markdown
最終源碼下載: https://gitee.com/tczmh/markdown

入門款demo

只需要引入CSS、JS、一個(gè)textarea標(biāo)簽即可。無(wú)其他依賴。




    
    Title
    






效果圖

進(jìn)階用法



    
    Title
    
    
    







效果圖

主要用到的配置

啟用預(yù)覽模式

啟用自動(dòng)保存(每秒保存到localstorage,防刷新后丟失)

啟用代碼高亮

啟用自定義地址的font-awesome

更多內(nèi)容可以參考作者在github寫(xiě)的說(shuō)明文檔
https://github.com/sparksuite...

稍微復(fù)制一些說(shuō)明文檔中主要的配置參數(shù)說(shuō)明

(在下英語(yǔ)水平有限,翻譯就免了,交給有道翻譯吧)

autoDownloadFontAwesome: If set to true, force downloads Font Awesome (used for icons). If set to false, prevents downloading. Defaults to undefined, which will intelligently check whether Font Awesome has already been included, then download accordingly.
autofocus: If set to true, autofocuses the editor. Defaults to false.
autosave: Saves the text that"s being written and will load it back in the future. It will forget the text when the form it"s contained in is submitted.

enabled: If set to true, autosave the text. Defaults to false.

delay: Delay between saves, in milliseconds. Defaults to 10000 (10s).

uniqueId: You must set a unique string identifier so that SimpleMDE can autosave. Something that separates this from other instances of SimpleMDE elsewhere on your website.

blockStyles: Customize how certain buttons that style blocks of text behave.

bold Can be set to ** or __. Defaults to **.

code Can be set to ``` or ~~~. Defaults to ``` .

italic Can be set to * or _. Defaults to *.

element: The DOM element for the textarea to use. Defaults to the first textarea on the page.
forceSync: If set to true, force text changes made in SimpleMDE to be immediately stored in original textarea. Defaults to false.
hideIcons: An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar.
indentWithTabs: If set to false, indent using spaces instead of tabs. Defaults to true.
initialValue: If set, will customize the initial value of the editor.
insertTexts: Customize how certain buttons that insert text behave. Takes an array with two elements. The first element will be the text inserted before the cursor or highlight, and the second element will be inserted after. For example, this is the default link value: ["[", "](http://)"].

horizontalRule

image

link

table

lineWrapping: If set to false, disable line wrapping. Defaults to true.
parsingConfig: Adjust settings for parsing the Markdown during editing (not previewing).

allowAtxHeaderWithoutSpace: If set to true, will render headers without a space after the #. Defaults to false.

strikethrough: If set to false, will not process GFM strikethrough syntax. Defaults to true.

underscoresBreakWords: If set to true, let underscores be a delimiter for separating words. Defaults to false.

placeholder: Custom placeholder that should be displayed
previewRender: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.
promptURLs: If set to true, a JS alert window appears asking for the link or image URL. Defaults to false.
renderingConfig: Adjust settings for parsing the Markdown during previewing (not editing).

singleLineBreaks: If set to false, disable parsing GFM single line breaks. Defaults to true.

codeSyntaxHighlighting: If set to true, will highlight using highlight.js. Defaults to false. To use this feature you must include highlight.js on your page. For example, include the script and the CSS files like:

shortcuts: Keyboard shortcuts associated with this instance. Defaults to the array of shortcuts.
showIcons: An array of icon names to show. Can be used to show specific icons hidden by default without completely customizing the toolbar.
spellChecker: If set to false, disable the spell checker. Defaults to true.
status: If set to false, hide the status bar. Defaults to the array of built-in status bar items.

Optionally, you can set an array of status bar items to include, and in what order. You can even define your own custom status bar items.

styleSelectedText: If set to false, remove the CodeMirror-selectedtext class from selected lines. Defaults to true.
tabSize: If set, customize the tab size. Defaults to 2.
toolbar: If set to false, hide the toolbar. Defaults to the array of icons.
toolbarTips: If set to false, disable toolbar button tips. Defaults to true.

順便說(shuō)下這個(gè)工具有什么用哈

一般個(gè)人建博客站,如果是不用hexo、wp的話,就需要自己寫(xiě)個(gè)后臺(tái)新增編輯文章,這樣一來(lái)可能每篇文章就都需要用html語(yǔ)法來(lái)寫(xiě)大量代碼,消耗不少時(shí)間,還不能實(shí)時(shí)查看效果。用本工具既可以用在后臺(tái)的文章編輯,也可以把編輯器配置成頁(yè)面顯示,直接渲染出html代碼。從而大幅縮減開(kāi)發(fā)時(shí)間和編輯文章的時(shí)間。寫(xiě)出來(lái)的內(nèi)容語(yǔ)法和簡(jiǎn)書(shū)、思否等一致都是markdown,復(fù)制過(guò)來(lái)也完美兼容

END

本文也會(huì)發(fā)布在我的個(gè)人博客,并會(huì)附上在線演示,歡迎查看
https://zzzmh.cn/single?id=60
最終效果演示
https://tczmh.gitee.io/markdown
最終源碼下載
https://gitee.com/tczmh/markdown
參考
https://yq.aliyun.com/article...
simplemde官網(wǎng)
https://simplemde.com/
Github
https://github.com/sparksuite...

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/101430.html

相關(guān)文章

  • 靡不有初,鮮克有終——寫(xiě)在VNote半周歲

    摘要:舒適的編輯體驗(yàn)通過(guò)語(yǔ)法高亮,最大地消除與生俱來(lái)的編輯和閱讀的割裂感。所以,是不是又少了一個(gè)回到閱讀模式的借口代碼塊語(yǔ)法高亮通過(guò)插件可以支持代碼塊里面的代碼語(yǔ)法高亮,其他的編輯器好像沒(méi)有支持。 首發(fā)于簡(jiǎn)書(shū). showImg(https://segmentfault.com/img/remote/1460000009164987); 從去年的十一開(kāi)始到今天,VNote已經(jīng)半周歲了,也迭代到...

    roland_reed 評(píng)論0 收藏0
  • SimpleMDE輯器 + 提取HTML + 美化輸出

    摘要:不過(guò)的縮進(jìn),是個(gè)無(wú)情的痛,會(huì)呼吸的痛。使用方法在輸出的地方加上的類即可下面的代碼是給編輯器預(yù)覽輸出的容器加的。 這幾天在幫公司內(nèi)部弄編輯器,之前是用wangEditor富文本編輯器的,也不能說(shuō)別人插件不好什么的,畢竟我是寫(xiě)不出來(lái)的。不過(guò)wangEditor的縮進(jìn),是個(gè)無(wú)情的痛,會(huì)呼吸的痛。因此我找到了一款好用的markown編輯器——simpleMDE 可能你會(huì)跟我說(shuō),喲?那Edit...

    elliott_hu 評(píng)論0 收藏0
  • 超好用的谷歌瀏覽器、Sublime Text、Phpstorm、油猴插件合集

    摘要:分享一些超好用插件,打造一個(gè)不一樣的瀏覽器編輯器。一谷歌瀏覽器插件谷歌訪問(wèn)助手強(qiáng)烈推薦一鍵安裝,無(wú)需其他配置,即可訪問(wèn)谷歌。谷歌瀏覽器是很耗內(nèi)存的,該插件會(huì)自動(dòng)掛起長(zhǎng)時(shí)間未使用的網(wǎng)頁(yè),來(lái)釋放系統(tǒng)資源。 showImg(https://segmentfault.com/img/remote/1460000014011338); 分享一些超好用插件,打造一個(gè)不一樣的 GitHub、瀏覽器、...

    Rango 評(píng)論0 收藏0
  • GitHub 值得收藏的前端項(xiàng)目[每月更新...]

    摘要:也是一款優(yōu)秀的響應(yīng)式框架站點(diǎn)所使用的一套框架為微信服務(wù)量身設(shè)計(jì)的一套框架一組很小的,響應(yīng)式的組件,你可以在網(wǎng)頁(yè)的項(xiàng)目上到處使用一個(gè)可定制的文件,使瀏覽器呈現(xiàn)的所有元素,更一致和符合現(xiàn)代標(biāo)準(zhǔn)。 GitHub 值得收藏的前端項(xiàng)目 整理與收集的一些比較優(yōu)秀github項(xiàng)目,方便自己閱讀,順便分享出來(lái),大家一起學(xué)習(xí),本篇文章會(huì)持續(xù)更新,版權(quán)歸原作者所有。歡迎github star與fork 預(yù)...

    maxmin 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<