jodit
4.2.5
Descargue la última versión o a través de NPM:
npm install joditObtendrá los siguientes archivos:
/esm : la versión ESM del editor (compatible con herramientas como Webpack)/es5 , /es2015 , /es2018 , /es2021 : archivos bundledes UMD (no minificado)/es5 , /es2015 , /es2018 , /es2021 con .min.js Extensión: archivos BUNDLED y minificados UMDtypes/index.d.ts : este archivo especifica la API del editor. Está versión, mientras que todo lo demás se considera privado y puede cambiar con cada lanzamiento.Incluya los siguientes dos archivos:
< link type =" text/css " rel =" stylesheet " href =" es2015/jodit.min.css " />
< script type =" text/javascript " src =" es2015/jodit.min.js " > </ script >Versión ES2021 (solo para navegadores modernos):
< link type =" text/css " rel =" stylesheet " href =" es2021/jodit.min.css " />
< script type =" text/javascript " src =" es2021/jodit.min.js " > </ script > < script type =" importmap " >
{
"imports" : {
"autobind-decorator" : "https://unpkg.com/[email protected]/lib/esm/index.js"
}
}
</ script >
< link rel =" stylesheet " href =" ./node_modules/jodit/es2021/jodit.min.css " />
< script type =" module " >
import { Jodit } from './node_modules/jodit/esm/index.js' ;
Jodit . make ( '#editor' , {
width : 600 ,
height : 400
} ) ;
</ script >Los módulos ESM incluyen automáticamente solo el conjunto básico de complementos y el idioma inglés. Puede incluir manualmente complementos e idiomas adicionales según sea necesario.
< script type =" importmap " >
{
"imports" : {
"autobind-decorator" : "https://unpkg.com/[email protected]/lib/esm/index.js"
}
}
</ script >
< link rel =" stylesheet " href =" ./node_modules/jodit/es2021/jodit.min.css " />
< script type =" module " >
import { Jodit } from './node_modules/jodit/esm/index.js' ;
import './node_modules/jodit/esm/plugins/add-new-line/add-new-line.js' ;
import './node_modules/jodit/esm/plugins/fullsize/fullsize.js' ;
import de from './node_modules/jodit/esm/langs/de.js' ;
Jodit . langs . de = de ;
Jodit . make ( '#editor' , {
width : 600 ,
height : 400 ,
language : 'de'
} ) ;
</ script > < link
rel =" stylesheet "
href =" https://cdnjs.cloudflare.com/ajax/libs/jodit/4.0.1/es2021/jodit.min.css "
/>
< script src =" https://cdnjs.cloudflare.com/ajax/libs/jodit/4.0.1/es2021/jodit.min.js " > </ script > < link
rel =" stylesheet "
href =" https://unpkg.com/[email protected]/es2021/jodit.min.css "
/>
< script src =" https://unpkg.com/[email protected]/es2021/jodit.min.js " > </ script > Agregue un elemento textarea a su HTML:
< textarea id =" editor " name =" editor " > </ textarea >Inicializar Jodit en TextAREA:
const editor = Jodit . make ( '#editor' ) ;
editor . value = '<p>start</p>' ; Jodit . plugins . yourplugin = function ( editor ) {
editor . events . on ( 'afterInit' , function ( ) {
editor . s . insertHTMl ( 'Text' ) ;
} ) ;
} ; const editor = Jodit . make ( '.someselector' , {
extraButtons : [
{
name : 'insertDate' ,
iconURL : 'https://xdsoft.net/jodit/logo.png' ,
exec : function ( editor ) {
editor . s . insertHTML ( new Date ( ) . toDateString ( ) ) ;
editor . synchronizeValues ( ) ; // For history saving
}
}
]
} ) ;o
const editor = Jodit . make ( '.someselector' , {
buttons : [ 'bold' , 'insertDate' ] ,
controls : {
insertDate : {
name : 'insertDate' ,
iconURL : 'https://xdsoft.net/jodit/logo.png' ,
exec : function ( editor ) {
editor . s . insertHTML ( new Date ( ) . toDateString ( ) ) ;
}
}
}
} ) ;botón con complemento
Jodit . plugins . add ( 'insertText' , function ( editor ) {
editor . events . on ( 'someEvent' , function ( text ) {
editor . s . insertHTMl ( 'Hello ' + text ) ;
} ) ;
} ) ;
// or
Jodit . plugins . add ( 'textLength' , {
init ( editor ) {
const div = editor . create . div ( 'jodit_div' ) ;
editor . container . appendChild ( div ) ;
editor . events . on ( 'change.textLength' , ( ) => {
div . innerText = editor . value . length ;
} ) ;
} ,
destruct ( editor ) {
editor . events . off ( 'change.textLength' ) ;
}
} ) ;
// or use class
Jodit . plugins . add (
'textLength' ,
class textLength {
init ( editor ) {
const div = editor . create . div ( 'jodit_div' ) ;
editor . container . appendChild ( div ) ;
editor . events . on ( 'change.textLength' , ( ) => {
div . innerText = editor . value . length ;
} ) ;
}
destruct ( editor ) {
editor . events . off ( 'change.textLength' ) ;
}
}
) ;
const editor = Jodit . make ( '.someselector' , {
buttons : [ 'bold' , 'insertText' ] ,
controls : {
insertText : {
iconURL : 'https://xdsoft.net/jodit/logo.png' ,
exec : function ( editor ) {
editor . events . fire ( 'someEvent' , 'world!!!' ) ;
}
}
}
} ) ; Para probar los módulos de argumento de archivos y cargador, necesita instalar el conector PHP
composer create-project --no-dev jodit/connectorEjecutar el servidor de prueba PHP
php -S localhost:8181 -t ./y establezca opciones para Jodit:
const editor = Jodit . make ( '#editor' , {
uploader : {
url : 'http://localhost:8181/index-test.php?action=fileUpload'
} ,
filebrowser : {
ajax : {
url : 'http://localhost:8181/index-test.php'
}
}
} ) ; MIT