001/* 002 * Copyright 2017 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.core.ui.widgets.richtext; 017 018import java.util.Set; 019 020/** 021 * A tag configuration for a {@link RichTextConfiguration} 022 */ 023public interface RichTextConfigurationTag 024{ 025 /** 026 * What to do if this tag is empty? 027 */ 028 public enum EMPTY_TAG 029 { 030 /** Remove the tag. <code><span>content</span></code> => <code>content</code> */ 031 REMOVE_EMPTY_ATTRIBUTES, 032 /** Remove the tag. <code><span></span></code> => */ 033 REMOVE_EMPTY_CONTENT, 034 /** Padding the tag. <code><span></span></code> => <code><span>&nbsp;</span></code> */ 035 PADDING, 036 /** Keep open the tag. <code><span></span></code> => <code><span></span></code> */ 037 OPEN, 038 /** Auto-close the tag. <code><span></span></code> => <code><span/></code> */ 039 CLOSE 040 } 041 042 /** 043 * Get the tag name. Such as 'span'. 044 * @return The tag name. Cannot be empty or null. 045 */ 046 public String getTag(); 047 048 /** 049 * Determine the action to do when this tag is empty. 050 * @return The behavior. Cannot be null. 051 */ 052 public EMPTY_TAG onEmptyTag(); 053 054 /** 055 * The tags that should be replaced by this one. For example, "b" should be replaced by "strong". 056 * Note that if "b" is handled otherwise, it will not be replaced. 057 * @return A non null set of tags. 058 */ 059 public Set<String> getSynonyms(); 060 061 /** 062 * Get the attributes handled on this tag 063 * @return A non null set of attributes. 064 */ 065 public Set<RichTextConfigurationAttribute> getAttributes(); 066}