Skip to content
Snippets Groups Projects
Commit 92a2514f authored by Giannis Kopanas's avatar Giannis Kopanas
Browse files

fix(services): add schema of inline Annotation

parent 1c12c8f8
No related branches found
No related tags found
1 merge request!45Develop
......@@ -3,14 +3,15 @@ import { emphasisMark } from "wax-prosemirror-schema";
import Emphasis from "./Emphasis";
class EmphasisService extends Service {
boot() {
const createMark = this.container.get("CreateMark");
createMark({ em: emphasisMark });
}
register() {
this.container.bind("Emphasis").to(Emphasis);
this.container
.bind("schema")
.toConstantValue({
em: emphasisMark
})
.whenTargetNamed("mark");
}
}
......
import { toggleMark } from "prosemirror-commands";
import { markActive, promptForURL } from "../../lib/Utils";
import Tools from "../../lib/Tools";
import { injectable } from "inversify";
import { icons } from "wax-prosemirror-components";
@injectable()
export default class Link extends Tools {
title = "Add or remove link";
content = icons.link;
get run() {
return (state, dispatch) => {
if (markActive(state.config.schema.marks.link)(state)) {
toggleMark(state.config.schema.marks.link)(state, dispatch);
return true;
}
const href = promptForURL();
if (!href) return false;
toggleMark(state.config.schema.marks.link, { href })(state, dispatch);
};
}
get enable() {
return state => !state.selection.empty;
}
get active() {
return state => {
return markActive(state.config.schema.marks.link)(state);
};
}
}
import Service from "wax-prosemirror-core/src/services/Service";
import { linkMark } from "wax-prosemirror-schema";
import Link from "./Link";
class LinkService extends Service {
boot() {
const createMark = this.container.get("CreateMark");
createMark({ link: linkMark });
}
register() {
this.container.bind("Link").to(Link);
}
}
export default LinkService;
......@@ -3,14 +3,15 @@ import { strongMark } from "wax-prosemirror-schema";
import Strong from "./Strong";
class StrongService extends Service {
boot() {
const createMark = this.container.get("CreateMark");
createMark({ strong: strongMark });
}
register() {
this.container.bind("Strong").to(Strong);
this.container
.bind("schema")
.toConstantValue({
strong: strongMark
})
.whenTargetNamed("mark");
}
}
......
import CodeService from "./CodeService/CodeService";
import StrongService from "./StrongService/StrongService";
import LinkService from "./LinkService/LinkService";
import EmphasisService from "./EmphasisService/EmphasisService";
export default [
new CodeService(),
new StrongService(),
new LinkService(),
new EmphasisService()
];
export default [new CodeService(), new StrongService(), new EmphasisService()];
import Service from "wax-prosemirror-core/src/services/Service";
import LinkComponent from "./LinkComponent";
import { linkMark } from "wax-prosemirror-schema";
import LinkTool from "./LinkTool";
export default class LinkService extends Service {
......@@ -12,37 +13,13 @@ export default class LinkService extends Service {
}
register() {
this.container.bind("Link").to(LinkTool);
this.container
.bind("schema")
.toConstantValue({
link: {
attrs: {
href: { default: null },
rel: { default: "" },
target: { default: "blank" },
title: { default: null }
},
inclusive: false,
parseDOM: {
tag: "a[href]",
getAttrs: (hook, next) => {
const href = hook.dom.getAttribute("href");
const target = href && href.indexOf("#") === 0 ? "" : "blank";
Object.assign(hook, {
href: hook.dom.getAttribute("href"),
title: hook.dom.getAttribute("title"),
target
});
next();
}
},
toDOM(hook, next) {
hook.value = ["a", node.attrs, 0];
next();
}
}
link: linkMark
})
.whenTargetNamed("mark");
this.container.bind("Link").to(LinkTool);
}
}
......@@ -10,7 +10,7 @@ import {
class Rules {
constructor(plugins, schema) {
this.PmPlugins = plugins;
debugger;
this.schema = schema;
this.extendedRules = this.allRules();
}
......@@ -42,7 +42,7 @@ class Rules {
wrappingInputRule(/^\s*([-+*])\s$/, this.schema.nodes.bullet_list),
// ``` code block
schema => textblockTypeInputRule(/^```$/, schema.nodes.code_block),
textblockTypeInputRule(/^```$/, this.schema.nodes.code_block),
// # heading
textblockTypeInputRule(
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment