@ckeditor/ckeditor5-autoformat 31.1.0 → 32.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +2 -2
- package/build/autoformat.js +2 -3
- package/package.json +20 -20
- package/src/autoformat.js +1 -1
- package/src/blockautoformatediting.js +2 -2
- package/src/index.js +1 -1
- package/src/inlineautoformatediting.js +2 -2
package/LICENSE.md
CHANGED
|
@@ -2,7 +2,7 @@ Software License Agreement
|
|
|
2
2
|
==========================
|
|
3
3
|
|
|
4
4
|
**CKEditor 5 autoformat feature** – https://github.com/ckeditor/ckeditor5-autoformat <br>
|
|
5
|
-
Copyright (c) 2003-
|
|
5
|
+
Copyright (c) 2003-2022, [CKSource](http://cksource.com) Holding sp. z o.o. All rights reserved.
|
|
6
6
|
|
|
7
7
|
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
|
|
8
8
|
|
|
@@ -14,4 +14,4 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi
|
|
|
14
14
|
Trademarks
|
|
15
15
|
----------
|
|
16
16
|
|
|
17
|
-
**CKEditor** is a trademark of [CKSource](http://cksource.com)
|
|
17
|
+
**CKEditor** is a trademark of [CKSource](http://cksource.com) Holding sp. z o.o. All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
|
package/build/autoformat.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource - Frederico Knabben. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
|
-
*/
|
|
5
|
-
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=5)}([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/typing.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 u}));var n=o(1),i=o(2),r=o(3),s=o(4);function d(t,e,o,n){let i,d=null;"function"==typeof n?i=n:(d=t.commands.get(n),i=()=>{t.execute(n)}),t.model.document.on("change:data",(a,c)=>{if(d&&!d.isEnabled||!e.isEnabled)return;const u=Object(s.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 g=f.position.parent;if(g.is("element","codeBlock"))return;if(g.is("element","listItem")&&"function"!=typeof n&&!["numberedList","bulletedList","todoList"].includes(n))return;if(d&&!0===d.value)return;const h=g.getChild(0),m=t.model.createRangeOn(h);if(!m.containsRange(u)&&!u.end.isEqual(m.end))return;const p=o.exec(h.data.substr(0,u.end.offset));p&&t.model.enqueueChange(e=>{const o=e.createPositionAt(g,0),n=e.createPositionAt(g,p[0].length),s=new r.LiveRange(o,n);if(!1!==i({match:p})){e.remove(s);const o=t.model.document.selection.getFirstRange(),n=e.createRangeIn(g);!g.isEmpty||n.isEqual(o)||n.containsRange(o,!0)||e.remove(g)}s.detach(),t.model.enqueueChange(()=>{t.plugins.get("Delete").requestUndoOnBackspace()})})})}function a(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 a=Array.from(s.document.differ.getChanges()),u=a[0];if(1!=a.length||"insert"!==u.type||"$text"!=u.name||1!=u.length)return;const l=d.focus,f=l.parent,{text:g,range:h}=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(g),p=c(h.start,m.format,s),b=c(h.start,m.remove,s);p.length&&b.length&&s.enqueueChange(e=>{if(!1!==n(e,p)){for(const t of b.reverse())e.remove(t);s.enqueueChange(()=>{t.plugins.get("Delete").requestUndoOnBackspace()})}})})}function c(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 u extends n.Plugin{static get requires(){return[i.Delete]}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")&&d(this.editor,this,/^[*-]\s$/,"bulletedList"),t.get("numberedList")&&d(this.editor,this,/^1[.|)]\s$/,"numberedList"),t.get("todoList")&&d(this.editor,this,/^\[\s?\]\s$/,"todoList"),t.get("checkTodoList")&&d(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=l(this.editor,"bold");a(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,t),a(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,t)}if(t.get("italic")){const t=l(this.editor,"italic");a(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,t),a(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,t)}if(t.get("code")){const t=l(this.editor,"code");a(this.editor,this,/(`)([^`]+)(`)$/g,t)}if(t.get("strikethrough")){const t=l(this.editor,"strikethrough");a(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$`);d(this.editor,this,n,()=>{if(!t.isEnabled||t.value===e)return!1;this.editor.execute("heading",{value:e})})})}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&d(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const t=this.editor,e=t.model.document.selection;t.commands.get("codeBlock")&&d(t,this,/^```$/,()=>{if(e.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})})}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&d(this.editor,this,/^---$/,"horizontalLine")}}function l(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)}}}]);
|
|
4
|
+
*/(()=>{var t={704:(t,e,o)=>{t.exports=o(79)("./src/core.js")},492:(t,e,o)=>{t.exports=o(79)("./src/engine.js")},181:(t,e,o)=>{t.exports=o(79)("./src/typing.js")},209:(t,e,o)=>{t.exports=o(79)("./src/utils.js")},79:t=>{"use strict";t.exports=CKEditor5.dll}},e={};function o(i){var s=e[i];if(void 0!==s)return s.exports;var n=e[i]={exports:{}};return t[i](n,n.exports,o),n.exports}o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};(()=>{"use strict";o.r(i),o.d(i,{Autoformat:()=>c});var t=o(704),e=o(181),s=o(492),n=o(209);function r(t,e,o,i){let r,d=null;"function"==typeof i?r=i:(d=t.commands.get(i),r=()=>{t.execute(i)}),t.model.document.on("change:data",((a,c)=>{if(d&&!d.isEnabled||!e.isEnabled)return;const l=(0,n.first)(t.model.document.selection.getRanges());if(!l.isCollapsed)return;if(c.isUndo||!c.isLocal)return;const u=Array.from(t.model.document.differ.getChanges()),h=u[0];if(1!=u.length||"insert"!==h.type||"$text"!=h.name||1!=h.length)return;const g=h.position.parent;if(g.is("element","codeBlock"))return;if(g.is("element","listItem")&&"function"!=typeof i&&!["numberedList","bulletedList","todoList"].includes(i))return;if(d&&!0===d.value)return;const m=g.getChild(0),f=t.model.createRangeOn(m);if(!f.containsRange(l)&&!l.end.isEqual(f.end))return;const p=o.exec(m.data.substr(0,l.end.offset));p&&t.model.enqueueChange((e=>{const o=e.createPositionAt(g,0),i=e.createPositionAt(g,p[0].length),n=new s.LiveRange(o,i);if(!1!==r({match:p})){e.remove(n);const o=t.model.document.selection.getFirstRange(),i=e.createRangeIn(g);!g.isEmpty||i.isEqual(o)||i.containsRange(o,!0)||e.remove(g)}n.detach(),t.model.enqueueChange((()=>{t.plugins.get("Delete").requestUndoOnBackspace()}))}))}))}function d(t,e,o,i){let s,n;o instanceof RegExp?s=o:n=o,n=n||(t=>{let e;const o=[],i=[];for(;null!==(e=s.exec(t))&&!(e&&e.length<4);){let{index:t,1:s,2:n,3:r}=e;const d=s+n+r;t+=e[0].length-d.length;const a=[t,t+s.length],c=[t+s.length+n.length,t+s.length+n.length+r.length];o.push(a),o.push(c),i.push([t+s.length,t+s.length+n.length])}return{remove:o,format:i}}),t.model.document.on("change:data",((o,s)=>{if(s.isUndo||!s.isLocal||!e.isEnabled)return;const r=t.model,d=r.document.selection;if(!d.isCollapsed)return;const c=Array.from(r.document.differ.getChanges()),l=c[0];if(1!=c.length||"insert"!==l.type||"$text"!=l.name||1!=l.length)return;const u=d.focus,h=u.parent,{text:g,range:m}=function(t,e){let o=t.start;return{text:Array.from(t.getItems()).reduce(((t,i)=>!i.is("$text")&&!i.is("$textProxy")||i.getAttribute("code")?(o=e.createPositionAfter(i),""):t+i.data),""),range:e.createRange(o,t.end)}}(r.createRange(r.createPositionAt(h,0),u),r),f=n(g),p=a(m.start,f.format,r),x=a(m.start,f.remove,r);p.length&&x.length&&r.enqueueChange((e=>{if(!1!==i(e,p)){for(const t of x.reverse())e.remove(t);r.enqueueChange((()=>{t.plugins.get("Delete").requestUndoOnBackspace()}))}}))}))}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 t.Plugin{static get requires(){return[e.Delete]}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")&&r(this.editor,this,/^[*-]\s$/,"bulletedList"),t.get("numberedList")&&r(this.editor,this,/^1[.|)]\s$/,"numberedList"),t.get("todoList")&&r(this.editor,this,/^\[\s?\]\s$/,"todoList"),t.get("checkTodoList")&&r(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=l(this.editor,"bold");d(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,t),d(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,t)}if(t.get("italic")){const t=l(this.editor,"italic");d(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,t),d(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,t)}if(t.get("code")){const t=l(this.editor,"code");d(this.editor,this,/(`)([^`]+)(`)$/g,t)}if(t.get("strikethrough")){const t=l(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],i=new RegExp(`^(#{${o}})\\s$`);r(this.editor,this,i,(()=>{if(!t.isEnabled||t.value===e)return!1;this.editor.execute("heading",{value:e})}))}))}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&r(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const t=this.editor,e=t.model.document.selection;t.commands.get("codeBlock")&&r(t,this,/^```$/,(()=>{if(e.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})}))}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&r(this.editor,this,/^---$/,"horizontalLine")}}function l(t,e){return(o,i)=>{if(!t.commands.get(e).isEnabled)return!1;const s=t.model.schema.getValidRanges(i,e);for(const t of s)o.setAttribute(e,!0,t);o.removeSelectionAttribute(e)}}})(),(window.CKEditor5=window.CKEditor5||{}).autoformat=i})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-autoformat",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "32.0.0",
|
|
4
4
|
"description": "Autoformatting feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -12,29 +12,29 @@
|
|
|
12
12
|
],
|
|
13
13
|
"main": "src/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"ckeditor5": "^
|
|
15
|
+
"ckeditor5": "^32.0.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@ckeditor/ckeditor5-basic-styles": "^
|
|
19
|
-
"@ckeditor/ckeditor5-block-quote": "^
|
|
20
|
-
"@ckeditor/ckeditor5-code-block": "^
|
|
21
|
-
"@ckeditor/ckeditor5-core": "^
|
|
22
|
-
"@ckeditor/ckeditor5-dev-utils": "^
|
|
23
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
|
24
|
-
"@ckeditor/ckeditor5-engine": "^
|
|
25
|
-
"@ckeditor/ckeditor5-enter": "^
|
|
26
|
-
"@ckeditor/ckeditor5-heading": "^
|
|
27
|
-
"@ckeditor/ckeditor5-horizontal-line": "^
|
|
28
|
-
"@ckeditor/ckeditor5-list": "^
|
|
29
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
|
30
|
-
"@ckeditor/ckeditor5-theme-lark": "^
|
|
31
|
-
"@ckeditor/ckeditor5-typing": "^
|
|
32
|
-
"@ckeditor/ckeditor5-undo": "^
|
|
33
|
-
"webpack": "^
|
|
34
|
-
"webpack-cli": "^
|
|
18
|
+
"@ckeditor/ckeditor5-basic-styles": "^32.0.0",
|
|
19
|
+
"@ckeditor/ckeditor5-block-quote": "^32.0.0",
|
|
20
|
+
"@ckeditor/ckeditor5-code-block": "^32.0.0",
|
|
21
|
+
"@ckeditor/ckeditor5-core": "^32.0.0",
|
|
22
|
+
"@ckeditor/ckeditor5-dev-utils": "^27.1.0",
|
|
23
|
+
"@ckeditor/ckeditor5-editor-classic": "^32.0.0",
|
|
24
|
+
"@ckeditor/ckeditor5-engine": "^32.0.0",
|
|
25
|
+
"@ckeditor/ckeditor5-enter": "^32.0.0",
|
|
26
|
+
"@ckeditor/ckeditor5-heading": "^32.0.0",
|
|
27
|
+
"@ckeditor/ckeditor5-horizontal-line": "^32.0.0",
|
|
28
|
+
"@ckeditor/ckeditor5-list": "^32.0.0",
|
|
29
|
+
"@ckeditor/ckeditor5-paragraph": "^32.0.0",
|
|
30
|
+
"@ckeditor/ckeditor5-theme-lark": "^32.0.0",
|
|
31
|
+
"@ckeditor/ckeditor5-typing": "^32.0.0",
|
|
32
|
+
"@ckeditor/ckeditor5-undo": "^32.0.0",
|
|
33
|
+
"webpack": "^5.58.1",
|
|
34
|
+
"webpack-cli": "^4.9.0"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
|
-
"node": ">=
|
|
37
|
+
"node": ">=14.0.0",
|
|
38
38
|
"npm": ">=5.7.1"
|
|
39
39
|
},
|
|
40
40
|
"author": "CKSource (http://cksource.com/)",
|
package/src/autoformat.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -77,7 +77,7 @@ export default function blockAutoformatEditing( editor, plugin, pattern, callbac
|
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
if ( batch.
|
|
80
|
+
if ( batch.isUndo || !batch.isLocal ) {
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
83
|
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -125,7 +125,7 @@ export default function inlineAutoformatEditing( editor, plugin, testRegexpOrCal
|
|
|
125
125
|
} );
|
|
126
126
|
|
|
127
127
|
editor.model.document.on( 'change:data', ( evt, batch ) => {
|
|
128
|
-
if ( batch.
|
|
128
|
+
if ( batch.isUndo || !batch.isLocal || !plugin.isEnabled ) {
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
131
|
|