Skip to content

Commit c482c7e

Browse files
authored
Merge pull request #977 from ubyssey/smart-quote
Smart quote
2 parents e9871a3 + 6a2e043 commit c482c7e

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

dispatch/static/manager/src/js/vendor/dispatch-editor/components/Editor.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,33 +96,34 @@ class ContentEditor extends React.Component {
9696
const { editorState } = this.state;
9797
const selection = editorState.getSelection();
9898
const content = editorState.getCurrentContent();
99+
const style = editorState.getCurrentInlineStyle();
99100
const currentIndex = selection.getEndOffset();
100101
const currentBlock = editorState.getCurrentContent().getBlockForKey(selection.getStartKey()).getText().substring(0, currentIndex);
101102

102103
let contentReplaced = Modifier.insertText(content, selection, str);
103104

104105
if(currentBlock !== "") {
105106
if(str === '\"' && currentBlock.lastIndexOf('“') <= currentBlock.lastIndexOf('”') && currentBlock[currentIndex-1].match(/[\s-]/g)) {
106-
contentReplaced = Modifier.insertText(content, selection, '“');
107+
contentReplaced = Modifier.insertText(content, selection, '“', style);
107108
}
108109
else if(str === '\"') {
109-
contentReplaced = Modifier.insertText(content, selection, '”');
110+
contentReplaced = Modifier.insertText(content, selection, '”', style);
110111
}
111112
else if(str === "\'" && currentBlock.lastIndexOf('‘') <= currentBlock.lastIndexOf('’') && currentBlock[currentIndex-1].match(/[\s-]/g)) {
112-
contentReplaced = Modifier.insertText(content, selection, '‘');
113+
contentReplaced = Modifier.insertText(content, selection, '‘', style);
113114
}
114115
else if(str === "\'") {
115-
contentReplaced = Modifier.insertText(content, selection, );
116+
contentReplaced = Modifier.insertText(content, selection, '’', style);
116117
} else {
117118
return false;
118119
}
119120
}
120121
else {
121122
if(str === "\'") {
122-
contentReplaced = Modifier.insertText(content, selection, '‘');
123+
contentReplaced = Modifier.insertText(content, selection, '‘', style);
123124
}
124125
else if (str === '\"'){
125-
contentReplaced = Modifier.insertText(content, selection, '“');
126+
contentReplaced = Modifier.insertText(content, selection, '“', style);
126127
}
127128
else {
128129
return false;

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(name='dispatch',
44
description='A publishing platform for modern newspapers',
5-
version='1.3.3',
5+
version='1.3.4',
66
url='https://github.com/ubyssey/dispatch',
77
author='Peter Siemens',
88
author_email='peterjsiemens@gmail.com',

0 commit comments

Comments
 (0)