Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@inscreen/rich-text

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inscreen/rich-text - npm Package Compare versions

Comparing version 0.1.11 to 0.1.12

dist/utilities/runes.d.ts

3

dist/index.d.ts
export { RichTextEditor } from './editor';
export { RichTextNodeId, RichTextPosition, RichTextRange } from './selection';
export { type RichTextNodeId, RichTextPosition, RichTextRange } from './selection';
export type { RichText, RichTextFormat, RichTextNode, RichTextParagraph } from './types';
export { isCompleteRichText, isEmptyRichText, isRTL, listMentions, listAnonymousMentions, deanonymizeMentions, parseToRichText, richTextToString, } from './utilities';
export { stringOffsetToTrueOffset } from './utilities/runes';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.richTextToString = exports.parseToRichText = exports.deanonymizeMentions = exports.listAnonymousMentions = exports.listMentions = exports.isRTL = exports.isEmptyRichText = exports.isCompleteRichText = exports.RichTextRange = exports.RichTextPosition = exports.RichTextEditor = void 0;
exports.stringOffsetToTrueOffset = exports.richTextToString = exports.parseToRichText = exports.deanonymizeMentions = exports.listAnonymousMentions = exports.listMentions = exports.isRTL = exports.isEmptyRichText = exports.isCompleteRichText = exports.RichTextRange = exports.RichTextPosition = exports.RichTextEditor = void 0;
var editor_1 = require("./editor");

@@ -18,2 +18,4 @@ Object.defineProperty(exports, "RichTextEditor", { enumerable: true, get: function () { return editor_1.RichTextEditor; } });

Object.defineProperty(exports, "richTextToString", { enumerable: true, get: function () { return utilities_1.richTextToString; } });
var runes_1 = require("./utilities/runes");
Object.defineProperty(exports, "stringOffsetToTrueOffset", { enumerable: true, get: function () { return runes_1.stringOffsetToTrueOffset; } });
//# sourceMappingURL=index.js.map

@@ -5,2 +5,3 @@ "use strict";

const state_1 = require("./state");
const runes_1 = require("./utilities/runes");
function erase(text, range) {

@@ -24,10 +25,10 @@ const result = new state_1.RichTextBuilder(range);

if (ref.node.type === 'text' || ref.node.type === '_open') {
const preText = ref.startOffset !== undefined ? ref.node.text.substring(0, ref.startOffset) : '';
const postText = ref.endOffset !== undefined ? ref.node.text.substring(ref.endOffset) : '';
const preText = ref.startOffset !== undefined ? (0, runes_1.substring)(ref.node.text, 0, ref.startOffset) : '';
const postText = ref.endOffset !== undefined ? (0, runes_1.substring)(ref.node.text, ref.endOffset) : '';
result.addNode({ ...ref.node, text: preText + postText });
if (ref.startOffset !== undefined) {
result.markRangeStart(preText.length);
result.markRangeStart((0, runes_1.length)(preText));
}
if (ref.endOffset !== undefined) {
result.markRangeEnd(preText.length);
result.markRangeEnd((0, runes_1.length)(preText));
}

@@ -89,3 +90,3 @@ }

...ref.node,
text: ref.node.text.substring(0, ref.startOffset),
text: (0, runes_1.substring)(ref.node.text, 0, ref.startOffset),
});

@@ -95,3 +96,3 @@ result.addNode({

format: appliedFormat,
text: ref.node.text.substring(ref.startOffset, ref.endOffset),
text: (0, runes_1.substring)(ref.node.text, ref.startOffset, ref.endOffset),
});

@@ -102,3 +103,3 @@ result.markRangeStart();

...ref.node,
text: ref.node.text.substring(ref.endOffset),
text: (0, runes_1.substring)(ref.node.text, ref.endOffset),
});

@@ -109,3 +110,3 @@ }

...ref.node,
text: ref.node.text.substring(0, ref.startOffset),
text: (0, runes_1.substring)(ref.node.text, 0, ref.startOffset),
});

@@ -115,3 +116,3 @@ result.addNode({

format: appliedFormat,
text: ref.node.text.substring(ref.startOffset),
text: (0, runes_1.substring)(ref.node.text, ref.startOffset),
});

@@ -124,3 +125,3 @@ result.markRangeStart();

format: appliedFormat,
text: ref.node.text.substring(0, ref.endOffset),
text: (0, runes_1.substring)(ref.node.text, 0, ref.endOffset),
});

@@ -130,3 +131,3 @@ result.markRangeEnd();

...ref.node,
text: ref.node.text.substring(ref.endOffset),
text: (0, runes_1.substring)(ref.node.text, ref.endOffset),
});

@@ -155,6 +156,6 @@ }

if (ref.matched && (ref.node.type === 'text' || ref.node.type === '_open')) {
const preText = ref.node.text.substring(0, position.offset);
const postText = ref.node.text.substring(position.offset);
const preText = (0, runes_1.substring)(ref.node.text, 0, position.offset);
const postText = (0, runes_1.substring)(ref.node.text, position.offset);
result.addNode({ ...ref.node, text: preText + insertion + postText });
const finalOffset = position.offset + insertion.length;
const finalOffset = position.offset + (0, runes_1.length)(insertion);
result.markRangeStart(finalOffset);

@@ -180,4 +181,4 @@ result.markRangeEnd(finalOffset);

if (ref.node.type === 'text') {
const preText = ref.node.text.substring(0, position.offset);
const postText = ref.node.text.substring(position.offset);
const preText = (0, runes_1.substring)(ref.node.text, 0, position.offset);
const postText = (0, runes_1.substring)(ref.node.text, position.offset);
result.addNode({ ...ref.node, text: preText });

@@ -184,0 +185,0 @@ result.addNode({ type: '_open', subtype: 'mention', text: '' });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RichTextRange = exports.RichTextPosition = void 0;
const runes_1 = require("./utilities/runes");
class RichTextPosition {

@@ -17,3 +18,3 @@ constructor(text, nodeId, offset) {

nextCharacter() {
if ((this.node.type === 'text' || this.node.type === '_open') && this.offset < this.node.text.length) {
if ((this.node.type === 'text' || this.node.type === '_open') && this.offset < (0, runes_1.length)(this.node.text)) {
return new RichTextPosition(this.text, this.nodeId, this.offset + 1);

@@ -45,3 +46,4 @@ }

if (node.type === 'text' || node.type === '_open') {
return new RichTextPosition(this.text, { paragraphIdx, nodeIdx }, neighboringNodes ? node.text.length - 1 : node.text.length);
const nodeTextLength = (0, runes_1.length)(node.text);
return new RichTextPosition(this.text, { paragraphIdx, nodeIdx }, neighboringNodes ? nodeTextLength - 1 : nodeTextLength);
}

@@ -100,3 +102,3 @@ neighboringNodes = false;

const lastNode = lastParagraph.nodes[lastNodeIdx];
const lastOffset = lastNode.type === 'text' ? lastNode.text.length : 0;
const lastOffset = lastNode.type === 'text' ? (0, runes_1.length)(lastNode.text) : 0;
const endOfTextPosition = new RichTextPosition(text, {

@@ -103,0 +105,0 @@ paragraphIdx: lastParagraphIdx,

@@ -7,2 +7,3 @@ "use strict";

const formatsEqual_1 = require("./utilities/formatsEqual");
const runes_1 = require("./utilities/runes");
function walk(text, range, process) {

@@ -135,3 +136,3 @@ text.paragraphs.forEach((paragraph, paragraphIdx) => {

const currentNode = this.currentNode;
const currentNodeLength = currentNode.type === 'text' || currentNode.type === '_open' ? currentNode.text.length : 0;
const currentNodeLength = currentNode.type === 'text' || currentNode.type === '_open' ? (0, runes_1.length)(currentNode.text) : 0;
this.range.end = new selection_1.RichTextPosition(this.text, this.currentNodeId, offset !== undefined ? offset : currentNodeLength);

@@ -267,3 +268,3 @@ }

if (previousNode && previousNode.type === 'text' && (0, formatsEqual_1.formatsEqual)(node.format, previousNode.format)) {
const previousTextLength = previousNode.text.length;
const previousTextLength = (0, runes_1.length)(previousNode.text);
previousNode.text += node.text;

@@ -270,0 +271,0 @@ markRange(ref, previousTextLength);

{
"name": "@inscreen/rich-text",
"version": "0.1.11",
"version": "0.1.12",
"description": "Lightweight rich-text functionality",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc