It's possible to have CKEditor 5 getData() return custom attributes? - ckeditor5

I've succesfully managed implementing custom attributes creating upcasts and downcasts converters; all seems to work but I'm now blocked on how to get the actual data back from the editor; if I use:
editor.getData()
I got the html tag (an <img> one) without the custom attributes while in the CKEditor Inspector I can see the attributes in both the model and the view.
How I can retrieve the data with the custom attributes?

Related

Access lastMeasurement in HTML widget

I want to reference the last measurment of a device in a HTML widget.
The page https://www.cumulocity.com/guides/users-guide/cockpit/ give samples to access these.
My attempt to show the TemperatureMeasurement doesn't return a result:
{{devices[391].lastMeasurement.c8y_TemperatureMeasurement.T}}
This is currently not possible from the HTML widget. You can only access the data inside the managedObject from there.
Maybe try using the SCADA widget for that and create your custom content as SVG instead of HTML.

Adding custom data list to alsfresco share

i am a newbie in Alfresco. I have created custom datalist models, context model and also configured the share config xml file and everything is working well. How ever the datalist is not showing when i log in alfresco. What should i do then.
You should be able to create one of your custom datalists on the page :
http://"myhostandport"/share/page/site/"mysite"/data-lists
Does it show up there?
If not:
-Did you declare your datalist content model as a bean with parent="dictionaryModelBootstrap"?
-Does your content model type extend dl:dataListItem
-You can find all the datalists of your type with this kind of query: #dl\:dataListItemType:'myprefix\:mydatalisttype'

asp.net MVC - #HTML.Raw writes out model to page

I have an ASP.net MVC 4 (Razor) application. We are using Dojo's 1.9 Gridx to display data.
My controller returns my model to the view. To work with the model on the client side, I usually will assign it to javascript variable as so:
var _model = #Html.Raw(Json.Encode(Model));
I can then pass the _model to Dojo's Gridx control. What I don't like is if you view the source in a browser, the data in _model is visible on the page. Is seeing the _model data in the browser by design? or is there a better way to do this?
Another way to do it (not sure if it's better), is to send your model to your view via the standard #model MyModel, serialize it to JSON and set it as a value of an input element, and then grab the value of the input via Javascript. Then you can destroy/remove the input element, and that data won't be visible in the browser source anymore.
Example:
In Razor View
#model MyModel
<input type="hidden" id="myViewModel" value="#Newtonsoft.Json.JsonConvert.SerializeObject(Model)" />
In Your Javascrip File
$(function(){
var _model = JSON.parse($('#myViewModel').val());
$('#myViewModel').remove();
});
Doing it your way or this way, the entirety of the model's data will still be in the page's source (and hence visible to anyone looking) - even if it's for a short amount of time. Always remember that when considering security for your application.

jQuery Mobile does not process elements in Partial View

I'm converting my site from using jQueryUI to jQuery Mobile, and I'm having some trouble.
I have a page that lets users add new timesheet entries. They click the "Add" button and it retrieves a Partial View from the server right onto the page.
The problem is that jQuery Mobile is not applying to any of the elements in the Partial View.
How can I force jQuery Mobile to process my elements after they've been inserted into the page?
The short answer is that you can just trigger the create method on the parent element of where you inserting your partial view.
For example $('#container').trigger( "create" );
Alternatively most widgets can be manually initialized by calling them on the element, for example for a listview: $('#myListview').listview(). This can be useful if you have only a few elements that need to be enhaced and you don't want to traverse all the child elements of the container. You should also know that for many widgets there is also a refresh method which you can call if you add elements to it after it has already been initialized for example $('#myListview').listview('refresh).
Also have a look at the following Q & A from the JQM docs which deals with this issue and for an explanation as to why it is necessary to call these methods.
Question: Content injected into a page is not enhanced.
Answer:
jQuery Mobile has no way to know when you have injected content into a
page. To let jQuery Mobile know you have injected content that must be
enhanced, you need to either make sure the plugins are called to
enhance the new elements or trigger("create") on the parent container
so you don't have to call each plugin manually.

ASP.NET MVC Set texts in the View or in the Controller

What is the best practice in MVC (for testing, SOC and scaffolding) for setting texts (for exemple page title, h1,h2..)
Is it better to do it in the controlle, fill a viewmodel and send it to the view
or directly typing texts in the view?
Also I will propably use ressouces files for global texts (like button text, menu texts) and local ressouces for view specific texts.
The view is merely to present the output to the user. Depending on your requirement you can either:
1) Type the text in the view directly <h2>Hello World</h2> (for static content that will not change)
The latter two options are for ideal for dynamic content, where the content could be received from a database or some additional input.
2) Use the ViewBag to pass information to the view (in which case you would set it in the controller ie. ViewBag.HelloWorld = "Hello World" : <h2>#ViewBag.HelloWorld</h2>
3) Use a model to pass the information to your view. This should be your preferred option where possible. In your specific case you could use the controller to retrieve the content from your global resources, bind it to the model and pass it to the view.
The logic on where to get the data should come from the controller and the View's function should be to merely display it.
I recommend binding properties on the viewModel to the UI.
This is not only more testable, but it's also more flexible. It makes it easier to implement features like mult language support etc.
I recommend avoiding hard coding text in the markup if you can