@files-stack/client-redux
Advanced tools
Comparing version 0.0.26-5 to 0.0.26-6
@@ -39,2 +39,5 @@ import * as actionTypes from './types'; | ||
type: actionTypes.CLOSE_ALL_EDITORS; | ||
}) | ({ | ||
type: actionTypes.KEEP_OPEN_EDITOR; | ||
content: IContent; | ||
}); | ||
@@ -53,1 +56,2 @@ export declare const openFileAction: (payload: any) => EditAction; | ||
export declare const closeAllEditorAction: () => EditAction; | ||
export declare const keepOpenAction: (content: IContent) => EditAction; |
@@ -53,1 +53,3 @@ export declare type SET_ROOTPATH = '@@files-stack/SET_ROOTPATH'; | ||
export declare const CLOSE_ALL_EDITORS: CLOSE_ALL_EDITORS; | ||
export declare type KEEP_OPEN_EDITOR = '@@files-stack/KEEP_OPEN_EDITOR'; | ||
export declare const KEEP_OPEN_EDITOR: KEEP_OPEN_EDITOR; |
137
lib/index.js
@@ -100,2 +100,3 @@ module.exports = | ||
exports.CLOSE_ALL_EDITORS = '@@files-stack/CLOSE_ALL_EDITORS'; | ||
exports.KEEP_OPEN_EDITOR = '@@files-stack/KEEP_OPEN_EDITOR'; | ||
@@ -120,4 +121,4 @@ | ||
__export(__webpack_require__(0)); | ||
__export(__webpack_require__(8)); | ||
__export(__webpack_require__(9)); | ||
__export(__webpack_require__(10)); | ||
@@ -137,3 +138,3 @@ | ||
__export(__webpack_require__(2)); | ||
__export(__webpack_require__(10)); | ||
__export(__webpack_require__(11)); | ||
@@ -300,2 +301,3 @@ | ||
const lodash_1 = __webpack_require__(7); | ||
const core_1 = __webpack_require__(8); | ||
const actionTypes = __webpack_require__(0); | ||
@@ -327,28 +329,40 @@ const initialEditState = { | ||
editorsHeight = state.editorsHeight; | ||
if (editors.length === 0) { | ||
editors = [1]; | ||
editorsHeight = [{ editorId: 1, height: 80 }]; | ||
activeEditorId = 1; | ||
openingFiles = [...state.openingFiles]; | ||
index = ramda_1.findIndex(ramda_1.whereEq({ | ||
resource: 'file://' + action.payload.resource, | ||
editorId: activeEditorId, | ||
}))(openingFiles); | ||
if (index !== -1) { | ||
openingFiles[index] = Object.assign({}, openingFiles[index], { preopen: false }); | ||
editingFiles = lodash_1.filter(state.editingFiles, item => item.editorId !== activeEditorId); | ||
editingFiles.push(Object.assign({}, openingFiles[index])); | ||
return Object.assign({}, state, { openingFiles: [...openingFiles], editingFiles: [...editingFiles] }); | ||
} | ||
if (action.payload.editorId) { | ||
activeEditorId = action.payload.editorId; | ||
index = editors.indexOf(action.payload.editorId); | ||
if (index === -1) { | ||
if (editors.length < 3) { | ||
editors.push(action.payload.editorId); | ||
editorsHeight.push({ editorId: action.payload.editorId, height: 80 }); | ||
else { | ||
if (editors.length === 0) { | ||
editors = [1]; | ||
editorsHeight = [{ editorId: 1, height: 80 }]; | ||
activeEditorId = 1; | ||
} | ||
if (action.payload.editorId) { | ||
activeEditorId = action.payload.editorId; | ||
index = editors.indexOf(action.payload.editorId); | ||
if (index === -1) { | ||
if (editors.length < 3) { | ||
editors.push(action.payload.editorId); | ||
editorsHeight.push({ editorId: action.payload.editorId, height: 80 }); | ||
} | ||
else { | ||
activeEditorId = editors[editors.length - 1]; | ||
} | ||
} | ||
else { | ||
activeEditorId = editors[editors.length - 1]; | ||
} | ||
} | ||
readingFile = { | ||
resource: action.payload.resource, | ||
name: action.payload.name, | ||
editorId: activeEditorId, | ||
}; | ||
return Object.assign({}, state, { readingFile, | ||
activeEditorId, editors: [...editors], editorsHeight: [...editorsHeight], oldValue: action.payload ? action.payload.oldValue : null, deleted: action.payload ? action.payload.deleted : null, addIgnore: action.payload ? action.payload.addIgnore : null }); | ||
} | ||
readingFile = { | ||
resource: action.payload.resource, | ||
name: action.payload.name, | ||
editorId: activeEditorId, | ||
}; | ||
console.log('readingFile', readingFile); | ||
return Object.assign({}, state, { readingFile, | ||
activeEditorId, editors: [...editors], editorsHeight: [...editorsHeight], oldValue: action.payload ? action.payload.oldValue : null, deleted: action.payload ? action.payload.deleted : null, addIgnore: action.payload ? action.payload.addIgnore : null }); | ||
case actionTypes.ADD_EDIT: | ||
@@ -360,2 +374,5 @@ if (action.content.editorId) { | ||
editorsHeight = [...state.editorsHeight]; | ||
if (action.content.preopen) { | ||
openingFiles = lodash_1.filter(openingFiles, item => !(item.editorId === editorId && item.preopen)); | ||
} | ||
if (editors.length === 0) { | ||
@@ -454,15 +471,42 @@ editors = [editorId]; | ||
case actionTypes.SELECT_EDIT: | ||
editorId = action.content.editorId; | ||
openingFiles = state.openingFiles; | ||
activeEditorId = state.activeEditorId; | ||
editingFiles = lodash_1.filter(state.editingFiles, item => item.editorId !== editorId); | ||
editors = [...state.editors]; | ||
editorsHeight = state.editorsHeight; | ||
openingFiles = [...state.openingFiles]; | ||
index = ramda_1.findIndex(ramda_1.whereEq({ | ||
resource: action.content.resource, | ||
editorId, | ||
editorId: action.content.editorId, | ||
}))(openingFiles); | ||
if (index !== -1) { | ||
return Object.assign({}, state, { editingFiles: [...editingFiles, Object.assign({}, openingFiles[index])], activeEditorId: editorId }); | ||
editingFiles = lodash_1.filter(state.editingFiles, item => item.editorId !== action.content.editorId); | ||
editingFiles.push(Object.assign({}, openingFiles[index])); | ||
return Object.assign({}, state, { editingFiles: [...editingFiles] }); | ||
} | ||
else { | ||
return state; | ||
if (editors.length === 0) { | ||
editors = [1]; | ||
editorsHeight = [{ editorId: 1, height: 80 }]; | ||
activeEditorId = 1; | ||
} | ||
if (action.content.editorId) { | ||
activeEditorId = action.content.editorId; | ||
index = editors.indexOf(action.content.editorId); | ||
if (index === -1) { | ||
if (editors.length < 3) { | ||
editors.push(action.content.editorId); | ||
editorsHeight.push({ editorId: action.content.editorId, height: 80 }); | ||
} | ||
else { | ||
activeEditorId = editors[editors.length - 1]; | ||
} | ||
} | ||
} | ||
readingFile = { | ||
resource: core_1.getPath(action.content.resource), | ||
name: action.content.name, | ||
editorId: activeEditorId, | ||
preopen: true, | ||
}; | ||
return Object.assign({}, state, { readingFile, | ||
activeEditorId, editors: [...editors], editorsHeight: [...editorsHeight], openingFiles: [...openingFiles] }); | ||
} | ||
@@ -480,2 +524,5 @@ case actionTypes.CHANGE_EDIT: | ||
openingFiles[itemIndex] = Object.assign({}, openingFiles[itemIndex], { newValue: action.newValue }); | ||
if (item.editorId === activeEditorFile.editorId) { | ||
openingFiles[itemIndex]['preopen'] = false; | ||
} | ||
} | ||
@@ -488,2 +535,15 @@ }); | ||
} | ||
case actionTypes.KEEP_OPEN_EDITOR: | ||
openingFiles = state.openingFiles; | ||
index = ramda_1.findIndex(ramda_1.whereEq({ | ||
editorId: action.content.editorId, | ||
resource: action.content.resource, | ||
}))(openingFiles); | ||
if (index !== -1) { | ||
openingFiles[index] = Object.assign({}, openingFiles[index], { preopen: false }); | ||
return Object.assign({}, state, { openingFiles: [...openingFiles] }); | ||
} | ||
else { | ||
return state; | ||
} | ||
case actionTypes.UPDATE_CONTENT: | ||
@@ -570,2 +630,8 @@ openingFiles = state.openingFiles; | ||
/* 8 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("@files-stack/core"); | ||
/***/ }), | ||
/* 9 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -625,3 +691,3 @@ | ||
/***/ }), | ||
/* 9 */ | ||
/* 10 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -669,6 +735,9 @@ | ||
}); | ||
exports.keepOpenAction = (content) => ({ | ||
type: actionTypes.KEEP_OPEN_EDITOR, content, | ||
}); | ||
/***/ }), | ||
/* 10 */ | ||
/* 11 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -682,7 +751,7 @@ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(__webpack_require__(11)); | ||
__export(__webpack_require__(12)); | ||
/***/ }), | ||
/* 11 */ | ||
/* 12 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -689,0 +758,0 @@ |
@@ -40,2 +40,5 @@ export { Store } from './Store'; | ||
type: "@@files-stack/CLOSE_ALL_EDITORS"; | ||
} | { | ||
type: "@@files-stack/KEEP_OPEN_EDITOR"; | ||
content: IContent; | ||
}) => IEdit; | ||
@@ -78,2 +81,5 @@ '@files/finderOptions': (state: IFinderOptions, action: { | ||
type: "@@files-stack/CLOSE_ALL_EDITORS"; | ||
} | { | ||
type: "@@files-stack/KEEP_OPEN_EDITOR"; | ||
content: IContent; | ||
}) => IFinderOptions; | ||
@@ -80,0 +86,0 @@ '@files/expand': (state: IFileExpand[], action: { |
{ | ||
"name": "@files-stack/client-redux", | ||
"version": "0.0.26-5", | ||
"version": "0.0.26-6", | ||
"description": "Files Redux consists of reducers and actions", | ||
@@ -56,4 +56,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@files-stack/client-core": "^0.0.26-5", | ||
"@files-stack/core": "^0.0.26-5" | ||
"@files-stack/client-core": "^0.0.26-6", | ||
"@files-stack/core": "^0.0.26-6" | ||
}, | ||
@@ -60,0 +60,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
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
108135
1309