{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import panel as pn\n", "import param\n", "\n", "pn.extension('texteditor')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The ``TextEditor`` widget provides a WYSIWYG (what-you-see-is-what-you-get) rich text editor into a Panel application which outputs HTML. The editor is built on top of the [Quill.js](https://quilljs.com/) library.\n", "\n", "#### Parameters:\n", "\n", "For layout and styling related parameters see the [customization user guide](../../user_guide/Customization.ipynb).\n", "\n", "* **``disabled``** (boolean): Whether the editor is disabled\n", "* **``mode``** (str): Whether to display a `'toolbar'` or a `'bubble'` menu on highlight.\n", "* **``placeholder``** (str): Placeholder output to render when the editor is empty.\n", "* **``toolbar``** (boolean or list): Toolbar configuration either as a boolean toggle or a configuration specified as a list.\n", "* **``value``** (str): The current HTML output of the widget\n", "\n", "___" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To construct a `TextEditor` editor widget we must declare it explicitly and may provide a `placeholder` as pure text or a `value` as HTML:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "wysiwyg = pn.widgets.TextEditor(placeholder='Enter some text')\n", "wysiwyg" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The current state of the editor output is reflected on the `value` parameter:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "wysiwyg.value" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `value` may also be set:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "wysiwyg.value = '