@ckeditor/ckeditor5-bookmark 0.0.0-nightly-20260121.0 → 0.0.0-nightly-next-20260121.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}/bookmark.d.ts +2 -2
- package/{src → dist}/bookmarkediting.d.ts +2 -2
- package/{src → dist}/bookmarkui.d.ts +3 -3
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/{src → dist}/insertbookmarkcommand.d.ts +1 -1
- package/{src → dist}/ui/bookmarkformview.d.ts +2 -2
- package/{src → dist}/updatebookmarkcommand.d.ts +1 -1
- package/package.json +26 -48
- 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/lang/contexts.json +0 -15
- package/lang/translations/af.po +0 -64
- package/lang/translations/ar.po +0 -64
- package/lang/translations/ast.po +0 -64
- package/lang/translations/az.po +0 -64
- package/lang/translations/be.po +0 -64
- package/lang/translations/bg.po +0 -64
- package/lang/translations/bn.po +0 -64
- package/lang/translations/bs.po +0 -64
- package/lang/translations/ca.po +0 -64
- package/lang/translations/cs.po +0 -64
- package/lang/translations/da.po +0 -64
- package/lang/translations/de-ch.po +0 -64
- package/lang/translations/de.po +0 -64
- package/lang/translations/el.po +0 -64
- package/lang/translations/en-au.po +0 -64
- package/lang/translations/en-gb.po +0 -64
- package/lang/translations/en.po +0 -64
- package/lang/translations/eo.po +0 -64
- package/lang/translations/es-co.po +0 -64
- package/lang/translations/es.po +0 -64
- package/lang/translations/et.po +0 -64
- package/lang/translations/eu.po +0 -64
- package/lang/translations/fa.po +0 -64
- package/lang/translations/fi.po +0 -64
- package/lang/translations/fr.po +0 -64
- package/lang/translations/gl.po +0 -64
- package/lang/translations/gu.po +0 -64
- package/lang/translations/he.po +0 -64
- package/lang/translations/hi.po +0 -64
- package/lang/translations/hr.po +0 -64
- package/lang/translations/hu.po +0 -64
- package/lang/translations/hy.po +0 -64
- package/lang/translations/id.po +0 -64
- package/lang/translations/it.po +0 -64
- package/lang/translations/ja.po +0 -64
- package/lang/translations/jv.po +0 -64
- package/lang/translations/kk.po +0 -64
- package/lang/translations/km.po +0 -64
- package/lang/translations/kn.po +0 -64
- package/lang/translations/ko.po +0 -64
- package/lang/translations/ku.po +0 -64
- package/lang/translations/lt.po +0 -64
- package/lang/translations/lv.po +0 -64
- package/lang/translations/ms.po +0 -64
- package/lang/translations/nb.po +0 -64
- package/lang/translations/ne.po +0 -64
- package/lang/translations/nl.po +0 -64
- package/lang/translations/no.po +0 -64
- package/lang/translations/oc.po +0 -64
- package/lang/translations/pl.po +0 -64
- package/lang/translations/pt-br.po +0 -64
- package/lang/translations/pt.po +0 -64
- package/lang/translations/ro.po +0 -64
- package/lang/translations/ru.po +0 -64
- package/lang/translations/si.po +0 -64
- package/lang/translations/sk.po +0 -64
- package/lang/translations/sl.po +0 -64
- package/lang/translations/sq.po +0 -64
- package/lang/translations/sr-latn.po +0 -64
- package/lang/translations/sr.po +0 -64
- package/lang/translations/sv.po +0 -64
- package/lang/translations/th.po +0 -64
- package/lang/translations/ti.po +0 -64
- package/lang/translations/tk.po +0 -64
- package/lang/translations/tr.po +0 -64
- package/lang/translations/tt.po +0 -64
- package/lang/translations/ug.po +0 -64
- package/lang/translations/uk.po +0 -64
- package/lang/translations/ur.po +0 -64
- package/lang/translations/uz.po +0 -64
- package/lang/translations/vi.po +0 -64
- package/lang/translations/zh-cn.po +0 -64
- package/lang/translations/zh.po +0 -64
- 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/theme/bookmark.css +0 -4
- package/theme/bookmarkform.css +0 -4
- package/theme/bookmarktoolbar.css +0 -4
- /package/{src → dist}/augmentation.d.ts +0 -0
- /package/{src → dist}/bookmarkconfig.d.ts +0 -0
- /package/{src → dist}/index.d.ts +0 -0
- /package/{src → dist}/utils.d.ts +0 -0
package/lang/translations/vi.po
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: vi\n"
|
|
11
|
-
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "The label of the bookmark toolbar button. Also, a bookmark form header."
|
|
15
|
-
msgid "Bookmark"
|
|
16
|
-
msgstr "Dấu trang"
|
|
17
|
-
|
|
18
|
-
msgctxt "Button opening the Bookmark editing balloon."
|
|
19
|
-
msgid "Edit bookmark"
|
|
20
|
-
msgstr "Chỉnh sửa dấu trang"
|
|
21
|
-
|
|
22
|
-
msgctxt "Toolbar button tooltip for bookmark remove button."
|
|
23
|
-
msgid "Remove bookmark"
|
|
24
|
-
msgstr "Xóa dấu trang"
|
|
25
|
-
|
|
26
|
-
msgctxt "The label of the input in the bookmark insert and update form. Also, the tooltip for the bookmark name in the bookmark preview."
|
|
27
|
-
msgid "Bookmark name"
|
|
28
|
-
msgstr "Tên dấu trang"
|
|
29
|
-
|
|
30
|
-
msgctxt "The description of bookmark input in the bookmark insert form."
|
|
31
|
-
msgid "Enter the bookmark name without spaces."
|
|
32
|
-
msgstr "Nhập tên dấu trang không có khoảng trắng."
|
|
33
|
-
|
|
34
|
-
msgctxt "The error message. Displayed when the bookmark name is empty."
|
|
35
|
-
msgid "Bookmark must not be empty."
|
|
36
|
-
msgstr "Dấu trang không được để trống."
|
|
37
|
-
|
|
38
|
-
msgctxt "The error message. Displayed when provided name includes spaces."
|
|
39
|
-
msgid "Bookmark name cannot contain space characters."
|
|
40
|
-
msgstr "Tên dấu trang không được chứa ký tự khoảng trắng."
|
|
41
|
-
|
|
42
|
-
msgctxt "The error message. Displayed when provided name already exists."
|
|
43
|
-
msgid "Bookmark name already exists."
|
|
44
|
-
msgstr "Tên dấu trang đã tồn tại."
|
|
45
|
-
|
|
46
|
-
msgctxt "The label for the bookmark widget."
|
|
47
|
-
msgid "bookmark widget"
|
|
48
|
-
msgstr "tiện ích đánh dấu trang"
|
|
49
|
-
|
|
50
|
-
msgctxt "The label used by assistive technologies describing an bookmark toolbar attached to a bookmark widget."
|
|
51
|
-
msgid "Bookmark toolbar"
|
|
52
|
-
msgstr "Thanh công cụ Đánh dấu trang"
|
|
53
|
-
|
|
54
|
-
msgctxt "Title for a feature displaying a list of bookmarks."
|
|
55
|
-
msgid "Bookmarks"
|
|
56
|
-
msgstr "Dấu trang"
|
|
57
|
-
|
|
58
|
-
msgctxt "A message displayed instead of a list of bookmarks if it is empty."
|
|
59
|
-
msgid "No bookmarks available."
|
|
60
|
-
msgstr "Không có dấu trang khả dụng."
|
|
61
|
-
|
|
62
|
-
msgctxt "Tooltip shown after hovering the bookmark link preview."
|
|
63
|
-
msgid "Scroll to bookmark"
|
|
64
|
-
msgstr "Cuộn chuột đến dấu trang"
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: zh_CN\n"
|
|
11
|
-
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "The label of the bookmark toolbar button. Also, a bookmark form header."
|
|
15
|
-
msgid "Bookmark"
|
|
16
|
-
msgstr "书签"
|
|
17
|
-
|
|
18
|
-
msgctxt "Button opening the Bookmark editing balloon."
|
|
19
|
-
msgid "Edit bookmark"
|
|
20
|
-
msgstr "编辑书签"
|
|
21
|
-
|
|
22
|
-
msgctxt "Toolbar button tooltip for bookmark remove button."
|
|
23
|
-
msgid "Remove bookmark"
|
|
24
|
-
msgstr "删除书签"
|
|
25
|
-
|
|
26
|
-
msgctxt "The label of the input in the bookmark insert and update form. Also, the tooltip for the bookmark name in the bookmark preview."
|
|
27
|
-
msgid "Bookmark name"
|
|
28
|
-
msgstr "书签名称"
|
|
29
|
-
|
|
30
|
-
msgctxt "The description of bookmark input in the bookmark insert form."
|
|
31
|
-
msgid "Enter the bookmark name without spaces."
|
|
32
|
-
msgstr "输入书签名称,不带空格。"
|
|
33
|
-
|
|
34
|
-
msgctxt "The error message. Displayed when the bookmark name is empty."
|
|
35
|
-
msgid "Bookmark must not be empty."
|
|
36
|
-
msgstr "书签不能为空。"
|
|
37
|
-
|
|
38
|
-
msgctxt "The error message. Displayed when provided name includes spaces."
|
|
39
|
-
msgid "Bookmark name cannot contain space characters."
|
|
40
|
-
msgstr "书签名称不能包含空格。"
|
|
41
|
-
|
|
42
|
-
msgctxt "The error message. Displayed when provided name already exists."
|
|
43
|
-
msgid "Bookmark name already exists."
|
|
44
|
-
msgstr "书签名称已存在。"
|
|
45
|
-
|
|
46
|
-
msgctxt "The label for the bookmark widget."
|
|
47
|
-
msgid "bookmark widget"
|
|
48
|
-
msgstr "书签小组件"
|
|
49
|
-
|
|
50
|
-
msgctxt "The label used by assistive technologies describing an bookmark toolbar attached to a bookmark widget."
|
|
51
|
-
msgid "Bookmark toolbar"
|
|
52
|
-
msgstr "书签工具栏"
|
|
53
|
-
|
|
54
|
-
msgctxt "Title for a feature displaying a list of bookmarks."
|
|
55
|
-
msgid "Bookmarks"
|
|
56
|
-
msgstr "书签"
|
|
57
|
-
|
|
58
|
-
msgctxt "A message displayed instead of a list of bookmarks if it is empty."
|
|
59
|
-
msgid "No bookmarks available."
|
|
60
|
-
msgstr "无可用书签。"
|
|
61
|
-
|
|
62
|
-
msgctxt "Tooltip shown after hovering the bookmark link preview."
|
|
63
|
-
msgid "Scroll to bookmark"
|
|
64
|
-
msgstr "滚动到书签"
|
package/lang/translations/zh.po
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: zh_TW\n"
|
|
11
|
-
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "The label of the bookmark toolbar button. Also, a bookmark form header."
|
|
15
|
-
msgid "Bookmark"
|
|
16
|
-
msgstr "書籤"
|
|
17
|
-
|
|
18
|
-
msgctxt "Button opening the Bookmark editing balloon."
|
|
19
|
-
msgid "Edit bookmark"
|
|
20
|
-
msgstr "編輯書籤"
|
|
21
|
-
|
|
22
|
-
msgctxt "Toolbar button tooltip for bookmark remove button."
|
|
23
|
-
msgid "Remove bookmark"
|
|
24
|
-
msgstr "移除書籤"
|
|
25
|
-
|
|
26
|
-
msgctxt "The label of the input in the bookmark insert and update form. Also, the tooltip for the bookmark name in the bookmark preview."
|
|
27
|
-
msgid "Bookmark name"
|
|
28
|
-
msgstr "書籤名稱"
|
|
29
|
-
|
|
30
|
-
msgctxt "The description of bookmark input in the bookmark insert form."
|
|
31
|
-
msgid "Enter the bookmark name without spaces."
|
|
32
|
-
msgstr "輸入書籤名稱,請勿包含空格。"
|
|
33
|
-
|
|
34
|
-
msgctxt "The error message. Displayed when the bookmark name is empty."
|
|
35
|
-
msgid "Bookmark must not be empty."
|
|
36
|
-
msgstr "書籤名稱不得為空。"
|
|
37
|
-
|
|
38
|
-
msgctxt "The error message. Displayed when provided name includes spaces."
|
|
39
|
-
msgid "Bookmark name cannot contain space characters."
|
|
40
|
-
msgstr "書籤名稱不可包含空格字元。"
|
|
41
|
-
|
|
42
|
-
msgctxt "The error message. Displayed when provided name already exists."
|
|
43
|
-
msgid "Bookmark name already exists."
|
|
44
|
-
msgstr "書籤名稱已存在。"
|
|
45
|
-
|
|
46
|
-
msgctxt "The label for the bookmark widget."
|
|
47
|
-
msgid "bookmark widget"
|
|
48
|
-
msgstr "書籤小工具"
|
|
49
|
-
|
|
50
|
-
msgctxt "The label used by assistive technologies describing an bookmark toolbar attached to a bookmark widget."
|
|
51
|
-
msgid "Bookmark toolbar"
|
|
52
|
-
msgstr "書籤工具列"
|
|
53
|
-
|
|
54
|
-
msgctxt "Title for a feature displaying a list of bookmarks."
|
|
55
|
-
msgid "Bookmarks"
|
|
56
|
-
msgstr "書籤"
|
|
57
|
-
|
|
58
|
-
msgctxt "A message displayed instead of a list of bookmarks if it is empty."
|
|
59
|
-
msgid "No bookmarks available."
|
|
60
|
-
msgstr "無可用書籤。"
|
|
61
|
-
|
|
62
|
-
msgctxt "Tooltip shown after hovering the bookmark link preview."
|
|
63
|
-
msgid "Scroll to bookmark"
|
|
64
|
-
msgstr "捲動至書籤"
|
package/src/augmentation.js
DELETED
package/src/bookmark.js
DELETED
|
@@ -1,36 +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 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-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 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
|
-
}
|