MCPcopy
hub / github.com/securingsincity/react-ace / updatePlaceholder

Method updatePlaceholder

src/ace.tsx:564–587  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

562 }
563
564 public updatePlaceholder() {
565 // Adapted from https://stackoverflow.com/questions/26695708/how-can-i-add-placeholder-text-when-the-editor-is-empty
566
567 const editor = this.editor;
568 const { placeholder } = this.props;
569
570 const showPlaceholder = !editor.session.getValue().length;
571 let node = editor.renderer.placeholderNode;
572
573 if (!showPlaceholder && node) {
574 editor.renderer.scroller.removeChild(editor.renderer.placeholderNode);
575 editor.renderer.placeholderNode = null;
576 } else if (showPlaceholder && !node) {
577 node = editor.renderer.placeholderNode = document.createElement("div");
578 node.textContent = placeholder || "";
579 node.className = "ace_comment ace_placeholder";
580 node.style.padding = "0 9px";
581 node.style.position = "absolute";
582 node.style.zIndex = "3";
583 editor.renderer.scroller.appendChild(node);
584 } else if (showPlaceholder && node) {
585 node.textContent = placeholder;
586 }
587 }
588
589 public updateRef(item: HTMLElement) {
590 this.refEditor = item;

Callers 3

componentDidMountMethod · 0.95
componentDidUpdateMethod · 0.95
onInputMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected