How to completely omit an element when doing a dataDowncast in CKEditor5 - ckeditor5

I have a custom plugin and have a transient element that exists in the model, and also in the editor view. However, when I do a dataDowncast conversion, I want to completely omit the element from the data view.
If I omit the dataDowncast conversion completely, I get a conversion-model-consumable-not-consumed error.
If you are wondering why I need this. I am doing a custom upload support, and I am showing the upload progress in the editor. However, I don't want to save that upload progress element, as it is transient and only for improved user experience, and it gets replace with a 'real' element when the upload completes.
Any thoughts?

Related

How to insert custom inline javascript code in php phalcon framework

I want to insert from Controller in the end of some view's code like this
"<"script> setInterval(function(){ alert("Hello"); }, 3000);"<"/script>
How to do this?
There's multiple ways to do this in PhalconPHP. Depending on your needs, you might be able to get away with just:
$js='setInterval(function(){alert("Hello");},3000);';
$this->view->js=$js;
then from the view, you'd do:
<script><?php echo $js; ?></script>
If you need to insert the JavaScript into your top-level index.phtml from a nested view, the way to accomplish this is to first edit your ControllerBase.php and define a new collection:
$this->assets->collection('footer');
Then add a reference to the footer collection from your top-level index.phtml file:
<body>
<?php echo $this->getContent(); ?>
<?php $this->assets->outputJs('footer'); ?>
</body>
You could also use output('footer') instead if you just wanted a dynamic place in the document you can insert HTML of any kind. Note that a collection specializes in managing CSS and JavaScript, hence the outputJS method, but can also handle miscellaneous code for other purposes. There's also outputCSS, outputInlineJs, outputInlineCss, outputInline, and simply output. See:
http://php-phalcon-docs.readthedocs.org/en/latest/api/Phalcon_Assets_Manager.html
Then edit your ControllerBase.php to initialize the asset to an empty collection:
$this->assets->collection('footer');
(if you skip this step, your code will see errors if your top-level index.phtml file tries to output the contents of a non-existent collection if you never write to it, so always initialize it to an empty collection so it exists.)
Finally, from the controller you want to use, you'd do:
$this->assets->collection('footer')->addInlineJs($js);
where $js is your inline JavaScript, excluding the script tags.
You can also work with external JavaScript files by using
->addJs(...). By default it will be relative to your application directory, inserting a / automatically. If you dislike this functionality, you can set the second parameter to false then it will allow you to specify your own leading / or point your resources at another domain.
As far as the assets you can add to a collection, see:
https://docs.phalconphp.com/en/latest/api/Phalcon_Assets_Collection.html
Note that you can also add assets to your collection from your view and the changes would still appear in your top-most index.phtml.
It is also worth noting that you don't need to actually use collections, you can simply use assets without a collection, but I think collections are more powerful in that you get to name them so there's another level of separation in case you need to manage more than one kind of collection of data.
In terms of what you're trying to accomplish, if you're just trying to give the user a message, this is what Phalcon's flash is for, not to be confused with Adobe Flash which is for playing videos. Phalcon's flash is for flashing messages to the user such as error messages, or your form submit successfully kind of messages. See:
https://docs.phalconphp.com/en/latest/reference/flash.html
If you're still confused what flash is, a demo of what it's output is, you can see in the screenshot here: https://docs.phalconphp.com/en/latest/_images/invo-2.png
That is output of ->error(...) and ->notice(...) respectively. The flash component keeps track of a collection of the messages you'd like to show the user. Then once you're ready to display them to the user you'd call:
<?php echo $this->flash->output(); ?> from your view. It is best to make this call from your top-most template or a template which is always included in your top-most template such as your navigation template so you can easily display messages to the user. It is also useful for debugging. I'd suggest using twitter bootstrap for styling the flash output.
Some sample applications which you might find useful:
https://github.com/phalcon/invo
https://github.com/phalcon/vokuro
https://github.com/phalcon/website
https://github.com/phalcon/forum
Further reading:
https://docs.phalconphp.com/en/latest/index.html

What is the proper way to test mandatory field in selenium

I am testing my web application using Selenium. All the form validation in the web application is done by HTML5 and some JS(for safari browser). I want to know what is the proper way to test the form validation.
Currently I am using one approach, i.e Before I filled up a mandatory field I clicked on the submit button. If the page is not refreshed then I assume the form validation working correctly. But I think there should be a better approach to do it. I am unable to find any proper solution. Any suggestion will be highly appreciated.
I also go through this link. But it is not working for me because it is not enough to have required attribute (eg required attribute does not work in older Safari browser).
Rather than checking if the page is refreshed or not, you should instead expect that it is not and that a certain error message or field highlighting or something is applied to the current page. When in an error state, the input fields probably get given an extra class, or an error div/span might be added to the DOM, try checking for that sort of thing

How to add a custom image (<xh:img>) to PDF

We would like to add an image to our PDF in Orbeon. We explorered different tags and came up with tag. This worked the way we wanted but this tag keeps the PDF from building. We don't get any (visible) errors but a time-out occurs after couple of seconds.
To cross check: PDF build fine without the xh:img tag.
I was wondering what other options do we have. I thought about a PDF template but we would like to give the form author the option to choose his/hers own jpg from a web resource.
This is on 43PE.
User error yet we didn't change much after all.

How to change dojo locale after dojo loaded?

We need set locale in data-dojo-config before dojo loaded so that dojo.i18n will work with this locale. Is there any workaround that we can change this locale in dojo/_base/config after dojo loaded so that any further dojo.i18n call will work with this new locale?
I have a single page application, by carefully design, I already be able to recreate all my UI widgets dynamically anytime. I want to add a Select somewhere so that user can change languages on the fly. Currently the only solution I have is put a queryString locale='newLocale' at Url and force browser refresh. That works but everything User have done lost and with a fresh start. That's not what I want.
Any idea? I don't afraid some changes of dojo to make this happen since my application will be built as a single layer and deploy to customers.
According to dojo's documentation, you cannot change the locale once it's loaded. See this page from their documentation, the relevant line is:
Once Dojo is loaded, it is not possible to change the locale for the
page.
Your description of adding a new parameter is what I've done in this situation, you can specify the locale property on the dojoConfig object to override the default locale.
EDIT: There is an open bug for this use case, see https://bugs.dojotoolkit.org/ticket/17196. In that ticket there also appears to be a workaround that basically involves manually loading the resource file of the language you want to use and updating any text.
So, adapting their example (http://jsbin.com/aquviq/1/edit), this would run after you initiate a change locale action:
require(['dojo/i18n!dojo/nls/' + resourceModuleWithLocale], function (resource) {
/* in here, you must set all of the text manually to the values in the resource object */
});
It still seems like a lot of work, but I suppose that's one possible way to accomplish this.

Where can I read how to make web notifiers such as the StackExchange at the top left side of StackOverflow screen?

I'm not even sure what the name of that is to be able to make a search... but I would like to make those kind of things. Facebook has that too with the messages, notifications and friends requests. Thanks
I'm not sure if you expect anyone to give you a complete tutorial with source code included? :) You should probably do some digging around yourself, since a concrete answer on this could mean to write a few pages :)
How can you dig around?
Thé tool for a job like that is Firebug (IMO).
With bigger tasks like these it makes sense to try to split it up in smaller pieces.
Let's say you go for a widget like the user profile popup on SO.
you need some HTML to display in a popup: right click on any html element on the popup and click the 'inspect element' menu item. This brings you to the HTML tab in firebug. This allows you to figure out how the HTML is structured
you need some CSS to style that popup: when you're browsing the html structure, you might already have noticed that on the right side of it is the CSS that is applied to the active element
you might want to use some animation effects: for that you could use jquery. Have a look here to find out more on which effects are available and how they can be triggered. Fading is used in the profile popup on SO.
then you might ask yourself the question where SO get's that html structure from, right? To find out more about which server calls are made you can use the 'NET' tab in Firebug. (When you hover over your user name (only the first time?), then you should notice there's a call made to something like: http://stackoverflow.com/users/profile-link-stats?_=someLongNumberHere
In firebug you can then inspect the request and response. You should notice that the response is some HTML structure. This HTML structure is then inserted into the DOM.
Sooooo you can kinda glue it all together now:
the user hovers over his user name
the hovering triggers a server call (see step 4): use jquery hover to attach a handler to the user link. (subsequent hovers don't trigger that server call, so there needs to be a check to see if that profile popup was already loaded or not)
when the server call successfully returns (see jquery get), the returned html is inserted into the DOM and a fadeIn effect is triggered.
it seems a mouseout is used to fadeOut the popup
I HOPE this is the answer you were looking for. It took me a while ;)
You probably need to check out stackapps