cm-page-builder
Advanced tools
Comparing version 1.2.23 to 1.2.24
@@ -47,4 +47,2 @@ 'use strict'; | ||
var split = require('split-string'); | ||
//A higher order component for the generic components to handle there functionalily. | ||
@@ -112,3 +110,2 @@ | ||
var allActions = isEdit ? { | ||
'onPaste': this.handlePaste, | ||
'onMouseUp': this.handleMouseUp, | ||
@@ -229,3 +226,2 @@ 'onMouseDown': this.handleMouseDown, | ||
this.handleKeyDown = function (e) { | ||
e.stopPropagation(); | ||
var _props = _this3.props, | ||
@@ -361,23 +357,2 @@ appData = _props.appData, | ||
}; | ||
this.handlePaste = function (e) { | ||
var clipboardData = e.clipboardData || window.clipboardData; | ||
var pastedData = clipboardData.getData('text/html'); | ||
if (pastedData) { | ||
e.preventDefault(); | ||
e.persist(); | ||
var content = pastedData.match(/src="(.[^"]+)"/gm)[0].split("\"")[1]; | ||
if (content) { | ||
var filename = 'attachments'; | ||
var blockId = e.currentTarget.dataset.blockId; | ||
if (!content.includes('base64')) { | ||
(0, _helpers.toDataURL)(content, function (dataUrl) { | ||
_this3.props.updateComponent({ id: blockId, newState: { componentType: 'Upload', component_attachment: { filename: filename, content: dataUrl } } }); | ||
}); | ||
} else { | ||
_this3.props.updateComponent({ id: blockId, newState: { componentType: 'Upload', component_attachment: { filename: filename, content: content } } }); | ||
} | ||
} | ||
} | ||
}; | ||
}; | ||
@@ -384,0 +359,0 @@ |
@@ -7,4 +7,2 @@ 'use strict'; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -34,8 +32,4 @@ | ||
var _assert = require('assert'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -55,16 +49,18 @@ | ||
_this.handleFocusAndBlur = function (oldProps, oldState) { | ||
_this.setFocus = function () { | ||
if (_this.props.currentElem.elemId === _this.props.id) { | ||
if (_this.elem) _this.elem.focus(); | ||
} else if (oldProps && _this.props.currentElem.elemId === oldProps.currentElem.elemId) { | ||
if (_this.elem) _this.elem.blur(); | ||
} | ||
}; | ||
_this.emitChange = function (e) { | ||
_this.emitChange = function (e, context) { | ||
if (!_this.props.componentType && e.target.innerHTML) { | ||
_this.context.emitUpdate(null, { content: e.target.innerHTML }, 'updateTitle'); | ||
context.emitUpdate(null, { content: e.target.innerHTML }, 'updateTitle'); | ||
} // Block to make changes to title of the page | ||
}; | ||
_this.handleMouseUp = function (e) { | ||
if (!_this.props.componentType) _this.props.setCurrentElem(_this.props.id); | ||
}; | ||
_this.handleFocus = function (e) { | ||
@@ -76,14 +72,9 @@ e.persist(); | ||
_this.handleNewLine = function (e) { | ||
if (e.key === 'Enter' && _this.props.id === 'page-title') { | ||
if (e.keyCode === 13 && _this.props.id === 'page-title') { | ||
e.preventDefault(); | ||
_this.emitChange(e); | ||
_this.props.addNewComponent({ id: undefined, componentType: 'Text' }); | ||
return false; | ||
} | ||
}; | ||
_this.handleMouseDown = function (e) { | ||
if (_this.props.id === 'page-title') { | ||
_this.props.setCurrentElem(_this.props.id); | ||
} | ||
}; | ||
_this.state = {}; | ||
@@ -97,8 +88,8 @@ ContentEditable.contextType = _permissionContext.PermissionContext; | ||
value: function componentDidMount() { | ||
this.handleFocusAndBlur(); | ||
this.setFocus(); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate(oldProps, oldState) { | ||
this.handleFocusAndBlur(oldProps, oldState); | ||
value: function componentDidUpdate() { | ||
this.setFocus(); | ||
} | ||
@@ -116,14 +107,4 @@ }, { | ||
content = _props.content; | ||
var context = this.context, | ||
status = this.status; | ||
var context = this.context; | ||
var isEdit = status === 'Edit'; | ||
var actions = _defineProperty({ | ||
onMouseUp: this.handleMouseUp, | ||
onBlur: this.emitChange, | ||
onSelect: context.handleSelection, | ||
onFocus: this.handleFocus, | ||
onMouseDown: this.handleMouseDown, | ||
onKeyDown: this.handleNewLine | ||
}, 'onMouseDown', this.handleMouseDown); | ||
return _react2.default.createElement( | ||
@@ -133,3 +114,3 @@ 'div', | ||
listOrder, | ||
_react2.default.createElement('div', _extends({ | ||
_react2.default.createElement('div', { | ||
'data-root': 'true', | ||
@@ -140,8 +121,15 @@ ref: function ref(node) { | ||
className: (0, _classnames2.default)(className, context.status.toLowerCase()), | ||
styles: styles, | ||
onMouseUp: this.handleMouseUp, | ||
onFocus: this.handleFocus, | ||
onBlur: function onBlur(e) { | ||
return _this2.emitChange(e, context); | ||
}, | ||
contentEditable: context.status === 'Edit', | ||
placeholder: content || context.status === 'Edit' ? placeholder : '', | ||
dangerouslySetInnerHTML: { __html: (0, _sanitizeHtml2.default)(content || '') }, | ||
'data-gramm_editor': 'false' | ||
}, actions)) | ||
styles: styles, | ||
'data-gramm_editor': 'false', | ||
onSelect: context.handleSelection, | ||
onKeyDown: this.handleNewLine | ||
}) | ||
); | ||
@@ -148,0 +136,0 @@ } |
@@ -27,6 +27,2 @@ 'use strict'; | ||
var _reactHelmet = require('react-helmet'); | ||
var _reactHelmet2 = _interopRequireDefault(_reactHelmet); | ||
var _permissionContext = require('../contexts/permission-context'); | ||
@@ -42,4 +38,2 @@ | ||
var _currentElemReducer = require('../redux/reducers/currentElemReducer'); | ||
require('../styles/global.css'); | ||
@@ -82,2 +76,6 @@ | ||
// if(args[2] === 'updateTitle'){ | ||
// args[1].office_id = +this.props.currentOffices[0].id | ||
// } | ||
// console.log("TEST HERE") | ||
(_this$props = _this.props).handleUpdate.apply(_this$props, arguments); | ||
@@ -87,21 +85,2 @@ } | ||
_this.removeFocus = function (e) { | ||
var conElem = document.querySelector('[data-container-block="true"]'); | ||
if (conElem && !conElem.contains(e.target)) { | ||
_this.props.removeCurrentElem(); | ||
} | ||
}; | ||
_this.handlePageUnload = function (e) { | ||
var elemId = _this.props.currentElem.elemId; | ||
if (elemId) { | ||
_this.props.removeCurrentElem(); | ||
var barEl = document.getElementById('bar-text'); | ||
if (barEl) barEl.innerHTML = "Changes saved."; | ||
e.preventDefault(); | ||
e.returnValue = false; | ||
} | ||
}; | ||
_this._getCurrentOrder = function (currentIndex) { | ||
@@ -247,11 +226,2 @@ var appData = _this.props.appData; | ||
_this.handleKeyDown = function (e) { | ||
if (!_this.props.newPage) { | ||
if (e.key === 'Enter' && e.target.dataset.root) { | ||
e.preventDefault(); | ||
if (_this.props.appData.componentData.length > 0) _this.props.setCurrentElem(_this.props.appData.componentData[0].id);else _this.props.addNewComponent({ componentType: 'Text' }); | ||
} | ||
} | ||
}; | ||
_this.state = { | ||
@@ -270,5 +240,3 @@ meta: props.meta, | ||
this.initWindowVar(this.props); | ||
this.initApp(this.props); | ||
document.addEventListener('mousedown', this.removeFocus); | ||
window.addEventListener('beforeunload', this.handlePageUnload); | ||
if (!this.props.newPage) this.props.initComponents(this.props.pageComponents); | ||
} | ||
@@ -278,8 +246,13 @@ }, { | ||
value: function componentWillReceiveProps(newProps) { | ||
if (newProps.meta && !this.props.meta) { | ||
this.initWindowVar(newProps); | ||
this.initApp(newProps); | ||
} | ||
this.initWindowVar(newProps); | ||
} | ||
}, { | ||
key: 'initWindowVar', | ||
value: function initWindowVar(props) { | ||
window.cmPageBuilder = { | ||
handleUpdate: props.handleUpdate, | ||
pid: props.meta && props.meta.id | ||
}; | ||
} | ||
}, { | ||
key: 'componentDidMount', | ||
@@ -318,23 +291,2 @@ value: function componentDidMount() { | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
document.removeEventListener('mousedown', this.removeFocus); | ||
document.removeEventListener('beforeunload', this.handlePageUnload); | ||
} | ||
}, { | ||
key: 'initWindowVar', | ||
value: function initWindowVar(props) { | ||
window.cmPageBuilder = { | ||
handleUpdate: props.handleUpdate, | ||
pid: props.meta && props.meta.id | ||
}; | ||
} | ||
}, { | ||
key: 'initApp', | ||
value: function initApp(props) { | ||
if (!props.newPage && props.meta) { | ||
if (props.pageComponents.length > 0) this.props.initComponents(props.pageComponents);else this.props.addNewComponent({ componentType: 'Text' }); | ||
} | ||
} | ||
}, { | ||
key: 'checkPageHeight', | ||
@@ -364,2 +316,3 @@ value: function checkPageHeight() { | ||
var isEdit = this.props.status === 'Edit'; | ||
console.log(); | ||
return _react2.default.createElement( | ||
@@ -371,11 +324,5 @@ 'div', | ||
onMouseUp: isEdit ? this.handleMouseUp : undefined, | ||
onSelect: isEdit ? this.handleSelection : undefined, | ||
onKeyDown: isEdit ? this.handleKeyDown : undefined | ||
onSelect: isEdit ? this.handleSelection : undefined | ||
}, | ||
_react2.default.createElement( | ||
_reactHelmet2.default, | ||
null, | ||
_react2.default.createElement('link', { rel: 'stylesheet', href: 'https://d1azc1qln24ryf.cloudfront.net/120939/PageBuilder/style-cf.css?fcnavv' }) | ||
), | ||
_react2.default.createElement( | ||
_permissionContext.PermissionContext.Provider, | ||
@@ -452,5 +399,3 @@ { value: { status: this.props.status, emitUpdate: this.emitUpdate } }, | ||
initComponents: _appDataReducers.initComponents, | ||
updatePosition: _appDataReducers.updatePosition, | ||
setCurrentElem: _currentElemReducer.setCurrentElem, | ||
removeCurrentElem: _currentElemReducer.removeCurrentElem | ||
updatePosition: _appDataReducers.updatePosition | ||
}; | ||
@@ -476,3 +421,2 @@ | ||
PageContainer.defaultProps = { | ||
handleUpdate: function handleUpdate() {}, | ||
status: 'Edit', | ||
@@ -479,0 +423,0 @@ updateComponentData: function updateComponentData(data) {}, |
@@ -58,6 +58,11 @@ 'use strict'; | ||
return function (dispatch) { | ||
var newId = createID(); | ||
dispatch({ | ||
type: INIT_COMPONENTS, | ||
data: data | ||
data: data.length === 0 ? [{ content: '', position: 1, componentType: 'Text', id: newId }] : data | ||
}); | ||
dispatch({ | ||
type: _currentElemReducer.SET_CURRENT_ELEM, | ||
elemId: data.length === 0 ? newId : null | ||
}); | ||
}; | ||
@@ -149,3 +154,3 @@ }; | ||
function removeComponentFromState(state, data) { | ||
if (state.componentData.length > 0) { | ||
if (state.componentData.length > 1) { | ||
var componentData = state.componentData; | ||
@@ -166,3 +171,5 @@ var blockId = data.blockId; | ||
} | ||
// if(!isInitial){ | ||
emitUpdate({ id: blockId }, 'remove'); | ||
// } | ||
return _extends({}, state, { componentData: temp }); | ||
@@ -169,0 +176,0 @@ } else { |
@@ -34,17 +34,2 @@ 'use strict'; | ||
// convert url to dataUrl | ||
var toDataURL = exports.toDataURL = function toDataURL(url, callback) { | ||
var xhr = new XMLHttpRequest(); | ||
xhr.onload = function () { | ||
var reader = new FileReader(); | ||
reader.onloadend = function () { | ||
callback(reader.result); | ||
}; | ||
reader.readAsDataURL(xhr.response); | ||
}; | ||
xhr.open('GET', url); | ||
xhr.responseType = 'blob'; | ||
xhr.send(); | ||
}; | ||
//sort pageComponents on the basis of pos | ||
@@ -51,0 +36,0 @@ function sortDataOnPos(data) { |
{ | ||
"name": "cm-page-builder", | ||
"version": "1.2.23", | ||
"version": "1.2.24", | ||
"description": "Awesome react starter kit", | ||
@@ -71,3 +71,2 @@ "main": "lib/page/index.js", | ||
"prop-types": "^15.7.2", | ||
"react-helmet": "^5.2.1", | ||
"react-redux": "^7.1.0", | ||
@@ -80,3 +79,2 @@ "react-transition-group": "^4.0.1", | ||
"sortablejs": "^1.10.0-rc3", | ||
"split-string": "^6.1.0", | ||
"style-loader": "^0.23.1", | ||
@@ -83,0 +81,0 @@ "uuid": "^3.3.2" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19
134363
3146
- Removedreact-helmet@^5.2.1
- Removedsplit-string@^6.1.0
- Removedreact-fast-compare@2.0.4(transitive)
- Removedreact-helmet@5.2.1(transitive)
- Removedreact-side-effect@1.2.0(transitive)
- Removedshallowequal@1.1.0(transitive)
- Removedsplit-string@6.1.0(transitive)