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

@txtextcontrol/tx-document-editor

v32.4.0

Published

Text Control HTML5 Document Editor.

Downloads

12

Readme

TX Text Control HTML5 Document Editor

TX Text Control HTML5 Document Editor for Node.js.

Prerequisites

The TX Text Control HTML5 Document Editor communicates with the backend over a WebSocket connection. Therefore you additionally need to create and run a Node.js application which contains an instance of the class WebSocketServer from the package tx-websocket-server.

The "heart" of the document editor is the so called synchronization service that synchronizes the document in order to provide the WYSIWYG rendering. If you want to deploy your project, you will have to host your own synchronization service and set the serviceAddress in the WebSocket server application mentioned above accordingly. The synchronization service is part of TX Text Control .NET Server for ASP.NET.

Installation

npm install @txtextcontrol/tx-document-editor

Usage

The following example shows how to use the TX Text Control Document Editor in a simple web application using Express as the web server and the template engine Pug.

This example already provides the necessary WebSocket server mentioned in the prerequisites, so you don't need to create an additional project to run it.

To make the example work, please install the following three packages:

npm install express
npm install pug
npm install @txtextcontrol/tx-websocket-server

Content of index.pug in the views folder:

html
   head
      title= title
   body
      h3= heading
      p= text
      div(
         style='position: absolute; top: 100px; left: 80px; width: 80%; height: 700px'
      ) !{editor}

Content of your application's main js file:

const { WebSocketServer } = require('@txtextcontrol/tx-websocket-server');
const { DocumentEditor } = require('@txtextcontrol/tx-document-editor');
const express = require('express');

const app = express();
const server = app.listen(8080);

app.set('view engine', 'pug');

var wsServer = new WebSocketServer(server);

var editor = new DocumentEditor({
   webSocketURL: 'ws://localhost:8080/TXWebSocket'
});

app.get('/', (req, res) => {
   res.render('index', {
      title: 'Text Control HTML5 Document Editor',
      heading: 'Text Control HTML5 Document Editor in Node.js',
      text: '(Using the template engine "Pug")',
      editor: editor.render()
   });
});

If you run your application, the editor should now be accessible at http://localhost:8080.

Configuration

The DocumentEditor object can be configured via the optional constructor parameter. This parameter must be an object. The following properties are recognized:

  • webSocketURL (string) - The WebSocket URL.

  • documentTargetMarkers (boolean) - Sets whether markers for hypertext targets are shown in the editor.

  • editMode (number / string) - Sets whether the document's text is read-only, can be selected or is editable. This can either be a string, in which case the possible values are 'Edit', 'ReadAndSelect', 'ReadOnly' and 'UsePassword', or a numerical value, in which case the value must be one of the values defined in the EditMode enumeration. The EditMode enumeration is also part of the tx-document-editor package and can be required like this:

    const { EditMode } = require('@txtextcontrol/tx-document-editor');
  • contextMenusEnabled (boolean) - Sets whether a right click opens a context menu or not.

  • saveDocumentQuestionDialogEnabled (boolean) - Sets whether a confirmation dialog should be shown before discarding unsaved changes.

  • tableGridLines (boolean) - Sets wether table grid lines are shown in the editor or not.

  • textFrameMarkerLines (boolean) - Sets whether text frames that have no border line are shown with marker lines.

  • controlChars (boolean) - Sets whether control characters are visible or not.

  • textFieldsEditable (boolean) - Sets whether text fields are editable or not.

  • formattingPrinter (string) - The name of a printer the text dimensions and capabilities of which are used to format the document.

  • culture (string) - The culture (e. g. 'de-DE'). Affects date and time string formats, for example.

  • uiCulture (string) - The user interface culture (e. g. 'en-US'). Affects the string resource language.

  • userNames (string[]) - An array of names specifying users who have access to editable regions. When a document is set to read-only all editable regions that are related to these users can be edited.

  • reconnectTimeout (number) - Time in seconds before stopping reconnection attempts after a connection loss.

The render() function takes one optional parameter. This parameter must be an object. The following properties are recognized:

  • dockStyle (number) - The docking style. The DockStyle enumeration is also part of the tx-document-editor package and can be required like this:

    const { DockStyle } = require('@txtextcontrol/tx-document-editor');
  • width (string) - The width of the editor (e. g. '1024px').

  • height (string) - The height of the editor (e. g. '600px').

Environment

  • @txtextcontrol/tx-websocket-server ^32.4.0 (or NuGet package TXTextControl.Web 32.4.0)
  • TX Text Control .NET Server for ASP.NET 32.0 SP4