Fixed google sign in

This commit is contained in:
benweet 2017-11-17 00:38:55 +00:00
parent fcff116d92
commit 0dd787a4e6
10 changed files with 86 additions and 43 deletions

View File

@ -90,7 +90,7 @@ export default {
.toc__inner { .toc__inner {
color: rgba(0, 0, 0, 0.75); color: rgba(0, 0, 0, 0.75);
cursor: pointer; cursor: pointer;
font-size: 10px; font-size: 9px;
padding: 10px 20px 40px; padding: 10px 20px 40px;
white-space: nowrap; white-space: nowrap;
-webkit-user-select: none; -webkit-user-select: none;

View File

@ -260,6 +260,10 @@ textarea {
.discussion-preview-highlighting { .discussion-preview-highlighting {
cursor: pointer; cursor: pointer;
&.discussion-preview-highlighting--selected {
cursor: auto;
}
} }
.hidden-rendering-container { .hidden-rendering-container {

View File

@ -160,6 +160,10 @@ img {
vertical-align: top; vertical-align: top;
} }
.page-break-after {
page-break-after: always;
}
.stackedit__html { .stackedit__html {
margin-bottom: 180px; margin-bottom: 180px;
margin-left: auto; margin-left: auto;

View File

@ -186,20 +186,6 @@ export default {
padding-top: 10px; padding-top: 10px;
} }
.comment--last {
opacity: 0.33;
cursor: pointer;
* {
pointer-events: none;
}
&:hover,
&.comment--hover {
opacity: 0.67;
}
}
.comment-list__current-discussion { .comment-list__current-discussion {
border-top: 2px solid; border-top: 2px solid;
border-bottom: 2px solid; border-bottom: 2px solid;
@ -217,10 +203,25 @@ export default {
font-weight: 600; font-weight: 600;
} }
.comment { /* use div selector to avoid collision with Prism */
div.comment {
padding: 5px 10px 10px; padding: 5px 10px 10px;
} }
.comment--last {
opacity: 0.33;
cursor: pointer;
* {
pointer-events: none;
}
&:hover,
&.comment--hover {
opacity: 0.5;
}
}
.comment__header { .comment__header {
font-size: 0.75em; font-size: 0.75em;
padding-bottom: 0.25em; padding-bottom: 0.25em;

View File

@ -39,6 +39,7 @@ export default {
methods: { methods: {
...mapMutations('discussion', [ ...mapMutations('discussion', [
'setIsCommenting', 'setIsCommenting',
'setNewCommentFocus',
]), ]),
addComment() { addComment() {
const text = this.$store.state.discussion.newCommentText.trim(); const text = this.$store.state.discussion.newCommentText.trim();
@ -88,7 +89,7 @@ export default {
selectionEnd: this.$store.state.discussion.newCommentSelection.end, selectionEnd: this.$store.state.discussion.newCommentSelection.end,
getCursorFocusRatio: () => 0.2, getCursorFocusRatio: () => 0.2,
}); });
this.$nextTick(() => clEditor.focus()); clEditor.on('focus', () => this.setNewCommentFocus(true));
// Save typed content and selection // Save typed content and selection
clEditor.on('contentChanged', value => clEditor.on('contentChanged', value =>
@ -98,6 +99,15 @@ export default {
start, end, start, end,
})); }));
this.$watch(
() => this.$store.state.discussion.currentDiscussionId,
() => this.$nextTick(() => {
if (this.$store.state.discussion.newCommentFocus) {
clEditor.focus();
}
}),
{ immediate: true });
const isSticky = this.$el.parentNode.classList.contains('sticky-comment'); const isSticky = this.$el.parentNode.classList.contains('sticky-comment');
if (isSticky) { if (isSticky) {
let scrollerMirrorElt; let scrollerMirrorElt;
@ -124,8 +134,10 @@ export default {
clEditor.setContent(text); clEditor.setContent(text);
const selection = this.$store.state.discussion.newCommentSelection; const selection = this.$store.state.discussion.newCommentSelection;
clEditor.selectionMgr.setSelectionStartEnd(selection.start, selection.end); clEditor.selectionMgr.setSelectionStartEnd(selection.start, selection.end);
if (this.$store.state.discussion.newCommentFocus) {
clEditor.focus(); clEditor.focus();
} }
}
}, },
{ immediate: true }, { immediate: true },
); );

View File

@ -64,21 +64,28 @@ function stripDiscussionOffsets(objectMap) {
} }
function restoreDiscussionOffsets(content, markerKeys) { function restoreDiscussionOffsets(content, markerKeys) {
const len = content.text.length; // Init offsets (just in case)
Object.keys(content.discussions).forEach((discussionId) => {
const discussion = content.discussions[discussionId];
discussion.start = 0;
discussion.end = 0;
});
// Go through markers
let count = 0;
const maxIdx = markerKeys.length; const maxIdx = markerKeys.length;
for (let i = 0; i < len; i += 1) { content.text = content.text.replace(/[\ue000-\uf8ff]/g, (match, offset) => {
const idx = content.text.charCodeAt(i) - 0xe000; const idx = match.charCodeAt(0) - 0xe000;
if (idx >= 0 && idx < maxIdx) { if (idx >= maxIdx) {
return match;
}
const markerKey = markerKeys[idx]; const markerKey = markerKeys[idx];
content.text = content.text.slice(0, i) + content.text.slice(i + 1);
const discussion = content.discussions[markerKey.id]; const discussion = content.discussions[markerKey.id];
if (discussion) { if (discussion) {
discussion[markerKey.offsetName] = i; discussion[markerKey.offsetName] = offset - count;
}
// We just removed the current character, we may have multiple markers with same offset
i -= 1;
}
} }
count += 1;
return '';
});
} }
function mergeText(serverText, clientText, lastMergedText) { function mergeText(serverText, clientText, lastMergedText) {

View File

@ -18,7 +18,7 @@ let editorClassAppliers = {};
let previewClassAppliers = {}; let previewClassAppliers = {};
function getDiscussionMarkers(discussion, discussionId, onMarker) { function getDiscussionMarkers(discussion, discussionId, onMarker) {
function getMarker(offsetName) { const getMarker = (offsetName) => {
const markerKey = `${discussionId}:${offsetName}`; const markerKey = `${discussionId}:${offsetName}`;
let marker = discussionMarkers[markerKey]; let marker = discussionMarkers[markerKey];
if (!marker) { if (!marker) {
@ -29,7 +29,7 @@ function getDiscussionMarkers(discussion, discussionId, onMarker) {
discussionMarkers[markerKey] = marker; discussionMarkers[markerKey] = marker;
} }
onMarker(marker); onMarker(marker);
} };
getMarker('start'); getMarker('start');
getMarker('end'); getMarker('end');
} }
@ -117,7 +117,6 @@ export default {
createClEditor(editorElt) { createClEditor(editorElt) {
this.clEditor = cledit(editorElt, editorElt.parentNode); this.clEditor = cledit(editorElt, editorElt.parentNode);
clEditor = this.clEditor; clEditor = this.clEditor;
removeDiscussionMarkers();
clEditor.on('contentChanged', (text) => { clEditor.on('contentChanged', (text) => {
const oldContent = store.getters['content/current']; const oldContent = store.getters['content/current'];
const newContent = { const newContent = {
@ -136,10 +135,12 @@ export default {
store.dispatch('content/patchCurrent', newContent); store.dispatch('content/patchCurrent', newContent);
isChangePatch = false; isChangePatch = false;
}); });
clEditor.on('focus', () => store.commit('discussion/setNewCommentFocus', false));
}, },
initClEditorInternal(opts) { initClEditorInternal(opts) {
const content = store.getters['content/current']; const content = store.getters['content/current'];
if (content) { if (content) {
removeDiscussionMarkers(); // Markers will be recreated on contentChanged
const contentState = store.getters['contentState/current']; const contentState = store.getters['contentState/current'];
const options = Object.assign({ const options = Object.assign({
selectionStart: contentState.selectionStart, selectionStart: contentState.selectionStart,

View File

@ -168,9 +168,12 @@ export default {
})) }))
// Call the user info endpoint // Call the user info endpoint
.then(token => this.getUser(token.sub) .then(token => this.getUser(token.sub)
.then((user) => { .catch(() => {
store.dispatch('notification/info', 'Please activate Google Plus to change your account name!');
})
.then((user = {}) => {
// Add name to token // Add name to token
token.name = user.displayName; token.name = user.displayName || 'Unknown';
const existingToken = store.getters['data/googleTokens'][token.sub]; const existingToken = store.getters['data/googleTokens'][token.sub];
if (existingToken) { if (existingToken) {
// We probably retrieved a new token with restricted scopes. // We probably retrieved a new token with restricted scopes.

View File

@ -12,9 +12,10 @@ export default {
currentDiscussionId: null, currentDiscussionId: null,
newDiscussion: null, newDiscussion: null,
newDiscussionId: null, newDiscussionId: null,
isCommenting: false,
newCommentText: '', newCommentText: '',
newCommentSelection: { start: 0, end: 0 }, newCommentSelection: { start: 0, end: 0 },
isCommenting: false, newCommentFocus: false,
stickyComment: null, stickyComment: null,
}, },
mutations: { mutations: {
@ -29,21 +30,27 @@ export default {
state.newDiscussionId = utils.uid(); state.newDiscussionId = utils.uid();
state.currentDiscussionId = state.newDiscussionId; state.currentDiscussionId = state.newDiscussionId;
state.isCommenting = true; state.isCommenting = true;
state.newCommentFocus = true;
}, },
patchNewDiscussion: (state, value) => { patchNewDiscussion: (state, value) => {
Object.assign(state.newDiscussion, value); Object.assign(state.newDiscussion, value);
}, },
setIsCommenting: (state, value) => {
state.isCommenting = value;
if (!value) {
state.newDiscussionId = null;
} else {
state.newCommentFocus = true;
}
},
setNewCommentText: (state, value) => { setNewCommentText: (state, value) => {
state.newCommentText = value || ''; state.newCommentText = value || '';
}, },
setNewCommentSelection: (state, value) => { setNewCommentSelection: (state, value) => {
state.newCommentSelection = value; state.newCommentSelection = value;
}, },
setIsCommenting: (state, value) => { setNewCommentFocus: (state, value) => {
state.isCommenting = value; state.newCommentFocus = value;
if (!value) {
state.newDiscussionId = null;
}
}, },
setStickyComment: (state, value) => { setStickyComment: (state, value) => {
state.stickyComment = value; state.stickyComment = value;

View File

@ -39,6 +39,11 @@ function computeStyles(state, getters, localSettings = getters['data/localSettin
} }
styles.innerWidth = state.layout.bodyWidth; styles.innerWidth = state.layout.bodyWidth;
if (styles.innerWidth < constants.editorMinWidth
+ constants.gutterWidth + constants.buttonBarWidth
) {
styles.layoutOverflow = true;
}
if (styles.showSideBar) { if (styles.showSideBar) {
styles.innerWidth -= constants.sideBarWidth; styles.innerWidth -= constants.sideBarWidth;
} }
@ -53,7 +58,6 @@ function computeStyles(state, getters, localSettings = getters['data/localSettin
} }
if (doublePanelWidth < constants.editorMinWidth) { if (doublePanelWidth < constants.editorMinWidth) {
doublePanelWidth = constants.editorMinWidth; doublePanelWidth = constants.editorMinWidth;
styles.layoutOverflow = true;
} }
if (styles.showSidePreview && doublePanelWidth / 2 < constants.editorMinWidth) { if (styles.showSidePreview && doublePanelWidth / 2 < constants.editorMinWidth) {