npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tinymce-solid

v0.0.8

Published

📝 TinyMCE Component for SolidJS

Downloads

15

Readme

TinyMCE Component for SolidJS

Coverage Status ci Npm Version solid-js version tinymce version typescript version prettier version vitest version vite version

About

This package is a wrapper around TinyMCE to make it easier to use in a SolidJS / SolidStart application.

Quick Start Guide

Installation

npm

npm install tinymce-solid

pnpm

pnpm install tinymce-solid

yarn

yarn add tinymce-solid

Basic Usage

SPA Mode

In your usual SolidJS SPA you can use tinymce-solid component like this.

import { createSignal } from "solid-js";
import { type Editor as TinyEditor } from "tinymce";
import { Editor } from "tinymce-solid";

export default function App() {
  let editorRef!: TinyEditor;
  const [content, setContent] = createSignal("");

  return (
    <main>
      <Editor
        apiKey="your-api-key"
        value={content()}
        onInit={(_content: string, editor: TinyEditor) => (editorRef = editor)}
        init={{
          menubar: false,
          placeholder: "Write an epic story here...",
          plugins:
            "advlist advlist autolink lists link image charmap preview anchor searchreplace visualblocks code fullscreen insertdatetime media table code help wordcount",
          toolbar:
            "undo redo | blocks | bold italic forecolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image code | removeformat | help",
        }}
        onEditorChange={(content: string, editor: TinyEditor) => {
          // you can also access the editor's content via its own accessor
          // const newContent = editor.getContent();
          setContent(content);
        }}
      />
    </main>
  );
}

SSR Mode

When using SolidStart in SSR mode, you may want to bring the clientOnly loader, since the TinyMCE editor uses mainly the DOM API.

import { clientOnly } from "@solidjs/start";
import { Component, createSignal } from "solid-js";
import { type IAllProps } from "tinymce-solid";

const Editor = clientOnly<Component<IAllProps>>(() => import("tinymce-solid"));

export default function App() {
  const [content, setContent] = createSignal("");

  return (
    <main>
      <Editor
        apiKey="your-api-key"
        value={content()}
        init={{
          menubar: false,
          placeholder: "Write an epic story here...",
          plugins:
            "advlist advlist autolink lists link image charmap preview anchor searchreplace visualblocks code fullscreen insertdatetime media table code help wordcount",
          toolbar:
            "undo redo | blocks | bold italic forecolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image code | removeformat | help",
        }}
        onEditorChange={(newContent: string) => {
          setContent(newContent);
        }}
      />
    </main>
  );
}

Properties

  • skin: reactive - change the skin of the editor
  • contentCss: reactive - change the styling of the content
  • disabled: reactive - toggles the disabled property of the editor
  • value: reactive - the actual content;
  • initialValue: reactive - the initial content value;
  • onEditorChange: (content: string, editor: Editor) => void - the callback you can use to update the parent state;
  • editorRef: - allows you to hook into the TinyMCE instance for additional functionality;
  • all other TinyMCE properties are non-reactive and should work as designed for the original TinyMCE React component.

Some notes

  • This package will automatically load the TinyMCE library and its dependencies by the use of the tinymceScriptSrc property;
  • You can make use of the dark mode via TinyMCE skins: skin="oxide-dark" and contentCss="dark" properties, the demo is configured to make use of them via createEffect;
  • Like the original React adaptation, this component allows you to hook into the TinyMCE instance via an editorRef reference.
  • We've added tests powered by Vitest, with a real coverage of ~70%, that is becasue many branches cannot be covered in Vitest browser mode and playwright won't work in some Linux distributions for some reason.

Issues

Have you found an issue with tinymce-solid or do you have a feature request? Open up an issue and let us know or submit a pull request.

Note: For issues concerning TinyMCE please visit the TinyMCE repository.

License

tinymce-solid is released under the MIT License.