Skip to content

Commit

Permalink
Fix draggable blocks and style pull quote preview (#4285)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc authored Jul 5, 2023
1 parent 21dc6e7 commit 36e6a58
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 56 deletions.
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
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> | null;
Expand Down Expand Up @@ -46,9 +47,9 @@ export class FormattingOptionsTreeSelect extends React.Component<IProps> {
value={values}
allowMultiple
fullWidth
label={gettext('Formatting options')}
labelHidden
inlineLabel
width="100%"
/>
);
}
Expand Down
1 change: 1 addition & 0 deletions scripts/core/editor3/components/Editor3Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ export class Editor3Component extends React.Component<IProps, IState> {
// eslint-disable-next-line react/no-find-dom-node
this.editorNode.current = this.editor === null ?
undefined :
// eslint-disable-next-line react/no-find-dom-node
ReactDOM.findDOMNode(this.editor) as HTMLDivElement;
}

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

0 comments on commit 36e6a58

Please sign in to comment.