New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@textbus/core

Package Overview
Dependencies
Maintainers
1
Versions
344
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@textbus/core - npm Package Compare versions

Comparing version 2.0.0-alpha.6 to 2.0.0-alpha.7

1

bundles/foundation/commander.d.ts

@@ -11,2 +11,3 @@ import { TBRange, TBSelection } from './selection';

constructor(selection: TBSelection, nativeRenderer: NativeRenderer);
extractContentBySchema(source: Slot, schema: ContentType[], startIndex?: number, endIndex?: number): Slot[];
extractSlots(schema: ContentType[], greedy?: boolean): {

@@ -13,0 +14,0 @@ slots: Slot<any>[];

@@ -12,3 +12,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

import { TBSelection } from './selection';
import { FormatType, placeholder } from '../model/_api';
import { ContentType, FormatType, placeholder, Slot } from '../model/_api';
import { NativeRenderer } from './_injection-tokens';

@@ -21,2 +21,50 @@ import { invokeListener, TBEvent } from '../define-component';

}
extractContentBySchema(source, schema, startIndex = 0, endIndex = source.length) {
if (schema.length === 0) {
return [];
}
let isPreventDefault = true;
const event = new TBEvent(source, {
count: endIndex - startIndex,
index: endIndex
}, () => {
isPreventDefault = false;
});
invokeListener(source.parent, 'onDelete', event);
if (isPreventDefault) {
return [];
}
const slot = source.cut(startIndex, endIndex);
const content = slot.sliceContent();
const slotList = [];
let len = slot.length;
let i = len;
while (content.length) {
const item = content.pop();
let contentType;
if (typeof item === 'string') {
contentType = ContentType.Text;
}
else {
contentType = item.type;
}
if (!schema.includes(contentType)) {
if (len > i) {
slotList.unshift(slot.cutTo(new Slot(schema), i, len));
i = len;
}
if (typeof item !== 'string') {
item.slots.toArray().forEach(slot => {
slotList.unshift(...this.extractContentBySchema(slot, schema));
});
i--;
}
}
len -= item.length;
}
if (i > 0) {
slotList.unshift(slot.cutTo(new Slot(schema), 0, i));
}
return slotList;
}
extractSlots(schema, greedy = false) {

@@ -38,3 +86,3 @@ const range = {

for (const scope of scopes) {
const childSlots = scope.slot.splitBySchema(schema, scope.startIndex, scope.endIndex);
const childSlots = this.extractContentBySchema(scope.slot, schema, scope.startIndex, scope.endIndex);
if (scope.slot === this.selection.startSlot) {

@@ -212,2 +260,3 @@ let offset = this.selection.startOffset;

const commonAncestorSlotRef = selection.commonAncestorSlot;
const dumpStartSlot = selection.startSlot;
while (scopes.length) {

@@ -237,3 +286,3 @@ const scope = scopes.pop();

slot.delete(scope.endIndex - scope.startIndex);
if (scopes.length === 0) {
if (slot === dumpStartSlot) {
break;

@@ -240,0 +289,0 @@ }

16

bundles/foundation/renderer.js

@@ -257,3 +257,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

}
const { attrChanges, styleChanges, classesChanges } = getNodeChanges(newFirstVNode, oldFirstVNode);
const { attrChanges, styleChanges, classesChanges, listenerChanges } = getNodeChanges(newFirstVNode, oldFirstVNode);
const isChanged = [

@@ -265,4 +265,6 @@ attrChanges.set.length,

classesChanges.add.length,
classesChanges.remove.length
].join('') !== '000000';
classesChanges.remove.length,
listenerChanges.add.length,
listenerChanges.remove.length
].join('') !== '00000000';
if (isChanged) {

@@ -304,3 +306,3 @@ break;

}
const { attrChanges, styleChanges, classesChanges } = getNodeChanges(newLastVNode, oldLastVNode);
const { attrChanges, styleChanges, classesChanges, listenerChanges } = getNodeChanges(newLastVNode, oldLastVNode);
const isChanged = [

@@ -312,4 +314,6 @@ attrChanges.set.length,

classesChanges.add.length,
classesChanges.remove.length
].join('') !== '000000';
classesChanges.remove.length,
listenerChanges.add.length,
listenerChanges.remove.length
].join('') !== '00000000';
if (isChanged) {

@@ -316,0 +320,0 @@ break;

@@ -49,4 +49,2 @@ import { ComponentInstance, ComponentLiteral } from './component';

getContentAtIndex(index: number): string | ComponentInstance<import("./component").ComponentMethods<any>, any>;
slice(startIndex?: number, endIndex?: number): Slot<any>;
splitBySchema(schema: ContentType[], startIndex?: number, endIndex?: number): Slot[];
sliceContent(startIndex?: number, endIndex?: number): (string | ComponentInstance<import("./component").ComponentMethods<any>, any>)[];

@@ -53,0 +51,0 @@ createFormatTree(): any;

@@ -331,45 +331,2 @@ import { Content } from './content';

}
slice(startIndex = 0, endIndex = this.length) {
const slot = new Slot([...this.schema]);
this.sliceContent(startIndex, endIndex).forEach(c => slot.insert(c));
slot.format = this.format.createFormatByRange(slot, startIndex, endIndex);
return slot;
}
splitBySchema(schema, startIndex = 0, endIndex = this.length) {
if (schema.length === 0) {
return [];
}
const slot = this.slice(startIndex, endIndex);
const content = slot.sliceContent();
const slotList = [];
let i = 0;
let n = 0;
for (const item of content) {
let contentType;
if (typeof item === 'string') {
contentType = ContentType.Text;
}
else {
contentType = item.type;
}
if (!schema.includes(contentType)) {
if (n > i) {
slotList.push(slot.slice(i, n));
i = n;
}
if (typeof item !== 'string') {
item.slots.toArray().forEach(slot => {
slotList.push(...slot.splitBySchema(schema));
});
i++;
}
}
n += item.length;
}
if (n > i) {
slotList.push(slot.slice(i, n));
}
slotList.forEach(i => i.schema = schema);
return slotList;
}
sliceContent(startIndex = 0, endIndex = this.length) {

@@ -376,0 +333,0 @@ return this.content.slice(startIndex, endIndex);

{
"name": "@textbus/core",
"version": "2.0.0-alpha.6",
"version": "2.0.0-alpha.7",
"description": "TextBus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.",

@@ -42,3 +42,3 @@ "main": "./bundles/public-api.js",

},
"gitHead": "d6f18fe71f6dbc986a207d0078b4f19a086cef09"
"gitHead": "5c1d191c66dd883840a2ead1b16c5915b6a266b2"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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