@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
@@ -0,0 +1,42 @@
|
|
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 { Command } from 'ckeditor5/src/core.js';
|
10
|
+
/**
|
11
|
+
* The insert bookmark command.
|
12
|
+
*
|
13
|
+
* The command is registered by {@link module:bookmark/bookmarkediting~BookmarkEditing} as `'insertBookmark'`.
|
14
|
+
*
|
15
|
+
* To insert a bookmark element at place where is the current collapsed selection or where is the beginning of document selection,
|
16
|
+
* execute the command passing the bookmark id as a parameter:
|
17
|
+
*
|
18
|
+
* ```ts
|
19
|
+
* editor.execute( 'insertBookmark', { bookmarkId: 'foo_bar' } );
|
20
|
+
* ```
|
21
|
+
*/
|
22
|
+
export default class InsertBookmarkCommand extends Command {
|
23
|
+
/**
|
24
|
+
* @inheritDoc
|
25
|
+
*/
|
26
|
+
refresh(): void;
|
27
|
+
/**
|
28
|
+
* Executes the command.
|
29
|
+
*
|
30
|
+
* @fires execute
|
31
|
+
* @param options Command options.
|
32
|
+
* @param options.bookmarkId The value of the `bookmarkId` attribute.
|
33
|
+
*/
|
34
|
+
execute(options: {
|
35
|
+
bookmarkId: string;
|
36
|
+
}): void;
|
37
|
+
/**
|
38
|
+
* Returns the position where the bookmark can be inserted. And if it is not possible to insert a bookmark,
|
39
|
+
* check if it is possible to insert a paragraph.
|
40
|
+
*/
|
41
|
+
private _getPositionToInsertBookmark;
|
42
|
+
}
|
@@ -0,0 +1,106 @@
|
|
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/ui/bookmarkactionsview
|
11
|
+
*/
|
12
|
+
import { LabelView, ButtonView, View } from 'ckeditor5/src/ui.js';
|
13
|
+
import { FocusTracker, KeystrokeHandler, type LocaleTranslate, type Locale } from 'ckeditor5/src/utils.js';
|
14
|
+
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
15
|
+
import '../../theme/bookmarkactions.css';
|
16
|
+
/**
|
17
|
+
* The bookmark actions view class. This view displays the bookmark preview, allows
|
18
|
+
* removing or editing the bookmark.
|
19
|
+
*/
|
20
|
+
export default class BookmarkActionsView extends View {
|
21
|
+
/**
|
22
|
+
* Tracks information about DOM focus in the actions.
|
23
|
+
*/
|
24
|
+
readonly focusTracker: FocusTracker;
|
25
|
+
/**
|
26
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
27
|
+
*/
|
28
|
+
readonly keystrokes: KeystrokeHandler;
|
29
|
+
/**
|
30
|
+
* The bookmark preview view.
|
31
|
+
*/
|
32
|
+
bookmarkPreviewView: LabelView;
|
33
|
+
/**
|
34
|
+
* The remove button view.
|
35
|
+
*/
|
36
|
+
removeButtonView: ButtonView;
|
37
|
+
/**
|
38
|
+
* The edit bookmark button view.
|
39
|
+
*/
|
40
|
+
editButtonView: ButtonView;
|
41
|
+
/**
|
42
|
+
* The id preview view.
|
43
|
+
*
|
44
|
+
* @observable
|
45
|
+
*/
|
46
|
+
id: string | undefined;
|
47
|
+
/**
|
48
|
+
* A collection of views that can be focused in the view.
|
49
|
+
*/
|
50
|
+
private readonly _focusables;
|
51
|
+
/**
|
52
|
+
* Helps cycling over {@link #_focusables} in the view.
|
53
|
+
*/
|
54
|
+
private readonly _focusCycler;
|
55
|
+
t: LocaleTranslate;
|
56
|
+
/**
|
57
|
+
* @inheritDoc
|
58
|
+
*/
|
59
|
+
constructor(locale: Locale);
|
60
|
+
/**
|
61
|
+
* @inheritDoc
|
62
|
+
*/
|
63
|
+
render(): void;
|
64
|
+
/**
|
65
|
+
* @inheritDoc
|
66
|
+
*/
|
67
|
+
destroy(): void;
|
68
|
+
/**
|
69
|
+
* Focuses the fist {@link #_focusables} in the actions.
|
70
|
+
*/
|
71
|
+
focus(): void;
|
72
|
+
/**
|
73
|
+
* Creates a button view.
|
74
|
+
*
|
75
|
+
* @param label The button label.
|
76
|
+
* @param icon The button icon.
|
77
|
+
* @param eventName An event name that the `ButtonView#execute` event will be delegated to.
|
78
|
+
* @param additionalLabel An additional label outside the button.
|
79
|
+
* @returns The button view instance.
|
80
|
+
*/
|
81
|
+
private _createButton;
|
82
|
+
/**
|
83
|
+
* Creates a bookmark name preview label.
|
84
|
+
*
|
85
|
+
* @returns The label view instance.
|
86
|
+
*/
|
87
|
+
private _createBookmarkPreviewView;
|
88
|
+
}
|
89
|
+
/**
|
90
|
+
* Fired when the {@link ~BookmarkActionsView#editButtonView} is clicked.
|
91
|
+
*
|
92
|
+
* @eventName ~BookmarkActionsView#edit
|
93
|
+
*/
|
94
|
+
export type EditEvent = {
|
95
|
+
name: 'edit';
|
96
|
+
args: [];
|
97
|
+
};
|
98
|
+
/**
|
99
|
+
* Fired when the {@link ~BookmarkActionsView#removeButtonView} is clicked.
|
100
|
+
*
|
101
|
+
* @eventName ~BookmarkActionsView#remove
|
102
|
+
*/
|
103
|
+
export type RemoveEvent = {
|
104
|
+
name: 'remove';
|
105
|
+
args: [];
|
106
|
+
};
|
@@ -0,0 +1,122 @@
|
|
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/ui/bookmarkformview
|
11
|
+
*/
|
12
|
+
import { ButtonView, LabeledFieldView, View, ViewCollection, type InputTextView } from 'ckeditor5/src/ui.js';
|
13
|
+
import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils.js';
|
14
|
+
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
15
|
+
import '../../theme/bookmarkform.css';
|
16
|
+
/**
|
17
|
+
* The bookmark form view controller class.
|
18
|
+
*
|
19
|
+
* See {@link module:bookmark/ui/bookmarkformview~BookmarkFormView}.
|
20
|
+
*/
|
21
|
+
export default class BookmarkFormView extends View {
|
22
|
+
/**
|
23
|
+
* Tracks information about DOM focus in the form.
|
24
|
+
*/
|
25
|
+
readonly focusTracker: FocusTracker;
|
26
|
+
/**
|
27
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
28
|
+
*/
|
29
|
+
readonly keystrokes: KeystrokeHandler;
|
30
|
+
/**
|
31
|
+
* The ID input view.
|
32
|
+
*/
|
33
|
+
idInputView: LabeledFieldView<InputTextView>;
|
34
|
+
/**
|
35
|
+
* The Submit button view.
|
36
|
+
*/
|
37
|
+
buttonView: ButtonView;
|
38
|
+
/**
|
39
|
+
* A collection of form child views in the form.
|
40
|
+
*/
|
41
|
+
readonly children: ViewCollection;
|
42
|
+
/**
|
43
|
+
* An array of form validators used by {@link #isValid}.
|
44
|
+
*/
|
45
|
+
private readonly _validators;
|
46
|
+
/**
|
47
|
+
* A collection of views that can be focused in the form.
|
48
|
+
*/
|
49
|
+
private readonly _focusables;
|
50
|
+
/**
|
51
|
+
* Helps cycling over {@link #_focusables} in the form.
|
52
|
+
*/
|
53
|
+
private readonly _focusCycler;
|
54
|
+
/**
|
55
|
+
* Creates an instance of the {@link module:bookmark/ui/bookmarkformview~BookmarkFormView} class.
|
56
|
+
*
|
57
|
+
* Also see {@link #render}.
|
58
|
+
*
|
59
|
+
* @param locale The localization services instance.
|
60
|
+
* @param validators Form validators used by {@link #isValid}.
|
61
|
+
*/
|
62
|
+
constructor(locale: Locale, validators: Array<BookmarkFormValidatorCallback>);
|
63
|
+
/**
|
64
|
+
* @inheritDoc
|
65
|
+
*/
|
66
|
+
render(): void;
|
67
|
+
/**
|
68
|
+
* @inheritDoc
|
69
|
+
*/
|
70
|
+
destroy(): void;
|
71
|
+
/**
|
72
|
+
* Focuses the fist {@link #_focusables} in the form.
|
73
|
+
*/
|
74
|
+
focus(): void;
|
75
|
+
/**
|
76
|
+
* Validates the form and returns `false` when some fields are invalid.
|
77
|
+
*/
|
78
|
+
isValid(): boolean;
|
79
|
+
/**
|
80
|
+
* Cleans up the supplementary error and information text of the {@link #idInputView}
|
81
|
+
* bringing them back to the state when the form has been displayed for the first time.
|
82
|
+
*
|
83
|
+
* See {@link #isValid}.
|
84
|
+
*/
|
85
|
+
resetFormStatus(): void;
|
86
|
+
/**
|
87
|
+
* Creates header and form view.
|
88
|
+
*/
|
89
|
+
private _createViewChildren;
|
90
|
+
/**
|
91
|
+
* Creates form content view with input and button.
|
92
|
+
*/
|
93
|
+
private _createFormContentView;
|
94
|
+
/**
|
95
|
+
* Creates a labeled input view.
|
96
|
+
*
|
97
|
+
* @returns Labeled field view instance.
|
98
|
+
*/
|
99
|
+
private _createIdInput;
|
100
|
+
/**
|
101
|
+
* Creates a button view.
|
102
|
+
*
|
103
|
+
* @param label The button label.
|
104
|
+
* @param className The additional button CSS class name.
|
105
|
+
* @returns The button view instance.
|
106
|
+
*/
|
107
|
+
private _createButton;
|
108
|
+
/**
|
109
|
+
* The native DOM `value` of the {@link #idInputView} element.
|
110
|
+
*
|
111
|
+
* **Note**: Do not confuse it with the {@link module:ui/inputtext/inputtextview~InputTextView#value}
|
112
|
+
* which works one way only and may not represent the actual state of the component in the DOM.
|
113
|
+
*/
|
114
|
+
get id(): string | null;
|
115
|
+
}
|
116
|
+
/**
|
117
|
+
* Callback used by {@link ~BookmarkFormView} to check if passed form value is valid.
|
118
|
+
*
|
119
|
+
* If `undefined` is returned, it is assumed that the form value is correct and there is no error.
|
120
|
+
* If string is returned, it is assumed that the form value is incorrect and the returned string is displayed in the error label
|
121
|
+
*/
|
122
|
+
export type BookmarkFormValidatorCallback = (form: BookmarkFormView) => string | undefined;
|
@@ -0,0 +1,46 @@
|
|
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/updatebookmarkcommand
|
11
|
+
*/
|
12
|
+
import { Command } from 'ckeditor5/src/core.js';
|
13
|
+
/**
|
14
|
+
* The update bookmark command.
|
15
|
+
*
|
16
|
+
* The command is registered by {@link module:bookmark/bookmarkediting~BookmarkEditing} as `'updateBookmark'`.
|
17
|
+
*
|
18
|
+
* To update the `bookmarkId` of current selected bookmark element, execute the command passing the bookmark id as a parameter:
|
19
|
+
*
|
20
|
+
* ```ts
|
21
|
+
* editor.execute( 'updateBookmark', { bookmarkId: 'newId' } );
|
22
|
+
* ```
|
23
|
+
*/
|
24
|
+
export default class UpdateBookmarkCommand extends Command {
|
25
|
+
/**
|
26
|
+
* The value of the `'bookmarkId'` attribute.
|
27
|
+
*
|
28
|
+
* @observable
|
29
|
+
* @readonly
|
30
|
+
*/
|
31
|
+
value: string | undefined;
|
32
|
+
/**
|
33
|
+
* @inheritDoc
|
34
|
+
*/
|
35
|
+
refresh(): void;
|
36
|
+
/**
|
37
|
+
* Executes the command.
|
38
|
+
*
|
39
|
+
* @fires execute
|
40
|
+
* @param options Command options.
|
41
|
+
* @param options.bookmarkId The new value of the `bookmarkId` attribute to set.
|
42
|
+
*/
|
43
|
+
execute(options: {
|
44
|
+
bookmarkId: string;
|
45
|
+
}): void;
|
46
|
+
}
|
package/dist/utils.d.ts
ADDED
@@ -0,0 +1,15 @@
|
|
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/utils
|
11
|
+
*/
|
12
|
+
/**
|
13
|
+
* Returns `true` if the bookmark id is valid; otherwise, returns `false`.
|
14
|
+
*/
|
15
|
+
export declare function isBookmarkIdValid(id: string): boolean;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"Bookmark": "The label of the bookmark toolbar button. Also, a bookmark form header.",
|
3
|
+
"Insert": "The button in the bookmark insert form.",
|
4
|
+
"Update": "The button in the bookmark update form.",
|
5
|
+
"Edit bookmark": "Button opening the Bookmark editing balloon.",
|
6
|
+
"Remove bookmark": "Toolbar button tooltip for bookmark remove button.",
|
7
|
+
"Bookmark name": "The label of the input in the bookmark insert and update form. Also, the tooltip for the bookmark name in the bookmark preview.",
|
8
|
+
"Enter the bookmark name without spaces.": "The description of bookmark input in the bookmark insert form.",
|
9
|
+
"Bookmark must not be empty.": "The error message. Displayed when the bookmark name is empty.",
|
10
|
+
"Bookmark name cannot contain space characters.": "The error message. Displayed when provided name includes spaces.",
|
11
|
+
"Bookmark name already exists.": "The error message. Displayed when provided name already exists.",
|
12
|
+
"bookmark widget": "The label for the bookmark widget."
|
13
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
{
|
2
|
+
"name": "@ckeditor/ckeditor5-bookmark",
|
3
|
+
"version": "0.0.0-nightly-20241025.0",
|
4
|
+
"description": "Bookmark feature for CKEditor 5.",
|
5
|
+
"keywords": [
|
6
|
+
"ckeditor",
|
7
|
+
"ckeditor5",
|
8
|
+
"ckeditor 5",
|
9
|
+
"ckeditor5-feature",
|
10
|
+
"ckeditor5-plugin",
|
11
|
+
"ckeditor5-dll"
|
12
|
+
],
|
13
|
+
"type": "module",
|
14
|
+
"main": "src/index.js",
|
15
|
+
"dependencies": {
|
16
|
+
"ckeditor5": "0.0.0-nightly-20241025.0",
|
17
|
+
"@ckeditor/ckeditor5-core": "0.0.0-nightly-20241025.0",
|
18
|
+
"@ckeditor/ckeditor5-engine": "0.0.0-nightly-20241025.0",
|
19
|
+
"@ckeditor/ckeditor5-widget": "0.0.0-nightly-20241025.0",
|
20
|
+
"@ckeditor/ckeditor5-utils": "0.0.0-nightly-20241025.0",
|
21
|
+
"@ckeditor/ckeditor5-ui": "0.0.0-nightly-20241025.0"
|
22
|
+
},
|
23
|
+
"author": "CKSource (http://cksource.com/)",
|
24
|
+
"license": "GPL-2.0-or-later",
|
25
|
+
"homepage": "https://ckeditor.com/ckeditor-5",
|
26
|
+
"bugs": "https://github.com/ckeditor/ckeditor5/issues",
|
27
|
+
"repository": {
|
28
|
+
"type": "git",
|
29
|
+
"url": "https://github.com/ckeditor/ckeditor5.git",
|
30
|
+
"directory": "packages/ckeditor5-bookmark"
|
31
|
+
},
|
32
|
+
"files": [
|
33
|
+
"dist",
|
34
|
+
"lang",
|
35
|
+
"src/**/*.js",
|
36
|
+
"src/**/*.d.ts",
|
37
|
+
"theme",
|
38
|
+
"build",
|
39
|
+
"ckeditor5-metadata.json",
|
40
|
+
"CHANGELOG.md"
|
41
|
+
],
|
42
|
+
"types": "src/index.d.ts"
|
43
|
+
}
|
@@ -0,0 +1,24 @@
|
|
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
|
+
import type { Bookmark, BookmarkEditing, BookmarkUI, InsertBookmarkCommand, UpdateBookmarkCommand, BookmarkConfig } from './index.js';
|
6
|
+
declare module '@ckeditor/ckeditor5-core' {
|
7
|
+
interface EditorConfig {
|
8
|
+
/**
|
9
|
+
* The configuration of the {@link module:bookmark/bookmark~Bookmark} feature.
|
10
|
+
*
|
11
|
+
* Read more in {@link module:bookmark/bookmarkconfig~BookmarkConfig}.
|
12
|
+
*/
|
13
|
+
bookmark?: BookmarkConfig;
|
14
|
+
}
|
15
|
+
interface PluginsMap {
|
16
|
+
[Bookmark.pluginName]: Bookmark;
|
17
|
+
[BookmarkEditing.pluginName]: BookmarkEditing;
|
18
|
+
[BookmarkUI.pluginName]: BookmarkUI;
|
19
|
+
}
|
20
|
+
interface CommandsMap {
|
21
|
+
insertBookmark: InsertBookmarkCommand;
|
22
|
+
updateBookmark: UpdateBookmarkCommand;
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,30 @@
|
|
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
|
+
* @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 default class Bookmark extends Plugin {
|
18
|
+
/**
|
19
|
+
* @inheritDoc
|
20
|
+
*/
|
21
|
+
static get pluginName(): "Bookmark";
|
22
|
+
/**
|
23
|
+
* @inheritDoc
|
24
|
+
*/
|
25
|
+
static get requires(): readonly [typeof BookmarkEditing, typeof BookmarkUI, typeof Widget];
|
26
|
+
/**
|
27
|
+
* @inheritDoc
|
28
|
+
*/
|
29
|
+
static get isOfficialPlugin(): true;
|
30
|
+
}
|
package/src/bookmark.js
ADDED
@@ -0,0 +1,36 @@
|
|
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
|
+
* @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 default 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
|
+
}
|
@@ -0,0 +1,48 @@
|
|
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
|
+
* @module bookmark/bookmarkconfig
|
7
|
+
*/
|
8
|
+
/**
|
9
|
+
* The configuration of the bookmark feature.
|
10
|
+
*
|
11
|
+
* The properties defined in this config are set in the `config.bookmark` namespace.
|
12
|
+
*
|
13
|
+
* ```ts
|
14
|
+
* ClassicEditor
|
15
|
+
* .create( editorElement, {
|
16
|
+
* bookmark: {
|
17
|
+
* // Bookmark configuration.
|
18
|
+
* }
|
19
|
+
* } )
|
20
|
+
* .then( ... )
|
21
|
+
* .catch( ... );
|
22
|
+
* ```
|
23
|
+
*
|
24
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
25
|
+
*/
|
26
|
+
export interface BookmarkConfig {
|
27
|
+
/**
|
28
|
+
* Allows to convert into bookmarks non-empty anchor elements.
|
29
|
+
*
|
30
|
+
* With this option enabled you will have all non-empty anchors converted into bookmakrs.
|
31
|
+
* For example:
|
32
|
+
*
|
33
|
+
*```html
|
34
|
+
* <a id="bookmark">Bookmark</a>
|
35
|
+
*```
|
36
|
+
*
|
37
|
+
* will be converted into:
|
38
|
+
*
|
39
|
+
*```html
|
40
|
+
* <a id="bookmark"></a>Bookmark
|
41
|
+
*```
|
42
|
+
*
|
43
|
+
* **Note:** This is enabled by default.
|
44
|
+
*
|
45
|
+
* @default true
|
46
|
+
*/
|
47
|
+
enableNonEmptyAnchorConversion?: boolean;
|
48
|
+
}
|
@@ -0,0 +1,51 @@
|
|
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
|
+
* @module bookmark/bookmarkediting
|
7
|
+
*/
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
9
|
+
import type { Element } from 'ckeditor5/src/engine.js';
|
10
|
+
import '../theme/bookmark.css';
|
11
|
+
/**
|
12
|
+
* The bookmark editing plugin.
|
13
|
+
*/
|
14
|
+
export default class BookmarkEditing extends Plugin {
|
15
|
+
/**
|
16
|
+
* A collection of bookmarks elements in the document.
|
17
|
+
*/
|
18
|
+
private _bookmarkElements;
|
19
|
+
/**
|
20
|
+
* @inheritDoc
|
21
|
+
*/
|
22
|
+
static get pluginName(): "BookmarkEditing";
|
23
|
+
/**
|
24
|
+
* @inheritDoc
|
25
|
+
*/
|
26
|
+
static get isOfficialPlugin(): true;
|
27
|
+
/**
|
28
|
+
* @inheritDoc
|
29
|
+
*/
|
30
|
+
init(): void;
|
31
|
+
/**
|
32
|
+
* Returns the model element for the given bookmark ID if it exists.
|
33
|
+
*/
|
34
|
+
getElementForBookmarkId(bookmarkId: string): Element | null;
|
35
|
+
/**
|
36
|
+
* Defines the schema for the bookmark feature.
|
37
|
+
*/
|
38
|
+
private _defineSchema;
|
39
|
+
/**
|
40
|
+
* Defines the converters for the bookmark feature.
|
41
|
+
*/
|
42
|
+
private _defineConverters;
|
43
|
+
/**
|
44
|
+
* Creates a UI element for the `bookmark` representation in editing view.
|
45
|
+
*/
|
46
|
+
private _createBookmarkUIElement;
|
47
|
+
/**
|
48
|
+
* Tracking the added or removed bookmark elements.
|
49
|
+
*/
|
50
|
+
private _trackBookmarkElements;
|
51
|
+
}
|