@ckeditor/ckeditor5-clipboard 42.0.2 → 43.0.0-alpha.1

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.
@@ -0,0 +1,8 @@
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
+ import type { Translations } from '@ckeditor/ckeditor5-utils';
7
+ declare const translations: Translations;
8
+ export default translations;
@@ -0,0 +1,5 @@
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
+ export default {"sr-latn":{"dictionary":{"Copy selected content":"Kopirajte izabrani sadržaj","Paste content":"Nalepite sadržaj","Paste content as plain text":"Nalepite sadržaj kao običan tekst"},getPluralForm(n){return (n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);}}}
@@ -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
+ ( e => {
7
+ const { [ 'sr-latn' ]: { dictionary, getPluralForm } } = {"sr-latn":{"dictionary":{"Copy selected content":"Kopirajte izabrani sadržaj","Paste content":"Nalepite sadržaj","Paste content as plain text":"Nalepite sadržaj kao običan tekst"},getPluralForm(n){return (n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);}}};
8
+ e[ 'sr-latn' ] ||= { dictionary: {}, getPluralForm: null };
9
+ e[ 'sr-latn' ].dictionary = Object.assign( e[ 'sr-latn' ].dictionary, dictionary );
10
+ e[ 'sr-latn' ].getPluralForm = getPluralForm;
11
+ } )( window.CKEDITOR_TRANSLATIONS ||= {} );
@@ -0,0 +1,30 @@
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ #
3
+ # !!! IMPORTANT !!!
4
+ #
5
+ # Before you edit this file, please keep in mind that contributing to the project
6
+ # translations is possible ONLY via the Transifex online service.
7
+ #
8
+ # To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
9
+ #
10
+ # To learn more, check out the official contributor's guide:
11
+ # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
12
+ #
13
+ msgid ""
14
+ msgstr ""
15
+ "Language-Team: Serbian (Latin) (https://app.transifex.com/ckeditor/teams/11143/sr@latin/)\n"
16
+ "Language: sr@latin\n"
17
+ "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
19
+
20
+ msgctxt "Keystroke description for assistive technologies: keystroke for copying selected content."
21
+ msgid "Copy selected content"
22
+ msgstr "Kopirajte izabrani sadržaj"
23
+
24
+ msgctxt "Keystroke description for assistive technologies: keystroke for pasting content."
25
+ msgid "Paste content"
26
+ msgstr "Nalepite sadržaj"
27
+
28
+ msgctxt "Keystroke description for assistive technologies: keystroke for pasting content as plain text."
29
+ msgid "Paste content as plain text"
30
+ msgstr "Nalepite sadržaj kao običan tekst"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-clipboard",
3
- "version": "42.0.2",
3
+ "version": "43.0.0-alpha.1",
4
4
  "description": "Clipboard integration feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,11 +13,11 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "@ckeditor/ckeditor5-core": "42.0.2",
17
- "@ckeditor/ckeditor5-engine": "42.0.2",
18
- "@ckeditor/ckeditor5-ui": "42.0.2",
19
- "@ckeditor/ckeditor5-utils": "42.0.2",
20
- "@ckeditor/ckeditor5-widget": "42.0.2",
16
+ "@ckeditor/ckeditor5-core": "43.0.0-alpha.1",
17
+ "@ckeditor/ckeditor5-engine": "43.0.0-alpha.1",
18
+ "@ckeditor/ckeditor5-ui": "43.0.0-alpha.1",
19
+ "@ckeditor/ckeditor5-utils": "43.0.0-alpha.1",
20
+ "@ckeditor/ckeditor5-widget": "43.0.0-alpha.1",
21
21
  "lodash-es": "4.17.21"
22
22
  },
23
23
  "author": "CKSource (http://cksource.com/)",
@@ -33,17 +33,10 @@ export default class PastePlainText extends Plugin {
33
33
  const editor = this.editor;
34
34
  const model = editor.model;
35
35
  const view = editor.editing.view;
36
- const viewDocument = view.document;
37
36
  const selection = model.document.selection;
38
- let shiftPressed = false;
39
37
  view.addObserver(ClipboardObserver);
40
- this.listenTo(viewDocument, 'keydown', (evt, data) => {
41
- shiftPressed = data.shiftKey;
42
- });
43
38
  editor.plugins.get(ClipboardPipeline).on('contentInsertion', (evt, data) => {
44
- // Plain text can be determined based on the event flag (#7799) or auto-detection (#1006). If detected,
45
- // preserve selection attributes on pasted items.
46
- if (!shiftPressed && !isPlainTextFragment(data.content, model.schema)) {
39
+ if (!isUnformattedInlineContent(data.content, model)) {
47
40
  return;
48
41
  }
49
42
  model.change(writer => {
@@ -59,8 +52,10 @@ export default class PastePlainText extends Plugin {
59
52
  textAttributes.push(...selection.getAttributes());
60
53
  const range = writer.createRangeIn(data.content);
61
54
  for (const item of range.getItems()) {
62
- if (item.is('$textProxy')) {
63
- writer.setAttributes(textAttributes, item);
55
+ for (const attribute of textAttributes) {
56
+ if (model.schema.checkAttribute(item, attribute[0])) {
57
+ writer.setAttribute(attribute[0], attribute[1], item);
58
+ }
64
59
  }
65
60
  }
66
61
  });
@@ -68,15 +63,34 @@ export default class PastePlainText extends Plugin {
68
63
  }
69
64
  }
70
65
  /**
71
- * Returns true if specified `documentFragment` represents a plain text.
66
+ * Returns true if specified `documentFragment` represents the unformatted inline content.
72
67
  */
73
- function isPlainTextFragment(documentFragment, schema) {
74
- if (documentFragment.childCount > 1) {
75
- return false;
68
+ function isUnformattedInlineContent(documentFragment, model) {
69
+ let range = model.createRangeIn(documentFragment);
70
+ // We consider three scenarios here. The document fragment may include:
71
+ //
72
+ // 1. Only text and inline objects. Then it could be unformatted inline content.
73
+ // 2. Exactly one block element on top-level, eg. <p>Foobar</p> or <h2>Title</h2>.
74
+ // In this case, check this element content, it could be treated as unformatted inline content.
75
+ // 3. More block elements or block objects, then it is not unformatted inline content.
76
+ //
77
+ // We will check for scenario 2. specifically, and if it happens, we will unwrap it and follow with the regular algorithm.
78
+ //
79
+ if (documentFragment.childCount == 1) {
80
+ const child = documentFragment.getChild(0);
81
+ if (child.is('element') && model.schema.isBlock(child) && !model.schema.isObject(child) && !model.schema.isLimit(child)) {
82
+ // Scenario 2. as described above.
83
+ range = model.createRangeIn(child);
84
+ }
76
85
  }
77
- const child = documentFragment.getChild(0);
78
- if (schema.isObject(child)) {
79
- return false;
86
+ for (const child of range.getItems()) {
87
+ if (!model.schema.isInline(child)) {
88
+ return false;
89
+ }
90
+ const attributeKeys = Array.from(child.getAttributeKeys());
91
+ if (attributeKeys.find(key => model.schema.getAttributeProperties(key).isFormatting)) {
92
+ return false;
93
+ }
80
94
  }
81
- return Array.from(child.getAttributeKeys()).length == 0;
95
+ return true;
82
96
  }
@@ -62,6 +62,11 @@ function newLinePadding(element, previous) {
62
62
  // Add small padding between selected container elements.
63
63
  return '\n';
64
64
  }
65
+ // Do not add padding around the elements that won't be rendered.
66
+ if (element.is('element') && element.getCustomProperty('dataPipeline:transparentRendering') ||
67
+ previous.is('element') && previous.getCustomProperty('dataPipeline:transparentRendering')) {
68
+ return '';
69
+ }
65
70
  // Add empty lines between container elements.
66
71
  return '\n\n';
67
72
  }