Giter Club home page Giter Club logo

tailwind-editor's Introduction

Tailwind Editor

Svelte component to generate tailwindcss html from a notion like wysiwyg editor.

This component is under development, don't use it in production yet!

svelte tailwind wysiwyg editor

Installation

$npm i tailwind-editor

Import to use in a svelte project, you need also tailwind installed (or imported) in order for this to work

<script>
    import Editor from 'tailwind-editor'
    let html = ''
</script>

<div class="flex">
    <Editor bind:html={html} />
    <div>
        {html}
    </div>
</div>

Add initial HTML

If you want to add custom html when you load the component you can pass an array of elements like the following

this is not recommended if the code is not previously generated by the editor

<script>
    import Editor from 'tailwind-editor'
    let arr_html = [
        {html: 'Hello <span class="font-bold">world!</span>', klass: 'p-2 text-3xl'}
    ]
    let html = ''
</script>

<Editor bind:html={html} {arr_html} editable />

TODO

  1. embed media (image, video)
  2. add lists
  3. drag and drop positions
  4. code highlighter with tailwindcss

Contribution

All contribution are welcome!

About

Fouita : UI framework for svelte + tailwind components

tailwind-editor's People

Contributors

haynajjar avatar rotimi-best avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tailwind-editor's Issues

Editor tab doesn't work on Firefox

I don't know if it's a bug of library. But it doesn't show editor tab in Firefox, when I select a text. But in Yandex Browser/Chrome it works well.
изображение

Could you remove the klass?

I am trying your WYSIWYG binding a textarea to the editor

<script>
	import Tailwindcss from './Tailwindcss.svelte';
	import Editor from 'tailwind-editor';
	
	let in_html = "";
	let out_html = ""

	$: arr_html = [
        {html: in_html, klass: ''}
	]
	
	// $: console.log(out_html)
</script>

<Tailwindcss />


<main class="p-4">
	<div class="flex">
		<div class="flex-1">
			<Editor bind:html={out_html} {arr_html}/>
		</div>
		<textarea class="flex-1" 
			value={out_html}
			on:change={e => {
				in_html = e.target.value;
			}}></textarea>
	</div>
</main>

My only issue with this aproach is that the klass is wrapping the textarea code in a div so for every change i make, the source is wrapped in another div.

If you could bring me a new aproach or make the use of klass optional i would be pleased

remove previous class before adding a new one

Hello,

first of all congrats on your work. I like that it keeps a clean html.

Here is what i've noticed. When I add a background color or bg-transparent or a text color, and then I change the color, the editor just adds the new class that i selected. Therefore it ends up having multiple text- or bg- classes, for example:

<span class="text-teal-600 text-white text-black text-red-400 bg-blue-500 bg-transparent">style</span>

if a text- class is selected it should delete all other text- classes. the same with the bg- class. in other words, there should be only one text- or bg- class at any given time.

cheers

No svelte 5 support

After importing it into svelte 5 and doing some fixing based on the "Window is not defined" issue (Which needs to be fixed as well), there's an error in the console:

Error: Your application, or one of its dependencies, imported from 'svelte/internal', which was a private module used by Svelte 4 components that no longer exists in Svelte 5. It is not intended to be public API. If you're a library author and you used 'svelte/internal' deliberately, please raise an issue on https://github.com/sveltejs/svelte/issues detailing your use case.

Please remove the ability to install into Svelte5 or change the logic to support it.

Thanks.

window is not defined

ReferenceError: window is not defined
at \node_modules\tailwind-editor\src\index.js:1:14
at instantiateModule (/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:55058:15)

Does it work with SvelteKit?

Hello,
I'm trying to use this component in a SvelteKit app, but I'm encountering some css loading issues (see below).
I saw there is a demo repo for using this editor with Sapper, but I'm wondering if there are known issues with SvelteKit.
Here is what I've tried:

npm init svelte@next
npx svelte-add@latest tailwindcss
npm install
npm install -D tailwind-editor

But when I use the simple <Editor /> example given in the main page of this repo, I get lots of issues with tailwind styles not being properly loaded for the editor. Is there some special configuration I need to adjust to make it work for SvelteKit?

Sveltekit integration

Hello,
I manage to make it wotk a bit (a bit) with svelkit but it not fully working properly

// +page.svelte
<script>
  import "../app.css"; // for tailwind
  import { onMount } from "svelte";
  let html = "";
  let Editor;
  let arr_html = [
    {
      html: 'Hello <span class="font-bold">world!</span>',
      klass: "p-2 text-3xl",
    },
  ];
  onMount(async () => {
    const module = await import("tailwind-editor");
    Editor = module.default;
  });
</script>

<div>
  {html}
</div>
<div class="flex">
  <svelte:component this={Editor} bind:html {arr_html} editable />
</div>

and this to don't run ssr

// +page.js
export const ssr = false;

and this is how the floating menu is displayed
Screenshot 2023-02-19 at 11 34 35

it is working but it's not really usable :/

any help would be welcomed 😀

Best regards

Yohann

Editor pops far away from the content

Hello,

I am having issues using your component :

image

As you can see in the image, the editing popup pops really far away from the content I desire to edit. Do you have an idea about how I can fix this ?

following is the implemented (revelent) code :
<div class="p-4 whitespace-pre-wrap"> <div class="relative flex"> <Editor bind:html={html} {arr_html} /> <div> {html} </div> </div> </div>

Thanks you !

EDIT : The problem seems to be that i have an element with the "relative" class higher in the DOM tree, conflicting with the positioning of the toolbar.

please complete all Todos

TODO
[ ] embed media (image, video)
[ ] add lists
[ ] drag and drop positions
[ ] code highlighter with tailwindcss

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.