MCPcopy Index your code
hub / github.com/appleple/smartblock

github.com/appleple/smartblock @v1.4.8

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.4.8 ↗ · + Follow
527 symbols 992 edges 152 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

SmartBlock

npm version npm download GitHub license Tweet

SmartBlock.js is a JavaScript block based editor which enables you to write contents easily on websites even with SmartPhone.

| IE / Edge

IE11 / Edge | Firefox

Firefox | Chrome

Chrome | Safari

Safari | iOS Safari

iOS Safari | | --------- | --------- | --------- | --------- | --------- |

ScreenShot

Features

  • Easy to use with SmartPhone
  • Fully customizable
  • Block based
  • Keep clean HTML and wipe out unnecessary tags
  • Get the result as HTML or JSON
  • copy and paste contents

Install

$ npm install smartblock --save

Usage

import * as React from 'react';
import { render } from 'react-dom';
import 'smartblock/css/smartblock.css';
import { SmartBlock, Extensions } from 'smartblock';

render(<>
  <SmartBlock 
    extensions={Extensions}
    html={'<h2>Hello World</h2>

hello

'}
    onChange={({ json, html }) => { console.log(json, html);}}  
  />
</>, document.getElementById("app"));

Try it on CodeSandbox

Edit hardcore-kalam-tghp9

Customize

You can add custom block like this

import * as React from 'react';
import { Extensions, CustomBlock, CustomMark } from 'smartblock';
Extensions.push(new CustomBlock({  
  tagName: 'div',
  className: '.alert',
  icon: <SomeIconComponent />
});

render(<>
  <SmartBlock 
    extensions={Extensions}
    html={'<h2>Hello World</h2>

hello

'}
    onChange={({ json, html }) => { console.log(json, html);}}  
  />
</>, document.getElementById("app"));

You can add custom inline element like this

import * as React from 'react';
import { Extension, CustomBlock, CustomMark } from 'smartblock';
import 'smartblock/css/smartblock.css';
Extension.push(new CustomMark({  
  tagName: 'span',
  className: '.small',
  icon: <SomeIconComponent />
});

render(<>
  <SmartBlock 
    extensions={Extensions}
    html={'<h2>Hello World</h2>

<small>hello</small>

'}
    onChange={({ json, html }) => { console.log(json, html);}}  
  />
</>, document.getElementById("app"));

Options

Props description type default
extensions Array of extensions which extend the feature of SmartBlock Extension[] array of extensions
onChange Callback function which is called when the content of the editor is changed. You can get both html and json Function
onInit Callback function which is called when the editor is initialized Function
json The editor contents will be initialized with the json data Object {}
HTML The editor contents will be initialized with the HTML String ''
showTitle Title will be shown Boolean false
showBackBtn Btn to support history back will be shown Boolean false
autoSave The HTML will be stored to the localstorage every time the content is changed Boolean false
getEditorRef Get the editor ref object Function
## Download
Download ZIP

Github

https://github.com/appleple/smartblock

Contributor

@steelydylan

License

Code and documentation copyright 2020 by appleple, Inc. Code released under the MIT License.

Extension points exported contracts — how you extend this code

ExtensionSchema (Interface)
(no doc) [8 implementers]
src/types/index.ts
PositionProps (Interface)
(no doc)
src/components/edit-menu.tsx
PlaceholderPluginConfig (Interface)
(no doc)
src/extensions/default-plugins.tsx
VisualViewport (Interface)
(no doc)
src/types/global.d.ts
CustomLayoutProps (Interface)
(no doc)
src/components/custom-layout.tsx
PlaceholderPluginOptions (Interface)
(no doc)
src/extensions/default-plugins.tsx
DocumentElement (Interface)
(no doc)
src/types/global.d.ts
Props (Interface)
(no doc)
src/components/back-btn.tsx

Core symbols most depended-on inside this repo

getParentNodeFromState
called by 21
src/utils/index.ts
blockActive
called by 15
src/utils/index.ts
getOffset
called by 10
src/utils/index.ts
markActive
called by 7
src/utils/index.ts
getScrollTop
called by 6
src/utils/index.ts
active
called by 6
src/extensions/strong.tsx
getMenu
called by 5
src/components/smartblock.tsx
getMarkInSelection
called by 4
src/utils/index.ts

Shape

Method 272
Function 177
Class 64
Interface 14

Languages

TypeScript100%

Modules by API surface

src/utils/index.ts31 symbols
src/extensions/table/index.tsx20 symbols
src/extensions/image/index.tsx16 symbols
src/components/smartblock.tsx16 symbols
src/extensions/ordered-list.tsx15 symbols
src/extensions/code/index.tsx15 symbols
src/extensions/bullet-list.tsx15 symbols
src/extensions/heading6.tsx14 symbols
src/extensions/heading5.tsx14 symbols
src/extensions/heading4.tsx14 symbols
src/extensions/heading3.tsx14 symbols
src/extensions/embed/index.tsx14 symbols

For agents

$ claude mcp add smartblock \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact