Skip to content

Commit

Permalink
refactor: provide schema via secondary entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed Jan 24, 2021
1 parent 90d8236 commit 9dc6a98
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/lib/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
editable as editablePlugin,
placeholder as placeholderPlugin
} from 'ngx-editor/plugins';
import { isNil } from 'ngx-editor/utils';

import EditorCommands from './EditorCommands';
import defautlSchema from './schema';
import { parseContent } from './parsers';
import isNil from './utils/isNil';
import getDefaultPlugins from './defaultPlugins';

type Content = string | Record<string, any> | null;
Expand Down
14 changes: 2 additions & 12 deletions src/lib/schema.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
import { Schema } from 'prosemirror-model';

import nodes from './schema/nodes';
import marks from './schema/marks';

export { default as marks } from './schema/marks';
export { default as nodes } from './schema/nodes';

export const schema = new Schema({
marks,
nodes
});
import { schema } from 'ngx-editor/schema';

export { schema, marks, nodes } from 'ngx-editor/schema';
export default schema;
11 changes: 11 additions & 0 deletions src/schema/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Schema } from 'prosemirror-model';

import marks from './marks';
import nodes from './nodes';

const schema = new Schema({
marks,
nodes
});

export default schema;
4 changes: 2 additions & 2 deletions src/lib/schema/marks.ts → src/schema/marks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const textBackgroundColor: MarkSpec = {
},
};

const makrs = {
const marks = {
link,
em,
strong,
Expand All @@ -152,4 +152,4 @@ const makrs = {
text_background_color: textBackgroundColor
};

export default makrs;
export default marks;
2 changes: 1 addition & 1 deletion src/lib/schema/nodes.ts → src/schema/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DOMOutputSpec, Node as ProsemirrorNode, NodeSpec } from 'prosemirror-model';
import * as sl from 'prosemirror-schema-list';

import toStyleString from '../utils/toStyleString';
import { toStyleString } from 'ngx-editor/utils';

const doc: NodeSpec = {
content: 'block+'
Expand Down
11 changes: 11 additions & 0 deletions src/schema/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"ngPackage": {
"lib": {
"entryFile": "./public_api.ts",
"umdModuleIds": {
"prosemirror-model": "prosemirrorModel",
"prosemirror-schema-list": "prosemirrorSchemaList"
}
}
}
}
3 changes: 3 additions & 0 deletions src/schema/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default as marks } from './marks';
export { default as nodes } from './nodes';
export { default as schema } from './index';
File renamed without changes.
7 changes: 7 additions & 0 deletions src/utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ngPackage": {
"lib": {
"entryFile": "./public_api.ts"
}
}
}
2 changes: 2 additions & 0 deletions src/utils/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as isNil } from './isNil';
export { default as toStyleString } from './toStyleString';
File renamed without changes.
24 changes: 8 additions & 16 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,25 @@
"dist/ngx-editor/ngx-editor",
"dist/ngx-editor"
],
"ngx-editor/utils": [
"dist/ngx-editor/ngx-editor/utils",
"dist/ngx-editor/utils"
],
"ngx-editor/helpers": [
"dist/ngx-editor/ngx-editor/helpers",
"dist/ngx-editor/helpers"
],
"ngx-editor/schema": [
"dist/ngx-editor/ngx-editor/schema",
"dist/ngx-editor/schema"
],
"ngx-editor/commands": [
"dist/ngx-editor/ngx-editor/commands",
"dist/ngx-editor/commands"
],
"ngx-editor/history": [
"dist/ngx-editor/ngx-editor/history",
"dist/ngx-editor/history"
],
"ngx-editor/plugins": [
"dist/ngx-editor/ngx-editor/plugins",
"dist/ngx-editor/plugins"
],
"ngx-editor/keymap": [
"dist/ngx-editor/ngx-editor/keymap",
"dist/ngx-editor/keymap"
],
"ngx-editor/inputrules": [
"dist/ngx-editor/ngx-editor/inputrules",
"dist/ngx-editor/inputrules"
],
"ngx-editor/schema-list": [
"dist/ngx-editor/ngx-editor/schema-list",
"dist/ngx-editor/schema-list"
]
}
},
Expand Down

0 comments on commit 9dc6a98

Please sign in to comment.