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

@remirror/extension-mention

Package Overview
Dependencies
Maintainers
1
Versions
333
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@remirror/extension-mention - npm Package Compare versions

Comparing version

to
0.11.1

7

CHANGELOG.md
# @remirror/extension-mention
## 0.11.1
### Patch Changes
- bd606ca0: Fixes #263 by adding `this.getExtraAttrs(node)` to the `MentionExtension.schema.parseDOM`
attribute. Now custom attributes passed into the `extraAttrs` options will be parsed from the DOM.
## 0.11.0

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

6

lib/dist/extension-mention.cjs.js

@@ -15,4 +15,4 @@ 'use strict';

var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty'));
var prosemirrorSuggest = require('prosemirror-suggest');
var core = require('@remirror/core');
var prosemirrorSuggest = require('prosemirror-suggest');

@@ -374,7 +374,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

var label = node.innerText;
return {
return _objectSpread$1({}, _this2.getExtraAttrs(node), {
id: id,
label: label,
name: name
};
});
}

@@ -381,0 +381,0 @@ }],

@@ -9,4 +9,4 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { DEFAULT_SUGGESTER, getRegexPrefix, escapeChar, regexToString, isSplitReason, isInvalidSplitReason, isRemovedReason } from 'prosemirror-suggest';
import { bool, isPlainObject, pick, isString, replaceText, removeMark, markPasteRule, getMatchString, MarkGroup, isElementDOMNode, MarkExtension, getMarkRange, isMarkActive, noop } from '@remirror/core';
import { DEFAULT_SUGGESTER, getRegexPrefix, escapeChar, regexToString, isSplitReason, isInvalidSplitReason, isRemovedReason } from 'prosemirror-suggest';

@@ -368,7 +368,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

var label = node.innerText;
return {
return _objectSpread$1({}, _this2.getExtraAttrs(node), {
id: id,
label: label,
name: name
};
});
}

@@ -375,0 +375,0 @@ }],

@@ -0,3 +1,3 @@

import { Suggester } from 'prosemirror-suggest';
import { CommandMarkTypeParams, ExtensionManagerMarkTypeParams, MarkExtension, MarkExtensionSpec, RangeParams } from '@remirror/core';
import { Suggester } from 'prosemirror-suggest';
import { MentionExtensionOptions } from './mention-types';

@@ -4,0 +4,0 @@ /**

@@ -15,4 +15,4 @@ 'use strict';

var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty'));
var prosemirrorSuggest = require('prosemirror-suggest');
var core = require('@remirror/core');
var prosemirrorSuggest = require('prosemirror-suggest');
var mentionUtils = require('./mention-utils.js');

@@ -325,7 +325,7 @@

var label = node.innerText;
return {
return _objectSpread({}, _this2.getExtraAttrs(node), {
id: id,
label: label,
name: name
};
});
}

@@ -332,0 +332,0 @@ }],

@@ -0,3 +1,3 @@

import { FromToEndParams, SuggestReplacementType, Suggester } from 'prosemirror-suggest';
import { Attrs, MarkExtensionOptions } from '@remirror/core';
import { FromToEndParams, SuggestReplacementType, Suggester } from 'prosemirror-suggest';
export interface OptionalMentionExtensionParams {

@@ -4,0 +4,0 @@ /**

@@ -8,4 +8,4 @@ 'use strict';

var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty'));
var prosemirrorSuggest = require('prosemirror-suggest');
var core = require('@remirror/core');
var prosemirrorSuggest = require('prosemirror-suggest');

@@ -12,0 +12,0 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

{
"name": "@remirror/extension-mention",
"version": "0.11.0",
"version": "0.11.1",
"description": "Mention extension for the remirror wysiwyg editor",

@@ -24,5 +24,5 @@ "homepage": "https://github.com/remirror/remirror/tree/master/@remirror/extension-mention",

"prosemirror-keymap": "^1.0.2",
"prosemirror-state": "^1.2.4",
"prosemirror-state": "^1.3.2",
"prosemirror-suggest": "^0.7.6",
"prosemirror-view": "^1.12.0"
"prosemirror-view": "^1.14.4"
},

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

@@ -1,3 +0,1 @@

import { fromHTML, toHTML } from '@remirror/core';
import { createBaseTestManager } from '@remirror/test-fixtures';
import { pmBuild } from 'jest-prosemirror';

@@ -7,2 +5,5 @@ import { renderEditor } from 'jest-remirror';

import { fromHTML, toHTML } from '@remirror/core';
import { createBaseTestManager } from '@remirror/test-fixtures';
import { MentionExtension, MentionExtensionOptions } from '../';

@@ -38,4 +39,33 @@ import { MentionExtensionSuggestCommand } from '../mention-types';

const expected = doc(p(mention(attrs.label)));
expect(node).toEqualProsemirrorNode(expected);
});
describe('extraAttrs', () => {
const custom = 'test';
const { schema } = createBaseTestManager([
{
extension: new MentionExtension({
matchers: [],
extraAttrs: ['data-custom'],
}),
priority: 1,
},
]);
const { doc, p, mention } = pmBuild(schema, {
mention: { markType: 'mention', ['data-custom']: custom, ...attrs },
});
it('parses the dom structure and finds itself with custom attributes', () => {
const node = fromHTML({
schema,
content: `<a class="mention mention-at" data-custom="${custom}" data-mention-id="${attrs.id}" data-mention-name="${attrs.name}">${attrs.label}</a>`,
});
const expected = doc(p(mention(attrs.label)));
expect(node).toEqualProsemirrorNode(expected);
});
});
});

@@ -63,2 +93,3 @@

});
expect(mentionOne.options.matchers).toEqual([{ char: '#', name: 'tag' }]);

@@ -125,2 +156,3 @@ });

add(doc(p('<cursor>'))).insertText(`This ${label} `);
expect(view.state).toContainRemirrorDocument(p(`This ${label} `));

@@ -137,2 +169,3 @@ });

add(doc(p('hello <cursor>friend'))).insertText(`${label} `);
expect(view.state).toContainRemirrorDocument(p('hello ', mentionMark(label), ' friend'));

@@ -144,2 +177,3 @@ });

add(doc(p(splitMention('@1<cursor>23')))).insertText(` `);
expect(view.state).toContainRemirrorDocument(

@@ -153,2 +187,3 @@ p(mention({ id: '1', label: '@1', name: 'at' })('@1'), ' 23'),

add(doc(p(splitMention('@<cursor>123')))).insertText(` `);
expect(view.state).toContainRemirrorDocument(p('@ 123'));

@@ -159,2 +194,3 @@ });

add(doc(p('hello <cursor>friend'))).insertText(`${label}`);
expect(view.dom).toContainHTML('<a class="suggest suggest-at">@mentionfriend</a>');

@@ -165,2 +201,3 @@ });

add(doc(p('<cursor>'))).insertText(`This ${label} `);
expect(view.state).toContainRemirrorDocument(p('This ', mentionMark(label), ' '));

@@ -193,8 +230,11 @@ expect(mocks.onChange).toHaveBeenCalledTimes(id.length);

add(doc(p('<cursor>'))).insertText(`This ${labelFn('#')} `);
expect(view.state).toContainRemirrorDocument(p('This ', hashMark(labelFn('#')), ' '));
add(doc(p('<cursor>'))).insertText(`This ${labelFn('+')} `);
expect(view.state).toContainRemirrorDocument(p('This ', plusMark(labelFn('+')), ' '));
add(doc(p('<cursor>'))).insertText(`This ${labelFn('@')} `);
expect(view.state).toContainRemirrorDocument(p('This ', atMark(labelFn('@')), ' '));

@@ -201,0 +241,0 @@ });

import {
Suggester,
escapeChar,
getRegexPrefix,
isInvalidSplitReason,
isRemovedReason,
isSplitReason,
regexToString,
} from 'prosemirror-suggest';
import {
Attrs,

@@ -21,11 +31,2 @@ CommandMarkTypeParams,

} from '@remirror/core';
import {
Suggester,
escapeChar,
getRegexPrefix,
isInvalidSplitReason,
isRemovedReason,
isSplitReason,
regexToString,
} from 'prosemirror-suggest';

@@ -94,3 +95,3 @@ import {

const label = node.innerText;
return { id, label, name };
return { ...this.getExtraAttrs(node), id, label, name };
},

@@ -97,0 +98,0 @@ },

@@ -1,4 +0,5 @@

import { Attrs, MarkExtensionOptions } from '@remirror/core';
import { FromToEndParams, SuggestReplacementType, Suggester } from 'prosemirror-suggest';
import { Attrs, MarkExtensionOptions } from '@remirror/core';
export interface OptionalMentionExtensionParams {

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

@@ -1,4 +0,5 @@

import { Attrs, bool, isPlainObject, isString, pick } from '@remirror/core';
import { DEFAULT_SUGGESTER } from 'prosemirror-suggest';
import { Attrs, bool, isPlainObject, isString, pick } from '@remirror/core';
import { MentionExtensionAttrs, MentionExtensionMatcher } from './mention-types';

@@ -5,0 +6,0 @@

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet