Skip to content

Commit be31102

Browse files
committed
feat(globalLinkList): open dialog on copy text
1 parent 4accbf4 commit be31102

File tree

5 files changed

+64
-12
lines changed

5 files changed

+64
-12
lines changed

app-src/scripts/dialogs/edit-global-link/edit-global-link-c.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<md-dialog aria-label="Edit global link"
1+
<md-dialog aria-label="{{vm.editOrAddStr}} global link"
22
md-theme="vm.theme"
33
class="edit-global-link-dialog">
44
<md-toolbar>
55
<div class="md-toolbar-tools">
6-
<h2>Edit global link</h2>
6+
<h2>{{vm.editOrAddStr}} global link</h2>
77
<span flex></span>
88
<md-button class="md-icon-button"
99
aria-label="Cancel"

app-src/scripts/dialogs/edit-global-link/edit-global-link-c.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app-src/scripts/global-link-list/global-link-list-cp.html

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

4141
<div class="controls">
4242
<md-button class="md-icon-button md-raised md-primary md-hue-3 edit-button"
43-
ng-click="$ctrl.edit(link)">
43+
ng-click="$ctrl.openEditDialog(link)">
4444
<ng-md-icon icon="edit"
4545
aria-label="edit link"></ng-md-icon>
4646
</md-button>

app-src/scripts/global-link-list/global-link-list-cp.js

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,56 @@
2323
};
2424

2525
$document[0].body.ondrop = (ev) => {
26-
this.handleDrag(ev);
26+
this.handleDrop(ev);
2727
};
28+
29+
$document[0].onpaste = (ev) => {
30+
if (ev.target.tagName !== 'INPUT' && ev.target.tagName !== 'TEXTAREA') {
31+
const link = this.GlobalLinkList.createLinkFromPaste(ev);
32+
this.openEditDialog(link, true);
33+
}
34+
35+
//const log = console.log;
36+
//const e = ev;
37+
//log('event.clipboardData');
38+
//if (e.clipboardData.types) {
39+
// log('event.clipboardData.types');
40+
//
41+
// // Look for a types property that is undefined
42+
// if (!Array.isArray(e.clipboardData.types)) {
43+
// log('event.clipboardData.types is undefined');
44+
// }
45+
//
46+
// // Loop the data store in type and display it
47+
// var i = 0;
48+
// while (i < e.clipboardData.types.length) {
49+
// var key = e.clipboardData.types[i];
50+
// var val = e.clipboardData.getData(key);
51+
// log((i + 1) + ': ' + key + ' - ' + val);
52+
// i++;
53+
// }
54+
//
55+
//} else {
56+
// // Look for access to data if types array is missing
57+
// console.log('I am here!');
58+
//
59+
// var text = e.clipboardData.getData('text/plain');
60+
// var url = e.clipboardData.getData('text/uri-list');
61+
// var html = e.clipboardData.getData('text/html');
62+
// log('text/plain - ' + text);
63+
// if (url !== undefined) {
64+
// log('text/uri-list - ' + url);
65+
// }
66+
// if (html !== undefined) {
67+
// log('text/html - ' + html);
68+
// }
69+
//}
70+
}
2871
}
2972

30-
handleDrag(ev) {
73+
handleDrop(ev) {
3174
const taskEl = ev.target.closest('.task');
32-
const link = this.GlobalLinkList.createLink(ev);
75+
const link = this.GlobalLinkList.createLinkFromDrop(ev);
3376

3477
if (taskEl) {
3578
const $taskEl = angular.element(taskEl);
@@ -44,12 +87,12 @@
4487
this.$scope.$apply();
4588
}
4689

47-
edit(link) {
48-
this.Dialogs('EDIT_GLOBAL_LINK', { link }, true);
90+
openEditDialog(link, isNew) {
91+
this.Dialogs('EDIT_GLOBAL_LINK', { link, isNew }, true);
4992
}
5093

5194
addLink() {
52-
this.edit();
95+
this.openEditDialog(undefined, true);
5396
}
5497

5598
remove($index) {

app-src/scripts/global-link-list/global-link-list-s.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
return base;
3939
}
4040

41-
createLink(ev) {
41+
createLinkFromDrop(ev) {
4242
const text = ev.dataTransfer.getData('text');
4343
if (text) {
4444
return this.createTextLink(text);
@@ -47,6 +47,14 @@
4747
}
4848
}
4949

50+
51+
createLinkFromPaste(ev) {
52+
const text = ev.clipboardData.getData('text/plain');
53+
if (text) {
54+
return this.createTextLink(text);
55+
}
56+
}
57+
5058
createTextLink(text) {
5159
if (text) {
5260
if (text.match(/\n/)) {

0 commit comments

Comments
 (0)