UNPKG

@blinkk/editor

Version:

Structured content editor with live previews.

83 lines 3.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const selective_edit_1 = require("@blinkk/selective-edit"); const document_1 = require("../projectType/amagaki/field/document"); const static_1 = require("../projectType/amagaki/field/static"); const string_1 = require("../projectType/amagaki/field/string"); const yaml_1 = require("../projectType/amagaki/field/yaml"); const aside_1 = require("../editor/field/aside"); const state_1 = require("../editor/state"); const exampleApi_1 = require("./exampleApi"); const exampleField_1 = require("./field/exampleField"); const exampleTool_1 = require("./exampleTool"); const document_2 = require("../projectType/grow/field/document"); const static_2 = require("../projectType/grow/field/static"); const string_2 = require("../projectType/grow/field/string"); const yaml_2 = require("../projectType/grow/field/yaml"); const editor_1 = require("../editor/editor"); const media_1 = require("../editor/field/media"); const mediaList_1 = require("../editor/field/mediaList"); const container = document.querySelector('.container'); const exampleApi = new exampleApi_1.ExampleApi(); const exampleState = new state_1.EditorState(exampleApi); const exampleEditor = new editor_1.LiveEditor({ api: exampleApi, selectiveConfig: { fieldTypes: { amagakiDocument: document_1.AmagakiDocumentField, amagakiStatic: static_1.AmagakiStaticField, amagakiString: string_1.AmagakiStringField, amagakiYaml: yaml_1.AmagakiYamlField, aside: aside_1.AsideField, checkbox: selective_edit_1.CheckboxField, checkboxMulti: selective_edit_1.CheckboxMultiField, color: selective_edit_1.ColorField, date: selective_edit_1.DateField, datetime: selective_edit_1.DatetimeField, exampleField: exampleField_1.ExampleFieldField, group: selective_edit_1.GroupField, growDocument: document_2.GrowDocumentField, growStatic: static_2.GrowStaticField, growString: string_2.GrowStringField, growYaml: yaml_2.GrowYamlField, list: selective_edit_1.ListField, media: media_1.MediaField, mediaList: mediaList_1.MediaListField, number: selective_edit_1.NumberField, radio: selective_edit_1.RadioField, text: selective_edit_1.TextField, textarea: selective_edit_1.TextareaField, time: selective_edit_1.TimeField, variant: selective_edit_1.VariantField, }, ruleTypes: { length: selective_edit_1.LengthRule, match: selective_edit_1.MatchRule, pattern: selective_edit_1.PatternRule, range: selective_edit_1.RangeRule, require: selective_edit_1.RequireRule, }, global: { api: exampleApi, labels: {}, state: exampleState, }, }, state: exampleState, }, container); const url = new URL(window.location.toString()); if (url.searchParams.get('path')) { exampleEditor.state.getFile({ path: url.searchParams.get('path') || '', }); } /** * Tool for working with the api through the UI. */ const toolContainer = document.querySelector('.example_tool'); const tool = new exampleTool_1.ExampleTool(exampleEditor.config.api, exampleEditor.storage, toolContainer); tool.render(); // Render the editor after the tool is created so that stored // error states can be loaded before the editor calls them. exampleEditor.render(); //# sourceMappingURL=example.js.map