npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pangaeatech/tinymce-paste-from-word-lib

v1.3.2

Published

TinyMCE 6.x Plugin to add support for pasting from Microsoft Word documents

Downloads

435

Readme

TinyMCE Paste from Word Plugin

This plugin adds the open-source Paste from Word functionality from the 5.x branch of TinyMCE as a plugin for the 6.x branch. The goal of this project is not to replace the premium PowerPaste plugin, but to allow users who would otherwise stay on the 5.x branch solely for paste-from-word support to upgrade to the 6.x branch.

END-OF-SUPPORT NOTICE

This plugin will not support the 7.x or later branches of TinyMCE due to their licensing changes. Therefore, this repository became READ-ONLY when TinyMCE 6.x support ended in Oct 2024.

Comparison with PowerPaste

| Feature | This Plugin | PowerPaste | | :-------------------------------- | :---------: | :--------: | | Automatically cleans up content | ✔ | ✔ | | Supports embedded images | - | ✔ | | Paste from Microsoft Word | ✔ | ✔ | | Paste from Microsoft Word online | ✔ | ✔ | | Paste from Microsoft Excel | - | ✔ | | Paste from Microsoft Excel online | - | - | | Paste from Google Docs | ✔ | ✔ | | Paste from Google Sheets | - | - |

Usage

Option 1: CDN Hosted

  1. Tell your TinyMCE instance where to load the plugin from and how to configure it:
tinymce.PluginManager.load(
  "paste_from_word",
  "https://unpkg.com/@pangaeatech/tinymce-paste-from-word-plugin@latest/index.js",
);
tinymce.init({
  selector: "textarea", // change this value according to your HTML
  plugins: "paste_from_word",
  paste_webkit_styles: "all",
  paste_remove_styles_if_webkit: false,
});

Option 2: Self-Hosted

  1. Create a new folder paste_from_word inside of the existing TinyMCE plugins folder.
  2. Download the file https://unpkg.com/@pangaeatech/tinymce-paste-from-word-plugin@latest/index.js and add it to that new folder, renaming it plugin.min.js
  3. Configure your TinyMCE instance to use the plugin:
tinymce.init({
  selector: "textarea", // change this value according to your HTML
  plugins: "paste_from_word",
  paste_webkit_styles: "all",
  paste_remove_styles_if_webkit: false,
});

Option 3: React (etc.)

The following instructions are for a project using ReactJS and NPM, but you can easily modify these for any other NodeJS-based project.

  1. Add the TinyMCE and TinyMCE Paste from Word Plugin projects to your package management:
npx create-react-app tinymce-react-demo
cd tinymce-react-demo
npm install --save @tinymce/tinymce-react @pangaeatech/tinymce-paste-from-word-lib
  1. Using a text editor, open ./src/App.js and replace the contents with:
import React from "react";
import { Editor } from "@tinymce/tinymce-react";
import PasteFromWord from "@pangaeatech/tinymce-paste-from-word-lib";

const config = {
  height: 500,
  paste_preprocess: PasteFromWord,
  paste_webkit_styles: "all",
  paste_remove_styles_if_webkit: false,
};

export default function App() {
  return (
    <Editor
      initialValue="<p>This is the initial content of the editor.</p>"
      init={config}
    />
  );
}

Settings

These settings affect the execution of the paste_from_word plugin.

pastefromword_valid_elements

This option enables you to configure the elements specific to MS Office. Word produces a lot of junk HTML, so when users paste things from Word we do extra restrictive filtering on it to remove as much of this as possible. This option enables you to specify which elements and attributes you want to include when Word contents are intercepted.

Type: String

Default Value: "-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody"

pastefromword_convert_fake_lists

This option lets you disable the logic that converts list like paragraph structures into real semantic HTML lists.

Type: Boolean

Default Value: true

paste_webkit_styles

This plugin is a preprocessor which converts paste content from MS Word into WebKit-style paste content which TinyMCE's built-in paste function can handle. Therefore, it is impacted by the webkit-specific settings of the paste module. In order to prevent the paste module from stripping out all style information, you need to set this to "all" or to a specific list of styles you wish to retain.

Type: String

Default value: "none"

paste_remove_styles_if_webkit

This plugin is a preprocessor which converts paste content from MS Word into WebKit-style paste content which TinyMCE's built-in paste function can handle. Therefore, it is impacted by the webkit-specific settings of the paste module. In order to prevent the paste module from stripping out all style information, you need to set this to false.

Type: Boolean

Default Value: true