@elementor/editor-controls 4.1.0-746 → 4.1.0-748

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-controls",
3
3
  "description": "This package contains the controls model and utils for the Elementor editor",
4
- "version": "4.1.0-746",
4
+ "version": "4.1.0-748",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,22 +40,22 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor-current-user": "4.1.0-746",
44
- "@elementor/editor-elements": "4.1.0-746",
45
- "@elementor/editor-props": "4.1.0-746",
46
- "@elementor/editor-responsive": "4.1.0-746",
47
- "@elementor/editor-ui": "4.1.0-746",
48
- "@elementor/editor-v1-adapters": "4.1.0-746",
49
- "@elementor/env": "4.1.0-746",
50
- "@elementor/http-client": "4.1.0-746",
43
+ "@elementor/editor-current-user": "4.1.0-748",
44
+ "@elementor/editor-elements": "4.1.0-748",
45
+ "@elementor/editor-props": "4.1.0-748",
46
+ "@elementor/editor-responsive": "4.1.0-748",
47
+ "@elementor/editor-ui": "4.1.0-748",
48
+ "@elementor/editor-v1-adapters": "4.1.0-748",
49
+ "@elementor/env": "4.1.0-748",
50
+ "@elementor/http-client": "4.1.0-748",
51
51
  "@elementor/icons": "^1.68.0",
52
- "@elementor/locations": "4.1.0-746",
53
- "@elementor/events": "4.1.0-746",
54
- "@elementor/query": "4.1.0-746",
55
- "@elementor/session": "4.1.0-746",
52
+ "@elementor/locations": "4.1.0-748",
53
+ "@elementor/events": "4.1.0-748",
54
+ "@elementor/query": "4.1.0-748",
55
+ "@elementor/session": "4.1.0-748",
56
56
  "@elementor/ui": "1.36.17",
57
- "@elementor/utils": "4.1.0-746",
58
- "@elementor/wp-media": "4.1.0-746",
57
+ "@elementor/utils": "4.1.0-748",
58
+ "@elementor/wp-media": "4.1.0-748",
59
59
  "@wordpress/i18n": "^5.13.0",
60
60
  "@monaco-editor/react": "^4.7.0",
61
61
  "dayjs": "^1.11.18",
@@ -16,7 +16,7 @@ import Underline from '@tiptap/extension-underline';
16
16
  import { type EditorProps, type EditorView } from '@tiptap/pm/view';
17
17
  import { type Editor, EditorContent, useEditor } from '@tiptap/react';
18
18
 
19
- import { isEmpty } from '../utils/inline-editing';
19
+ import { htmlToPlainText, isEmpty } from '../utils/inline-editing';
20
20
 
21
21
  const ITALIC_KEYBOARD_SHORTCUT = 'i';
22
22
  const BOLD_KEYBOARD_SHORTCUT = 'b';
@@ -141,7 +141,7 @@ export const InlineEditor = React.forwardRef( ( props: InlineEditorProps, ref )
141
141
  attributes: {
142
142
  ...( editorProps.attributes ?? {} ),
143
143
  role: 'textbox',
144
- ...( placeholder ? { 'data-placeholder': placeholder } : {} ),
144
+ ...( placeholder ? { 'data-placeholder': htmlToPlainText( placeholder ) } : {} ),
145
145
  ...( value === null || value === '' ? { class: 'is-empty' } : {} ),
146
146
  },
147
147
  },
@@ -9,3 +9,14 @@ export function isEmpty( value: string | null = '' ) {
9
9
 
10
10
  return ! pseudoElement.textContent?.length;
11
11
  }
12
+
13
+ export function htmlToPlainText( html: string | null ): string {
14
+ if ( ! html ) {
15
+ return '';
16
+ }
17
+
18
+ const normalizedHtml = html.replace( /<br\s*\/?>/gi, '\n' ).replace( /<\/p>\s*<p[^>]*>/gi, '\n' );
19
+ const doc = new DOMParser().parseFromString( normalizedHtml, 'text/html' );
20
+
21
+ return doc.body.textContent ?? '';
22
+ }