-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
script mode #24
Comments
|
https://glitch.com/~adaptable-linseed // global createMachine
let clicks = 0;
const script = document.getElementById("script");
script.onkeydown = event => {
if (event.key !== "Tab") {
return;
}
event.preventDefault();
document.execCommand("formatBlock", false, "div");
let myClass;
if (clicks % 2 === 0) {
myClass = "character";
}
else {
myClass = "title";
}
const quote = window.getSelection().focusNode.parentNode;
quote.classList = myClass;
clicks += 1;
}; |
this seems to cover basic shuffling of components: // from: http://www.writingroom.com/viewwriting/wr_how_to/How-To-Format-A-Screenplay
const screenplayComponents = [
"heading",
"action",
"character",
"dialogue",
"parenthetical",
"transition"
];
// get the screenplay component after the current
// next("action") -> "character"
function next(screenplayComponent) {
const index = screenplayComponents.indexOf(screenplayComponent);
if (index === -1) {
return screenplayComponents[0];
}
return screenplayComponents[(index + 1) % screenplayComponents.length];
}
// get the screenplay component before the current
// previous("action") -> "header"
function previous(screenplayComponent) {
const index = screenplayComponents.indexOf(screenplayComponent);
if (index === -1) {
return screenplayComponents[0];
}
return screenplayComponents[(index + screenplayComponents.length - 1) % screenplayComponents.length];
}
function getActiveElement() {
let focused = window.getSelection().focusNode;
return focused.nodeName === "#text" ? focused.parentNode : focused;
}
const script = document.getElementById("script");
script.onkeydown = event => {
if (!event.shiftKey && event.key === "Tab") {
event.preventDefault();
nextStyle();
}
if (event.shiftKey && event.key == "Tab") {
event.preventDefault();
prevStyle();
}
};
function nextStyle() {
document.execCommand("formatBlock", false, "p");
const activeElement = getActiveElement();
const nextScreenplayComponent = next(activeElement.className);
activeElement.classList = nextScreenplayComponent;
}
function prevStyle() {
document.execCommand("formatBlock", false, "p");
const activeElement = getActiveElement();
const nextScreenplayComponent = previous(activeElement.className);
activeElement.classList = nextScreenplayComponent;
} ideally server would deserialize from submit, like: [
Line("i am writing a normal text here"),
Line(""),
Line("i am about to start my script"),
Heading("ext. daytime. outside."),
Action("A person walks down the road. A gust of wind blows by."),
Character("Narrator"),
Parenthetical("(dramatically)"),
Dialogue("Nothing is as it seems...")
] but would probably? still store in the db as a text blob, maybe adding back some type of
then when rendering out to html, the array of line/heading/etc would be render to html |
the main thing for me is: most of the time we want a turn in the db to just look like:
and ideally that'd be represented simply like
but i want some optional markup to be in there, at first for script writing, in a way that's not a pain in the ass |
also, obviously i want to make sure it's not a problem if someone writes in their turn, in plaintext:
|
v1
|
need to fix:
|
s/Line/Text |
i'm leaning more towards having each part in the db.
|
i want to be able to enable script mode when writing, which converts my textarea into a simple, user-friendly writer with screenplay formatting.
simple ui/ux like:
ideal requirements:
impl:
The text was updated successfully, but these errors were encountered: