@ckeditor/ckeditor5-bookmark 0.0.1 → 44.0.0-alpha.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 +4 -5
- package/README.md +31 -3
- package/build/bookmark.js +5 -0
- package/build/translations/af.js +1 -0
- package/build/translations/ar.js +1 -0
- package/build/translations/ast.js +1 -0
- package/build/translations/az.js +1 -0
- package/build/translations/bg.js +1 -0
- package/build/translations/bn.js +1 -0
- package/build/translations/bs.js +1 -0
- package/build/translations/ca.js +1 -0
- package/build/translations/cs.js +1 -0
- package/build/translations/da.js +1 -0
- package/build/translations/de-ch.js +1 -0
- package/build/translations/de.js +1 -0
- package/build/translations/el.js +1 -0
- package/build/translations/en-au.js +1 -0
- package/build/translations/en-gb.js +1 -0
- package/build/translations/eo.js +1 -0
- package/build/translations/es-co.js +1 -0
- package/build/translations/es.js +1 -0
- package/build/translations/et.js +1 -0
- package/build/translations/eu.js +1 -0
- package/build/translations/fa.js +1 -0
- package/build/translations/fi.js +1 -0
- package/build/translations/fr.js +1 -0
- package/build/translations/gl.js +1 -0
- package/build/translations/gu.js +1 -0
- package/build/translations/he.js +1 -0
- package/build/translations/hi.js +1 -0
- package/build/translations/hr.js +1 -0
- package/build/translations/hu.js +1 -0
- package/build/translations/hy.js +1 -0
- package/build/translations/id.js +1 -0
- package/build/translations/it.js +1 -0
- package/build/translations/ja.js +1 -0
- package/build/translations/jv.js +1 -0
- package/build/translations/kk.js +1 -0
- package/build/translations/km.js +1 -0
- package/build/translations/kn.js +1 -0
- package/build/translations/ko.js +1 -0
- package/build/translations/ku.js +1 -0
- package/build/translations/lt.js +1 -0
- package/build/translations/lv.js +1 -0
- package/build/translations/ms.js +1 -0
- package/build/translations/nb.js +1 -0
- package/build/translations/ne.js +1 -0
- package/build/translations/nl.js +1 -0
- package/build/translations/no.js +1 -0
- package/build/translations/oc.js +1 -0
- package/build/translations/pl.js +1 -0
- package/build/translations/pt-br.js +1 -0
- package/build/translations/pt.js +1 -0
- package/build/translations/ro.js +1 -0
- package/build/translations/ru.js +1 -0
- package/build/translations/si.js +1 -0
- package/build/translations/sk.js +1 -0
- package/build/translations/sl.js +1 -0
- package/build/translations/sq.js +1 -0
- package/build/translations/sr-latn.js +1 -0
- package/build/translations/sr.js +1 -0
- package/build/translations/sv.js +1 -0
- package/build/translations/th.js +1 -0
- package/build/translations/ti.js +1 -0
- package/build/translations/tk.js +1 -0
- package/build/translations/tr.js +1 -0
- package/build/translations/tt.js +1 -0
- package/build/translations/ug.js +1 -0
- package/build/translations/uk.js +1 -0
- package/build/translations/ur.js +1 -0
- package/build/translations/uz.js +1 -0
- package/build/translations/vi.js +1 -0
- package/build/translations/zh-cn.js +1 -0
- package/build/translations/zh.js +1 -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 +1320 -0
- package/dist/index.js.map +1 -0
- package/dist/insertbookmarkcommand.d.ts +42 -0
- package/dist/translations/af.d.ts +8 -0
- package/dist/translations/af.js +5 -0
- package/dist/translations/af.umd.js +11 -0
- package/dist/translations/ar.d.ts +8 -0
- package/dist/translations/ar.js +5 -0
- package/dist/translations/ar.umd.js +11 -0
- package/dist/translations/ast.d.ts +8 -0
- package/dist/translations/ast.js +5 -0
- package/dist/translations/ast.umd.js +11 -0
- package/dist/translations/az.d.ts +8 -0
- package/dist/translations/az.js +5 -0
- package/dist/translations/az.umd.js +11 -0
- package/dist/translations/bg.d.ts +8 -0
- package/dist/translations/bg.js +5 -0
- package/dist/translations/bg.umd.js +11 -0
- package/dist/translations/bn.d.ts +8 -0
- package/dist/translations/bn.js +5 -0
- package/dist/translations/bn.umd.js +11 -0
- package/dist/translations/bs.d.ts +8 -0
- package/dist/translations/bs.js +5 -0
- package/dist/translations/bs.umd.js +11 -0
- package/dist/translations/ca.d.ts +8 -0
- package/dist/translations/ca.js +5 -0
- package/dist/translations/ca.umd.js +11 -0
- package/dist/translations/cs.d.ts +8 -0
- package/dist/translations/cs.js +5 -0
- package/dist/translations/cs.umd.js +11 -0
- package/dist/translations/da.d.ts +8 -0
- package/dist/translations/da.js +5 -0
- package/dist/translations/da.umd.js +11 -0
- package/dist/translations/de-ch.d.ts +8 -0
- package/dist/translations/de-ch.js +5 -0
- package/dist/translations/de-ch.umd.js +11 -0
- package/dist/translations/de.d.ts +8 -0
- package/dist/translations/de.js +5 -0
- package/dist/translations/de.umd.js +11 -0
- package/dist/translations/el.d.ts +8 -0
- package/dist/translations/el.js +5 -0
- package/dist/translations/el.umd.js +11 -0
- package/dist/translations/en-au.d.ts +8 -0
- package/dist/translations/en-au.js +5 -0
- package/dist/translations/en-au.umd.js +11 -0
- package/dist/translations/en-gb.d.ts +8 -0
- package/dist/translations/en-gb.js +5 -0
- package/dist/translations/en-gb.umd.js +11 -0
- package/dist/translations/en.d.ts +8 -0
- package/dist/translations/en.js +5 -0
- package/dist/translations/en.umd.js +11 -0
- package/dist/translations/eo.d.ts +8 -0
- package/dist/translations/eo.js +5 -0
- package/dist/translations/eo.umd.js +11 -0
- package/dist/translations/es-co.d.ts +8 -0
- package/dist/translations/es-co.js +5 -0
- package/dist/translations/es-co.umd.js +11 -0
- package/dist/translations/es.d.ts +8 -0
- package/dist/translations/es.js +5 -0
- package/dist/translations/es.umd.js +11 -0
- package/dist/translations/et.d.ts +8 -0
- package/dist/translations/et.js +5 -0
- package/dist/translations/et.umd.js +11 -0
- package/dist/translations/eu.d.ts +8 -0
- package/dist/translations/eu.js +5 -0
- package/dist/translations/eu.umd.js +11 -0
- package/dist/translations/fa.d.ts +8 -0
- package/dist/translations/fa.js +5 -0
- package/dist/translations/fa.umd.js +11 -0
- package/dist/translations/fi.d.ts +8 -0
- package/dist/translations/fi.js +5 -0
- package/dist/translations/fi.umd.js +11 -0
- package/dist/translations/fr.d.ts +8 -0
- package/dist/translations/fr.js +5 -0
- package/dist/translations/fr.umd.js +11 -0
- package/dist/translations/gl.d.ts +8 -0
- package/dist/translations/gl.js +5 -0
- package/dist/translations/gl.umd.js +11 -0
- package/dist/translations/gu.d.ts +8 -0
- package/dist/translations/gu.js +5 -0
- package/dist/translations/gu.umd.js +11 -0
- package/dist/translations/he.d.ts +8 -0
- package/dist/translations/he.js +5 -0
- package/dist/translations/he.umd.js +11 -0
- package/dist/translations/hi.d.ts +8 -0
- package/dist/translations/hi.js +5 -0
- package/dist/translations/hi.umd.js +11 -0
- package/dist/translations/hr.d.ts +8 -0
- package/dist/translations/hr.js +5 -0
- package/dist/translations/hr.umd.js +11 -0
- package/dist/translations/hu.d.ts +8 -0
- package/dist/translations/hu.js +5 -0
- package/dist/translations/hu.umd.js +11 -0
- package/dist/translations/hy.d.ts +8 -0
- package/dist/translations/hy.js +5 -0
- package/dist/translations/hy.umd.js +11 -0
- package/dist/translations/id.d.ts +8 -0
- package/dist/translations/id.js +5 -0
- package/dist/translations/id.umd.js +11 -0
- package/dist/translations/it.d.ts +8 -0
- package/dist/translations/it.js +5 -0
- package/dist/translations/it.umd.js +11 -0
- package/dist/translations/ja.d.ts +8 -0
- package/dist/translations/ja.js +5 -0
- package/dist/translations/ja.umd.js +11 -0
- package/dist/translations/jv.d.ts +8 -0
- package/dist/translations/jv.js +5 -0
- package/dist/translations/jv.umd.js +11 -0
- package/dist/translations/kk.d.ts +8 -0
- package/dist/translations/kk.js +5 -0
- package/dist/translations/kk.umd.js +11 -0
- package/dist/translations/km.d.ts +8 -0
- package/dist/translations/km.js +5 -0
- package/dist/translations/km.umd.js +11 -0
- package/dist/translations/kn.d.ts +8 -0
- package/dist/translations/kn.js +5 -0
- package/dist/translations/kn.umd.js +11 -0
- package/dist/translations/ko.d.ts +8 -0
- package/dist/translations/ko.js +5 -0
- package/dist/translations/ko.umd.js +11 -0
- package/dist/translations/ku.d.ts +8 -0
- package/dist/translations/ku.js +5 -0
- package/dist/translations/ku.umd.js +11 -0
- package/dist/translations/lt.d.ts +8 -0
- package/dist/translations/lt.js +5 -0
- package/dist/translations/lt.umd.js +11 -0
- package/dist/translations/lv.d.ts +8 -0
- package/dist/translations/lv.js +5 -0
- package/dist/translations/lv.umd.js +11 -0
- package/dist/translations/ms.d.ts +8 -0
- package/dist/translations/ms.js +5 -0
- package/dist/translations/ms.umd.js +11 -0
- package/dist/translations/nb.d.ts +8 -0
- package/dist/translations/nb.js +5 -0
- package/dist/translations/nb.umd.js +11 -0
- package/dist/translations/ne.d.ts +8 -0
- package/dist/translations/ne.js +5 -0
- package/dist/translations/ne.umd.js +11 -0
- package/dist/translations/nl.d.ts +8 -0
- package/dist/translations/nl.js +5 -0
- package/dist/translations/nl.umd.js +11 -0
- package/dist/translations/no.d.ts +8 -0
- package/dist/translations/no.js +5 -0
- package/dist/translations/no.umd.js +11 -0
- package/dist/translations/oc.d.ts +8 -0
- package/dist/translations/oc.js +5 -0
- package/dist/translations/oc.umd.js +11 -0
- package/dist/translations/pl.d.ts +8 -0
- package/dist/translations/pl.js +5 -0
- package/dist/translations/pl.umd.js +11 -0
- package/dist/translations/pt-br.d.ts +8 -0
- package/dist/translations/pt-br.js +5 -0
- package/dist/translations/pt-br.umd.js +11 -0
- package/dist/translations/pt.d.ts +8 -0
- package/dist/translations/pt.js +5 -0
- package/dist/translations/pt.umd.js +11 -0
- package/dist/translations/ro.d.ts +8 -0
- package/dist/translations/ro.js +5 -0
- package/dist/translations/ro.umd.js +11 -0
- package/dist/translations/ru.d.ts +8 -0
- package/dist/translations/ru.js +5 -0
- package/dist/translations/ru.umd.js +11 -0
- package/dist/translations/si.d.ts +8 -0
- package/dist/translations/si.js +5 -0
- package/dist/translations/si.umd.js +11 -0
- package/dist/translations/sk.d.ts +8 -0
- package/dist/translations/sk.js +5 -0
- package/dist/translations/sk.umd.js +11 -0
- package/dist/translations/sl.d.ts +8 -0
- package/dist/translations/sl.js +5 -0
- package/dist/translations/sl.umd.js +11 -0
- package/dist/translations/sq.d.ts +8 -0
- package/dist/translations/sq.js +5 -0
- package/dist/translations/sq.umd.js +11 -0
- package/dist/translations/sr-latn.d.ts +8 -0
- package/dist/translations/sr-latn.js +5 -0
- package/dist/translations/sr-latn.umd.js +11 -0
- package/dist/translations/sr.d.ts +8 -0
- package/dist/translations/sr.js +5 -0
- package/dist/translations/sr.umd.js +11 -0
- package/dist/translations/sv.d.ts +8 -0
- package/dist/translations/sv.js +5 -0
- package/dist/translations/sv.umd.js +11 -0
- package/dist/translations/th.d.ts +8 -0
- package/dist/translations/th.js +5 -0
- package/dist/translations/th.umd.js +11 -0
- package/dist/translations/ti.d.ts +8 -0
- package/dist/translations/ti.js +5 -0
- package/dist/translations/ti.umd.js +11 -0
- package/dist/translations/tk.d.ts +8 -0
- package/dist/translations/tk.js +5 -0
- package/dist/translations/tk.umd.js +11 -0
- package/dist/translations/tr.d.ts +8 -0
- package/dist/translations/tr.js +5 -0
- package/dist/translations/tr.umd.js +11 -0
- package/dist/translations/tt.d.ts +8 -0
- package/dist/translations/tt.js +5 -0
- package/dist/translations/tt.umd.js +11 -0
- package/dist/translations/ug.d.ts +8 -0
- package/dist/translations/ug.js +5 -0
- package/dist/translations/ug.umd.js +11 -0
- package/dist/translations/uk.d.ts +8 -0
- package/dist/translations/uk.js +5 -0
- package/dist/translations/uk.umd.js +11 -0
- package/dist/translations/ur.d.ts +8 -0
- package/dist/translations/ur.js +5 -0
- package/dist/translations/ur.umd.js +11 -0
- package/dist/translations/uz.d.ts +8 -0
- package/dist/translations/uz.js +5 -0
- package/dist/translations/uz.umd.js +11 -0
- package/dist/translations/vi.d.ts +8 -0
- package/dist/translations/vi.js +5 -0
- package/dist/translations/vi.umd.js +11 -0
- package/dist/translations/zh-cn.d.ts +8 -0
- package/dist/translations/zh-cn.js +5 -0
- package/dist/translations/zh-cn.umd.js +11 -0
- package/dist/translations/zh.d.ts +8 -0
- package/dist/translations/zh.js +5 -0
- package/dist/translations/zh.umd.js +11 -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/lang/translations/af.po +56 -0
- package/lang/translations/ar.po +56 -0
- package/lang/translations/ast.po +56 -0
- package/lang/translations/az.po +56 -0
- package/lang/translations/bg.po +56 -0
- package/lang/translations/bn.po +56 -0
- package/lang/translations/bs.po +56 -0
- package/lang/translations/ca.po +56 -0
- package/lang/translations/cs.po +56 -0
- package/lang/translations/da.po +56 -0
- package/lang/translations/de-ch.po +56 -0
- package/lang/translations/de.po +56 -0
- package/lang/translations/el.po +56 -0
- package/lang/translations/en-au.po +56 -0
- package/lang/translations/en-gb.po +56 -0
- package/lang/translations/en.po +56 -0
- package/lang/translations/eo.po +56 -0
- package/lang/translations/es-co.po +56 -0
- package/lang/translations/es.po +56 -0
- package/lang/translations/et.po +56 -0
- package/lang/translations/eu.po +56 -0
- package/lang/translations/fa.po +56 -0
- package/lang/translations/fi.po +56 -0
- package/lang/translations/fr.po +56 -0
- package/lang/translations/gl.po +56 -0
- package/lang/translations/gu.po +56 -0
- package/lang/translations/he.po +56 -0
- package/lang/translations/hi.po +56 -0
- package/lang/translations/hr.po +56 -0
- package/lang/translations/hu.po +56 -0
- package/lang/translations/hy.po +56 -0
- package/lang/translations/id.po +56 -0
- package/lang/translations/it.po +56 -0
- package/lang/translations/ja.po +56 -0
- package/lang/translations/jv.po +56 -0
- package/lang/translations/kk.po +56 -0
- package/lang/translations/km.po +56 -0
- package/lang/translations/kn.po +56 -0
- package/lang/translations/ko.po +56 -0
- package/lang/translations/ku.po +56 -0
- package/lang/translations/lt.po +56 -0
- package/lang/translations/lv.po +56 -0
- package/lang/translations/ms.po +56 -0
- package/lang/translations/nb.po +56 -0
- package/lang/translations/ne.po +56 -0
- package/lang/translations/nl.po +56 -0
- package/lang/translations/no.po +56 -0
- package/lang/translations/oc.po +56 -0
- package/lang/translations/pl.po +56 -0
- package/lang/translations/pt-br.po +56 -0
- package/lang/translations/pt.po +56 -0
- package/lang/translations/ro.po +56 -0
- package/lang/translations/ru.po +56 -0
- package/lang/translations/si.po +56 -0
- package/lang/translations/sk.po +56 -0
- package/lang/translations/sl.po +56 -0
- package/lang/translations/sq.po +56 -0
- package/lang/translations/sr-latn.po +56 -0
- package/lang/translations/sr.po +56 -0
- package/lang/translations/sv.po +56 -0
- package/lang/translations/th.po +56 -0
- package/lang/translations/ti.po +56 -0
- package/lang/translations/tk.po +56 -0
- package/lang/translations/tr.po +56 -0
- package/lang/translations/tt.po +56 -0
- package/lang/translations/ug.po +56 -0
- package/lang/translations/uk.po +56 -0
- package/lang/translations/ur.po +56 -0
- package/lang/translations/uz.po +56 -0
- package/lang/translations/vi.po +56 -0
- package/lang/translations/zh-cn.po +56 -0
- package/lang/translations/zh.po +56 -0
- package/package.json +32 -3
- 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 +211 -0
- package/src/bookmarkui.d.ts +166 -0
- package/src/bookmarkui.js +582 -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
|
+
* @module bookmark/updatebookmarkcommand
|
7
|
+
*/
|
8
|
+
import { Command } from 'ckeditor5/src/core.js';
|
9
|
+
/**
|
10
|
+
* The update bookmark command.
|
11
|
+
*
|
12
|
+
* The command is registered by {@link module:bookmark/bookmarkediting~BookmarkEditing} as `'updateBookmark'`.
|
13
|
+
*
|
14
|
+
* To update the `bookmarkId` of current selected bookmark element, execute the command passing the bookmark id as a parameter:
|
15
|
+
*
|
16
|
+
* ```ts
|
17
|
+
* editor.execute( 'updateBookmark', { bookmarkId: 'newId' } );
|
18
|
+
* ```
|
19
|
+
*/
|
20
|
+
export default class UpdateBookmarkCommand extends Command {
|
21
|
+
/**
|
22
|
+
* The value of the `'bookmarkId'` attribute.
|
23
|
+
*
|
24
|
+
* @observable
|
25
|
+
* @readonly
|
26
|
+
*/
|
27
|
+
value: string | undefined;
|
28
|
+
/**
|
29
|
+
* @inheritDoc
|
30
|
+
*/
|
31
|
+
refresh(): void;
|
32
|
+
/**
|
33
|
+
* Executes the command.
|
34
|
+
*
|
35
|
+
* @fires execute
|
36
|
+
* @param options Command options.
|
37
|
+
* @param options.bookmarkId The new value of the `bookmarkId` attribute to set.
|
38
|
+
*/
|
39
|
+
execute(options: {
|
40
|
+
bookmarkId: string;
|
41
|
+
}): void;
|
42
|
+
}
|
@@ -0,0 +1,75 @@
|
|
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/updatebookmarkcommand
|
7
|
+
*/
|
8
|
+
import { Command } from 'ckeditor5/src/core.js';
|
9
|
+
import { logWarning } from 'ckeditor5/src/utils.js';
|
10
|
+
import { isBookmarkIdValid } from './utils.js';
|
11
|
+
/**
|
12
|
+
* The update bookmark command.
|
13
|
+
*
|
14
|
+
* The command is registered by {@link module:bookmark/bookmarkediting~BookmarkEditing} as `'updateBookmark'`.
|
15
|
+
*
|
16
|
+
* To update the `bookmarkId` of current selected bookmark element, execute the command passing the bookmark id as a parameter:
|
17
|
+
*
|
18
|
+
* ```ts
|
19
|
+
* editor.execute( 'updateBookmark', { bookmarkId: 'newId' } );
|
20
|
+
* ```
|
21
|
+
*/
|
22
|
+
export default class UpdateBookmarkCommand extends Command {
|
23
|
+
/**
|
24
|
+
* @inheritDoc
|
25
|
+
*/
|
26
|
+
refresh() {
|
27
|
+
const model = this.editor.model;
|
28
|
+
const selection = model.document.selection;
|
29
|
+
const selectedBookmark = getSelectedBookmark(selection);
|
30
|
+
this.isEnabled = !!selectedBookmark;
|
31
|
+
this.value = selectedBookmark ? selectedBookmark.getAttribute('bookmarkId') : undefined;
|
32
|
+
}
|
33
|
+
/**
|
34
|
+
* Executes the command.
|
35
|
+
*
|
36
|
+
* @fires execute
|
37
|
+
* @param options Command options.
|
38
|
+
* @param options.bookmarkId The new value of the `bookmarkId` attribute to set.
|
39
|
+
*/
|
40
|
+
execute(options) {
|
41
|
+
if (!options) {
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
const { bookmarkId } = options;
|
45
|
+
if (!isBookmarkIdValid(bookmarkId)) {
|
46
|
+
/**
|
47
|
+
* Update bookmark command can be executed only with a valid name.
|
48
|
+
*
|
49
|
+
* A valid bookmark name must be a non-empty string and must not contain any spaces.
|
50
|
+
*
|
51
|
+
* @error update-bookmark-command-executed-with-invalid-name
|
52
|
+
*/
|
53
|
+
logWarning('update-bookmark-command-executed-with-invalid-name');
|
54
|
+
return;
|
55
|
+
}
|
56
|
+
const model = this.editor.model;
|
57
|
+
const selection = model.document.selection;
|
58
|
+
const selectedBookmark = getSelectedBookmark(selection);
|
59
|
+
if (selectedBookmark) {
|
60
|
+
model.change(writer => {
|
61
|
+
writer.setAttribute('bookmarkId', bookmarkId, selectedBookmark);
|
62
|
+
});
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
/**
|
67
|
+
* Returns the selected `bookmark` element in the model, if any.
|
68
|
+
*/
|
69
|
+
function getSelectedBookmark(selection) {
|
70
|
+
const element = selection.getSelectedElement();
|
71
|
+
if (!!element && element.is('element', 'bookmark')) {
|
72
|
+
return element;
|
73
|
+
}
|
74
|
+
return null;
|
75
|
+
}
|
package/src/utils.d.ts
ADDED
@@ -0,0 +1,11 @@
|
|
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/utils
|
7
|
+
*/
|
8
|
+
/**
|
9
|
+
* Returns `true` if the bookmark id is valid; otherwise, returns `false`.
|
10
|
+
*/
|
11
|
+
export declare function isBookmarkIdValid(id: string): boolean;
|
package/src/utils.js
ADDED
@@ -0,0 +1,19 @@
|
|
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/utils
|
7
|
+
*/
|
8
|
+
/**
|
9
|
+
* Returns `true` if the bookmark id is valid; otherwise, returns `false`.
|
10
|
+
*/
|
11
|
+
export function isBookmarkIdValid(id) {
|
12
|
+
if (!id || typeof id !== 'string') {
|
13
|
+
return false;
|
14
|
+
}
|
15
|
+
if (/\s/.test(id)) {
|
16
|
+
return false;
|
17
|
+
}
|
18
|
+
return true;
|
19
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
/*
|
2
|
+
* 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
|
+
:root {
|
7
|
+
--ck-bookmark-icon-hover-fill-color: var(--ck-color-widget-hover-border);
|
8
|
+
--ck-bookmark-icon-selected-fill-color: var(--ck-color-focus-border);
|
9
|
+
--ck-bookmark-icon-animation-duration: var(--ck-widget-handler-animation-duration);
|
10
|
+
--ck-bookmark-icon-animation-curve: var(--ck-widget-handler-animation-curve);
|
11
|
+
}
|
12
|
+
|
13
|
+
.ck-bookmark {
|
14
|
+
&.ck-widget {
|
15
|
+
outline: none;
|
16
|
+
|
17
|
+
& .ck-bookmark__icon .ck-icon__fill {
|
18
|
+
transition: fill var(--ck-bookmark-icon-animation-duration) var(--ck-bookmark-icon-animation-curve);
|
19
|
+
}
|
20
|
+
|
21
|
+
&:hover {
|
22
|
+
& .ck-bookmark__icon .ck-icon__fill {
|
23
|
+
fill: var(--ck-bookmark-icon-hover-fill-color);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
&.ck-widget_selected {
|
28
|
+
.ck-bookmark__icon .ck-icon__fill {
|
29
|
+
fill: var(--ck-bookmark-icon-selected-fill-color);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
&.ck-widget_selected,
|
34
|
+
&.ck-widget_selected:hover {
|
35
|
+
outline: none;
|
36
|
+
}
|
37
|
+
|
38
|
+
& .ck-bookmark__icon {
|
39
|
+
position: relative;
|
40
|
+
/* To make it align with text baseline. */
|
41
|
+
top: -0.1em;
|
42
|
+
|
43
|
+
& .ck-icon {
|
44
|
+
height: 1.2em;
|
45
|
+
width: auto;
|
46
|
+
vertical-align: middle;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/*
|
2
|
+
* 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
|
+
@import "@ckeditor/ckeditor5-ui/theme/mixins/_rwd.css";
|
7
|
+
@import "@ckeditor/ckeditor5-ui/theme/mixins/_unselectable.css";
|
8
|
+
|
9
|
+
.ck.ck-bookmark-actions {
|
10
|
+
display: flex;
|
11
|
+
align-items: center;
|
12
|
+
|
13
|
+
& .ck-bookmark-actions__preview {
|
14
|
+
max-width: var(--ck-input-width);
|
15
|
+
min-width: 3em;
|
16
|
+
font-weight: normal;
|
17
|
+
text-overflow: ellipsis;
|
18
|
+
text-align: center;
|
19
|
+
overflow: hidden;
|
20
|
+
|
21
|
+
@mixin ck-unselectable;
|
22
|
+
cursor: default;
|
23
|
+
}
|
24
|
+
|
25
|
+
@mixin ck-media-phone {
|
26
|
+
display: flex;
|
27
|
+
flex-wrap: wrap;
|
28
|
+
|
29
|
+
& .ck-bookmark-actions__preview {
|
30
|
+
flex-basis: 100%;
|
31
|
+
margin: var(--ck-spacing-standard) var(--ck-spacing-standard) 0;
|
32
|
+
min-width: auto;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
&.ck-responsive-form {
|
37
|
+
& .ck-button {
|
38
|
+
@mixin ck-media-phone {
|
39
|
+
flex-basis: 50%;
|
40
|
+
margin-top: var(--ck-spacing-standard);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
/*
|
2
|
+
* 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
|
+
@import "@ckeditor/ckeditor5-ui/theme/mixins/_rwd.css";
|
7
|
+
|
8
|
+
.ck.ck-bookmark-view {
|
9
|
+
&:focus {
|
10
|
+
outline: none;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
.ck.ck-bookmark-form {
|
15
|
+
display: flex;
|
16
|
+
align-items: flex-start;
|
17
|
+
|
18
|
+
@mixin ck-media-phone {
|
19
|
+
flex-wrap: wrap;
|
20
|
+
|
21
|
+
& .ck-button,
|
22
|
+
& .ck-labeled-field-view {
|
23
|
+
flex-basis: 100%;
|
24
|
+
}
|
25
|
+
|
26
|
+
& .ck-button {
|
27
|
+
justify-content: center;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
&.ck-responsive-form {
|
32
|
+
& > .ck-button {
|
33
|
+
@mixin ck-media-phone {
|
34
|
+
&:nth-last-child(1) {
|
35
|
+
margin: var(--ck-spacing-large);
|
36
|
+
padding: 0 var(--ck-spacing-standard);
|
37
|
+
border-radius: var(--ck-border-radius);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|