This repository has been archived by the owner on Oct 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1710b35
commit 1c5d750
Showing
10 changed files
with
257 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.drop-indicator { | ||
width: 100%; | ||
min-height: 6rem; | ||
} | ||
|
||
.drop-indicator .ui.message { | ||
/* padding: 0px; */ | ||
} | ||
|
||
.drop-indicator .ui.message center { | ||
height: 100%; | ||
/* margin: 0 auto; */ | ||
} | ||
|
||
.drop-indicator .ui.message center img { | ||
width: 100%; | ||
height: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { nestContent } from '@plone/volto/helpers'; | ||
import { UPLOAD_CONTENT } from 'volto-slate/constants'; | ||
|
||
// A custom version of Volto's createContent that can take an "origin" block id | ||
export function uploadContent(url, content, origin) { | ||
return { | ||
type: UPLOAD_CONTENT, | ||
origin, | ||
request: Array.isArray(content) | ||
? content.map((item) => ({ op: 'post', path: url, data: item })) | ||
: { op: 'post', path: url, data: nestContent(content) }, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export saveSlateBlockSelection from './selection'; | ||
export * from './content'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
export const LISTTYPES = ['bulleted-list', 'numbered-list']; | ||
|
||
export default { | ||
LISTTYPES, | ||
}; | ||
export const SAVE_SLATE_BLOCK_SELECTION = 'SAVE_SLATE_BLOCK_SELECTION'; | ||
export const UPLOAD_CONTENT = 'UPLOAD_CONTENT'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* Upload reducer. | ||
* @module reducers/content | ||
* | ||
* Customized copy of Volto's content reducer | ||
*/ | ||
|
||
import { settings } from '~/config'; | ||
|
||
import { UPLOAD_CONTENT } from 'volto-slate/constants'; | ||
|
||
const initialState = {}; | ||
|
||
/** | ||
* Content reducer. | ||
* @function content | ||
* @param {Object} state Current state. | ||
* @param {Object} action Action to be handled. | ||
* @returns {Object} New state. | ||
*/ | ||
export default function upload_content(state = initialState, action = {}) { | ||
let { result, origin } = action; | ||
switch (action.type) { | ||
case `${UPLOAD_CONTENT}_PENDING`: | ||
return { | ||
...state, | ||
[origin]: { | ||
...state[origin], | ||
upload: { | ||
loading: true, | ||
loaded: false, | ||
error: null, | ||
}, | ||
}, | ||
}; | ||
case `${UPLOAD_CONTENT}_SUCCESS`: | ||
return { | ||
...state, | ||
[origin]: { | ||
...state[origin], | ||
data: { | ||
...result, | ||
items: | ||
action.result && | ||
action.result.items && | ||
action.result.items.map((item) => ({ | ||
...item, | ||
url: item['@id'].replace(settings.apiPath, ''), | ||
})), | ||
}, | ||
upload: { | ||
loading: false, | ||
loaded: true, | ||
error: null, | ||
}, | ||
}, | ||
}; | ||
case `${UPLOAD_CONTENT}_FAIL`: | ||
return { | ||
...state, | ||
[origin]: { | ||
...state[origin], | ||
data: null, | ||
upload: { | ||
loading: false, | ||
loaded: false, | ||
error: action.error, | ||
}, | ||
}, | ||
}; | ||
default: | ||
return state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export slate_block_selections from './selection'; | ||
export upload_content from './content'; |