Giter Site home page Giter Site logo

aem / docs-soap Goto Github PK

View Code? Open in Web Editor NEW
18.0 2.0 13.0 95 KB

Library to clean up the clipboard contents generated by google docs

Home Page: https://www.npmjs.com/package/docs-soap

License: ISC License

JavaScript 100.00%
html google google-docs javascript draft-js draftjs

docs-soap's Introduction

docs-soap Build Status npm version codecov

docs-soap is a small (1.5kb minified/gzipped), simple library that can be used to transform clipboard contents from Google Docs into readable HTML. This library was born from the need to parse clipboard content from Google Docs into a DraftJS Rich Text Editor and fits nicely into Draft's handlePastedText hook.

This project was developed for use in a client-side project. To use in a Node environment, your project will also require jsdom-global.

New in 1.2.1

  • Comment are stripped from output. Fixes bug when pasting on Windows.

Exported API

module.exports = {
  default: docsSoap,
  docsSoap,
  parseHTML
};

Testing

Tests are written in Mocha, using expect for assertions. npm run test will run all tests in the test/ directory, allowing you to test the entire library's functionality at once. All contributions to the repository are expected to contain accompanying tests.

In the examples/ directory, there's a simple HTML example that, after running npm run build in the project root, can be used to test your changes or just see the library in action.

Installation

ESM

yarn add docs-soap
import docsSoap from 'docs-soap';

CommonJS

yarn add docs-soap
const docsSoap = require('docs-soap').default;

Script tag

<script src="https://unpkg.com/[email protected]/dist/docs-soap.min.js"></script>
var docsSoap = window.docsSoap;

Usage

const html =
  '<body id="docs-internal-guid-1234"><b><span style="font-weight:700">bold text</span><span style="font-style:italic">some italic text</span></b></body>';
const clean = docsSoap(html);
console.log(
  clean
); /* "<body><strong>some bold text</strong><i>some italic text</i></body>" */

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.