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

@bangle.dev/core

Package Overview
Dependencies
Maintainers
1
Versions
143
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bangle.dev/core - npm Package Compare versions

Comparing version 0.9.1 to 0.10.0

components/components.js

2

__tests__/editor.test.js

@@ -6,3 +6,3 @@ /**

import { SpecRegistry } from '../spec-registry';
import { psx, renderTestEditor } from '../test-helpers/index';
import { psx, renderTestEditor } from '../test-helpers/test-helpers';
import { BangleEditorState, BangleEditor, blockquote, heading } from '../index';

@@ -9,0 +9,0 @@ import { coreSpec } from '../utils/core-components';

import { MarkType, NodeType } from 'prosemirror-model';
import { hardBreak, doc, paragraph, text, bold } from '../components/index';
import {
hardBreak,
doc,
paragraph,
text,
bold,
} from '../components/components';

@@ -4,0 +10,0 @@ import { SpecRegistry } from '../spec-registry';

@@ -11,5 +11,5 @@ /**

typeText,
} from '../../test-helpers/index';
} from '../../test-helpers/test-helpers';
import { blockquote } from '../index';
import { blockquote } from '../components';

@@ -16,0 +16,0 @@ const keybindings = blockquote.defaultKeys;

@@ -6,6 +6,10 @@ /**

/** @jsx psx */
import { psx, renderTestEditor, sendKeyToPm } from '../../test-helpers/index';
import {
psx,
renderTestEditor,
sendKeyToPm,
} from '../../test-helpers/test-helpers';
import { setSelectionNear } from '../../test-helpers/selection-helpers';
import { bold } from '../index';
import { bold } from '../components';

@@ -12,0 +16,0 @@ const keybindings = bold.defaultKeys;

@@ -6,4 +6,8 @@ /**

/** @jsx psx */
import { psx, renderTestEditor, sendKeyToPm } from '../../test-helpers/index';
import { codeBlock } from '../index';
import {
psx,
renderTestEditor,
sendKeyToPm,
} from '../../test-helpers/test-helpers';
import { codeBlock } from '../components';

@@ -10,0 +14,0 @@ const testEditor = renderTestEditor();

@@ -11,6 +11,6 @@ /**

typeChar,
} from '../../test-helpers/index';
} from '../../test-helpers/test-helpers';
import { setSelectionNear } from '../../test-helpers/selection-helpers';
import { code } from '../index';
import { code } from '../components';

@@ -17,0 +17,0 @@ const keybindings = code.defaultKeys;

@@ -19,3 +19,3 @@ /**

heading,
} from '@bangle.dev/core/components';
} from '@bangle.dev/core';
import {

@@ -25,3 +25,3 @@ psx,

createPSXFragment,
} from '@bangle.dev/core/test-helpers/index';
} from '@bangle.dev/core/test-helpers/test-helpers';
import { toggleHeadingCollapse, uncollapseAllHeadings } from '../heading';

@@ -28,0 +28,0 @@

@@ -6,5 +6,9 @@ /**

/** @jsx psx */
import { psx, renderTestEditor, sendKeyToPm } from '../../test-helpers/index';
import {
psx,
renderTestEditor,
sendKeyToPm,
} from '../../test-helpers/test-helpers';
import { hardBreak } from '../index';
import { hardBreak } from '../components';
const keybindings = hardBreak.defaultKeys;

@@ -11,0 +15,0 @@

@@ -11,4 +11,4 @@ /**

typeText,
} from '../../test-helpers/index';
import { heading } from '../index';
} from '../../test-helpers/test-helpers';
import { heading } from '../components';

@@ -15,0 +15,0 @@ const testEditor = renderTestEditor();

@@ -6,3 +6,7 @@ /**

/** @jsx psx */
import { psx, renderTestEditor, typeText } from '../../test-helpers/index';
import {
psx,
renderTestEditor,
typeText,
} from '../../test-helpers/test-helpers';

@@ -9,0 +13,0 @@ describe('Markdown shorthand works', () => {

@@ -12,3 +12,3 @@ /**

createEvent,
} from '../../test-helpers/index';
} from '../../test-helpers/test-helpers';

@@ -15,0 +15,0 @@ import { sleep } from '../../utils/js-utils';

@@ -6,6 +6,10 @@ /**

/** @jsx psx */
import { psx, renderTestEditor, sendKeyToPm } from '../../test-helpers/index';
import {
psx,
renderTestEditor,
sendKeyToPm,
} from '../../test-helpers/test-helpers';
import { setSelectionNear } from '../../test-helpers/selection-helpers';
import { italic } from '../index';
import { italic } from '../components';

@@ -12,0 +16,0 @@ const keybindings = italic.defaultKeys;

@@ -11,3 +11,3 @@ /**

selectNodeAt,
} from '../../test-helpers/index';
} from '../../test-helpers/test-helpers';
import { toggleMark } from 'prosemirror-commands';

@@ -24,3 +24,3 @@ import { queryLinkAttrs, updateLink } from '../link';

paragraph,
} from '../index';
} from '../components';
import { SpecRegistry } from '../../spec-registry';

@@ -27,0 +27,0 @@

@@ -6,3 +6,3 @@ /**

/** @jsx psx */
import { doc, heading, paragraph, text } from '../../components/index';
import { doc, heading, paragraph, text } from '../components';
import { SpecRegistry } from '../../spec-registry';

@@ -14,3 +14,3 @@ import {

sendKeyToPm,
} from '../../test-helpers/index';
} from '../../test-helpers/test-helpers';
import {

@@ -17,0 +17,0 @@ convertToParagraph,

@@ -6,6 +6,10 @@ /**

/** @jsx psx */
import { psx, renderTestEditor, sendKeyToPm } from '../../test-helpers/index';
import {
psx,
renderTestEditor,
sendKeyToPm,
} from '../../test-helpers/test-helpers';
import { setSelectionNear } from '../../test-helpers/selection-helpers';
import { strike } from '../index';
import { strike } from '../components';

@@ -12,0 +16,0 @@ const keybindings = strike.defaultKeys;

@@ -10,5 +10,5 @@ /**

sendKeyToPm,
} from '../../test-helpers/index';
} from '../../test-helpers/test-helpers';
import { siblingsAndNodesBetween } from '../list-item/todo';
import { listItem } from '../index';
import { listItem } from '../components';

@@ -15,0 +15,0 @@ const testEditor = renderTestEditor();

@@ -6,6 +6,10 @@ /**

/** @jsx psx */
import { psx, renderTestEditor, sendKeyToPm } from '../../test-helpers/index';
import {
psx,
renderTestEditor,
sendKeyToPm,
} from '../../test-helpers/test-helpers';
import { setSelectionNear } from '../../test-helpers/selection-helpers';
import { underline } from '../index';
import { underline } from '../components';

@@ -12,0 +16,0 @@ const keybindings = underline.defaultKeys;

@@ -1,205 +0,1 @@

import { chainCommands } from 'prosemirror-commands';
import { keymap } from 'prosemirror-keymap';
import {
indentList,
backspaceKeyCommand,
enterKeyCommand,
outdentList,
moveEdgeListItem,
updateNodeAttrs,
} from './commands';
import {
cutEmptyCommand,
copyEmptyCommand,
parentHasDirectParentOfType,
moveNode,
} from '../../core-commands';
import { filter, insertEmpty } from '../../utils/pm-utils';
import { domSerializationHelpers } from '../../utils/dom-serialization-helpers';
import browser from '../../utils/browser';
import { isNodeTodo, setTodoCheckedAttr } from './todo';
import { listItemNodeViewPlugin } from './list-item-node-view-plugin';
const LOG = false;
let log = LOG ? console.log.bind(console, 'list-item') : () => {};
export const spec = specFactory;
export const plugins = pluginsFactory;
export const commands = {
indentListItem,
outdentListItem,
moveListItemUp,
moveListItemDown,
};
export const defaultKeys = {
toggleDone: browser.mac ? 'Ctrl-Enter' : 'Ctrl-I',
indent: 'Tab',
outdent: 'Shift-Tab',
moveDown: 'Alt-ArrowDown',
moveUp: 'Alt-ArrowUp',
emptyCopy: 'Mod-c',
emptyCut: 'Mod-x',
insertEmptyListAbove: 'Mod-Shift-Enter',
insertEmptyListBelow: 'Mod-Enter',
};
const name = 'listItem';
const getTypeFromSchema = (schema) => schema.nodes[name];
function specFactory(opts = {}) {
const { toDOM, parseDOM } = domSerializationHelpers(name, {
tag: 'li',
content: 0,
});
return {
type: 'node',
name,
schema: {
content: '(paragraph) (paragraph | bulletList | orderedList)*',
defining: true,
draggable: true,
attrs: {
todoChecked: {
default: null,
},
},
toDOM,
parseDOM,
},
markdown: {
toMarkdown(state, node) {
if (node.attrs.todoChecked != null) {
state.write(node.attrs.todoChecked ? '[x] ' : '[ ] ');
}
state.renderContent(node);
},
parseMarkdown: {
list_item: {
block: name,
getAttrs: (tok) => {
return {
todoChecked: tok.attrGet('isDone'),
};
},
},
},
},
};
}
function pluginsFactory({ keybindings = defaultKeys, nodeView = true } = {}) {
return ({ schema }) => {
const type = getTypeFromSchema(schema);
const isBulletList = parentHasDirectParentOfType(type, [
schema.nodes['bulletList'],
schema.nodes['orderedList'],
]);
return [
keybindings &&
keymap({
[keybindings.toggleDone]: filter(
isBulletList,
updateNodeAttrs(schema.nodes['listItem'], (attrs) => ({
...attrs,
todoChecked:
attrs.todoChecked == null ? false : !attrs.todoChecked,
})),
),
Backspace: backspaceKeyCommand(type),
Enter: enterKeyCommand(type),
[keybindings.indent]: indentListItem(),
[keybindings.outdent]: outdentListItem(),
[keybindings.moveUp]: moveListItemUp(),
[keybindings.moveDown]: moveListItemDown(),
[keybindings.emptyCut]: filter(isBulletList, cutEmptyCommand(type)),
[keybindings.emptyCopy]: filter(isBulletList, copyEmptyCommand(type)),
[keybindings.insertEmptyListAbove]: chainCommands(
filter(
isSelectionInsideTodo,
insertEmpty(type, 'above', true, { todoChecked: false }),
),
filter(isBulletList, insertEmpty(type, 'above', true)),
),
[keybindings.insertEmptyListBelow]: chainCommands(
filter(
isSelectionInsideTodo,
insertEmpty(type, 'below', true, { todoChecked: false }),
),
filter(isBulletList, insertEmpty(type, 'below', true)),
),
}),
nodeView && listItemNodeViewPlugin(name),
];
};
}
export function indentListItem() {
return (state, dispatch, view) => {
const type = getTypeFromSchema(state.schema);
return indentList(type)(state, dispatch, view);
};
}
export function outdentListItem() {
return (state, dispatch, view) => {
const type = getTypeFromSchema(state.schema);
return outdentList(type)(state, dispatch, view);
};
}
const isSelectionInsideTodo = (state) => {
return isNodeTodo(state.selection.$from.node(-1), state.schema);
};
function moveListItem(dir) {
return (state, dispatch, view) => {
const { schema } = state;
const type = getTypeFromSchema(schema);
const isBulletList = parentHasDirectParentOfType(type, [
schema.nodes['bulletList'],
schema.nodes['orderedList'],
]);
const move = (dir) =>
chainCommands(moveNode(type, dir), (state, dispatch, view) => {
const node = state.selection.$from.node(-3);
const isParentTodo = isNodeTodo(node, state.schema);
const result = moveEdgeListItem(type, dir)(state, dispatch, view);
if (!result) {
return false;
}
// if parent was a todo convert the moved edge node
// to todo bullet item
if (isParentTodo && dispatch) {
const state = view.state;
let { tr, schema } = state;
tr = setTodoCheckedAttr(
tr,
schema,
state.selection.$from.node(-1),
state.selection.$from.before(-1),
);
dispatch(tr);
}
return true;
});
return filter(isBulletList, move(dir))(state, dispatch, view);
};
}
export function moveListItemUp() {
return moveListItem('UP');
}
export function moveListItemDown() {
return moveListItem('DOWN');
}
export * from './list-item-component';
import * as logging from './utils/logging';
import browser, { isChromeWithSelectionBug } from './utils/browser';
import * as utils from './utils';
import * as utils from './utils/utils';
export * from './components/index';
export * from './components/components';
export * from './bangle-editor';

@@ -7,0 +7,0 @@ export * from './bangle-editor-state';

{
"name": "@bangle.dev/core",
"version": "0.9.1",
"version": "0.10.0",
"homepage": "https://bangle.dev",

@@ -5,0 +5,0 @@ "authors": [

import { Schema } from 'prosemirror-model';
import { doc, paragraph, text } from './components/index';
import { doc, paragraph, text } from './components/components';
import { bangleWarn } from './utils/js-utils';

@@ -4,0 +4,0 @@

@@ -5,3 +5,3 @@ /**

/** @jsx psx */
import { psx, renderTestEditor, typeText } from '../../test-helpers/index';
import { psx, renderTestEditor, typeText } from '../test-helpers';

@@ -8,0 +8,0 @@ const testEditor = renderTestEditor();

@@ -6,3 +6,3 @@ /**

/** @jsx psx */
import { psx, renderTestEditor } from '../index';
import { psx, renderTestEditor } from '../test-helpers';

@@ -9,0 +9,0 @@ const testEditor = renderTestEditor();

@@ -21,3 +21,3 @@ import {

image,
} from '../components/index';
} from '../components/components';

@@ -24,0 +24,0 @@ export function defaultSpecs(opts = {}) {

@@ -5,3 +5,3 @@ /**

/** @jsx psx */
import { psx, renderTestEditor } from '../../test-helpers/index';
import { psx, renderTestEditor } from '../../test-helpers/test-helpers';

@@ -8,0 +8,0 @@ import { isFirstChildOfParent, findCutBefore } from '../pm-utils';

@@ -21,3 +21,3 @@ import {

image,
} from '../components/index';
} from '../components/components';

@@ -24,0 +24,0 @@ export function coreSpec() {

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