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

Add DOM parser prototype #111

Closed
wants to merge 36 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fc6d876
Add TinyMCE-per-block prototype
aduth Feb 16, 2017
386073b
Document and add licensing information for preact-compat render
aduth Feb 16, 2017
5e50c86
Add Mockups
jasmussen Feb 17, 2017
45f98ea
Merge pull request #84 from WordPress/add/mockups
jasmussen Feb 17, 2017
5941a0f
Merge pull request #80 from WordPress/add/tinymce-per-block-prototype
mtias Feb 17, 2017
ef02dd7
Add navigation between prototypes to the top of the page.
mtias Feb 17, 2017
68f2805
Merge pull request #86 from WordPress/add/prototype-nav-bar
mtias Feb 17, 2017
17cb314
Merge pull request #85 from WordPress/add/block-menu-search
mtias Feb 17, 2017
c80e6a6
Adding keyboard shortcuts to navigate on the Block Insert Menu
youknowriad Feb 17, 2017
7216259
Attempt to make controls appear in the correct spot
timmyc Feb 17, 2017
9808671
Update mockups
jasmussen Feb 20, 2017
c18d0f2
Merge pull request #96 from WordPress/update/mockups
jasmussen Feb 20, 2017
78c0334
Changes per review
youknowriad Feb 20, 2017
afa5dbe
Merge pull request #95 from WordPress/fix/92
mtias Feb 20, 2017
88feb95
Changes per review
youknowriad Feb 20, 2017
ce2f866
Merge pull request #88 from WordPress/add/keyboard-shortcuts
youknowriad Feb 20, 2017
e86a88e
Keep the block position on the screen when moving blocks
youknowriad Feb 20, 2017
f267737
Add lots of blocks
jasmussen Feb 20, 2017
6092250
Update the category attribute
youknowriad Feb 20, 2017
0e6e06f
Default SVG width and height
youknowriad Feb 20, 2017
52c59f5
Merge pull request #101 from WordPress/add/lotsa-blocks
jasmussen Feb 20, 2017
b3e9083
Merge pull request #100 from WordPress/update/keep-block-position
youknowriad Feb 20, 2017
ad34ca4
Move prototype navigation UI into common script
aduth Feb 20, 2017
77ddc6a
Remove unused prototypes styles from UI stylesheet
aduth Feb 20, 2017
67caffa
Update Automattic package references to WordPress
aduth Feb 20, 2017
7f74289
Iterate keys of prototypes object
aduth Feb 20, 2017
2a5a9f2
Merge pull request #103 from WordPress/update/package-author
mtias Feb 20, 2017
6666eaf
Create TinyMCE demo page with single paragraph block.
mtias Feb 20, 2017
445846f
Merge pull request #105 from WordPress/add/tinymce-demo
mtias Feb 20, 2017
c21746d
Add basic page styles to TinyMCE demo.
mtias Feb 20, 2017
d2c4762
Merge pull request #106 from WordPress/add/tinymce-demo-css
mtias Feb 20, 2017
8606884
UI Prototype: Add indication that there are more blocks available (#107)
youknowriad Feb 21, 2017
33db39f
Fix switching between block types (paragraph, quote and heading) (#109)
youknowriad Feb 21, 2017
a416864
UI Prototype: Try the dockerized controls prototype (#108)
youknowriad Feb 21, 2017
315ee13
Merge pull request #102 from WordPress/update/consistent-navigation
mtias Feb 21, 2017
9fe4d9f
Add DOM parser prototype
aduth Feb 21, 2017
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
Prev Previous commit
Next Next commit
Attempt to make controls appear in the correct spot
  • Loading branch information
timmyc committed Feb 17, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 72162597801d0c95f175bd1515f277934d9eab9b
31 changes: 30 additions & 1 deletion blocks.js
Original file line number Diff line number Diff line change
@@ -168,6 +168,7 @@ function showControls( node ) {
switcherButtons.forEach( function( element ) {
element.style.display = 'none';
} );

var blockType = getTagType( node.nodeName );
var switcherQuery = '.type-icon-' + blockType;
queryFirst( switcherQuery ).style.display = 'block';
@@ -185,8 +186,35 @@ function showControls( node ) {
blockControls.style.display = 'block';

// reposition block-specific block controls
blockControls.style.top = ( position.top - 36 + window.scrollY ) + 'px';
updateBlockControlsPosition();
}

function updateBlockControlsPosition( newClassName ) {
var isImage = selectedBlock.tagName === 'IMG';
var className = selectedBlock.className;
var position = selectedBlock.getBoundingClientRect();
var alignedRight = className.match( /align-right/ );
var alignedLeft = className.match( /align-left/ );
var fullBleed = className.match( /full-bleed/ );

var topPosition = position.top - 36 + window.scrollY;
var leftPosition = null;

if ( isImage && alignedRight ) {
leftPosition = position.left;
topPosition = newClassName ? topPosition - 15 : topPosition;
} else if ( isImage && alignedLeft && newClassName ) {
topPosition = topPosition - 15;
} else if ( isImage && className === 'is-selected' && blockControls.style.left ) {
leftPosition = null;
topPosition = topPosition + 15;
} else if ( fullBleed ) {
leftPosition = ( window.innerWidth / 2 ) - ( blockControls.clientWidth / 2 );
}

blockControls.style.maxHeight = 'none';
blockControls.style.top = topPosition + 'px';
blockControls.style.left = leftPosition ? leftPosition + 'px' : null;
}

function hideControls() {
@@ -436,6 +464,7 @@ function setElementState( className, event ) {
if ( className ) {
selectedBlock.classList.add( className );
}
updateBlockControlsPosition( className );
}

function l( data ) {