Skip to content

Commit

Permalink
Custom editor example
Browse files Browse the repository at this point in the history
  • Loading branch information
gbisurgi committed Nov 15, 2024
1 parent a41a2ce commit 59c01e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src-docs/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
</template>

<script>
import EditorStringCustom from "./js/custom-editor.js";
import Jedi from '/src/index.js'
import all from './json/editors/all.json'
import array from './json/editors/array.json'
Expand Down Expand Up @@ -412,7 +415,7 @@ export default {
theme: this.getThemeInstance(this.theme),
refParser,
customEditors: [
// EditorStringCustom
EditorStringCustom
]
}
Expand Down
21 changes: 21 additions & 0 deletions src-docs/js/custom-editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Jedi from '../../src/index.js'

class EditorStringCustom extends Jedi.EditorNull {
static resolves (schema) {
const schemaType = Jedi.Schema.getSchemaType(schema)
const custom = Jedi.Schema.getSchemaXOption(schema, 'custom')
return schemaType === 'null' && Jedi.Utils.isSet(custom)
}

build () {
super.build()

const iframe = document.createElement('iframe')
iframe.src = 'https://json-schema.org/'
iframe.setAttribute('width', '100%')
iframe.setAttribute('height', '1000px')
this.control.container.appendChild(iframe)
}
}

export default EditorStringCustom

0 comments on commit 59c01e5

Please sign in to comment.