@ckeditor/ckeditor5-bookmark 0.0.0-nightly-20260107.0 → 0.0.0-nightly-next-20260107.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/ckeditor5-metadata.json +1 -1
- package/{src → dist}/augmentation.d.ts +4 -0
- package/{src → dist}/bookmark.d.ts +6 -2
- package/{src → dist}/bookmarkconfig.d.ts +4 -0
- package/{src → dist}/bookmarkediting.d.ts +6 -2
- package/{src → dist}/bookmarkui.d.ts +7 -3
- package/{src → dist}/index.d.ts +4 -0
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/{src → dist}/insertbookmarkcommand.d.ts +5 -1
- package/{src → dist}/ui/bookmarkformview.d.ts +6 -2
- package/{src → dist}/updatebookmarkcommand.d.ts +5 -1
- package/{src → dist}/utils.d.ts +4 -0
- package/package.json +25 -34
- package/build/bookmark.js +0 -5
- package/build/translations/af.js +0 -1
- package/build/translations/ar.js +0 -1
- package/build/translations/ast.js +0 -1
- package/build/translations/az.js +0 -1
- package/build/translations/be.js +0 -1
- package/build/translations/bg.js +0 -1
- package/build/translations/bn.js +0 -1
- package/build/translations/bs.js +0 -1
- package/build/translations/ca.js +0 -1
- package/build/translations/cs.js +0 -1
- package/build/translations/da.js +0 -1
- package/build/translations/de-ch.js +0 -1
- package/build/translations/de.js +0 -1
- package/build/translations/el.js +0 -1
- package/build/translations/en-au.js +0 -1
- package/build/translations/en-gb.js +0 -1
- package/build/translations/eo.js +0 -1
- package/build/translations/es-co.js +0 -1
- package/build/translations/es.js +0 -1
- package/build/translations/et.js +0 -1
- package/build/translations/eu.js +0 -1
- package/build/translations/fa.js +0 -1
- package/build/translations/fi.js +0 -1
- package/build/translations/fr.js +0 -1
- package/build/translations/gl.js +0 -1
- package/build/translations/gu.js +0 -1
- package/build/translations/he.js +0 -1
- package/build/translations/hi.js +0 -1
- package/build/translations/hr.js +0 -1
- package/build/translations/hu.js +0 -1
- package/build/translations/hy.js +0 -1
- package/build/translations/id.js +0 -1
- package/build/translations/it.js +0 -1
- package/build/translations/ja.js +0 -1
- package/build/translations/jv.js +0 -1
- package/build/translations/kk.js +0 -1
- package/build/translations/km.js +0 -1
- package/build/translations/kn.js +0 -1
- package/build/translations/ko.js +0 -1
- package/build/translations/ku.js +0 -1
- package/build/translations/lt.js +0 -1
- package/build/translations/lv.js +0 -1
- package/build/translations/ms.js +0 -1
- package/build/translations/nb.js +0 -1
- package/build/translations/ne.js +0 -1
- package/build/translations/nl.js +0 -1
- package/build/translations/no.js +0 -1
- package/build/translations/oc.js +0 -1
- package/build/translations/pl.js +0 -1
- package/build/translations/pt-br.js +0 -1
- package/build/translations/pt.js +0 -1
- package/build/translations/ro.js +0 -1
- package/build/translations/ru.js +0 -1
- package/build/translations/si.js +0 -1
- package/build/translations/sk.js +0 -1
- package/build/translations/sl.js +0 -1
- package/build/translations/sq.js +0 -1
- package/build/translations/sr-latn.js +0 -1
- package/build/translations/sr.js +0 -1
- package/build/translations/sv.js +0 -1
- package/build/translations/th.js +0 -1
- package/build/translations/ti.js +0 -1
- package/build/translations/tk.js +0 -1
- package/build/translations/tr.js +0 -1
- package/build/translations/tt.js +0 -1
- package/build/translations/ug.js +0 -1
- package/build/translations/uk.js +0 -1
- package/build/translations/ur.js +0 -1
- package/build/translations/uz.js +0 -1
- package/build/translations/vi.js +0 -1
- package/build/translations/zh-cn.js +0 -1
- package/build/translations/zh.js +0 -1
- package/src/augmentation.js +0 -5
- package/src/bookmark.js +0 -36
- package/src/bookmarkconfig.js +0 -5
- package/src/bookmarkediting.js +0 -238
- package/src/bookmarkui.js +0 -591
- package/src/index.js +0 -15
- package/src/insertbookmarkcommand.js +0 -113
- package/src/ui/bookmarkformview.js +0 -244
- package/src/updatebookmarkcommand.js +0 -75
- package/src/utils.js +0 -21
package/build/translations/uz.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(o){const a=o.uz=o.uz||{};a.dictionary=Object.assign(a.dictionary||{},{Bookmark:"","Bookmark must not be empty.":"","Bookmark name":"","Bookmark name already exists.":"","Bookmark name cannot contain space characters.":"","Bookmark toolbar":"","bookmark widget":"",Bookmarks:"","Edit bookmark":"","Enter the bookmark name without spaces.":"","No bookmarks available.":"","Remove bookmark":"","Scroll to bookmark":""})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
package/build/translations/vi.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(n){const a=n.vi=n.vi||{};a.dictionary=Object.assign(a.dictionary||{},{Bookmark:"Dấu trang","Bookmark must not be empty.":"Dấu trang không được để trống.","Bookmark name":"Tên dấu trang","Bookmark name already exists.":"Tên dấu trang đã tồn tại.","Bookmark name cannot contain space characters.":"Tên dấu trang không được chứa ký tự khoảng trắng.","Bookmark toolbar":"Thanh công cụ Đánh dấu trang","bookmark widget":"tiện ích đánh dấu trang",Bookmarks:"Dấu trang","Edit bookmark":"Chỉnh sửa dấu trang","Enter the bookmark name without spaces.":"Nhập tên dấu trang không có khoảng trắng.","No bookmarks available.":"Không có dấu trang khả dụng.","Remove bookmark":"Xóa dấu trang","Scroll to bookmark":"Cuộn chuột đến dấu trang"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(o){const a=o["zh-cn"]=o["zh-cn"]||{};a.dictionary=Object.assign(a.dictionary||{},{Bookmark:"书签","Bookmark must not be empty.":"书签不能为空。","Bookmark name":"书签名称","Bookmark name already exists.":"书签名称已存在。","Bookmark name cannot contain space characters.":"书签名称不能包含空格。","Bookmark toolbar":"书签工具栏","bookmark widget":"书签小组件",Bookmarks:"书签","Edit bookmark":"编辑书签","Enter the bookmark name without spaces.":"输入书签名称,不带空格。","No bookmarks available.":"无可用书签。","Remove bookmark":"删除书签","Scroll to bookmark":"滚动到书签"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
package/build/translations/zh.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(o){const a=o.zh=o.zh||{};a.dictionary=Object.assign(a.dictionary||{},{Bookmark:"書籤","Bookmark must not be empty.":"書籤名稱不得為空。","Bookmark name":"書籤名稱","Bookmark name already exists.":"書籤名稱已存在。","Bookmark name cannot contain space characters.":"書籤名稱不可包含空格字元。","Bookmark toolbar":"書籤工具列","bookmark widget":"書籤小工具",Bookmarks:"書籤","Edit bookmark":"編輯書籤","Enter the bookmark name without spaces.":"輸入書籤名稱,請勿包含空格。","No bookmarks available.":"無可用書籤。","Remove bookmark":"移除書籤","Scroll to bookmark":"捲動至書籤"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
package/src/augmentation.js
DELETED
package/src/bookmark.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2025, 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 bookmark/bookmark
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { Widget } from 'ckeditor5/src/widget.js';
|
|
10
|
-
import { BookmarkUI } from './bookmarkui.js';
|
|
11
|
-
import { BookmarkEditing } from './bookmarkediting.js';
|
|
12
|
-
/**
|
|
13
|
-
* The bookmark feature.
|
|
14
|
-
*
|
|
15
|
-
* For a detailed overview, check the {@glink features/bookmarks Bookmarks} feature guide.
|
|
16
|
-
*/
|
|
17
|
-
export class Bookmark extends Plugin {
|
|
18
|
-
/**
|
|
19
|
-
* @inheritDoc
|
|
20
|
-
*/
|
|
21
|
-
static get pluginName() {
|
|
22
|
-
return 'Bookmark';
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* @inheritDoc
|
|
26
|
-
*/
|
|
27
|
-
static get requires() {
|
|
28
|
-
return [BookmarkEditing, BookmarkUI, Widget];
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @inheritDoc
|
|
32
|
-
*/
|
|
33
|
-
static get isOfficialPlugin() {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
}
|
package/src/bookmarkconfig.js
DELETED
package/src/bookmarkediting.js
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2025, 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 bookmark/bookmarkediting
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { toWidget } from 'ckeditor5/src/widget.js';
|
|
10
|
-
import { IconView } from 'ckeditor5/src/ui.js';
|
|
11
|
-
import { IconBookmarkInline } from 'ckeditor5/src/icons.js';
|
|
12
|
-
import { InsertBookmarkCommand } from './insertbookmarkcommand.js';
|
|
13
|
-
import { UpdateBookmarkCommand } from './updatebookmarkcommand.js';
|
|
14
|
-
import '../theme/bookmark.css';
|
|
15
|
-
/**
|
|
16
|
-
* The bookmark editing plugin.
|
|
17
|
-
*/
|
|
18
|
-
export class BookmarkEditing extends Plugin {
|
|
19
|
-
/**
|
|
20
|
-
* A collection of bookmarks elements in the document.
|
|
21
|
-
*/
|
|
22
|
-
_bookmarkElements = new Map();
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
static get pluginName() {
|
|
27
|
-
return 'BookmarkEditing';
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @inheritDoc
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
static get licenseFeatureCode() {
|
|
34
|
-
return 'BKM';
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @inheritDoc
|
|
38
|
-
*/
|
|
39
|
-
static get isOfficialPlugin() {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* @inheritDoc
|
|
44
|
-
*/
|
|
45
|
-
static get isPremiumPlugin() {
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* @inheritDoc
|
|
50
|
-
*/
|
|
51
|
-
constructor(editor) {
|
|
52
|
-
super(editor);
|
|
53
|
-
editor.config.define('bookmark', {
|
|
54
|
-
toolbar: ['bookmarkPreview', '|', 'editBookmark', 'removeBookmark']
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* @inheritDoc
|
|
59
|
-
*/
|
|
60
|
-
init() {
|
|
61
|
-
const { editor } = this;
|
|
62
|
-
this._defineSchema();
|
|
63
|
-
this._defineConverters();
|
|
64
|
-
editor.commands.add('insertBookmark', new InsertBookmarkCommand(editor));
|
|
65
|
-
editor.commands.add('updateBookmark', new UpdateBookmarkCommand(editor));
|
|
66
|
-
this.listenTo(editor.model.document, 'change:data', () => {
|
|
67
|
-
this._trackBookmarkElements();
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Returns the model element for the given bookmark ID if it exists.
|
|
72
|
-
*/
|
|
73
|
-
getElementForBookmarkId(bookmarkId) {
|
|
74
|
-
for (const [element, id] of this._bookmarkElements) {
|
|
75
|
-
if (id == bookmarkId) {
|
|
76
|
-
return element;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Returns all unique bookmark names existing in the content.
|
|
83
|
-
*/
|
|
84
|
-
getAllBookmarkNames() {
|
|
85
|
-
return new Set(this._bookmarkElements.values());
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Defines the schema for the bookmark feature.
|
|
89
|
-
*/
|
|
90
|
-
_defineSchema() {
|
|
91
|
-
const schema = this.editor.model.schema;
|
|
92
|
-
schema.register('bookmark', {
|
|
93
|
-
inheritAllFrom: '$inlineObject',
|
|
94
|
-
allowAttributes: 'bookmarkId',
|
|
95
|
-
disallowAttributes: ['linkHref', 'htmlA']
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Defines the converters for the bookmark feature.
|
|
100
|
-
*/
|
|
101
|
-
_defineConverters() {
|
|
102
|
-
const { editor } = this;
|
|
103
|
-
const { conversion, t } = editor;
|
|
104
|
-
editor.data.htmlProcessor.domConverter.registerInlineObjectMatcher(element => upcastMatcher(element));
|
|
105
|
-
// Register an inline object matcher so that bookmarks <a>s are correctly recognized as inline elements in editing pipeline.
|
|
106
|
-
// This prevents converting spaces around bookmarks to ` `s.
|
|
107
|
-
editor.editing.view.domConverter.registerInlineObjectMatcher(element => upcastMatcher(element, false));
|
|
108
|
-
conversion.for('dataDowncast').elementToElement({
|
|
109
|
-
model: {
|
|
110
|
-
name: 'bookmark',
|
|
111
|
-
attributes: ['bookmarkId']
|
|
112
|
-
},
|
|
113
|
-
view: (modelElement, { writer }) => {
|
|
114
|
-
const emptyElement = writer.createEmptyElement('a', {
|
|
115
|
-
'id': modelElement.getAttribute('bookmarkId')
|
|
116
|
-
});
|
|
117
|
-
// `getFillerOffset` is not needed to set here, because `emptyElement` has already covered it.
|
|
118
|
-
return emptyElement;
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
conversion.for('editingDowncast').elementToElement({
|
|
122
|
-
model: {
|
|
123
|
-
name: 'bookmark',
|
|
124
|
-
attributes: ['bookmarkId']
|
|
125
|
-
},
|
|
126
|
-
view: (modelElement, { writer }) => {
|
|
127
|
-
const id = modelElement.getAttribute('bookmarkId');
|
|
128
|
-
const containerElement = writer.createContainerElement('a', {
|
|
129
|
-
id,
|
|
130
|
-
class: 'ck-bookmark'
|
|
131
|
-
}, [this._createBookmarkUIElement(writer)]);
|
|
132
|
-
writer.setCustomProperty('bookmark', true, containerElement);
|
|
133
|
-
this._bookmarkElements.set(modelElement, id);
|
|
134
|
-
// `getFillerOffset` is not needed to set here, because `toWidget` has already covered it.
|
|
135
|
-
const labelCreator = () => `${id} ${t('bookmark widget')}`;
|
|
136
|
-
return toWidget(containerElement, writer, { label: labelCreator });
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
conversion.for('upcast').add(dispatcher => dispatcher.on('element:a', dataViewModelAnchorInsertion(editor)));
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Creates a UI element for the `bookmark` representation in editing view.
|
|
143
|
-
*/
|
|
144
|
-
_createBookmarkUIElement(writer) {
|
|
145
|
-
return writer.createUIElement('span', { class: 'ck-bookmark__icon' }, function (domDocument) {
|
|
146
|
-
const domElement = this.toDomElement(domDocument);
|
|
147
|
-
const icon = new IconView();
|
|
148
|
-
icon.set({
|
|
149
|
-
content: IconBookmarkInline,
|
|
150
|
-
isColorInherited: false
|
|
151
|
-
});
|
|
152
|
-
icon.render();
|
|
153
|
-
domElement.appendChild(icon.element);
|
|
154
|
-
return domElement;
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Tracking the added or removed bookmark elements.
|
|
159
|
-
*/
|
|
160
|
-
_trackBookmarkElements() {
|
|
161
|
-
this._bookmarkElements.forEach((id, element) => {
|
|
162
|
-
if (element.root.rootName === '$graveyard') {
|
|
163
|
-
this._bookmarkElements.delete(element);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* A helper function to match an `anchor` element which must contain `id` or `name` attribute but without `href` attribute,
|
|
170
|
-
* also when `expectEmpty` is set to `true` but the element is not empty matcher should not match any element.
|
|
171
|
-
*
|
|
172
|
-
* @param element The element to be checked.
|
|
173
|
-
* @param expectEmpty Default set to `true`, when set to `false` matcher expects that `anchor` is not empty;
|
|
174
|
-
* in editing pipeline it's not empty because it contains the `UIElement`.
|
|
175
|
-
*/
|
|
176
|
-
function upcastMatcher(element, expectEmpty = true) {
|
|
177
|
-
const isAnchorElement = element.name === 'a';
|
|
178
|
-
if (!isAnchorElement) {
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
if (expectEmpty && !element.isEmpty) {
|
|
182
|
-
return null;
|
|
183
|
-
}
|
|
184
|
-
const hasIdAttribute = element.hasAttribute('id');
|
|
185
|
-
const hasNameAttribute = element.hasAttribute('name');
|
|
186
|
-
const hasHrefAttribute = element.hasAttribute('href');
|
|
187
|
-
if (hasIdAttribute && !hasHrefAttribute) {
|
|
188
|
-
return { name: true, attributes: ['id'] };
|
|
189
|
-
}
|
|
190
|
-
if (hasNameAttribute && !hasHrefAttribute) {
|
|
191
|
-
return { name: true, attributes: ['name'] };
|
|
192
|
-
}
|
|
193
|
-
return null;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* A view-to-model converter that handles converting pointed or wrapped anchors with `id` and/or `name` attributes.
|
|
197
|
-
*
|
|
198
|
-
* @returns Returns a conversion callback.
|
|
199
|
-
*/
|
|
200
|
-
function dataViewModelAnchorInsertion(editor) {
|
|
201
|
-
return (evt, data, conversionApi) => {
|
|
202
|
-
const viewItem = data.viewItem;
|
|
203
|
-
const match = upcastMatcher(viewItem, false);
|
|
204
|
-
if (!match || !conversionApi.consumable.test(viewItem, match)) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
const enableNonEmptyAnchorConversion = isEnabledNonEmptyAnchorConversion(editor);
|
|
208
|
-
if (!enableNonEmptyAnchorConversion && !viewItem.isEmpty) {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
const modelWriter = conversionApi.writer;
|
|
212
|
-
const anchorId = viewItem.getAttribute('id');
|
|
213
|
-
const anchorName = viewItem.getAttribute('name');
|
|
214
|
-
const bookmarkId = anchorId || anchorName;
|
|
215
|
-
const bookmark = modelWriter.createElement('bookmark', { bookmarkId });
|
|
216
|
-
if (!conversionApi.safeInsert(bookmark, data.modelCursor)) {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
conversionApi.consumable.consume(viewItem, match);
|
|
220
|
-
if (anchorId === anchorName) {
|
|
221
|
-
conversionApi.consumable.consume(viewItem, { attributes: ['name'] });
|
|
222
|
-
}
|
|
223
|
-
conversionApi.updateConversionResult(bookmark, data);
|
|
224
|
-
// Convert children uses the result of `bookmark` insertion to convert the `anchor` content
|
|
225
|
-
// after the bookmark element (not inside it).
|
|
226
|
-
const { modelCursor, modelRange } = conversionApi.convertChildren(viewItem, data.modelCursor);
|
|
227
|
-
data.modelCursor = modelCursor;
|
|
228
|
-
data.modelRange = modelWriter.createRange(data.modelRange.start, modelRange.end);
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Normalize the bookmark configuration option `enableNonEmptyAnchorConversion`.
|
|
233
|
-
*/
|
|
234
|
-
function isEnabledNonEmptyAnchorConversion(editor) {
|
|
235
|
-
const enableNonEmptyAnchorConversion = editor.config.get('bookmark.enableNonEmptyAnchorConversion');
|
|
236
|
-
// When not defined, option `enableNonEmptyAnchorConversion` by default is set to `true`.
|
|
237
|
-
return enableNonEmptyAnchorConversion !== undefined ? enableNonEmptyAnchorConversion : true;
|
|
238
|
-
}
|