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

roosterjs-editor-api

Package Overview
Dependencies
Maintainers
2
Versions
317
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

roosterjs-editor-api - npm Package Compare versions

Comparing version 6.1.1 to 6.2.0

lib/format/toggleBlockQuote.d.ts

4

lib/format/cacheGetListElement.d.ts
import { Editor } from 'roosterjs-editor-core';
import { PluginEvent } from 'roosterjs-editor-types';
export default function cacheGetListElement(editor: Editor, event?: PluginEvent): Element;
export declare type ListType = 'LI' | 'BLOCKQUOTE';
export default function cacheGetListElement(editor: Editor, event?: PluginEvent, listType?: ListType): Element;
export declare function getListElementAtNode(editor: Editor, node: Node, listType: ListType): Element;

@@ -7,17 +7,22 @@ "use strict";

var EVENTDATACACHE_LISTELEMENT = 'LISTELEMENT';
function cacheGetListElement(editor, event) {
function cacheGetListElement(editor, event, listType) {
return roosterjs_editor_core_1.cacheGetEventData(event, EVENTDATACACHE_LISTELEMENT, function () {
var node = getNodeAtCursor_1.default(editor);
var startElement = node && node.nodeType == 3 /* Text */ ? node.parentElement : node;
while (startElement && editor.contains(startElement)) {
var tagName = roosterjs_editor_dom_1.getTagOfNode(startElement);
if (tagName == 'LI') {
return startElement;
}
startElement = startElement.parentElement;
}
return null;
listType = listType || 'LI';
return getListElementAtNode(editor, node, listType);
});
}
exports.default = cacheGetListElement;
function getListElementAtNode(editor, node, listType) {
var startElement = node && node.nodeType == 3 /* Text */ ? node.parentElement : node;
while (startElement && editor.contains(startElement)) {
var tagName = roosterjs_editor_dom_1.getTagOfNode(startElement);
if (tagName == listType) {
return startElement;
}
startElement = startElement.parentElement;
}
return null;
}
exports.getListElementAtNode = getListElementAtNode;
//# sourceMappingURL=cacheGetListElement.js.map
import { Editor } from 'roosterjs-editor-core';
import { ListState, PluginEvent } from 'roosterjs-editor-types';
export declare function getListStateAtNode(editor: Editor, node: Node): ListState;
export declare function getListStateAtSelection(editor: Editor, nodeAtCursor: Node): ListState;
export default function cacheGetListState(editor: Editor, event?: PluginEvent): ListState;

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

}
// In rare cases that an element is both in list and blockquote we treat is as a list element
if (tagName == 'BLOCKQUOTE') {
listState = 3 /* BlockQuote */;
break;
}
startNode = startNode.parentNode;

@@ -33,2 +38,28 @@ }

exports.getListStateAtNode = getListStateAtNode;
// Get the list state from selection
function getListStateAtSelection(editor, nodeAtCursor) {
var contentTraverser = editor.getContentTraverser(1 /* Selection */);
var range = editor.getSelectionRange();
if (contentTraverser && range && !range.collapsed) {
var blockElement = contentTraverser.currentBlockElement;
var listStates = [];
// If any lines in selection is related to blockquote, then the state is blockquote,
// this is treated different than other list states
while (blockElement) {
var listState = getListStateAtNode(editor, blockElement.getStartNode());
if (listState == 3 /* BlockQuote */) {
return 3 /* BlockQuote */;
}
else if (listStates.indexOf(listState) == -1) {
listStates.push(listState);
}
blockElement = contentTraverser.getNextBlockElement();
}
return listStates.length > 1 ? 0 /* None */ : listStates[0];
}
else {
return getListStateAtNode(editor, nodeAtCursor);
}
}
exports.getListStateAtSelection = getListStateAtSelection;
// Get the list state

@@ -35,0 +66,0 @@ function cacheGetListState(editor, event) {

@@ -71,10 +71,3 @@ "use strict";

}
formatter = function () {
return editor.insertNode(anchor_1, {
position: 2 /* SelectionStart */,
updateCursor: true,
replaceSelection: true,
insertOnNewLine: false,
});
};
formatter = function () { return editor.insertNode(anchor_1); };
}

@@ -81,0 +74,0 @@ else {

@@ -83,5 +83,6 @@ "use strict";

var nodeAtCursor = getNodeAtCursor_1.default(editor);
var listState = nodeAtCursor ? cacheGetListState_1.getListStateAtNode(editor, nodeAtCursor) : null;
var listState = nodeAtCursor ? cacheGetListState_1.getListStateAtSelection(editor, nodeAtCursor) : null;
var isBullet = listState && listState == 1 /* Bullets */ ? true : false;
var isNumbering = listState && listState == 2 /* Numbering */ ? true : false;
var isBlockQuote = listState && listState == 3 /* BlockQuote */ ? true : false;
return nodeAtCursor

@@ -105,2 +106,3 @@ ? {

canRedo: editor.canRedo(),
isBlockQuote: isBlockQuote,
}

@@ -107,0 +109,0 @@ : null;

@@ -8,3 +8,3 @@ export { default as cacheGetCursorEventData, clearCursorEventDataCache } from './cursor/cacheGetCursorEventData';

export { default as cacheGetListElement } from './format/cacheGetListElement';
export { default as cacheGetListState, getListStateAtNode } from './format/cacheGetListState';
export { default as cacheGetListState, getListStateAtNode, getListStateAtSelection } from './format/cacheGetListState';
export { default as clearFormat } from './format/clearFormat';

@@ -27,2 +27,3 @@ export { default as createLink } from './format/createLink';

export { default as toggleNumbering } from './format/toggleNumbering';
export { default as toggleBlockQuote } from './format/toggleBlockQuote';
export { default as toggleStrikethrough } from './format/toggleStrikethrough';

@@ -29,0 +30,0 @@ export { default as toggleSubscript } from './format/toggleSubscript';

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

exports.getListStateAtNode = cacheGetListState_1.getListStateAtNode;
exports.getListStateAtSelection = cacheGetListState_1.getListStateAtSelection;
var clearFormat_1 = require("./format/clearFormat");

@@ -56,2 +57,4 @@ exports.clearFormat = clearFormat_1.default;

exports.toggleNumbering = toggleNumbering_1.default;
var toggleBlockQuote_1 = require("./format/toggleBlockQuote");
exports.toggleBlockQuote = toggleBlockQuote_1.default;
var toggleStrikethrough_1 = require("./format/toggleStrikethrough");

@@ -58,0 +61,0 @@ exports.toggleStrikethrough = toggleStrikethrough_1.default;

@@ -5,8 +5,8 @@ {

"dependencies": {
"roosterjs-editor-types": "6.1.1",
"roosterjs-editor-dom": "6.1.1",
"roosterjs-editor-core": "6.1.1"
"roosterjs-editor-types": "6.2.0",
"roosterjs-editor-dom": "6.2.0",
"roosterjs-editor-core": "6.2.0"
},
"main": "./lib/index.js",
"version": "6.1.1",
"version": "6.2.0",
"typings": "./lib/index.d.ts",

@@ -13,0 +13,0 @@ "license": "MIT",

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

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