Skip to content

Commit 324cd2e

Browse files
committed
fix: qol for easier anchor handling
1 parent 4e4d8b7 commit 324cd2e

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/js/Plugins/modxlink/Data.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ export default class Data {
33
this.editor = editor;
44
window.editor = editor;
55
this.element = editor.dom.getParent(editor.selection.getStart(), 'a[href]');
6-
const textarea = document.createElement('textarea');
7-
textarea.innerHTML = this.editor.selection.getContent();
8-
6+
let blocks = this.editor.selection.getSelectedBlocks();
7+
if (blocks[0].firstElementChild && blocks[0].firstElementChild.nodeName === 'A') {
8+
console.info('Descending into anchor');
9+
this.element = blocks[0].firstElementChild;
10+
this.editor.selection.select(this.element);
11+
}
12+
13+
914
this.initialData = {
1015
link_text: this.editor.selection.getContent(),
1116
link_title: '',

src/js/Plugins/modxlink/modxlink.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,22 +290,16 @@ export default (editor, url) => {
290290
win.showTab(currentTab);
291291

292292
document.querySelectorAll('.tox-dialog').forEach((item) => {
293-
item.classList.add('mce-fred--modxlink');
293+
item.classList.add('mce--modxlink');
294294
});
295295

296296

297297
const populateOptions = options => {
298-
const toRemove = [];
299-
console.log(templateInputChoices);
300-
/* templateInputChoices.currentState.items.forEach(item => {
301-
if (item.active) {
302-
toRemove.push(item.value);
303-
}
304-
});*/
298+
const toRemove = templateInputChoices.getValue();
305299

306300
const toKeep = [];
307301
options.forEach(option => {
308-
if (toRemove.indexOf(option.id) === -1) {
302+
if (toRemove.value !== option.value) {
309303
toKeep.push(option);
310304
}
311305
});

0 commit comments

Comments
 (0)