@ckeditor/ckeditor5-minimap 47.6.1 → 48.0.0-alpha.1
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/ckeditor5-metadata.json +1 -1
- package/dist/index-editor.css +55 -59
- package/dist/index.css +55 -65
- package/dist/index.css.map +1 -1
- package/dist/index.js.map +1 -1
- package/{src → dist}/minimap.d.ts +1 -1
- package/{src → dist}/minimapiframeview.d.ts +2 -2
- package/{src → dist}/minimappositiontrackerview.d.ts +2 -2
- package/{src → dist}/minimapview.d.ts +2 -2
- package/{src → dist}/utils.d.ts +2 -2
- package/package.json +22 -45
- package/build/minimap.js +0 -4
- package/src/augmentation.js +0 -5
- package/src/index.js +0 -13
- package/src/minimap.js +0 -183
- package/src/minimapconfig.js +0 -5
- package/src/minimapiframeview.js +0 -136
- package/src/minimappositiontrackerview.js +0 -78
- package/src/minimapview.js +0 -149
- package/src/utils.js +0 -96
- package/theme/minimap.css +0 -80
- /package/{src → dist}/augmentation.d.ts +0 -0
- /package/{src → dist}/index.d.ts +0 -0
- /package/{src → dist}/minimapconfig.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,63 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-minimap",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "48.0.0-alpha.1",
|
|
4
4
|
"description": "Content minimap feature for CKEditor 5.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
|
+
"author": "CKSource (http://cksource.com/)",
|
|
7
|
+
"homepage": "https://ckeditor.com/ckeditor-5",
|
|
8
|
+
"bugs": "https://github.com/ckeditor/ckeditor5/issues",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/ckeditor/ckeditor5.git",
|
|
12
|
+
"directory": "packages/ckeditor5-minimap"
|
|
13
|
+
},
|
|
5
14
|
"keywords": [
|
|
6
15
|
"ckeditor",
|
|
7
16
|
"ckeditor5",
|
|
8
17
|
"ckeditor 5",
|
|
9
18
|
"ckeditor5-feature",
|
|
10
|
-
"ckeditor5-plugin"
|
|
11
|
-
"ckeditor5-dll"
|
|
19
|
+
"ckeditor5-plugin"
|
|
12
20
|
],
|
|
13
21
|
"type": "module",
|
|
14
|
-
"main": "
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"@ckeditor/ckeditor5-utils": "47.6.1",
|
|
20
|
-
"ckeditor5": "47.6.1"
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": "./dist/index.js",
|
|
25
|
+
"./dist/*": "./dist/*",
|
|
26
|
+
"./package.json": "./package.json"
|
|
21
27
|
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"type": "git",
|
|
28
|
-
"url": "https://github.com/ckeditor/ckeditor5.git",
|
|
29
|
-
"directory": "packages/ckeditor5-minimap"
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@ckeditor/ckeditor5-core": "48.0.0-alpha.1",
|
|
30
|
+
"@ckeditor/ckeditor5-engine": "48.0.0-alpha.1",
|
|
31
|
+
"@ckeditor/ckeditor5-ui": "48.0.0-alpha.1",
|
|
32
|
+
"@ckeditor/ckeditor5-utils": "48.0.0-alpha.1"
|
|
30
33
|
},
|
|
31
34
|
"files": [
|
|
32
35
|
"dist",
|
|
33
|
-
"lang",
|
|
34
|
-
"src/**/*.js",
|
|
35
|
-
"src/**/*.d.ts",
|
|
36
|
-
"theme",
|
|
37
|
-
"build",
|
|
38
36
|
"ckeditor5-metadata.json",
|
|
39
37
|
"CHANGELOG.md"
|
|
40
38
|
],
|
|
41
|
-
"types": "
|
|
42
|
-
"exports": {
|
|
43
|
-
".": {
|
|
44
|
-
"types": "./src/index.d.ts",
|
|
45
|
-
"import": "./src/index.js",
|
|
46
|
-
"default": "./src/index.js"
|
|
47
|
-
},
|
|
48
|
-
"./dist/*": {
|
|
49
|
-
"types": "./src/index.d.ts",
|
|
50
|
-
"import": "./dist/*",
|
|
51
|
-
"default": "./dist/*"
|
|
52
|
-
},
|
|
53
|
-
"./src/*": {
|
|
54
|
-
"types": "./src/*.d.ts",
|
|
55
|
-
"import": "./src/*",
|
|
56
|
-
"default": "./src/*"
|
|
57
|
-
},
|
|
58
|
-
"./build/*": "./build/*",
|
|
59
|
-
"./theme/*": "./theme/*",
|
|
60
|
-
"./ckeditor5-metadata.json": "./ckeditor5-metadata.json",
|
|
61
|
-
"./package.json": "./package.json"
|
|
62
|
-
}
|
|
39
|
+
"types": "./dist/index.d.ts"
|
|
63
40
|
}
|
package/build/minimap.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md.
|
|
4
|
-
*/(()=>{var t={163:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},237:t=>{"use strict";t.exports=CKEditor5.dll},305:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var i="",n=void 0!==e[5];return e[4]&&(i+="@supports (".concat(e[4],") {")),e[2]&&(i+="@media ".concat(e[2]," {")),n&&(i+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),i+=t(e),n&&(i+="}"),e[2]&&(i+="}"),e[4]&&(i+="}"),i}).join("")},e.i=function(t,i,n,o,r){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(n)for(var a=0;a<this.length;a++){var c=this[a][0];null!=c&&(s[c]=!0)}for(var l=0;l<t.length;l++){var m=[].concat(t[l]);n&&s[m[0]]||(void 0!==r&&(void 0===m[5]||(m[1]="@layer".concat(m[5].length>0?" ".concat(m[5]):""," {").concat(m[1],"}")),m[5]=r),i&&(m[2]?(m[1]="@media ".concat(m[2]," {").concat(m[1],"}"),m[2]=i):m[2]=i),o&&(m[4]?(m[1]="@supports (".concat(m[4],") {").concat(m[1],"}"),m[4]=o):m[4]="".concat(o)),e.push(m))}},e}},311:(t,e,i)=>{t.exports=i(237)("./src/ui.js")},424:t=>{"use strict";var e={};t.exports=function(t,i){var n=function(t){if(void 0===e[t]){var i=document.querySelector(t);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(t){i=null}e[t]=i}return e[t]}(t);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(i)}},517:t=>{"use strict";t.exports=function(t,e){Object.keys(e).forEach(function(i){t.setAttribute(i,e[i])})}},584:(t,e,i)=>{t.exports=i(237)("./src/utils.js")},719:t=>{"use strict";var e=[];function i(t){for(var i=-1,n=0;n<e.length;n++)if(e[n].identifier===t){i=n;break}return i}function n(t,n){for(var r={},s=[],a=0;a<t.length;a++){var c=t[a],l=n.base?c[0]+n.base:c[0],m=r[l]||0,p="".concat(l," ").concat(m);r[l]=m+1;var h=i(p),d={css:c[1],media:c[2],sourceMap:c[3],supports:c[4],layer:c[5]};if(-1!==h)e[h].references++,e[h].updater(d);else{var u=o(d,n);n.byIndex=a,e.splice(a,0,{identifier:p,updater:u,references:1})}s.push(p)}return s}function o(t,e){var i=e.domAPI(e);i.update(t);return function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;i.update(t=e)}else i.remove()}}t.exports=function(t,o){var r=n(t=t||[],o=o||{});return function(t){t=t||[];for(var s=0;s<r.length;s++){var a=i(r[s]);e[a].references--}for(var c=n(t,o),l=0;l<r.length;l++){var m=i(r[l]);0===e[m].references&&(e[m].updater(),e.splice(m,1))}r=c}}},770:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var n=i(792),o=i.n(n),r=i(305),s=i.n(r)()(o());s.push([t.id,':root{--ck-color-minimap-tracker-background:208,0%,51%;--ck-color-minimap-iframe-outline:#bfbfbf;--ck-color-minimap-iframe-shadow:rgba(0,0,0,.11);--ck-color-minimap-progress-background:#666}.ck.ck-minimap{background:var(--ck-color-base-background);position:absolute;user-select:none}.ck.ck-minimap,.ck.ck-minimap iframe{height:100%;width:100%}.ck.ck-minimap iframe{border:0;box-shadow:0 2px 5px var(--ck-color-minimap-iframe-shadow);margin:0;outline:1px solid var(--ck-color-minimap-iframe-outline);pointer-events:none;position:relative}.ck.ck-minimap .ck.ck-minimap__position-tracker{background:hsla(var(--ck-color-minimap-tracker-background),.2);position:absolute;top:0;transition:background .1s ease-in-out;width:100%;z-index:1}@media (prefers-reduced-motion:reduce){.ck.ck-minimap .ck.ck-minimap__position-tracker{transition:none}}.ck.ck-minimap .ck.ck-minimap__position-tracker:hover{background:hsla(var(--ck-color-minimap-tracker-background),.3)}.ck.ck-minimap .ck.ck-minimap__position-tracker.ck-minimap__position-tracker_dragging,.ck.ck-minimap .ck.ck-minimap__position-tracker.ck-minimap__position-tracker_dragging:hover{background:hsla(var(--ck-color-minimap-tracker-background),.4)}.ck.ck-minimap .ck.ck-minimap__position-tracker.ck-minimap__position-tracker_dragging:after,.ck.ck-minimap .ck.ck-minimap__position-tracker.ck-minimap__position-tracker_dragging:hover:after{opacity:1}.ck.ck-minimap .ck.ck-minimap__position-tracker:after{background:var(--ck-color-minimap-progress-background);border:1px solid var(--ck-color-base-background);border-radius:3px;color:var(--ck-color-base-background);content:attr(data-progress) "%";font-size:10px;opacity:0;padding:2px 4px;position:absolute;right:5px;top:5px;transition:opacity .1s ease-in-out}@media (prefers-reduced-motion:reduce){.ck.ck-minimap .ck.ck-minimap__position-tracker:after{transition:none}}',""]);const a=s},782:(t,e,i)=>{t.exports=i(237)("./src/core.js")},783:(t,e,i)=>{t.exports=i(237)("./src/engine.js")},792:t=>{"use strict";t.exports=function(t){return t[1]}},863:t=>{"use strict";var e,i=(e=[],function(t,i){return e[t]=i,e.filter(Boolean).join("\n")});function n(t,e,n,o){var r;if(n)r="";else{r="",o.supports&&(r+="@supports (".concat(o.supports,") {")),o.media&&(r+="@media ".concat(o.media," {"));var s=void 0!==o.layer;s&&(r+="@layer".concat(o.layer.length>0?" ".concat(o.layer):""," {")),r+=o.css,s&&(r+="}"),o.media&&(r+="}"),o.supports&&(r+="}")}if(t.styleSheet)t.styleSheet.cssText=i(e,r);else{var a=document.createTextNode(r),c=t.childNodes;c[e]&&t.removeChild(c[e]),c.length?t.insertBefore(a,c[e]):t.appendChild(a)}}var o={singleton:null,singletonCounter:0};t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=o.singletonCounter++,i=o.singleton||(o.singleton=t.insertStyleElement(t));return{update:function(t){n(i,e,!1,t)},remove:function(t){n(i,e,!0,t)}}}}},e={};function i(n){var o=e[n];if(void 0!==o)return o.exports;var r=e[n]={id:n,exports:{}};return t[n](r,r.exports,i),r.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";i.r(n),i.d(n,{Minimap:()=>V,_MinimapIframeView:()=>s,_MinimapPositionTrackerView:()=>c,_MinimapView:()=>l,_cloneMinimapEditingViewDomRoot:()=>p,_getMinimapClientHeight:()=>u,_getMinimapDomElementRect:()=>d,_getMinimapPageStyles:()=>h,_getMinimapScrollable:()=>g});var t=i(782),e=i(584),o=i(311);const r=(0,e.toUnit)("px");class s extends o.IframeView{_options;constructor(t,e){super(t);const i=this.bindTemplate;this.set("top",0),this.set("height",0),this._options=e,this.extendTemplate({attributes:{tabindex:-1,"aria-hidden":"true",class:["ck-minimap__iframe"],style:{top:i.to("top",t=>r(t)),height:i.to("height",t=>r(t))}}})}render(){return super.render().then(()=>{this._prepareDocument()})}setHeight(t){this.height=t}setTopOffset(t){this.top=t}_prepareDocument(){const t=this.element.contentWindow.document,e=t.adoptNode(this._options.domRootClone),i=this._options.useSimplePreview?"\n\t\t\t.ck.ck-editor__editable_inline img {\n\t\t\t\tfilter: contrast( 0 );\n\t\t\t}\n\n\t\t\tp, li, a, figcaption, span {\n\t\t\t\tbackground: hsl(0, 0%, 80%) !important;\n\t\t\t\tcolor: hsl(0, 0%, 80%) !important;\n\t\t\t}\n\n\t\t\th1, h2, h3, h4 {\n\t\t\t\tbackground: hsl(0, 0%, 60%) !important;\n\t\t\t\tcolor: hsl(0, 0%, 60%) !important;\n\t\t\t}\n\t\t":"",n=`<!DOCTYPE html><html lang="en">\n\t\t\t<head>\n\t\t\t\t<meta charset="utf-8">\n\t\t\t\t<meta name="viewport" content="width=device-width, initial-scale=1">\n\t\t\t\t${this._options.pageStyles.map(t=>"string"==typeof t?`<style>${t}</style>`:`<link rel="stylesheet" type="text/css" href="${t.href}">`).join("\n")}\n\t\t\t\t<style>\n\t\t\t\t\thtml, body {\n\t\t\t\t\t\tmargin: 0 !important;\n\t\t\t\t\t\tpadding: 0 !important;\n\t\t\t\t\t}\n\n\t\t\t\t\thtml {\n\t\t\t\t\t\toverflow: hidden;\n\t\t\t\t\t}\n\n\t\t\t\t\tbody {\n\t\t\t\t\t\ttransform: scale( ${this._options.scaleRatio} );\n\t\t\t\t\t\ttransform-origin: 0 0;\n\t\t\t\t\t\toverflow: visible;\n\t\t\t\t\t}\n\n\t\t\t\t\t.ck.ck-editor__editable_inline {\n\t\t\t\t\t\tmargin: 0 !important;\n\t\t\t\t\t\tborder-color: transparent !important;\n\t\t\t\t\t\toutline-color: transparent !important;\n\t\t\t\t\t\tbox-shadow: none !important;\n\t\t\t\t\t}\n\n\t\t\t\t\t.ck.ck-content {\n\t\t\t\t\t\tbackground: white;\n\t\t\t\t\t}\n\n\t\t\t\t\t${i}\n\t\t\t\t</style>\n\t\t\t</head>\n\t\t\t<body class="${this._options.extraClasses||""}"></body>\n\t\t</html>`;t.open(),t.write(n),t.close(),t.body.appendChild(e)}}const a=(0,e.toUnit)("px");class c extends o.View{constructor(t){super(t);const e=this.bindTemplate;this.set("height",0),this.set("top",0),this.set("scrollProgress",0),this.set("_isDragging",!1),this.setTemplate({tag:"div",attributes:{class:["ck","ck-minimap__position-tracker",e.if("_isDragging","ck-minimap__position-tracker_dragging")],style:{top:e.to("top",t=>a(t)),height:e.to("height",t=>a(t))},"data-progress":e.to("scrollProgress")},on:{mousedown:e.to(()=>{this._isDragging=!0})}})}render(){super.render(),this.listenTo(e.global.document,"mousemove",(t,e)=>{this._isDragging&&this.fire("drag",e.movementY)},{useCapture:!0}),this.listenTo(e.global.document,"mouseup",()=>{this._isDragging=!1},{useCapture:!0})}setHeight(t){this.height=t}setTopOffset(t){this.top=t}setScrollProgress(t){this.scrollProgress=t}}class l extends o.View{_positionTrackerView;_scaleRatio;_minimapIframeView;constructor({locale:t,scaleRatio:e,pageStyles:i,extraClasses:n,useSimplePreview:o,domRootClone:r}){super(t);const a=this.bindTemplate;this._positionTrackerView=new c(t),this._positionTrackerView.delegate("drag").to(this),this._scaleRatio=e,this._minimapIframeView=new s(t,{useSimplePreview:o,pageStyles:i,extraClasses:n,scaleRatio:e,domRootClone:r}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-minimap"]},children:[this._positionTrackerView],on:{click:a.to(this._handleMinimapClick.bind(this)),wheel:a.to(this._handleMinimapMouseWheel.bind(this))}})}destroy(){this._minimapIframeView.destroy(),super.destroy()}get height(){return new e.Rect(this.element).height}get scrollHeight(){return Math.max(0,Math.min(this.height,this._minimapIframeView.height)-this._positionTrackerView.height)}render(){super.render(),this._minimapIframeView.render(),this.element.appendChild(this._minimapIframeView.element)}setContentHeight(t){this._minimapIframeView.setHeight(t*this._scaleRatio)}setScrollProgress(t){const e=this._minimapIframeView,i=this._positionTrackerView;if(e.height<this.height)e.setTopOffset(0),i.setTopOffset((e.height-i.height)*t);else{const n=e.height-this.height;e.setTopOffset(-n*t),i.setTopOffset((this.height-i.height)*t)}i.setScrollProgress(Math.round(100*t))}setPositionTrackerHeight(t){this._positionTrackerView.setHeight(t*this._scaleRatio)}_handleMinimapClick(t){const i=this._positionTrackerView;if(t.target===i.element)return;const n=new e.Rect(i.element),o=(t.clientY-n.top-n.height/2)/this._minimapIframeView.height;this.fire("click",o)}_handleMinimapMouseWheel(t){this.fire("drag",t.deltaY*this._scaleRatio)}}var m=i(783);function p(t,e){const i=t.editing.view.document,n=i.getRoot(e),o=new m.ViewDomConverter(i),r=new m.ViewRenderer(o,i.selection),s=t.editing.view.getDomRoot().cloneNode();return o.bindElements(s,n),r.markToSync("children",n),r.markToSync("attributes",n),n.on("change:children",(t,e)=>r.markToSync("children",e)),n.on("change:attributes",(t,e)=>r.markToSync("attributes",e)),n.on("change:text",(t,e)=>r.markToSync("text",e)),r.render(),t.editing.view.on("render",()=>r.render()),t.on("destroy",()=>{o.unbindDomElement(s)}),s}function h(){return Array.from(e.global.document.styleSheets).map(t=>t.href&&!t.href.startsWith(e.global.window.location.origin)?{href:t.href}:Array.from(t.cssRules).filter(t=>!(t instanceof CSSMediaRule)).map(t=>t.cssText).join(" \n"))}function d(t){return new e.Rect(t===e.global.document.body?e.global.window:t)}function u(t){return t===e.global.document.body?e.global.window.innerHeight:t.clientHeight}function g(t){return t===e.global.document.body?e.global.window:t}var f=i(719),k=i.n(f),_=i(863),b=i.n(_),w=i(424),v=i.n(w),y=i(517),x=i.n(y),T=i(163),R=i.n(T),S=i(770),M={attributes:{"data-cke":!0}};M.setAttributes=x(),M.insert=v().bind(null,"head"),M.domAPI=b(),M.insertStyleElement=R();k()(S.A,M);S.A&&S.A.locals&&S.A.locals;class V extends t.Plugin{static get pluginName(){return"Minimap"}static get isOfficialPlugin(){return!0}_minimapView;_scrollableRootAncestor;_editingRootElement;init(){const t=this.editor;this._minimapView=null,this._scrollableRootAncestor=null,this.listenTo(t.ui,"ready",this._onUiReady.bind(this))}destroy(){super.destroy(),this._minimapView.destroy(),this._minimapView.element.remove()}_onUiReady(){const t=this.editor,i=this._editingRootElement=t.ui.getEditableElement();this._scrollableRootAncestor=(0,e.findClosestScrollableAncestor)(i),i.ownerDocument.body.contains(i)?(this._initializeMinimapView(),this.listenTo(t.editing.view,"render",()=>{"ready"===t.state&&this._syncMinimapToEditingRootScrollPosition()}),this._syncMinimapToEditingRootScrollPosition()):t.ui.once("update",this._onUiReady.bind(this))}_initializeMinimapView(){const t=this.editor,i=t.locale,n=t.config.get("minimap.useSimplePreview"),o=t.config.get("minimap.container"),r=this._scrollableRootAncestor,s=d(this._editingRootElement).width,a=d(o).width/s,c=this._minimapView=new l({locale:i,scaleRatio:a,pageStyles:h(),extraClasses:t.config.get("minimap.extraClasses"),useSimplePreview:n,domRootClone:p(t)});c.render(),c.listenTo(e.global.document,"scroll",(t,i)=>{if(r===e.global.document.body){if(i.target!==e.global.document)return}else if(i.target!==r)return;this._syncMinimapToEditingRootScrollPosition()},{useCapture:!0,usePassive:!0}),c.listenTo(e.global.window,"resize",()=>{this._syncMinimapToEditingRootScrollPosition()}),c.on("drag",(t,e)=>{let i;i=0===c.scrollHeight?0:e/c.scrollHeight;const n=i*(r.scrollHeight-u(r));g(r).scrollBy(0,Math.round(n))}),c.on("click",(t,e)=>{const i=e*r.scrollHeight;g(r).scrollBy(0,Math.round(i))}),o.appendChild(c.element)}_syncMinimapToEditingRootScrollPosition(){const t=this._editingRootElement,e=this._minimapView;e.setContentHeight(t.offsetHeight);const i=d(t),n=d(this._scrollableRootAncestor);let o;n.getIntersection(i)&&(n.contains(i)||i.top>n.top?o=0:(o=(i.top-n.top)/(n.height-i.height),o=Math.max(0,Math.min(o,1))),e.setPositionTrackerHeight(n.getIntersection(i).height),e.setScrollProgress(o))}}})(),(window.CKEditor5=window.CKEditor5||{}).minimap=n})();
|
package/src/augmentation.js
DELETED
package/src/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module minimap
|
|
7
|
-
*/
|
|
8
|
-
export { Minimap } from './minimap.js';
|
|
9
|
-
export { MinimapIframeView as _MinimapIframeView } from './minimapiframeview.js';
|
|
10
|
-
export { MinimapPositionTrackerView as _MinimapPositionTrackerView } from './minimappositiontrackerview.js';
|
|
11
|
-
export { MinimapView as _MinimapView } from './minimapview.js';
|
|
12
|
-
export { cloneEditingViewDomRoot as _cloneMinimapEditingViewDomRoot, getPageStyles as _getMinimapPageStyles, getDomElementRect as _getMinimapDomElementRect, getClientHeight as _getMinimapClientHeight, getScrollable as _getMinimapScrollable } from './utils.js';
|
|
13
|
-
import './augmentation.js';
|
package/src/minimap.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module minimap/minimap
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { findClosestScrollableAncestor, global } from 'ckeditor5/src/utils.js';
|
|
10
|
-
import { MinimapView } from './minimapview.js';
|
|
11
|
-
import { cloneEditingViewDomRoot, getClientHeight, getDomElementRect, getPageStyles, getScrollable } from './utils.js';
|
|
12
|
-
// @if CK_DEBUG_MINIMAP // const RectDrawer = require( '@ckeditor/ckeditor5-utils/tests/_utils/rectdrawer' ).default;
|
|
13
|
-
import '../theme/minimap.css';
|
|
14
|
-
/**
|
|
15
|
-
* The content minimap feature.
|
|
16
|
-
*/
|
|
17
|
-
export class Minimap extends Plugin {
|
|
18
|
-
/**
|
|
19
|
-
* @inheritDoc
|
|
20
|
-
*/
|
|
21
|
-
static get pluginName() {
|
|
22
|
-
return 'Minimap';
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* @inheritDoc
|
|
26
|
-
*/
|
|
27
|
-
static get isOfficialPlugin() {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* The reference to the view of the minimap.
|
|
32
|
-
*/
|
|
33
|
-
_minimapView;
|
|
34
|
-
/**
|
|
35
|
-
* The DOM element closest to the editable element of the editor as returned
|
|
36
|
-
* by {@link module:ui/editorui/editorui~EditorUI#getEditableElement}.
|
|
37
|
-
*/
|
|
38
|
-
_scrollableRootAncestor;
|
|
39
|
-
/**
|
|
40
|
-
* The DOM element closest to the editable element of the editor as returned
|
|
41
|
-
* by {@link module:ui/editorui/editorui~EditorUI#getEditableElement}.
|
|
42
|
-
*/
|
|
43
|
-
_editingRootElement;
|
|
44
|
-
/**
|
|
45
|
-
* @inheritDoc
|
|
46
|
-
*/
|
|
47
|
-
init() {
|
|
48
|
-
const editor = this.editor;
|
|
49
|
-
this._minimapView = null;
|
|
50
|
-
this._scrollableRootAncestor = null;
|
|
51
|
-
this.listenTo(editor.ui, 'ready', this._onUiReady.bind(this));
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @inheritDoc
|
|
55
|
-
*/
|
|
56
|
-
destroy() {
|
|
57
|
-
super.destroy();
|
|
58
|
-
this._minimapView.destroy();
|
|
59
|
-
this._minimapView.element.remove();
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Initializes the minimap view element and starts the layout synchronization
|
|
63
|
-
* on the editing view `render` event.
|
|
64
|
-
*/
|
|
65
|
-
_onUiReady() {
|
|
66
|
-
const editor = this.editor;
|
|
67
|
-
// TODO: This will not work with the multi-root editor.
|
|
68
|
-
const editingRootElement = this._editingRootElement = editor.ui.getEditableElement();
|
|
69
|
-
this._scrollableRootAncestor = findClosestScrollableAncestor(editingRootElement);
|
|
70
|
-
// DOM root element is not yet attached to the document.
|
|
71
|
-
if (!editingRootElement.ownerDocument.body.contains(editingRootElement)) {
|
|
72
|
-
editor.ui.once('update', this._onUiReady.bind(this));
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
this._initializeMinimapView();
|
|
76
|
-
this.listenTo(editor.editing.view, 'render', () => {
|
|
77
|
-
if (editor.state !== 'ready') {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
this._syncMinimapToEditingRootScrollPosition();
|
|
81
|
-
});
|
|
82
|
-
this._syncMinimapToEditingRootScrollPosition();
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Initializes the minimap view and attaches listeners that make it responsive to the environment (document)
|
|
86
|
-
* but also allow the minimap to control the document (scroll position).
|
|
87
|
-
*/
|
|
88
|
-
_initializeMinimapView() {
|
|
89
|
-
const editor = this.editor;
|
|
90
|
-
const locale = editor.locale;
|
|
91
|
-
const useSimplePreview = editor.config.get('minimap.useSimplePreview');
|
|
92
|
-
// TODO: Throw an error if there is no `minimap` in config.
|
|
93
|
-
const minimapContainerElement = editor.config.get('minimap.container');
|
|
94
|
-
const scrollableRootAncestor = this._scrollableRootAncestor;
|
|
95
|
-
// TODO: This should be dynamic, the root width could change as the viewport scales if not fixed unit.
|
|
96
|
-
const editingRootElementWidth = getDomElementRect(this._editingRootElement).width;
|
|
97
|
-
const minimapContainerWidth = getDomElementRect(minimapContainerElement).width;
|
|
98
|
-
const minimapScaleRatio = minimapContainerWidth / editingRootElementWidth;
|
|
99
|
-
const minimapView = this._minimapView = new MinimapView({
|
|
100
|
-
locale,
|
|
101
|
-
scaleRatio: minimapScaleRatio,
|
|
102
|
-
pageStyles: getPageStyles(),
|
|
103
|
-
extraClasses: editor.config.get('minimap.extraClasses'),
|
|
104
|
-
useSimplePreview,
|
|
105
|
-
domRootClone: cloneEditingViewDomRoot(editor)
|
|
106
|
-
});
|
|
107
|
-
minimapView.render();
|
|
108
|
-
// Scrollable ancestor scroll -> minimap position update.
|
|
109
|
-
minimapView.listenTo(global.document, 'scroll', (evt, data) => {
|
|
110
|
-
if (scrollableRootAncestor === global.document.body) {
|
|
111
|
-
if (data.target !== global.document) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else if (data.target !== scrollableRootAncestor) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
this._syncMinimapToEditingRootScrollPosition();
|
|
119
|
-
}, { useCapture: true, usePassive: true });
|
|
120
|
-
// Viewport resize -> minimap position update.
|
|
121
|
-
minimapView.listenTo(global.window, 'resize', () => {
|
|
122
|
-
this._syncMinimapToEditingRootScrollPosition();
|
|
123
|
-
});
|
|
124
|
-
// Dragging the visible content area -> document (scrollable) position update.
|
|
125
|
-
minimapView.on('drag', (evt, movementY) => {
|
|
126
|
-
let movementYPercentage;
|
|
127
|
-
if (minimapView.scrollHeight === 0) {
|
|
128
|
-
movementYPercentage = 0;
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
movementYPercentage = movementY / minimapView.scrollHeight;
|
|
132
|
-
}
|
|
133
|
-
const absoluteScrollProgress = movementYPercentage *
|
|
134
|
-
(scrollableRootAncestor.scrollHeight - getClientHeight(scrollableRootAncestor));
|
|
135
|
-
const scrollable = getScrollable(scrollableRootAncestor);
|
|
136
|
-
scrollable.scrollBy(0, Math.round(absoluteScrollProgress));
|
|
137
|
-
});
|
|
138
|
-
// Clicking the minimap -> center the document (scrollable) to the corresponding position.
|
|
139
|
-
minimapView.on('click', (evt, percentage) => {
|
|
140
|
-
const absoluteScrollProgress = percentage * scrollableRootAncestor.scrollHeight;
|
|
141
|
-
const scrollable = getScrollable(scrollableRootAncestor);
|
|
142
|
-
scrollable.scrollBy(0, Math.round(absoluteScrollProgress));
|
|
143
|
-
});
|
|
144
|
-
minimapContainerElement.appendChild(minimapView.element);
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* @private
|
|
148
|
-
*/
|
|
149
|
-
_syncMinimapToEditingRootScrollPosition() {
|
|
150
|
-
const editingRootElement = this._editingRootElement;
|
|
151
|
-
const minimapView = this._minimapView;
|
|
152
|
-
minimapView.setContentHeight(editingRootElement.offsetHeight);
|
|
153
|
-
const editingRootRect = getDomElementRect(editingRootElement);
|
|
154
|
-
const scrollableRootAncestorRect = getDomElementRect(this._scrollableRootAncestor);
|
|
155
|
-
let scrollProgress;
|
|
156
|
-
// It's possible that at some point elements do not intersect, e.g. when entering the fullscreen mode.
|
|
157
|
-
// Prevent the minimap from being updated in such case.
|
|
158
|
-
if (!scrollableRootAncestorRect.getIntersection(editingRootRect)) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
// @if CK_DEBUG_MINIMAP // RectDrawer.clear();
|
|
162
|
-
// @if CK_DEBUG_MINIMAP // RectDrawer.draw( scrollableRootAncestorRect, { outlineColor: 'red' }, 'scrollableRootAncestor' );
|
|
163
|
-
// @if CK_DEBUG_MINIMAP // RectDrawer.draw( editingRootRect, { outlineColor: 'green' }, 'editingRoot' );
|
|
164
|
-
// The root is completely visible in the scrollable ancestor.
|
|
165
|
-
if (scrollableRootAncestorRect.contains(editingRootRect)) {
|
|
166
|
-
scrollProgress = 0;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
if (editingRootRect.top > scrollableRootAncestorRect.top) {
|
|
170
|
-
scrollProgress = 0;
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
scrollProgress = (editingRootRect.top - scrollableRootAncestorRect.top) /
|
|
174
|
-
(scrollableRootAncestorRect.height - editingRootRect.height);
|
|
175
|
-
scrollProgress = Math.max(0, Math.min(scrollProgress, 1));
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
// The intersection helps to change the tracker height when there is a lot of padding around the root.
|
|
179
|
-
// Note: It is **essential** that the height is set first because the progress depends on the correct tracker height.
|
|
180
|
-
minimapView.setPositionTrackerHeight(scrollableRootAncestorRect.getIntersection(editingRootRect).height);
|
|
181
|
-
minimapView.setScrollProgress(scrollProgress);
|
|
182
|
-
}
|
|
183
|
-
}
|
package/src/minimapconfig.js
DELETED
package/src/minimapiframeview.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module minimap/minimapiframeview
|
|
7
|
-
*/
|
|
8
|
-
import { IframeView } from 'ckeditor5/src/ui.js';
|
|
9
|
-
import { toUnit } from 'ckeditor5/src/utils.js';
|
|
10
|
-
const toPx = /* #__PURE__ */ toUnit('px');
|
|
11
|
-
/**
|
|
12
|
-
* The internal `<iframe>` view that hosts the minimap content.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export class MinimapIframeView extends IframeView {
|
|
17
|
-
/**
|
|
18
|
-
* Cached view constructor options for re-use in other methods.
|
|
19
|
-
*/
|
|
20
|
-
_options;
|
|
21
|
-
/**
|
|
22
|
-
* Creates an instance of the internal minimap iframe.
|
|
23
|
-
*/
|
|
24
|
-
constructor(locale, options) {
|
|
25
|
-
super(locale);
|
|
26
|
-
const bind = this.bindTemplate;
|
|
27
|
-
this.set('top', 0);
|
|
28
|
-
this.set('height', 0);
|
|
29
|
-
this._options = options;
|
|
30
|
-
this.extendTemplate({
|
|
31
|
-
attributes: {
|
|
32
|
-
tabindex: -1,
|
|
33
|
-
'aria-hidden': 'true',
|
|
34
|
-
class: [
|
|
35
|
-
'ck-minimap__iframe'
|
|
36
|
-
],
|
|
37
|
-
style: {
|
|
38
|
-
top: bind.to('top', top => toPx(top)),
|
|
39
|
-
height: bind.to('height', height => toPx(height))
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* @inheritDoc
|
|
46
|
-
*/
|
|
47
|
-
render() {
|
|
48
|
-
return super.render().then(() => {
|
|
49
|
-
this._prepareDocument();
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Sets the new height of the iframe.
|
|
54
|
-
*/
|
|
55
|
-
setHeight(newHeight) {
|
|
56
|
-
this.height = newHeight;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Sets the top offset of the iframe to move it around vertically.
|
|
60
|
-
*/
|
|
61
|
-
setTopOffset(newOffset) {
|
|
62
|
-
this.top = newOffset;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Sets the internal structure of the `<iframe>` readying it to display the
|
|
66
|
-
* minimap element.
|
|
67
|
-
*/
|
|
68
|
-
_prepareDocument() {
|
|
69
|
-
const iframeDocument = this.element.contentWindow.document;
|
|
70
|
-
const domRootClone = iframeDocument.adoptNode(this._options.domRootClone);
|
|
71
|
-
const boxStyles = this._options.useSimplePreview ? `
|
|
72
|
-
.ck.ck-editor__editable_inline img {
|
|
73
|
-
filter: contrast( 0 );
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
p, li, a, figcaption, span {
|
|
77
|
-
background: hsl(0, 0%, 80%) !important;
|
|
78
|
-
color: hsl(0, 0%, 80%) !important;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
h1, h2, h3, h4 {
|
|
82
|
-
background: hsl(0, 0%, 60%) !important;
|
|
83
|
-
color: hsl(0, 0%, 60%) !important;
|
|
84
|
-
}
|
|
85
|
-
` : '';
|
|
86
|
-
const pageStyles = this._options.pageStyles.map(definition => {
|
|
87
|
-
if (typeof definition === 'string') {
|
|
88
|
-
return `<style>${definition}</style>`;
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
return `<link rel="stylesheet" type="text/css" href="${definition.href}">`;
|
|
92
|
-
}
|
|
93
|
-
}).join('\n');
|
|
94
|
-
const html = `<!DOCTYPE html><html lang="en">
|
|
95
|
-
<head>
|
|
96
|
-
<meta charset="utf-8">
|
|
97
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
98
|
-
${pageStyles}
|
|
99
|
-
<style>
|
|
100
|
-
html, body {
|
|
101
|
-
margin: 0 !important;
|
|
102
|
-
padding: 0 !important;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
html {
|
|
106
|
-
overflow: hidden;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
body {
|
|
110
|
-
transform: scale( ${this._options.scaleRatio} );
|
|
111
|
-
transform-origin: 0 0;
|
|
112
|
-
overflow: visible;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.ck.ck-editor__editable_inline {
|
|
116
|
-
margin: 0 !important;
|
|
117
|
-
border-color: transparent !important;
|
|
118
|
-
outline-color: transparent !important;
|
|
119
|
-
box-shadow: none !important;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.ck.ck-content {
|
|
123
|
-
background: white;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
${boxStyles}
|
|
127
|
-
</style>
|
|
128
|
-
</head>
|
|
129
|
-
<body class="${this._options.extraClasses || ''}"></body>
|
|
130
|
-
</html>`;
|
|
131
|
-
iframeDocument.open();
|
|
132
|
-
iframeDocument.write(html);
|
|
133
|
-
iframeDocument.close();
|
|
134
|
-
iframeDocument.body.appendChild(domRootClone);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module minimap/minimappositiontrackerview
|
|
7
|
-
*/
|
|
8
|
-
import { View } from 'ckeditor5/src/ui.js';
|
|
9
|
-
import { toUnit, global } from 'ckeditor5/src/utils.js';
|
|
10
|
-
const toPx = /* #__PURE__ */ toUnit('px');
|
|
11
|
-
/**
|
|
12
|
-
* The position tracker visualizing the visible subset of the content. Displayed over the minimap.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export class MinimapPositionTrackerView extends View {
|
|
17
|
-
constructor(locale) {
|
|
18
|
-
super(locale);
|
|
19
|
-
const bind = this.bindTemplate;
|
|
20
|
-
this.set('height', 0);
|
|
21
|
-
this.set('top', 0);
|
|
22
|
-
this.set('scrollProgress', 0);
|
|
23
|
-
this.set('_isDragging', false);
|
|
24
|
-
this.setTemplate({
|
|
25
|
-
tag: 'div',
|
|
26
|
-
attributes: {
|
|
27
|
-
class: [
|
|
28
|
-
'ck',
|
|
29
|
-
'ck-minimap__position-tracker',
|
|
30
|
-
bind.if('_isDragging', 'ck-minimap__position-tracker_dragging')
|
|
31
|
-
],
|
|
32
|
-
style: {
|
|
33
|
-
top: bind.to('top', top => toPx(top)),
|
|
34
|
-
height: bind.to('height', height => toPx(height))
|
|
35
|
-
},
|
|
36
|
-
'data-progress': bind.to('scrollProgress')
|
|
37
|
-
},
|
|
38
|
-
on: {
|
|
39
|
-
mousedown: bind.to(() => {
|
|
40
|
-
this._isDragging = true;
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* @inheritDoc
|
|
47
|
-
*/
|
|
48
|
-
render() {
|
|
49
|
-
super.render();
|
|
50
|
-
this.listenTo(global.document, 'mousemove', (evt, data) => {
|
|
51
|
-
if (!this._isDragging) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
this.fire('drag', data.movementY);
|
|
55
|
-
}, { useCapture: true });
|
|
56
|
-
this.listenTo(global.document, 'mouseup', () => {
|
|
57
|
-
this._isDragging = false;
|
|
58
|
-
}, { useCapture: true });
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Sets the new height of the tracker to visualize the subset of the content visible to the user.
|
|
62
|
-
*/
|
|
63
|
-
setHeight(newHeight) {
|
|
64
|
-
this.height = newHeight;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Sets the top offset of the tracker to move it around vertically.
|
|
68
|
-
*/
|
|
69
|
-
setTopOffset(newOffset) {
|
|
70
|
-
this.top = newOffset;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Sets the scroll progress (in %) to inform the user using a label when the tracker is being dragged.
|
|
74
|
-
*/
|
|
75
|
-
setScrollProgress(newProgress) {
|
|
76
|
-
this.scrollProgress = newProgress;
|
|
77
|
-
}
|
|
78
|
-
}
|