@ckeditor/ckeditor5-bookmark 0.0.0-nightly-20241025.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +4 -0
- package/LICENSE.md +17 -0
- package/README.md +26 -0
- package/build/bookmark.js +4 -0
- package/ckeditor5-metadata.json +24 -0
- package/dist/augmentation.d.ts +28 -0
- package/dist/bookmark.d.ts +34 -0
- package/dist/bookmarkconfig.d.ts +52 -0
- package/dist/bookmarkediting.d.ts +55 -0
- package/dist/bookmarkui.d.ts +170 -0
- package/dist/index-content.css +4 -0
- package/dist/index-editor.css +150 -0
- package/dist/index.css +195 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +1322 -0
- package/dist/index.js.map +1 -0
- package/dist/insertbookmarkcommand.d.ts +42 -0
- package/dist/ui/bookmarkactionsview.d.ts +106 -0
- package/dist/ui/bookmarkformview.d.ts +122 -0
- package/dist/updatebookmarkcommand.d.ts +46 -0
- package/dist/utils.d.ts +15 -0
- package/lang/contexts.json +13 -0
- package/package.json +43 -0
- package/src/augmentation.d.ts +24 -0
- package/src/augmentation.js +5 -0
- package/src/bookmark.d.ts +30 -0
- package/src/bookmark.js +36 -0
- package/src/bookmarkconfig.d.ts +48 -0
- package/src/bookmarkconfig.js +5 -0
- package/src/bookmarkediting.d.ts +51 -0
- package/src/bookmarkediting.js +212 -0
- package/src/bookmarkui.d.ts +166 -0
- package/src/bookmarkui.js +583 -0
- package/src/index.d.ts +14 -0
- package/src/index.js +13 -0
- package/src/insertbookmarkcommand.d.ts +38 -0
- package/src/insertbookmarkcommand.js +113 -0
- package/src/ui/bookmarkactionsview.d.ts +102 -0
- package/src/ui/bookmarkactionsview.js +154 -0
- package/src/ui/bookmarkformview.d.ts +118 -0
- package/src/ui/bookmarkformview.js +203 -0
- package/src/updatebookmarkcommand.d.ts +42 -0
- package/src/updatebookmarkcommand.js +75 -0
- package/src/utils.d.ts +11 -0
- package/src/utils.js +19 -0
- package/theme/bookmark.css +50 -0
- package/theme/bookmarkactions.css +44 -0
- package/theme/bookmarkform.css +42 -0
package/CHANGELOG.md
ADDED
package/LICENSE.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
Software License Agreement
|
2
|
+
==========================
|
3
|
+
|
4
|
+
**CKEditor 5 bookmark feature** – https://github.com/ckeditor/packages/ckeditor5-bookmarks <br>
|
5
|
+
Copyright (c) 2003–2024, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
|
6
|
+
|
7
|
+
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
|
8
|
+
|
9
|
+
Sources of Intellectual Property Included in CKEditor
|
10
|
+
-----------------------------------------------------
|
11
|
+
|
12
|
+
Where not otherwise indicated, all CKEditor content is authored by CKSource engineers and consists of CKSource-owned intellectual property. In some specific instances, CKEditor will incorporate work done by developers outside of CKSource with their express permission.
|
13
|
+
|
14
|
+
Trademarks
|
15
|
+
----------
|
16
|
+
|
17
|
+
**CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks, or service marks of their respective holders.
|
package/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
CKEditor 5 bookmark feature
|
2
|
+
================================
|
3
|
+
|
4
|
+
[![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-bookmark.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-bookmark)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/github/ckeditor/ckeditor5/badge.svg?branch=master)](https://coveralls.io/github/ckeditor/ckeditor5?branch=master)
|
6
|
+
[![Build Status](https://travis-ci.com/ckeditor/ckeditor5.svg?branch=master)](https://app.travis-ci.com/github/ckeditor/ckeditor5)
|
7
|
+
|
8
|
+
This package contains the bookmark feature for CKEditor 5. It allows to add and manage the bookmarks attached to the content of editor for fast access and more efficient content creation.
|
9
|
+
|
10
|
+
## Demo
|
11
|
+
|
12
|
+
Check out the [demo in the bookmark feature](https://ckeditor.com/docs/ckeditor5/latest/features/bookmarks.html#demo) guide.
|
13
|
+
|
14
|
+
## Documentation
|
15
|
+
|
16
|
+
See the [`@ckeditor/ckeditor5-bookmark` package](https://ckeditor.com/docs/ckeditor5/latest/api/bookmark.html) page in [CKEditor 5 documentation](https://ckeditor.com/docs/ckeditor5/latest/) as well as the [bookmark](https://ckeditor.com/docs/ckeditor5/latest/features/bookmarks.html) feature guide.
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
```bash
|
21
|
+
npm install ckeditor5
|
22
|
+
```
|
23
|
+
|
24
|
+
## License
|
25
|
+
|
26
|
+
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html). For full details about the license, please check the `LICENSE.md` file or [https://ckeditor.com/legal/ckeditor-oss-license](https://ckeditor.com/legal/ckeditor-oss-license).
|
@@ -0,0 +1,4 @@
|
|
1
|
+
/*!
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md.
|
4
|
+
*/(()=>{var e={501:(e,t,o)=>{"use strict";o.d(t,{A:()=>n});var i=o(935),r=o.n(i)()((function(e){return e[1]}));r.push([e.id,'.ck-vertical-form .ck-button:after{bottom:-1px;content:"";position:absolute;right:-1px;top:-1px;width:0;z-index:1}.ck-vertical-form .ck-button:focus:after{display:none}@media screen and (max-width:600px){.ck.ck-responsive-form .ck-button:after{bottom:-1px;content:"";position:absolute;right:-1px;top:-1px;width:0;z-index:1}.ck.ck-responsive-form .ck-button:focus:after{display:none}}.ck-vertical-form>.ck-button:nth-last-child(2):after{border-right:1px solid var(--ck-color-base-border)}.ck.ck-responsive-form{padding:var(--ck-spacing-large)}.ck.ck-responsive-form:focus{outline:none}.ck.ck-responsive-form{[dir=ltr] &>:not(:first-child),[dir=rtl] &>:not(:last-child){margin-left:var(--ck-spacing-standard)}}@media screen and (max-width:600px){.ck.ck-responsive-form{padding:0;width:calc(var(--ck-input-width)*.8)}.ck.ck-responsive-form .ck-labeled-field-view{margin:var(--ck-spacing-large) var(--ck-spacing-large) 0}.ck.ck-responsive-form .ck-labeled-field-view .ck-input-number,.ck.ck-responsive-form .ck-labeled-field-view .ck-input-text{min-width:0;width:100%}.ck.ck-responsive-form .ck-labeled-field-view .ck-labeled-field-view__error{white-space:normal}.ck.ck-responsive-form>.ck-button:nth-last-child(2):after{border-right:1px solid var(--ck-color-base-border)}.ck.ck-responsive-form>.ck-button:last-child,.ck.ck-responsive-form>.ck-button:nth-last-child(2){border-radius:0;margin-top:var(--ck-spacing-large);padding:var(--ck-spacing-standard)}.ck.ck-responsive-form>.ck-button:last-child:not(:focus),.ck.ck-responsive-form>.ck-button:nth-last-child(2):not(:focus){border-top:1px solid var(--ck-color-base-border)}.ck.ck-responsive-form>.ck-button:last-child,.ck.ck-responsive-form>.ck-button:nth-last-child(2){[dir=ltr] &,[dir=rtl] &{margin-left:0}[dir=rtl] &:last-of-type{border-right:1px solid var(--ck-color-base-border)}}}',""]);const n=r},493:(e,t,o)=>{"use strict";o.d(t,{A:()=>n});var i=o(935),r=o.n(i)()((function(e){return e[1]}));r.push([e.id,":root{--ck-bookmark-icon-hover-fill-color:var(--ck-color-widget-hover-border);--ck-bookmark-icon-selected-fill-color:var(--ck-color-focus-border);--ck-bookmark-icon-animation-duration:var(--ck-widget-handler-animation-duration);--ck-bookmark-icon-animation-curve:var(--ck-widget-handler-animation-curve)}.ck-bookmark.ck-widget{outline:none}.ck-bookmark.ck-widget .ck-bookmark__icon .ck-icon__fill{transition:fill var(--ck-bookmark-icon-animation-duration) var(--ck-bookmark-icon-animation-curve)}.ck-bookmark.ck-widget:hover .ck-bookmark__icon .ck-icon__fill{fill:var(--ck-bookmark-icon-hover-fill-color)}.ck-bookmark.ck-widget.ck-widget_selected{.ck-bookmark__icon .ck-icon__fill{fill:var(--ck-bookmark-icon-selected-fill-color)}}.ck-bookmark.ck-widget.ck-widget_selected,.ck-bookmark.ck-widget.ck-widget_selected:hover{outline:none}.ck-bookmark.ck-widget .ck-bookmark__icon{position:relative;top:-.1em}.ck-bookmark.ck-widget .ck-bookmark__icon .ck-icon{height:1.2em;vertical-align:middle;width:auto}.ck .ck-fake-bookmark-selection{background:var(--ck-color-link-fake-selection)}.ck .ck-fake-bookmark-selection_collapsed{border-right:1px solid var(--ck-color-base-text);height:100%;margin-right:-1px;outline:1px solid hsla(0,0%,100%,.5)}",""]);const n=r},324:(e,t,o)=>{"use strict";o.d(t,{A:()=>n});var i=o(935),r=o.n(i)()((function(e){return e[1]}));r.push([e.id,".ck.ck-bookmark-actions{align-items:center;display:flex}.ck.ck-bookmark-actions .ck-bookmark-actions__preview{cursor:default;font-weight:400;max-width:var(--ck-input-width);min-width:3em;overflow:hidden;text-align:center;text-overflow:ellipsis;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}@media screen and (max-width:600px){.ck.ck-bookmark-actions{display:flex;flex-wrap:wrap}.ck.ck-bookmark-actions .ck-bookmark-actions__preview{flex-basis:100%;margin:var(--ck-spacing-standard) var(--ck-spacing-standard) 0;min-width:auto}.ck.ck-bookmark-actions.ck-responsive-form .ck-button{flex-basis:50%;margin-top:var(--ck-spacing-standard)}}",""]);const n=r},731:(e,t,o)=>{"use strict";o.d(t,{A:()=>n});var i=o(935),r=o.n(i)()((function(e){return e[1]}));r.push([e.id,".ck.ck-bookmark-view:focus{outline:none}.ck.ck-bookmark-form{align-items:flex-start;display:flex}@media screen and (max-width:600px){.ck.ck-bookmark-form{flex-wrap:wrap}.ck.ck-bookmark-form .ck-button,.ck.ck-bookmark-form .ck-labeled-field-view{flex-basis:100%}.ck.ck-bookmark-form .ck-button{justify-content:center}.ck.ck-bookmark-form.ck-responsive-form>.ck-button:last-child{border-radius:var(--ck-border-radius);margin:var(--ck-spacing-large);padding:0 var(--ck-spacing-standard)}}",""]);const n=r},935:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var o=e(t);return t[2]?"@media ".concat(t[2]," {").concat(o,"}"):o})).join("")},t.i=function(e,o,i){"string"==typeof e&&(e=[[null,e,""]]);var r={};if(i)for(var n=0;n<this.length;n++){var s=this[n][0];null!=s&&(r[s]=!0)}for(var a=0;a<e.length;a++){var c=[].concat(e[a]);i&&r[c[0]]||(o&&(c[2]?c[2]="".concat(o," and ").concat(c[2]):c[2]=o),t.push(c))}},t}},591:(e,t,o)=>{"use strict";var i,r=function(){return void 0===i&&(i=Boolean(window&&document&&document.all&&!window.atob)),i},n=function(){var e={};return function(t){if(void 0===e[t]){var o=document.querySelector(t);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(e){o=null}e[t]=o}return e[t]}}(),s=[];function a(e){for(var t=-1,o=0;o<s.length;o++)if(s[o].identifier===e){t=o;break}return t}function c(e,t){for(var o={},i=[],r=0;r<e.length;r++){var n=e[r],c=t.base?n[0]+t.base:n[0],l=o[c]||0,d="".concat(c," ").concat(l);o[c]=l+1;var k=a(d),m={css:n[1],media:n[2],sourceMap:n[3]};-1!==k?(s[k].references++,s[k].updater(m)):s.push({identifier:d,updater:f(m,t),references:1}),i.push(d)}return i}function l(e){var t=document.createElement("style"),i=e.attributes||{};if(void 0===i.nonce){var r=o.nc;r&&(i.nonce=r)}if(Object.keys(i).forEach((function(e){t.setAttribute(e,i[e])})),"function"==typeof e.insert)e.insert(t);else{var s=n(e.insert||"head");if(!s)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");s.appendChild(t)}return t}var d,k=(d=[],function(e,t){return d[e]=t,d.filter(Boolean).join("\n")});function m(e,t,o,i){var r=o?"":i.media?"@media ".concat(i.media," {").concat(i.css,"}"):i.css;if(e.styleSheet)e.styleSheet.cssText=k(t,r);else{var n=document.createTextNode(r),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(n,s[t]):e.appendChild(n)}}function u(e,t,o){var i=o.css,r=o.media,n=o.sourceMap;if(r?e.setAttribute("media",r):e.removeAttribute("media"),n&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(n))))," */")),e.styleSheet)e.styleSheet.cssText=i;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(i))}}var h=null,b=0;function f(e,t){var o,i,r;if(t.singleton){var n=b++;o=h||(h=l(t)),i=m.bind(null,o,n,!1),r=m.bind(null,o,n,!0)}else o=l(t),i=u.bind(null,o,t),r=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(o)};return i(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;i(e=t)}else r()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=r());var o=c(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var i=0;i<o.length;i++){var r=a(o[i]);s[r].references--}for(var n=c(e,t),l=0;l<o.length;l++){var d=a(o[l]);0===s[d].references&&(s[d].updater(),s.splice(d,1))}o=n}}}},782:(e,t,o)=>{e.exports=o(237)("./src/core.js")},783:(e,t,o)=>{e.exports=o(237)("./src/engine.js")},311:(e,t,o)=>{e.exports=o(237)("./src/ui.js")},584:(e,t,o)=>{e.exports=o(237)("./src/utils.js")},901:(e,t,o)=>{e.exports=o(237)("./src/widget.js")},237:e=>{"use strict";e.exports=CKEditor5.dll}},t={};function o(i){var r=t[i];if(void 0!==r)return r.exports;var n=t[i]={id:i,exports:{}};return e[i](n,n.exports,o),n.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nc=void 0;var i={};(()=>{"use strict";o.r(i),o.d(i,{Bookmark:()=>A,BookmarkEditing:()=>B,BookmarkUI:()=>C,InsertBookmarkCommand:()=>p,UpdateBookmarkCommand:()=>v});var e=o(782),t=o(901),r=o(311),n=o(783),s=o(584),a=o(591),c=o.n(a),l=o(501),d={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};c()(l.A,d);l.A.locals;var k=o(731),m={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};c()(k.A,m);k.A.locals;class u extends r.View{constructor(e,t){super(e),this.focusTracker=new s.FocusTracker,this.keystrokes=new s.KeystrokeHandler,this._focusables=new r.ViewCollection;const o=e.t;this._validators=t,this.idInputView=this._createIdInput(),this.buttonView=this._createButton(o("Insert"),"ck-button-action ck-button-bold"),this.buttonView.type="submit",this.children=this._createViewChildren(),this._focusCycler=new r.FocusCycler({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});this.setTemplate({tag:"form",attributes:{class:["ck","ck-bookmark-view"],tabindex:"-1"},children:this.children})}render(){super.render(),(0,r.submitHandler)({view:this});[this.idInputView,this.buttonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.idInputView.errorText=t,!1}return!0}resetFormStatus(){this.idInputView.errorText=null}_createViewChildren(){const e=this.createCollection(),t=this.t;return e.add(new r.FormHeaderView(this.locale,{label:t("Bookmark")})),e.add(this._createFormContentView()),e}_createFormContentView(){const e=new r.View(this.locale),t=this.createCollection();return t.add(this.idInputView),t.add(this.buttonView),e.setTemplate({tag:"div",attributes:{class:["ck","ck-bookmark-form","ck-responsive-form"]},children:t}),e}_createIdInput(){const e=this.locale.t,t=new r.LabeledFieldView(this.locale,r.createLabeledInputText);return t.label=e("Bookmark name"),t.infoText=e("Enter the bookmark name without spaces."),t}_createButton(e,t){const o=new r.ButtonView(this.locale);return o.set({label:e,withText:!0}),o.extendTemplate({attributes:{class:t}}),o}get id(){const{element:e}=this.idInputView.fieldView;return e?e.value.trim():null}}var h=o(324),b={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};c()(h.A,b);h.A.locals;class f extends r.View{constructor(t){super(t),this.focusTracker=new s.FocusTracker,this.keystrokes=new s.KeystrokeHandler,this._focusables=new r.ViewCollection;const o=t.t;this.bookmarkPreviewView=this._createBookmarkPreviewView(),this.removeButtonView=this._createButton(o("Remove bookmark"),e.icons.remove,"remove",this.bookmarkPreviewView),this.editButtonView=this._createButton(o("Edit bookmark"),e.icons.pencil,"edit",this.bookmarkPreviewView),this.set("id",void 0),this._focusCycler=new r.FocusCycler({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-bookmark-actions","ck-responsive-form"],tabindex:"-1"},children:[this.bookmarkPreviewView,this.editButtonView,this.removeButtonView]})}render(){super.render();[this.editButtonView,this.removeButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(e,t,o,i){const n=new r.ButtonView(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n.delegate("execute").to(this,o),n.labelView.unbind("id"),n.labelView.bind("id").to(n,"ariaLabelledBy",(e=>e.split(" ")[0])),n.ariaLabelledBy=`${n.ariaLabelledBy} ${i.id}`,n}_createBookmarkPreviewView(){const e=new r.LabelView(this.locale);return e.extendTemplate({attributes:{class:["ck","ck-bookmark-actions__preview"]}}),e.bind("text").to(this,"id"),e}}function w(e){return!(!e||"string"!=typeof e)&&!/\s/.test(e)}class p extends e.Command{refresh(){const e=this.editor.model.document.selection,t=this._getPositionToInsertBookmark(e);this.isEnabled=!!t}execute(e){if(!e)return;const{bookmarkId:t}=e;if(!w(t))return void(0,s.logWarning)("insert-bookmark-command-executed-with-invalid-name");const o=this.editor,i=o.model,r=i.document.selection;i.change((e=>{let n=this._getPositionToInsertBookmark(r);if(!i.schema.checkChild(n,"bookmark")){const e=o.execute("insertParagraph",{position:n});if(!e)return;n=e}const s=e.createElement("bookmark",{...Object.fromEntries(r.getAttributes()),bookmarkId:t});i.insertObject(s,n,null,{setSelection:"on"})}))}_getPositionToInsertBookmark(e){const t=this.editor.model,o=t.schema,i=e.getFirstRange(),r=i.start;if(g(r,o))return r;for(const{previousPosition:e,item:r}of i){if(r.is("element")&&o.checkChild(r,"$text")&&g(r,o))return t.createPositionAt(r,0);if(g(e,o))return e}return null}}function g(e,t){return!!t.checkChild(e,"bookmark")||!!t.checkChild(e,"paragraph")&&t.checkChild("paragraph","bookmark")}class v extends e.Command{refresh(){const e=_(this.editor.model.document.selection);this.isEnabled=!!e,this.value=e?e.getAttribute("bookmarkId"):void 0}execute(e){if(!e)return;const{bookmarkId:t}=e;if(!w(t))return void(0,s.logWarning)("update-bookmark-command-executed-with-invalid-name");const o=this.editor.model,i=_(o.document.selection);i&&o.change((e=>{e.setAttribute("bookmarkId",t,i)}))}}function _(e){const t=e.getSelectedElement();return t&&t.is("element","bookmark")?t:null}var V=o(493),y={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};c()(V.A,y);V.A.locals;const x=e.icons.bookmarkInline;class B extends e.Plugin{constructor(){super(...arguments),this._bookmarkElements=new Map}static get pluginName(){return"BookmarkEditing"}static get isOfficialPlugin(){return!0}init(){const{editor:e}=this;this._defineSchema(),this._defineConverters(),e.commands.add("insertBookmark",new p(e)),e.commands.add("updateBookmark",new v(e)),this.listenTo(e.model.document,"change:data",(()=>{this._trackBookmarkElements()}))}getElementForBookmarkId(e){for(const[t,o]of this._bookmarkElements)if(o==e)return t;return null}_defineSchema(){this.editor.model.schema.register("bookmark",{inheritAllFrom:"$inlineObject",allowAttributes:"bookmarkId",disallowAttributes:["linkHref","htmlA"]})}_defineConverters(){const{editor:e}=this,{conversion:o,t:i}=e;e.data.htmlProcessor.domConverter.registerInlineObjectMatcher((e=>I(e))),e.editing.view.domConverter.registerInlineObjectMatcher((e=>I(e,!1))),o.for("dataDowncast").elementToElement({model:{name:"bookmark",attributes:["bookmarkId"]},view:(e,{writer:t})=>t.createEmptyElement("a",{id:e.getAttribute("bookmarkId")})}),o.for("editingDowncast").elementToElement({model:{name:"bookmark",attributes:["bookmarkId"]},view:(e,{writer:o})=>{const r=e.getAttribute("bookmarkId"),n=o.createContainerElement("a",{id:r,class:"ck-bookmark"},[this._createBookmarkUIElement(o)]);this._bookmarkElements.set(e,r);return(0,t.toWidget)(n,o,{label:()=>`${r} ${i("bookmark widget")}`})}}),o.for("upcast").add((t=>t.on("element:a",function(e){return(t,o,i)=>{const r=o.viewItem,n=I(r,!1);if(!n||!i.consumable.test(r,n))return;const s=function(e){const t=e.config.get("bookmark.enableNonEmptyAnchorConversion");return void 0===t||t}(e);if(!s&&!r.isEmpty)return;const a=i.writer,c=r.getAttribute("id"),l=r.getAttribute("name"),d=c||l,k=a.createElement("bookmark",{bookmarkId:d});if(!i.safeInsert(k,o.modelCursor))return;i.consumable.consume(r,n),c===l&&i.consumable.consume(r,{attributes:["name"]}),i.updateConversionResult(k,o);const{modelCursor:m,modelRange:u}=i.convertChildren(r,o.modelCursor);o.modelCursor=m,o.modelRange=a.createRange(o.modelRange.start,u.end)}}(e))))}_createBookmarkUIElement(e){return e.createUIElement("span",{class:"ck-bookmark__icon"},(function(e){const t=this.toDomElement(e),o=new r.IconView;return o.set({content:x,isColorInherited:!1}),o.render(),t.appendChild(o.element),t}))}_trackBookmarkElements(){this._bookmarkElements.forEach(((e,t)=>{"$graveyard"===t.root.rootName&&this._bookmarkElements.delete(t)}))}}function I(e,t=!0){if(!("a"===e.name))return null;if(t&&!e.isEmpty)return null;const o=e.hasAttribute("id"),i=e.hasAttribute("name"),r=e.hasAttribute("href");return o&&!r?{name:!0,attributes:["id"]}:i&&!r?{name:!0,attributes:["name"]}:null}const E=e.icons.bookmark,T="bookmark-ui";class C extends e.Plugin{constructor(){super(...arguments),this.actionsView=null,this.formView=null}static get requires(){return[B,r.ContextualBalloon]}static get pluginName(){return"BookmarkUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.editing.view.addObserver(n.ClickObserver),this._balloon=e.plugins.get(r.ContextualBalloon),this._createToolbarBookmarkButton(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:T,view:{classes:["ck-fake-bookmark-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:T,view:(e,{writer:t})=>{if(!e.markerRange.isCollapsed)return null;const o=t.createUIElement("span");return t.addClass(["ck-fake-bookmark-selection","ck-fake-bookmark-selection_collapsed"],o),o}})}destroy(){super.destroy(),this.formView&&this.formView.destroy(),this.actionsView&&this.actionsView.destroy()}_createViews(){this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._enableUserBalloonInteractions()}_createActionsView(){const e=this.editor,t=new f(e.locale),o=e.commands.get("updateBookmark"),i=e.commands.get("delete");return t.bind("id").to(o,"value"),t.editButtonView.bind("isEnabled").to(o),t.removeButtonView.bind("isEnabled").to(i),this.listenTo(t,"edit",(()=>{this._addFormView()})),this.listenTo(t,"remove",(()=>{this._hideUI(),e.execute("delete")})),t.keystrokes.set("Esc",((e,t)=>{this._hideUI(),t()})),t}_createFormView(){const e=this.editor,t=e.locale,o=e.commands.get("insertBookmark"),i=e.commands.get("updateBookmark"),n=[o,i],s=new((0,r.CssTransitionDisablerMixin)(u))(t,function(e){const{t}=e,o=e.plugins.get(B);return[e=>{if(!e.id)return t("Bookmark must not be empty.")},e=>{if(e.id&&/\s/.test(e.id))return t("Bookmark name cannot contain space characters.")},i=>{const r=e.model.document.selection.getSelectedElement(),n=o.getElementForBookmarkId(i.id);if(r!==n)return n?t("Bookmark name already exists."):void 0}]}(e));return s.idInputView.fieldView.bind("value").to(i,"value"),s.idInputView.bind("isEnabled").toMany(n,"isEnabled",((...e)=>e.some((e=>e)))),s.buttonView.bind("isEnabled").toMany(n,"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(s,"submit",(()=>{if(s.isValid()){const t=s.id;this._getSelectedBookmarkElement()?e.execute("updateBookmark",{bookmarkId:t}):e.execute("insertBookmark",{bookmarkId:t}),this._closeFormView()}})),this.listenTo(s.idInputView,"change:errorText",(()=>{e.ui.update()})),s.keystrokes.set("Esc",((e,t)=>{this._closeFormView(),t()})),s}_createToolbarBookmarkButton(){const e=this.editor;e.ui.componentFactory.add("bookmark",(()=>{const e=this._createButton(r.ButtonView);return e.set({tooltip:!0}),e})),e.ui.componentFactory.add("menuBar:bookmark",(()=>this._createButton(r.MenuBarMenuListItemButtonView)))}_createButton(e){const t=this.editor,o=t.locale,i=new e(o),r=t.commands.get("insertBookmark"),n=t.commands.get("updateBookmark"),s=o.t;return i.set({label:s("Bookmark"),icon:E}),this.listenTo(i,"execute",(()=>this._showUI(!0))),i.bind("isEnabled").toMany([r,n],"isEnabled",((...e)=>e.some((e=>e)))),i.bind("isOn").to(n,"value",(e=>!!e)),i}_enableBalloonActivators(){const e=this.editor.editing.view.document;this.listenTo(e,"click",(()=>{this._getSelectedBookmarkElement()&&this._showUI()}))}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",((e,t)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),t())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((e,t)=>{this._isUIVisible&&(this._hideUI(),t())})),(0,r.clickOutsideHandler)({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUI()})}_updateFormButtonLabel(e){const t=this.editor.locale.t;this.formView.buttonView.label=t(e?"Update":"Insert")}_addActionsView(){this.actionsView||this._createViews(),this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("updateBookmark");this.formView.disableCssTransitions(),this.formView.resetFormStatus(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.formView.idInputView.fieldView.value=e.value||"",this._balloon.visibleView===this.formView&&this.formView.idInputView.fieldView.select(),this.formView.enableCssTransitions()}_closeFormView(){void 0!==this.editor.commands.get("updateBookmark").value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.buttonView.focus(),this.formView.idInputView.fieldView.reset(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this.formView||this._createViews(),this._getSelectedBookmarkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let o=this._getSelectedBookmarkElement(),i=n();this._updateFormButtonLabel(!!o);const r=()=>{const e=this._getSelectedBookmarkElement(),t=n();o&&!e||!o&&t!==i?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),this._updateFormButtonLabel(!!o),o=e,i=t};function n(){return t.selection.focus.getAncestors().reverse().find((e=>e.is("element")))}this.listenTo(e.ui,"update",r),this.listenTo(this._balloon,"change:visibleView",r)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _areActionsInPanel(){return!!this.actionsView&&this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return!!this.actionsView&&this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){const e=this._balloon.visibleView;return!!this.formView&&e==this.formView||this._areActionsVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model;let o;const i=this._getSelectedBookmarkElement();if(t.markers.has(T)){const t=Array.from(this.editor.editing.mapper.markerNameToElements(T)),i=e.createRange(e.createPositionBefore(t[0]),e.createPositionAfter(t[t.length-1]));o=e.domConverter.viewRangeToDom(i)}else i&&(o=()=>{const t=this.editor.editing.mapper,o=e.domConverter,r=t.toViewElement(i);return o.mapViewToDom(r)});return o&&{target:o}}_getSelectedBookmarkElement(){const e=this.editor.model.document.selection.getSelectedElement();return e&&e.is("element","bookmark")?e:null}_showFakeVisualSelection(){const e=this.editor.model;e.change((t=>{const o=e.document.selection.getFirstRange();if(e.markers.has(T))t.updateMarker(T,{range:o});else if(o.start.isAtEnd){const i=o.start.getLastMatchingPosition((({item:t})=>!e.schema.isContent(t)),{boundaries:o});t.addMarker(T,{usingOperation:!1,affectsData:!1,range:t.createRange(i,o.end)})}else t.addMarker(T,{usingOperation:!1,affectsData:!1,range:o})}))}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(T)&&e.change((e=>{e.removeMarker(T)}))}}class A extends e.Plugin{static get pluginName(){return"Bookmark"}static get requires(){return[B,C,t.Widget]}static get isOfficialPlugin(){return!0}}})(),(window.CKEditor5=window.CKEditor5||{}).bookmark=i})();
|
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"plugins": [
|
3
|
+
{
|
4
|
+
"name": "Bookmark",
|
5
|
+
"className": "Bookmark",
|
6
|
+
"description": "Allows to insert a bookmark into the content to provide fast access to important sections.",
|
7
|
+
"docs": "features/bookmarks.html",
|
8
|
+
"path": "src/bookmark.js",
|
9
|
+
"uiComponents": [
|
10
|
+
{
|
11
|
+
"type": "Button",
|
12
|
+
"name": "bookmark",
|
13
|
+
"iconPath": "@ckeditor/ckeditor5-core/theme/icons/bookmark.svg"
|
14
|
+
}
|
15
|
+
],
|
16
|
+
"htmlOutput": [
|
17
|
+
{
|
18
|
+
"elements": "a",
|
19
|
+
"attributes": "id"
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
23
|
+
]
|
24
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
8
|
+
*/
|
9
|
+
import type { Bookmark, BookmarkEditing, BookmarkUI, InsertBookmarkCommand, UpdateBookmarkCommand, BookmarkConfig } from './index.js';
|
10
|
+
declare module '@ckeditor/ckeditor5-core' {
|
11
|
+
interface EditorConfig {
|
12
|
+
/**
|
13
|
+
* The configuration of the {@link module:bookmark/bookmark~Bookmark} feature.
|
14
|
+
*
|
15
|
+
* Read more in {@link module:bookmark/bookmarkconfig~BookmarkConfig}.
|
16
|
+
*/
|
17
|
+
bookmark?: BookmarkConfig;
|
18
|
+
}
|
19
|
+
interface PluginsMap {
|
20
|
+
[Bookmark.pluginName]: Bookmark;
|
21
|
+
[BookmarkEditing.pluginName]: BookmarkEditing;
|
22
|
+
[BookmarkUI.pluginName]: BookmarkUI;
|
23
|
+
}
|
24
|
+
interface CommandsMap {
|
25
|
+
insertBookmark: InsertBookmarkCommand;
|
26
|
+
updateBookmark: UpdateBookmarkCommand;
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
8
|
+
*/
|
9
|
+
/**
|
10
|
+
* @module bookmark/bookmark
|
11
|
+
*/
|
12
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
13
|
+
import { Widget } from 'ckeditor5/src/widget.js';
|
14
|
+
import BookmarkUI from './bookmarkui.js';
|
15
|
+
import BookmarkEditing from './bookmarkediting.js';
|
16
|
+
/**
|
17
|
+
* The bookmark feature.
|
18
|
+
*
|
19
|
+
* For a detailed overview, check the {@glink features/bookmarks Bookmarks} feature guide.
|
20
|
+
*/
|
21
|
+
export default class Bookmark extends Plugin {
|
22
|
+
/**
|
23
|
+
* @inheritDoc
|
24
|
+
*/
|
25
|
+
static get pluginName(): "Bookmark";
|
26
|
+
/**
|
27
|
+
* @inheritDoc
|
28
|
+
*/
|
29
|
+
static get requires(): readonly [typeof BookmarkEditing, typeof BookmarkUI, typeof Widget];
|
30
|
+
/**
|
31
|
+
* @inheritDoc
|
32
|
+
*/
|
33
|
+
static get isOfficialPlugin(): true;
|
34
|
+
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
8
|
+
*/
|
9
|
+
/**
|
10
|
+
* @module bookmark/bookmarkconfig
|
11
|
+
*/
|
12
|
+
/**
|
13
|
+
* The configuration of the bookmark feature.
|
14
|
+
*
|
15
|
+
* The properties defined in this config are set in the `config.bookmark` namespace.
|
16
|
+
*
|
17
|
+
* ```ts
|
18
|
+
* ClassicEditor
|
19
|
+
* .create( editorElement, {
|
20
|
+
* bookmark: {
|
21
|
+
* // Bookmark configuration.
|
22
|
+
* }
|
23
|
+
* } )
|
24
|
+
* .then( ... )
|
25
|
+
* .catch( ... );
|
26
|
+
* ```
|
27
|
+
*
|
28
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
29
|
+
*/
|
30
|
+
export interface BookmarkConfig {
|
31
|
+
/**
|
32
|
+
* Allows to convert into bookmarks non-empty anchor elements.
|
33
|
+
*
|
34
|
+
* With this option enabled you will have all non-empty anchors converted into bookmakrs.
|
35
|
+
* For example:
|
36
|
+
*
|
37
|
+
*```html
|
38
|
+
* <a id="bookmark">Bookmark</a>
|
39
|
+
*```
|
40
|
+
*
|
41
|
+
* will be converted into:
|
42
|
+
*
|
43
|
+
*```html
|
44
|
+
* <a id="bookmark"></a>Bookmark
|
45
|
+
*```
|
46
|
+
*
|
47
|
+
* **Note:** This is enabled by default.
|
48
|
+
*
|
49
|
+
* @default true
|
50
|
+
*/
|
51
|
+
enableNonEmptyAnchorConversion?: boolean;
|
52
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
8
|
+
*/
|
9
|
+
/**
|
10
|
+
* @module bookmark/bookmarkediting
|
11
|
+
*/
|
12
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
13
|
+
import type { Element } from 'ckeditor5/src/engine.js';
|
14
|
+
import '../theme/bookmark.css';
|
15
|
+
/**
|
16
|
+
* The bookmark editing plugin.
|
17
|
+
*/
|
18
|
+
export default class BookmarkEditing extends Plugin {
|
19
|
+
/**
|
20
|
+
* A collection of bookmarks elements in the document.
|
21
|
+
*/
|
22
|
+
private _bookmarkElements;
|
23
|
+
/**
|
24
|
+
* @inheritDoc
|
25
|
+
*/
|
26
|
+
static get pluginName(): "BookmarkEditing";
|
27
|
+
/**
|
28
|
+
* @inheritDoc
|
29
|
+
*/
|
30
|
+
static get isOfficialPlugin(): true;
|
31
|
+
/**
|
32
|
+
* @inheritDoc
|
33
|
+
*/
|
34
|
+
init(): void;
|
35
|
+
/**
|
36
|
+
* Returns the model element for the given bookmark ID if it exists.
|
37
|
+
*/
|
38
|
+
getElementForBookmarkId(bookmarkId: string): Element | null;
|
39
|
+
/**
|
40
|
+
* Defines the schema for the bookmark feature.
|
41
|
+
*/
|
42
|
+
private _defineSchema;
|
43
|
+
/**
|
44
|
+
* Defines the converters for the bookmark feature.
|
45
|
+
*/
|
46
|
+
private _defineConverters;
|
47
|
+
/**
|
48
|
+
* Creates a UI element for the `bookmark` representation in editing view.
|
49
|
+
*/
|
50
|
+
private _createBookmarkUIElement;
|
51
|
+
/**
|
52
|
+
* Tracking the added or removed bookmark elements.
|
53
|
+
*/
|
54
|
+
private _trackBookmarkElements;
|
55
|
+
}
|
@@ -0,0 +1,170 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
8
|
+
*/
|
9
|
+
/**
|
10
|
+
* @module bookmark/bookmarkui
|
11
|
+
*/
|
12
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
13
|
+
import { ContextualBalloon, type ViewWithCssTransitionDisabler } from 'ckeditor5/src/ui.js';
|
14
|
+
import BookmarkFormView from './ui/bookmarkformview.js';
|
15
|
+
import BookmarkActionsView from './ui/bookmarkactionsview.js';
|
16
|
+
import BookmarkEditing from './bookmarkediting.js';
|
17
|
+
/**
|
18
|
+
* The UI plugin of the bookmark feature.
|
19
|
+
*
|
20
|
+
* It registers the `'bookmark'` UI button in the editor's {@link module:ui/componentfactory~ComponentFactory component factory}
|
21
|
+
* which inserts the `bookmark` element upon selection.
|
22
|
+
*/
|
23
|
+
export default class BookmarkUI extends Plugin {
|
24
|
+
/**
|
25
|
+
* The actions view displayed inside of the balloon.
|
26
|
+
*/
|
27
|
+
actionsView: BookmarkActionsView | null;
|
28
|
+
/**
|
29
|
+
* The form view displayed inside the balloon.
|
30
|
+
*/
|
31
|
+
formView: BookmarkFormView & ViewWithCssTransitionDisabler | null;
|
32
|
+
/**
|
33
|
+
* The contextual balloon plugin instance.
|
34
|
+
*/
|
35
|
+
private _balloon;
|
36
|
+
/**
|
37
|
+
* @inheritDoc
|
38
|
+
*/
|
39
|
+
static get requires(): readonly [typeof BookmarkEditing, typeof ContextualBalloon];
|
40
|
+
/**
|
41
|
+
* @inheritDoc
|
42
|
+
*/
|
43
|
+
static get pluginName(): "BookmarkUI";
|
44
|
+
/**
|
45
|
+
* @inheritDoc
|
46
|
+
*/
|
47
|
+
static get isOfficialPlugin(): true;
|
48
|
+
/**
|
49
|
+
* @inheritDoc
|
50
|
+
*/
|
51
|
+
init(): void;
|
52
|
+
/**
|
53
|
+
* @inheritDoc
|
54
|
+
*/
|
55
|
+
destroy(): void;
|
56
|
+
/**
|
57
|
+
* Creates views.
|
58
|
+
*/
|
59
|
+
private _createViews;
|
60
|
+
/**
|
61
|
+
* Creates the {@link module:bookmark/ui/bookmarkactionsview~BookmarkActionsView} instance.
|
62
|
+
*/
|
63
|
+
private _createActionsView;
|
64
|
+
/**
|
65
|
+
* Creates the {@link module:bookmark/ui/bookmarkformview~BookmarkFormView} instance.
|
66
|
+
*/
|
67
|
+
private _createFormView;
|
68
|
+
/**
|
69
|
+
* Creates a toolbar Bookmark button. Clicking this button will show
|
70
|
+
* a {@link #_balloon} attached to the selection.
|
71
|
+
*/
|
72
|
+
private _createToolbarBookmarkButton;
|
73
|
+
/**
|
74
|
+
* Creates a button for `bookmark` command to use either in toolbar or in menu bar.
|
75
|
+
*/
|
76
|
+
private _createButton;
|
77
|
+
/**
|
78
|
+
* Attaches actions that control whether the balloon panel containing the
|
79
|
+
* {@link #formView} should be displayed.
|
80
|
+
*/
|
81
|
+
private _enableBalloonActivators;
|
82
|
+
/**
|
83
|
+
* Attaches actions that control whether the balloon panel containing the
|
84
|
+
* {@link #formView} is visible or not.
|
85
|
+
*/
|
86
|
+
private _enableUserBalloonInteractions;
|
87
|
+
/**
|
88
|
+
* Updates the button label. If bookmark is selected label is set to 'Update' otherwise
|
89
|
+
* it is 'Insert'.
|
90
|
+
*/
|
91
|
+
private _updateFormButtonLabel;
|
92
|
+
/**
|
93
|
+
* Adds the {@link #actionsView} to the {@link #_balloon}.
|
94
|
+
*
|
95
|
+
* @internal
|
96
|
+
*/
|
97
|
+
_addActionsView(): void;
|
98
|
+
/**
|
99
|
+
* Adds the {@link #formView} to the {@link #_balloon}.
|
100
|
+
*/
|
101
|
+
private _addFormView;
|
102
|
+
/**
|
103
|
+
* Closes the form view. Decides whether the balloon should be hidden completely.
|
104
|
+
*/
|
105
|
+
private _closeFormView;
|
106
|
+
/**
|
107
|
+
* Removes the {@link #formView} from the {@link #_balloon}.
|
108
|
+
*/
|
109
|
+
private _removeFormView;
|
110
|
+
/**
|
111
|
+
* Shows the correct UI type. It is either {@link #formView} or {@link #actionsView}.
|
112
|
+
*/
|
113
|
+
private _showUI;
|
114
|
+
/**
|
115
|
+
* Removes the {@link #formView} from the {@link #_balloon}.
|
116
|
+
*
|
117
|
+
* See {@link #_addFormView}, {@link #_addActionsView}.
|
118
|
+
*/
|
119
|
+
private _hideUI;
|
120
|
+
/**
|
121
|
+
* Makes the UI react to the {@link module:ui/editorui/editorui~EditorUI#event:update} event to
|
122
|
+
* reposition itself when the editor UI should be refreshed.
|
123
|
+
*
|
124
|
+
* See: {@link #_hideUI} to learn when the UI stops reacting to the `update` event.
|
125
|
+
*/
|
126
|
+
private _startUpdatingUI;
|
127
|
+
/**
|
128
|
+
* Returns `true` when {@link #formView} is in the {@link #_balloon}.
|
129
|
+
*/
|
130
|
+
private get _isFormInPanel();
|
131
|
+
/**
|
132
|
+
* Returns `true` when {@link #actionsView} is in the {@link #_balloon}.
|
133
|
+
*/
|
134
|
+
private get _areActionsInPanel();
|
135
|
+
/**
|
136
|
+
* Returns `true` when {@link #actionsView} is in the {@link #_balloon} and it is
|
137
|
+
* currently visible.
|
138
|
+
*/
|
139
|
+
private get _areActionsVisible();
|
140
|
+
/**
|
141
|
+
* Returns `true` when {@link #actionsView} or {@link #formView} is in the {@link #_balloon}.
|
142
|
+
*/
|
143
|
+
private get _isUIInPanel();
|
144
|
+
/**
|
145
|
+
* Returns `true` when {@link #actionsView} or {@link #formView} is in the {@link #_balloon} and it is
|
146
|
+
* currently visible.
|
147
|
+
*/
|
148
|
+
private get _isUIVisible();
|
149
|
+
/**
|
150
|
+
* Returns positioning options for the {@link #_balloon}. They control the way the balloon is attached
|
151
|
+
* to the target element or selection.
|
152
|
+
*/
|
153
|
+
private _getBalloonPositionData;
|
154
|
+
/**
|
155
|
+
* Returns the bookmark {@link module:engine/view/attributeelement~AttributeElement} under
|
156
|
+
* the {@link module:engine/view/document~Document editing view's} selection or `null`
|
157
|
+
* if there is none.
|
158
|
+
*/
|
159
|
+
private _getSelectedBookmarkElement;
|
160
|
+
/**
|
161
|
+
* Displays a fake visual selection when the contextual balloon is displayed.
|
162
|
+
*
|
163
|
+
* This adds a 'bookmark-ui' marker into the document that is rendered as a highlight on selected text fragment.
|
164
|
+
*/
|
165
|
+
private _showFakeVisualSelection;
|
166
|
+
/**
|
167
|
+
* Hides the fake visual selection created in {@link #_showFakeVisualSelection}.
|
168
|
+
*/
|
169
|
+
private _hideFakeVisualSelection;
|
170
|
+
}
|
@@ -0,0 +1,150 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
:root{
|
6
|
+
--ck-bookmark-icon-hover-fill-color:var(--ck-color-widget-hover-border);
|
7
|
+
--ck-bookmark-icon-selected-fill-color:var(--ck-color-focus-border);
|
8
|
+
--ck-bookmark-icon-animation-duration:var(--ck-widget-handler-animation-duration);
|
9
|
+
--ck-bookmark-icon-animation-curve:var(--ck-widget-handler-animation-curve);
|
10
|
+
}
|
11
|
+
|
12
|
+
.ck-bookmark.ck-widget{
|
13
|
+
outline:none;
|
14
|
+
}
|
15
|
+
|
16
|
+
.ck-bookmark.ck-widget .ck-bookmark__icon .ck-icon__fill{
|
17
|
+
transition:fill var(--ck-bookmark-icon-animation-duration) var(--ck-bookmark-icon-animation-curve);
|
18
|
+
}
|
19
|
+
|
20
|
+
.ck-bookmark.ck-widget:hover .ck-bookmark__icon .ck-icon__fill{
|
21
|
+
fill:var(--ck-bookmark-icon-hover-fill-color);
|
22
|
+
}
|
23
|
+
|
24
|
+
.ck-bookmark.ck-widget.ck-widget_selected .ck-bookmark__icon .ck-icon__fill{
|
25
|
+
fill:var(--ck-bookmark-icon-selected-fill-color);
|
26
|
+
}
|
27
|
+
|
28
|
+
.ck-bookmark.ck-widget.ck-widget_selected,
|
29
|
+
.ck-bookmark.ck-widget.ck-widget_selected:hover{
|
30
|
+
outline:none;
|
31
|
+
}
|
32
|
+
|
33
|
+
.ck-bookmark.ck-widget .ck-bookmark__icon{
|
34
|
+
position:relative;
|
35
|
+
top:-0.1em;
|
36
|
+
}
|
37
|
+
|
38
|
+
.ck-bookmark.ck-widget .ck-bookmark__icon .ck-icon{
|
39
|
+
height:1.2em;
|
40
|
+
width:auto;
|
41
|
+
vertical-align:middle;
|
42
|
+
}
|
43
|
+
|
44
|
+
.ck.ck-bookmark-view:focus{
|
45
|
+
outline:none;
|
46
|
+
}
|
47
|
+
|
48
|
+
.ck.ck-bookmark-form{
|
49
|
+
display:flex;
|
50
|
+
align-items:flex-start;
|
51
|
+
}
|
52
|
+
|
53
|
+
@media screen and (max-width: 600px){
|
54
|
+
|
55
|
+
.ck.ck-bookmark-form{
|
56
|
+
flex-wrap:wrap;
|
57
|
+
}
|
58
|
+
|
59
|
+
.ck.ck-bookmark-form .ck-button,
|
60
|
+
.ck.ck-bookmark-form .ck-labeled-field-view{
|
61
|
+
flex-basis:100%;
|
62
|
+
}
|
63
|
+
|
64
|
+
.ck.ck-bookmark-form .ck-button{
|
65
|
+
justify-content:center;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
@media screen and (max-width: 600px){
|
70
|
+
.ck.ck-bookmark-form.ck-responsive-form > .ck-button:nth-last-child(1){
|
71
|
+
margin:var(--ck-spacing-large);
|
72
|
+
padding:0 var(--ck-spacing-standard);
|
73
|
+
border-radius:var(--ck-border-radius);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
.ck-vertical-form .ck-button::after{
|
78
|
+
content:"";
|
79
|
+
width:0;
|
80
|
+
position:absolute;
|
81
|
+
right:-1px;
|
82
|
+
top:-1px;
|
83
|
+
bottom:-1px;
|
84
|
+
z-index:1;
|
85
|
+
}
|
86
|
+
|
87
|
+
.ck-vertical-form .ck-button:focus::after{
|
88
|
+
display:none;
|
89
|
+
}
|
90
|
+
|
91
|
+
@media screen and (max-width: 600px){
|
92
|
+
.ck.ck-responsive-form .ck-button::after{
|
93
|
+
content:"";
|
94
|
+
width:0;
|
95
|
+
position:absolute;
|
96
|
+
right:-1px;
|
97
|
+
top:-1px;
|
98
|
+
bottom:-1px;
|
99
|
+
z-index:1;
|
100
|
+
}
|
101
|
+
|
102
|
+
.ck.ck-responsive-form .ck-button:focus::after{
|
103
|
+
display:none;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
.ck.ck-bookmark-actions{
|
108
|
+
display:flex;
|
109
|
+
align-items:center;
|
110
|
+
}
|
111
|
+
|
112
|
+
.ck.ck-bookmark-actions .ck-bookmark-actions__preview{
|
113
|
+
max-width:var(--ck-input-width);
|
114
|
+
min-width:3em;
|
115
|
+
font-weight:normal;
|
116
|
+
text-overflow:ellipsis;
|
117
|
+
text-align:center;
|
118
|
+
overflow:hidden;
|
119
|
+
|
120
|
+
-moz-user-select:none;
|
121
|
+
|
122
|
+
-webkit-user-select:none;
|
123
|
+
|
124
|
+
-ms-user-select:none;
|
125
|
+
|
126
|
+
user-select:none;
|
127
|
+
cursor:default;
|
128
|
+
}
|
129
|
+
|
130
|
+
@media screen and (max-width: 600px){
|
131
|
+
|
132
|
+
.ck.ck-bookmark-actions{
|
133
|
+
display:flex;
|
134
|
+
flex-wrap:wrap;
|
135
|
+
}
|
136
|
+
|
137
|
+
.ck.ck-bookmark-actions .ck-bookmark-actions__preview{
|
138
|
+
flex-basis:100%;
|
139
|
+
margin:var(--ck-spacing-standard) var(--ck-spacing-standard) 0;
|
140
|
+
min-width:auto;
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
@media screen and (max-width: 600px){
|
145
|
+
|
146
|
+
.ck.ck-bookmark-actions.ck-responsive-form .ck-button{
|
147
|
+
flex-basis:50%;
|
148
|
+
margin-top:var(--ck-spacing-standard);
|
149
|
+
}
|
150
|
+
}
|