slate-angular 14.1.1 → 14.1.2

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.
@@ -1839,18 +1839,28 @@ class BaseLeafComponent extends BaseComponent {
1839
1839
  // Issue occurs when the span node of the placeholder is before the slateString span node
1840
1840
  if (this.context.leaf['placeholder']) {
1841
1841
  if (!this.placeholderElement) {
1842
- this.placeholderElement = document.createElement('span');
1843
- this.placeholderElement.innerText = this.context.leaf['placeholder'];
1844
- this.placeholderElement.contentEditable = 'false';
1845
- this.placeholderElement.setAttribute('data-slate-placeholder', 'true');
1846
- this.nativeElement.classList.add('leaf-with-placeholder');
1847
- this.nativeElement.appendChild(this.placeholderElement);
1842
+ this.createPlaceholder();
1848
1843
  }
1844
+ this.updatePlaceholder();
1849
1845
  }
1850
1846
  else {
1851
1847
  this.destroyPlaceholder();
1852
1848
  }
1853
1849
  }
1850
+ createPlaceholder() {
1851
+ const placeholderElement = document.createElement('span');
1852
+ placeholderElement.innerText = this.context.leaf['placeholder'];
1853
+ placeholderElement.contentEditable = 'false';
1854
+ placeholderElement.setAttribute('data-slate-placeholder', 'true');
1855
+ this.placeholderElement = placeholderElement;
1856
+ this.nativeElement.classList.add('leaf-with-placeholder');
1857
+ this.nativeElement.appendChild(placeholderElement);
1858
+ }
1859
+ updatePlaceholder() {
1860
+ if (this.placeholderElement.innerText !== this.context.leaf['placeholder']) {
1861
+ this.placeholderElement.innerText = this.context.leaf['placeholder'];
1862
+ }
1863
+ }
1854
1864
  destroyPlaceholder() {
1855
1865
  if (this.placeholderElement) {
1856
1866
  this.placeholderElement.remove();
@@ -2587,6 +2597,10 @@ class SlateEditableComponent {
2587
2597
  if (decorateChange) {
2588
2598
  this.forceFlush();
2589
2599
  }
2600
+ const placeholderChange = simpleChanges['placeholder'];
2601
+ if (placeholderChange) {
2602
+ this.detectContext();
2603
+ }
2590
2604
  const readonlyChange = simpleChanges['readonly'];
2591
2605
  if (readonlyChange) {
2592
2606
  IS_READONLY.set(this.editor, this.readonly);