UNPKG

communication-react-19

Version:

React library for building modern communication user experiences utilizing Azure Communication Services (React 19 compatible fork)

42 lines 1.4 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import { WatermarkPlugin } from 'roosterjs-content-model-plugins'; /** * PlaceholderPlugin is a plugin for displaying placeholder and handle localization for it in the editor. */ export class PlaceholderPlugin extends WatermarkPlugin { constructor() { super(...arguments); this.isPlaceholderShown = false; this.editorValue = null; } updatePlaceholder(placeholder) { this.watermark = placeholder; // hide and show the placeholder to show the latest one // this needs to be done only if the placeholder is currently shown if (this.editorValue && this.isPlaceholderShown) { this.hide(this.editorValue); this.show(this.editorValue); } } initialize(editor) { this.editorValue = editor; super.initialize(editor); // Hide/show the placeholder as workaround for the placeholder not hiding in some cases this.hide(this.editorValue); this.show(this.editorValue); } dispose() { this.editorValue = null; super.dispose(); } show(editor) { super.show(editor); this.isPlaceholderShown = true; } hide(editor) { super.hide(editor); this.isPlaceholderShown = false; } } //# sourceMappingURL=PlaceholderPlugin.js.map