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

@stackoverflow/stacks-editor

Package Overview
Dependencies
Maintainers
4
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stackoverflow/stacks-editor - npm Package Compare versions

Comparing version 0.8.1 to 0.8.2

4

dist/commonmark/commands.d.ts

@@ -33,6 +33,6 @@ import { EditorState, Transaction } from "prosemirror-state";

* Inserts a tagLink at the cursor, optionally placing it around the currently selected text if able
* @param validate The validation method that will be used to validate the selected text
* @param options The passed TagLinkOptions
* @param isMetaTag Whether or not the inserted tagLink is for a meta tag
*/
export declare function insertTagLinkCommand(validate: TagLinkOptions["validate"], isMetaTag: boolean): MenuCommand;
export declare function insertTagLinkCommand(options: TagLinkOptions, isMetaTag: boolean): MenuCommand;
/**

@@ -39,0 +39,0 @@ * Inserts a basic table at the cursor

@@ -399,8 +399,11 @@ import { TextSelection } from "prosemirror-state";

* Inserts a tagLink at the cursor, optionally placing it around the currently selected text if able
* @param validate The validation method that will be used to validate the selected text
* @param options The passed TagLinkOptions
* @param isMetaTag Whether or not the inserted tagLink is for a meta tag
*/
export function insertTagLinkCommand(validate, isMetaTag) {
export function insertTagLinkCommand(options, isMetaTag) {
return (state, dispatch) => {
const leading = isMetaTag ? "[meta-tag:" : "[tag:";
if (isMetaTag && options.disableMetaTags) {
return false;
}
if (state.selection.empty) {

@@ -412,3 +415,3 @@ const dummyText = "tag-name";

const selectedText = state.doc.textBetween(from, to);
if (!validate(selectedText.trim(), isMetaTag)) {
if (!options.validate(selectedText.trim(), isMetaTag)) {
return false;

@@ -415,0 +418,0 @@ }

@@ -7,3 +7,3 @@ import { keymap } from "prosemirror-keymap";

export function allKeymaps(parserFeatures) {
const commonmarkKeymap = keymap(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, bindLetterKeymap("Mod-z", undo)), bindLetterKeymap("Mod-y", redo)), bindLetterKeymap("Mod-Shift-z", redo)), { "Tab": indentCommand, "Shift-Tab": indentCommand }), bindLetterKeymap("Mod-b", boldCommand)), bindLetterKeymap("Mod-i", emphasisCommand)), bindLetterKeymap("Mod-l", insertCommonmarkLinkCommand)), bindLetterKeymap("Ctrl-q", blockquoteCommand)), bindLetterKeymap("Mod-k", inlineCodeCommand)), bindLetterKeymap("Mod-g", insertCommonmarkImageCommand)), bindLetterKeymap("Ctrl-g", insertCommonmarkImageCommand)), bindLetterKeymap("Mod-o", orderedListCommand)), bindLetterKeymap("Mod-u", unorderedListCommand)), bindLetterKeymap("Mod-h", headerCommand)), bindLetterKeymap("Mod-r", insertCommonmarkHorizontalRuleCommand)), bindLetterKeymap("Mod-m", insertCodeblockCommand)), bindLetterKeymap("Mod-[", insertTagLinkCommand(parserFeatures.tagLinks.validate, false))), bindLetterKeymap("Mod-]", insertTagLinkCommand(parserFeatures.tagLinks.validate, true))), bindLetterKeymap("Mod-/", spoilerCommand)), bindLetterKeymap("Mod-,", subCommand)), bindLetterKeymap("Mod-.", supCommand)), bindLetterKeymap("Mod-'", kbdCommand)), bindLetterKeymap("Mod-a", selectAllTextCommand)));
const commonmarkKeymap = keymap(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, bindLetterKeymap("Mod-z", undo)), bindLetterKeymap("Mod-y", redo)), bindLetterKeymap("Mod-Shift-z", redo)), { "Tab": indentCommand, "Shift-Tab": indentCommand }), bindLetterKeymap("Mod-b", boldCommand)), bindLetterKeymap("Mod-i", emphasisCommand)), bindLetterKeymap("Mod-l", insertCommonmarkLinkCommand)), bindLetterKeymap("Ctrl-q", blockquoteCommand)), bindLetterKeymap("Mod-k", inlineCodeCommand)), bindLetterKeymap("Mod-g", insertCommonmarkImageCommand)), bindLetterKeymap("Ctrl-g", insertCommonmarkImageCommand)), bindLetterKeymap("Mod-o", orderedListCommand)), bindLetterKeymap("Mod-u", unorderedListCommand)), bindLetterKeymap("Mod-h", headerCommand)), bindLetterKeymap("Mod-r", insertCommonmarkHorizontalRuleCommand)), bindLetterKeymap("Mod-m", insertCodeblockCommand)), bindLetterKeymap("Mod-[", insertTagLinkCommand(parserFeatures.tagLinks, false))), bindLetterKeymap("Mod-]", insertTagLinkCommand(parserFeatures.tagLinks, true))), bindLetterKeymap("Mod-/", spoilerCommand)), bindLetterKeymap("Mod-,", subCommand)), bindLetterKeymap("Mod-.", supCommand)), bindLetterKeymap("Mod-'", kbdCommand)), bindLetterKeymap("Mod-a", selectAllTextCommand)));
const tableKeymap = keymap(Object.assign({}, bindLetterKeymap("Mod-e", insertCommonmarkTableCommand)));

@@ -10,0 +10,0 @@ const keymaps = [commonmarkKeymap, keymap(baseKeymap)];

@@ -52,6 +52,6 @@ import { MarkType, NodeType } from "prosemirror-model";

* Creates a command that toggles tagLink formatting for a node
* @param validate The function to validate the tagName with
* @param options The passed TagLinkOptions
* @param isMetaTag Whether the tag to be created is a meta tag or not
*/
export declare function toggleTagLinkCommand(validate: TagLinkOptions["validate"], isMetaTag: boolean): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
export declare function toggleTagLinkCommand(options: TagLinkOptions, isMetaTag: boolean): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
/**

@@ -58,0 +58,0 @@ * Creates a command that inserts a horizontal rule node

@@ -197,8 +197,11 @@ import { setBlockType, toggleMark, wrapIn } from "prosemirror-commands";

* Creates a command that toggles tagLink formatting for a node
* @param validate The function to validate the tagName with
* @param options The passed TagLinkOptions
* @param isMetaTag Whether the tag to be created is a meta tag or not
*/
export function toggleTagLinkCommand(validate, isMetaTag) {
export function toggleTagLinkCommand(options, isMetaTag) {
return (state, dispatch) => {
var _a;
if (options.disableMetaTags && isMetaTag) {
return false;
}
if (state.selection.empty) {

@@ -227,3 +230,3 @@ return false;

}
if (!validate(selectedText.trim(), isMetaTag)) {
if (!options.validate(selectedText.trim(), isMetaTag)) {
return false;

@@ -230,0 +233,0 @@ }

@@ -16,3 +16,5 @@ import { toggleMark, wrapIn, setBlockType, exitCode, baseKeymap, } from "prosemirror-commands";

const tableKeymap = keymap(Object.assign(Object.assign({}, bindLetterKeymap("Mod-e", insertRichTextTableCommand)), { "Mod-Enter": moveSelectionAfterTableCommand, "Shift-Enter": moveSelectionAfterTableCommand, "Enter": moveToNextCellCommand, "Backspace": removeTableContentCommand, "Delete": removeTableContentCommand, "Mod-Backspace": removeTableContentCommand, "Mod-Delete": removeTableContentCommand, "Tab": moveToNextCellCommand, "Shift-Tab": moveToPreviousCellCommand }));
const richTextKeymap = keymap(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, bindLetterKeymap("Mod-z", undo)), bindLetterKeymap("Mod-y", redo)), bindLetterKeymap("Mod-Shift-z", redo)), { "Backspace": undoInputRule, "Enter": splitListItem(schema.nodes.list_item), "Tab": sinkListItem(schema.nodes.list_item), "Shift-Tab": liftListItem(schema.nodes.list_item), "Mod-Enter": exitBlockCommand, "Shift-Enter": exitBlockCommand }), bindLetterKeymap("Mod-b", toggleMark(schema.marks.strong))), bindLetterKeymap("Mod-i", toggleMark(schema.marks.em))), bindLetterKeymap("Mod-l", insertRichTextLinkCommand)), bindLetterKeymap("Ctrl-q", wrapIn(schema.nodes.blockquote))), bindLetterKeymap("Mod-k", toggleMark(schema.marks.code))), bindLetterKeymap("Mod-g", insertRichTextImageCommand)), bindLetterKeymap("Ctrl-g", insertRichTextImageCommand)), bindLetterKeymap("Mod-o", wrapIn(schema.nodes.ordered_list))), bindLetterKeymap("Mod-u", wrapIn(schema.nodes.bullet_list))), bindLetterKeymap("Mod-h", toggleHeadingLevel())), bindLetterKeymap("Mod-r", insertRichTextHorizontalRuleCommand)), bindLetterKeymap("Mod-m", setBlockType(schema.nodes.code_block))), bindLetterKeymap("Mod-[", toggleTagLinkCommand(parserFeatures.tagLinks.validate, false))), bindLetterKeymap("Mod-]", toggleTagLinkCommand(parserFeatures.tagLinks.validate, true))), bindLetterKeymap("Mod-/", wrapIn(schema.nodes.spoiler))), bindLetterKeymap("Mod-,", toggleMark(schema.marks.sub))), bindLetterKeymap("Mod-.", toggleMark(schema.marks.sup))), bindLetterKeymap("Mod-'", toggleMark(schema.marks.kbd))), {
const richTextKeymap = keymap(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, bindLetterKeymap("Mod-z", undo)), bindLetterKeymap("Mod-y", redo)), bindLetterKeymap("Mod-Shift-z", redo)), { "Backspace": undoInputRule, "Enter": splitListItem(schema.nodes.list_item), "Tab": sinkListItem(schema.nodes.list_item), "Shift-Tab": liftListItem(schema.nodes.list_item), "Mod-Enter": exitBlockCommand, "Shift-Enter": exitBlockCommand }), bindLetterKeymap("Mod-b", toggleMark(schema.marks.strong))), bindLetterKeymap("Mod-i", toggleMark(schema.marks.em))), bindLetterKeymap("Mod-l", insertRichTextLinkCommand)), bindLetterKeymap("Ctrl-q", wrapIn(schema.nodes.blockquote))), bindLetterKeymap("Mod-k", toggleMark(schema.marks.code))), bindLetterKeymap("Mod-g", insertRichTextImageCommand)), bindLetterKeymap("Ctrl-g", insertRichTextImageCommand)), bindLetterKeymap("Mod-o", wrapIn(schema.nodes.ordered_list))), bindLetterKeymap("Mod-u", wrapIn(schema.nodes.bullet_list))), bindLetterKeymap("Mod-h", toggleHeadingLevel())), bindLetterKeymap("Mod-r", insertRichTextHorizontalRuleCommand)), bindLetterKeymap("Mod-m", setBlockType(schema.nodes.code_block))), bindLetterKeymap("Mod-[", toggleTagLinkCommand(parserFeatures.tagLinks, false))), (!parserFeatures.tagLinks.disableMetaTags
? bindLetterKeymap("Mod-]", toggleTagLinkCommand(parserFeatures.tagLinks, true))
: {})), bindLetterKeymap("Mod-/", wrapIn(schema.nodes.spoiler))), bindLetterKeymap("Mod-,", toggleMark(schema.marks.sub))), bindLetterKeymap("Mod-.", toggleMark(schema.marks.sup))), bindLetterKeymap("Mod-'", toggleMark(schema.marks.kbd))), {
// users expect to be able to leave certain blocks/marks using the arrow keys

@@ -19,0 +21,0 @@ "ArrowRight": exitInclusiveMarkCommand, "ArrowDown": exitCode }));

@@ -208,7 +208,7 @@ import { toggleMark } from "prosemirror-commands";

// don't bind the exact listener, call whatever is currently set on `this` at event time
const removeListener = (e) => {
this.removeListener.call(this, e);
const removeListener = () => {
this.removeListener.call(this);
};
const editListener = (e) => {
this.editListener.call(this, e);
const editListener = () => {
this.editListener.call(this);
};

@@ -215,0 +215,0 @@ // hook up the click/keyboard events for the supporting buttons

@@ -19,2 +19,5 @@ function parse_tag_link(state, silent, options) {

const tagName = totalContent.slice(isMeta ? 10 : 5, -1);
if (isMeta && options.disableMetaTags) {
return false;
}
if (options.validate && !options.validate(tagName, isMeta, totalContent)) {

@@ -21,0 +24,0 @@ return false;

@@ -27,3 +27,3 @@ import { toggleMark } from "prosemirror-commands";

commonmark: null,
}, "h1-btn", ["fs-body3", "mt8"]), makeDropdownItem(_t("commands.heading.entry", { level: 2 }), {
}, "h1-btn", ["fs-body3"]), makeDropdownItem(_t("commands.heading.entry", { level: 2 }), {
richText: {

@@ -47,16 +47,16 @@ command: toggleHeadingLevel({ level: 2 }),

const moreFormattingDropdown = (schema, options) => {
var _a, _b, _c, _d, _e, _f, _g, _h;
var _a, _b, _c, _d, _e, _f;
return makeMenuDropdown("EllipsisHorizontal", _t("commands.moreFormatting"), "more-formatting-dropdown", () => true, () => false, makeDropdownItem(_t("commands.tagLink", { shortcut: getShortcut("Mod-[") }), {
richText: {
command: toggleTagLinkCommand((_b = (_a = options.parserFeatures) === null || _a === void 0 ? void 0 : _a.tagLinks) === null || _b === void 0 ? void 0 : _b.validate, false),
command: toggleTagLinkCommand((_a = options.parserFeatures) === null || _a === void 0 ? void 0 : _a.tagLinks, false),
active: nodeTypeActive(schema.nodes.tagLink),
},
commonmark: insertTagLinkCommand((_d = (_c = options.parserFeatures) === null || _c === void 0 ? void 0 : _c.tagLinks) === null || _d === void 0 ? void 0 : _d.validate, false),
}, "tag-btn"), makeDropdownItem(_t("commands.metaTagLink", { shortcut: getShortcut("Mod-]") }), {
commonmark: insertTagLinkCommand((_b = options.parserFeatures) === null || _b === void 0 ? void 0 : _b.tagLinks, false),
}, "tag-btn"), addIf(makeDropdownItem(_t("commands.metaTagLink", { shortcut: getShortcut("Mod-]") }), {
richText: {
command: toggleTagLinkCommand((_f = (_e = options.parserFeatures) === null || _e === void 0 ? void 0 : _e.tagLinks) === null || _f === void 0 ? void 0 : _f.validate, true),
command: toggleTagLinkCommand((_c = options.parserFeatures) === null || _c === void 0 ? void 0 : _c.tagLinks, true),
active: nodeTypeActive(schema.nodes.tagLink),
},
commonmark: insertTagLinkCommand((_h = (_g = options.parserFeatures) === null || _g === void 0 ? void 0 : _g.tagLinks) === null || _h === void 0 ? void 0 : _h.validate, true),
}, "meta-tag-btn"), makeDropdownItem(_t("commands.spoiler", { shortcut: getShortcut("Mod-/") }), {
commonmark: insertTagLinkCommand((_d = options.parserFeatures) === null || _d === void 0 ? void 0 : _d.tagLinks, true),
}, "meta-tag-btn"), !((_f = (_e = options.parserFeatures) === null || _e === void 0 ? void 0 : _e.tagLinks) === null || _f === void 0 ? void 0 : _f.disableMetaTags)), makeDropdownItem(_t("commands.spoiler", { shortcut: getShortcut("Mod-/") }), {
richText: {

@@ -63,0 +63,0 @@ command: toggleWrapIn(schema.nodes.spoiler),

@@ -202,3 +202,3 @@ import { Plugin, } from "prosemirror-state";

const popover = document.createElement("div");
popover.className = "s-popover wmn-initial w-auto px0 pt0 pb8";
popover.className = "s-popover wmn-initial w-auto px0 pt0 py8";
popover.id = popoverId;

@@ -205,0 +205,0 @@ popover.setAttribute("role", "menu");

@@ -51,2 +51,4 @@ import type { Node } from "prosemirror-model";

export interface TagLinkOptions {
/** Disables meta tag support entirely, removing entries from the menu and skipping calls to validate */
disableMetaTags?: boolean;
/**

@@ -53,0 +55,0 @@ * Callback to check if a tagname is valid; a return value of false fails the token parsing

{
"name": "@stackoverflow/stacks-editor",
"version": "0.8.1",
"version": "0.8.2",
"description": "",

@@ -50,3 +50,3 @@ "repository": {

"@commitlint/config-conventional": "^17.1.0",
"@playwright/test": "^1.26.0",
"@playwright/test": "^1.27.1",
"@stackoverflow/commitlint-config": "^1.0.0",

@@ -56,11 +56,11 @@ "@stackoverflow/eslint-config": "^1.0.0",

"@stackoverflow/tsconfig": "^1.0.0",
"@types/jest": "^29.0.3",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"@types/jest": "^29.2.0",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"clean-webpack-plugin": "^4.0.0",
"css-loader": "^6.7.1",
"cssnano": "^5.1.13",
"eslint": "^8.24.0",
"eslint": "^8.25.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^27.0.4",
"eslint-plugin-jest": "^27.1.3",
"eslint-plugin-no-unsanitized": "^4.0.1",

@@ -71,16 +71,16 @@ "highlight.js": "^11.6.0",

"husky": "^8.0.1",
"jest": "^29.0.3",
"jest-environment-jsdom": "^29.0.3",
"jest": "^29.2.1",
"jest-environment-jsdom": "^29.2.1",
"less": "^4.1.3",
"less-loader": "^11.0.0",
"less-loader": "^11.1.0",
"liquidjs-loader": "^1.0.1",
"mini-css-extract-plugin": "^2.6.1",
"mini-svg-data-uri": "^1.4.4",
"postcss": "^8.4.16",
"postcss": "^8.4.18",
"postcss-loader": "^7.0.1",
"prettier": "^2.7.1",
"standard-version": "^9.5.0",
"ts-jest": "^29.0.2",
"ts-jest": "^29.0.3",
"ts-loader": "^9.4.1",
"typescript": "^4.8.3",
"typescript": "^4.8.4",
"webpack": "^5.74.0",

@@ -93,6 +93,6 @@ "webpack-bundle-analyzer": "^4.6.1",

"dependencies": {
"@lezer/highlight": "^1.1.1",
"@lezer/highlight": "^1.1.2",
"@lezer/markdown": "^1.0.2",
"@stackoverflow/stacks": "^1.3.6",
"@stackoverflow/stacks-icons": "^3.0.5",
"@stackoverflow/stacks-icons": "^4.0.0",
"@types/markdown-it": "12.2.3",

@@ -107,9 +107,9 @@ "markdown-it": "^13.0.1",

"prosemirror-lezer": "^0.0.5",
"prosemirror-markdown": "^1.9.4",
"prosemirror-markdown": "^1.10.0",
"prosemirror-model": "^1.18.1",
"prosemirror-schema-basic": "^1.2.0",
"prosemirror-schema-list": "^1.2.2",
"prosemirror-state": "^1.4.1",
"prosemirror-state": "^1.4.2",
"prosemirror-transform": "^1.7.0",
"prosemirror-view": "^1.28.2"
"prosemirror-view": "^1.29.0"
},

@@ -116,0 +116,0 @@ "peerDependencies": {

Sorry, the diff of this file is too big to display

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