How to retrieve and display Draft-js raw object in a react component? - draftjs

Although the author of Draft-js said that he "didn't want to release any conversion utilities" (https://github.com/facebook/draft-js/issues/62),
I still want to ask that after saving raw object into database, how can we conveniently retrieve and display the raw object in our react component?
And how can we customized the display effect, to be different with effect of displaying it using Draft-js Editor component with the readOnly prop? Because we often want to customize the display effect, for the display effect is always different with the effect when we were editing in the editor.

We will be facing this issue shortly. It's been our plan to simply provide a different blockRendererFn and possibly a different blockStyleFn to the Editor when rendering on front of the site (in readOnly=true mode). That way the bits of UI needed for authoring the custom content blocks will not exist.

Related

Using contentEditable inside Flutter's webview

For an application I need a document that is able to record and display among each other any type (text, audio, video, HTML, maybe PDF) that the user enters or inserts.
At first I wanted to use a listview with different types of widgets (textfields, video via plugin, webview via plugin etc.), but it seemed much too complicated to me. For example, how could I have selected parts of a text field, the following image and parts of the next text field at the same time?
Actually, the document format that I need already exists: HTML. If you set the attribute "contentEditable" accordingly, it is not a big problem to let the user change the document in any way with the help of JS. And this is exactly my problem: If I use the Webview (Developer Preview) of the Flutter team (webview_flutter), the attribute "contentEditable" is apparently ignored. I can't mark text and no keyboard appears.
Am I doing something wrong or does the plugin not (yet) support this attribute? Otherwise, is there an alternative? I have to say that I am an absolute beginner in Flutter.

Visio automatic hyperlink for common label

I have a wiring diagram drawn in visio that contains many wires (lines) spread over several pages. To follow a certain wire, I often have to jump around multiple pages. The wires always have the same text/label even when propagated to different pages. Normally, I use the find-in-files and type in the specific label I'm hunting for.
It would be even better if I could just click on the wire when it goes off page and a hyperlink would take my to the appropriate place on the appropriate page.
I know how to create hyperlinks manually, but there are a lot of signals and I'd like to somehow automate this, hinged by the fact that the source/destination share a common label.
Is this possible?
If you have rules, where the corresponding shape (link) resides, then you can set up the hyperlink via a SETF(Getref(... formula.
Otherwise, you could use VBA to find the corresponding shape by parsing the whole document and inserting the hyperlink automatically.
HTH,Y.

Copy presentation details and data from a page to a placeholder of another page on the fly in sitecore 8.1

I have a requirement from my customer where I need to make the footer of the website dynamic in terms of adding sublayouts in footer placeholders via page editor by the Content Author.
The footer shall consist of:
One content slot - to which any sublayout/sublayouts like grid component or rich text can be added.
I want to add a new placeholder 'ContentSlotPH' to my footer which picks up its presentation details and data from a common page at "/sitecore/Content/Common/Footers/FooterContent/" ( where I have added my sublayouts like grid/richtext for the footer); and shall apply to all the pages of the website where the footer is present.
I want this change to be visible on the fly so that in future if the presentation details on FooterContent page change, new presentation and data gets applied to the ContentSlotPH of the footer.
Can someone help me in implementing this?
This functionality is not available out of the box unfortunately, the only way to achieve it with standard features (as Anton mentions in the comments) is to set them as presentation details on the standard values of a base template.
Unfortunately, this is not user friendly or editable through the Experience Editor (out of the box). It would also mean giving Content Editors write access to the templates and standard values, something that is normally locked down since making a mistake could cause exceptions especially on a production system.
Instead you could look to utilise Sitecore Placeholder Fallback. This will allow you to set up the headers/footers on a top level page and then any children will fallback to use the renderings in the placeholder from a parent item if they have not been set.
We have tried to approach this problem by using components that have presentation details on them. We call these Content Blocks, but other accelerators have different names for them with similar functionality. Essentially, this becomes a 'page inside a page'. You add your component to the template and reference a central datasource which has your footer datasource (including presentation details).
This allows for authors to have access to edit the footer by editing the footer component datasource without accessing template details.
Check out my Sitecore Base Layouts project:
http://www.awareweb.com/resources/video?vid=7d52fef2a67c453fa38dd092bd9ae7e2&
https://github.com/BenGGolden/Sitecore.BaseLayouts

Binding to custom built control according to different data

Here's the issue, I build a special book reader/browser (For holy quran), my code behind loads the page and constructs how it should look. and then it should bind that look to a some kind of data-bindable custom control to view it properly. the problem is, the look differs from page to page, so I cannot bind to a certain control or wrap panel.
here's how it generally looks:
The decorative border top of the page is always there at any page, it indicates the part and chapter the viewer is in.
If you're starting a new chapter it have additional image under that decorative border or anywhere in the page (there can be multiple chapters in the same page) something like this
or this:
The normal text is not an issue, it's just a special font, however, I put each individual word in its own text block for reasons of user selection by word.
The issue here is, given the previous information, and knowing how random it is to place the decoration picture or the amount of words (text blocks) per page. how can I bind that to some kind of view to separate the view from the VM and Engine that builds the page.
my past solution was to actually build everything in the VM in a wrappanel built inside a scrollviewer having lots of textblocks and images according to the page. but that's naiive solution. I want to rebuild that in a more professional separated way. I also want to do this for Windows RT beside Windows phone so I need to reuse the code behind in a Portable class library.
I think all you need to do is slightly adjust your current design. So perhaps have a VM that represents the entire content, and that would have a Collection of say Pages or Sections. A second VM would represent the Page/Section, allowing you to create a property for the WrapPanel content (i.e. the words) and another property for the Header and or other things.
In the View you would have the scrollviewer and bind to the main VM collection. Then create another View or DataTemplate that represents the Page/Section.
You should be able to do this is a strict MVVM sense quite easily and it will be dynamic based on the content.
You could even cater for advanced scenarios where each section has a different template/view.

AEM/CQ5 how to share component values?

I want to have a header component that is shared across multiple page rendering components. The header component has a text label. How do I make the value of this text label available to all page components.
Do I have to make the path in the <cq:include> to a common format?
Design mode, if properly understood, can work quite well. However, it doesn't replicate content in the same manner as page activation, and thus can be confusing for your authors. Also, the sharing model is limited to the exact page type - which may or may not be the granularity you desire.
From CQ5's Best Practices (https://dev.day.com/docs/en/cq/current/developing/developing_guidelines_bestpractices.html), they strongly encourage the paragraph system (iparsys to inherit/share). iparsys named the same can be shared across different page templates (while design mode will only apply to a single template type).
I can archive that by creating a design dialog that is similar to dialog (http://dev.day.com/docs/en/cq/5-6/developing/components.html#Dialogs) under the header component. You add the text label field to design dialog. And to enter value for the field, you switch the page to the design mode and click on Edit button on the top of the component. The entered value will be available to all pages that contain the header component.
Note: design dialog will be named as design_dialog
This functionality is now offered in ACS AEM Commons as Shared Component Properties - http://adobe-consulting-services.github.io/acs-aem-commons/features/shared-component-properties.html
Supports standard content activation and internationalization (values stored below the homepage) and anything else you would expect from content.
If the component is baked in the template(i,e page rendering component), yes you can make the <cq:include> path attribute to point to some common place where the data for this is stored and all the pages irrespective of , type of the template can get the values configured.
You can create header component and then include it using <cq:include> in base template/page. This base template/page will be inherited by all other templates. This way the header once configured in base page is availble through out different templates/page components.
If the goal is to share "across multiple page rendering components" the design dialog will only help if the page share the same rendering component.
If you want to have the header component displayed in a page and all its subpages, then you should use iparsys.
If you just want to reuse the properties of that header component, then it needs to have a fixed path (cq:include in a page component) and then you can reference the properties you need in other page rendering components. I would not suggest that approach since it breaks the idea of having a component. Everything becomes tightly coupled.
What you could also do is save those properties at the page level (some top parent page) and then use InheritanceValueMap in the subpages to read those properties.