Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix draggable blocks and style pull quote preview #4285

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"sass-loader": "6.0.6",
"shortid": "2.2.8",
"style-loader": "0.20.2",
"superdesk-ui-framework": "3.0.30",
"superdesk-ui-framework": "^3.0.39",
"ts-loader": "3.5.0",
"tslint": "5.11.0",
"typescript": "~4.9.5",
Expand Down
2 changes: 1 addition & 1 deletion scripts/appConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function getUserInterfaceLanguage() {
const user: IUser | null = JSON.parse(localStorage.getItem(IDENTITY_KEY));
const language = user?.language ?? appConfig.default_language ?? window.navigator.language ?? 'en';

if (appConfig.profileLanguages.includes(language)) {
if (appConfig.profileLanguages?.includes(language)) {
return language;
} else {
return 'en';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getEditor3RichFormattingOptions,
} from '../directives/ContentProfileSchemaEditor';
import {IArticleField} from 'superdesk-api';
import {gettext} from 'core/utils';

interface IProps {
value: Array<string>;
Expand Down Expand Up @@ -44,9 +45,9 @@ export class FormattingOptionsTreeSelect extends React.Component<IProps> {
value={values}
allowMultiple
fullWidth
label={gettext('Formatting options')}
labelHidden
inlineLabel
width="100%"
/>
);
}
Expand Down
52 changes: 43 additions & 9 deletions scripts/core/editor3/components/media/dragable-editor3-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,75 @@ import React from 'react';
import {ContentBlock} from 'draft-js';
import {EDITOR_BLOCK_TYPE} from 'core/editor3/constants';
import {connect} from 'react-redux';
import {Spacer} from 'core/ui/components/SubNav/Spacer';
import {DragHandle} from 'superdesk-ui-framework/react';

interface IProps {
block: ContentBlock;
readOnly?: boolean; // connected
children: React.ReactNode;
}

class DragableEditor3BlockComponent extends React.PureComponent<IProps> {
interface IState {
displayHandle: boolean;
}

class DragableEditor3BlockComponent extends React.PureComponent<IProps, IState> {
timeoutId: number;
constructor(props: IProps) {
super(props);

this.onDragStart = this.onDragStart.bind(this);
this.state = {
displayHandle: false,
};
}

onDragStart(event) {
event.dataTransfer.setData(EDITOR_BLOCK_TYPE, this.props.block.getKey());
}

render() {
return (
<div
style={{
display: 'flex',
flexDirection: 'row',
gap: 24,
gap: 4,
}}
onMouseEnter={() => {
this.setState({
displayHandle: true,
});
}}
onMouseLeave={() => {
this.timeoutId = window.setTimeout(() => {
this.setState({
displayHandle: false,
});
}, 3000);
}}
>
<div
style={{
backgroundColor: 'red',
height: '100px',
width: '10px',
}}
className={this.state.displayHandle ? 'draggable-block-handle' : 'draggable-block-handle-hide'}
draggable={this.props.readOnly !== true}
onDragStart={this.onDragStart}
/>
onMouseOver={() => {
this.setState({
displayHandle: true,
}, () => {
window.clearTimeout(this.timeoutId);
});
}}
onMouseEnter={() => {
this.setState({
displayHandle: true,
}, () => {
window.clearTimeout(this.timeoutId);
});
}}
>
<DragHandle />
</div>
{this.props.children}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion scripts/core/editor3/html/to-html/AtomicBlockParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class AtomicBlockParser {
}

const {cells} = data;
let html = '<div className="multi-line-quote">';
let html = '<div class="multi-line-quote">';
const cellContentState = cells[0]?.[0] != null
? convertFromRaw(cells[0][0])
: ContentState.createFromText('');
Expand Down
Loading