pell

2025-12-11 0 775

V2工作分支和V2项目委员会


pell是Web的最简单,最小的Wysiwyg文本编辑器,没有依赖关系

比较

图书馆 尺寸(最小+Gzip) 尺寸(最小) jQuery 引导程序 反应 关联
pell 1.38kb 3.54KB https://gi*th*ub.*com/jaredreich/pell
乡绅 16KB 49kb https://git*hu*b.c*om/neilj/squire
中编辑 27kb 105kb https://g*ithub.c**om/yabwe/medium-editor
鹅毛笔 43kb 205kb https://gith*u*b.co*m/quilljs/quill
trix 47KB 204KB https://g*it*hub.*com/basecamp/trix
Ckeditor 163KB 551KB https://ck*e*dit*or.com
Trumbowyg 8KB 23kb x https://git*h*ub.c*om/alex-d/trumbowyg
Summernote 26KB 93kb x x https://git**hub.co*m/summernote/summernote
草稿 46kb 147KB x https://github.*c**om/facebook/draft-js
弗罗拉 52kb 186KB x https://gi*thub.*c*om/froala/wysiwyg-editor
Tinymce 157KB 491KB x https://githu**b*.com/tinymce/tinymce

特征

  • 纯JavaScript,无依赖项,用ES6编写
  • 易于使用SASS文件( pell .scs)或覆盖CSS易于自定义

包括措施:

  • 大胆的
  • 斜体
  • 强调
  • 罢工
  • 标题1
  • 标题2
  • 段落
  • 引用
  • 排序列表
  • 无序列表
  • 代码
  • 水平规则
  • 关联
  • 图像

其他可用操作(在https://developer.m*ozi*l*la.org/en-us/docs/web/api/document/execcommand上列出):

  • 证明中心合理
  • 证明充实
  • 左侧是合理的
  • 正确地证明是合理的
  • 下标
  • 上标
  • 字体名称
  • 字体大小
  • 缩进
  • 八个
  • 清晰的格式
  • 撤消
  • 重做

或创建任何自定义操作!

浏览器支持

  • 即9+(理论上,但祝你好运)
  • Chrome 5+
  • Firefox 4+
  • Safari 5+
  • 歌剧11.6+

安装

NPM:

npm install --save pell 

html:

pell.min.css\”>
<style>
/* override styles here */
. pell -content {
background-color: pink;
}
</style>
</head>
<body>

<!– Bottom of body –>
<script src=\”https://u*npkg.c**om/pell\”></script>
</body>\”>

 < head >
  ...
  < link rel =\" stylesheet \" type =\" text/css \" href =\" https://u*npkg.c**om/pell/dist/ pell .min.css \" >
  < style >
    /* override styles here */
    . pell -content {
      background-color : pink;
    }
  </ style >
</ head >
< body >
  ...
  <!-- Bottom of body -->
  < script src =\" https://u*npkg.c**om/pell \" > </ script >
</ body > 

用法

API

pell \’
// or
import { exec, init } from \’ pell \’\”>

 // ES6
import pell from \' pell \'
// or
import { exec , init } from \' pell \' 

pell
// or
window. pell \”>

 // Browser
pell
// or
window . pell 

pell on an HTMLElement
pell .init({
// <HTMLElement>, required
element: document.getElementById(\’some-id\’),

// <Function>, required
// Use the output html, triggered by element\’s `oninput` event
onChange: html => console.log(html),

// <string>, optional, default = \’div\’
// Instructs the editor which element to inject via the return key
defaultParagraphSeparator: \’div\’,

// <boolean>, optional, default = false
// Outputs <span style=\”font-weight: bold;\”></span> instead of <b></b>
styleWithCSS: false,

// <Array[string | Object]>, string if overwriting, object if customizing/creating
// action.name<string> (only required if overwriting)
// action.icon<string> (optional if overwriting, required if custom action)
// action.title<string> (optional)
// action.result<Function> (required)
// Specify the actions you specifically want (in order)
actions: [
\’bold\’,
{
name: \’custom\’,
icon: \’C\’,
title: \’Custom Action\’,
result: () => console.log(\’Do something!\’)
},
\’underline\’
],

// classes<Array[string]> (optional)
// Choose your custom class names
classes: {
actionbar: \’ pell -actionbar\’,
button: \’ pell -button\’,
content: \’ pell -content\’,
selected: \’ pell -button-selected\’
}
})

// Execute a document command, see reference:
// https://developer.mozi**l*la.org/en/docs/Web/API/Document/execCommand
// this is just `document.execCommand(command, false, value)`
pell .exec(command<string>, value<string>)\”>

 // Initialize pell on an HTMLElement
pell . init ( {
  // <HTMLElement>, required
  element : document . getElementById ( \'some-id\' ) ,

  // <Function>, required
  // Use the output html, triggered by element\'s `oninput` event
  onChange : html => console . log ( html ) ,

  // <string>, optional, default = \'div\'
  // Instructs the editor which element to inject via the return key
  defaultParagraphSeparator : \'div\' ,

  // <boolean>, optional, default = false
  // Outputs <span style=\"font-weight: bold;\"></span> instead of <b></b>
  styleWithCSS : false ,

  // <Array[string | Object]>, string if overwriting, object if customizing/creating
  // action.name<string> (only required if overwriting)
  // action.icon<string> (optional if overwriting, required if custom action)
  // action.title<string> (optional)
  // action.result<Function> (required)
  // Specify the actions you specifically want (in order)
  actions : [
    \'bold\' ,
    {
      name : \'custom\' ,
      icon : \'C\' ,
      title : \'Custom Action\' ,
      result : ( ) => console . log ( \'Do something!\' )
    } ,
    \'underline\'
  ] ,

  // classes<Array[string]> (optional)
  // Choose your custom class names
  classes : {
    actionbar : \' pell -actionbar\' ,
    button : \' pell -button\' ,
    content : \' pell -content\' ,
    selected : \' pell -button-selected\'
  }
} )

// Execute a document command, see reference:
// https://developer.mozi**l*la.org/en/docs/Web/API/Document/execCommand
// this is just `document.execCommand(command, false, value)`
pell . exec ( command < string > , value < string > ) 

覆盖动作名称的列表

  • 大胆的
  • 斜体
  • 强调
  • 罢工
  • 标题1
  • 标题2
  • 段落
  • 引用
  • olist
  • Ulist
  • 代码
  • 线
  • 关联
  • 图像

例子

一般的

pell\”></div>
<div>
HTML output:
<div id=\”html-output\” style=\”white-space:pre-wrap;\”></div>
</div>\”>

 < div id =\" editor \" class =\" pell \" > </ div >
< div >
  HTML output:
  < div id =\" html-output \" style =\" white-space:pre-wrap; \" > </ div >
</ div > 

pell\’

const editor = init({
element: document.getElementById(\’editor\’),
onChange: html => {
document.getElementById(\’html-output\’).textContent = html
},
defaultParagraphSeparator: \’p\’,
styleWithCSS: true,
actions: [
\’bold\’,
\’underline\’,
{
name: \’italic\’,
result: () => exec(\’italic\’)
},
{
name: \’backColor\’,
icon: \'<div style=\”background-color:pink;\”>A</div>\’,
title: \’Highlight Color\’,
result: () => exec(\’backColor\’, \’pink\’)
},
{
name: \’image\’,
result: () => {
const url = window.prompt(\’Enter the image URL\’)
if (url) exec(\’insertImage\’, url)
}
},
{
name: \’link\’,
result: () => {
const url = window.prompt(\’Enter the link URL\’)
if (url) exec(\’createLink\’, url)
}
}
],
classes: {
actionbar: \’ pell -actionbar-custom-name\’,
button: \’ pell -button-custom-name\’,
content: \’ pell -content-custom-name\’,
selected: \’ pell -button-selected-custom-name\’
}
})

// editor.content<HTMLElement>
// To change the editor\’s content:
editor.content.innerHTML = \'<b><u><i>Initial content!</i></u></b>\’\”>

 import { exec , init } from \' pell \'

const editor = init ( {
  element : document . getElementById ( \'editor\' ) ,
  onChange : html => {
    document . getElementById ( \'html-output\' ) . textContent = html
  } ,
  defaultParagraphSeparator : \'p\' ,
  styleWithCSS : true ,
  actions : [
    \'bold\' ,
    \'underline\' ,
    {
      name : \'italic\' ,
      result : ( ) => exec ( \'italic\' )
    } ,
    {
      name : \'backColor\' ,
      icon : \'<div style=\"background-color:pink;\">A</div>\' ,
      title : \'Highlight Color\' ,
      result : ( ) => exec ( \'backColor\' , \'pink\' )
    } ,
    {
      name : \'image\' ,
      result : ( ) => {
        const url = window . prompt ( \'Enter the image URL\' )
        if ( url ) exec ( \'insertImage\' , url )
      }
    } ,
    {
      name : \'link\' ,
      result : ( ) => {
        const url = window . prompt ( \'Enter the link URL\' )
        if ( url ) exec ( \'createLink\' , url )
      }
    }
  ] ,
  classes : {
    actionbar : \' pell -actionbar-custom-name\' ,
    button : \' pell -button-custom-name\' ,
    content : \' pell -content-custom-name\' ,
    selected : \' pell -button-selected-custom-name\'
  }
} )

// editor.content<HTMLElement>
// To change the editor\'s content:
editor . content . innerHTML = \'<b><u><i>Initial content!</i></u></b>\' 

示例(Markdown)

pell\”></div>
<div>
Markdown output:
<div id=\”markdown-output\” style=\”white-space:pre-wrap;\”></div>
</div>\”>

 < div id =\" editor \" class =\" pell \" > </ div >
< div >
  Markdown output:
  < div id =\" markdown-output \" style =\" white-space:pre-wrap; \" > </ div >
</ div > 

pell\’
import Turndown from \’turndown\’

const { turndown } = new Turndown({ headingStyle: \’atx\’ })

init({
element: document.getElementById(\’editor\’),
actions: [\’bold\’, \’italic\’, \’heading1\’, \’heading2\’, \’olist\’, \’ulist\’],
onChange: html => {
document.getElementById(\’markdown-output\’).innerHTML = turndown(html)
}
})\”>

 import { init } from \' pell \'
import Turndown from \'turndown\'

const { turndown } = new Turndown ( { headingStyle : \'atx\' } )

init ( {
  element : document . getElementById ( \'editor\' ) ,
  actions : [ \'bold\' , \'italic\' , \'heading1\' , \'heading2\' , \'olist\' , \'ulist\' ] ,
  onChange : html => {
    document . getElementById ( \'markdown-output\' ) . innerHTML = turndown ( html )
  }
} ) 

框架

  • 反应
  • Vue

定制样式

SCSS

pell-content-height: 400px;
// See all overwriteable variables in src/ pell .scss

// Then import pell .scss into styles:
@import \’../../node_modules/ pell /src/ pell \’;\”>

 $ pell -content-height : 400 px ;
// See all overwriteable variables in src/ pell .scss

// Then import pell .scss into styles:
@import \' ../../node_modules/ pell /src/ pell \' ;

CSS

pell styles are applied to DOM: */
. pell -content {
height: 400px;
}\”>

 /* After pell styles are applied to DOM: */
. pell -content {
  height : 400 px ;
}

执照

麻省理工学院

学分

浏览器浏览器测试的浏览:

下载源码

通过命令行克隆项目:

git clone https://github.com/jaredreich/pell.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 建站资源 pell https://www.zuozi.net/35170.html

vnote
上一篇: vnote
edit
下一篇: edit
常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务