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

Help #29

Closed
ismailhakkieren opened this issue Aug 1, 2016 · 5 comments
Closed

Help #29

ismailhakkieren opened this issue Aug 1, 2016 · 5 comments

Comments

@ismailhakkieren
Copy link

i wrote special ediitor and i use your library for mentions.
my div id is mainEditor.

tribute.attach($('#mainEditor'));

it works perfect but i have a special situation. this div (mainEditor) has a h3 (h3 id is hContent )and i dont want to mentions only this element. Please help me.

@mrsweaters
Copy link
Collaborator

Can you try <h3 contenteditable="false">Text</h3>? I think that should do the trick.

@ismailhakkieren
Copy link
Author

i tried but i cant write anything. i need contenteditable="true". ithink i should change tribute.js when i see #hContent id i'll return nothing.

@ismailhakkieren
Copy link
Author

ismailhakkieren commented Aug 2, 2016

$("#mainEditor").keyup(function () {
    var focusNode = window.getSelection().focusNode;
    var idFocus = "";
    var parentNode = focusNode.parentNode;
    idFocus = parentNode.id;
    if (idFocus == "hContent") {
        console.log("not here");
    } else {
        tribute.attach($('#mainEditor'));
    }
});

i wrote this code and mentions doesnt work in #hContent h3. it is ok for me. But when i mentions other element in #mainEditor div.
console error : tribute.js:230 Uncaught TypeError: Cannot read property '0' of undefined
line is : let item = this.current.filteredItems[index]

how i can do it. Please help me

@mrsweaters
Copy link
Collaborator

This doesn't help me get a picture of what you are trying to do. It would be best if you could create a plunkr or jsfiddle that has both the markup and the JS you are using.

However, it does seem that #mainEditor is the parent of the h3. This seems wrong to me as you don't want your user to be able to mention in that content.

I would do this:

<div id="mainEditor">
    <h3>Title</h3>
    <div class="content">
        Editable content.
    </div>
</div>

For the js:

tribute.attach($('#mainEditor').find('.content'))

Then you would make the h3 and the div.content section independently editable. Also store these as two separate attributes in your database. You can then style #mainContent so that the h3 and the div.content section look as if they are part of the same editable area. I hope that makes sense.

@mrsweaters
Copy link
Collaborator

I'm going to close this issue since I feel like the above is the best route for you to take.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants