問(wèn)題描述
我正在尋找一個(gè) jQuery 插件,它將顯示一個(gè)用于 HTML 創(chuàng)作的文本區(qū)域 &編輯.
I'm looking for a jQuery Plugin that will display a textarea for HTML authoring & editing.
我正在尋找的東西:
- 必須支持編寫(xiě) HTML,而不是所見(jiàn)即所得的表示
- 必須像任何富客戶(hù)端 IDE 一樣在鍵入時(shí)為 HTML 著色.
- 應(yīng)該是 jQuery,但原生 JS 也可以.
我玩過(guò) MarkItUp,它可以讓我 90% 到達(dá)那里,但沒(méi)有提供語(yǔ)法著色.據(jù)我所知,WYMeditor 沒(méi)有代碼視圖"選項(xiàng),而只是一個(gè)所見(jiàn)即所得的視圖.
I have played with MarkItUp which gets me 90% there but offers no syntax coloring. And WYMeditor as far as I can tell has no option for "code view" and is instead just a WYSIWYG view.
過(guò)去有人做過(guò)類(lèi)似的事情嗎?
Anybody out there done something like this in the past?
推薦答案
使用 CodeMirror.它是 Google 用于他們的 API 游樂(lè)場(chǎng) 的熒光筆.
Use CodeMirror. It's the highlighter used by Google for their API playground.
我試過(guò)了,效果很好,根據(jù)他們的網(wǎng)站,它可以在以下瀏覽器中運(yùn)行:
I've tried it and it works well, and according to their site it works in the following browsers:
- Firefox 1.5 或更高版本
- Internet Explorer 6 或更高版本
- Safari 3 或更高版本
- Opera 9.52 或更高版本
- 鉻
我不明白你為什么在這種情況下提到 jQuery,因?yàn)?jQuery 與你需要做的事情沒(méi)有任何關(guān)系,除了它的選擇器引擎可以用來(lái)找到你想要啟用語(yǔ)法突出顯示的文本框(盡管如果你把 id
放在上面,你也不應(yīng)該需要 jQuery.)
I don't understand why you mention jQuery in this case, since jQuery has nothing relevant to what you need to do, other than its selector engine which could be used to find the textbox you want to enable syntax highlighting for (although if you put an id
on it you shouldn't need jQuery for that either.)
最好使用專(zhuān)門(mén)設(shè)計(jì)用于解決手頭任務(wù)的獨(dú)立庫(kù)(CodeMirror 就是這樣).您將獲得最佳性能,并且開(kāi)發(fā)人員更易于維護(hù),從而確保更好的質(zhì)量的代碼.
It's better to go with a stand-alone library that is especially designed to solve the task at hand (which CodeMirror is.) You'll get maximum performance and it'll be much more maintainable by the developers, ensuring better quality of the code.
這篇關(guān)于用于帶有語(yǔ)法著色的 HTML 編輯器的 jQuery 插件的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!