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

@the-grid/ed

Package Overview
Dependencies
Maintainers
19
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@the-grid/ed - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

8

CHANGES.md
### dev
# 2.0.1 - 2017-01-26
## 2.1.0 - 2017-01-27
* Save-as-you-type, even non-valid URLs, to avoid inconsistent state bug
* New callback prop for native menus: `onRequestLink` #314
* Extending `ed.execCommand('link:toggle', {href, title})` (title optional) to make `<a>` with current selection
### 2.0.1 - 2017-01-26
* React fix: array child wants key

@@ -6,0 +12,0 @@ * Meta modal autoFocus (also blurs PM editable, so you don't type under the meta modal)

@@ -41,2 +41,5 @@ /* eslint no-console: 0 */

onDropFileOnBlock: onDropFileOnBlockDemo,
// onRequestLink: function (value) {
// console.log('onRequestLink', value)
// },
imgfloConfig: null,

@@ -43,0 +46,0 @@ widgetPath: './node_modules/',

2

demo/fixture.js

@@ -594,3 +594,3 @@ import getHappyLittlePhrase from 'bob-ross-lipsum'

'type': 'text',
'html': `<p>${getHappyLittlePhrase()}<br><strong>Strong.</strong> <em>Em.</em> <strong><em>Both.</em></strong> Plain.</p>`,
'html': `<p>${getHappyLittlePhrase()}<br><strong>Strong.</strong> <em>Em.</em> <strong><em>Both.</em></strong> <a href="http://meemoo.org" title="Web-based media hacking for kids and other artists">Link</a>. Plain.</p>`,
'metadata': {'starred': true},

@@ -597,0 +597,0 @@ },

@@ -84,2 +84,3 @@ 'use strict';

onRequestCoverUpload = props.onRequestCoverUpload,
onRequestLink = props.onRequestLink,
onDropFiles = props.onDropFiles,

@@ -95,2 +96,3 @@ onDropFileOnBlock = props.onDropFileOnBlock,

onRequestCoverUpload: onRequestCoverUpload,
onRequestLink: onRequestLink,
onDropFiles: onDropFiles,

@@ -238,3 +240,3 @@ onDropFileOnBlock: onDropFileOnBlock,

key: 'execCommand',
value: function execCommand(commandName) {
value: function execCommand(commandName, attrs) {
var item = _edMenu.edCommands[commandName];

@@ -244,7 +246,13 @@ if (!item) {

}
var _store$pm$editor = this._store.pm.editor,
state = _store$pm$editor.state,
dispatch = _store$pm$editor.dispatch;
item.spec.run(state, dispatch);
// HACK consider onRequestLink with callback instead
if (commandName === 'link:toggle' && attrs) {
if (this._store._applyLink) {
this._store._applyLink(attrs);
return;
} else {
throw new Error('Must trigger link:toggle once before triggering it with attrs.');
}
}
var view = this._store.pm.editor;
item.spec.run(view.state, view.dispatch, view);
}

@@ -318,2 +326,3 @@ }, {

onRequestCoverUpload: _react2.default.PropTypes.func.isRequired,
onRequestLink: _react2.default.PropTypes.func,
imgfloConfig: _react2.default.PropTypes.object,

@@ -320,0 +329,0 @@ widgetPath: _react2.default.PropTypes.string,

@@ -198,5 +198,3 @@ 'use strict';

this.setState({ value: value, valid: valid });
if (valid && onChange) {
onChange(event);
}
onChange(event);
this.boundResize();

@@ -217,3 +215,3 @@ }

autoCapitalize: _react2.default.PropTypes.string,
onChange: _react2.default.PropTypes.func,
onChange: _react2.default.PropTypes.func.isRequired,
onKeyDown: _react2.default.PropTypes.func,

@@ -220,0 +218,0 @@ multiline: _react2.default.PropTypes.bool,

@@ -23,2 +23,4 @@ 'use strict';

var _storeRef = require('../plugins/store-ref');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -57,3 +59,18 @@

var selectedText = state.doc.textBetween(from, to);
var urlLike = (0, _url.isUrlLike)(selectedText);
var value = urlLike ? selectedText : '';
var callback = function callback(attrs) {
(0, _prosemirrorCommands.toggleMark)(markType, attrs)(view.state, view.dispatch);
view.focus();
};
var ed = _storeRef.key.get(state).options.edStuff.ed;
if (ed.onRequestLink) {
// HACK consider onRequestLink with callback instead
ed._applyLink = callback;
ed.onRequestLink(value);
return true;
}
(0, _menuPrompt.openMenuPrompt)({

@@ -67,2 +84,3 @@ title: 'Create a link',

required: true,
value: value,
clean: function clean(val) {

@@ -73,4 +91,3 @@ if (!/^https?:\/\//i.test(val)) {

return val;
},
value: (0, _url.isUrlLike)(selectedText) ? selectedText : ''
}
}),

@@ -81,7 +98,3 @@ title: new _menuPrompt.TextField({

},
callback: function callback(attrs) {
(0, _prosemirrorCommands.toggleMark)(markType, attrs)(view.state, view.dispatch);
view.focus();
},
callback: callback,
menuEl: menuEl,

@@ -88,0 +101,0 @@ buttonEl: buttonEl

@@ -61,2 +61,3 @@ 'use strict';

this.onRequestCoverUpload = options.onRequestCoverUpload;
this.onRequestLink = options.onRequestLink;
options.onDropFiles = options.onDropFiles || noop;

@@ -63,0 +64,0 @@ this.onDropFileOnBlock = options.onDropFileOnBlock || noop;

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "2.0.1",
"version": "2.1.0",
"description": "the grid api with prosemirror",

@@ -8,0 +8,0 @@ "main": "dist/ed.js",

@@ -86,2 +86,11 @@ `npm start`

// OPTIONAL
onRequestLink: function (value) {
/*
If defined, Ed will _not_ show prompt for link
If selection is url-like, value will be the selected string
App can then call `ed.execCommand('link:toggle', {href, title})`
Note: If that is called while command 'link:toggle' is 'active', it will remove the link, not replace it
*/
},
// OPTIONAL
onDropFiles: function (index, files) {

@@ -132,2 +141,3 @@ /* App calls ed.insertPlaceholders(index, files.length) and gets array of ids back */

// {status (string), progress (number 0-100), failed (boolean)}
// metadata argument with {progress: null} will remove the progress bar
ed.updateProgress(id, metadata)

@@ -134,0 +144,0 @@

@@ -38,10 +38,13 @@ require('./app.css')

const { initialContent
, onChange
, onShareFile
, onShareUrl
, onRequestCoverUpload
, onDropFiles
, onDropFileOnBlock
, onCommandsChanged } = props
const {
initialContent,
onChange,
onShareFile,
onShareUrl,
onRequestCoverUpload,
onRequestLink,
onDropFiles,
onDropFileOnBlock,
onCommandsChanged,
} = props

@@ -54,2 +57,3 @@ this._store = new EdStore(

onRequestCoverUpload,
onRequestLink,
onDropFiles,

@@ -179,3 +183,3 @@ onDropFileOnBlock,

}
execCommand (commandName) {
execCommand (commandName, attrs) {
const item = edCommands[commandName]

@@ -185,4 +189,13 @@ if (!item) {

}
const {state, dispatch} = this._store.pm.editor
item.spec.run(state, dispatch)
// HACK consider onRequestLink with callback instead
if (commandName === 'link:toggle' && attrs) {
if (this._store._applyLink) {
this._store._applyLink(attrs)
return
} else {
throw new Error('Must trigger link:toggle once before triggering it with attrs.')
}
}
const view = this._store.pm.editor
item.spec.run(view.state, view.dispatch, view)
}

@@ -232,2 +245,3 @@ insertPlaceholders (index, count) {

onRequestCoverUpload: React.PropTypes.func.isRequired,
onRequestLink: React.PropTypes.func,
imgfloConfig: React.PropTypes.object,

@@ -234,0 +248,0 @@ widgetPath: React.PropTypes.string,

@@ -153,5 +153,3 @@ require('./textarea-autosize.css')

this.setState({value, valid})
if (valid && onChange) {
onChange(event)
}
onChange(event)
this.boundResize()

@@ -168,3 +166,3 @@ }

autoCapitalize: React.PropTypes.string,
onChange: React.PropTypes.func,
onChange: React.PropTypes.func.isRequired,
onKeyDown: React.PropTypes.func,

@@ -171,0 +169,0 @@ multiline: React.PropTypes.bool,

@@ -7,2 +7,3 @@ import {MenuItem} from 'prosemirror-menu'

import {isUrlLike} from '../util/url'
import {key} from '../plugins/store-ref'

@@ -33,3 +34,17 @@ const markType = EdSchema.marks.link

const selectedText = state.doc.textBetween(from, to)
const urlLike = isUrlLike(selectedText)
const value = (urlLike ? selectedText : '')
const callback = function (attrs) {
toggleMark(markType, attrs)(view.state, view.dispatch)
view.focus()
}
const {ed} = key.get(state).options.edStuff
if (ed.onRequestLink) {
// HACK consider onRequestLink with callback instead
ed._applyLink = callback
ed.onRequestLink(value)
return true
}
openMenuPrompt({

@@ -43,2 +58,3 @@ title: 'Create a link',

required: true,
value,
clean: (val) => {

@@ -50,3 +66,2 @@ if (!/^https?:\/\//i.test(val)) {

},
value: (isUrlLike(selectedText) ? selectedText : ''),
}),

@@ -57,6 +72,3 @@ title: new TextField({

},
callback (attrs) {
toggleMark(markType, attrs)(view.state, view.dispatch)
view.focus()
},
callback,
menuEl,

@@ -63,0 +75,0 @@ buttonEl,

@@ -34,2 +34,3 @@ import _ from '../util/lodash'

this.onRequestCoverUpload = options.onRequestCoverUpload
this.onRequestLink = options.onRequestLink
options.onDropFiles = options.onDropFiles || noop

@@ -36,0 +37,0 @@ this.onDropFileOnBlock = options.onDropFileOnBlock || noop

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

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