Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Revert "Multi line title (#575)"
Browse files Browse the repository at this point in the history
This reverts commit b5a7fef.
  • Loading branch information
kevinansfield committed Mar 14, 2017
1 parent e1f5ee8 commit 7661212
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 252 deletions.
95 changes: 0 additions & 95 deletions app/components/gh-title.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/styles/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@import "components/selectize.css";
@import "components/power-select.css";
@import "components/publishmenu.css";
@import "components/title.css";


/* Layouts: Groups of Components
/* ---------------------------------------------------------- */
Expand Down
24 changes: 0 additions & 24 deletions app/styles/components/title.css

This file was deleted.

1 change: 1 addition & 0 deletions app/styles/layouts/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ body > .ember-view:not(.default-liquid-destination) {
margin: 0;
padding: 0;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 2rem;
line-height: 1.2em;
font-weight: 400;
Expand Down
1 change: 0 additions & 1 deletion app/templates/components/gh-title.hbs

This file was deleted.

24 changes: 1 addition & 23 deletions app/templates/editor/edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,8 @@
</header>
<div class="gh-editor-container">
<div class="gh-editor-inner">

{{#gh-view-title classNames="gh-editor-title" openMobileMenu="openMobileMenu"}}
{{gh-title
value=(readonly model.titleScratch)
onChange=(action (mut model.titleScratch))
tabindex="1"
shouldFocus=shouldFocusTitle
focus-out="updateTitle"
update=(action (perform updateTitle))
keyDown=(action "titleKeyDown")
id='gh-title'
}}
<!--{ {gh-trim-focus-input
model.titleScratch
type="text"
id="entry-title"
placeholder="Your Post Title"
tabindex="1"
shouldFocus=shouldFocusTitle
focus-out="updateTitle"
update=(action (perform updateTitle))
keyDown=(action "titleKeyDown")
} }-->
{{gh-trim-focus-input model.titleScratch type="text" id="entry-title" placeholder="Your Post Title" tabindex="1" shouldFocus=shouldFocusTitle focus-out="updateTitle" update=(action (perform updateTitle)) keyDown=(action "titleKeyDown")}}
{{/gh-view-title}}
{{#if scheduleCountdown}}
<time datetime="{{post.publishedAtUTC}}" class="gh-notification gh-notification-schedule">
Expand All @@ -72,7 +51,6 @@
apiRoot=apiRoot
assetPath=assetPath
tabindex=2
titleQuery='#gh-title div'
containerSelector='.gh-editor-container'
}}
</div>
Expand Down
55 changes: 0 additions & 55 deletions lib/gh-koenig/addon/components/gh-koenig.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {MOBILEDOC_VERSION} from 'mobiledoc-kit/renderers/mobiledoc';
import createCardFactory from '../lib/card-factory';
import defaultCommands from '../options/default-commands';
import editorCards from '../cards/index';
import $ from 'jquery';
// import { VALID_MARKUP_SECTION_TAGNAMES } from 'mobiledoc-kit/models/markup-section'; //the block elements supported by mobile-doc

export const BLANK_DOC = {
Expand Down Expand Up @@ -118,30 +117,6 @@ export default Component.extend({

this.editor.cursorDidChange(() => this.cursorMoved());

// hack to track key up to focus back on the title when the up key is pressed
this.editor.element.addEventListener('keydown', (event) => {
if (event.keyCode === 38) {
let range = window.getSelection().getRangeAt(0); // get the actual range within the DOM.
let cursorPositionOnScreen = range.getBoundingClientRect();
let topOfEditor = this.editor.element.getBoundingClientRect().top;
if (cursorPositionOnScreen.top < topOfEditor + 33) {
let $title = $(this.titleQuery);

// let offset = findCursorPositionFromPixel($title[0].firstChild, cursorPositionOnScreen.left);

// let newRange = document.createRange();
// newRange.collapse(true);
// newRange.setStart($title[0].firstChild, offset);
// newRange.setEnd($title[0].firstChild, offset);
// updateCursor(newRange);

$title[0].focus();

return false;
}
}
});

},

// drag and drop images onto the editor
Expand Down Expand Up @@ -174,33 +149,3 @@ export default Component.extend({
}

});

// // code for moving the cursor into the correct position of the title: (is buggy)

// // find the cursor position based on a pixel offset of an element.
// // used to move the cursor vertically into the title.
// function findCursorPositionFromPixel(el, horizontal_offset) {
// let len = el.textContent.length;
// let range = document.createRange();
// for(let i = len -1; i > -1; i--) {
// range.setStart(el, i);
// range.setEnd(el, i + 1);
// let rect = range.getBoundingClientRect();
// if (rect.top === rect.bottom) {
// continue;
// }
// if(rect.left <= horizontal_offset && rect.right >= horizontal_offset) {
// return i + (horizontal_offset >= (rect.left + rect.right) / 2 ? 1 : 0); // if the horizontal_offset is on the left hand side of the
// // character then return `i`, if it's on the right return `i + 1`
// }
// }

// return el.length;
// }

// // update the cursor position.
// function updateCursor(range) {
// let selection = window.getSelection();
// selection.removeAllRanges();
// selection.addRange(range);
// }
20 changes: 6 additions & 14 deletions tests/acceptance/editor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {invalidateSession, authenticateSession} from 'ghost-admin/tests/helpers/
import Mirage from 'ember-cli-mirage';
import sinon from 'sinon';
import testSelector from 'ember-test-selectors';
import {titleRendered} from '../helpers/editor-helpers';

describe('Acceptance: Editor', function() {
let application;

Expand All @@ -25,7 +25,7 @@ describe('Acceptance: Editor', function() {
});

it('redirects to signin when not authenticated', function () {
server.create('user'); // necesary for post-author association
server.create('user'); // necessray for post-author association
server.create('post');

invalidateSession(application);
Expand Down Expand Up @@ -397,18 +397,10 @@ describe('Acceptance: Editor', function() {
.to.equal('/editor/1');
});

andThen(() => {
titleRendered();
});

andThen(() => {
let title = find('#gh-title div');
title.html(Array(160).join('a'));
});

andThen(() => {
click('.gh-btn.gh-btn-sm.js-publish-button');
});
// Test title validation
fillIn('input[id="entry-title"]', Array(160).join('a'));
triggerEvent('input[id="entry-title"]', 'blur');
click('.gh-btn.gh-btn-sm.js-publish-button');

andThen(() => {
expect(
Expand Down
15 changes: 0 additions & 15 deletions tests/helpers/editor-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,6 @@ export function editorRendered() {
});
}

// polls the title until it's started.
export function titleRendered() {
return Ember.Test.promise(function (resolve) { // eslint-disable-line
function checkTitle() {
let title = $('#gh-title div');
if (title[0]) {
return resolve();
} else {
window.requestAnimationFrame(checkTitle);
}
}
checkTitle();
});
}

// simulates text inputs into the editor, unfortunately the helper Ember helper functions
// don't work on content editable so we have to manipuate the text input event manager
// in mobiledoc-kit directly. This is a private API.
Expand Down
24 changes: 0 additions & 24 deletions tests/integration/components/gh-title-test.js

This file was deleted.

0 comments on commit 7661212

Please sign in to comment.