Skip to content

Instantly share code, notes, and snippets.

@grapho
Last active December 23, 2021 20:58
Show Gist options
  • Save grapho/dd1d3dfa9850fc09e39c83e9fbf0cef5 to your computer and use it in GitHub Desktop.
Save grapho/dd1d3dfa9850fc09e39c83e9fbf0cef5 to your computer and use it in GitHub Desktop.
Save the selection
import Component from '@ember/component';
import { action } from '@ember/object';
export default Component.extend({
didInsertElement() {
document.addEventListener('selectionchange', () => {
console.log('SELECTIONCHANGE')
console.log(document.getSelection().type)
});
document.addEventListener('click', () => { console.log('CLICK')});
}
});
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.wrapper {
position: relative;
}
.thebutton {
position: absolute;
top: 50%;
left: 50%
}
<h1>Welcome to {{this.appName}}</h1>
<br>
<br>
{{my-component}}
<br>
<br>
<form class="wrapper">
<section>
<div>
<div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>
</div>
</section>
<button class="thebutton" type='button'>button</button>
</form>
{
"version": "0.17.1",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
"ember": "3.18.1",
"ember-template-compiler": "3.18.1",
"ember-testing": "3.18.1"
},
"addons": {
"@glimmer/component": "1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment