@ckeditor/ckeditor5-paragraph
Advanced tools
Comparing version 38.2.0-alpha.0 to 38.2.0-alpha.1
{ | ||
"name": "@ckeditor/ckeditor5-paragraph", | ||
"version": "38.2.0-alpha.0", | ||
"version": "38.2.0-alpha.1", | ||
"description": "Paragraph feature for CKEditor 5.", | ||
@@ -16,5 +16,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-core": "38.2.0-alpha.0", | ||
"@ckeditor/ckeditor5-ui": "38.2.0-alpha.0", | ||
"@ckeditor/ckeditor5-utils": "38.2.0-alpha.0" | ||
"@ckeditor/ckeditor5-core": "38.2.0-alpha.1", | ||
"@ckeditor/ckeditor5-ui": "38.2.0-alpha.1", | ||
"@ckeditor/ckeditor5-utils": "38.2.0-alpha.1" | ||
}, | ||
@@ -21,0 +21,0 @@ "engines": { |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
import type { Paragraph, ParagraphCommand, InsertParagraphCommand } from './index'; | ||
import type { Paragraph, ParagraphCommand, InsertParagraphCommand } from './index.js'; | ||
declare module '@ckeditor/ckeditor5-core' { | ||
@@ -8,0 +8,0 @@ interface CommandsMap { |
@@ -8,6 +8,6 @@ /** | ||
*/ | ||
export { default as Paragraph } from './paragraph'; | ||
export { default as ParagraphButtonUI } from './paragraphbuttonui'; | ||
export type { default as ParagraphCommand } from './paragraphcommand'; | ||
export type { default as InsertParagraphCommand } from './insertparagraphcommand'; | ||
import './augmentation'; | ||
export { default as Paragraph } from './paragraph.js'; | ||
export { default as ParagraphButtonUI } from './paragraphbuttonui.js'; | ||
export type { default as ParagraphCommand } from './paragraphcommand.js'; | ||
export type { default as InsertParagraphCommand } from './insertparagraphcommand.js'; | ||
import './augmentation.js'; |
@@ -8,4 +8,4 @@ /** | ||
*/ | ||
export { default as Paragraph } from './paragraph'; | ||
export { default as ParagraphButtonUI } from './paragraphbuttonui'; | ||
import './augmentation'; | ||
export { default as Paragraph } from './paragraph.js'; | ||
export { default as ParagraphButtonUI } from './paragraphbuttonui.js'; | ||
import './augmentation.js'; |
@@ -50,12 +50,34 @@ /** | ||
const paragraph = writer.createElement('paragraph'); | ||
const allowedParent = model.schema.findAllowedParent(position, paragraph); | ||
// It could be there's no ancestor limit that would allow paragraph. | ||
// In theory, "paragraph" could be disallowed even in the "$root". | ||
if (!allowedParent) { | ||
return; | ||
} | ||
if (attributes) { | ||
model.schema.setAllowedAttributes(paragraph, attributes, writer); | ||
} | ||
if (!model.schema.checkChild(position.parent, paragraph)) { | ||
const allowedParent = model.schema.findAllowedParent(position, paragraph); | ||
// It could be there's no ancestor limit that would allow paragraph. | ||
// In theory, "paragraph" could be disallowed even in the "$root". | ||
if (!allowedParent) { | ||
return; | ||
} | ||
if (position.path.length < 2) { | ||
model.insertContent(paragraph, position); | ||
writer.setSelection(paragraph, 'in'); | ||
return; | ||
} | ||
const positionParent = position.parent; | ||
// E.g. | ||
// <paragraph>[]</paragraph> ---> <paragraph></paragraph><paragraph>[]</paragraph> | ||
const isInEmptyBlock = positionParent.isEmpty; | ||
// E.g. | ||
// <paragraph>foo[]</paragraph> ---> <paragraph>foo</paragraph><paragraph>[]</paragraph> | ||
const isAtEndOfTextBlock = position.isAtEnd && !positionParent.isEmpty; | ||
// E.g. | ||
// <paragraph>[]foo</paragraph> ---> <paragraph>[]</paragraph><paragraph>foo</paragraph> | ||
const isAtStartOfTextBlock = position.isAtStart && !positionParent.isEmpty; | ||
const canBeChild = model.schema.checkChild(positionParent, paragraph); | ||
if (isInEmptyBlock || isAtEndOfTextBlock) { | ||
position = writer.createPositionAfter(positionParent); | ||
} | ||
else if (isAtStartOfTextBlock) { | ||
position = writer.createPositionBefore(positionParent); | ||
} | ||
else if (!canBeChild) { | ||
position = writer.split(position, allowedParent).position; | ||
@@ -62,0 +84,0 @@ } |
@@ -8,4 +8,4 @@ /** | ||
*/ | ||
import ParagraphCommand from './paragraphcommand'; | ||
import InsertParagraphCommand from './insertparagraphcommand'; | ||
import ParagraphCommand from './paragraphcommand.js'; | ||
import InsertParagraphCommand from './insertparagraphcommand.js'; | ||
import { Plugin } from '@ckeditor/ckeditor5-core'; | ||
@@ -12,0 +12,0 @@ /** |
@@ -9,3 +9,3 @@ /** | ||
import { Plugin } from '@ckeditor/ckeditor5-core'; | ||
import Paragraph from './paragraph'; | ||
import Paragraph from './paragraph.js'; | ||
/** | ||
@@ -12,0 +12,0 @@ * This plugin defines the `'paragraph'` button. It can be used together with |
@@ -10,3 +10,3 @@ /** | ||
import { ButtonView } from '@ckeditor/ckeditor5-ui'; | ||
import Paragraph from './paragraph'; | ||
import Paragraph from './paragraph.js'; | ||
const icon = icons.paragraph; | ||
@@ -13,0 +13,0 @@ /** |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30060
549
+ Added@ckeditor/ckeditor5-core@38.2.0-alpha.1(transitive)
+ Added@ckeditor/ckeditor5-engine@38.2.0-alpha.1(transitive)
+ Added@ckeditor/ckeditor5-ui@38.2.0-alpha.1(transitive)
+ Added@ckeditor/ckeditor5-utils@38.2.0-alpha.1(transitive)
- Removed@ckeditor/ckeditor5-core@38.2.0-alpha.0(transitive)
- Removed@ckeditor/ckeditor5-engine@38.2.0-alpha.0(transitive)
- Removed@ckeditor/ckeditor5-ui@38.2.0-alpha.0(transitive)
- Removed@ckeditor/ckeditor5-utils@38.2.0-alpha.0(transitive)