


tinymce and prism implement highlighted code and Chinese configuration method process
This article introduces to you the implementation of code highlighting and Chinese configuration of tinymce and prism. It analyzes this problem in detail through specific examples. Friends in need can refer to it.
Brief introduction: TinyMCE is a lightweight browser-based WYSIWYG editor written in JavaScript. It has very good support for IE6 and Firefox1.5. The functions are powerful and the function configuration is flexible and simple. Another feature is that the loading speed is very fast. The most important thing is that TinyMCE is a free software released under the LGPL license. You can use it for commercial applications. Enough said. If you want to know more about Baidu, let’s get to the point.
1. Edit page configuration
1. First we need to reference the web page style control file and script language editing file (the first two are tinymce script files, and the last two are prism highlight files )
1 <script type="text/javascript" src="tinymce.min.js"></script> 2 <script type="text/javascript" src="jquery.tinymce.min.js"></script> 3 <link href="prism.css" rel="stylesheet" /> 4 <script src="prism.js"></script>
2. Design our text in the body
1 <textarea name="content" style="width:100%"></textarea>
3. Initialize the text in js
(1) tinymce.init configures and initializes tinymce
(2) selector: "textarea" is specified according to your selector. Here is textarea, which can be bound to id (#···) or class (.····)
(3) plugins fill in the name of the plug-in to be used
(4) toolbar sets the toolbar to specify the display plug-in, here I show three toolbars
(5) menubar disables the menu bar Template
(6) toolbar_items_size toolbar label size is set to small
(7) style_formats is the default style initialized, this can be adjusted according to your own preferences
(8) templates template, The template in toolbar3 automatically appends the value content to the text box after selecting the title
(9) language: 'zh_CN' The language itself defaults to English, and the language specified here is Chinese
<script type="text/javascript"> tinymce.init({ selector: "textarea", plugins: [ "advlist autolink autosave link image lists charmap print preview hr anchor pagebreak spellchecker", "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking", "table contextmenu directionality emoticons template textcolor paste fullpage textcolor codesample" ], toolbar1: "undo redo | cut copy paste | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect formatselect fontselect fontsizeselect", toolbar2: " searchreplace | bullist numlist | outdent indent blockquote | link unlink anchor image media code codesample | inserttime preview | forecolor backcolor", toolbar3: "table | hr removeformat | subscript superscript | charmap emoticons | print fullscreen | ltr rtl | spellchecker | visualchars visualblocks nonbreaking template pagebreak restoredraft", menubar: false, toolbar_items_size: 'small', style_formats: [ {title: 'Bold text', inline: 'b'}, {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}}, {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}}, {title: 'Example 1', inline: 'span', classes: 'example1'}, {title: 'Example 2', inline: 'span', classes: 'example2'}, {title: 'Table styles'}, {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'} ], templates: [ {title: 'Test template 1', content: 'Test 1'}, {title: 'Test template 2', content: 'Test 2'} ], language:'zh_CN' });</script>
In addition, when we use codesample Inserting will generate the
(4) Assignment and setting value operations
1 var context=tinyMCE.activeEditor.getContent();//进行值得获取 2 3 tinyMCE.activeEditor.setContent("你的数据");//进行值得获取
2. Display page related configuration
1. Reference web page style control file and script language editing file (two highlights Display script)
1 <link href="prism.css" rel="stylesheet" /> 2 <script src="prism.js"></script>
2. Just take out the value saved by your editor and display it on the page.
Related recommendations:
How to briefly describe the basic structure of html (with code)
The above is the detailed content of tinymce and prism implement highlighted code and Chinese configuration method process. For more information, please follow other related articles on the PHP Chinese website!

The core purpose of HTML is to enable the browser to understand and display web content. 1. HTML defines the web page structure and content through tags, such as, to, etc. 2. HTML5 enhances multimedia support and introduces and tags. 3.HTML provides form elements to support user interaction. 4. Optimizing HTML code can improve web page performance, such as reducing HTTP requests and compressing HTML.

HTMLtagsareessentialforwebdevelopmentastheystructureandenhancewebpages.1)Theydefinelayout,semantics,andinteractivity.2)SemantictagsimproveaccessibilityandSEO.3)Properuseoftagscanoptimizeperformanceandensurecross-browsercompatibility.

A consistent HTML encoding style is important because it improves the readability, maintainability and efficiency of the code. 1) Use lowercase tags and attributes, 2) Keep consistent indentation, 3) Select and stick to single or double quotes, 4) Avoid mixing different styles in projects, 5) Use automation tools such as Prettier or ESLint to ensure consistency in styles.

Solution to implement multi-project carousel in Bootstrap4 Implementing multi-project carousel in Bootstrap4 is not an easy task. Although Bootstrap...

How to achieve the effect of mouse scrolling event penetration? When we browse the web, we often encounter some special interaction designs. For example, on deepseek official website, �...

The default playback control style of HTML video cannot be modified directly through CSS. 1. Create custom controls using JavaScript. 2. Beautify these controls through CSS. 3. Consider compatibility, user experience and performance, using libraries such as Video.js or Plyr can simplify the process.

Potential problems with using native select on mobile phones When developing mobile applications, we often encounter the need for selecting boxes. Normally, developers...

What are the disadvantages of using native select on your phone? When developing applications on mobile devices, it is very important to choose the right UI components. Many developers...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

WebStorm Mac version
Useful JavaScript development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version
SublimeText3 Linux latest version
