jodit
4.2.5
최신 릴리스를 다운로드하거나 NPM을 통해 :
npm install jodit다음 파일을 얻을 수 있습니다.
/esm : ESTE의 ESM 버전 (Webpack과 같은 도구와 호환)/es5 , /es2015 , /es2018 , /es2021 : UMD 묶음 파일 (미수 없음)/es5 , /es2015 , /es2018 , /es2021 with .min.js Extension : UMD 번들 및 미니딩 파일types/index.d.ts :이 파일은 편집기의 API를 지정합니다. 버전이 제공되지만 다른 모든 것은 비공개로 간주되며 각 릴리스마다 변경 될 수 있습니다.다음 두 파일을 포함하십시오.
< link type =" text/css " rel =" stylesheet " href =" es2015/jodit.min.css " />
< script type =" text/javascript " src =" es2015/jodit.min.js " > </ script >ES2021 버전 (최신 브라우저 용) :
< 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 >ESM 모듈에는 기본 플러그인 세트와 영어 만 자동으로 포함됩니다. 필요에 따라 추가 플러그인과 언어를 수동으로 포함시킬 수 있습니다.
< 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 > HTML에 textarea 요소를 추가하십시오.
< textarea id =" editor " name =" editor " > </ textarea >Textarea에서 Jodit을 초기화하십시오.
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
}
}
]
} ) ;또는
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 ( ) ) ;
}
}
}
} ) ;플러그인이있는 버튼
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!!!' ) ;
}
}
}
} ) ; 파일 브라우저 및 업 로더 모듈을 테스트하려면 PHP 커넥터를 설치해야합니다.
composer create-project --no-dev jodit/connector테스트 PHP 서버를 실행하십시오
php -S localhost:8181 -t ./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