All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vaadin.flow.component.richtexteditor.GeneratedVaadinRichTextEditor Maven / Gradle / Ivy

/*
 * Copyright 2000-2022 Vaadin Ltd.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.vaadin.flow.component.richtexteditor;

import java.util.stream.Collectors;
import java.util.stream.Stream;

/*
 * #%L
 * Vaadin RichTextEditor for Vaadin 10
 * %%
 * Copyright (C) 2018 Vaadin Ltd
 * %%
 * This program is available under Commercial Vaadin Add-On License 3.0
 * (CVALv3).
 * 
 * See the file license.html distributed with this software for more
 * information about licensing.
 * 
 * You should have received a copy of the CVALv3 along with this program.
 * If not, see .
 * #L%
 */

import com.vaadin.flow.component.AbstractSinglePropertyField;
import com.vaadin.flow.component.ComponentEvent;
import com.vaadin.flow.component.ComponentEventListener;
import com.vaadin.flow.component.DomEvent;
import com.vaadin.flow.component.HasStyle;
import com.vaadin.flow.component.HasTheme;
import com.vaadin.flow.component.Synchronize;
import com.vaadin.flow.component.Tag;
import com.vaadin.flow.component.dependency.HtmlImport;
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.dependency.NpmPackage;
import com.vaadin.flow.function.SerializableBiFunction;
import com.vaadin.flow.function.SerializableFunction;
import com.vaadin.flow.shared.Registration;

import elemental.json.JsonArray;

/**
 * 

* Description copied from corresponding location in WebComponent: *

*

* {@code } is a Web Component for rich text editing. * It provides a set of toolbar controls to apply formatting on the content, * which is stored and can be accessed as HTML5 or JSON string. *

*

* {@code } *

*

* Vaadin Rich Text Editor focuses on the structure, not the styling of content. * Therefore, the semantic HTML5 tags and CSS usage is limited to most common * cases, like horizontal text alignment. *

*

Styling

*

* The following state attributes are available for styling: *

* * * * * * * * * * * * * * * * * * * *
AttributeDescriptionPart name
{@code disabled}Set to a disabled text editor:host
{@code readonly}Set to a readonly text editor:host
Styling
*

* The following shadow DOM parts are available for styling: *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Part nameDescription
{@code toolbar}The toolbar wrapper
{@code content}The content wrapper
{@code group}The group for toolbar controls
{@code undo-button}The "undo" button
{@code redo-button}The "redo" button
{@code bold-button}The "bold" button
{@code italic-button}The "italic" button
{@code underline-button}The "underline" button
{@code strike-button}The "strike-through" button
{@code h1-button}The "header 1" button
{@code h2-button}The "header 2" button
{@code h3-button}The "header 3" button
{@code subscript-button}The "subscript" button
{@code superscript-button}The "superscript" button
{@code list-ordered-button}The "ordered list" button
{@code list-bullet-button}The "bullet list" button
{@code align-left-button}The "left align" button
{@code align-center-button}The "center align" button
{@code align-right-button}The "right align" button
{@code image-button}The "image" button
{@code blockquote-button}The "blockquote" button
{@code code-block-button}The "code block" button
{@code clean-button}The "clean formatting" button
Shadow parts
*

* See * ThemableMixin * – how to apply styles for shadow parts *

*/ @Tag("vaadin-rich-text-editor") @NpmPackage(value = "@vaadin/vaadin-rich-text-editor", version = "1.3.1") @JsModule("@vaadin/vaadin-rich-text-editor/src/vaadin-rich-text-editor.js") @HtmlImport("frontend://bower_components/vaadin-rich-text-editor/src/vaadin-rich-text-editor.html") public abstract class GeneratedVaadinRichTextEditor, T> extends AbstractSinglePropertyField implements HasStyle, HasTheme { /** * Adds theme variants to the component. * * @param variants * theme variants to add */ public void addThemeVariants(RichTextEditorVariant... variants) { getThemeNames().addAll( Stream.of(variants).map(RichTextEditorVariant::getVariantName) .collect(Collectors.toList())); } /** * Removes theme variants from the component. * * @param variants * theme variants to remove */ public void removeThemeVariants(RichTextEditorVariant... variants) { getThemeNames().removeAll( Stream.of(variants).map(RichTextEditorVariant::getVariantName) .collect(Collectors.toList())); } /** *

* Description copied from corresponding location in WebComponent: *

*

* HTML representation of the rich text editor content. *

* This property is synchronized automatically from client side when a * 'html-value-changed' event happens. *

* * @return the {@code htmlValue} property from the webcomponent */ @Synchronize(property = "htmlValue", value = "html-value-changed") protected String getHtmlValueString() { return getElement().getProperty("htmlValue"); } /** *

* Description copied from corresponding location in WebComponent: *

*

* When true, the user can not modify, nor copy the editor content. *

* This property is not synchronized automatically from the client side, so * the returned value may not be the same as in client side. *

* * @return the {@code disabled} property from the webcomponent */ protected boolean isDisabledBoolean() { return getElement().getProperty("disabled", false); } /** *

* Description copied from corresponding location in WebComponent: *

*

* When true, the user can not modify, nor copy the editor content. *

* * @param disabled * the boolean value to set */ protected void setDisabled(boolean disabled) { getElement().setProperty("disabled", disabled); } /** *

* Description copied from corresponding location in WebComponent: *

*

* When true, the user can not modify the editor content, but can copy it. *

* This property is not synchronized automatically from the client side, so * the returned value may not be the same as in client side. *

* * @return the {@code readonly} property from the webcomponent */ protected boolean isReadonlyBoolean() { return getElement().getProperty("readonly", false); } /** *

* Description copied from corresponding location in WebComponent: *

*

* When true, the user can not modify the editor content, but can copy it. *

* * @param readonly * the boolean value to set */ protected void setReadonly(boolean readonly) { getElement().setProperty("readonly", readonly); } /** *

* Description copied from corresponding location in WebComponent: *

*

* An object used to localize this component. The properties are used e.g. * as the tooltips for the editor toolbar buttons. *

* This property is not synchronized automatically from the client side, so * the returned value may not be the same as in client side. *

* * @return the {@code i18n} property from the webcomponent */ protected JsonArray getI18nJsonArray() { return (JsonArray) getElement().getPropertyRaw("i18n"); } /** *

* Description copied from corresponding location in WebComponent: *

*

* An object used to localize this component. The properties are used e.g. * as the tooltips for the editor toolbar buttons. *

* * @param i18n * the JsonArray value to set */ protected void setI18n(JsonArray i18n) { getElement().setPropertyJson("i18n", i18n); } @DomEvent("change") public static class ChangeEvent> extends ComponentEvent { public ChangeEvent(R source, boolean fromClient) { super(source, fromClient); } } /** * Adds a listener for {@code change} events fired by the webcomponent. * * @param listener * the listener * @return a {@link Registration} for removing the event listener */ @SuppressWarnings({ "rawtypes", "unchecked" }) protected Registration addChangeListener( ComponentEventListener> listener) { return addListener(ChangeEvent.class, (ComponentEventListener) listener); } /** * Constructs a new GeneratedVaadinRichTextEditor component with the given * arguments. * * @param initialValue * the initial value to set to the value * @param defaultValue * the default value to use if the value isn't defined * @param elementPropertyType * the type of the element property * @param presentationToModel * a function that converts a string value to a model value * @param modelToPresentation * a function that converts a model value to a string value * @param

* the property type */ public

GeneratedVaadinRichTextEditor(T initialValue, T defaultValue, Class

elementPropertyType, SerializableFunction presentationToModel, SerializableFunction modelToPresentation) { super("value", defaultValue, elementPropertyType, presentationToModel, modelToPresentation); if (initialValue != null) { setModelValue(initialValue, false); setPresentationValue(initialValue); } } /** * Constructs a new GeneratedVaadinRichTextEditor component with the given * arguments. * * @param initialValue * the initial value to set to the value * @param defaultValue * the default value to use if the value isn't defined * @param acceptNullValues * whether null is accepted as a model value */ public GeneratedVaadinRichTextEditor(T initialValue, T defaultValue, boolean acceptNullValues) { super("value", defaultValue, acceptNullValues); if (initialValue != null) { setModelValue(initialValue, false); setPresentationValue(initialValue); } } /** * Constructs a new GeneratedVaadinRichTextEditor component with the given * arguments. * * @param initialValue * the initial value to set to the value * @param defaultValue * the default value to use if the value isn't defined * @param elementPropertyType * the type of the element property * @param presentationToModel * a function that accepts this component and a property value * and returns a model value * @param modelToPresentation * a function that accepts this component and a model value and * returns a property value * @param

* the property type */ public

GeneratedVaadinRichTextEditor(T initialValue, T defaultValue, Class

elementPropertyType, SerializableBiFunction presentationToModel, SerializableBiFunction modelToPresentation) { super("value", defaultValue, elementPropertyType, presentationToModel, modelToPresentation); if (initialValue != null) { setModelValue(initialValue, false); setPresentationValue(initialValue); } } /** * Default constructor. */ public GeneratedVaadinRichTextEditor() { this(null, null, null, (SerializableFunction) null, (SerializableFunction) null); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy