@ckeditor/ckeditor5-page-break 39.0.1 → 40.0.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/LICENSE.md +1 -1
- package/README.md +3 -3
- package/build/page-break.js.map +1 -0
- package/lang/translations/ar.po +1 -0
- package/lang/translations/az.po +1 -0
- package/lang/translations/bg.po +1 -0
- package/lang/translations/bn.po +1 -0
- package/lang/translations/ca.po +1 -0
- package/lang/translations/cs.po +1 -0
- package/lang/translations/da.po +1 -0
- package/lang/translations/de-ch.po +1 -0
- package/lang/translations/de.po +1 -0
- package/lang/translations/el.po +1 -0
- package/lang/translations/en-au.po +1 -0
- package/lang/translations/en.po +1 -0
- package/lang/translations/es.po +1 -0
- package/lang/translations/et.po +1 -0
- package/lang/translations/fa.po +1 -0
- package/lang/translations/fi.po +1 -0
- package/lang/translations/fr.po +1 -0
- package/lang/translations/gl.po +1 -0
- package/lang/translations/he.po +1 -0
- package/lang/translations/hi.po +1 -0
- package/lang/translations/hr.po +1 -0
- package/lang/translations/hu.po +1 -0
- package/lang/translations/id.po +1 -0
- package/lang/translations/it.po +1 -0
- package/lang/translations/ja.po +1 -0
- package/lang/translations/ko.po +1 -0
- package/lang/translations/ku.po +1 -0
- package/lang/translations/lt.po +1 -0
- package/lang/translations/lv.po +1 -0
- package/lang/translations/ms.po +1 -0
- package/lang/translations/nl.po +1 -0
- package/lang/translations/no.po +1 -0
- package/lang/translations/pl.po +1 -0
- package/lang/translations/pt-br.po +1 -0
- package/lang/translations/pt.po +1 -0
- package/lang/translations/ro.po +1 -0
- package/lang/translations/ru.po +1 -0
- package/lang/translations/sk.po +1 -0
- package/lang/translations/sq.po +1 -0
- package/lang/translations/sr-latn.po +1 -0
- package/lang/translations/sr.po +1 -0
- package/lang/translations/sv.po +1 -0
- package/lang/translations/th.po +1 -0
- package/lang/translations/tk.po +1 -0
- package/lang/translations/tr.po +1 -0
- package/lang/translations/ug.po +1 -0
- package/lang/translations/uk.po +1 -0
- package/lang/translations/ur.po +1 -0
- package/lang/translations/uz.po +1 -0
- package/lang/translations/vi.po +1 -0
- package/lang/translations/zh-cn.po +1 -0
- package/lang/translations/zh.po +1 -0
- package/package.json +2 -6
- package/src/augmentation.d.ts +15 -15
- package/src/augmentation.js +5 -5
- package/src/index.d.ts +12 -12
- package/src/index.js +11 -11
- package/src/pagebreak.d.ts +28 -28
- package/src/pagebreak.js +32 -32
- package/src/pagebreakcommand.d.ts +29 -29
- package/src/pagebreakcommand.js +61 -61
- package/src/pagebreakediting.d.ts +22 -22
- package/src/pagebreakediting.js +102 -102
- package/src/pagebreakui.d.ts +21 -21
- package/src/pagebreakui.js +45 -45
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-page-break",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "40.0.0",
|
|
4
4
|
"description": "Page break feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -12,11 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"main": "src/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"ckeditor5": "
|
|
16
|
-
},
|
|
17
|
-
"engines": {
|
|
18
|
-
"node": ">=16.0.0",
|
|
19
|
-
"npm": ">=5.7.1"
|
|
15
|
+
"ckeditor5": "40.0.0"
|
|
20
16
|
},
|
|
21
17
|
"author": "CKSource (http://cksource.com/)",
|
|
22
18
|
"license": "GPL-2.0-or-later",
|
package/src/augmentation.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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 { PageBreak, PageBreakEditing, PageBreakUI, PageBreakCommand } from './index';
|
|
6
|
-
declare module '@ckeditor/ckeditor5-core' {
|
|
7
|
-
interface PluginsMap {
|
|
8
|
-
[PageBreak.pluginName]: PageBreak;
|
|
9
|
-
[PageBreakEditing.pluginName]: PageBreakEditing;
|
|
10
|
-
[PageBreakUI.pluginName]: PageBreakUI;
|
|
11
|
-
}
|
|
12
|
-
interface CommandsMap {
|
|
13
|
-
pageBreak: PageBreakCommand;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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 { PageBreak, PageBreakEditing, PageBreakUI, PageBreakCommand } from './index';
|
|
6
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
7
|
+
interface PluginsMap {
|
|
8
|
+
[PageBreak.pluginName]: PageBreak;
|
|
9
|
+
[PageBreakEditing.pluginName]: PageBreakEditing;
|
|
10
|
+
[PageBreakUI.pluginName]: PageBreakUI;
|
|
11
|
+
}
|
|
12
|
+
interface CommandsMap {
|
|
13
|
+
pageBreak: PageBreakCommand;
|
|
14
|
+
}
|
|
15
|
+
}
|
package/src/augmentation.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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
|
+
export {};
|
package/src/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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 page-break
|
|
7
|
-
*/
|
|
8
|
-
export { default as PageBreak } from './pagebreak';
|
|
9
|
-
export { default as PageBreakEditing } from './pagebreakediting';
|
|
10
|
-
export { default as PageBreakUI } from './pagebreakui';
|
|
11
|
-
export type { default as PageBreakCommand } from './pagebreakcommand';
|
|
12
|
-
import './augmentation';
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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 page-break
|
|
7
|
+
*/
|
|
8
|
+
export { default as PageBreak } from './pagebreak';
|
|
9
|
+
export { default as PageBreakEditing } from './pagebreakediting';
|
|
10
|
+
export { default as PageBreakUI } from './pagebreakui';
|
|
11
|
+
export type { default as PageBreakCommand } from './pagebreakcommand';
|
|
12
|
+
import './augmentation';
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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 page-break
|
|
7
|
-
*/
|
|
8
|
-
export { default as PageBreak } from './pagebreak';
|
|
9
|
-
export { default as PageBreakEditing } from './pagebreakediting';
|
|
10
|
-
export { default as PageBreakUI } from './pagebreakui';
|
|
11
|
-
import './augmentation';
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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 page-break
|
|
7
|
+
*/
|
|
8
|
+
export { default as PageBreak } from './pagebreak';
|
|
9
|
+
export { default as PageBreakEditing } from './pagebreakediting';
|
|
10
|
+
export { default as PageBreakUI } from './pagebreakui';
|
|
11
|
+
import './augmentation';
|
package/src/pagebreak.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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 page-break/pagebreak
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import { Widget } from 'ckeditor5/src/widget';
|
|
10
|
-
import PageBreakEditing from './pagebreakediting';
|
|
11
|
-
import PageBreakUI from './pagebreakui';
|
|
12
|
-
/**
|
|
13
|
-
* The page break feature.
|
|
14
|
-
*
|
|
15
|
-
* It provides the possibility to insert a page break into the rich-text editor.
|
|
16
|
-
*
|
|
17
|
-
* For a detailed overview, check the {@glink features/page-break Page break feature} documentation.
|
|
18
|
-
*/
|
|
19
|
-
export default class PageBreak extends Plugin {
|
|
20
|
-
/**
|
|
21
|
-
* @inheritDoc
|
|
22
|
-
*/
|
|
23
|
-
static get requires(): readonly [typeof PageBreakEditing, typeof PageBreakUI, typeof Widget];
|
|
24
|
-
/**
|
|
25
|
-
* @inheritDoc
|
|
26
|
-
*/
|
|
27
|
-
static get pluginName(): "PageBreak";
|
|
28
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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 page-break/pagebreak
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
import { Widget } from 'ckeditor5/src/widget';
|
|
10
|
+
import PageBreakEditing from './pagebreakediting';
|
|
11
|
+
import PageBreakUI from './pagebreakui';
|
|
12
|
+
/**
|
|
13
|
+
* The page break feature.
|
|
14
|
+
*
|
|
15
|
+
* It provides the possibility to insert a page break into the rich-text editor.
|
|
16
|
+
*
|
|
17
|
+
* For a detailed overview, check the {@glink features/page-break Page break feature} documentation.
|
|
18
|
+
*/
|
|
19
|
+
export default class PageBreak extends Plugin {
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
static get requires(): readonly [typeof PageBreakEditing, typeof PageBreakUI, typeof Widget];
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
static get pluginName(): "PageBreak";
|
|
28
|
+
}
|
package/src/pagebreak.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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 page-break/pagebreak
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import { Widget } from 'ckeditor5/src/widget';
|
|
10
|
-
import PageBreakEditing from './pagebreakediting';
|
|
11
|
-
import PageBreakUI from './pagebreakui';
|
|
12
|
-
/**
|
|
13
|
-
* The page break feature.
|
|
14
|
-
*
|
|
15
|
-
* It provides the possibility to insert a page break into the rich-text editor.
|
|
16
|
-
*
|
|
17
|
-
* For a detailed overview, check the {@glink features/page-break Page break feature} documentation.
|
|
18
|
-
*/
|
|
19
|
-
export default class PageBreak extends Plugin {
|
|
20
|
-
/**
|
|
21
|
-
* @inheritDoc
|
|
22
|
-
*/
|
|
23
|
-
static get requires() {
|
|
24
|
-
return [PageBreakEditing, PageBreakUI, Widget];
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* @inheritDoc
|
|
28
|
-
*/
|
|
29
|
-
static get pluginName() {
|
|
30
|
-
return 'PageBreak';
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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 page-break/pagebreak
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
import { Widget } from 'ckeditor5/src/widget';
|
|
10
|
+
import PageBreakEditing from './pagebreakediting';
|
|
11
|
+
import PageBreakUI from './pagebreakui';
|
|
12
|
+
/**
|
|
13
|
+
* The page break feature.
|
|
14
|
+
*
|
|
15
|
+
* It provides the possibility to insert a page break into the rich-text editor.
|
|
16
|
+
*
|
|
17
|
+
* For a detailed overview, check the {@glink features/page-break Page break feature} documentation.
|
|
18
|
+
*/
|
|
19
|
+
export default class PageBreak extends Plugin {
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
static get requires() {
|
|
24
|
+
return [PageBreakEditing, PageBreakUI, Widget];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
static get pluginName() {
|
|
30
|
+
return 'PageBreak';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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 page-break/pagebreakcommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from 'ckeditor5/src/core';
|
|
9
|
-
/**
|
|
10
|
-
* The page break command.
|
|
11
|
-
*
|
|
12
|
-
* The command is registered by {@link module:page-break/pagebreakediting~PageBreakEditing} as `'pageBreak'`.
|
|
13
|
-
*
|
|
14
|
-
* To insert a page break at the current selection, execute the command:
|
|
15
|
-
*
|
|
16
|
-
* editor.execute( 'pageBreak' );
|
|
17
|
-
*/
|
|
18
|
-
export default class PageBreakCommand extends Command {
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
refresh(): void;
|
|
23
|
-
/**
|
|
24
|
-
* Executes the command.
|
|
25
|
-
*
|
|
26
|
-
* @fires execute
|
|
27
|
-
*/
|
|
28
|
-
execute(): void;
|
|
29
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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 page-break/pagebreakcommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The page break command.
|
|
11
|
+
*
|
|
12
|
+
* The command is registered by {@link module:page-break/pagebreakediting~PageBreakEditing} as `'pageBreak'`.
|
|
13
|
+
*
|
|
14
|
+
* To insert a page break at the current selection, execute the command:
|
|
15
|
+
*
|
|
16
|
+
* editor.execute( 'pageBreak' );
|
|
17
|
+
*/
|
|
18
|
+
export default class PageBreakCommand extends Command {
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
refresh(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Executes the command.
|
|
25
|
+
*
|
|
26
|
+
* @fires execute
|
|
27
|
+
*/
|
|
28
|
+
execute(): void;
|
|
29
|
+
}
|
package/src/pagebreakcommand.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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 page-break/pagebreakcommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from 'ckeditor5/src/core';
|
|
9
|
-
import { findOptimalInsertionRange } from 'ckeditor5/src/widget';
|
|
10
|
-
/**
|
|
11
|
-
* The page break command.
|
|
12
|
-
*
|
|
13
|
-
* The command is registered by {@link module:page-break/pagebreakediting~PageBreakEditing} as `'pageBreak'`.
|
|
14
|
-
*
|
|
15
|
-
* To insert a page break at the current selection, execute the command:
|
|
16
|
-
*
|
|
17
|
-
* editor.execute( 'pageBreak' );
|
|
18
|
-
*/
|
|
19
|
-
export default class PageBreakCommand extends Command {
|
|
20
|
-
/**
|
|
21
|
-
* @inheritDoc
|
|
22
|
-
*/
|
|
23
|
-
refresh() {
|
|
24
|
-
const model = this.editor.model;
|
|
25
|
-
const schema = model.schema;
|
|
26
|
-
const selection = model.document.selection;
|
|
27
|
-
this.isEnabled = isPageBreakAllowedInParent(selection, schema, model);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Executes the command.
|
|
31
|
-
*
|
|
32
|
-
* @fires execute
|
|
33
|
-
*/
|
|
34
|
-
execute() {
|
|
35
|
-
const model = this.editor.model;
|
|
36
|
-
model.change(writer => {
|
|
37
|
-
const pageBreakElement = writer.createElement('pageBreak');
|
|
38
|
-
model.insertObject(pageBreakElement, null, null, {
|
|
39
|
-
setSelection: 'after'
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Checks if a page break is allowed by the schema in the optimal insertion parent.
|
|
46
|
-
*/
|
|
47
|
-
function isPageBreakAllowedInParent(selection, schema, model) {
|
|
48
|
-
const parent = getInsertPageBreakParent(selection, model);
|
|
49
|
-
return schema.checkChild(parent, 'pageBreak');
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Returns a node that will be used to insert a page break with `model.insertContent` to check if the page break can be placed there.
|
|
53
|
-
*/
|
|
54
|
-
function getInsertPageBreakParent(selection, model) {
|
|
55
|
-
const insertionRange = findOptimalInsertionRange(selection, model);
|
|
56
|
-
const parent = insertionRange.start.parent;
|
|
57
|
-
if (parent.isEmpty && !parent.is('element', '$root')) {
|
|
58
|
-
return parent.parent;
|
|
59
|
-
}
|
|
60
|
-
return parent;
|
|
61
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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 page-break/pagebreakcommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'ckeditor5/src/core';
|
|
9
|
+
import { findOptimalInsertionRange } from 'ckeditor5/src/widget';
|
|
10
|
+
/**
|
|
11
|
+
* The page break command.
|
|
12
|
+
*
|
|
13
|
+
* The command is registered by {@link module:page-break/pagebreakediting~PageBreakEditing} as `'pageBreak'`.
|
|
14
|
+
*
|
|
15
|
+
* To insert a page break at the current selection, execute the command:
|
|
16
|
+
*
|
|
17
|
+
* editor.execute( 'pageBreak' );
|
|
18
|
+
*/
|
|
19
|
+
export default class PageBreakCommand extends Command {
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
refresh() {
|
|
24
|
+
const model = this.editor.model;
|
|
25
|
+
const schema = model.schema;
|
|
26
|
+
const selection = model.document.selection;
|
|
27
|
+
this.isEnabled = isPageBreakAllowedInParent(selection, schema, model);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Executes the command.
|
|
31
|
+
*
|
|
32
|
+
* @fires execute
|
|
33
|
+
*/
|
|
34
|
+
execute() {
|
|
35
|
+
const model = this.editor.model;
|
|
36
|
+
model.change(writer => {
|
|
37
|
+
const pageBreakElement = writer.createElement('pageBreak');
|
|
38
|
+
model.insertObject(pageBreakElement, null, null, {
|
|
39
|
+
setSelection: 'after'
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Checks if a page break is allowed by the schema in the optimal insertion parent.
|
|
46
|
+
*/
|
|
47
|
+
function isPageBreakAllowedInParent(selection, schema, model) {
|
|
48
|
+
const parent = getInsertPageBreakParent(selection, model);
|
|
49
|
+
return schema.checkChild(parent, 'pageBreak');
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns a node that will be used to insert a page break with `model.insertContent` to check if the page break can be placed there.
|
|
53
|
+
*/
|
|
54
|
+
function getInsertPageBreakParent(selection, model) {
|
|
55
|
+
const insertionRange = findOptimalInsertionRange(selection, model);
|
|
56
|
+
const parent = insertionRange.start.parent;
|
|
57
|
+
if (parent.isEmpty && !parent.is('element', '$root')) {
|
|
58
|
+
return parent.parent;
|
|
59
|
+
}
|
|
60
|
+
return parent;
|
|
61
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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 page-break/pagebreakediting
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import '../theme/pagebreak.css';
|
|
10
|
-
/**
|
|
11
|
-
* The page break editing feature.
|
|
12
|
-
*/
|
|
13
|
-
export default class PageBreakEditing extends Plugin {
|
|
14
|
-
/**
|
|
15
|
-
* @inheritDoc
|
|
16
|
-
*/
|
|
17
|
-
static get pluginName(): "PageBreakEditing";
|
|
18
|
-
/**
|
|
19
|
-
* @inheritDoc
|
|
20
|
-
*/
|
|
21
|
-
init(): void;
|
|
22
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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 page-break/pagebreakediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
import '../theme/pagebreak.css';
|
|
10
|
+
/**
|
|
11
|
+
* The page break editing feature.
|
|
12
|
+
*/
|
|
13
|
+
export default class PageBreakEditing extends Plugin {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
static get pluginName(): "PageBreakEditing";
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
init(): void;
|
|
22
|
+
}
|