Socket
Socket
Sign inDemoInstall

@ckeditor/ckeditor5-autoformat

Package Overview
Dependencies
Maintainers
1
Versions
647
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckeditor/ckeditor5-autoformat - npm Package Compare versions

Comparing version 28.0.0 to 29.0.0

2

build/autoformat.js

@@ -5,2 +5,2 @@ /*!

*/
window.CKEditor5=window.CKEditor5||{},window.CKEditor5.autoformat=function(t){var e={};function o(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)o.d(n,i,function(e){return t[e]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=4)}([function(t,e){t.exports=CKEditor5.dll},function(t,e,o){t.exports=o(0)("./src/core.js")},function(t,e,o){t.exports=o(0)("./src/engine.js")},function(t,e,o){t.exports=o(0)("./src/utils.js")},function(t,e,o){"use strict";o.r(e);var n=o(1),i=o(2),r=o(3);function s(t,e,o,n){let s,d=null;"function"==typeof n?s=n:(d=t.commands.get(n),s=()=>{t.execute(n)}),t.model.document.on("change:data",(a,c)=>{if(d&&!d.isEnabled||!e.isEnabled)return;const u=Object(r.first)(t.model.document.selection.getRanges());if(!u.isCollapsed)return;if("transparent"==c.type)return;const l=Array.from(t.model.document.differ.getChanges()),f=l[0];if(1!=l.length||"insert"!==f.type||"$text"!=f.name||1!=f.length)return;const h=f.position.parent;if(h.is("element","codeBlock"))return;if(h.is("element","listItem")&&"function"!=typeof n&&!["numberedList","bulletedList","todoList"].includes(n))return;if(d&&!0===d.value)return;const g=h.getChild(0),m=t.model.createRangeOn(g);if(!m.containsRange(u)&&!u.end.isEqual(m.end))return;const p=o.exec(g.data.substr(0,u.end.offset));p&&t.model.enqueueChange(e=>{const o=e.createPositionAt(h,0),n=e.createPositionAt(h,p[0].length),r=new i.LiveRange(o,n);if(!1!==s({match:p})){e.remove(r);const o=t.model.document.selection.getFirstRange(),n=e.createRangeIn(h);!h.isEmpty||n.isEqual(o)||n.containsRange(o,!0)||e.remove(h)}r.detach()})})}function d(t,e,o,n){let i,r;o instanceof RegExp?i=o:r=o,r=r||(t=>{let e;const o=[],n=[];for(;null!==(e=i.exec(t))&&!(e&&e.length<4);){let{index:t,1:i,2:r,3:s}=e;const d=i+r+s;t+=e[0].length-d.length;const a=[t,t+i.length],c=[t+i.length+r.length,t+i.length+r.length+s.length];o.push(a),o.push(c),n.push([t+i.length,t+i.length+r.length])}return{remove:o,format:n}}),t.model.document.on("change:data",(o,i)=>{if("transparent"==i.type||!e.isEnabled)return;const s=t.model,d=s.document.selection;if(!d.isCollapsed)return;const c=Array.from(s.document.differ.getChanges()),u=c[0];if(1!=c.length||"insert"!==u.type||"$text"!=u.name||1!=u.length)return;const l=d.focus,f=l.parent,{text:h,range:g}=function(t,e){let o=t.start;return{text:Array.from(t.getItems()).reduce((t,n)=>!n.is("$text")&&!n.is("$textProxy")||n.getAttribute("code")?(o=e.createPositionAfter(n),""):t+n.data,""),range:e.createRange(o,t.end)}}(s.createRange(s.createPositionAt(f,0),l),s),m=r(h),p=a(g.start,m.format,s),b=a(g.start,m.remove,s);p.length&&b.length&&s.enqueueChange(t=>{if(!1!==n(t,p))for(const e of b.reverse())t.remove(e)})})}function a(t,e,o){return e.filter(t=>void 0!==t[0]&&void 0!==t[1]).map(e=>o.createRange(t.getShiftedBy(e[0]),t.getShiftedBy(e[1])))}class c extends n.Plugin{static get pluginName(){return"Autoformat"}afterInit(){this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats(),this._addCodeBlockAutoformats(),this._addHorizontalLineAutoformats()}_addListAutoformats(){const t=this.editor.commands;t.get("bulletedList")&&s(this.editor,this,/^[*-]\s$/,"bulletedList"),t.get("numberedList")&&s(this.editor,this,/^1[.|)]\s$/,"numberedList"),t.get("todoList")&&s(this.editor,this,/^\[\s?\]\s$/,"todoList"),t.get("checkTodoList")&&s(this.editor,this,/^\[\s?x\s?\]\s$/,()=>{this.editor.execute("todoList"),this.editor.execute("checkTodoList")})}_addBasicStylesAutoformats(){const t=this.editor.commands;if(t.get("bold")){const t=u(this.editor,"bold");d(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,t),d(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,t)}if(t.get("italic")){const t=u(this.editor,"italic");d(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,t),d(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,t)}if(t.get("code")){const t=u(this.editor,"code");d(this.editor,this,/(`)([^`]+)(`)$/g,t)}if(t.get("strikethrough")){const t=u(this.editor,"strikethrough");d(this.editor,this,/(~~)([^~]+)(~~)$/g,t)}}_addHeadingAutoformats(){const t=this.editor.commands.get("heading");t&&t.modelElements.filter(t=>t.match(/^heading[1-6]$/)).forEach(e=>{const o=e[7],n=new RegExp(`^(#{${o}})\\s$`);s(this.editor,this,n,()=>{if(!t.isEnabled||t.value===e)return!1;this.editor.execute("heading",{value:e})})})}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&s(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){this.editor.commands.get("codeBlock")&&s(this.editor,this,/^```$/,"codeBlock")}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&s(this.editor,this,/^---$/,"horizontalLine")}}function u(t,e){return(o,n)=>{if(!t.commands.get(e).isEnabled)return!1;const i=t.model.schema.getValidRanges(n,e);for(const t of i)o.setAttribute(e,!0,t);o.removeSelectionAttribute(e)}}e.default={Autoformat:c}}]).default;
window.CKEditor5=window.CKEditor5||{},window.CKEditor5.autoformat=function(t){var e={};function o(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)o.d(n,i,function(e){return t[e]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=4)}([function(t,e){t.exports=CKEditor5.dll},function(t,e,o){t.exports=o(0)("./src/core.js")},function(t,e,o){t.exports=o(0)("./src/engine.js")},function(t,e,o){t.exports=o(0)("./src/utils.js")},function(t,e,o){"use strict";o.r(e),o.d(e,"Autoformat",(function(){return c}));var n=o(1),i=o(2),r=o(3);function s(t,e,o,n){let s,d=null;"function"==typeof n?s=n:(d=t.commands.get(n),s=()=>{t.execute(n)}),t.model.document.on("change:data",(a,c)=>{if(d&&!d.isEnabled||!e.isEnabled)return;const u=Object(r.first)(t.model.document.selection.getRanges());if(!u.isCollapsed)return;if("transparent"==c.type)return;const l=Array.from(t.model.document.differ.getChanges()),f=l[0];if(1!=l.length||"insert"!==f.type||"$text"!=f.name||1!=f.length)return;const h=f.position.parent;if(h.is("element","codeBlock"))return;if(h.is("element","listItem")&&"function"!=typeof n&&!["numberedList","bulletedList","todoList"].includes(n))return;if(d&&!0===d.value)return;const g=h.getChild(0),m=t.model.createRangeOn(g);if(!m.containsRange(u)&&!u.end.isEqual(m.end))return;const p=o.exec(g.data.substr(0,u.end.offset));p&&t.model.enqueueChange(e=>{const o=e.createPositionAt(h,0),n=e.createPositionAt(h,p[0].length),r=new i.LiveRange(o,n);if(!1!==s({match:p})){e.remove(r);const o=t.model.document.selection.getFirstRange(),n=e.createRangeIn(h);!h.isEmpty||n.isEqual(o)||n.containsRange(o,!0)||e.remove(h)}r.detach()})})}function d(t,e,o,n){let i,r;o instanceof RegExp?i=o:r=o,r=r||(t=>{let e;const o=[],n=[];for(;null!==(e=i.exec(t))&&!(e&&e.length<4);){let{index:t,1:i,2:r,3:s}=e;const d=i+r+s;t+=e[0].length-d.length;const a=[t,t+i.length],c=[t+i.length+r.length,t+i.length+r.length+s.length];o.push(a),o.push(c),n.push([t+i.length,t+i.length+r.length])}return{remove:o,format:n}}),t.model.document.on("change:data",(o,i)=>{if("transparent"==i.type||!e.isEnabled)return;const s=t.model,d=s.document.selection;if(!d.isCollapsed)return;const c=Array.from(s.document.differ.getChanges()),u=c[0];if(1!=c.length||"insert"!==u.type||"$text"!=u.name||1!=u.length)return;const l=d.focus,f=l.parent,{text:h,range:g}=function(t,e){let o=t.start;return{text:Array.from(t.getItems()).reduce((t,n)=>!n.is("$text")&&!n.is("$textProxy")||n.getAttribute("code")?(o=e.createPositionAfter(n),""):t+n.data,""),range:e.createRange(o,t.end)}}(s.createRange(s.createPositionAt(f,0),l),s),m=r(h),p=a(g.start,m.format,s),b=a(g.start,m.remove,s);p.length&&b.length&&s.enqueueChange(t=>{if(!1!==n(t,p))for(const e of b.reverse())t.remove(e)})})}function a(t,e,o){return e.filter(t=>void 0!==t[0]&&void 0!==t[1]).map(e=>o.createRange(t.getShiftedBy(e[0]),t.getShiftedBy(e[1])))}class c extends n.Plugin{static get pluginName(){return"Autoformat"}afterInit(){this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats(),this._addCodeBlockAutoformats(),this._addHorizontalLineAutoformats()}_addListAutoformats(){const t=this.editor.commands;t.get("bulletedList")&&s(this.editor,this,/^[*-]\s$/,"bulletedList"),t.get("numberedList")&&s(this.editor,this,/^1[.|)]\s$/,"numberedList"),t.get("todoList")&&s(this.editor,this,/^\[\s?\]\s$/,"todoList"),t.get("checkTodoList")&&s(this.editor,this,/^\[\s?x\s?\]\s$/,()=>{this.editor.execute("todoList"),this.editor.execute("checkTodoList")})}_addBasicStylesAutoformats(){const t=this.editor.commands;if(t.get("bold")){const t=u(this.editor,"bold");d(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,t),d(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,t)}if(t.get("italic")){const t=u(this.editor,"italic");d(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,t),d(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,t)}if(t.get("code")){const t=u(this.editor,"code");d(this.editor,this,/(`)([^`]+)(`)$/g,t)}if(t.get("strikethrough")){const t=u(this.editor,"strikethrough");d(this.editor,this,/(~~)([^~]+)(~~)$/g,t)}}_addHeadingAutoformats(){const t=this.editor.commands.get("heading");t&&t.modelElements.filter(t=>t.match(/^heading[1-6]$/)).forEach(e=>{const o=e[7],n=new RegExp(`^(#{${o}})\\s$`);s(this.editor,this,n,()=>{if(!t.isEnabled||t.value===e)return!1;this.editor.execute("heading",{value:e})})})}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&s(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){this.editor.commands.get("codeBlock")&&s(this.editor,this,/^```$/,"codeBlock")}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&s(this.editor,this,/^---$/,"horizontalLine")}}function u(t,e){return(o,n)=>{if(!t.commands.get(e).isEnabled)return!1;const i=t.model.schema.getValidRanges(n,e);for(const t of i)o.setAttribute(e,!0,t);o.removeSelectionAttribute(e)}}}]);
{
"name": "@ckeditor/ckeditor5-autoformat",
"version": "28.0.0",
"version": "29.0.0",
"description": "Autoformatting feature for CKEditor 5.",

@@ -14,20 +14,20 @@ "keywords": [

"dependencies": {
"ckeditor5": "^28.0.0"
"ckeditor5": "^29.0.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-basic-styles": "^28.0.0",
"@ckeditor/ckeditor5-block-quote": "^28.0.0",
"@ckeditor/ckeditor5-code-block": "^28.0.0",
"@ckeditor/ckeditor5-core": "^28.0.0",
"@ckeditor/ckeditor5-basic-styles": "^29.0.0",
"@ckeditor/ckeditor5-block-quote": "^29.0.0",
"@ckeditor/ckeditor5-code-block": "^29.0.0",
"@ckeditor/ckeditor5-core": "^29.0.0",
"@ckeditor/ckeditor5-dev-utils": "^25.0.0",
"@ckeditor/ckeditor5-editor-classic": "^28.0.0",
"@ckeditor/ckeditor5-engine": "^28.0.0",
"@ckeditor/ckeditor5-enter": "^28.0.0",
"@ckeditor/ckeditor5-heading": "^28.0.0",
"@ckeditor/ckeditor5-horizontal-line": "^28.0.0",
"@ckeditor/ckeditor5-list": "^28.0.0",
"@ckeditor/ckeditor5-paragraph": "^28.0.0",
"@ckeditor/ckeditor5-theme-lark": "^28.0.0",
"@ckeditor/ckeditor5-typing": "^28.0.0",
"@ckeditor/ckeditor5-undo": "^28.0.0",
"@ckeditor/ckeditor5-editor-classic": "^29.0.0",
"@ckeditor/ckeditor5-engine": "^29.0.0",
"@ckeditor/ckeditor5-enter": "^29.0.0",
"@ckeditor/ckeditor5-heading": "^29.0.0",
"@ckeditor/ckeditor5-horizontal-line": "^29.0.0",
"@ckeditor/ckeditor5-list": "^29.0.0",
"@ckeditor/ckeditor5-paragraph": "^29.0.0",
"@ckeditor/ckeditor5-theme-lark": "^29.0.0",
"@ckeditor/ckeditor5-typing": "^29.0.0",
"@ckeditor/ckeditor5-undo": "^29.0.0",
"webpack": "^4.43.0",

@@ -34,0 +34,0 @@ "webpack-cli": "^3.3.11"

@@ -5,4 +5,4 @@ CKEditor 5 autoformat feature

[![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-autoformat.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-autoformat)
[![Dependency Status](https://david-dm.org/ckeditor/ckeditor5-autoformat/status.svg)](https://david-dm.org/ckeditor/ckeditor5-autoformat)
[![devDependency Status](https://david-dm.org/ckeditor/ckeditor5-autoformat/dev-status.svg)](https://david-dm.org/ckeditor/ckeditor5-autoformat?type=dev)
[![Coverage Status](https://coveralls.io/repos/github/ckeditor/ckeditor5/badge.svg?branch=master)](https://coveralls.io/github/ckeditor/ckeditor5?branch=master)
[![Build Status](https://travis-ci.com/ckeditor/ckeditor5.svg?branch=master)](https://travis-ci.com/ckeditor/ckeditor5)

@@ -9,0 +9,0 @@ This package implements the autoformatting feature for CKEditor 5. It allows styling text by typing sequences like `**bold this**`.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc