Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id='slateCanvas' style='width:100%;height:500px;border: 1px solid black;'></div>
              
            
!

CSS

              
                
              
            
!

JS

              
                import { Slatebox } from "https://cdn.skypack.dev/slateboxjs";

const s = new Slatebox.slate(
  {
    name: "New Slate",
    description: "",
    defaultLineColor: "#333",
    container: "slateCanvas",
    instance: "",
    basedOnThemeId: "",
    syncWithTheme: false,
    viewPort: {
      useInertiaScrolling: true,
      showGrid: false,
      snapToObjects: true,
      gridSize: 50,
      width: 50000,
      height: 50000,
      left: 25000,
      top: 25000
    },
    enabled: true,
    allowDrag: true,
    showbirdsEye: true,
    sizeOfbirdsEye: 150,
    showMultiSelect: false,
    showZoom: true,
    showUndoRedo: true,
    showStatus: true,
    showLocks: true,
    mindMapMode: true,
    isPublic: true,
    isUnlisted: false,
    autoEnableDefaultFilters: true,
    followMe: false,
    containerStyle: {
      backgroundColor: "",
      backgroundImage: "",
      backgroundSize: "",
      backgroundEffect: "",
      backgroundColorAsGradient: true,
      backgroundGradientType: "radial",
      backgroundGradientColors: ["#fff", "#333"],
      backgroundGradientStrategy: "shades"
    }
  },
  {
    onConfirmRequested: async (title, msg, cb) => {
      // implement confirmation dialog
    },
    onTakeSnapshot: async (opts) => {
      // implement slate snapshot
    },
    onTextPaneRequested: (node, cb) => {
      // implement text pane
    },
    onLineMenuRequested: (node, association, cb) => {
      // implement line menu request
    },
    onMenuRequested: (node, cb) => {
      // implement menu request
    },
    onBase64ImageRequested: (imgUrl, imageType, cb) => {
      // implement base64 image request
    },
    onOptimizeSVG: (svg, cb) => {
      // implement SVG optimization
    },
    isReadOnly: () => {
      // is the slate read only for this user?
      return false;
    },
    isCommentOnly: () => {
      // does the user have comment only access to this slate?
      return false;
    },
    canRemoveComments: () => {
      // can the user remove comments?
    },
    onThemeRequired: (opts, cb) => {
      // expirmental: provide a them in the cb
    }
  },
  {
    allow: true,
    localizedOnly: false,
    onCollaboration: async function (opts) {
      switch (opts.type) {
        case "process":
          // implement collab mechanism
          break;
        case "custom":
          switch (opts.pkg.type) {
            case "onSaveRequested":
              if (opts.pkg._id) {
                // implement explicit saving
                break;
              }
              break;
          }
      }
    }
  }
).init();

const nodes = [
  new Slatebox.node({
    id: "first_node",
    name: "first_node",
    text: "drag me",
    xPos: 25140,
    yPos: 25120,
    height: 60,
    width: 120,
    vectorPath: "roundedrectangle",
    backgroundColor: "#24A8E0",
    lineColor: "#333",
    lineWidth: 5,
    allowMenu: false
  }),
  new Slatebox.node({
    id: "second_node",
    name: "second_node",
    text: "drag me",
    xPos: 25300,
    yPos: 25250,
    height: 60,
    width: 120,
    vectorPath: "roundedrectangle",
    backgroundColor: "#24A8E0",
    lineColor: "#333",
    lineWidth: 5,
    allowMenu: false
  })
];

s.nodes.addRange(nodes);
nodes[0].relationships.addAssociation(nodes[1], {
  showChildArrow: true,
  showParentArrow: true
});

              
            
!
999px

Console