0.2.7 • Published 2 years ago

editor-to-word v0.2.7

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Introduction

Editor-to-Word is a tool to export rich-text editor content as word file (.docx) by browser 🎉.

Usage

npm i editor-to-word

# or pnpm add editor-to-word
# or yarn add editor-to-word

In web project:

import { exportHtmlToDocx } from 'editor-to-word';

const html = '<p>hello <span style="color: #999">world</span></p>';

exportHtmlToDocx(html, 'testFileName');

Options

For different default style set you can provider the custom paper layout and styleMap like:

// default paper layout
export const D_Layout: IPageLayout = {
  bottomMargin: '2.54cm',
  leftMargin: '3.18cm',
  rightMargin: '3.18cm',
  topMargin: '2.54cm',
  orientation: PageOrientation.PORTRAIT,
};

// style with tag
export const D_TagStyleMap = {
  p: 'line-height: 1.5;',
  strong: 'font-weight: bold;',
  em: 'font-style: italic;',
  u: 'text-decoration: underline;',
  del: 'text-decoration: line-through;',
  h1: 'font-weight: bold; font-size: 40px; line-height: 1.5;',
  h2: 'font-weight: bold; font-size: 36px; line-height: 1.5;',
  h3: 'font-weight: bold; font-size: 24px; line-height: 1.5;',
  h4: 'font-weight: bold; font-size: 18px; line-height: 1.5;',
  h5: 'font-weight: bold; font-size: 15px; line-height: 1.5;',
  h6: 'font-weight: bold; font-size: 13px; line-height: 1.5;',
};

const options = {
  layout: D_Layout,
  tagStyleMap: D_TagStyleMap,
};

exportHtmlToDocx = ('<p>Hi there!</p>', 'doc', options);

And if you don't provider the options it will use the default preset.

0.2.7

2 years ago

0.2.6

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.2.3

2 years ago

0.1.4

2 years ago

0.2.2

2 years ago

0.1.3

2 years ago

0.2.5

2 years ago

0.1.6

2 years ago

0.2.4

2 years ago

0.1.5

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago