-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Lib Version for native html #37
Comments
Hi @pnegahdar! I currently do not have time to dedicate to this, but I'll leave the issue open: I may come back to this in the future, or maybe you or some other developer may help 😄 |
Hi @BearToCode , I know that currently you don't have time to dedicate to this, I was just wondering if it is possible to
I can imagine this library being used in a lot of projects, and frameworks, and I'm willing to put work to port this to vanilla JS (and possibly Vue and React as well)... But I need some guidance (I haven't used Svelte 4 before... and regarding the internals of the carta library itself... I'm quite confused about the architecture system design decisions and responsibilities of the components because of my unfamiliarity of svelte 4 😢 ... ), I'm imagining it will be something like quill mention or Niivue Where we can create our own components like (Just throwing initial ideas around) const carta = new Carta({ extensions: [hashtag()] });
const markdownEditor = new MarkdownEditor(
{ carta,
debounce: 500,
onDebouncedChange: (insertedTextSinceLastCalled: string, currentPosition: number) => {
// maybe get the AST here
console.log(carta.currentASTRepresentation);
console.log(carta.currentStringRepresentation);
console.log(insertedTextSinceLastCalled, currentPosition)
// so we can save it on our server
// or plug it in on our own previewer
},
onDispatchEvent: (eventType, payload) => {
// maybe do something given eventType and payload
console.log(eventType === "carta-render", payload) // onKeyUp, onKeyDown, onBlur
console.log(eventType === "onClick", payload.cursorPosition)
}
}).
markdownEditor.attachToId("carta-markdown-editor-container")
<div id="carta-markdown-editor-container" /> I know these tasks are quite involved, but I think you have done incredible work..
I'm willing to put my money where my mouth by personally sponsoring you for the two tasks if I can afford it... Again.. amazing project. Hopefully you can give me a number (in Looking forward to hear back from you 😀 |
Hi @mithi, I appreciate very much your comment 😄 . I don't think I'll be able to work on this for at least a couple of months, due to my enrollment in university, but I should be able to do something then. I think you asked for two very different modifications in your comment in terms of work required: migrating to Svelte 5 and creating a vanilla JS version of the library. For the first one, even thought Svelte 5 is not yet definitive and I've not worked directly with it, I'm quite confident not too much work will be needed. This project does not make extensive use of Svelte components, so migrating shoud be straightforward. I'd still wait for a stable release before doing so(as you said). Providing a vanilla version of the library is a lot more tricky and requires planning. There are several points that need to be adressed to make it viable, as Svelte(Kit) does not provide a simple universal way to do so:
There are probably other things that I forgot/will discover during developing. Regarding the commission: I've created this project because I needed an editor myself, and I decided to share it. I don't see developing OSS as a job. For this reason, I don't quite like the idea of a commision. If in the meantime I hopefully get time to dedicate to this, you'd like to start working on it yourself, start making some other changes or have any question regarding the project, feel free to ask. |
Hi @BearToCode I really appreciate your detailed response to my query. I'm sorry I think I did not word the second request properly, I didn't mean to ask you do create a vanilla JS version of the library, that would be too much work for you! It's more like I noticed that the Carta class is purely written in Typescript and I think that it would be possible for for me I was just hoping I could request to you to write more detailed documentation on how the svelte 4 component I believe that a documentation will help provide some direction and guidance so I can write my own As you've mentioned that this library does not make extensive use of Svelte components, so I was thinking that maybe I can actually migrate it myself, if you don't have time to do so. Svelte 5 is now on I quote from there blog post:
I understand that you don't quite like the idea of commission, I'd gladly make a donation (Maybe through PayPal or Buy me a Coffee (Like https://ko-fi.com/minimithi) as an appreciation of your time and effort into writing this. I tried to read your I can try to spend a bit more time to try to explore and play around but then I thought maybe it's more efficient to just ask you directly for help since you know this library inside out (naturally because you wrote it!) TLDR
Again, thank you so much for creating this library and making it open source... It's the most awesome extendable markdown editor I've seen ever! 🥳 🥳 👏 👏 |
Hi again, Using the If you just need me to explain the roles of the components and how they work, I can do that easily. I think I could add an header to the various components explaining them, and add descriptions to their functions and properties: <!--
@description A description of the what the component does and how it does that
-->
<script lang="ts">
/**
* A description of the property.
*/
export let prop: Something;
/**
* What the function does
* @param a What is a
* @param b What is b
*/
function fn(a, b) {
}
</script> Let me know if something like this would be enough, or if you had another idea in mind. You could obviously contact for any question. Following your suggestion I created a ko-fi page. |
Yes that would be really cool! But if you're doing this just for me, and if it will take too much time from more important things, then please don't prioritize this! After familiarizing myself with Svelte more the past few hours I think I'm hoping to contribute more to this project in the near future when I'm no longer swamped with work... So no hurry really...
I have made a little donation on your Ko-Fi page, and I'll be making more donations in the future once I get to spend more time playing with this library. Again, thank you so much for entertaining all my questions! 🙂 I will message you again in the next couple of months 🙂 |
Thanks a lot for your donation! Looking forward to working with you 😄 |
just a quick drive-by comment regarding this issue.. comparison of this project to another project that uses Svelte and publishes a vanilla JS library: carta-md
bigger-picture
summary:
example: vanilla-bigger-picture.html<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/bigger-picture.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/bigger-picture.min.css" rel="stylesheet" />
<script>
document.addEventListener("DOMContentLoaded", (event) => {
// initialize
let bp = window.BiggerPicture({
target: document.body,
})
// open (will be a child of the target element above)
bp.open({
items: document.querySelectorAll('#images a'),
})
})
</script>
</head>
<body>
<div id="images">
<a
href="https://assets.henrygd.me/bp/images/joshua-sukoff-sZ5zbZMAYJs-unsplash.jpg"
target="_blank"
data-img="https://assets.henrygd.me/bp/images/joshua-sukoff-sZ5zbZMAYJs-unsplash_1133.jpg 1133w, https://assets.henrygd.me/bp/images/joshua-sukoff-sZ5zbZMAYJs-unsplash.jpg 1667w"
data-thumb="https://assets.henrygd.me/bp/images/joshua-sukoff-sZ5zbZMAYJs-unsplash_thumb.jpg"
data-height="2500"
data-width="1667"
data-alt="Antelope Canyon"
>
<img
src="https://assets.henrygd.me/bp/images/joshua-sukoff-sZ5zbZMAYJs-unsplash_thumb.jpg"
alt="Antelope Canyon"
loading="lazy"
/>
</a>
</div>
</body>
</html> assertion:
|
just for fun.. I spent a little time this evening attempting to make a browser build.
update: new links: just an fyi.. update: though the last comment is still true, I've since updated the rollup config to automatically remove this export while processing the aforementioned files |
refreshed browser build..
|
Hi @warren-bank , This looks really cool! I'll try it out once my schedule clears up! |
This editor is so cool, kudos!
I'm not too familiar with svelte, but how hard would it be to compile this into JS and have a pure JS api to bind it to an element.
That way it can be used in a react or vanilla project as well?
The text was updated successfully, but these errors were encountered: