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.14.0 to 0.15.0

75

components/__tests__/horizontal-rule.test.js

@@ -83,2 +83,77 @@ /**

});
it('type --- above a paragraph', () => {
const { view } = testEditor(
<doc>
<para>[]</para>
<para>test</para>
</doc>,
);
typeText(view, '---');
expect(view.state).toEqualDocAndSelection(
<doc>
<hr />
<para>[]test</para>
</doc>,
);
});
it('type --- above a hr', () => {
const { view } = testEditor(
<doc>
<para>[]</para>
<hr />
</doc>,
);
typeText(view, '---');
expect(view.state).toEqualDocAndSelection(
<doc>
<hr />
<para>[]</para>
<hr />
</doc>,
);
});
it('type --- inisde a nested blockquote', () => {
const { view } = testEditor(
<doc>
<blockquote>
<blockquote>
<para>[]</para>
</blockquote>
</blockquote>
</doc>,
);
typeText(view, '---');
expect(view.state).toEqualDocAndSelection(
<doc>
<blockquote>
<blockquote>
<hr />
<para>[]</para>
</blockquote>
</blockquote>
</doc>,
);
});
it('type --- inisde a paragraph with more text', () => {
const { view } = testEditor(
<doc>
<para>[]abc</para>
</doc>,
);
typeText(view, '---');
expect(view.state).toEqualDocAndSelection(
<doc>
<hr />
<para>[]abc</para>
</doc>,
);
});
});

29

components/horizontal-rule.js

@@ -43,6 +43,27 @@ import { safeInsert } from '../utils/pm-utils';

let tr = state.tr.replaceWith(start - 1, end, type.createChecked());
return safeInsert(
state.schema.nodes.paragraph.createChecked(),
tr.selection.end,
)(tr);
// Find the paragraph that contains the "---" shortcut text, we need
// it below for deciding whether to insert a new paragraph after the
// hr.
const $para = state.doc.resolve(start);
let insertParaAfter = false;
if ($para.end() != end) {
// if the paragraph has more characters, e.g. "---abc", then no
// need to insert a new paragraph
insertParaAfter = false;
} else if ($para.after() == $para.end(-1)) {
// if the paragraph is the last child of its parent, then insert a
// new paragraph
insertParaAfter = true;
} else {
const nextNode = state.doc.resolve($para.after()).nodeAfter;
// if the next node is a hr, then insert a new paragraph
insertParaAfter = nextNode.type === type;
}
return insertParaAfter
? safeInsert(
state.schema.nodes.paragraph.createChecked(),
tr.mapping.map($para.after()),
)(tr)
: tr;
},

@@ -49,0 +70,0 @@ ),

2

package.json
{
"name": "@bangle.dev/core",
"version": "0.14.0",
"version": "0.15.0",
"homepage": "https://bangle.dev",

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

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