simple.js editor question

54 views
Skip to first unread message

ValdikSS

unread,
Aug 21, 2019, 1:40:42 PM8/21/19
to tiddly...@googlegroups.com
core/modules/editor/engines/simple.js contains unimplemented createTextOperation and executeTextOperation functions:

Create a blank structure representing a text operation
*/
SimpleEngine.prototype.createTextOperation = function() {
return null;
};

/*
Execute a text operation
*/
SimpleEngine.prototype.executeTextOperation = function(operation) {
};

Due to some SOP constraints in environment where TiddlyWiki is run (ZeroNet) it's not always possible to use framed.js editor. I've patched core/modules/widgets/edit-text.js to load only simple.js version editor and copy-pasted these functions from frames.js with minor modifications. It works without any problems.

I'm a beginner in JavaScript and not aware of possible problems introduced by this change. May I ask why these functions are not implemented? Is my fix is a proper fix? Could I commit it to the core? Visually everything seems to be OK, it works fine.


editor-simple-fix.txt
signature.asc

Jeremy Ruston

unread,
Aug 24, 2019, 5:26:42 AM8/24/19
to TiddlyWikiDev
Hi Vladik

> core/modules/editor/engines/simple.js contains unimplemented createTextOperation and executeTextOperation functions:

These functions aren’t implemented for the simple editor because the toolbar button mechanism doesn’t work properly without the iframe editor. The reason for the iframe editor is that with a simple textarea, clicking on a toolbar button loses the selection. Having said that, it sounds like you’ve got it working somehow?

Best wishes

Jeremy

>
> Create a blank structure representing a text operation
> */
> SimpleEngine.prototype.createTextOperation = function() {
> return null;
> };
>
> /*
> Execute a text operation
> */
> SimpleEngine.prototype.executeTextOperation = function(operation) {
> };
>
> Due to some SOP constraints in environment where TiddlyWiki is run (ZeroNet) it's not always possible to use framed.js editor. I've patched core/modules/widgets/edit-text.js to load only simple.js version editor and copy-pasted these functions from frames.js with minor modifications. It works without any problems.
>
> I'm a beginner in JavaScript and not aware of possible problems introduced by this change. May I ask why these functions are not implemented? Is my fix is a proper fix? Could I commit it to the core? Visually everything seems to be OK, it works fine.
>
>
> --
> You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/00f96b36-b86e-9644-69b6-5260c009230e%40valdikss.org.ru.
> <editor-simple-fix.txt>

ValdikSS ValdikSS

unread,
Aug 24, 2019, 1:49:57 PM8/24/19
to TiddlyWikiDev
On Saturday, August 24, 2019 at 12:26:42 PM UTC+3, Jeremy Ruston wrote:
Hi Vladik

> core/modules/editor/engines/simple.js contains unimplemented createTextOperation and executeTextOperation functions:

These functions aren’t implemented for the simple editor because the toolbar button mechanism doesn’t work properly without the iframe editor. The reason for the iframe editor is that with a simple textarea, clicking on a toolbar button loses the selection. Having said that, it sounds like you’ve got it working somehow?

Yes, I basically copy-pasted the implementation from framed.js with some minor editing (replaced iframe document with global document) and it worked out of the box. All the toolbar buttons work correctly. Tested in Firefox and Chromium.
 

Best wishes

Jeremy


Reply all
Reply to author
Forward
0 new messages