Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#49 2021-02-06 00:04:15

Myusername
Member
Registered: 2019-12-12
Posts: 109

Re: wysiwyg editor

It is likely that I do not create anything for the community, I do not program as well. But of course, I can do that, gaekwad.

Bloke, take a curiosity out of me, I’m just trying to learn, don’t laugh at me haha. But in this case here, codejar is using export in javascript. Thus, incorporating it directly will not work at first. Okay, can I download the file, remove export, and then embed it? In my understanding, I could do that, but things didn’t work. It seems that there is something more than just removing “export” and using it in a standard script tag, I mean without type="module". Well, I don’t know. If I’m leaving something behind, tell me.

But, I noticed that when I do it the way you recommended me, a file is created in the plugin folder: data.txp. So I was wondering, is there any way (I mean easy and recommended) to create a .js file, instead of .txp, in the plugin folder? The goal is to use the file externally using import, as in the codejar documentation.

Last edited by Myusername (2021-02-06 00:05:05)

Offline

#50 2021-02-06 00:30:44

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,367
Website GitHub

Re: wysiwyg editor

The data.txp is just a place to store whatever is in the data column on disk. We use .txp because we don’t know what the file might be. It could be JSON, it could be a concatenation of a bunch of things, it could be some scripts, some CSS, anything.

I don’t know enough about JavaScript export and modules, unfortunately. Maybe the rest of the code relies on it being imported that way? I don’t know as I didn’t look at the code in depth.

There is absolutely nothing stopping you from storing the code inside the plugin (as above in the ‘data’ array element, or just stashed in a variable inside the code) but instead of reading it out at runtime using fetchData() you could instead hook into Txp’s ‘install’ lifecycle event. So when the plugin is installed/activated it runs a function that extracts the contents and writes it to disk as a .js file. Could be in the plugin’s own subdir or anywhere you like. Then you can reference it directly using the PLUGINPATH constant and the plugin’s name as file path.

Alternatively, you could write the plugin as normal but instead of distributing it as a .txt file or a .php file you could distribute it as a .zip and bundle up the codejar with it. When people use the Browse… thing in the Plugins panel and choose a .zip, any files inside that are not our PHP standard plugin template or manifest or .textile etc, will just be copied verbatim into the plugin’s subdir.

Txp 4.9.0 handles this much better but that’s not out yet :)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#51 2021-02-06 10:44:14

Myusername
Member
Registered: 2019-12-12
Posts: 109

Re: wysiwyg editor

Bloke wrote #328567:

any files inside that are not our PHP standard plugin template or manifest or .textile etc, will just be copied verbatim into the plugin’s subdir.

As I understand it, I need to package just the plugin template together with the .js file, and send it as a .zip, right?

But I did it and something went wrong. The plugin template is not interpreted.

manifest or some other file is necessary?

Offline

#52 2021-02-06 11:10:24

etc
Developer
Registered: 2010-11-11
Posts: 4,323
Website GitHub

Re: wysiwyg editor

Myusername wrote #328570:

manifest or some other file is necessary?

Yes, currently the installer parses only stand-alone .php files (improvements to come). You’d need to split its content as shown here when zipping. An example of manifest.json:

{
  "description": "ProseMirror Editor",
  "version": "0.8",
  "author": "Me Myself",
  "author_uri": "https://github.com/bloatware/",
  "type": 4
}

Offline

#53 2021-02-06 13:10:02

Myusername
Member
Registered: 2019-12-12
Posts: 109

Re: wysiwyg editor

Right, thanks. The .zip file is here.

Offline

#54 2021-02-12 14:12:46

Myusername
Member
Registered: 2019-12-12
Posts: 109

Re: wysiwyg editor

look. What do you think, has potential?

obs: ctrl+b and ctrl+i are working too

edit: I think it is perfectly possible to switch between textile and markdown. You only need to load a markdown library (like textile.js) for the visualization and then update the inserts (bold, italic and etc.). Would it be useful?

Last edited by Myusername (2021-02-12 14:19:44)

Offline

#55 2021-02-12 14:39:20

etc
Developer
Registered: 2010-11-11
Posts: 4,323
Website GitHub

Re: wysiwyg editor

Very nice, though it must be tested with large texts. It would also be nice if in a ** list pressing enter added a new ** item.

Offline

Board footer

Powered by FluxBB