@ckeditor/ckeditor5-engine 39.0.0 → 39.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-engine",
3
- "version": "39.0.0",
3
+ "version": "39.0.1",
4
4
  "description": "The editing engine of CKEditor 5 – the best browser-based rich text editor.",
5
5
  "keywords": [
6
6
  "wysiwyg",
@@ -23,7 +23,7 @@
23
23
  ],
24
24
  "main": "src/index.js",
25
25
  "dependencies": {
26
- "@ckeditor/ckeditor5-utils": "39.0.0",
26
+ "@ckeditor/ckeditor5-utils": "39.0.1",
27
27
  "lodash-es": "4.17.21"
28
28
  },
29
29
  "engines": {
@@ -25,12 +25,15 @@ import type View from './view';
25
25
  * in the passed `element` but in one of its children (selected automatically, i.e. a first empty child element).
26
26
  * Useful when attaching placeholders to elements that can host other elements (not just text), for instance,
27
27
  * editable root elements.
28
+ * @param options.text Placeholder text. It's **deprecated** and will be removed soon. Use
29
+ * {@link module:engine/view/placeholder~PlaceholderableElement#placeholder `options.element.placeholder`} instead.
28
30
  * @param options.keepOnFocus If set `true`, the placeholder stay visible when the host element is focused.
29
31
  */
30
- export declare function enablePlaceholder({ view, element, isDirectHost, keepOnFocus }: {
32
+ export declare function enablePlaceholder({ view, element, text, isDirectHost, keepOnFocus }: {
31
33
  view: View;
32
34
  element: PlaceholderableElement | EditableElement;
33
35
  isDirectHost?: boolean;
36
+ text?: string;
34
37
  keepOnFocus?: boolean;
35
38
  }): void;
36
39
  /**
@@ -6,8 +6,10 @@
6
6
  * @module engine/view/placeholder
7
7
  */
8
8
  import '../../theme/placeholder.css';
9
+ import { logWarning } from '@ckeditor/ckeditor5-utils';
9
10
  // Each document stores information about its placeholder elements and check functions.
10
11
  const documentPlaceholders = new WeakMap();
12
+ let hasDisplayedPlaceholderDeprecationWarning = false;
11
13
  /**
12
14
  * A helper that enables a placeholder on the provided view element (also updates its visibility).
13
15
  * The placeholder is a CSS pseudo–element (with a text content) attached to the element.
@@ -23,9 +25,11 @@ const documentPlaceholders = new WeakMap();
23
25
  * in the passed `element` but in one of its children (selected automatically, i.e. a first empty child element).
24
26
  * Useful when attaching placeholders to elements that can host other elements (not just text), for instance,
25
27
  * editable root elements.
28
+ * @param options.text Placeholder text. It's **deprecated** and will be removed soon. Use
29
+ * {@link module:engine/view/placeholder~PlaceholderableElement#placeholder `options.element.placeholder`} instead.
26
30
  * @param options.keepOnFocus If set `true`, the placeholder stay visible when the host element is focused.
27
31
  */
28
- export function enablePlaceholder({ view, element, isDirectHost = true, keepOnFocus = false }) {
32
+ export function enablePlaceholder({ view, element, text, isDirectHost = true, keepOnFocus = false }) {
29
33
  const doc = view.document;
30
34
  // Use a single a single post fixer per—document to update all placeholders.
31
35
  if (!documentPlaceholders.has(doc)) {
@@ -46,6 +50,12 @@ export function enablePlaceholder({ view, element, isDirectHost = true, keepOnFo
46
50
  if (element.placeholder) {
47
51
  setPlaceholder(element.placeholder);
48
52
  }
53
+ else if (text) {
54
+ setPlaceholder(text);
55
+ }
56
+ if (text) {
57
+ showPlaceholderTextDeprecationWarning();
58
+ }
49
59
  function setPlaceholder(text) {
50
60
  // Store information about the element placeholder under its document.
51
61
  documentPlaceholders.get(doc).set(element, {
@@ -237,3 +247,21 @@ function getChildPlaceholderHostSubstitute(parent) {
237
247
  }
238
248
  return null;
239
249
  }
250
+ /**
251
+ * Displays a deprecation warning message in the console, but only once per page load.
252
+ */
253
+ function showPlaceholderTextDeprecationWarning() {
254
+ if (!hasDisplayedPlaceholderDeprecationWarning) {
255
+ /**
256
+ * The "text" option in the {@link module:engine/view/placeholder~enablePlaceholder `enablePlaceholder()`}
257
+ * function is deprecated and will be removed soon.
258
+ *
259
+ * See the {@glink updating/guides/update-to-39#view-element-placeholder Migration to v39} guide for
260
+ * more information on how to apply this change.
261
+ *
262
+ * @error enableplaceholder-deprecated-text-option
263
+ */
264
+ logWarning('enableplaceholder-deprecated-text-option');
265
+ }
266
+ hasDisplayedPlaceholderDeprecationWarning = true;
267
+ }