I've been trying to use the bundled word_paste.min.js to see if it helps with some complaints about copy&pasting from Word into XF.
Except I can't get it working to even determine if it would be useful.
The problem is the plugin throws an error on being loaded by the browser;
De-minifying the code gives;
Tracing back the call stack, it looks like this code is expecting
So how is this plugin supposed to be loaded?
Except I can't get it working to even determine if it would be useful.
I can inject the javascript via a template pre-render hook for the "editor" template, and the js is successfully included and the browser fetches it.
I've prepped javascript to enable the plugin;
PHP:
public static function editorTemplatePreRender(\XF\Template\Templater $templater, string &$type, string &$template, array &$params)
{
...
$templater->includeJs(['src' => 'vendor/froala/plugins/word_paste.min.js']);
}
Code:
$(document).on('editor:config', function(event, config, xfEditor) {
...
config.wordPasteModal = true;
config.wordPasteKeepFormatting = true;
The problem is the plugin throws an error on being loaded by the browser;
Code:
Uncaught TypeError: Cannot read property 'DEFAULTS' of undefined
at word_paste.min.js?_v=82104a58:formatted:12
at word_paste.min.js?_v=82104a58:formatted:8
at word_paste.min.js?_v=82104a58:formatted:9
JavaScript:
!function(e, t) {
"object" == typeof exports && "undefined" != typeof module ? t(require("froala-editor")) : "function" == typeof define && define.amd ? define(["froala-editor"], t) : t(e.FroalaEditor)
}(this, function(w) {
"use strict";
w = w && w.hasOwnProperty("default") ? w["default"] : w,
Object.assign(w.DEFAULTS, {
wordDeniedTags: [],
wordDeniedAttrs: [],
wordAllowedStyleProps: ["font-family", "font-size", "background", "color", "width", "text-align", "vertical-align", "background-color", "padding", "margin", "height", "margin-top", "margin-left", "margin-right", "margin-bottom", "text-decoration", "font-weight", "font-style", "text-indent", "border", "border-.*", "line-height", "list-style-type"],
wordPasteModal: !0,
wordPasteKeepFormatting: !0
}),
Tracing back the call stack, it looks like this code is expecting
document.FroalaEditor
to have contents.So how is this plugin supposed to be loaded?