xdan / jodit
出色的 WYSIWYG 编辑器和文件浏览器
4.0.0-beta.41
2023-05-08 16:50 UTC
- 4.0.0-beta.41
- 4.0.0-beta.40
- 4.0.0-beta.39
- 4.0.0-beta.38
- 4.0.0-beta.37
- 4.0.0-beta.36
- 4.0.0-beta.35
- 4.0.0-beta.34
- 4.0.0-beta.33
- 4.0.0-beta.32
- 4.0.0-beta.31
- 4.0.0-beta.30
- 4.0.0-beta.29
- 4.0.0-beta.28
- 4.0.0-beta.27
- 4.0.0-beta.26
- 4.0.0-beta.25
- 4.0.0-beta.24
- 4.0.0-beta.23
- 4.0.0-beta.22
- 4.0.0-beta.21
- 4.0.0-beta.20
- 4.0.0-beta.19
- 4.0.0-beta.18
- 4.0.0-beta.17
- 4.0.0-beta.16
- 4.0.0-beta.15
- 4.0.0-beta.14
- 4.0.0-beta.13
- 4.0.0-beta.12
- 4.0.0-beta.11
- 4.0.0-beta.10
- 4.0.0-beta.9
- 4.0.0-beta.8
- 4.0.0-beta.7
- 4.0.0-beta.6
- 3.24.9
- 3.24.8
- 3.24.7
- 3.24.6
- 3.24.5
- 3.24.4
- 3.24.3
- 3.24.2
- 3.24.1
- 3.23.3
- 3.23.2
- 3.23.1
- 3.22.1
- 3.21.5
- 3.21.4
- 3.21.3
- 3.20.4
- 3.20.3
- 3.20.2
- 3.20.1
- 3.19.5
- 3.19.4
- 3.19.3
- 3.19.2
- 3.19.1
- 3.18.9
- 3.18.8
- 3.18.7
- 3.18.6
- 3.18.5
- 3.18.4
- 3.18.3
- 3.18.2
- 3.18.1
- 3.17.1
- 3.16.6
- 3.16.5
- 3.16.4
- 3.16.3
- 3.16.2
- 3.16.1
- 3.15.3
- 3.15.2
- 3.15.1
- 3.14.3
- 3.14.2
- 3.14.1
- 3.13.6
- 3.13.5
- 3.13.4
- 3.13.3
- 3.13.2
- 3.13.1
- 3.12.5
- 3.12.4
- 3.12.3
- 3.12.2
- 3.11.4
- 3.11.3
- 3.11.2
- 3.11.1
- 3.10.2
- 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3.2.10
- 3.2.9
- 3.2.8
- 3.2.7
- 3.2.6
- 3.2.5
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.1.96
- 3.1.95
- 3.1.94
- 3.1.93
- 3.1.92
- 3.1.91
- 3.1.90
- 3.1.89
- 3.1.88
- 3.1.87
- 3.1.86
- 3.1.85
- 3.1.84
- 3.1.83
- 3.1.82
- 3.1.81
- 3.1.80
- 3.1.79
- 3.1.78
- 3.1.77
- 3.1.76
- 3.1.75
- 3.1.74
- 3.1.73
- 3.1.72
- 3.1.71
- 3.1.70
- 3.1.69
- 3.1.68
- 3.1.67
- 3.1.66
- 3.1.65
- 3.1.64
- 3.1.63
- 3.1.62
- 3.1.61
- 3.1.60
- 3.1.59
- 3.1.58
- 3.1.57
- 3.1.56
- 3.1.55
- 3.1.54
- 3.1.53
- 3.1.52
- 3.1.51
- dev-mangle-private-fields
- dev-separate-building
- dev-speech-recognize
- dev-async-bugs-17.2
- dev-lazy-walk
- dev-doca2
- dev-apply-style
- dev-generate-ts
- dev-security
- dev-refactoring
- dev-next
- dev-fixed-table-issues
- dev-feat-filebrowser
- dev-paste-refactoring
- dev-extra-plugins
- dev-es2018-build
This package is auto-updated.
Last update: 2024-09-20 23:29:38 UTC
README
Jodit 编辑器
Jodit 编辑器是一个使用纯 TypeScript 编写的出色 WYSIWYG 编辑器,不使用任何额外的库。它包括文件编辑器和图片编辑器。
开始使用
如何使用
下载最新版本 发布 或通过 npm
npm install jodit
您将获得以下文件
- 在
/esm
中:编辑器的 ESM 版本(与 webpack 等工具兼容) - 在
/es5
、/es2015
、/es2018
、/es2021
中:UMD 打包文件(未压缩) - 在
/es5
、/es2015
、/es2018
、/es2021
中,扩展名为.min.js
:UMD 打包和压缩文件 types/index.d.ts
:此文件指定了编辑器的 API。它是版本化的,而其他所有内容都视为私有,可能会随着每个版本而更改。
将 Jodit 包含到您的项目中
包含以下两个文件
ES5 版本
<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>
ESM 模块
<script type="importmap"> { "imports": { "autobind-decorator": "https://unpkg.com/autobind-decorator@2.4.0/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/autobind-decorator@2.4.0/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>
使用 CDN
cdnjs
<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>
unpkg
<link rel="stylesheet" href="https://unpkg.com/jodit@4.0.1/es2021/jodit.min.css" /> <script src="https://unpkg.com/jodit@4.0.1/es2021/jodit.min.js"></script>
用法
将 textarea
元素添加到您的 HTML 中
<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: 'https://:8181/index-test.php?action=fileUpload' }, filebrowser: { ajax: { url: 'https://:8181/index-test.php' } } });
浏览器支持
- Internet Explorer 11
- 最新版 Chrome
- 最新版 Firefox
- 最新版 Safari
- Microsoft Edge
许可证
MIT