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

tw-react

v0.6.3

Published

npm scripts to build plugins

Downloads

92

Readme

TiddlyWiki React

What’s your opinion about using ReactJS in the plugin? Sometimes it is inevitable to use ReactJS in the widget, for example, JSONSchemaForm.

See Website for documentation.

Usage

Add this to a type.d.ts file to your src/ folder:

declare module '$:/plugins/linonetwo/tw-react/widget.js' {
  import { IReactWidgetConstructor } from 'tw-react';
  const widget: IReactWidgetConstructor;
}

or in tsconfig.json add:

    "typeRoots" : ["node_modules/@types", "node_modules/tw5-typed", "node_modules/tw-react/dist/lib"],

Products

  1. WhiteBoard plugin
  2. Demo of a new WYSIWYG editor: slate-write (unstable alpha stage)
  3. FlowTiwi - a Multi-column draggable resizable sidebar (beta release)
  4. Smart Form plugin - beta release - Display different form based on the tag you add

When installing these plugins from TiddlyWiki-CPL: TiddlyWiki world of Google App Store! , this React plugin will be automatically installed as a dependency. So you probably don't need to install this manyally.

(You can also drag __plugins_linonetwo_tw-react.json from Release · tiddly-gittly/tw-react · GitHub. But Don't drag them from above demo sites. Because the ReactJS plugin from those demosite is of dev mode, so size is much larger than the one in the CPL and Github release!)

Trouble shotting

React is undefined

You may need import React from 'react'; on the top of jsx file, even you are in react 17+ and not using this variable...

My css is not loading

See things in your dist/plugins/xxx/yyy, is there a zzz.css file?

Then you will need to create a zzz.css.meta file in your src folder:

title: $:/plugins/linonetwo/flowtiwi-sidebar/flowtiwi-sidebar.css
tags: $:/tags/Stylesheet
type: text/css

ReferenceError: window is not defined

You may have this error when booting nodejs wiki:

Error executing boot module $:/plugins/linonetwo/tw-whiteboard/widget.js: {}

$:/plugins/linonetwo/tw-whiteboard/widget.js:29527
var AY = window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)").matches : false;
         ^

ReferenceError: window is not defined
    at $:/plugins/linonetwo/tw-whiteboard/widget.js:29527:10
    at Script.runInContext (node:vm:139:12)
    at Script.runInNewContext (node:vm:144:17)

This is because in nodejs context, there are no window object.

You need to only execute your script in browser, like the example in slate-write:

/* eslint-disable @typescript-eslint/no-unsafe-assignment */
(function slateWriteWidgetIIFE() {
  // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
  if (!$tw.browser) {
    return;
  }
  // separate the widget from the exports here, so we can skip the require of react code if `!$tw.browser`. Those ts code will error if loaded in the nodejs side.
  const components = require('$:/plugins/linonetwo/slate-write/components/index.js');
  const { widget } = components;
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
  exports.slateWrite = widget;
  // fix `Undefined widget 'edit-slateWrite'`
  exports['edit-slateWrite'] = widget;
})();

While export the widget from another file:

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
exports.widget = SlateWriteWidget;