commit 72d5e0fe6dda7f8f35a60226cc79f46523b8b5a0
parent 95d64f1e6bfe41dd7bdb1a632a20e47f27e49cdf
Author: Henry Unite <unitehenry@gmail.com>
Date: Tue, 1 Sep 2020 11:36:21 -0400
documentation
Diffstat:
| D | CONTRIBUTING.md | | | 55 | ------------------------------------------------------- |
| M | README.md | | | 312 | ++------------------------------------------------------------------------------ |
2 files changed, 4 insertions(+), 363 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
@@ -1,55 +0,0 @@
-# CONTRIBUTING
-
-Anyone can contribute to the Striven WYSIWYG editor. Please open an issue for any feature requests, bug fixes, and enhancements that you would like to be implemented into the editor. Keep in mind that this editor has been tailored to the needs of the Striven ERP Platform, so some requests may not be fulfillable.
-
-Please open all pull requests to the ```dev``` branch.
-
-## Addressing Issues
-
-When resolving a posted issue, please ask a maintainer to assign the issue to you prior to opening a pull request.
-
-## Install Dependencies
-
-```sh
-$ npm install
-```
-
-```sh
-$ cd demo && npm install
-```
-
-## Symlink Development Package
-
-Initialize ```@striven-erp/striven-editor``` symlink.
-
-```sh
-$ npm link
-```
-
-Symlink ```@striven-erp/striven-editor``` in the development environment.
-
-```sh
-$ npm link @striven-erp/striven-editor
-```
-
-## Start Development Server
-
-Start the development server in ```demo``` and go to ```http://localhost:8080/``` to begin developing.
-
-```sh
-$ npm start
-```
-
-## Testing with Meta Data Extraction
-
-Start the metadata server.
-
-```sh
-$ node demo-server/meta-server
-```
-
-Pass the ```metaUrl``` to the editor.
-
-```js
-this.editor = new StrivenEditor(this.$refs.editor, { metaUrl: 'http://localhost:4200/meta' })
-```
diff --git a/README.md b/README.md
@@ -5,315 +5,11 @@
</p>
<p align="center">
-<img src="https://img.shields.io/npm/v/@striven-erp/striven-editor" alt="version">
-<img src="https://img.shields.io/github/issues/striven-erp/striven-editor" alt="GitHub issus">
-<img src="https://img.shields.io/github/languages/top/striven-erp/striven-editor" alt="GitHub top language">
+ <img src="https://img.shields.io/npm/v/@striven-erp/striven-editor" alt="version">
+ <img src="https://img.shields.io/github/issues/striven-erp/striven-editor" alt="GitHub issus">
+ <img src="https://img.shields.io/github/languages/top/striven-erp/striven-editor" alt="GitHub top language">
</p>
<p align="center">
- <strong>Supports Firefox, Edge, Safari, and Chrome</strong>
- <br />
- ✌ <a href="#vue-component">Vue</a> | 🥋 <a href="#knockout-binding">Knockout</a>
+ Visit the <a href="https://github.com/striven-erp/striven-editor/wiki">wiki</a> to get started.
</p>
-
-## Getting Started
-
-### Install Package
-
-```sh
-$ npm install @striven-erp/striven-editor
-```
-
-### Initialize Editor
-
-```js
-import { StrivenEditor } from 'striven-editor';
-
-const editor = new StrivenEditor(editorEl);
-```
-
-### Passing Options to the Editor
-
-```js
-import StrivenEditor from 'striven-editor';
-
-const editor = new StrivenEditor(editorEl, { toolbarHide: true, toolbarBottom: true });
-```
-
-## Vue Component
-
-```js
-<template>
- <striven-editor ref="editor" :minimal="true" />
-</template>
-
-<script>
-import { VueStrivenEditor as StrivenEditor } from '@striven-erp/striven-editor';
-
-export default {
- components: { StrivenEditor }
-}
-</script>
-```
-
-### Using Vue Component Methods
-
-```js
-<template>
- <striven-editor ref="editor" :minimal="true" />
-</template>
-
-<script>
-import { VueStrivenEditor as StrivenEditor } from '@striven-erp/striven-editor';
-
-export default {
- components: { StrivenEditor },
- mounted () {
- const editor = this.$refs.editor.editor;
-
- console.log(editor.getContent());
- }
-}
-</script>
-```
-
-### Custom Toolbar Options with Vue
-
-```js
-<template>
- <striven-editor :custom-toolbar-button="customButton" />
- <button ref="customButton">Send</button>
-</template>
-
-<script>
-export default {
- data () {
- return {
- customButton: () => this.$refs.customButton
- }
- }
-}
-</script>
-```
-
-## Knockout Binding
-
-```js
-import ko from 'knockout';
-import { KoStrivenEditor } from '@striven-erp/striven-editor';
-
-new KoStrivenEditor(ko);
-```
-
-```html
-<div data-bind="striveneditor: editorConfig" />
-```
-
-## Fetching Meta Data on Link Insertions
-
-To fetch meta data from links that are pasted or inserted into the editor, you must set up a back end utility to fetch the data and send it back to your client. For a node server, we recommend using [metascraper](https://metascraper.js.org/#/) on your server. See the example below for setting this up with express.
-
-```js
-const got = require('got');
-const app = require('express')();
-const bodyParser = require('body-parser');
-const metascraper = require('metascraper')([
- require('metascraper-description')(),
- require('metascraper-image')(),
- require('metascraper-title')(),
- require('metascraper-url')()
-]);
-
-app.use(bodyParser.json());
-app.use(bodyParser.urlencoded({ extended: true }));
-
-app.post('/meta', (req, res) => {
- const targetUrl = req.body.targetUrl;
- if(targetUrl) {
- (async () => {
- const { body: html, url } = await got(targetUrl);
- const metadata = await metascraper({ html, url });
- res.send(metadata);
- })()
- } else {
- res.sendStatus(400);
- }
-})
-
-app.listen(8080, () => console.log('Server is on.'));
-```
-
-Your editor should look something like this.
-
-```js
-const editor = new StrivenEditor(editorEl, { metaUrl: 'http://localhost:8080/meta' });
-```
-
-### Meta Data POST Request
-
-Here is an example of what the editor uses for the client to make a ```POST``` request to the server.
-
-```js
-fetch(this.options.metaUrl, {
- method: "POST",
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ targetUrl: url })
-}).then((res) => res.json())
-```
-
-## Writing Encoded Images to a Server
-
-**Passing ```imageUrl``` will disable the use of ```uploadOnPaste```**
-
-Using Node's [File System](https://nodejs.org/api/fs.html), you can send encoded image data to your server and send the editor a reference to those files. See the example below for doing this on an express server.
-
-```js
-const express = require('express');
-const app = express();
-const PORT = 4200;
-const path = require('path');
-const bodyParser = require('body-parser');
-const cors = require('cors');
-const fs = require('fs');
-const shortid = require('shortid');
-
-app.use(bodyParser.json());
-app.use(cors());
-
-app.get('/images/:name', (req, res) => {
- res.sendFile(path.join(__dirname, 'images', req.params.name));
-})
-
-app.post('/image', (req, res) => {
- const imageEncoding = req.body.imageEncoding;
- try {
- const base64Image = imageEncoding.split(';base64,').pop();
- const imageId = shortid.generate();
-
- fs.writeFile(path.join(__dirname, 'images', `${imageId}.png`), base64Image, {encoding: 'base64'}, function(err) {
- console.log('File created');
- res.send({ imageRef: `http://localhost:${PORT}/images/${imageId}.png` });
- err && console.log(err);
- });
- }
- catch (e) {
- res.sendStatus(400);
- }
-})
-
-app.listen(PORT, () => console.log(`Image server open on port: ${PORT}`))
-```
-
-### Handling the Image Reference
-
-Here is an example of what the editor uses for the client to make a ```POST``` request to the server. If the server returns an error, the editor will paste the image as normal.
-
-```js
-fetch(this.options.imageUrl, {
- method: "POST",
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ imageEncoding })
-}).then((res) => res.json())
-```
-
-## Toolbar Options
-
-Specify which options to display in the toolbar and allow for use in the editor.
-
-```js
-const editor = new StrivenEditor(editorEl, { toolbarOptions: ["bold", "italic", "underline"] })
-```
-
-### List of Toolbar Options
-
-* bold
-* italic
-* underline
-* strikethrough
-* removeFormat
-* insertOrderedList
-* insertUnorderedList
-* indent
-* justifyLeft
-* justifyCenter
-* justifyRight
-* attachment
-* link
-* image
-
-### Passing Custom Toolbar Options
-
-```js
-const customToolbarOption = {
- icon: {
- viewBox: "0 0 1792 1792",
- d: "M1600 736v192q0 40-28 68t-68 28h-416v416q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-416h-416q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h416v-416q0-40 28-68t68-28h192q40 0 68 28t28 68v416h416q40 0 68 28t28 68z"
- },
- handler: () => this.editor.getRange().insertNode(document.createTextNode("hello world"))
-};
-
-const editor = new StrivenEditor(editorEl, { toolbarOptions: ["bold", "italic", "underline", customToolbarOption] });
-```
-
-#### Finding SVG Data
-
-You can find Raw Fontawesome SVG data [here](https://github.com/encharm/Font-Awesome-SVG-PNG/tree/master/black/svg). After finding the icon you want, view the SVG file as raw.
-
-
-
-Then take the SVG element's ```viewBox``` attribute data and the path element's ```d``` attribute data.
-
-
-
-## Editor Options
-
-|Option|Type|Default|Description|
-|:-:|:-:|:-:|:-:|
-|toolbarHide|```Boolean```|```false```|Enable the toolbar slide animation|
-|toolbarBottom|```Boolean```|```false```|Render the toolbar beneath the editor|
-|minimal|```Boolean```|```false```|Display minimal editor options|
-|metaUrl|```String```|```null```|An endpoint to make a ```POST``` request for a urls metadata. <br /> See [Fetching Metadata](#meta-data-post-request)|
-|extensions|```Array``` of ```String```|```[ ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf",".tif", ".jpeg", ".jpg", ".gif", ".bmp", ".txt", ".csv", ".png", ".msg", ".wav", ".mp3", ".mp4", ".zip", ".rtf", ".eps", ".ai", ".psd", ".avi", ".mov", ".wmv", ".cfg", ".wss", ".vsd", ".vsdx", ".tsd", ".lic" ]```|An array of file extensions allowed for upload|
-|uploadOnPaste|```Boolean```|```false```|Enable uploading images on paste.|
-|fileUpload|```Boolean```|```true```|Enable the ability to upload files with editor|
-|onInvalidFile|```Function```|```null```|Handler function to pass when an attached file is invalid|
-|onValidFile|```Function```|```null```|Handler function to pass when a file is successfully attached to the editor|
-|toolbarOptionFillColor|```String```|```#333```|Fill color for the toolbar option SVGs|
-|placeholder|```String```|```null```|Default text to display when the editor is empty|
-|sanitizePaste|```Boolean```|```false```|*Clean* pasted content of any HTML styles|
-|sanitizePaste|```Boolean```|```false```|*Clean* pasted content of any HTML styles|
-|imageUrl|```String```|```null```|An endpoint to make a ```POST``` request for writing encoded images to the server. <br /> See [Referencing Encoded Images](#writing-encoded-images-to-a-server)|
-|toolbarTemplate|```DOM Node```|```null```|A custom HTML DOM Node option can be passed to append to the toolbar|
-|activeOptionColor|```String```|```#ddd```|Fill color for the toolbar action to change to when active.|
-|onEnter(```e```)|```Function```|```null```|Handler function that fires when the the enter key is pressed|
-
-## Editor Methods
-
-|Method|Return Type|Description|
-|:-:|:-:|:-:|
-|getFiles|```Array``` of ```File```|Returns an Array of Files attached to the editor|
-|getContent|```String```|Returns an HTML String of the editor's contents|
-|setContent(```String```)|None|Set the editor ```innerHTML``` content by passing an HTML string|
-|clearContent|None|Clear the editor of its current contents|
-|clearFiles|None|Clear the files currently attached to the editor|
-|getRange|```Range```|Get the current [Range](https://developer.mozilla.org/en-US/docs/Web/API/Range) of the window at index ```0```|
-|setRange(```Range```)|None|Clears the current range of the ```window``` and sets it to the range option that is passed. If no option is passed, then the current editor instance of the range is used.|
-|attachFile(```File```)|None|Attaches given file to the editor|
-|openLinkMenu|None|Opens the ```insertLink``` menu|
-|closeLinkMenu|None|Closes the ```insertLink``` menu|
-|openImageMenu|None|Opens the ```insertImage``` menu|
-|closeImageMenu|None|Closes the ```insertImage``` menu|
-|overflow|None|Manually update the editor to handle overflow content <br /> ```overflowX``` ```overflowY```|
-|getMeta(```String```)|```Promise```|Returns a promise containing data from ```POST``` request to ```metaURl``` using the passed url as ```targetUrl``` <br /> ```const { url, title, image, description } = res```|
-|getImage(```String```)|```Promise```|Returns a promise containing data from ```POST``` request to ```imageUrl``` and passes ```imageEncoding``` in the body <br /> ```const { imageRef } = res```|
-|toolbarSlideUp|None|Manually trigger the toolbar open animation|
-|toolbarSlideDown|None|Manually trigger the toolbar close animation|
-|getActiveOptions|```Array``` of ```String```|Returns an array of currently active toolbar options|
-|getTextContent|```String```|Returns the text content of the editor with no HTML|
-|toolbarState|None|Updates the toolbars state based on the options passed in by ```toolbarOptions```|
-|executeCommand(```String```)|```None```|Executes an document command from the [toolbar options list](#list-of-toolbar-options)|
-|linkMenuSlideIn|None|Manually open the link menu with animation.|
-|imageMenuSlideIn|None|Manually open image menu with animation.|
-|pruneScripts|```HTML Node```|Return element with all ```<script>``` tags removed|
-|pruneStyles|```HTML Node```|Return element with all ```<style>``` tags removed|
-|pruneInlineStyles|```HTML Node```|Return element with all inline styles with ```position``` on child nodes removed|