0.1.13 • Published 3 years ago

@alanor87/tial v0.1.13

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

TIAL (v0.1.12) - text image anchoring library for React.

A library, that binds certain parts of the text to certain areas of the image on the html page, using highlighting text and corresponding selected image area.

Demo page

http://tial-lib.com

Install

npm

Through npm npm install @alanor87/tial

Usage

ES6

import { AnchorWrapper, AnchorText, AnchorImage } from "@alanor87/tial";

Overview

Components

The functionality is implemented with usage of three react components :

AnchorWrapper

<AnchorWrapper>{children}</AnchorWrapper> 

A wrapper, which provides a context for the interaction of highlighting text and corresponding image parts. Accepts children compoenents in arbitrary amounts, order and nesting levels. You can arrange all the contents of the wrapper block in the desired way and pass the anchored image and text blocks in any order and in any place among onther children componenets - they are going to be bound together through the common AnchorWrapper context. AnchorWrapper must not contain more than one AnchorText or AnchorImage - an error will be thrown in such case. Every pair of AnchorTexy/AnchorImage must be wrapped inside their own AnchorWrapper container.

PropsTypeRequiredDefaultDescription
classNamestringfalsenoneAdditional style through class name for the wrapper.
initialAnchorsDataobject (AnchorsDataType)truenoneThe object, that includes original text, imageUrl and anchors data. For the structure - see the Types section below.
highlightColorstringfalsenoneThe highlighting color of anchors. Takes any CSS interpretable color value.
onAnchorsUpdatefunctionfalsenoneCallback that gets updated list of anchors (see Types section). If undefined - option of creating and deleting anchors is not available.
onAnchorSelectfunctionfalsenoneCallback that gets id of selected anchor when it is being changed.

AnchorText

<AnchorText />

Container with the marked (anchored) text.

PropsTypeRequiredDefaultDescription
classNamestringfalsenoneAdditional style through class name for the text container.
textMarkerStyleobjectfalsenoneAdditional styles for the highlighting text marker. See Types below for the structure.

AnchorImage

<AnchorImage />

Container with the marked (anchored) image.

PropsTypeRequiredDefaultDescription
classNamestringfalsenoneAdditional style through class name for the text container.
imageFrameStyleobjectfalsenoneAdditional styles for the highlighting image frame. See Types below for the structure.

Types

AnchorType

 interface AnchorType {
  _id: string;
  anchorText: string;
  anchorTextStartPos: number;
  anchorFrameCoords: number[];
  anchorFrameSize: number[];
}
KeyDescription
_idUnique id for each anchor.
anchorTextThe text that should be in the highlighted marker.
anchorTextStartPosThe starting position of the highlighted text inside of the anchored text block.
anchorFrameCoordsX and Y coordinates of the upper left corner of the highlighing frame on the anchored image (percentage from image display size).
anchorFrameSizeWidth and height of the highlighing frame on the anchored image (percentage from image display size).

AnchorsDataType

 interface AnchorsDataType {
  anchorText: string;
  anchorImageUrl: string;
  anchorsArray: AnchorType[];
}
KeyDescription
anchorTextThe anchored text block, should be passed a a single solid string.
anchorImageUrlUrl of the anchored image.
anchorsArrayArray of anchors for the coupled text and image components.

AnchorTextMarkerFrameStyle

  interface AnchorTextMarkerFrameStyle {
  textColor?: string;
  outlineWidth?: string;
  borderRadius?: string;
}
KeyDescription
textColorColor of the text in marker - when the marker was selected. Takes any CSS interpretable color value.
outlineWidthWidth of the text marker outline. Takes any CSS interpretable outline-width value.
borderRadiusBorder radius for text marker. Takes any CSS interpretable border-radius value.

AnchorImageFrameStyle

  interface AnchorImageFrameStyle {
  boxShadow?: string;
  textColor?: string;
  borderWidth?: string;
  borderRadius?: string;
}
KeyDescription
boxShadowBox shadow for the image frame. Takes any CSS interpretable box-shadow value.
textColorColor of the text inside of the image frame. Takes any CSS interpretable color value.
borderWidthWidth of the image frame border. Takes any CSS interpretable border-width value.
borderRadiusBorder radius for text marker. Takes any CSS interpretable border-radius value.
0.1.11

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.167

3 years ago

0.0.166

3 years ago

0.0.165

3 years ago

0.0.164

3 years ago

0.0.163

3 years ago

0.0.162

3 years ago

0.0.161

3 years ago

0.0.160

3 years ago

0.0.159

3 years ago

0.0.158

3 years ago

0.0.157

3 years ago

0.0.156

3 years ago

0.0.155

3 years ago

0.0.154

3 years ago

0.0.153

3 years ago

0.0.152

3 years ago

0.0.151

3 years ago

0.0.150

3 years ago

0.0.149

3 years ago

0.0.148

3 years ago

0.0.147

3 years ago

0.0.146

3 years ago

0.0.145

3 years ago

0.0.144

3 years ago

0.0.143

3 years ago

0.0.142

3 years ago

0.0.141

3 years ago

0.0.140

3 years ago

0.0.139

3 years ago

0.0.138

3 years ago

0.0.137

3 years ago

0.0.136

3 years ago

0.0.135

3 years ago

0.0.134

3 years ago

0.0.133

3 years ago

0.0.132

3 years ago

0.0.131

3 years ago

0.0.130

3 years ago

0.0.129

3 years ago