In wagtail admin RichTextField(), I need to have support for a RTL language.
I see Draftail it self support this via textDirectionality.
What is the best way to add RTL support in wagtail RichTextField()?
Here, wagtail docs suggests using register_rich_text_features hook to limit features of the editor. But I couldn't find anything about adding textDirectionality to it.
Text directionality will be based on the characters within the editor. So you do not have to do anything. Draftail is Draft.js and the Draft.js documentation says:
textDirectionality?: DraftTextDirectionality
Optionally set the overriding text directionality for this editor. The values include 'RTL' for right-to-left text, like Hebrew or Arabic, and 'LTR' for left-to-right text, like English or Spanish. This directionality will apply to the entire contents, regardless of default text direction for input text.
If this value is not set, text directionality will be based on the characters within the editor, on a per-block basis.
Source: https://draftjs.org/docs/api-reference-editor.html#textdirectionality
I checked it:
At the moment all options are ignored except features. See Wagtail source code wagtail/admin/rich_text/editors/draftail/__init__.py:20
class DraftailRichTextArea(widgets.HiddenInput):
...
def __init__(self, *args, **kwargs):
# note: this constructor will receive an 'options' kwarg taken from the WAGTAILADMIN_RICH_TEXT_EDITORS setting,
# but we don't currently recognise any options from there (other than 'features', which is passed here as a separate kwarg)
kwargs.pop('options', None)
self.options = {}
If you require more control, you can always override the widget template. See wagtail/admin/templates/wagtailadmin/widgets/draftail_rich_text_area.html
Related
I am trying to format the content of 'Text Area' when using WordPress's Advanced Custom Fields. I am using React to build the project.
In an attempt to debug, I have been following this documentation and set my options to resemble the image referenced. Including Text Area as one of my custom fields and setting the New Lines option to Automatically add paragraphs
The documentation then goes on to show an example using PHP to render the content.
I am using graphQL to fetch my data, and delivering the contents as follows:
<div className="media-description-area">
{this.props.activeDescription}
</div>
with activeDescription being destructured from the object that the GraphQL request delivers.
The text as its being set in the field itself looks like this, with spacing included:
The formatting tags are being rendered directly into the string itself, this how it is appearing in the document:
Does anyone know how why this is? I am referring to the field directly so it appears as this formatting is being delivered from WordPress itself
activeDescription: objects[0].items[0].projectDescription,
Thank You
I have a page template that in webcenter portal with footer with 2 output text which will be rendered depending on the selected language from the language task flow.
I have custom template which I've created with the jdeveloper
and had put the follwing output label:
<af:outputFormatted id ="copyright" rendered="# {facesContext.externalContext.requestLocale} eq 'en'" value="the english text" />
<af:outputFormatted id ="copyright" rendered="#{facesContext.externalContext.requestLocale} eq 'ar'" value="the arabic text" />
And this El expression always return false
so how to render this components depending on the selected language?
The issue is that you are closing your el expression too soon ("requestLocale }") . To fix it, replace :
<af:outputFormatted id="copyright" rendered="#{facesContext.externalContext.requestLocale} eq 'en'" value="the english text" />
by
<af:outputFormatted id="copyright" rendered="#{facesContext.externalContext.requestLocale eq 'en'}" value="the english text" />
Or, as an alternative solution, you can have only one outputFormatted with all values like this :
<af:outputFormatted id="copyright" value="#{facesContext.externalContext.requestLocale eq 'en' ? 'the english text':(facesContext.externalContext.requestLocale eq 'ar' ? 'the arabic text' : 'Default text')}" />
However if you are looking for a translation functionnality in ADF you should go for a translation bundle file as explain in the documentation here : https://docs.oracle.com/cd/E15051_01/web.1111/b31973/af_global.htm#ADFUI425
Internationalization is the process of designing and developing products for easy adaptation to specific local languages and cultures. Localization is the process of adapting a product for a specific local language or culture by translating text and adding locale-specific components. A successfully localized application will appear to have been developed within the local culture. JDeveloper supports easy localization of ADF Faces components using the abstract class java.util.ResourceBundle to provide locale-specific resources.
When your application will be viewed by users in more than one
country, you can configure your JSF page or application to use
different locales so that it displays the correct language for the
language setting of a user's browser. For example, if you know your
page will be viewed in Italy, you can localize your page so that when
a user's browser is set to use the Italian language, text strings in
the browser page will appear in Italian.
ADF Faces components may include text that is part of the component,
for example the af:table component uses the resource string
af_table.LABEL_FETCHING for the message text that is displayed in the
browser while the table is fetching data during the initial load of
data or while the table is being scrolled. JDeveloper provides
automatic translation of these text resources into 28 languages. These
text resources are referenced in a resource bundle. If you set the
browser to use the language in Italy, any text contained within the
components will automatically be displayed in Italian. For more
information on skins and resource bundles, see Chapter 20,
"Customizing the Appearance Using Styles and Skins".
For any text you add to a component, for example if you define the
label of an af:commandButton component by setting the text attribute,
you must provide a resource bundle that holds the actual text, create
a version of the resource bundle for each locale, and add a
element to define default and support locales in the
application's faces-config.xml file. You must also add a
element to your application's faces-config.xml file
in order to make the resource bundles available to all the pages in
your application. Once you have configured and registered a resource
bundle, the Expression Language (EL) editor will display the key from
the bundle, making it easier to reference the bundle in application
pages.
To simplify the process of creating text resources for text you add to
ADF components, JDeveloper supports automatic resource bundle
synchronization for any translatable string in the visual editor. When
you edit components directly in the visual editor or in the Property
Inspector, text resources are automatically created in the base
resource bundle.
I added one field which is of type text as single line. Now I need to make some
of the text as underline.for example:-
He is a good employee.
I want underline in employee text. How can I add that in contentful?
👋🏻
When you're using the Markdown editor the problem the problem is not with Contentful but rather the markdown specs themselves. They do not provide the "underline" functionality.
The question about underline is a common question. The idea of markdown is to only care about content and not really the representation (e.g. "bold" translates to the html strong element which stands syntactically for important parts) though.
IMO underlined text can also be confused with links too easily.
If you have to make this work you can either bring in inline HTML (has the downside that you'll loose cross-platform compatibility because not every system can deal with HTML) or you handle the underline functionality in your application consuming Contentful with some CSS for example.
E.g. assuming that you want to highlight something in your application/website I could see that the "bold"/"strong" meaning could work for you.
Overall rule of thumb with markdown is thinking of the document structure and content rather then it's appearance. "These are important words in this paragraph" (👍) vs. "These are words that should be underlined" (👎).
In Contentful write the text under Markdown as:-
He is a good <u>employee</u>
Now in our reactjs application we can write:-
dangerouslySetInnerHTML={{
__html: employee.childMarkdownRemark.html,
}}
Hence if we render the output in the childMardownRemark.html under dangerouslySetInnerHTML then employee will come as underline in our UI.
I am trying to add links in the form 555-555-555 arbitrarily into paragraphs of text on my wagtail site. These phone numbers are currently peppered throughout the site as plain text, but I want to convert them to links.
I found this old wagtail github issue where they explained why they would not add them, but the 'Special-purpose pages' use case they described seems to be different than mine: my site has these numbers in paragraphs of text on most of the content pages (blog, product, marketing, etc).
Can anyone explain how I can add telephone links that can be used throughout the site?
I am using wagtail 1.x
To have telephone link within rich text, you'll need to create a plugin for Hallo.js. Have a look at the documentation and how Wagtail 1.13 creates and register such plugins.
Be aware though that it's usually quite involved and that Wagtail 2.0 rich text editor is now Draftail and Hallo.js is deprecated. Therefore, if you create a Hallo.js plugin and upgrade to Wagtail 2.0, you'll have to add some configuration to continue using Hallo.js or recreate the plugin for Draftail.
FWIW, if you are interested in having a look at what would be involved with creating an plugin for Draftail, you'll need to create an entity (also note that the API for creating entities should receive some enhancements in Wagtail 2.2).
With Raw HTML there is nothing to prevent editors from inserting malicious scripts into the page. Do not use this block. http://docs.wagtail.io/en/v2.1/topics/streamfield.html#rawhtmlblock
A workaround would be a custom filter. Eg:
{{ self.text|richtext|phonify }}
In your templatetags.py:
>>> def phonify(val):
... for tel in re.findall(r'tel:(\d+)', val):
... tag = '{}'.format(tel, tel)
... val = val.replace('tel:{}'.format(tel), tag)
... return val
...
>>> phonify('Hello tel:123 world tel:456!')
'Hello 123 world 456!'
>>>
Now you can instruct editors (via help_text) to add phone numbers like tel:5555555555.
This example does not handle - and +1. But if you figure that out, I'll update the answer ;)
I ended up chopping up my paragraphs and including raw html where I needed to add the tel links. A bit tedious, and the styles were slightly different on some pages, but shorter than doing it any other way.
I'm building a CakePHP application that involves forms, and I'm looking for a way to remove the asterisk from required fields. I have several input fields that are required, but I do not want the asterisk to show.
I've tried using 'required'=>false, but that makes the field optional as well as removing the asterisk. I just want to remove the asterisk; the field needs to remain required.
You could modify the css that adds that. I've made changes in my css, so I'm not sure if it's the one that comes out of the box anymore (for that matter, I don't know if you are using the one that comes out of the box), but the css that adds those asterisk(s?) on my form is
label.required:after {
color: #EE3322;
content: "*";
display: inline;
}
And you should just replace that content:"*" with
content: "";
Now, if your css isn't the same as mine, inspect the label element, and look for a similar line (it's probably using a content: "*", so you know what you have to look for).
If you want to delete the asterisks for a single view, add an inline style in the view. If it is for the whole application, delete the line in the css file.