Feature NPM Resource Changed PR-5.1-dev PR-5.2-dev Pending

User tests: Successful: Unsuccessful:

avatar brianteeman
brianteeman
18 Apr 2024

DRAFT - help requested @dgrammatiko @Fedik
I obviously have an error in the buildscripts (?) or most likely how I added the js to build/media_source/plg_editors_tinymce/js/plugins/paste_from_word/

The demo I built on codepen shows it working https://codepen.io/brianteeman/pen/RwOeyWL

Summary of Changes

When we upgraded to TinyMCE 6 with joomla 5.0 we missed that the "paste from word" functionality was removed from the paste plugin and now only exists in the non-free paste plugin.

This PR follows the advice from TinyMCE to implement a forked version of the original paste plugin with just the paste from word funtionality. https://github.com/pangaeatech/tinymce-paste-from-word-plugin

I consider the lack of paste from word to be a regression bug and therefore this PR is for 5.1.1 but I can see why others consider it a feature and should wait for 5.2. So I leave that to the maintainers to decided.

Testing Instructions

Use a sample word doc (for example from https://sample-videos.com/download-sample-doc-file.php or https://file-examples.com/index.php/sample-documents-download/sample-doc-download/)

Copy and paste the doc into Joomla. Save and then view the source

Actual result BEFORE applying this Pull Request

lots of mso tags etc in the source
example

<li class="MsoNormal" style="mso-list: l0 level1 lfo2; tab-stops: list 36.0pt;"><span lang="EN-US">First item of bulleted list. </span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo2; tab-stops: list 36.0pt;"><span lang="EN-US">Second item of bulleted list.</span></li>

Expected result AFTER applying this Pull Request

no mso tags in the source

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

574dde5 18 Apr 2024 avatar brianteeman js
9bed1bc 18 Apr 2024 avatar brianteeman tiny
avatar brianteeman brianteeman - open - 18 Apr 2024
avatar brianteeman brianteeman - change - 18 Apr 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 18 Apr 2024
Category Repository NPM Change JavaScript Front End Plugins
avatar dgrammatiko
dgrammatiko - comment - 19 Apr 2024

@brianteeman allow PRs in your cloned repo so I can sent you the code

avatar Fedik
Fedik - comment - 19 Apr 2024

I thought that the paste feature now is default for new tinymce.

If we want to "fork", we should do it from source:
https://github.com/tinymce/tinymce/blob/release/5.10/modules/tinymce/src/plugins/paste/main/ts/Plugin.ts
The same need to do for "template":
https://github.com/tinymce/tinymce/blob/release/5.10/modules/tinymce/src/plugins/template/main/ts/Plugin.ts

Need to complie ts to js, and copy non-minified version.
I had no time for that, maybe will look later or Dimitris will be faster ?

avatar dgrammatiko
dgrammatiko - comment - 19 Apr 2024

If we want to "fork", we should do it from source:

@Fedik if someone already has a package for this then why not use it. TS will be pain to get in the Joomla repo

avatar Fedik
Fedik - comment - 19 Apr 2024

No, no TS, compile then add.
Well, can also use some existing forks.

avatar dgrammatiko
dgrammatiko - comment - 19 Apr 2024

No, no TS, compile then add.

That means we need a repo for these plugins. Not a bad idea but:

  • I don't have permissions to do that
  • One more repo and judging from the custom-elements repo updates would be at the best sporadic (basically no updates)

FWIW this PR just needs:

  • npm install -S @pangaeatech/tinymce-paste-from-word-plugin
  • add a file build/media_source/plg_editors_tinymce/js/plugins/paste_from_word/plugin.es6.js with contents:
import '@pangaeatech/tinymce-paste-from-word-plugin';
  • delete the file build/media_source/plg_editors_tinymce/js/plugins/paste_from_word/plugin.min.js
avatar Fedik
Fedik - comment - 19 Apr 2024

That means we need a repo for these plugins.

No, just as in good old days, copy the js file and call it done ?
"One time compile" :neckbeard:

avatar brianteeman
brianteeman - comment - 19 Apr 2024

I thought that the paste feature now is default for new tinymce.

No that was the mistake we made. Paste is a default feature but without the paste from word.

If we want to "fork", we should do it from source:

No the correct way is to use the repo I linked to. As explained by tinymce tinymce/tinymce#7487 it is not a simple fork. and the linked repo as done what they said should be done.

FWIW this PR just needs:

Ah - I tried it that way before but I missed the

add a file build/media_source/plg_editors_tinymce/js/plugins/paste_from_word/plugin.es6.js with contents:
import '@pangaeatech/tinymce-paste-from-word-plugin';

I will do that now and see.

avatar dgrammatiko
dgrammatiko - comment - 19 Apr 2024

Ah yeah the good ol' days... We can revert all those confusing NPM build steps and have the code version directly in the repo, what could go wrong

a7a0607 19 Apr 2024 avatar brianteeman npm
avatar brianteeman brianteeman - change - 19 Apr 2024
Labels Added: NPM Resource Changed PR-5.1-dev
avatar brianteeman
brianteeman - comment - 19 Apr 2024

@dgrammatiko I have done what I believe you are suggesting but I must be missing something as after the build the folder media\plg_editors_tinymce\js\plugins\paste_from_word is empty

avatar dgrammatiko
dgrammatiko - comment - 19 Apr 2024

@brianteeman you have a typo in the filename: build/media_source/plg_editors_tinymce/js/plugins/paste_from_word/plugin.es6.js es6 not e6

avatar brianteeman
brianteeman - comment - 19 Apr 2024

@dgrammatiko please can you check out this pr (not code review) something isnt correct and I cant see what. Just look at the console errors

avatar richard67 richard67 - change - 19 Apr 2024
Title
[5.1] Tinymce past from word
[5.1] Tinymce paste from word
avatar richard67 richard67 - edited - 19 Apr 2024
avatar HLeithner
HLeithner - comment - 24 Apr 2024

This pull request has been automatically rebased to 5.2-dev.

avatar HLeithner HLeithner - change - 24 Apr 2024
Title
[5.1] Tinymce paste from word
[5.2] Tinymce paste from word
avatar HLeithner HLeithner - edited - 24 Apr 2024
avatar brianteeman brianteeman - change - 16 May 2024
Labels Added: Feature PR-5.2-dev
e27580f 16 May 2024 avatar brianteeman move
avatar brianteeman
brianteeman - comment - 16 May 2024

@dgrammatiko @Fedik could you take a look at this please. I must be missing something obvious. The js is correctly being loaded by
$wa->useScript('plg_editors_tinymce.paste_from_word');

but if i try to init the plugin with
$plugins[] = 'paste_from_word';

it will try to additionaly load the plugin from /media/vendor/tinymce/plugins/paste_from_word/plugin.min.js where it does not exist and gives a 404

No matter what I try I cannot get the plugin to load and initialise

avatar Fedik
Fedik - comment - 16 May 2024

There some error with this plugin.
I got Cannot read properties of undefined (reading 'tinymce') from this plugin.

Need some time to debug.

Does it work outside of Joomla? :)

avatar Fedik
Fedik - comment - 17 May 2024

Sommething with our build script (rollup corrupting the code) and the plugin script itself (it does not provide ES module).

When I copy their file node_modules/@pangaeatech/tinymce-paste-from-word-plugin/index.js to media/plg_editors_tinymce/js/plugins/paste_from_word/plugin.min.js
And change "type": "module" to "defer": true in asset defination. then it works.

Complicated :)

avatar brianteeman
brianteeman - comment - 17 May 2024

still no go for me

avatar brianteeman brianteeman - change - 27 Jun 2024
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2024-06-27 05:23:29
Closed_By brianteeman
avatar brianteeman brianteeman - close - 27 Jun 2024

Add a Comment

Login with GitHub to post a comment